VirtualBox

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

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

FreeBSD needs pthreads.

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