VirtualBox

source: kBuild/trunk/src/kash/Makefile.kmk

Last change on this file was 3477, checked in by bird, 4 years ago

kash: Use kHlpAssert instead of assert.h (debugger stops on the assertion rather than at exit process code).

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette