VirtualBox

source: kBuild/trunk/src/kmk/Makefile.kmk@ 1701

最後變更 在這個檔案從1701是 1701,由 bird 提交於 16 年 前

kmk: Implemented secondary target expansion. Fixes #42.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 10.8 KB
 
1# $Id: Makefile.kmk 1701 2008-09-02 02:06:18Z bird $
2## @file
3# Sub-makefile for kmk / GNU Make.
4#
5
6#
7# Copyright (c) 2004-2008 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 2 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, write to the Free Software
23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24#
25#
26
27SUB_DEPTH = ../..
28include $(KBUILD_PATH)/subheader.kmk
29
30
31#
32# Template for kmk and the kmk_* binaries in this makefile.
33#
34TEMPLATE_BIN-KMK = Template for src/gmake binaries
35TEMPLATE_BIN-KMK_EXTENDS = BIN
36TEMPLATE_BIN-KMK_DEFS = \
37 HAVE_CONFIG_H \
38 $(TEMPLATE_BIN_DEFS) \
39 KBUILD_SVN_REV=$(KBUILD_SVN_REV)
40TEMPLATE_BIN-KMK_DEPS = $(PATH_kmk)/config.h
41TEMPLATE_BIN-KMK_CLEAN = $(TEMPLATE_BIN-KMK_DEPS)
42TEMPLATE_BIN-KMK_DEPS.solaris = \
43 $(PATH_kmk)/fts.h \
44 $(PATH_kmk)/paths.h
45TEMPLATE_BIN-KMK_CLEAN.solaris = $(TEMPLATE_BIN-KMK_DEPS.solaris)
46TEMPLATE_BIN-KMK_DEPS.win = \
47 $(PATH_kmk)/fts.h \
48 $(PATH_kmk)/sysexits.h \
49 $(PATH_kmk)/unistd.h \
50 $(PATH_kmk)/paths.h \
51 $(PATH_kmk)/grp.h \
52 $(PATH_kmk)/pwd.h \
53 $(PATH_kmk)/inttypes.h
54TEMPLATE_BIN-KMK_CFLAGS.win.amd64 = $(TEMPLATE_BIN_CFLAGS.win.amd64) -wd4244 -wd4267
55TEMPLATE_BIN-KMK_CLEAN.win = $(TEMPLATE_BIN-KMK_DEPS.win)
56TEMPLATE_BIN-KMK_INCS = $(PATH_kmk) . $(TEMPLATE_BIN_INCS)
57TEMPLATE_BIN-KMK_INCS.darwin = glob
58TEMPLATE_BIN-KMK_INCS.dragonfly = glob
59TEMPLATE_BIN-KMK_INCS.freebsd = glob
60TEMPLATE_BIN-KMK_INCS.solaris = glob
61TEMPLATE_BIN-KMK_LIBS = $(TEMPLATE_BIN_LIBS) $(TARGET_kmkmissing) $(LIB_KUTIL)
62ifdef ELECTRIC_HEAP # for electric heap (see electric.c) - windows only.
63ifeq ($(KBUILD_TARGET),win)
64 TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) /FI$(kmk_PATH)/electric.h -DELECTRIC_HEAP=1
65else
66 TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) -include $(kmk_PATH)/electric.h -DELECTRIC_HEAP=1
67endif
68endif
69
70
71#
72# A library containing the missing features needed by kmk and the
73# kmk_* binaries. Saves a bit of work later on.
74#
75LIBRARIES += kmkmissing
76kmkmissing_TEMPLATE = BIN-KMK
77kmkmissing_DEFS = KMK
78kmkmissing_NOINST = 1
79kmkmissing_SOURCES = \
80 kmkbuiltin/err.c \
81 kmkbuiltin/setmode.c \
82 kmkbuiltin/strmode.c \
83 kmkbuiltin/kbuild_version.c \
84 kmkbuiltin/kbuild_protection.c \
85 getopt.c \
86 getopt1.c \
87 electric.c
88
89kmkmissing_SOURCES.darwin = \
90 kmkbuiltin/darwin.c \
91 glob/glob.c \
92 glob/fnmatch.c
93
94kmkmissing_SOURCES.dragonfly = \
95 glob/glob.c \
96 glob/fnmatch.c
97
98kmkmissing_SOURCES.freebsd = \
99 glob/glob.c \
100 glob/fnmatch.c
101
102kmkmissing_SOURCES.linux += \
103 kmkbuiltin/strlcpy.c
104
105kmkmissing_SOURCES.solaris = \
106 kmkbuiltin/strlcpy.c \
107 kmkbuiltin/solfakes.c \
108 kmkbuiltin/fts.c \
109 glob/glob.c \
110 glob/fnmatch.c
111
112kmkmissing_SOURCES.win += \
113 kmkbuiltin/strlcpy.c \
114 kmkbuiltin/mscfakes.c \
115 kmkbuiltin/fts.c \
116 glob/glob.c \
117 glob/fnmatch.c \
118 getloadavg.c \
119 w32/subproc/misc.c \
120 w32/subproc/sub_proc.c \
121 w32/subproc/w32err.c \
122 w32/compat/dirent.c \
123 w32/pathstuff.c
124
125#
126# kmk
127#
128PROGRAMS += kmk
129
130kmk_TEMPLATE = BIN-KMK
131
132kmk_DEFS = \
133 NO_ARCHIVES \
134 EXPERIMENTAL \
135 CONFIG_WITH_TOUPPER_TOLOWER \
136 CONFIG_WITH_EXPLICIT_MULTITARGET \
137 CONFIG_WITH_PREPEND_ASSIGNMENT \
138 CONFIG_WITH_LOCAL_VARIABLES \
139 CONFIG_WITH_2ND_TARGET_EXPANSION \
140 \
141 KMK \
142 KMK_HELPERS \
143 VARIABLE_HASH \
144 CONFIG_NO_DEFAULT_SUFFIXES \
145 CONFIG_NO_DEFAULT_PATTERN_RULES \
146 CONFIG_NO_DEFAULT_TERMINAL_RULES \
147 CONFIG_NO_DEFAULT_SUFFIX_RULES \
148 CONFIG_NO_DEFAULT_VARIABLES \
149 CONFIG_WITH_EXTENDED_NOTPARALLEL \
150 CONFIG_WITH_INCLUDEDEP \
151 CONFIG_WITH_VALUE_LENGTH \
152 CONFIG_WITH_RSORT \
153 CONFIG_WITH_ABSPATHEX \
154 CONFIG_WITH_COMPARE \
155 CONFIG_WITH_STACK \
156 CONFIG_WITH_MATH \
157 CONFIG_WITH_XARGS \
158 CONFIG_WITH_NANOTS \
159 CONFIG_WITH_SET_CONDITIONALS \
160 CONFIG_WITH_DATE \
161 CONFIG_WITH_FILE_SIZE \
162 CONFIG_WITH_WHICH \
163 CONFIG_WITH_EVALPLUS \
164 CONFIG_WITH_MAKE_STATS \
165 CONFIG_WITH_COMMANDS_FUNC \
166 CONFIG_PRETTY_COMMAND_PRINTING \
167 \
168 KBUILD_HOST=\"$(KBUILD_TARGET)\" \
169 KBUILD_HOST_ARCH=\"$(KBUILD_TARGET_ARCH)\" \
170 KBUILD_HOST_CPU=\"$(KBUILD_TARGET_CPU)\"
171kmk_DEFS.x86 = CONFIG_WITH_OPTIMIZATION_HACKS
172kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS
173kmk_DEFS.win = CONFIG_NEW_WIN32_CTRL_EVENT
174
175kmk_SOURCES = \
176 main.c \
177 read.c \
178 hash.c \
179 strcache.c \
180 variable.c \
181 ar.c \
182 arscan.c \
183 commands.c \
184 default.c \
185 dir.c \
186 expand.c \
187 file.c \
188 function.c \
189 implicit.c \
190 job.c \
191 misc.c \
192 remake.c \
193 rule.c \
194 signame.c \
195 version.c \
196 vpath.c \
197 remote-stub.c \
198 kbuild.c
199
200#
201# kmkbuiltin commands
202#
203kmk_DEFS += CONFIG_WITH_KMK_BUILTIN
204kmk_LIBS += $(LIB_KUTIL) $(LIB_KDEP)
205kmk_SOURCES += \
206 kmkbuiltin.c \
207 kmkbuiltin/append.c \
208 kmkbuiltin/cat.c \
209 kmkbuiltin/cmp.c \
210 kmkbuiltin/cmp_util.c \
211 kmkbuiltin/cp.c \
212 kmkbuiltin/cp_utils.c \
213 kmkbuiltin/echo.c \
214 kmkbuiltin/install.c \
215 kmkbuiltin/kDepIDB.c \
216 kmkbuiltin/md5sum.c \
217 kmkbuiltin/mkdir.c \
218 kmkbuiltin/mv.c \
219 kmkbuiltin/ln.c \
220 kmkbuiltin/printf.c \
221 kmkbuiltin/rm.c \
222 kmkbuiltin/rmdir.c \
223 kmkbuiltin/test.c \
224
225## @todo kmkbuiltin/redirect.c
226
227## Some profiling
228#kmk_SOURCES += kbuildprf.c
229#kmk_DEFS += open=prf_open read=prf_read lseek=prf_lseek close=prf_close
230##kmk_DEFS += KMK_PRF=1
231##kmkmissing_DEFS += KMK_PRF=1
232
233#
234# Standalone kmkbuiltin commands.
235#
236PROGRAMS += \
237 kmk_append \
238 kmk_cat \
239 kmk_cp \
240 kmk_cmp \
241 kmk_echo \
242 kmk_md5sum \
243 kmk_mkdir \
244 kmk_mv \
245 kmk_install \
246 kmk_ln \
247 kmk_printf \
248 kmk_redirect \
249 kmk_rm \
250 kmk_rmdir \
251 kmk_test \
252 kDepIDB \
253
254kmk_append_TEMPLATE = BIN-KMK
255kmk_append_DEFS = kmk_builtin_append=main
256kmk_append_INCS = .
257kmk_append_SOURCES = \
258 kmkbuiltin/append.c
259
260kmk_cat_TEMPLATE = BIN-KMK
261kmk_cat_DEFS = kmk_builtin_cat=main
262kmk_cat_SOURCES = \
263 kmkbuiltin/cat.c
264
265kmk_cmp_TEMPLATE = BIN-KMK
266kmk_cmp_DEFS = kmk_builtin_cmp=main
267kmk_cmp_SOURCES = \
268 kmkbuiltin/cmp.c \
269 kmkbuiltin/cmp_util.c
270
271kmk_cp_TEMPLATE = BIN-KMK
272kmk_cp_DEFS = kmk_builtin_cp=main
273kmk_cp_SOURCES = \
274 kmkbuiltin/cp.c \
275 kmkbuiltin/cp_utils.c \
276 kmkbuiltin/cmp_util.c
277
278kmk_echo_TEMPLATE = BIN-KMK
279kmk_echo_DEFS = kmk_builtin_echo=main
280kmk_echo_SOURCES = \
281 kmkbuiltin/echo.c
282
283kmk_install_TEMPLATE = BIN-KMK
284kmk_install_DEFS = kmk_builtin_install=main
285kmk_install_SOURCES = \
286 kmkbuiltin/install.c
287
288kmk_ln_TEMPLATE = BIN-KMK
289kmk_ln_DEFS = kmk_builtin_ln=main
290kmk_ln_SOURCES = \
291 kmkbuiltin/ln.c
292
293kmk_mkdir_TEMPLATE = BIN-KMK
294kmk_mkdir_DEFS = kmk_builtin_mkdir=main
295kmk_mkdir_SOURCES = \
296 kmkbuiltin/mkdir.c
297
298kmk_md5sum_TEMPLATE = BIN-KMK
299kmk_md5sum_DEFS = kmk_builtin_md5sum=main
300kmk_md5sum_SOURCES = \
301 kmkbuiltin/md5sum.c
302kmk_md5sum_LIBS = $(LIB_KUTIL)
303
304kmk_mv_TEMPLATE = BIN-KMK
305kmk_mv_DEFS = kmk_builtin_mv=main
306kmk_mv_SOURCES = \
307 kmkbuiltin/mv.c
308
309kmk_printf_TEMPLATE = BIN-KMK
310kmk_printf_DEFS = kmk_builtin_printf=main
311kmk_printf_SOURCES = \
312 kmkbuiltin/printf.c
313
314kmk_rm_TEMPLATE = BIN-KMK
315kmk_rm_DEFS = kmk_builtin_rm=main
316kmk_rm_SOURCES = \
317 kmkbuiltin/rm.c
318
319kmk_redirect_TEMPLATE = BIN-KMK
320kmk_redirect_DEFS = kmk_builtin_redirect=main
321kmk_redirect_SOURCES = \
322 kmkbuiltin/redirect.c
323
324kmk_rmdir_TEMPLATE = BIN-KMK
325kmk_rmdir_DEFS = kmk_builtin_rmdir=main
326kmk_rmdir_SOURCES = \
327 kmkbuiltin/rmdir.c
328
329kmk_test_TEMPLATE = BIN-KMK
330kmk_test_DEFS = kmk_builtin_test=main
331kmk_test_SOURCES = \
332 kmkbuiltin/test.c
333
334kDepIDB_TEMPLATE = BIN-KMK
335kDepIDB_DEFS = kmk_builtin_kDepIDB=main
336kDepIDB_INCS = .
337kDepIDB_LIBS = $(LIB_KDEP)
338kDepIDB_SOURCES = \
339 kmkbuiltin/kDepIDB.c
340
341
342#
343# kmk_gmake - almost plain GNU Make.
344#
345PROGRAMS += kmk_gmake
346
347kmk_gmake_TEMPLATE = BIN-KMK
348kmk_gmake_DEFS = \
349 HAVE_CONFIG_H \
350 NO_ARCHIVES \
351 CONFIG_WITH_TOUPPER_TOLOWER \
352 EXPERIMENTAL
353
354kmk_gmake_SOURCES = \
355 main.c \
356 read.c \
357 hash.c \
358 strcache.c \
359 variable.c \
360 ar.c \
361 arscan.c \
362 commands.c \
363 default.c \
364 dir.c \
365 expand.c \
366 file.c \
367 function.c \
368 implicit.c \
369 job.c \
370 misc.c \
371 remake.c \
372 rule.c \
373 signame.c \
374 version.c \
375 vpath.c \
376 remote-stub.c
377
378
379include $(FILE_KBUILD_SUB_FOOTER)
380
381
382#
383# Use checked in config.h instead of running ./Configure for it.
384#
385kmk_config.h.$(KBUILD_TARGET) := $(kmk_PATH)/config.h.$(KBUILD_TARGET)
386$(PATH_kmk)/config.h: $(kmk_config.h.$(KBUILD_TARGET))
387 $(MKDIR) -p $(dir $@)
388 $(CP) $^ $@
389
390#
391# Some missing headers.
392#
393$(PATH_kmk)/fts.h: $(kmk_PATH)/kmkbuiltin/ftsfake.h | $(call DIRDEP,$(PATH_kmk))
394 $(CP) $^ $@
395
396$(PATH_kmk)/unistd.h: | $(call DIRDEP,$(PATH_kmk))
397 $(ECHO_EXT) > $@
398
399$(PATH_kmk)/sysexits.h: | $(call DIRDEP,$(PATH_kmk))
400 $(ECHO_EXT) > $@
401
402$(PATH_kmk)/inttypes.h: | $(call DIRDEP,$(PATH_kmk))
403 $(ECHO_EXT) > $@
404
405$(PATH_kmk)/paths.h: | $(call DIRDEP,$(PATH_kmk))
406 $(ECHO_EXT) > $@
407
408$(PATH_kmk)/pwd.h: | $(call DIRDEP,$(PATH_kmk))
409 $(ECHO_EXT) > $@
410
411$(PATH_kmk)/grp.h: | $(call DIRDEP,$(PATH_kmk))
412 $(ECHO_EXT) > $@
413
414
415#
416# Some tests.
417#
418parallel: parallel_1 parallel_2 parallel_3 parallel_4 parallel_5
419parallel_1 parallel_2 parallel_3 parallel_4 parallel_5:
420 echo $@_start ; sleep 1; echo $@_done
421
422test:
423 echo "1"
424 echo "2"
425 echo "3"
426 echo "4"
427
428
429#
430# Shell execution tests.
431#
432test_shell: test_shell_quoting test_shell_double_quoting test_shell_newline
433
434# shell double and single quoting check (was busted on windows in 3.81).
435test_shell_quoting:
436 $(ECHO_EXT) "double quoted sTrInG"
437 $(ECHO_EXT) "double quoted sTrInG" | $(SED_EXT) -e "s/sTrInG/string/g"
438 $(ECHO_EXT) 'single quoted sTrInG' | $(SED_EXT) -e 's/sTrInG/string/g'
439 $(ECHO) "This string should not be printed with double quotes."
440 $(ECHO) 'This string should not be printed with single quotes.'
441 ( echo " #define PWD \"`pwd`\""; )
442
443test_shell_double_quoting:
444 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
445 "s/foo/$@/" -e \
446 "s/foo/works/" \
447 -e "s/foo/\!/"
448
449test_shell_double_quoting2:
450 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
451 "s/foo/$@/" -e \
452 "s/foo/works/" \
453 -e\
454 "s/foo/\!/"
455
456# when using batch mode shell, the newline got escaped twice and spoiling everything.
457test_shell_newline:
458 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
459 's/foo/$@/' -e \
460 's/foo/works/' \
461 -e 's/foo/\!/'
462
463
464test_stack:
465 $(MAKE) -f $(kmk_PATH)/testcase-stack.kmk
466
467test_math:
468 $(MAKE) -f $(kmk_PATH)/testcase-math.kmk
469
470test_if1of:
471 $(MAKE) -f $(kmk_PATH)/testcase-if1of.kmk
472
473test_local:
474 $(MAKE) -f $(kmk_PATH)/testcase-local.kmk
475
476test_includedep:
477 $(MAKE) -f $(kmk_PATH)/testcase-includedep.kmk
478
479test_2ndtargetexp:
480 $(MAKE) -f $(kmk_PATH)/testcase-2ndtargetexp.kmk
481
482test_30_continued_on_failure_worker:
483 this_executable_does_not_exist.exe
484 echo "We shouldn't see this..."
485
486test_30_continued_on_failure:
487 $(MAKE) -f $(MAKEFILE) test_30_continued_on_failure_worker; \
488 RC=$$?; \
489 if test $${RC} -ne 2; then \
490 echo "$@: FAILED - exit code $${RC} instead of 2."; \
491 exit 1; \
492 else \
493 echo "$@: SUCCESS"; \
494 fi
495
496
497test_all: test_math test_stack test_shell test_if1of test_local test_includedep test_2ndtargetexp test_30_continued_on_failure
498
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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