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