VirtualBox

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

Last change on this file since 1526 was 1526, checked in by bird, 17 years ago

Print the revision in the version info.

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