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