source: CMT/v1r25p20140131/src/Makefile.header @ 693

Last change on this file since 693 was 664, checked in by rybkin, 10 years ago

merge -r 646:663 HEAD

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