VirtualBox

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

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

split out the path protection code from rm.

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