1 | #----------------------------------------------------------- |
---|
2 | # Copyright Christian Arnault LAL-Orsay CNRS |
---|
3 | # arnault@lal.in2p3.fr |
---|
4 | # See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
5 | #----------------------------------------------------------- |
---|
6 | |
---|
7 | include ${CMTROOT}/src/Makefile.core |
---|
8 | |
---|
9 | # |
---|
10 | # Basic tag management |
---|
11 | # |
---|
12 | ifdef tag |
---|
13 | CMTEXTRATAGS = $(tag) |
---|
14 | else |
---|
15 | tag = $(CMTCONFIG) |
---|
16 | endif |
---|
17 | |
---|
18 | tags = $(tag),$(CMTEXTRATAGS) |
---|
19 | |
---|
20 | cmt_local_tagfile = $(bin)$(tag).make |
---|
21 | cmt_broadcast_tagfile = $(bin)$(tag)_broadcast.make |
---|
22 | |
---|
23 | cmt_constituents_makefile = $(bin)constituents.make |
---|
24 | cmt_broadcast_makefile = $(bin)broadcast.make |
---|
25 | |
---|
26 | #cmt_final_setup = $(bin)setup.make |
---|
27 | |
---|
28 | cmt_check_configurationstamp = $(bin)cmt_check_configuration.stamp |
---|
29 | |
---|
30 | #ifdef CMTBCAST |
---|
31 | #QUICK = 1 |
---|
32 | #endif |
---|
33 | |
---|
34 | ifdef QUICK |
---|
35 | ifndef CMTBCAST |
---|
36 | |
---|
37 | ifneq ($(MAKECMDGOALS),binclean) |
---|
38 | ifneq ($(MAKECMDGOALS),help) |
---|
39 | cmt_included = 1 |
---|
40 | -include $(cmt_local_tagfile) |
---|
41 | endif |
---|
42 | endif |
---|
43 | |
---|
44 | else |
---|
45 | |
---|
46 | ifneq ($(MAKECMDGOALS),help) |
---|
47 | cmt_included = 1 |
---|
48 | -include $(cmt_broadcast_tagfile) |
---|
49 | endif |
---|
50 | |
---|
51 | endif |
---|
52 | endif |
---|
53 | |
---|
54 | all :: |
---|
55 | ifndef CMTBCAST |
---|
56 | ifndef cmt_included |
---|
57 | @$(MAKE) $(cmt_constituents_makefile) |
---|
58 | endif |
---|
59 | @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ |
---|
60 | else |
---|
61 | ifndef cmt_included |
---|
62 | @$(MAKE) $(cmt_broadcast_makefile) |
---|
63 | endif |
---|
64 | @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ |
---|
65 | endif |
---|
66 | |
---|
67 | .DEFAULT : |
---|
68 | ifndef CMTBCAST |
---|
69 | ifndef cmt_included |
---|
70 | @$(MAKE) $(cmt_constituents_makefile) |
---|
71 | endif |
---|
72 | @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ |
---|
73 | else |
---|
74 | ifndef cmt_included |
---|
75 | @$(MAKE) $(cmt_broadcast_makefile) |
---|
76 | endif |
---|
77 | @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ |
---|
78 | endif |
---|
79 | |
---|
80 | check_config :: |
---|
81 | +@$(cmtexe) check configuration; retval=$$?; \ |
---|
82 | if test $${retval} -ne 0; then \ |
---|
83 | test -z "$(cmtmsg)" || \ |
---|
84 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ |
---|
85 | fi; exit $${retval} |
---|
86 | |
---|
87 | $(cmt_check_configurationstamp) : $(use_requirements) |
---|
88 | +@$(cmtexe) check configuration; retval=$$?; \ |
---|
89 | if test $${retval} -ne 0; then \ |
---|
90 | test -z "$(cmtmsg)" || \ |
---|
91 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ |
---|
92 | fi; exit $${retval} |
---|
93 | +$(silent) if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi && \touch $@ |
---|
94 | # echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; exit 17 |
---|
95 | |
---|
96 | ifndef QUICK |
---|
97 | $(cmt_constituents_makefile) :: |
---|
98 | #$(cmt_constituents_makefile) : check_config |
---|
99 | else |
---|
100 | $(cmt_local_tagfile) $(cmt_constituents_makefile) : $(use_requirements) |
---|
101 | #$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(cmt_check_configurationstamp) |
---|
102 | endif |
---|
103 | +$(echo) "(Makefile.header) Rebuilding $@"; \ |
---|
104 | if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ |
---|
105 | $(cmtexe) -tag=$(tags) build constituents_config -out=$(cmt_constituents_makefile); \ |
---|
106 | retval=$$?; \ |
---|
107 | if test $${retval} -ne 0; then \ |
---|
108 | test -z "$(cmtmsg)" || \ |
---|
109 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot rebuild $@" >&2; \ |
---|
110 | \rm -f $@; \ |
---|
111 | fi; \ |
---|
112 | exit $${retval} |
---|
113 | |
---|
114 | ifndef QUICK |
---|
115 | $(cmt_broadcast_makefile) :: |
---|
116 | #$(cmt_broadcast_makefile) : check_config |
---|
117 | else |
---|
118 | $(cmt_broadcast_tagfile) $(cmt_broadcast_makefile) : $(use_requirements) |
---|
119 | #$(cmt_broadcast_makefile) : $(cmt_check_configurationstamp) |
---|
120 | endif |
---|
121 | +$(echo) "(Makefile.header) Rebuilding $@"; \ |
---|
122 | if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ |
---|
123 | $(cmtexe) -tag=$(tags) build broadcast_config -out=$(cmt_broadcast_makefile); \ |
---|
124 | retval=$$?; \ |
---|
125 | if test $${retval} -ne 0; then \ |
---|
126 | test -z "$(cmtmsg)" || \ |
---|
127 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot rebuild $@" >&2; \ |
---|
128 | \rm -f $@; \ |
---|
129 | fi; \ |
---|
130 | exit $${retval} |
---|
131 | |
---|
132 | # |
---|
133 | # Ancient mechanism for remote launchers (kept for backward compatibility) |
---|
134 | # |
---|
135 | $(gmake_hosts) :: |
---|
136 | rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; gmake $(MAKEFLAGS) $(target))'" |
---|
137 | |
---|
138 | $(make_hosts) :: |
---|
139 | rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; make $(MAKEFLAGS) $(target))'" |
---|
140 | |
---|
141 | |
---|
142 | everywhere :: $(everywhere) |
---|
143 | |
---|
144 | ifndef CMTBCAST |
---|
145 | binclean :: |
---|
146 | $(silent)if _bin=`cd $(bin) 2>/dev/null&&pwd -P`&&_cur=`pwd -P`&&[ -n "$${_bin}" ]&&[ "$${_cur#$${_bin}}" = "$${_cur}" ] ; then \ |
---|
147 | test -z "$(cmtmsg)" || \ |
---|
148 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \ |
---|
149 | \rm -rf $(bin) ; \ |
---|
150 | fi |
---|
151 | endif |
---|
152 | |
---|
153 | # |
---|
154 | # Display all targets |
---|
155 | # |
---|
156 | help :: |
---|
157 | ifndef CMTBCAST |
---|
158 | @echo '--------------------------------------------------------------------------' |
---|
159 | @echo 'You may select one of the following make targets :' |
---|
160 | @echo ' ' |
---|
161 | @echo 'help : this help' |
---|
162 | @echo 'all : rebuild all constituents according to the $$(constituents) macro' |
---|
163 | @echo ' (this is the default target)' |
---|
164 | @echo 'clean : remove everything that can be rebuilt' |
---|
165 | @echo 'binclean : fast erase of the binary directory' |
---|
166 | @echo 'uninstall : remove everything installed in the installation area' |
---|
167 | @echo ' ' |
---|
168 | @groups=`$(cmtexe) show groups -tag=$(tags)`; \ |
---|
169 | for g in $${groups}; do \ |
---|
170 | echo "$${g} : rebuild all constituents of group $${g}"; \ |
---|
171 | done |
---|
172 | @echo "Constituents:"; \ |
---|
173 | for c in `$(cmtexe) show constituent_names -tag=$(tags)` ; do \ |
---|
174 | echo " $${c} $${c}clean $${c}uninstall"; \ |
---|
175 | done |
---|
176 | @echo ' ' |
---|
177 | @echo 'check :' |
---|
178 | @echo ' run all applications defined with the -check option' |
---|
179 | @echo ' ' |
---|
180 | @echo 'To switch to BCAST mode, set CMTBCAST to non-empty string.' |
---|
181 | else |
---|
182 | @echo 'Targets for BCAST mode:' |
---|
183 | @echo |
---|
184 | @echo 'help : this help' |
---|
185 | ifndef BCAST_ONLY |
---|
186 | ifndef BCAST_GLOBAL |
---|
187 | @echo 'all : (re)build all used packages in current project (this is default target)' |
---|
188 | else |
---|
189 | @echo 'all : (re)build all used packages in all projects (this is default target)' |
---|
190 | endif |
---|
191 | else |
---|
192 | @echo 'all : (re)build current package (this is default target)' |
---|
193 | endif |
---|
194 | @echo 'clean : remove everything that can be rebuilt' |
---|
195 | @echo 'binclean : fast erase of binary directories (and installation area)' |
---|
196 | @echo 'uninstall : remove everything installed in the installation area' |
---|
197 | @echo 'check : run all applications defined with the -check option' |
---|
198 | @echo |
---|
199 | ifndef BCAST_GLOBAL |
---|
200 | @uses=`$(cmtexe) -private show macros '_project$$|package$$' -tag=$(tags)| \ |
---|
201 | awk -F = '{if ($$1 ~ /_project$$/) {uses[substr($$1,1,length($$1)-8)]=$$2}else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}}END{for (u in uses){if (uses[u]==uses[cur]) print u}}'`; \ |
---|
202 | for u in $${uses}; do \ |
---|
203 | echo "$${u} : (re)build package $${u} ($(_groups))"; \ |
---|
204 | echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \ |
---|
205 | echo "$${u}binclean : fast erase of binary directory in package $${u}"; \ |
---|
206 | echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \ |
---|
207 | echo "$${u}check : run all applications defined with the -check option in package $${u}"; \ |
---|
208 | done |
---|
209 | else |
---|
210 | @uses=`$(cmtexe) -private show macros '_root$$' -tag=$(tags)| \ |
---|
211 | awk -F = '{u=substr($$1,1,length($$1)-5);if (u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}'`; \ |
---|
212 | for u in $${uses}; do \ |
---|
213 | echo "$${u} : (re)build package $${u} ($(_groups))"; \ |
---|
214 | echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \ |
---|
215 | echo "$${u}binclean : fast erase of binary directory in package $${u}"; \ |
---|
216 | echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \ |
---|
217 | echo "$${u}check : run all applications defined with the -check option in package $${u}"; \ |
---|
218 | done |
---|
219 | endif |
---|
220 | @echo |
---|
221 | ifndef BCAST_ONLY |
---|
222 | @echo ' ... with dependencies packages (may be ignored by setting BCAST_ONLY).' |
---|
223 | else |
---|
224 | @echo ' ... without dependencies packages (may be included by unsetting BCAST_ONLY).' |
---|
225 | endif |
---|
226 | @echo |
---|
227 | ifndef BCAST_GLOBAL |
---|
228 | @echo 'To (re)build packages in all projects, set BCAST_GLOBAL.' |
---|
229 | else |
---|
230 | @echo 'To (re)build packages in current project, unset BCAST_GLOBAL.' |
---|
231 | endif |
---|
232 | ifndef NO_ALL_GROUPS |
---|
233 | @echo 'To (re)build default group only, set NO_ALL_GROUPS.' |
---|
234 | ifndef CMTACTIONS |
---|
235 | @echo 'To also (re)build cmt_actions group, set CMTACTIONS.' |
---|
236 | endif |
---|
237 | else |
---|
238 | @echo 'To (re)build all groups, unset NO_ALL_GROUPS.' |
---|
239 | endif |
---|
240 | @echo |
---|
241 | @echo 'To switch to PACKAGE mode, unset CMTBCAST.' |
---|
242 | endif |
---|
243 | |
---|
244 | ifndef NO_ALL_GROUPS |
---|
245 | ifndef CMTACTIONS |
---|
246 | _groups = all groups except cmt_actions |
---|
247 | else |
---|
248 | _groups = all groups |
---|
249 | endif |
---|
250 | else |
---|
251 | _groups = default group |
---|
252 | endif |
---|
253 | |
---|
254 | # explicit rule to avoid implicit rule search |
---|
255 | # and not to remake |
---|
256 | ${CMTROOT}/src/Makefile.header : ; |
---|
257 | ${CMTROOT}/src/Makefile.core : ; |
---|
258 | ifdef use_requirements |
---|
259 | $(use_requirements) : ; |
---|
260 | endif |
---|
261 | |
---|
262 | # for multiple command line goals, |
---|
263 | # avoid race conditions when (re)writing constituents.make |
---|
264 | .NOTPARALLEL : |
---|