VirtualBox

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

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

solaris has mallinfo, but only in an alternative lib that is slower. duh.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.4 KB
Line 
1# $Id: Makefile.kmk 2057 2008-11-04 19:23:30Z 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 3 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, see <http://www.gnu.org/licenses/>
23#
24#
25
26SUB_DEPTH = ../..
27include $(KBUILD_PATH)/subheader.kmk
28
29
30#
31# Template for kmk and the kmk_* binaries in this makefile.
32#
33TEMPLATE_BIN-KMK = Template for src/gmake binaries
34TEMPLATE_BIN-KMK_EXTENDS = BIN
35TEMPLATE_BIN-KMK_DEFS = \
36 HAVE_CONFIG_H \
37 $(TEMPLATE_BIN_DEFS) \
38 KBUILD_SVN_REV=$(KBUILD_SVN_REV) \
39 KBUILD_TYPE=\"$(KBUILD_TYPE)\"
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_DEFINED \
137 CONFIG_WITH_EXPLICIT_MULTITARGET \
138 CONFIG_WITH_DOT_MUST_MAKE \
139 CONFIG_WITH_PREPEND_ASSIGNMENT \
140 CONFIG_WITH_LOCAL_VARIABLES \
141 CONFIG_WITH_2ND_TARGET_EXPANSION \
142 CONFIG_WITH_ALLOC_CACHES \
143 CONFIG_WITH_STRCACHE2 \
144 \
145 KMK \
146 KMK_HELPERS \
147 CONFIG_NO_DEFAULT_SUFFIXES \
148 CONFIG_NO_DEFAULT_PATTERN_RULES \
149 CONFIG_NO_DEFAULT_TERMINAL_RULES \
150 CONFIG_NO_DEFAULT_SUFFIX_RULES \
151 CONFIG_NO_DEFAULT_VARIABLES \
152 CONFIG_WITH_EXTENDED_NOTPARALLEL \
153 CONFIG_WITH_INCLUDEDEP \
154 CONFIG_WITH_VALUE_LENGTH \
155 CONFIG_WITH_RSORT \
156 CONFIG_WITH_ABSPATHEX \
157 CONFIG_WITH_COMPARE \
158 CONFIG_WITH_STACK \
159 CONFIG_WITH_MATH \
160 CONFIG_WITH_XARGS \
161 CONFIG_WITH_NANOTS \
162 CONFIG_WITH_SET_CONDITIONALS \
163 CONFIG_WITH_IF_CONDITIONALS \
164 CONFIG_WITH_DATE \
165 CONFIG_WITH_FILE_SIZE \
166 CONFIG_WITH_WHICH \
167 CONFIG_WITH_EVALPLUS \
168 CONFIG_WITH_MINIMAL_STATS \
169 CONFIG_WITH_COMMANDS_FUNC \
170 CONFIG_PRETTY_COMMAND_PRINTING \
171 CONFIG_WITH_PRINT_STATS_SWITCH \
172 CONFIG_WITH_RDONLY_VARIABLE_VALUE \
173 CONFIG_WITH_LAZY_DEPS_VARS \
174 CONFIG_WITH_MEMORY_OPTIMIZATIONS \
175 \
176 KBUILD_HOST=\"$(KBUILD_TARGET)\" \
177 KBUILD_HOST_ARCH=\"$(KBUILD_TARGET_ARCH)\" \
178 KBUILD_HOST_CPU=\"$(KBUILD_TARGET_CPU)\"
179kmk_DEFS.x86 = CONFIG_WITH_OPTIMIZATION_HACKS
180kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS
181kmk_DEFS.win = CONFIG_NEW_WIN32_CTRL_EVENT
182kmk_DEFS.debug = CONFIG_WITH_MAKE_STATS
183
184kmk_SOURCES = \
185 main.c \
186 kbuild.c \
187 read.c \
188 expreval.c \
189 incdep.c \
190 hash.c \
191 strcache.c \
192 strcache2.c \
193 variable.c \
194 ar.c \
195 arscan.c \
196 commands.c \
197 default.c \
198 dir.c \
199 expand.c \
200 file.c \
201 function.c \
202 implicit.c \
203 job.c \
204 misc.c \
205 remake.c \
206 rule.c \
207 signame.c \
208 version.c \
209 vpath.c \
210 remote-stub.c
211
212#kmk_LIBS.solaris = malloc
213#kmk_DEFS.solaris += HAVE_MALLINFO
214
215#
216# kmkbuiltin commands
217#
218kmk_DEFS += CONFIG_WITH_KMK_BUILTIN
219kmk_LIBS += $(LIB_KUTIL) $(LIB_KDEP)
220kmk_SOURCES += \
221 kmkbuiltin.c \
222 kmkbuiltin/append.c \
223 kmkbuiltin/cat.c \
224 kmkbuiltin/chmod.c \
225 kmkbuiltin/cmp.c \
226 kmkbuiltin/cmp_util.c \
227 kmkbuiltin/cp.c \
228 kmkbuiltin/cp_utils.c \
229 kmkbuiltin/echo.c \
230 kmkbuiltin/expr.c \
231 kmkbuiltin/install.c \
232 kmkbuiltin/kDepIDB.c \
233 kmkbuiltin/md5sum.c \
234 kmkbuiltin/mkdir.c \
235 kmkbuiltin/mv.c \
236 kmkbuiltin/ln.c \
237 kmkbuiltin/printf.c \
238 kmkbuiltin/rm.c \
239 kmkbuiltin/rmdir.c \
240 kmkbuiltin/sleep.c \
241 kmkbuiltin/test.c \
242
243## @todo kmkbuiltin/redirect.c
244
245## Some profiling
246#kmk_SOURCES += kbuildprf.c
247#kmk_DEFS += open=prf_open read=prf_read lseek=prf_lseek close=prf_close
248##kmk_DEFS += KMK_PRF=1
249##kmkmissing_DEFS += KMK_PRF=1
250
251#
252# Standalone kmkbuiltin commands.
253#
254PROGRAMS += \
255 kmk_append \
256 kmk_cat \
257 kmk_chmod \
258 kmk_cp \
259 kmk_cmp \
260 kmk_echo \
261 kmk_expr \
262 kmk_md5sum \
263 kmk_mkdir \
264 kmk_mv \
265 kmk_install \
266 kmk_ln \
267 kmk_printf \
268 kmk_redirect \
269 kmk_rm \
270 kmk_rmdir \
271 kmk_sleep \
272 kmk_test \
273 kDepIDB \
274
275kmk_append_TEMPLATE = BIN-KMK
276kmk_append_DEFS = kmk_builtin_append=main
277kmk_append_INCS = .
278kmk_append_SOURCES = \
279 kmkbuiltin/append.c
280
281kmk_cat_TEMPLATE = BIN-KMK
282kmk_cat_DEFS = kmk_builtin_cat=main
283kmk_cat_SOURCES = \
284 kmkbuiltin/cat.c
285
286kmk_chmod_TEMPLATE = BIN-KMK
287kmk_chmod_DEFS = kmk_builtin_chmod=main
288kmk_chmod_SOURCES = \
289 kmkbuiltin/chmod.c
290
291kmk_cmp_TEMPLATE = BIN-KMK
292kmk_cmp_DEFS = kmk_builtin_cmp=main
293kmk_cmp_SOURCES = \
294 kmkbuiltin/cmp.c \
295 kmkbuiltin/cmp_util.c
296
297kmk_cp_TEMPLATE = BIN-KMK
298kmk_cp_DEFS = kmk_builtin_cp=main
299kmk_cp_SOURCES = \
300 kmkbuiltin/cp.c \
301 kmkbuiltin/cp_utils.c \
302 kmkbuiltin/cmp_util.c
303
304kmk_echo_TEMPLATE = BIN-KMK
305kmk_echo_DEFS = kmk_builtin_echo=main
306kmk_echo_SOURCES = \
307 kmkbuiltin/echo.c
308
309kmk_expr_TEMPLATE = BIN-KMK
310kmk_expr_DEFS = kmk_builtin_expr=main
311kmk_expr_SOURCES = \
312 kmkbuiltin/expr.c
313
314kmk_install_TEMPLATE = BIN-KMK
315kmk_install_DEFS = kmk_builtin_install=main
316kmk_install_SOURCES = \
317 kmkbuiltin/install.c
318
319kmk_ln_TEMPLATE = BIN-KMK
320kmk_ln_DEFS = kmk_builtin_ln=main
321kmk_ln_SOURCES = \
322 kmkbuiltin/ln.c
323
324kmk_mkdir_TEMPLATE = BIN-KMK
325kmk_mkdir_DEFS = kmk_builtin_mkdir=main
326kmk_mkdir_SOURCES = \
327 kmkbuiltin/mkdir.c
328
329kmk_md5sum_TEMPLATE = BIN-KMK
330kmk_md5sum_DEFS = kmk_builtin_md5sum=main
331kmk_md5sum_SOURCES = \
332 kmkbuiltin/md5sum.c
333kmk_md5sum_LIBS = $(LIB_KUTIL)
334
335kmk_mv_TEMPLATE = BIN-KMK
336kmk_mv_DEFS = kmk_builtin_mv=main
337kmk_mv_SOURCES = \
338 kmkbuiltin/mv.c
339
340kmk_printf_TEMPLATE = BIN-KMK
341kmk_printf_DEFS = kmk_builtin_printf=main
342kmk_printf_SOURCES = \
343 kmkbuiltin/printf.c
344
345kmk_rm_TEMPLATE = BIN-KMK
346kmk_rm_DEFS = kmk_builtin_rm=main
347kmk_rm_SOURCES = \
348 kmkbuiltin/rm.c
349
350kmk_redirect_TEMPLATE = BIN-KMK
351kmk_redirect_DEFS = kmk_builtin_redirect=main
352kmk_redirect_SOURCES = \
353 kmkbuiltin/redirect.c
354
355kmk_rmdir_TEMPLATE = BIN-KMK
356kmk_rmdir_DEFS = kmk_builtin_rmdir=main
357kmk_rmdir_SOURCES = \
358 kmkbuiltin/rmdir.c
359
360kmk_sleep_TEMPLATE = BIN-KMK
361kmk_sleep_DEFS = kmk_builtin_sleep=main
362kmk_sleep_SOURCES = \
363 kmkbuiltin/sleep.c
364
365kmk_test_TEMPLATE = BIN-KMK
366kmk_test_DEFS = kmk_builtin_test=main
367kmk_test_SOURCES = \
368 kmkbuiltin/test.c
369
370kDepIDB_TEMPLATE = BIN-KMK
371kDepIDB_DEFS = kmk_builtin_kDepIDB=main
372kDepIDB_INCS = .
373kDepIDB_LIBS = $(LIB_KDEP)
374kDepIDB_SOURCES = \
375 kmkbuiltin/kDepIDB.c
376
377
378#
379# kmk_gmake - almost plain GNU Make.
380#
381PROGRAMS += kmk_gmake
382
383kmk_gmake_TEMPLATE = BIN-KMK
384kmk_gmake_DEFS = \
385 HAVE_CONFIG_H \
386 NO_ARCHIVES \
387 CONFIG_WITH_TOUPPER_TOLOWER \
388 EXPERIMENTAL
389
390kmk_gmake_SOURCES = \
391 main.c \
392 read.c \
393 hash.c \
394 strcache.c \
395 variable.c \
396 ar.c \
397 arscan.c \
398 commands.c \
399 default.c \
400 dir.c \
401 expand.c \
402 file.c \
403 function.c \
404 implicit.c \
405 job.c \
406 misc.c \
407 remake.c \
408 rule.c \
409 signame.c \
410 version.c \
411 vpath.c \
412 remote-stub.c
413
414
415#
416# kmk_fmake - Faster GNU Make.
417#
418PROGRAMS += kmk_fgmake
419
420kmk_fgmake_TEMPLATE = BIN-KMK
421kmk_fgmake_DEFS = \
422 HAVE_CONFIG_H \
423 NO_ARCHIVES \
424 CONFIG_WITH_TOUPPER_TOLOWER \
425 EXPERIMENTAL \
426 \
427 CONFIG_WITH_ALLOC_CACHES \
428 CONFIG_WITH_LAZY_DEPS_VARS \
429 CONFIG_WITH_STRCACHE2 \
430 CONFIG_WITH_VALUE_LENGTH \
431 CONFIG_WITH_RDONLY_VARIABLE_VALUE
432# TODO ?
433# CONFIG_WITH_PRINT_STATS_SWITCH \
434# CONFIG_WITH_EXTENDED_NOTPARALLEL \
435
436kmk_fgmake_SOURCES = \
437 main.c \
438 read.c \
439 hash.c \
440 strcache.c \
441 strcache2.c \
442 variable.c \
443 ar.c \
444 arscan.c \
445 commands.c \
446 default.c \
447 dir.c \
448 expand.c \
449 file.c \
450 function.c \
451 implicit.c \
452 job.c \
453 misc.c \
454 remake.c \
455 rule.c \
456 signame.c \
457 version.c \
458 vpath.c \
459 remote-stub.c
460
461
462include $(FILE_KBUILD_SUB_FOOTER)
463
464
465#
466# Use checked in config.h instead of running ./Configure for it.
467#
468kmk_config.h.$(KBUILD_TARGET) := $(kmk_PATH)/config.h.$(KBUILD_TARGET)
469$(PATH_kmk)/config.h: $(kmk_config.h.$(KBUILD_TARGET))
470 $(MKDIR) -p $(dir $@)
471 $(CP) $^ $@
472
473#
474# Some missing headers.
475#
476$(PATH_kmk)/fts.h: $(kmk_PATH)/kmkbuiltin/ftsfake.h | $(call DIRDEP,$(PATH_kmk))
477 $(CP) $^ $@
478
479$(PATH_kmk)/unistd.h: | $(call DIRDEP,$(PATH_kmk))
480 $(ECHO_EXT) > $@
481
482$(PATH_kmk)/sysexits.h: | $(call DIRDEP,$(PATH_kmk))
483 $(ECHO_EXT) > $@
484
485$(PATH_kmk)/inttypes.h: | $(call DIRDEP,$(PATH_kmk))
486 $(ECHO_EXT) > $@
487
488$(PATH_kmk)/paths.h: | $(call DIRDEP,$(PATH_kmk))
489 $(ECHO_EXT) > $@
490
491$(PATH_kmk)/pwd.h: | $(call DIRDEP,$(PATH_kmk))
492 $(ECHO_EXT) > $@
493
494$(PATH_kmk)/grp.h: | $(call DIRDEP,$(PATH_kmk))
495 $(ECHO_EXT) > $@
496
497
498#
499# Some tests.
500#
501parallel: parallel_1 parallel_2 parallel_3 parallel_4 parallel_5
502parallel_1 parallel_2 parallel_3 parallel_4 parallel_5:
503 echo $@_start ; sleep 1; echo $@_done
504
505test:
506 echo "1"
507 echo "2"
508 echo "3"
509 echo "4"
510
511
512#
513# Shell execution tests.
514#
515test_shell: test_shell_quoting test_shell_double_quoting test_shell_newline
516
517# shell double and single quoting check (was busted on windows in 3.81).
518test_shell_quoting:
519 $(ECHO_EXT) "double quoted sTrInG"
520 $(ECHO_EXT) "double quoted sTrInG" | $(SED_EXT) -e "s/sTrInG/string/g"
521 $(ECHO_EXT) 'single quoted sTrInG' | $(SED_EXT) -e 's/sTrInG/string/g'
522 $(ECHO) "This string should not be printed with double quotes."
523 $(ECHO) 'This string should not be printed with single quotes.'
524 ( echo " #define PWD \"`pwd`\""; )
525
526test_shell_double_quoting:
527 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
528 "s/foo/$@/" -e \
529 "s/foo/works/" \
530 -e "s/foo/\!/"
531
532test_shell_double_quoting2:
533 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
534 "s/foo/$@/" -e \
535 "s/foo/works/" \
536 -e\
537 "s/foo/\!/"
538
539# when using batch mode shell, the newline got escaped twice and spoiling everything.
540test_shell_newline:
541 $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \
542 's/foo/$@/' -e \
543 's/foo/works/' \
544 -e 's/foo/\!/'
545
546
547test_stack:
548 $(MAKE) -f $(kmk_PATH)/testcase-stack.kmk
549
550test_math:
551 $(MAKE) -f $(kmk_PATH)/testcase-math.kmk
552
553test_if1of:
554 $(MAKE) -f $(kmk_PATH)/testcase-if1of.kmk
555
556test_local:
557 $(MAKE) -f $(kmk_PATH)/testcase-local.kmk
558
559test_includedep:
560 $(MAKE) -f $(kmk_PATH)/testcase-includedep.kmk
561
562test_2ndtargetexp:
563 $(MAKE) -f $(kmk_PATH)/testcase-2ndtargetexp.kmk
564
565test_30_continued_on_failure_worker:
566 this_executable_does_not_exist.exe
567 echo "We shouldn't see this..."
568
569test_30_continued_on_failure:
570 $(MAKE) -f $(MAKEFILE) test_30_continued_on_failure_worker; \
571 RC=$$?; \
572 if test $${RC} -ne 2; then \
573 echo "$@: FAILED - exit code $${RC} instead of 2."; \
574 exit 1; \
575 else \
576 echo "$@: SUCCESS"; \
577 fi
578
579test_lazy_deps_vars:
580 $(MAKE) -C $(kmk_PATH) -f testcase-lazy-deps-vars.kmk
581
582
583test_all: test_math test_stack test_shell test_if1of test_local test_includedep test_2ndtargetexp test_30_continued_on_failure test_lazy_deps_vars
584
585
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