VirtualBox

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

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

kmk: Moved the alloccache code into a separate file because it seems gcc has ends up in some inlining / aliasing trouble in free_dep_chain (alloccache_free is suspected to be inlined) with gcc 4.3.2 on S/390.

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