VirtualBox

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

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

kmk: adding a 'faster-make' target called kmk_fgmake.

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