VirtualBox

source: kBuild/branches/kBuild-0.1.5/src/kmk/Makefile.kmk@ 2368

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

*: Updated copyright to 2009 and normalized name & email.

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