-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMake.global
428 lines (336 loc) · 11.6 KB
/
Make.global
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# "Make.global"
# vi: ft=automake
# Project-wide Makefile targets and dependencies.
# Generally, it is recommended to include this Makefile last.
# This file may be used as an includable Makefile snippet,
# or with automake for automatic inlining.
# NOTE: standard definition macros appear in "Make.stddef" and should
# be included *before* the inclusion of this Makefile.
# NOTE: the for-loop syntax used requires that SHELL = sh, not bash.
# $Id: Make.global,v 1.35 2010/04/22 19:06:53 fang Exp $
# automatically runs autotools (and recursively in subdirectories)
reconf: force
autoreconf
ALL_GITIGNORE =
SKIP_TEST_SCRIPT = \
$(ECHO) "Skipping $@ ..." ; \
{ $(ECHO) $(SHELL_INTERPRETER) ; \
$(ECHO) "\# \"$@\"" ; \
$(ECHO) "exit 77" ;} > $@ ; \
$(CHMOD) +x $@
DUMMY_TEST_SCRIPT = $(ECHO) "$(SHELL_INTERPRETER)" > $@ ; $(CHMOD) +x $@
# RECURSIVE_TARGETS =
# blatantly copied from Makefile.in, generated by automake
RECURSIVE_TARGET_SCRIPT = \
failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
# always bottom-up and reverse order
# NOTE: this script needs to be prepended with '+' to connect jobserver
CLEAN_RECURSIVE_TARGET_SCRIPT = \
set fnord $$MAKEFLAGS; amf=$$2; \
list='$(SUBDIRS)'; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
# demonstration of recursive target
MORE_RECURSIVE_TARGETS += pwd-recursive
pwd: pwd-recursive
pwd-am: pwd-local
pwd-local:
@$(ECHO) "======== "`pwd`
if AUTO_GITIGNORE
# .gitignore for this project will always be semi-automatically generated
# .gitignore is never needed for VPATH builds, duh!
$(srcdir)/.gitignore: $(srcdir)/Makefile.am $(top_srcdir)/Make.global
# make gitignore by default
ALL_GITIGNORE += gitignore-am
# phony recursive target
gitignore-recursive: $(srcdir)/.gitignore $(srcdir)/.gitignore force
gitignore: gitignore-recursive
gitignore-am: $(srcdir)/.gitignore $(srcdir)/.gitignore gitignore-local
clean-gitignore: clean-gitignore-recursive
clean-gitignore-am: clean-gitignore-local
-$(RM) $(srcdir)/.gitignore $(srcdir)/.gitignore
PHONY_GITIGNORE = clean-gitignore-local clean-gitignore-am gitignore \
clean-gitignore gitignore-local gitignore-am
# automake doesn't like b/c RECURSIVE_TARGETS not defined early enough
MORE_RECURSIVE_TARGETS += gitignore-recursive
MORE_CLEAN_RECURSIVE_TARGETS += clean-gitignore-recursive
# DISTCLEANFILES += $(srcdir)/.gitignore
else
gitignore:
endif
all-local: $(ALL_GITIGNORE)
MORE_RECURSIVE_TARGETS += build-check-recursive
build-check: build-check-recursive
build-check-am: build-check-local
build-check-local:
# convenient target for building subtree of the distribution
# not a recursive target
# this also clears out the target distribution directory first
distdir-subdir:
top_distdir="$(top_builddir)/$(PACKAGE)-$(VERSION)" ; \
distdir="$$top_distdir/$(subdir)" ; \
until rm -fr $$distdir ; do : ; done ; \
$(mkdir_p) $$distdir ; \
$(MAKE) top_distdir="$$top_distdir" distdir="$$distdir" distdir ; \
$(ECHO) "$$distdir ready for inspection."
# This target tells make to look exclusively in the srcdir for these files
# and copy them over to the distdir.
# This is needed because the EXTRA_DIST target sometimes finds unwanted files
# in the build directory. (e.g. auto-generated empty files)
# $distdir is assumed passed in as Makefile variable already because it
# is a dependency of dist-hook, which is a dependency of distdir.
# NOTE: this ignores files that are not found in the srcdir!
srcdir-distfiles: force
list='$(srcdir_EXTRA_DIST)'; \
for file in $$list ; do \
test ! -f $(srcdir)/$$file || cp -p $(srcdir)/$$file $(distdir) ; \
done
# for file in $$list ; do \
# case $$file in \
# $(srcdir)/*) cp $$file $(distdir) ;; \
# *) cp $(srcdir)/$$file $(distdir) ;; \
# esac ; \
# done
dist-hook: srcdir-distfiles
DISTCLEANFILES += check.log
DISTCLEANFILES += $(AUTO_DEPENDS)
cleandirs:
test -z "$(CLEANDIRS)" || $(RM) -r $(CLEANDIRS)
clean-local: cleandirs
# $distdir is assumed passed in as Makefile variable
MORE_CLEAN_RECURSIVE_TARGETS += distclean-depend-recursive
distclean-depend: distclean-depend-recursive distclean-depend-am
distclean-depend-am: distclean-depend-local
distcleandirs:
test -z "$(DISTCLEANDIRS)" || $(RM) -r $(DISTCLEANDIRS)
distclean-local: distcleandirs distclean-depend-local
# $distdir is assumed passed in as Makefile variable
dist-hook-autoclean:
-cd $(distdir) && { test -z "$(DISTHOOK_CLEANFILES)" || $(RM) $(DISTHOOK_CLEANFILES) ;}
dist-hook: dist-hook-autoclean
# list of files to automatically git ignore, accumulated over Makefile
AUTO_IGNORE += .gdb_history .gitignore \
Makefile.in Makefile make.log ignore backup temp \
$(CLEANFILES) $(DISTCLEANFILES)
# echo makefile debugging
echo-extra-dist: force
@$(ECHO) $(EXTRA_DIST)
echo-srcdir-extra-dist: force
@$(ECHO) $(srcdir_EXTRA_DIST)
# list the automatically distributed files
echo-dist-common: force
@$(ECHO) $(DIST_COMMON)
echo-distfiles: force
@$(ECHO) $(DISTFILES)
echo-cleanfiles: force
@$(ECHO) $(CLEANFILES)
echo-disthook-cleanfiles: force
@$(ECHO) $(DISTHOOK_CLEANFILES)
echo-distcleanfiles: force
@$(ECHO) $(DISTCLEANFILES)
echo-auto-ignore: force
@$(ECHO) $(AUTO_IGNORE)
echo-config: force
cd $(top_builddir) && ./config.status --version
echo-compile:
@$(ECHO) $(COMPILE)
echo-cxxcompile:
@$(ECHO) $(CXXCOMPILE)
echo-srcdir: force
@$(ECHO) $(srcdir)
echo-top-srcdir: force
@$(ECHO) $(top_srcdir)
echo-top-builddir: force
@$(ECHO) $(top_builddir)
echo-subdir: force
@$(ECHO) $(subdir)
echo-subdirs: force
@$(ECHO) $(SUBDIRS)
echo-dist-subdirs: force
@$(ECHO) $(DIST_SUBDIRS)
echo-build: force
@$(ECHO) $(build)
echo-host: force
@$(ECHO) $(host)
echo-program-transform-name: force
@$(ECHO) $(program_transform_name)
echo-prefix: force
@$(ECHO) $(prefix)
echo-exec-prefix: force
@$(ECHO) $(exec_prefix)
echo-programs: force
@$(ECHO) $(PROGRAMS)
echo-scripts: force
@$(ECHO) $(SCRIPTS)
echo-data: force
@$(ECHO) $(DATA)
echo-texinfos: force
@$(ECHO) $(TEXINFOS)
echo-dvis: force
@$(ECHO) $(DVIS)
echo-pdfs: force
@$(ECHO) $(PDFS)
echo-pss: force
@$(ECHO) $(PSS)
echo-htmls: force
@$(ECHO) $(htmls)
echo-package: force
@$(ECHO) $(PACKAGE)
echo-package-bugreport: force
@$(ECHO) $(PACKAGE_BUGREPORT)
echo-package-version: force
@$(ECHO) $(PACKAGE_VERSION)
echo-SUFFIXES: force
@$(ECHO) $(SUFFIXES)
echo-LEX: force
@$(ECHO) $(LEX)
echo-YACC: force
@$(ECHO) $(YACC)
echo-AM_CFLAGS: force
@$(ECHO) $(AM_CFLAGS)
echo-AM_CXXFLAGS: force
@$(ECHO) $(AM_CXXFLAGS)
echo-AM_CPPFLAGS: force
@$(ECHO) $(AM_CPPFLAGS)
echo-AM_LDFLAGS: force
@$(ECHO) $(AM_LDFLAGS)
echo-CFLAGS: force
@$(ECHO) $(CFLAGS)
echo-CXXFLAGS: force
@$(ECHO) $(CXXFLAGS)
echo-CPPFLAGS: force
@$(ECHO) $(CPPFLAGS)
echo-LDFLAGS: force
@$(ECHO) $(LDFLAGS)
echo-LIBS: force
@$(ECHO) $(LIBS)
# might as well include this for non-maintainers too
# again, can't append to file with cat redirection because distclean
# sets permissions of new files as read-only
# NOTE: local.gitignore may be normal or automatically generated
if AUTO_GITIGNORE
$(srcdir)/.gitignore: local.gitignore
@$(ECHO) $(AUTO_IGNORE) | $(SPACES_TO_NEWLINE) > [email protected]
-$(CAT) $< [email protected] > $@
-$(RM) [email protected]
endif
# -k option allows continuation past directories with failed tests
check.log: force
@$(ECHO) "Logging results of \"make -k check\" in $@ ..."
@$(ECHO) Tests started `$(DATE)` > [email protected]
-$(MAKE) -k check >> [email protected] 2>&1
@$(ECHO) Tests finished `$(DATE)` >> [email protected]
-$(MV) [email protected] $@
# dump failures
-$(GREP) -v "^PASS" $@ | $(GREP) -v "ignored"
-$(GREP) "^Tests" $@
# @$(ECHO) `$(GREP) "Abort trap" $@ | wc -l` cases crashed.
# @$(ECHO) Total of `$(GREP) ^FAIL $@ | wc -l` failures encountered.
$(AWK) -f $(top_srcdir)/scripts/tally_tests.awk $@
@if $(GREP) "make.* \*\*\* " $@ ; then \
$(ECHO) "Errors found! see $@." ; \
exit 1 ; \
fi
# filters are specific to this project
# don't depend on check.log which is forced
check.log.filter:
@test -f check.log && \
$(CAT) check.log | $(GREP) -v "^Summarizing" | \
$(GREP) -v "src/hackt" > $@ \
|| $(ECHO) "\'make check.log\' first"
# general rule for recursive targets
$(MORE_RECURSIVE_TARGETS):
+@$(RECURSIVE_TARGET_SCRIPT)
$(MORE_CLEAN_RECURSIVE_TARGETS):
+@$(CLEAN_RECURSIVE_TARGET_SCRIPT)
# this shouldn't be parallel...
# .NOTPARALLEL: help
# .NOTPARALLEL unfortunately kills everything...
# help: help-global help-local
help:
# ignore stderr
-@{ $(CALLMAKE) help-global ; \
$(CALLMAKE) help-local ;} 2> /dev/null
help-local:
# brief description of targets
help-global:
@$(ECHO) "Global make targets:" ; \
$(ECHO) " help: lists some useful make targets" ; \
$(ECHO) " all: builds everything (recursive)" ; \
$(ECHO) " clean: removes make targets (recursive)" ; \
$(ECHO) " distclean: removes configure targets (recursive)"
if AUTO_GITIGNORE
@$(ECHO) " gitignore: generates $$(srcdir)/.gitignore (recursive)" ; \
$(ECHO) " clean-gitignore: cleans $$(srcdir)/.gitignore (recursive)"
endif
@$(ECHO) " check: runs tests (recursive)" ; \
$(ECHO) " build-check: create/run tests, without check (recursive)" ; \
$(ECHO) " check.log: logs make check -k" ; \
$(ECHO) " distdir-subdir: packages subtree of distribution" ; \
$(ECHO) " pdf: builds PDFs (recursive)" ; \
$(ECHO) " ps: builds PostScripts (recursive)" ; \
$(ECHO) " info: builds texinfo files (recursive)" ; \
$(ECHO) " html: builds HTML files (recursive)" ; \
$(ECHO) " echo-*:" ; \
$(ECHO) " config: configure invocation (config.status --version)" ; \
$(ECHO) " cleanfiles: list of cleaned files" ; \
$(ECHO) " distcleanfiles: list of distcleaned files" ; \
$(ECHO) " SUFFIXES: list of Makefile suffixes" ; \
$(ECHO) " extra-dist: list of EXTRA_DIST files" ; \
$(ECHO) " srcdir-extra-dist: list of source-only distrib. files" ; \
$(ECHO) " dist-common: list automatic DIST_COMMON files" ; \
$(ECHO) " distfiles: list of all DISTFILES" ; \
$(ECHO) " disthook-cleanfiles: list of all DISTHOOK_CLEANFILES" ; \
$(ECHO) " auto-ignore: list of automatic gitignored files" ; \
$(ECHO) " srcdir, top-srcdir, top-builddir, subdir, " ; \
$(ECHO) " build, host, prefix, exec-prefix" ; \
$(ECHO) " subdirs, dist-subdirs" ; \
$(ECHO) " programs, scripts, data" ; \
$(ECHO) " texinfos, dvis, pdfs, pss, htmls" ; \
$(ECHO) " program-transform-name, package{,-version,-bugreport}" ; \
$(ECHO) " CFLAGS, CXXFLAGS, CPPFLAGS, LDFLAGS, AM_*FLAGS, LIBS, LEX, YACC"
# http://xkcd.com/149/
sandwich:
@if test `whoami` = "root" ; then \
$(ECHO) "Okay." ; \
else \
$(ECHO) "What? Make it yourself." ; \
fi
# standard phony target for unconditional targets
force:
.PHONY: force $(PHONY_GITIGNORE) \
$(MORE_RECURSIVE_TARGETS) $(MORE_CLEAN_RECURSIVE_TARGETS) \
help help-local help-global dist-hook dist-hook-autoclean \
srcdir-distfiles build-check build-check-am build-check-local \
distclean-depend distclean-depend-am distclean-depend-local