VirtualBox

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

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

GPLv2 -> GPLv3. See Ticket #44 for clarifications. Fixes #44.

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