Debian Codegraph @

Makefile

raw symbols SCIP
1 # -*- makefile -*-
2
3 ### NOTE: make-3.80 has a bug in eval which causes it not to return
4 ### an empty target, but instead it sometimes returns very weird
5 ### stuff that makes make segv, I think.
6 ### You need to get it patched at:
7 ### http://savannah.gnu.org/bugs/?func=detailbug&bug_id=1517&group_id=71
8
9 default: all
10
11 MAKEFILE/ :=$(dir $(firstword $(MAKEFILE_LIST)))
12
13 ifneq ($(shell ls -d ${MAKEFILE/}/Make.compilers 2> /dev/null), ${MAKEFILE/}/Make.compilers)
14 MAKECOMPILERSNOTHING := $(shell ${MAKEFILE/}configure.sh)
15 endif
16
17 include ${MAKEFILE/}Make.compilers
18
19
20 ##### non-recursive make magic
21 # all directories which have been included
22 // :=
23 # current path (empty)
24 / :=
25
26 # recursive directories to be filtered out of //
27 # and handled differently
28 //-RECURSIVE :=
29 define MakeRecursive
30 //-RECURSIVE :=$$/.
31 endef
32
33 ## Include -hack
34 # Include is wrapped in something which will push and pop /
35 # properly while adding newly discovered directories to //
36 # and keeping track of who is who's children (.SUBS).
37 #
38 # Each directory so included has its Make.include file included.
39 # Those Make.include files can use $/ prepended to local names
40 # to prevent name pollution, and define their own subtargets.
41 #
42 define Include
43 $(foreach x,$(strip ${1}),$(call Include_File,$x))
44 endef
45
46 define Include_File
47 ifeq ($(filter ${1}.,${WITHOUT_}),)
48 ifeq ($(wildcard ${1}Make.include),${1}Make.include)
49 $/.SUBS +=${1}.
50 // +=${1}.
51 ${1}.SUBS :=
52 / :=${1}
53 include ${1}Make.include
54 / :=$/
55 endif
56 endif
57
58 endef
59
60 ##### System specific includes
61
62 ## WITHOUT
63 # If the user specifies a WITHOUT, then those paths are not
64 # followed.
65 ifndef WITHOUT
66 WITHOUT:=
67 endif
68 WITHOUT_:=$(patsubst %,%.,$(strip ${WITHOUT}))
69
70 ## First Make.include inclusion
71 # invoke the toplevel include file.
72 # We use 'Include_File' instead of 'Include' since $/ is empty
73 $(eval $(call Include_File,$/))
74
75 #### Targets which have been declared RECURSIVE are removed
76 # from // and processed separately.
77 // :=$(filter-out ${//-RECURSIVE},${//})
78
79 # //-RECURSIVE now holds the paths which are being done legacy style
80 # and // holds the paths which are going to be part of the system.
81
82 ### Building subgoals in Make.rules
83 # subgoals and depends are done with the deferred '=' not the ':='.
84 # This is because we want dynamic scoping.
85 __SUBGOALS__=
86 __DEPGOALS__=
87
88 -include ${MAKEFILE/}Make.rules
89
90 # now we bring in the depends files as defined by the Includes
91 # and the patterns in Make.rules
92 $(eval DEPENDS:=$(foreach x,${//},$(call __DEPGOALS__,$x)))
93 ifneq ($(strip ${DEPENDS}),)
94 # this conditional gets us a way out if things go way wrong
95 ifeq ($(filter %-clean,${MAKECMDGOALS}),)
96 -include ${DEPENDS}
97 endif
98 endif
99
100 ### the standard make targets, applied to all subdirectory targets
101 # We define the basic form of the all, clean, ... rules on a
102 # per-path basis (the $/.all, $..clean, ... targets). This allows
103 # selective targeting.
104 ## rules for each subtarget
105 # current subtargets are :
106 # all, ls, clean, real-clean, depends-clean, install
107 # with all, clean, real-clean, install being required targets
108 # of recursive makes.
109
110 clean: ${//-RECURSIVE:.=.clean} $/.clean
111 define .RULE-clean
112 ${1:.=.clean}: $${${1:.=.SUBS}:.=.clean}
113 ${RM} $${${1:.=.CLEAN}} ${__SUBGOALS__}
114 ifneq ($(strip ${C_TMP_COMPILE} ${CXX_TMP_COMPILE}),)
115 (cd $1 && ${RM} -r ${C_TMP_COMPILE} ${CXX_TMP_COMPILE})
116 endif
117
118 endef
119 $(eval $(foreach x,${//},$(call .RULE-clean,$x)))
120
121
122 depends-clean: $/.depends-clean
123 ${//-RECURSIVE:.=.depends-clean}:
124 define .RULE-depends-clean
125 ${1:.=.depends-clean}: $${${1:.=.SUBS}:.=.depends-clean}
126 ${RM} ${1:.=Make.depends} ${__DEPGOALS__}
127
128 endef
129 $(eval $(foreach x,${//},$(call .RULE-depends-clean,$x)))
130
131 real-clean: ${//-RECURSIVE:.=.real-clean} $/.real-clean
132 define .RULE-real-clean
133 ${1:.=.real-clean}: $${${1:.=.SUBS}:.=.real-clean}
134 ${RM} $${${1:.=.CLEAN}} ${__SUBGOALS__} ${1:.=Make.depends} ${__DEPGOALS__} $${${1:.=.REAL-CLEAN}}
135 #ifneq ($(strip ${INSTALL/}),)
136 # ${RM} -r ${INSTALL/}
137 #endif
138 ifneq ($(strip ${C_TMP_COMPILE} ${CXX_TMP_COMPILE}),)
139 (cd $1 && ${RM} -r ${C_TMP_COMPILE} ${CXX_TMP_COMPILE})
140 endif
141
142 endef
143 $(eval $(foreach x,${//},$(call .RULE-real-clean,$x)))
144
145 all: ${//-RECURSIVE:.=.all} $/.all
146 define .RULE-all
147 ${1:.=.all}: $${${1:.=.SUBS}:.=.all} ${__SUBGOALS__}
148
149 endef
150 $(eval $(foreach x,${//},$(call .RULE-all,$x)))
151
152 ## INSTALL:
153 # Define targets which give a basic recursive traversal to hang
154 # things from for anything install related that I haven't thought of
155
156 # this does the copy part of the install
157 ${//-RECURSIVE:.=.install-copy}:
158 install-copy: ${//-RECURSIVE:.=.install-copy} $/.install-copy
159 define .RULE-install-copy
160 ${1:.=.install-copy}: $${${1:.=.SUBS}:.=.install-copy}
161
162 endef
163 $(eval $(foreach x,${//},$(call .RULE-install-copy,$x)))
164
165 # define the actual install target as being a combination of the
166 # all target plus the pre-/install-copy targets
167
168 install: ${//-RECURSIVE:.=.install} $/.install
169 define .RULE-install
170 ${1:.=.install}: ${1:.=.all} ${1:.=.install-copy}
171
172 endef
173 $(eval $(foreach x,${//},$(call .RULE-install,$x)))
174
175
176
177 # a sort of debugging thing. Let's me check on which targets
178 # actually didn't get made, or got partially made
179 LSOPTS:=-l
180 ls: $/.ls
181 ${//-RECURSIVE:.=.ls}:
182 define .RULE-ls
183 ${1:.=.ls}: $${${1:.=.SUBS}:.=.ls}
184 @ files='$$(strip ${__SUBGOALS__})'; \
185 if [ -n "$$$${files}" ] ; then \
186 ls ${LSOPTS} $$$${files} ; \
187 fi ; exit 0;
188
189 endef
190 $(eval $(foreach x,${//},$(call .RULE-ls,$x)))
191
192
193
194