VirtualBox

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

Last change on this file since 2141 was 2141, checked in by bird, 16 years ago

kmk: new function $(printf fmt,arg0,arg1,...).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.6 KB
Line 
1# $Id: Makefile.kmk 2141 2008-12-25 20:21:22Z 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 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
29
30#
31# Template for kmk and the kmk_* binaries in this makefile.
32#
33TEMPLATE_BIN-KMK = Template for src/gmake binaries
34TEMPLATE_BIN-KMK_EXTENDS = BIN
35TEMPLATE_BIN-KMK_DEFS = \
36 HAVE_CONFIG_H \
37 $(TEMPLATE_BIN_DEFS) \
38 KBUILD_SVN_REV=$(KBUILD_SVN_REV) \
39 KBUILD_TYPE=\"$(KBUILD_TYPE)\"
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_DEFINED \
137 CONFIG_WITH_EXPLICIT_MULTITARGET \
138 CONFIG_WITH_DOT_MUST_MAKE \
139 CONFIG_WITH_PREPEND_ASSIGNMENT \
140 CONFIG_WITH_LOCAL_VARIABLES \
141 CONFIG_WITH_2ND_TARGET_EXPANSION \
142 CONFIG_WITH_ALLOC_CACHES \
143 CONFIG_WITH_STRCACHE2 \
144 \
145 KMK \
146 KMK_HELPERS \
147 CONFIG_NO_DEFAULT_SUFFIXES \
148 CONFIG_NO_DEFAULT_PATTERN_RULES \
149 CONFIG_NO_DEFAULT_TERMINAL_RULES \
150 CONFIG_NO_DEFAULT_SUFFIX_RULES \
151 CONFIG_NO_DEFAULT_VARIABLES \
152 CONFIG_WITH_EXTENDED_NOTPARALLEL \
153 CONFIG_WITH_INCLUDEDEP \
154 CONFIG_WITH_VALUE_LENGTH \
155 CONFIG_WITH_RSORT \
156 CONFIG_WITH_ABSPATHEX \
157 CONFIG_WITH_COMPARE \
158 CONFIG_WITH_STACK \
159 CONFIG_WITH_MATH \
160 CONFIG_WITH_XARGS \
161 CONFIG_WITH_NANOTS \
162 CONFIG_WITH_SET_CONDITIONALS \
163 CONFIG_WITH_IF_CONDITIONALS \
164 CONFIG_WITH_DATE \
165 CONFIG_WITH_FILE_SIZE \
166 CONFIG_WITH_WHICH \
167 CONFIG_WITH_PRINTF \
168 CONFIG_WITH_EVALPLUS \
169 CONFIG_WITH_MINIMAL_STATS \
170 CONFIG_WITH_COMMANDS_FUNC \
171 CONFIG_PRETTY_COMMAND_PRINTING \
172 CONFIG_WITH_PRINT_STATS_SWITCH \
173 CONFIG_WITH_PRINT_TIME_SWITCH \
174 CONFIG_WITH_RDONLY_VARIABLE_VALUE \
175 CONFIG_WITH_LAZY_DEPS_VARS \
176 CONFIG_WITH_MEMORY_OPTIMIZATIONS \
177 \
178 KBUILD_HOST=\"$(KBUILD_TARGET)\" \
179 KBUILD_HOST_ARCH=\"$(KBUILD_TARGET_ARCH)\" \
180 KBUILD_HOST_CPU=\"$(KBUILD_TARGET_CPU)\"
181kmk_DEFS.x86 = CONFIG_WITH_OPTIMIZATION_HACKS
182kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS
183kmk_DEFS.win = CONFIG_NEW_WIN32_CTRL_EVENT
184kmk_DEFS.debug = CONFIG_WITH_MAKE_STATS
185
186kmk_SOURCES = \
187 main.c \
188 kbuild.c \
189 read.c \
190 expreval.c \
191 incdep.c \
192 hash.c \
193 strcache.c \
194 strcache2.c \
195 variable.c \
196 ar.c \
197 arscan.c \
198 commands.c \
199 default.c \
200 dir.c \
201 expand.c \
202 file.c \
203 function.c \
204 implicit.c \
205 job.c \
206 misc.c \
207 alloccache.c \
208 remake.c \
209 rule.c \
210 signame.c \
211 version.c \
212 vpath.c \
213 remote-stub.c
214
215#kmk_LIBS.solaris = malloc
216#kmk_DEFS.solaris += HAVE_MALLINFO
217
218kmk_LIBS.freebsd.amd64 = pthread
219kmk_DEFS.freebsd.x86 = CONFIG_WITHOUT_THREADS
220
221#
222# kmkbuiltin commands
223#
224kmk_DEFS += CONFIG_WITH_KMK_BUILTIN
225kmk_LIBS += $(LIB_KUTIL) $(LIB_KDEP)
226kmk_SOURCES += \
227 kmkbuiltin.c \
228 kmkbuiltin/append.c \
229 kmkbuiltin/cat.c \
230 kmkbuiltin/chmod.c \
231 kmkbuiltin/cmp.c \
232 kmkbuiltin/cmp_util.c \
233 kmkbuiltin/cp.c \
234 kmkbuiltin/cp_utils.c \
235 kmkbuiltin/echo.c \
236 kmkbuiltin/expr.c \
237 kmkbuiltin/install.c \
238 kmkbuiltin/kDepIDB.c \
239 kmkbuiltin/md5sum.c \
240 kmkbuiltin/mkdir.c \
241 kmkbuiltin/mv.c \
242 kmkbuiltin/ln.c \
243 kmkbuiltin/printf.c \
244 kmkbuiltin/rm.c \
245 kmkbuiltin/rmdir.c \
246 kmkbuiltin/sleep.c \
247 kmkbuiltin/test.c \
248
249## @todo kmkbuiltin/redirect.c
250
251## Some profiling
252#kmk_SOURCES += kbuildprf.c
253#kmk_DEFS += open=prf_open read=prf_read lseek=prf_lseek close=prf_close
254##kmk_DEFS += KMK_PRF=1
255##kmkmissing_DEFS += KMK_PRF=1
256
257#
258# Standalone kmkbuiltin commands.
259#
260PROGRAMS += \
261 kmk_append \
262 kmk_cat \
263 kmk_chmod \
264 kmk_cp \
265 kmk_cmp \
266 kmk_echo \
267 kmk_expr \
268 kmk_md5sum \
269 kmk_mkdir \
270 kmk_mv \
271 kmk_install \
272 kmk_ln \
273 kmk_printf \
274 kmk_redirect \
275 kmk_rm \
276 kmk_rmdir \
277 kmk_sleep \
278 kmk_test \
279 kDepIDB \
280
281kmk_append_TEMPLATE = BIN-KMK
282kmk_append_DEFS = kmk_builtin_append=main
283kmk_append_INCS = .
284kmk_append_SOURCES = \
285 kmkbuiltin/append.c
286
287kmk_cat_TEMPLATE = BIN-KMK
288kmk_cat_DEFS = kmk_builtin_cat=main
289kmk_cat_SOURCES = \
290 kmkbuiltin/cat.c
291
292kmk_chmod_TEMPLATE = BIN-KMK
293kmk_chmod_DEFS = kmk_builtin_chmod=main
294kmk_chmod_SOURCES = \
295 kmkbuiltin/chmod.c
296
297kmk_cmp_TEMPLATE = BIN-KMK
298kmk_cmp_DEFS = kmk_builtin_cmp=main
299kmk_cmp_SOURCES = \
300 kmkbuiltin/cmp.c \
301 kmkbuiltin/cmp_util.c
302
303kmk_cp_TEMPLATE = BIN-KMK
304kmk_cp_DEFS = kmk_builtin_cp=main
305kmk_cp_SOURCES = \
306 kmkbuiltin/cp.c \
307 kmkbuiltin/cp_utils.c \
308 kmkbuiltin/cmp_util.c
309
310kmk_echo_TEMPLATE = BIN-KMK
311kmk_echo_DEFS = kmk_builtin_echo=main
312kmk_echo_SOURCES = \
313 kmkbuiltin/echo.c
314
315kmk_expr_TEMPLATE = BIN-KMK
316kmk_expr_DEFS = kmk_builtin_expr=main
317kmk_expr_SOURCES = \
318 kmkbuiltin/expr.c
319
320kmk_install_TEMPLATE = BIN-KMK
321kmk_install_DEFS = kmk_builtin_install=main
322kmk_install_SOURCES = \
323 kmkbuiltin/install.c
324
325kmk_ln_TEMPLATE = BIN-KMK
326kmk_ln_DEFS = kmk_builtin_ln=main
327kmk_ln_SOURCES = \
328 kmkbuiltin/ln.c
329
330kmk_mkdir_TEMPLATE = BIN-KMK
331kmk_mkdir_DEFS = kmk_builtin_mkdir=main
332kmk_mkdir_SOURCES = \
333 kmkbuiltin/mkdir.c
334
335kmk_md5sum_TEMPLATE = BIN-KMK
336kmk_md5sum_DEFS = kmk_builtin_md5sum=main
337kmk_md5sum_SOURCES = \
338 kmkbuiltin/md5sum.c
339kmk_md5sum_LIBS = $(LIB_KUTIL)
340
341kmk_mv_TEMPLATE = BIN-KMK
342kmk_mv_DEFS = kmk_builtin_mv=main
343kmk_mv_SOURCES = \
344 kmkbuiltin/mv.c
345
346kmk_printf_TEMPLATE = BIN-KMK
347kmk_printf_DEFS = kmk_builtin_printf=main
348kmk_printf_SOURCES = \
349 kmkbuiltin/printf.c
350
351kmk_rm_TEMPLATE = BIN-KMK
352kmk_rm_DEFS = kmk_builtin_rm=main
353kmk_rm_SOURCES = \
354 kmkbuiltin/rm.c
355
356kmk_redirect_TEMPLATE = BIN-KMK
357kmk_redirect_DEFS = kmk_builtin_redirect=main
358kmk_redirect_SOURCES = \
359 kmkbuiltin/redirect.c
360
361kmk_rmdir_TEMPLATE = BIN-KMK
362kmk_rmdir_DEFS = kmk_builtin_rmdir=main
363kmk_rmdir_SOURCES = \
364 kmkbuiltin/rmdir.c
365
366kmk_sleep_TEMPLATE = BIN-KMK
367kmk_sleep_DEFS = kmk_builtin_sleep=main
368kmk_sleep_SOURCES = \
369 kmkbuiltin/sleep.c
370
371kmk_test_TEMPLATE = BIN-KMK
372kmk_test_DEFS = kmk_builtin_test=main
373kmk_test_SOURCES = \
374 kmkbuiltin/test.c
375
376kDepIDB_TEMPLATE = BIN-KMK
377kDepIDB_DEFS = kmk_builtin_kDepIDB=main
378kDepIDB_INCS = .
379kDepIDB_LIBS = $(LIB_KDEP)
380kDepIDB_SOURCES = \
381 kmkbuiltin/kDepIDB.c
382
383
384#
385# kmk_gmake - almost plain GNU Make.
386#
387PROGRAMS += kmk_gmake
388
389kmk_gmake_TEMPLATE = BIN-KMK
390kmk_gmake_DEFS = \
391 HAVE_CONFIG_H \
392 NO_ARCHIVES \
393 CONFIG_WITH_TOUPPER_TOLOWER \
394 EXPERIMENTAL
395
396kmk_gmake_SOURCES = \
397 main.c \
398 read.c \
399 hash.c \
400 strcache.c \
401 variable.c \
402 ar.c \
403 arscan.c \
404 commands.c \
405 default.c \
406 dir.c \
407 expand.c \
408 file.c \
409 function.c \
410 implicit.c \
411 job.c \
412 misc.c \
413 remake.c \
414 rule.c \
415 signame.c \
416 version.c \
417 vpath.c \
418 remote-stub.c
419
420
421#
422# kmk_fmake - Faster GNU Make.
423#
424ifeq ($(USER),bird) # for experimental purposes only.
425PROGRAMS += kmk_fgmake
426endif
427
428kmk_fgmake_TEMPLATE = BIN-KMK
429kmk_fgmake_DEFS = \
430 HAVE_CONFIG_H \
431 NO_ARCHIVES \
432 CONFIG_WITH_TOUPPER_TOLOWER \
433 EXPERIMENTAL \
434 \
435 CONFIG_WITH_ALLOC_CACHES \
436 CONFIG_WITH_LAZY_DEPS_VARS \
437 CONFIG_WITH_STRCACHE2 \
438 CONFIG_WITH_VALUE_LENGTH \
439 CONFIG_WITH_RDONLY_VARIABLE_VALUE
440# TODO ?
441# CONFIG_WITH_PRINT_STATS_SWITCH \
442# CONFIG_WITH_EXTENDED_NOTPARALLEL \
443
444kmk_fgmake_SOURCES = \
445 main.c \
446 read.c \
447 hash.c \
448 strcache.c \
449 strcache2.c \
450 variable.c \
451 ar.c \
452 arscan.c \
453 commands.c \
454 default.c \
455 dir.c \
456 expand.c \
457 file.c \
458 function.c \
459 implicit.c \
460 job.c \
461 misc.c \
462 alloccache.c \
463 remake.c \
464 rule.c \
465 signame.c \
466 version.c \
467 vpath.c \
468 remote-stub.c
469
470
471include $(FILE_KBUILD_SUB_FOOTER)
472
473
474#
475# Use checked in config.h instead of running ./Configure for it.
476#
477kmk_config.h.$(KBUILD_TARGET) := $(kmk_PATH)/config.h.$(KBUILD_TARGET)
478$(PATH_kmk)/config.h: $(kmk_config.h.$(KBUILD_TARGET))
479 $(MKDIR) -p $(dir $@)
480 $(CP) $^ $@
481
482#
483# Some missing headers.
484#
485$(PATH_kmk)/fts.h: $(kmk_PATH)/kmkbuiltin/ftsfake.h | $(call DIRDEP,$(PATH_kmk))
486 $(CP) $^ $@
487
488$(PATH_kmk)/unistd.h: | $(call DIRDEP,$(PATH_kmk))
489 $(ECHO_EXT) > $@
490
491$(PATH_kmk)/sysexits.h: | $(call DIRDEP,$(PATH_kmk))
492 $(ECHO_EXT) > $@
493
494$(PATH_kmk)/inttypes.h: | $(call DIRDEP,$(PATH_kmk))
495 $(ECHO_EXT) > $@
496
497$(PATH_kmk)/paths.h: | $(call DIRDEP,$(PATH_kmk))
498 $(ECHO_EXT) > $@
499
500$(PATH_kmk)/pwd.h: | $(call DIRDEP,$(PATH_kmk))
501 $(ECHO_EXT) > $@
502
503$(PATH_kmk)/grp.h: | $(call DIRDEP,$(PATH_kmk))
504 $(ECHO_EXT) > $@
505
506
507#
508# Some tests.
509#
510parallel: parallel_1 parallel_2 parallel_3 parallel_4 parallel_5
511parallel_1 parallel_2 parallel_3 parallel_4 parallel_5:
512 echo $@_start ; sleep 1; echo $@_done
513
514my_test:
515 echo "1"
516 echo "2"
517 echo "3"
518 echo "4"
519
520
521#
522# Shell execution tests.
523#
524test_shell: test_shell_quoting test_shell_double_quoting test_shell_newline
525
526# shell double and single quoting check (was busted on windows in 3.81).
527test_shell_quoting:
528 $(ECHO_EXT) "double quoted sTrInG"
529 $(ECHO_EXT) "double quoted sTrInG" | $(SED_EXT) -e "s/sTrInG/string/g"
530 $(ECHO_EXT) 'single quoted sTrInG' | $(SED_EXT) -e 's/sTrInG/string/g'
531 $(ECHO) "This string should not be printed with double quotes."
532 $(ECHO) 'This string should not be printed with single quotes.'
533 ( echo " #define PWD \"`pwd`\""; )
534
535test_shell_double_quoting:
536 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
537 "s/foo/$@/" -e \
538 "s/foo/works/" \
539 -e "s/foo/\!/"
540
541test_shell_double_quoting2:
542 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
543 "s/foo/$@/" -e \
544 "s/foo/works/" \
545 -e\
546 "s/foo/\!/"
547
548# when using batch mode shell, the newline got escaped twice and spoiling everything.
549test_shell_newline:
550 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
551 's/foo/$@/' -e \
552 's/foo/works/' \
553 -e 's/foo/\!/'
554
555
556test_stack:
557 $(MAKE) -f $(kmk_PATH)/testcase-stack.kmk
558
559test_math:
560 $(MAKE) -f $(kmk_PATH)/testcase-math.kmk
561
562test_if1of:
563 $(MAKE) -f $(kmk_PATH)/testcase-if1of.kmk
564
565test_local:
566 $(MAKE) -f $(kmk_PATH)/testcase-local.kmk
567
568test_includedep:
569 $(MAKE) -f $(kmk_PATH)/testcase-includedep.kmk
570
571test_2ndtargetexp:
572 $(MAKE) -f $(kmk_PATH)/testcase-2ndtargetexp.kmk
573
574test_30_continued_on_failure_worker:
575 this_executable_does_not_exist.exe
576 echo "We shouldn't see this..."
577
578test_30_continued_on_failure:
579 $(MAKE) -f $(MAKEFILE) test_30_continued_on_failure_worker; \
580 RC=$$?; \
581 if test $${RC} -ne 2; then \
582 echo "$@: FAILED - exit code $${RC} instead of 2."; \
583 exit 1; \
584 else \
585 echo "$@: SUCCESS"; \
586 fi
587
588test_lazy_deps_vars:
589 $(MAKE) -C $(kmk_PATH) -f testcase-lazy-deps-vars.kmk
590
591
592test_all: test_math test_stack test_shell test_if1of test_local test_includedep test_2ndtargetexp test_30_continued_on_failure test_lazy_deps_vars
593
594
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