VirtualBox

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

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

Added comp-cmds-ex, commands, commands-sc and commands-usr. Added a '%' command prefix that make the commands functions skip the line. Added a -c flag to append that'll make it call commands on each argument (similar to -v). Fixed a little bug in comp-cmds/vars.

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