1 | # $Id: Makefile.kmk 2652 2012-09-09 17:21:48Z bird $
|
---|
2 | ## @file
|
---|
3 | # Sub-makefile for kash.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2005-2010 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 |
|
---|
26 | SUB_DEPTH = ../..
|
---|
27 | include $(KBUILD_PATH)/subheader.kmk
|
---|
28 |
|
---|
29 | #
|
---|
30 | # The program.
|
---|
31 | #
|
---|
32 | PROGRAMS += kash
|
---|
33 | kash_TEMPLATE = BIN-THREADED
|
---|
34 | kash_NAME = kmk_ash
|
---|
35 | kash_ASTOOL = YASM
|
---|
36 | kash_DEFS = lint SHELL SMALL
|
---|
37 | kash_DEFS += SH_FORKED_MODE
|
---|
38 | kash_DEFS.debug = DEBUG=2
|
---|
39 | kash_DEFS.haiku = BSD
|
---|
40 | kash_DEFS.linux = BSD
|
---|
41 | kash_DEFS.solaris = BSD
|
---|
42 | ## @todo bring over PC_SLASHES?
|
---|
43 | kash_DEFS.win = \
|
---|
44 | BSD YY_NO_UNISTD_H \
|
---|
45 | SH_DEAL_WITH_CRLF PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS EXEC_HASH_BANG_SCRIPT
|
---|
46 | kash_DEFS.os2 = \
|
---|
47 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME PC_OS2_LIBPATHS \
|
---|
48 | SH_DEAL_WITH_CRLF PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS EXEC_HASH_BANG_SCRIPT
|
---|
49 | kash_DEFS.darwin = \
|
---|
50 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
|
---|
51 | kash_DEFS.dragonfly = \
|
---|
52 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
|
---|
53 | kash_DEFS.freebsd = \
|
---|
54 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
|
---|
55 | kash_DEFS.openbsd = \
|
---|
56 | HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
|
---|
57 | kash_INCS = $(kash_0_OUTDIR) . # (the last is because of error.h)
|
---|
58 | kash_ASFLAGS.win = -g cv8
|
---|
59 | kash_ASFLAGS.win.x86 = -f win32
|
---|
60 | kash_ASFLAGS.win.amd64 = -f win64
|
---|
61 | if "$(USER)" == "bird" && "$(KBUILD_TARGET)" != "win"
|
---|
62 | kash_CFLAGS += -std=gnu99
|
---|
63 | endif
|
---|
64 | kash_CFLAGS.win.amd64 = -GS-
|
---|
65 | kash_LDFLAGS.win = -DYNAMICBASE:NO
|
---|
66 | kash_SOURCES = \
|
---|
67 | main.c \
|
---|
68 | alias.c \
|
---|
69 | cd.c \
|
---|
70 | error.c \
|
---|
71 | eval.c \
|
---|
72 | exec.c \
|
---|
73 | expand.c \
|
---|
74 | histedit.c \
|
---|
75 | input.c \
|
---|
76 | jobs.c \
|
---|
77 | mail.c \
|
---|
78 | memalloc.c \
|
---|
79 | mystring.c \
|
---|
80 | options.c \
|
---|
81 | output.c \
|
---|
82 | parser.c \
|
---|
83 | redir.c \
|
---|
84 | show.c \
|
---|
85 | syntax.c \
|
---|
86 | trap.c \
|
---|
87 | var.c \
|
---|
88 | miscbltin.c \
|
---|
89 | bltin/echo.c \
|
---|
90 | bltin/kill.c \
|
---|
91 | bltin/test.c \
|
---|
92 | \
|
---|
93 | $(kash_0_OUTDIR)/builtins.c \
|
---|
94 | $(kash_0_OUTDIR)/init.c \
|
---|
95 | $(kash_0_OUTDIR)/nodes.c \
|
---|
96 | \
|
---|
97 | setmode.c \
|
---|
98 | shinstance.c \
|
---|
99 | shheap.c \
|
---|
100 | shthread.c \
|
---|
101 | shfile.c
|
---|
102 | kash_SOURCES.haiku = \
|
---|
103 | sys_signame.c \
|
---|
104 | strlcpy.c
|
---|
105 | kash_SOURCES.linux = \
|
---|
106 | sys_signame.c \
|
---|
107 | strlcpy.c
|
---|
108 | kash_SOURCES.solaris = \
|
---|
109 | sys_signame.c \
|
---|
110 | strlcpy.c
|
---|
111 | kash_SOURCES.win = \
|
---|
112 | sys_signame.c \
|
---|
113 | strlcpy.c \
|
---|
114 | shfork-win.c \
|
---|
115 | shforkA-win.asm
|
---|
116 |
|
---|
117 | kash_INTERMEDIATES = \
|
---|
118 | $(kash_0_OUTDIR)/builtins.h \
|
---|
119 | $(kash_0_OUTDIR)/nodes.h \
|
---|
120 | $(kash_0_OUTDIR)/token.h
|
---|
121 | kash_CLEAN = \
|
---|
122 | $(kash_INTERMEDIATES) \
|
---|
123 | $(kash_0_OUTDIR)/builtins.c \
|
---|
124 | $(kash_0_OUTDIR)/init.c \
|
---|
125 | $(kash_0_OUTDIR)/nodes.c
|
---|
126 |
|
---|
127 | kash_main.c_DEFS = KBUILD_SVN_REV=$(KBUILD_SVN_REV)
|
---|
128 |
|
---|
129 | ##
|
---|
130 | ## The manual page.
|
---|
131 | ##
|
---|
132 | #INSTALLS += kash.man
|
---|
133 | #kash.man_TEMPLATE = usr.bin.man
|
---|
134 | #kash.man_SOURCES = sh.1=>kash.1
|
---|
135 |
|
---|
136 |
|
---|
137 | if1of ($(KBUILD_TARGET), win os2)
|
---|
138 |
|
---|
139 | #
|
---|
140 | # Use the pregenerated code.
|
---|
141 | #
|
---|
142 | kash_SOURCES += \
|
---|
143 | $(kash_0_OUTDIR)/arith.c \
|
---|
144 | $(kash_0_OUTDIR)/arith_lex.c
|
---|
145 | kash_INTERMEDIATES += \
|
---|
146 | $(kash_0_OUTDIR)/arith.h
|
---|
147 |
|
---|
148 | define def_copy_generated
|
---|
149 | $$$$(kash_0_OUTDIR)/$(src): $(PATH_SUB_CURRENT)/generated/$(src)
|
---|
150 | $$(RM) -f $$@
|
---|
151 | $$(CP) -f $$^ $$@
|
---|
152 | endef
|
---|
153 |
|
---|
154 | $(foreach src, arith.h arith.c arith_lex.c builtins.h builtins.c nodes.h nodes.c token.h init.c,\
|
---|
155 | $(eval $(def_copy_generated)))
|
---|
156 |
|
---|
157 | else
|
---|
158 |
|
---|
159 | #
|
---|
160 | # Generate the code on the fly.
|
---|
161 | #
|
---|
162 |
|
---|
163 | USES += lex yacc
|
---|
164 | kash_USES = lex yacc
|
---|
165 | kash_LEXTOOL = FLEX
|
---|
166 | kash_LEXFLAGS = -8
|
---|
167 | #kash_YACCTOOL = BISON
|
---|
168 | kash_YACCTOOL = YACC
|
---|
169 | kash_YACCFLAGS = -ld
|
---|
170 | kash_SOURCES += \
|
---|
171 | arith.y \
|
---|
172 | arith_lex.l
|
---|
173 |
|
---|
174 | #
|
---|
175 | # ATTENTION! ATTENTION! ATTENTION!
|
---|
176 | #
|
---|
177 | # Older ash versions has trouble with some of these scripts, great.
|
---|
178 | # Kudos to the NetBSD guys for this clever move. ;)
|
---|
179 | #
|
---|
180 | # So, when building for the frist time, setting BOOSTRAP_SHELL=/bin/bash is good idea.
|
---|
181 | #
|
---|
182 | BOOTSTRAP_SHELL ?= $(SHELL)
|
---|
183 |
|
---|
184 | $$(kash_0_OUTDIR)/builtins.h + $$(kash_0_OUTDIR)/builtins.c: \
|
---|
185 | $$(kash_DEFPATH)/mkbuiltins \
|
---|
186 | $$(kash_DEFPATH)/shell.h \
|
---|
187 | $$(kash_DEFPATH)/builtins.def \
|
---|
188 | | $$(dir $$@)
|
---|
189 | $(BOOTSTRAP_SHELL) $+ $(dir $@)
|
---|
190 | [ -f $(kash_0_OUTDIR)/builtins.h ]
|
---|
191 |
|
---|
192 | $$(kash_0_OUTDIR)/nodes.h + $$(kash_0_OUTDIR)/nodes.c: \
|
---|
193 | $$(kash_DEFPATH)/mknodes.sh \
|
---|
194 | $$(kash_DEFPATH)/nodetypes \
|
---|
195 | $$(kash_DEFPATH)/nodes.c.pat \
|
---|
196 | | $$(dir $$@)
|
---|
197 | $(BOOTSTRAP_SHELL) $+ $(dir $@)
|
---|
198 | [ -f $(dir $@)/nodes.h ]
|
---|
199 |
|
---|
200 | $$(kash_0_OUTDIR)/token.h: $$(kash_DEFPATH)/mktokens | $$(dir $$@)
|
---|
201 | $(BOOTSTRAP_SHELL) $+
|
---|
202 | $(MV) token.h $@
|
---|
203 |
|
---|
204 | $$(kash_0_OUTDIR)/init.c: \
|
---|
205 | $$(kash_DEFPATH)/mkinit.sh \
|
---|
206 | $$(abspathex $$(filter-out $$(kash_0_OUTDIR)/%,$$(kash_SOURCES)), $$(kash_DEFPATH)) \
|
---|
207 | | $$(dir $$@)
|
---|
208 | $(BOOTSTRAP_SHELL) $+
|
---|
209 | $(MV) init.c $@
|
---|
210 |
|
---|
211 | endif
|
---|
212 |
|
---|
213 | #
|
---|
214 | # For debugging file handle inheritance on Windows.
|
---|
215 | #
|
---|
216 | if "$(KBUILD_TARGET)" == win && 0
|
---|
217 | PROGRAMS += tstDump
|
---|
218 | tstDump_TEMPLATE = BIN
|
---|
219 | tstDump_SOURCES = tstDump.c
|
---|
220 | endif
|
---|
221 |
|
---|
222 | # Include the sub-makefile.
|
---|
223 | include $(PATH_SUB_CURRENT)/tests/Makefile.kmk
|
---|
224 |
|
---|
225 | include $(FILE_KBUILD_SUB_FOOTER)
|
---|
226 |
|
---|
227 |
|
---|