VirtualBox

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

Last change on this file since 2419 was 2419, checked in by bird, 14 years ago

kmk: build kmk_gmake with support for archives (!NO_ARCHIVES).

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