source: CMT/HEAD/src/Makefile.header @ 652

Last change on this file since 652 was 652, checked in by rybkin, 11 years ago

See C.L. 511

  • Property svn:eol-style set to native
File size: 8.9 KB
RevLine 
[2]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
7include ${CMTROOT}/src/Makefile.core
8
9#
10#  Basic tag management
11#
12ifdef tag
13CMTEXTRATAGS = $(tag)
14else
15tag       = $(CMTCONFIG)
16endif
17
18tags      = $(tag),$(CMTEXTRATAGS)
19
[434]20cmt_local_tagfile = $(bin)$(tag).make
[588]21cmt_broadcast_tagfile = $(bin)$(tag)_broadcast.make
[2]22
[434]23cmt_constituents_makefile = $(bin)constituents.make
[588]24cmt_broadcast_makefile = $(bin)broadcast.make
[434]25
[595]26#cmt_final_setup = $(bin)setup.make
[487]27
[588]28cmt_check_configurationstamp = $(bin)cmt_check_configuration.stamp
[2]29
[595]30#ifdef CMTBCAST
31#QUICK = 1
32#endif
[2]33
[588]34ifdef QUICK
35ifndef CMTBCAST
[434]36
[588]37ifneq ($(MAKECMDGOALS),binclean)
38ifneq ($(MAKECMDGOALS),help)
39cmt_included = 1
40-include $(cmt_local_tagfile)
41endif
42endif
[547]43
[588]44else
[2]45
[588]46ifneq ($(MAKECMDGOALS),help)
47cmt_included = 1
48-include $(cmt_broadcast_tagfile)
49endif
[2]50
[588]51endif
52endif
53
54all ::
55ifndef CMTBCAST
56ifndef cmt_included
[547]57        @$(MAKE) $(cmt_constituents_makefile)
[588]58endif
[616]59        @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
[588]60else
61ifndef cmt_included
62        @$(MAKE) $(cmt_broadcast_makefile)
63endif
64        @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@
65endif
66
67.DEFAULT :
68ifndef CMTBCAST
69ifndef cmt_included
70        @$(MAKE) $(cmt_constituents_makefile)
71endif
[547]72        @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
[588]73else
74ifndef cmt_included
75        @$(MAKE) $(cmt_broadcast_makefile)
76endif
77        @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@
78endif
[547]79
[588]80check_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}
[2]86
[588]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
[2]95
[547]96ifndef QUICK
[588]97$(cmt_constituents_makefile) ::
98#$(cmt_constituents_makefile) : check_config
[547]99else
[588]100$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(use_requirements)
101#$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(cmt_check_configurationstamp)
[547]102endif
[588]103        +$(echo) "(Makefile.header) Rebuilding $@"; \
[434]104          if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \
[588]105          $(cmtexe) -tag=$(tags) build constituents_config -out=$(cmt_constituents_makefile); \
[434]106          retval=$$?; \
[547]107          if test $${retval} -ne 0; then \
[527]108            test -z "$(cmtmsg)" || \
[595]109            echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot rebuild $@" >&2; \
[527]110            \rm -f $@; \
111          fi; \
[434]112          exit $${retval}
[2]113
[434]114ifndef QUICK
[588]115$(cmt_broadcast_makefile) ::
116#$(cmt_broadcast_makefile) : check_config
[434]117else
[588]118$(cmt_broadcast_tagfile) $(cmt_broadcast_makefile) : $(use_requirements)
119#$(cmt_broadcast_makefile) : $(cmt_check_configurationstamp)
[434]120endif
[588]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)" || \
[595]127            echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot rebuild $@" >&2; \
[588]128            \rm -f $@; \
129          fi; \
130          exit $${retval}
[434]131
[2]132#
133#  Ancient mechanism for remote launchers (kept for backward compatibility)
134#
135$(gmake_hosts) ::
[459]136        rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; gmake $(MAKEFLAGS) $(target))'"
[2]137
138$(make_hosts) ::
139        rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; make $(MAKEFLAGS) $(target))'"
140
141
142everywhere :: $(everywhere)
143
[588]144ifndef CMTBCAST
145binclean ::
[616]146        $(silent)if _bin=`cd $(bin) 2>/dev/null&&pwd -P`&&_cur=`pwd -P`&&[ -n "$${_bin}" ]&&[ "$${_cur#$${_bin}}" = "$${_cur}" ] ; then \
[588]147            test -z "$(cmtmsg)" || \
148            echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \
149            \rm -rf $(bin) ; \
150        fi
151endif
152
[2]153#
154#   Display all targets
155#
156help ::
[588]157ifndef CMTBCAST
[2]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'
[487]166        @echo 'uninstall   : remove everything installed in the installation area'
[2]167        @echo ' '
[459]168        @groups=`$(cmtexe) show groups -tag=$(tags)`; \
[2]169          for g in $${groups}; do \
170            echo "$${g} : rebuild all constituents of group $${g}"; \
171          done
172        @echo "Constituents:"; \
[459]173          for c in `$(cmtexe) show constituent_names -tag=$(tags)` ; do \
[487]174            echo "  $${c}  $${c}clean  $${c}uninstall"; \
[2]175          done
176        @echo ' '
177        @echo 'check :'
178        @echo '              run all applications defined with the -check option'
179        @echo ' '
[588]180        @echo 'To switch to BCAST mode, set CMTBCAST to non-empty string.'
181else
182        @echo 'Targets for BCAST mode:'
183        @echo
184        @echo 'help        : this help'
185ifndef BCAST_ONLY
186ifndef BCAST_GLOBAL
187        @echo 'all         : (re)build all used packages in current project (this is default target)'
188else
189        @echo 'all         : (re)build all used packages in all projects (this is default target)'
190endif
191else
192        @echo 'all         : (re)build current package (this is default target)'
193endif
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'
[595]197        @echo 'check       : run all applications defined with the -check option'
[588]198        @echo
199ifndef BCAST_GLOBAL
[652]200        @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \
201          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}}'`; \
[588]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}"; \
[600]207            echo "$${u}check : run all applications defined with the -check option in package $${u}"; \
[588]208          done
209else
[652]210        @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \
211          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}}'`; \
[588]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}"; \
[600]217            echo "$${u}check : run all applications defined with the -check option in package $${u}"; \
[588]218          done
219endif
220        @echo
221ifndef BCAST_ONLY
222        @echo '   ... with dependencies packages (may be ignored by setting BCAST_ONLY).'
223else
224        @echo '   ... without dependencies packages (may be included by unsetting BCAST_ONLY).'
225endif
226        @echo
227ifndef BCAST_GLOBAL
228        @echo 'To (re)build packages in all projects, set BCAST_GLOBAL.'
229else
230        @echo 'To (re)build packages in current project, unset BCAST_GLOBAL.'
231endif
232ifndef NO_ALL_GROUPS
233        @echo 'To (re)build default group only, set NO_ALL_GROUPS.'
234ifndef CMTACTIONS
235        @echo 'To also (re)build cmt_actions group, set CMTACTIONS.'
236endif
237else
238        @echo 'To (re)build all groups, unset NO_ALL_GROUPS.'
239endif
240        @echo
241        @echo 'To switch to PACKAGE mode, unset CMTBCAST.'
242endif
[2]243
[588]244ifndef NO_ALL_GROUPS
245ifndef CMTACTIONS
246_groups = all groups except cmt_actions
247else
248_groups = all groups
249endif
250else
251_groups = default group
252endif
[2]253
[588]254# explicit rule to avoid implicit rule search
255# and not to remake
[434]256${CMTROOT}/src/Makefile.header : ;
[588]257${CMTROOT}/src/Makefile.core : ;
258ifdef use_requirements
259$(use_requirements) : ;
260endif
[547]261
262# for multiple command line goals,
263# avoid race conditions when (re)writing constituents.make
264.NOTPARALLEL :
Note: See TracBrowser for help on using the repository browser.