VirtualBox

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

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

kmk: Created a custom hook into the update_file process for checking additional file dependencies like changes in the commands and such. It's call .MUST_MAKE.

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