VirtualBox

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

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

kmk: replaced strcache with strcacahe2.

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