VirtualBox

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

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

src/kmk/Makefile.kmk: freebsd.sparc64 build fix. (thanks to gahr)

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