VirtualBox

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

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

kmk: Made struct variable capable of holding read only variables to speed up set_file_variables.

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