VirtualBox

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

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

kmk: delegating variable string hashing to the strcache, dropping the VARIALBE_HASH hack (remaining code to be removed).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.3 KB
Line 
1# $Id: Makefile.kmk 1887 2008-10-19 23:08:10Z 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 2 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, write to the Free Software
23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24#
25#
26
27SUB_DEPTH = ../..
28include $(KBUILD_PATH)/subheader.kmk
29
30
31#
32# Template for kmk and the kmk_* binaries in this makefile.
33#
34TEMPLATE_BIN-KMK = Template for src/gmake binaries
35TEMPLATE_BIN-KMK_EXTENDS = BIN
36TEMPLATE_BIN-KMK_DEFS = \
37 HAVE_CONFIG_H \
38 $(TEMPLATE_BIN_DEFS) \
39 KBUILD_SVN_REV=$(KBUILD_SVN_REV)
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_MAKE_STATS \
168 CONFIG_WITH_COMMANDS_FUNC \
169 CONFIG_PRETTY_COMMAND_PRINTING \
170 \
171 KBUILD_HOST=\"$(KBUILD_TARGET)\" \
172 KBUILD_HOST_ARCH=\"$(KBUILD_TARGET_ARCH)\" \
173 KBUILD_HOST_CPU=\"$(KBUILD_TARGET_CPU)\"
174kmk_DEFS.x86 = CONFIG_WITH_OPTIMIZATION_HACKS
175kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS
176kmk_DEFS.win = CONFIG_NEW_WIN32_CTRL_EVENT
177
178kmk_SOURCES = \
179 main.c \
180 read.c \
181 expreval.c \
182 incdep.c \
183 hash.c \
184 strcache.c \
185 strcache2.c \
186 variable.c \
187 ar.c \
188 arscan.c \
189 commands.c \
190 default.c \
191 dir.c \
192 expand.c \
193 file.c \
194 function.c \
195 implicit.c \
196 job.c \
197 misc.c \
198 remake.c \
199 rule.c \
200 signame.c \
201 version.c \
202 vpath.c \
203 remote-stub.c \
204 kbuild.c
205
206#
207# kmkbuiltin commands
208#
209kmk_DEFS += CONFIG_WITH_KMK_BUILTIN
210kmk_LIBS += $(LIB_KUTIL) $(LIB_KDEP)
211kmk_SOURCES += \
212 kmkbuiltin.c \
213 kmkbuiltin/append.c \
214 kmkbuiltin/cat.c \
215 kmkbuiltin/chmod.c \
216 kmkbuiltin/cmp.c \
217 kmkbuiltin/cmp_util.c \
218 kmkbuiltin/cp.c \
219 kmkbuiltin/cp_utils.c \
220 kmkbuiltin/echo.c \
221 kmkbuiltin/expr.c \
222 kmkbuiltin/install.c \
223 kmkbuiltin/kDepIDB.c \
224 kmkbuiltin/md5sum.c \
225 kmkbuiltin/mkdir.c \
226 kmkbuiltin/mv.c \
227 kmkbuiltin/ln.c \
228 kmkbuiltin/printf.c \
229 kmkbuiltin/rm.c \
230 kmkbuiltin/rmdir.c \
231 kmkbuiltin/test.c \
232
233## @todo kmkbuiltin/redirect.c
234
235## Some profiling
236#kmk_SOURCES += kbuildprf.c
237#kmk_DEFS += open=prf_open read=prf_read lseek=prf_lseek close=prf_close
238##kmk_DEFS += KMK_PRF=1
239##kmkmissing_DEFS += KMK_PRF=1
240
241#
242# Standalone kmkbuiltin commands.
243#
244PROGRAMS += \
245 kmk_append \
246 kmk_cat \
247 kmk_chmod \
248 kmk_cp \
249 kmk_cmp \
250 kmk_echo \
251 kmk_expr \
252 kmk_md5sum \
253 kmk_mkdir \
254 kmk_mv \
255 kmk_install \
256 kmk_ln \
257 kmk_printf \
258 kmk_redirect \
259 kmk_rm \
260 kmk_rmdir \
261 kmk_test \
262 kDepIDB \
263
264kmk_append_TEMPLATE = BIN-KMK
265kmk_append_DEFS = kmk_builtin_append=main
266kmk_append_INCS = .
267kmk_append_SOURCES = \
268 kmkbuiltin/append.c
269
270kmk_cat_TEMPLATE = BIN-KMK
271kmk_cat_DEFS = kmk_builtin_cat=main
272kmk_cat_SOURCES = \
273 kmkbuiltin/cat.c
274
275kmk_chmod_TEMPLATE = BIN-KMK
276kmk_chmod_DEFS = kmk_builtin_chmod=main
277kmk_chmod_SOURCES = \
278 kmkbuiltin/chmod.c
279
280kmk_cmp_TEMPLATE = BIN-KMK
281kmk_cmp_DEFS = kmk_builtin_cmp=main
282kmk_cmp_SOURCES = \
283 kmkbuiltin/cmp.c \
284 kmkbuiltin/cmp_util.c
285
286kmk_cp_TEMPLATE = BIN-KMK
287kmk_cp_DEFS = kmk_builtin_cp=main
288kmk_cp_SOURCES = \
289 kmkbuiltin/cp.c \
290 kmkbuiltin/cp_utils.c \
291 kmkbuiltin/cmp_util.c
292
293kmk_echo_TEMPLATE = BIN-KMK
294kmk_echo_DEFS = kmk_builtin_echo=main
295kmk_echo_SOURCES = \
296 kmkbuiltin/echo.c
297
298kmk_expr_TEMPLATE = BIN-KMK
299kmk_expr_DEFS = kmk_builtin_expr=main
300kmk_expr_SOURCES = \
301 kmkbuiltin/expr.c
302
303kmk_install_TEMPLATE = BIN-KMK
304kmk_install_DEFS = kmk_builtin_install=main
305kmk_install_SOURCES = \
306 kmkbuiltin/install.c
307
308kmk_ln_TEMPLATE = BIN-KMK
309kmk_ln_DEFS = kmk_builtin_ln=main
310kmk_ln_SOURCES = \
311 kmkbuiltin/ln.c
312
313kmk_mkdir_TEMPLATE = BIN-KMK
314kmk_mkdir_DEFS = kmk_builtin_mkdir=main
315kmk_mkdir_SOURCES = \
316 kmkbuiltin/mkdir.c
317
318kmk_md5sum_TEMPLATE = BIN-KMK
319kmk_md5sum_DEFS = kmk_builtin_md5sum=main
320kmk_md5sum_SOURCES = \
321 kmkbuiltin/md5sum.c
322kmk_md5sum_LIBS = $(LIB_KUTIL)
323
324kmk_mv_TEMPLATE = BIN-KMK
325kmk_mv_DEFS = kmk_builtin_mv=main
326kmk_mv_SOURCES = \
327 kmkbuiltin/mv.c
328
329kmk_printf_TEMPLATE = BIN-KMK
330kmk_printf_DEFS = kmk_builtin_printf=main
331kmk_printf_SOURCES = \
332 kmkbuiltin/printf.c
333
334kmk_rm_TEMPLATE = BIN-KMK
335kmk_rm_DEFS = kmk_builtin_rm=main
336kmk_rm_SOURCES = \
337 kmkbuiltin/rm.c
338
339kmk_redirect_TEMPLATE = BIN-KMK
340kmk_redirect_DEFS = kmk_builtin_redirect=main
341kmk_redirect_SOURCES = \
342 kmkbuiltin/redirect.c
343
344kmk_rmdir_TEMPLATE = BIN-KMK
345kmk_rmdir_DEFS = kmk_builtin_rmdir=main
346kmk_rmdir_SOURCES = \
347 kmkbuiltin/rmdir.c
348
349kmk_test_TEMPLATE = BIN-KMK
350kmk_test_DEFS = kmk_builtin_test=main
351kmk_test_SOURCES = \
352 kmkbuiltin/test.c
353
354kDepIDB_TEMPLATE = BIN-KMK
355kDepIDB_DEFS = kmk_builtin_kDepIDB=main
356kDepIDB_INCS = .
357kDepIDB_LIBS = $(LIB_KDEP)
358kDepIDB_SOURCES = \
359 kmkbuiltin/kDepIDB.c
360
361
362#
363# kmk_gmake - almost plain GNU Make.
364#
365PROGRAMS += kmk_gmake
366
367kmk_gmake_TEMPLATE = BIN-KMK
368kmk_gmake_DEFS = \
369 HAVE_CONFIG_H \
370 NO_ARCHIVES \
371 CONFIG_WITH_TOUPPER_TOLOWER \
372 EXPERIMENTAL
373
374kmk_gmake_SOURCES = \
375 main.c \
376 read.c \
377 hash.c \
378 strcache.c \
379 variable.c \
380 ar.c \
381 arscan.c \
382 commands.c \
383 default.c \
384 dir.c \
385 expand.c \
386 file.c \
387 function.c \
388 implicit.c \
389 job.c \
390 misc.c \
391 remake.c \
392 rule.c \
393 signame.c \
394 version.c \
395 vpath.c \
396 remote-stub.c
397
398
399include $(FILE_KBUILD_SUB_FOOTER)
400
401
402#
403# Use checked in config.h instead of running ./Configure for it.
404#
405kmk_config.h.$(KBUILD_TARGET) := $(kmk_PATH)/config.h.$(KBUILD_TARGET)
406$(PATH_kmk)/config.h: $(kmk_config.h.$(KBUILD_TARGET))
407 $(MKDIR) -p $(dir $@)
408 $(CP) $^ $@
409
410#
411# Some missing headers.
412#
413$(PATH_kmk)/fts.h: $(kmk_PATH)/kmkbuiltin/ftsfake.h | $(call DIRDEP,$(PATH_kmk))
414 $(CP) $^ $@
415
416$(PATH_kmk)/unistd.h: | $(call DIRDEP,$(PATH_kmk))
417 $(ECHO_EXT) > $@
418
419$(PATH_kmk)/sysexits.h: | $(call DIRDEP,$(PATH_kmk))
420 $(ECHO_EXT) > $@
421
422$(PATH_kmk)/inttypes.h: | $(call DIRDEP,$(PATH_kmk))
423 $(ECHO_EXT) > $@
424
425$(PATH_kmk)/paths.h: | $(call DIRDEP,$(PATH_kmk))
426 $(ECHO_EXT) > $@
427
428$(PATH_kmk)/pwd.h: | $(call DIRDEP,$(PATH_kmk))
429 $(ECHO_EXT) > $@
430
431$(PATH_kmk)/grp.h: | $(call DIRDEP,$(PATH_kmk))
432 $(ECHO_EXT) > $@
433
434
435#
436# Some tests.
437#
438parallel: parallel_1 parallel_2 parallel_3 parallel_4 parallel_5
439parallel_1 parallel_2 parallel_3 parallel_4 parallel_5:
440 echo $@_start ; sleep 1; echo $@_done
441
442test:
443 echo "1"
444 echo "2"
445 echo "3"
446 echo "4"
447
448
449#
450# Shell execution tests.
451#
452test_shell: test_shell_quoting test_shell_double_quoting test_shell_newline
453
454# shell double and single quoting check (was busted on windows in 3.81).
455test_shell_quoting:
456 $(ECHO_EXT) "double quoted sTrInG"
457 $(ECHO_EXT) "double quoted sTrInG" | $(SED_EXT) -e "s/sTrInG/string/g"
458 $(ECHO_EXT) 'single quoted sTrInG' | $(SED_EXT) -e 's/sTrInG/string/g'
459 $(ECHO) "This string should not be printed with double quotes."
460 $(ECHO) 'This string should not be printed with single quotes.'
461 ( echo " #define PWD \"`pwd`\""; )
462
463test_shell_double_quoting:
464 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
465 "s/foo/$@/" -e \
466 "s/foo/works/" \
467 -e "s/foo/\!/"
468
469test_shell_double_quoting2:
470 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
471 "s/foo/$@/" -e \
472 "s/foo/works/" \
473 -e\
474 "s/foo/\!/"
475
476# when using batch mode shell, the newline got escaped twice and spoiling everything.
477test_shell_newline:
478 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
479 's/foo/$@/' -e \
480 's/foo/works/' \
481 -e 's/foo/\!/'
482
483
484test_stack:
485 $(MAKE) -f $(kmk_PATH)/testcase-stack.kmk
486
487test_math:
488 $(MAKE) -f $(kmk_PATH)/testcase-math.kmk
489
490test_if1of:
491 $(MAKE) -f $(kmk_PATH)/testcase-if1of.kmk
492
493test_local:
494 $(MAKE) -f $(kmk_PATH)/testcase-local.kmk
495
496test_includedep:
497 $(MAKE) -f $(kmk_PATH)/testcase-includedep.kmk
498
499test_2ndtargetexp:
500 $(MAKE) -f $(kmk_PATH)/testcase-2ndtargetexp.kmk
501
502test_30_continued_on_failure_worker:
503 this_executable_does_not_exist.exe
504 echo "We shouldn't see this..."
505
506test_30_continued_on_failure:
507 $(MAKE) -f $(MAKEFILE) test_30_continued_on_failure_worker; \
508 RC=$$?; \
509 if test $${RC} -ne 2; then \
510 echo "$@: FAILED - exit code $${RC} instead of 2."; \
511 exit 1; \
512 else \
513 echo "$@: SUCCESS"; \
514 fi
515
516
517test_all: test_math test_stack test_shell test_if1of test_local test_includedep test_2ndtargetexp test_30_continued_on_failure
518
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