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

Last change on this file since 600 was 600, checked in by rybkin, 12 years ago

See C.L. 477

  • Property svn:eol-style set to native
File size: 8.3 KB
Line 
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
20cmt_local_tagfile = $(bin)$(tag).make
21cmt_broadcast_tagfile = $(bin)$(tag)_broadcast.make
22
23cmt_constituents_makefile = $(bin)constituents.make
24cmt_broadcast_makefile = $(bin)broadcast.make
25
26#cmt_final_setup = $(bin)setup.make
27
28cmt_check_configurationstamp = $(bin)cmt_check_configuration.stamp
29
30#ifdef CMTBCAST
31#QUICK = 1
32#endif
33
34ifdef QUICK
35ifndef CMTBCAST
36
37ifneq ($(MAKECMDGOALS),binclean)
38ifneq ($(MAKECMDGOALS),help)
39cmt_included = 1
40-include $(cmt_local_tagfile)
41endif
42endif
43
44else
45
46ifneq ($(MAKECMDGOALS),help)
47cmt_included = 1
48-include $(cmt_broadcast_tagfile)
49endif
50
51endif
52endif
53
54all ::
55ifndef CMTBCAST
56ifndef cmt_included
57        @$(MAKE) $(cmt_constituents_makefile)
58endif
59        $(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
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
72        @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
73else
74ifndef cmt_included
75        @$(MAKE) $(cmt_broadcast_makefile)
76endif
77        @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@
78endif
79
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}
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
96ifndef QUICK
97$(cmt_constituents_makefile) ::
98#$(cmt_constituents_makefile) : check_config
99else
100$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(use_requirements)
101#$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(cmt_check_configurationstamp)
102endif
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
114ifndef QUICK
115$(cmt_broadcast_makefile) ::
116#$(cmt_broadcast_makefile) : check_config
117else
118$(cmt_broadcast_tagfile) $(cmt_broadcast_makefile) : $(use_requirements)
119#$(cmt_broadcast_makefile) : $(cmt_check_configurationstamp)
120endif
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
142everywhere :: $(everywhere)
143
144ifndef CMTBCAST
145binclean ::
146        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
151endif
152
153#
154#   Display all targets
155#
156help ::
157ifndef 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.'
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'
197        @echo 'check       : run all applications defined with the -check option'
198        @echo
199ifndef 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
209else
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
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
243
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
253
254# explicit rule to avoid implicit rule search
255# and not to remake
256${CMTROOT}/src/Makefile.header : ;
257${CMTROOT}/src/Makefile.core : ;
258ifdef use_requirements
259$(use_requirements) : ;
260endif
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.