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