1 | # $Id: Makefile.kmk 986 2007-05-29 02:59:06Z bird $
|
---|
2 |
|
---|
3 |
|
---|
4 | DEPTH = ../..
|
---|
5 | include $(PATH_KBUILD)/header.kmk
|
---|
6 |
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Template for kmk and the kmk_* binaries in this makefile.
|
---|
10 | #
|
---|
11 | TEMPLATE_BIN-KMK = Template for src/gmake binaries
|
---|
12 | TEMPLATE_BIN-KMK_EXTENDS = BIN
|
---|
13 | TEMPLATE_BIN-KMK_DEFS = HAVE_CONFIG_H $(TEMPLATE_BIN_DEFS)
|
---|
14 | TEMPLATE_BIN-KMK_DEPS = $(PATH_TARGET)/config.h
|
---|
15 | TEMPLATE_BIN-KMK_CLEAN = $(TEMPLATE_BIN-KMK_DEPS)
|
---|
16 | TEMPLATE_BIN-KMK_DEPS.solaris = \
|
---|
17 | $(PATH_TARGET)/fts.h \
|
---|
18 | $(PATH_TARGET)/paths.h
|
---|
19 | TEMPLATE_BIN-KMK_CLEAN.solaris = $(TEMPLATE_BIN-KMK_DEPS.solaris)
|
---|
20 | TEMPLATE_BIN-KMK_DEPS.win = \
|
---|
21 | $(PATH_TARGET)/fts.h \
|
---|
22 | $(PATH_TARGET)/sysexits.h \
|
---|
23 | $(PATH_TARGET)/unistd.h \
|
---|
24 | $(PATH_TARGET)/paths.h \
|
---|
25 | $(PATH_TARGET)/grp.h \
|
---|
26 | $(PATH_TARGET)/pwd.h \
|
---|
27 | $(PATH_TARGET)/inttypes.h
|
---|
28 | TEMPLATE_BIN-KMK_CLEAN.win = $(TEMPLATE_BIN-KMK_DEPS.win)
|
---|
29 | TEMPLATE_BIN-KMK_INCS = $(PATH_TARGET) . $(TEMPLATE_BIN_INCS)
|
---|
30 | TEMPLATE_BIN-KMK_INCS.darwin = glob
|
---|
31 | TEMPLATE_BIN-KMK_INCS.freebsd = glob
|
---|
32 | TEMPLATE_BIN-KMK_INCS.solaris = glob
|
---|
33 | TEMPLATE_BIN-KMK_LIBS = $(TEMPLATE_BIN_LIBS) $(TARGET_kmkmissing)
|
---|
34 | ifdef ELECTRIC_HEAP # for electric heap (see electric.c) - windows only.
|
---|
35 | TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) /FI$(PATH_CURRENT)/electric.h -DELECTRIC_HEAP=1
|
---|
36 | endif
|
---|
37 |
|
---|
38 |
|
---|
39 | #
|
---|
40 | # A library containing the missing features needed by kmk and the
|
---|
41 | # kmk_* binaries. Saves a bit of work later on.
|
---|
42 | #
|
---|
43 | LIBRARIES += kmkmissing
|
---|
44 | kmkmissing_TEMPLATE = BIN-KMK
|
---|
45 | kmkmissing_NOINST = 1
|
---|
46 | kmkmissing_SOURCES = \
|
---|
47 | kmkbuiltin/err.c \
|
---|
48 | kmkbuiltin/setmode.c \
|
---|
49 | kmkbuiltin/strmode.c \
|
---|
50 | kmkbuiltin/strlcpy.c \
|
---|
51 | getopt.c \
|
---|
52 | getopt1.c \
|
---|
53 | electric.c
|
---|
54 |
|
---|
55 | kmkmissing_SOURCES.darwin = \
|
---|
56 | kmkbuiltin/darwin.c \
|
---|
57 | glob/glob.c \
|
---|
58 | glob/fnmatch.c
|
---|
59 |
|
---|
60 | kmkmissing_SOURCES.freebsd = \
|
---|
61 | glob/glob.c \
|
---|
62 | glob/fnmatch.c
|
---|
63 |
|
---|
64 | kmkmissing_SOURCES.solaris = \
|
---|
65 | kmkbuiltin/solfakes.c \
|
---|
66 | kmkbuiltin/fts.c \
|
---|
67 | glob/glob.c \
|
---|
68 | glob/fnmatch.c
|
---|
69 |
|
---|
70 | kmkmissing_SOURCES.win += \
|
---|
71 | kmkbuiltin/mscfakes.c \
|
---|
72 | kmkbuiltin/fts.c \
|
---|
73 | glob/glob.c \
|
---|
74 | glob/fnmatch.c \
|
---|
75 | getloadavg.c \
|
---|
76 | w32/subproc/misc.c \
|
---|
77 | w32/subproc/sub_proc.c \
|
---|
78 | w32/subproc/w32err.c \
|
---|
79 | w32/compat/dirent.c \
|
---|
80 | w32/pathstuff.c
|
---|
81 |
|
---|
82 | #
|
---|
83 | # kmk
|
---|
84 | #
|
---|
85 | PROGRAMS += kmk
|
---|
86 |
|
---|
87 | kmk_TEMPLATE = BIN-KMK
|
---|
88 |
|
---|
89 | kmk_DEFS = \
|
---|
90 | NO_ARCHIVES \
|
---|
91 | EXPERIMENTAL \
|
---|
92 | CONFIG_WITH_TOUPPER_TOLOWER \
|
---|
93 | CONFIG_WITH_EXPLICIT_MULTITARGET \
|
---|
94 | CONFIG_WITH_PREPEND_ASSIGNMENT \
|
---|
95 | \
|
---|
96 | KMK \
|
---|
97 | KMK_HELPERS \
|
---|
98 | VARIABLE_HASH \
|
---|
99 | CONFIG_NO_DEFAULT_SUFFIXES \
|
---|
100 | CONFIG_NO_DEFAULT_PATTERN_RULES \
|
---|
101 | CONFIG_NO_DEFAULT_TERMINAL_RULES \
|
---|
102 | CONFIG_NO_DEFAULT_SUFFIX_RULES \
|
---|
103 | CONFIG_NO_DEFAULT_VARIABLES \
|
---|
104 | CONFIG_WITH_EXTENDED_NOTPARALLEL \
|
---|
105 | CONFIG_WITH_INCLUDEDEP \
|
---|
106 | CONFIG_WITH_VALUE_LENGTH \
|
---|
107 | CONFIG_WITH_RSORT \
|
---|
108 | CONFIG_WITH_ABSPATHEX \
|
---|
109 | CONFIG_WITH_COMPARE \
|
---|
110 | CONFIG_WITH_STACK \
|
---|
111 | CONFIG_WITH_MATH \
|
---|
112 | CONFIG_WITH_XARGS \
|
---|
113 | CONFIG_WITH_NANOTS \
|
---|
114 | CONFIG_PRETTY_COMMAND_PRINTING \
|
---|
115 | \
|
---|
116 | BUILD_PLATFORM=\"$(BUILD_TARGET)\" \
|
---|
117 | BUILD_PLATFORM_ARCH=\"$(BUILD_TARGET_ARCH)\" \
|
---|
118 | BUILD_PLATFORM_CPU=\"$(BUILD_TARGET_CPU)\"
|
---|
119 | kmk_DEFS.x86 = CONFIG_WITH_OPTIMIZATION_HACKS
|
---|
120 | kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS
|
---|
121 | kmk_DEFS.win.x86 = \
|
---|
122 | CONFIG_NEW_WIN32_CTRL_EVENT
|
---|
123 |
|
---|
124 | kmk_SOURCES = \
|
---|
125 | main.c \
|
---|
126 | read.c \
|
---|
127 | hash.c \
|
---|
128 | strcache.c \
|
---|
129 | variable.c \
|
---|
130 | ar.c \
|
---|
131 | arscan.c \
|
---|
132 | commands.c \
|
---|
133 | default.c \
|
---|
134 | dir.c \
|
---|
135 | expand.c \
|
---|
136 | file.c \
|
---|
137 | function.c \
|
---|
138 | implicit.c \
|
---|
139 | job.c \
|
---|
140 | misc.c \
|
---|
141 | remake.c \
|
---|
142 | rule.c \
|
---|
143 | signame.c \
|
---|
144 | version.c \
|
---|
145 | vpath.c \
|
---|
146 | remote-stub.c \
|
---|
147 | kbuild.c
|
---|
148 |
|
---|
149 | #
|
---|
150 | # kmkbuiltin commands
|
---|
151 | #
|
---|
152 | kmk_DEFS += CONFIG_WITH_KMK_BUILTIN
|
---|
153 | kmk_SOURCES += \
|
---|
154 | kmkbuiltin.c \
|
---|
155 | kmkbuiltin/append.c \
|
---|
156 | kmkbuiltin/cat.c \
|
---|
157 | kmkbuiltin/cp.c \
|
---|
158 | kmkbuiltin/cp_utils.c \
|
---|
159 | kmkbuiltin/echo.c \
|
---|
160 | kmkbuiltin/install.c \
|
---|
161 | kmkbuiltin/mkdir.c \
|
---|
162 | kmkbuiltin/mv.c \
|
---|
163 | kmkbuiltin/ln.c \
|
---|
164 | kmkbuiltin/printf.c \
|
---|
165 | kmkbuiltin/rm.c \
|
---|
166 | kmkbuiltin/rmdir.c \
|
---|
167 |
|
---|
168 |
|
---|
169 | #
|
---|
170 | # Standalone kmkbuiltin commands.
|
---|
171 | #
|
---|
172 | ## @todo should probably put all those
|
---|
173 | PROGRAMS += kmk_append kmk_cat kmk_cp kmk_echo kmk_mkdir kmk_mv kmk_install kmk_ln kmk_printf kmk_rm kmk_rmdir
|
---|
174 |
|
---|
175 | kmk_append_TEMPLATE = BIN-KMK
|
---|
176 | kmk_append_DEFS = kmk_builtin_append=main
|
---|
177 | kmk_append_INCS = .
|
---|
178 | kmk_append_SOURCES = \
|
---|
179 | kmkbuiltin/append.c
|
---|
180 |
|
---|
181 | kmk_cat_TEMPLATE = BIN-KMK
|
---|
182 | kmk_cat_DEFS = kmk_builtin_cat=main
|
---|
183 | kmk_cat_SOURCES = \
|
---|
184 | kmkbuiltin/cat.c
|
---|
185 |
|
---|
186 | kmk_cp_TEMPLATE = BIN-KMK
|
---|
187 | kmk_cp_DEFS = kmk_builtin_cp=main
|
---|
188 | kmk_cp_SOURCES = \
|
---|
189 | kmkbuiltin/cp.c \
|
---|
190 | kmkbuiltin/cp_utils.c
|
---|
191 |
|
---|
192 | kmk_echo_TEMPLATE = BIN-KMK
|
---|
193 | kmk_echo_DEFS = kmk_builtin_echo=main
|
---|
194 | kmk_echo_SOURCES = \
|
---|
195 | kmkbuiltin/echo.c
|
---|
196 |
|
---|
197 | kmk_install_TEMPLATE = BIN-KMK
|
---|
198 | kmk_install_DEFS = kmk_builtin_install=main
|
---|
199 | kmk_install_SOURCES = \
|
---|
200 | kmkbuiltin/install.c
|
---|
201 |
|
---|
202 | kmk_ln_TEMPLATE = BIN-KMK
|
---|
203 | kmk_ln_DEFS = kmk_builtin_ln=main
|
---|
204 | kmk_ln_SOURCES = \
|
---|
205 | kmkbuiltin/ln.c
|
---|
206 |
|
---|
207 | kmk_mkdir_TEMPLATE = BIN-KMK
|
---|
208 | kmk_mkdir_DEFS = kmk_builtin_mkdir=main
|
---|
209 | kmk_mkdir_SOURCES = \
|
---|
210 | kmkbuiltin/mkdir.c
|
---|
211 |
|
---|
212 | kmk_mv_TEMPLATE = BIN-KMK
|
---|
213 | kmk_mv_DEFS = kmk_builtin_mv=main
|
---|
214 | kmk_mv_SOURCES = \
|
---|
215 | kmkbuiltin/mv.c
|
---|
216 |
|
---|
217 | kmk_printf_TEMPLATE = BIN-KMK
|
---|
218 | kmk_printf_DEFS = kmk_builtin_printf=main
|
---|
219 | kmk_printf_SOURCES = \
|
---|
220 | kmkbuiltin/printf.c
|
---|
221 |
|
---|
222 | kmk_rm_TEMPLATE = BIN-KMK
|
---|
223 | kmk_rm_DEFS = kmk_builtin_rm=main
|
---|
224 | kmk_rm_SOURCES = \
|
---|
225 | kmkbuiltin/rm.c
|
---|
226 |
|
---|
227 | kmk_rmdir_TEMPLATE = BIN-KMK
|
---|
228 | kmk_rmdir_DEFS = kmk_builtin_rmdir=main
|
---|
229 | kmk_rmdir_SOURCES = \
|
---|
230 | kmkbuiltin/rmdir.c
|
---|
231 |
|
---|
232 |
|
---|
233 | #
|
---|
234 | # kmk_gmake - almost plain GNU Make.
|
---|
235 | #
|
---|
236 | PROGRAMS += kmk_gmake
|
---|
237 |
|
---|
238 | kmk_gmake_TEMPLATE = BIN-KMK
|
---|
239 | kmk_gmake_DEFS = \
|
---|
240 | HAVE_CONFIG_H \
|
---|
241 | NO_ARCHIVES \
|
---|
242 | CONFIG_WITH_TOUPPER_TOLOWER \
|
---|
243 | EXPERIMENTAL
|
---|
244 |
|
---|
245 | kmk_gmake_SOURCES = \
|
---|
246 | main.c \
|
---|
247 | read.c \
|
---|
248 | hash.c \
|
---|
249 | strcache.c \
|
---|
250 | variable.c \
|
---|
251 | ar.c \
|
---|
252 | arscan.c \
|
---|
253 | commands.c \
|
---|
254 | default.c \
|
---|
255 | dir.c \
|
---|
256 | expand.c \
|
---|
257 | file.c \
|
---|
258 | function.c \
|
---|
259 | implicit.c \
|
---|
260 | job.c \
|
---|
261 | misc.c \
|
---|
262 | remake.c \
|
---|
263 | rule.c \
|
---|
264 | signame.c \
|
---|
265 | version.c \
|
---|
266 | vpath.c \
|
---|
267 | remote-stub.c
|
---|
268 |
|
---|
269 |
|
---|
270 | include $(PATH_KBUILD)/footer.kmk
|
---|
271 |
|
---|
272 |
|
---|
273 | #
|
---|
274 | # Use checked in config.h instead of running ./Configure for it.
|
---|
275 | #
|
---|
276 | config.h.$(BUILD_TARGET) := config.h.$(BUILD_TARGET)
|
---|
277 | $(PATH_TARGET)/config.h: $(config.h.$(BUILD_TARGET))
|
---|
278 | $(MKDIR) -p $(dir $@)
|
---|
279 | $(CP) $^ $@
|
---|
280 |
|
---|
281 | #
|
---|
282 | # Some missing headers.
|
---|
283 | #
|
---|
284 | $(PATH_TARGET)/fts.h: kmkbuiltin/ftsfake.h | $(call DIRDEP,$(PATH_TARGET))
|
---|
285 | $(CP) $^ $@
|
---|
286 |
|
---|
287 | $(PATH_TARGET)/unistd.h: | $(call DIRDEP,$(PATH_TARGET))
|
---|
288 | $(ECHO_EXT) > $@
|
---|
289 |
|
---|
290 | $(PATH_TARGET)/sysexits.h: | $(call DIRDEP,$(PATH_TARGET))
|
---|
291 | $(ECHO_EXT) > $@
|
---|
292 |
|
---|
293 | $(PATH_TARGET)/inttypes.h: | $(call DIRDEP,$(PATH_TARGET))
|
---|
294 | $(ECHO_EXT) > $@
|
---|
295 |
|
---|
296 | $(PATH_TARGET)/paths.h: | $(call DIRDEP,$(PATH_TARGET))
|
---|
297 | $(ECHO_EXT) > $@
|
---|
298 |
|
---|
299 | $(PATH_TARGET)/pwd.h: | $(call DIRDEP,$(PATH_TARGET))
|
---|
300 | $(ECHO_EXT) > $@
|
---|
301 |
|
---|
302 | $(PATH_TARGET)/grp.h: | $(call DIRDEP,$(PATH_TARGET))
|
---|
303 | $(ECHO_EXT) > $@
|
---|
304 |
|
---|
305 |
|
---|
306 | #
|
---|
307 | # Some tests.
|
---|
308 | #
|
---|
309 | parallel: parallel_1 parallel_2 parallel_3 parallel_4 parallel_5
|
---|
310 | parallel_1 parallel_2 parallel_3 parallel_4 parallel_5:
|
---|
311 | echo $@_start ; sleep 1; echo $@_done
|
---|
312 |
|
---|
313 | test:
|
---|
314 | echo "1"
|
---|
315 | echo "2"
|
---|
316 | echo "3"
|
---|
317 | echo "4"
|
---|
318 |
|
---|
319 |
|
---|
320 | #
|
---|
321 | # Shell execution tests.
|
---|
322 | #
|
---|
323 | test_shell: test_shell_quoting test_shell_double_quoting test_shell_newline
|
---|
324 |
|
---|
325 | # shell double and single quoting check (was busted on windows in 3.81).
|
---|
326 | test_shell_quoting:
|
---|
327 | $(ECHO_EXT) "double quoted sTrInG"
|
---|
328 | $(ECHO_EXT) "double quoted sTrInG" | $(SED_EXT) -e "s/sTrInG/string/g"
|
---|
329 | $(ECHO_EXT) 'single quoted sTrInG' | $(SED_EXT) -e 's/sTrInG/string/g'
|
---|
330 | $(ECHO) "This string should not be printed with double quotes."
|
---|
331 | $(ECHO) 'This string should not be printed with single quotes.'
|
---|
332 | ( echo " #define PWD \"`pwd`\""; )
|
---|
333 |
|
---|
334 | test_shell_double_quoting:
|
---|
335 | $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
|
---|
336 | "s/foo/$@/" -e \
|
---|
337 | "s/foo/works/" \
|
---|
338 | -e "s/foo/\!/"
|
---|
339 |
|
---|
340 | test_shell_double_quoting2:
|
---|
341 | $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
|
---|
342 | "s/foo/$@/" -e \
|
---|
343 | "s/foo/works/" \
|
---|
344 | -e\
|
---|
345 | "s/foo/\!/"
|
---|
346 |
|
---|
347 | # when using batch mode shell, the newline got escaped twice and spoiling everything.
|
---|
348 | test_shell_newline:
|
---|
349 | $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
|
---|
350 | 's/foo/$@/' -e \
|
---|
351 | 's/foo/works/' \
|
---|
352 | -e 's/foo/\!/'
|
---|
353 |
|
---|
354 |
|
---|
355 | test_stack:
|
---|
356 | $(MAKE) -f testcase-stack.kmk
|
---|
357 |
|
---|
358 | test_math:
|
---|
359 | $(MAKE) -f testcase-math.kmk
|
---|
360 |
|
---|
361 |
|
---|
362 | test_all: test_math test_stack test_shell
|
---|
363 |
|
---|