VirtualBox

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

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

kDepObj: Initial code that deals with Watcom and MASM OMF files.

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