VirtualBox

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

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

OpenBSD hacks.

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