Git fork
1### Remove GNU make implicit rules
2
3## This speeds things up since we don't need to look for and stat() a
4## "foo.c,v" every time a rule referring to "foo.c" is in play. See
5## "make -p -f/dev/null | grep ^%::'".
6%:: %,v
7%:: RCS/%,v
8%:: RCS/%
9%:: s.%
10%:: SCCS/s.%
11
12## Likewise delete default $(SUFFIXES). See:
13##
14## info make --index-search=.SUFFIXES
15.SUFFIXES:
16
17### Flags affecting all rules
18
19# A GNU make extension since gmake 3.72 (released in late 1994) to
20# remove the target of rules if commands in those rules fail. The
21# default is to only do that if make itself receives a signal. Affects
22# all targets, see:
23#
24# info make --index-search=.DELETE_ON_ERROR
25.DELETE_ON_ERROR:
26
27### Global variables
28
29## comma, empty, space: handy variables as these tokens are either
30## special or can be hard to spot among other Makefile syntax.
31comma := ,
32empty :=
33space := $(empty) $(empty)
34
35### Quieting
36## common
37QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
38QUIET_SUBDIR1 =
39
40ifneq ($(findstring w,$(firstword -$(MAKEFLAGS))),w)
41PRINT_DIR = --no-print-directory
42else # "make -w"
43NO_SUBDIR = :
44endif
45
46ifneq ($(findstring s,$(firstword -$(MAKEFLAGS))),s)
47ifndef V
48## common
49 QUIET_SUBDIR0 = +@subdir=
50 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
51 $(MAKE) $(PRINT_DIR) -C $$subdir
52
53 QUIET = @
54 QUIET_GEN = @echo ' ' GEN $@;
55
56 QUIET_MKDIR_P_PARENT = @echo ' ' MKDIR -p $(@D);
57
58## Used in "Makefile"
59 QUIET_CARGO = @echo ' ' CARGO $@;
60 QUIET_CC = @echo ' ' CC $@;
61 QUIET_AR = @echo ' ' AR $@;
62 QUIET_LINK = @echo ' ' LINK $@;
63 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
64 QUIET_CP = @echo ' ' CP $< $@;
65 QUIET_LNCP = @echo ' ' LN/CP $@;
66 QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
67 QUIET_MSGINIT = @echo ' ' MSGINIT $@;
68 QUIET_MSGFMT = @echo ' ' MSGFMT $@;
69 QUIET_MSGMERGE = @echo ' ' MSGMERGE $@;
70 QUIET_GCOV = @echo ' ' GCOV $@;
71 QUIET_SP = @echo ' ' SP $<;
72 QUIET_HDR = @echo ' ' HDR $(<:hcc=h);
73 QUIET_RC = @echo ' ' RC $@;
74
75## Used in "Makefile": SPATCH
76 QUIET_SPATCH = @echo ' ' SPATCH $< \>$@;
77 QUIET_SPATCH_TEST = @echo ' ' SPATCH TEST $(@:.build/%=%);
78 QUIET_SPATCH_CAT = @echo ' ' SPATCH CAT $(@:%.patch=%.d/)\*\*.patch \>$@;
79
80## Used in "Documentation/Makefile"
81 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
82 QUIET_XMLTO = @echo ' ' XMLTO $@;
83 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
84 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
85 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
86 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
87 QUIET_GEN = @echo ' ' GEN $@;
88 QUIET_STDERR = 2> /dev/null
89
90 QUIET_LINT_GITLINK = @echo ' ' LINT GITLINK $<;
91 QUIET_LINT_MANSEC = @echo ' ' LINT MAN SEC $<;
92 QUIET_LINT_DELIMSEC = @echo ' ' LINT DEL SEC $<;
93 QUIET_LINT_DOCSTYLE = @echo ' ' LINT DOCSTYLE $<;
94 QUIET_LINT_MANEND = @echo ' ' LINT MAN END $<;
95
96 export V
97endif
98endif
99
100### Templates
101
102## mkdir_p_parent: lazily "mkdir -p" the path needed for a $@
103## file. Uses $(wildcard) to avoid the "mkdir -p" if it's not
104## needed.
105##
106## Is racy, but in a good way; we might redundantly (and safely)
107## "mkdir -p" when running in parallel, but won't need to exhaustively create
108## individual rules for "a" -> "prefix" -> "dir" -> "file" if given a
109## "a/prefix/dir/file". This can instead be inserted at the start of
110## the "a/prefix/dir/file" rule.
111define mkdir_p_parent_template
112$(if $(wildcard $(@D)),,$(QUIET_MKDIR_P_PARENT)$(shell mkdir -p $(@D)))
113endef
114
115## Getting sick of writing -L$(SOMELIBDIR) $(CC_LD_DYNPATH)$(SOMELIBDIR)?
116## Write $(call libpath_template,$(SOMELIBDIR)) instead, perhaps?
117## With CC_LD_DYNPATH set to either an empty string or to "-L", the
118## the directory is not shown the second time.
119define libpath_template
120-L$(1) $(if $(filter-out -L,$(CC_LD_DYNPATH)),$(CC_LD_DYNPATH)$(1))
121endef
122
123# Populate build information into a file via GIT-VERSION-GEN. Requires the
124# absolute path to the root source directory as well as input and output files
125# as arguments, in that order.
126define version_gen
127GIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)" \
128GIT_DATE="$(GIT_DATE)" \
129GIT_USER_AGENT="$(GIT_USER_AGENT)" \
130GIT_VERSION="$(GIT_VERSION_OVERRIDE)" \
131$(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)"
132endef