VirtualBox

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

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

Fixed build issue on windows.

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