blob: f0e6e665b4a2444e56b8278432c76b338ccb3cc4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# $Id: Makefile.kmk 3477 2020-09-17 21:52:16Z bird $
## @file
# Sub-makefile for kash.
#
#
# Copyright (c) 2005-2020 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
#
# This file is part of kBuild.
#
# kBuild is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# kBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with kBuild. If not, see <http://www.gnu.org/licenses/>
#
#
SUB_DEPTH = ../..
include $(KBUILD_PATH)/subheader.kmk
KASH_WIN_FORKED_MODE =
#
# The program.
#
PROGRAMS += kash
kash_TEMPLATE = BIN-THREADED
kash_NAME = kmk_ash
kash_ASTOOL = YASM
kash_DEFS = lint SHELL SMALL KASH_SEPARATE_PARSER_ALLOCATOR
if "$(KBUILD_TARGET)" != "win" || defined(KASH_WIN_FORKED_MODE)
kash_DEFS += SH_FORKED_MODE
else
kash_DEFS += KASH_SEPARATE_PARSER_ALLOCATOR KASH_ASYNC_CLOSE_HANDLE
endif
kash_DEFS.debug = DEBUG=2 K_STRICT
kash_DEFS.haiku = BSD
kash_DEFS.linux = BSD
kash_DEFS.solaris = BSD
## @todo bring over PC_SLASHES?
kash_DEFS.win = \
BSD YY_NO_UNISTD_H \
SH_DEAL_WITH_CRLF PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS EXEC_HASH_BANG_SCRIPT \
KASH_USE_FORKSHELL2
kash_DEFS.os2 = \
HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME PC_OS2_LIBPATHS \
SH_DEAL_WITH_CRLF PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS EXEC_HASH_BANG_SCRIPT
kash_DEFS.darwin = \
HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
kash_DEFS.dragonfly = \
HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
kash_DEFS.freebsd = \
HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
kash_DEFS.gnukfbsd = HAVE_SYSCTL_H
kash_DEFS.netbsd = \
HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
kash_DEFS.openbsd = \
HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
kash_INCS = $(kash_0_OUTDIR) . # (the last is because of error.h)
kash_ASFLAGS.win = -g cv8
kash_ASFLAGS.win.x86 = -f win32
kash_ASFLAGS.win.amd64 = -f win64
if "$(USER)" == "bird" && "$(KBUILD_TARGET)" != "win"
kash_CFLAGS += -std=gnu99
endif
kash_CFLAGS.win.amd64 = -GS-
ifdef KASH_WIN_FORKED_MODE
kash_LDFLAGS.win = -DYNAMICBASE:NO
endif
kash_SOURCES = \
main.c \
alias.c \
cd.c \
error.c \
eval.c \
exec.c \
expand.c \
histedit.c \
input.c \
jobs.c \
mail.c \
memalloc.c \
mystring.c \
options.c \
output.c \
parser.c \
redir.c \
show.c \
syntax.c \
trap.c \
var.c \
miscbltin.c \
bltin/echo.c \
bltin/kill.c \
bltin/test.c \
\
$(kash_0_OUTDIR)/builtins.c \
$(kash_0_OUTDIR)/init.c \
$(kash_0_OUTDIR)/nodes.c \
\
setmode.c \
shinstance.c \
shheap.c \
shthread.c \
shfile.c
kash_SOURCES.gnuhurd = \
$(kash_0_OUTDIR)/sys_signame.c \
strlcpy.c
kash_SOURCES.gnukfbsd = \
$(kash_0_OUTDIR)/sys_signame.c \
strlcpy.c
kash_SOURCES.gnuknbsd = \
$(kash_0_OUTDIR)/sys_signame.c \
strlcpy.c
kash_SOURCES.haiku = \
$(kash_0_OUTDIR)/sys_signame.c \
strlcpy.c
kash_SOURCES.linux = \
$(kash_0_OUTDIR)/sys_signame.c \
strlcpy.c
kash_SOURCES.solaris = \
$(kash_0_OUTDIR)/sys_signame.c \
strlcpy.c
kash_SOURCES.win = \
$(kash_0_OUTDIR)/sys_signame.c \
strsignal.c \
strlcpy.c \
../lib/nt/ntstat.c \
../lib/nt/nthlpcore.c \
../lib/nt/nthlpfs.c \
../lib/nt/nt_child_inject_standard_handles.c
ifdef KASH_WIN_FORKED_MODE
kash_SOURCES.win += \
shfork-win.c \
shforkA-win.asm
endif
kash_INTERMEDIATES = \
$(kash_0_OUTDIR)/builtins.h \
$(kash_0_OUTDIR)/nodes.h \
$(kash_0_OUTDIR)/token.h
kash_CLEAN = \
$(kash_INTERMEDIATES) \
$(kash_0_OUTDIR)/builtins.c \
$(kash_0_OUTDIR)/init.c \
$(kash_0_OUTDIR)/nodes.c
kash_main.c_DEFS = KBUILD_SVN_REV=$(KBUILD_SVN_REV)
##
## The manual page.
##
#INSTALLS += kash.man
#kash.man_TEMPLATE = usr.bin.man
#kash.man_SOURCES = sh.1=>kash.1
#
# The signal name list:
#
$$(kash_0_OUTDIR)/sys_signame.c: $$(bld_signames_1_TARGET) | $$(dir $$@)
$< $@
BLDPROGS += bld_signames
bld_signames_TEMPLATE := BLD
bld_signames_DEFS := SHELL SMALL
bld_signames_SOURCES := bld_signames.c
if1of ($(KBUILD_TARGET), win os2)
KASH_USE_PREGENERATED_CODE = 1
endif
ifdef KASH_USE_PREGENERATED_CODE
#
# Use the pregenerated code.
#
kash_SOURCES += \
$(kash_0_OUTDIR)/arith.c \
$(kash_0_OUTDIR)/arith_lex.c
kash_INTERMEDIATES += \
$(kash_0_OUTDIR)/arith.h
define def_copy_generated
$$$$(kash_0_OUTDIR)/$(src): $(PATH_SUB_CURRENT)/generated/$(src)
$$(RM) -f $$@
$$(CP) -f $$^ $$@
endef
$(foreach src, arith.h arith.c arith_lex.c builtins.h builtins.c nodes.h nodes.c token.h init.c,\
$(eval $(def_copy_generated)))
else # !KASH_USE_PREGENERATED_CODE
#
# Generate the code on the fly.
#
USES += lex yacc
kash_USES = lex yacc
kash_LEXTOOL = FLEX
kash_LEXFLAGS = -8
#kash_YACCTOOL = BISON
kash_YACCTOOL = YACC
kash_YACCFLAGS = -ld
kash_SOURCES += \
arith.y \
arith_lex.l
#
# ATTENTION! ATTENTION! ATTENTION!
#
# Older ash versions has trouble with some of these scripts, great.
# Kudos to the NetBSD guys for this clever move. ;)
#
# So, when building for the frist time, setting BOOSTRAP_SHELL=/bin/bash is good idea.
#
BOOTSTRAP_SHELL ?= $(SHELL)
$$(kash_0_OUTDIR)/builtins.h + $$(kash_0_OUTDIR)/builtins.c: \
$$(kash_DEFPATH)/mkbuiltins \
$$(kash_DEFPATH)/shell.h \
$$(kash_DEFPATH)/builtins.def \
| $$(dir $$@)
$(BOOTSTRAP_SHELL) $+ $(dir $@)
[ -f $(kash_0_OUTDIR)/builtins.h ]
$$(kash_0_OUTDIR)/nodes.h + $$(kash_0_OUTDIR)/nodes.c: \
$$(kash_DEFPATH)/mknodes.sh \
$$(kash_DEFPATH)/nodetypes \
$$(kash_DEFPATH)/nodes.c.pat \
| $$(dir $$@)
$(BOOTSTRAP_SHELL) $+ $(dir $@)
[ -f $(dir $@)/nodes.h ]
$$(kash_0_OUTDIR)/token.h: $$(kash_DEFPATH)/mktokens | $$(dir $$@)
$(BOOTSTRAP_SHELL) $+
$(MV) token.h $@
$$(kash_0_OUTDIR)/init.c: \
$$(kash_DEFPATH)/mkinit.sh \
$$(abspathex $$(filter-out $$(kash_0_OUTDIR)/%,$$(kash_SOURCES)), $$(kash_DEFPATH)) \
| $$(dir $$@)
$(BOOTSTRAP_SHELL) $+
$(MV) init.c $@
endif # !KASH_USE_PREGENERATED_CODE
#
# For debugging file handle inheritance on Windows.
#
if "$(KBUILD_TARGET)" == win && 0
PROGRAMS += tstDump
tstDump_TEMPLATE = BIN
tstDump_SOURCES = tstDump.c
endif
# Include the sub-makefile.
include $(PATH_SUB_CURRENT)/tests/Makefile.kmk
include $(FILE_KBUILD_SUB_FOOTER)
|