VirtualBox

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

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

Environment / global variable renaming. Copyright header/year update.

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