source: CMT/v1r20p20080222/src/Makefile.header @ 674

Last change on this file since 674 was 441, checked in by rybkin, 16 years ago

See C.L. 345

  • Property svn:eol-style set to native
File size: 4.7 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
20ifdef READONLY
21cmt_local_tagfile = /tmp/CMT_$(tag).make$$$$
22else
23cmt_local_tagfile = $(bin)$(tag).make
24endif
25
26ifdef READONLY
27cmt_constituents_makefile = /tmp/CMT_$(tag)_constituents.make$$$$
28else
29cmt_constituents_makefile = $(bin)constituents.make
30endif
31
32#
33#  Generic entry points for all targets
34#
35ifndef QUICK
36all :: check_config ;
37else
38all :: no_check_config ;
39endif
40
41check_config ::
42        @$(cmtexe) check configuration; retval=$$?; \
43        if test $${retval} = 0; then \
44          $(MAKE) --no-print-directory target="first config all" common_target; \
45        else \
46          echo "#CMT> There are configuration errors. Please correct them before running gmake"; \
47        fi
48
49no_check_config ::
50        @$(MAKE) --no-print-directory target="first config all" common_target
51
52binclean ::
53        @if test ! "$(bin)" = "./"; then \
54          if test -d $(bin) ; then \
55            echo "------> (Makefile.header) Cleaning all from $(bin)"; \
56            /bin/rm -rf $(bin) ; \
57          fi ; \
58        fi
59
60clean ::
61        @$(cmtexe) check configuration
62        @$(MAKE) --no-print-directory target="$@" common_target
63
64.DEFAULT ::
65        @$(cmtexe) check configuration
66        @$(MAKE) --no-print-directory target="config $@" common_target
67
68#
69#  Capture all possible targets
70#
71ifdef READONLY
72common_target ::
73        @tmpdir=/tmp; \
74          if test ! "${TMPDIR}" = ""; then tmpdir=${TMPDIR}; fi; \
75          cmt_lock_pid=`mkdir -p $${tmpdir}; mktemp $${tmpdir}/CMT_XXXXXX | sed -e 's#'"$${tmpdir}"'/CMT_##'`; \
76          temp_marker=$${tmpdir}/CMT_$${cmt_lock_pid}; \
77          temp_lock=$${tmpdir}/CMT_lock$${cmt_lock_pid}.make; \
78          temp_constituents=$${tmpdir}/CMT_constituents$${cmt_lock_pid}; \
79          if test ! "${CMTMAKEDEBUG}" = 1; then\
80            trap '/bin/rm -f $${temp_lock} $${temp_constituents} $${temp_marker}; exit $${status}' 0 1 2 15; \
81          fi; \
82          /bin/rm -f $${temp_marker}; \
83          /bin/rm -f $${temp_lock}; \
84          echo "------> (Makefile.header) Rebuilding constituents.make"; \
85          $(cmtexe) -quiet -tag=$(tags) build constituents_makefile -out=$${temp_constituents}; status=$$?; \
86          if test $${status} = 0; then \
87            /bin/rm -f $(cmt_local_tagfile); \
88            $(MAKE) --no-print-directory -f $${temp_constituents} cmt_lock_pid=$${cmt_lock_pid} $(target); \
89            status=$$?; \
90          else \
91            echo "#CMT> Error generating constituents makefile"; \
92          fi; \
93          exit $${status}
94else
95common_target : $(cmt_constituents_makefile)
96        @$(MAKE) --no-print-directory -f $< cmt_lock_pid=$(cmt_lock_pid) $(target)
97endif
98
99$(cmt_constituents_makefile) : $(cmt_local_tagfile)
100        $(echo) "(Makefile.header) Rebuilding $@"; \
101          if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \
102          $(cmtexe) -quiet -tag=$(tags) build constituents_makefile -out=$@; \
103          retval=$$?; \
104          if test $${retval} != 0; then \
105          echo "#CMT> Error: $@: Cannot generate" >&2; \
106          /bin/rm -f $@; fi; \
107          exit $${retval}
108
109ifndef QUICK
110$(cmt_local_tagfile) ::
111else
112$(cmt_local_tagfile) :
113endif
114        $(echo) "(Makefile.header) Rebuilding $@"; \
115          if test -f $@; then rm -f $@; fi; \
116          if test ! -d $(@D); then $(mkdir) -p $(@D); fi; \
117          $(cmtexe) -quiet -tag=$(tags) build tag_makefile >$@
118
119#         && /bin/echo $@ ok   
120#       $(echo) CMTCONFIG=$(CMTCONFIG) ; \
121#
122
123#
124#  Ancient mechanism for remote launchers (kept for backward compatibility)
125#
126$(gmake_hosts) ::
127        rsh $@ "sh -c '(cd `$(cmtexe) show pwd -quiet`; . setup.sh; gmake $(MAKEFLAGS) $(target))'"
128
129$(make_hosts) ::
130        rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; make $(MAKEFLAGS) $(target))'"
131
132
133everywhere :: $(everywhere)
134
135#
136#   Display all targets
137#
138help ::
139        @echo '--------------------------------------------------------------------------'
140        @echo 'You may select one of the following make targets :'
141        @echo ' '
142        @echo 'help        : this help'
143        @echo 'all         : rebuild all constituents according to the $$(constituents) macro'
144        @echo '              (this is the default target)'
145        @echo 'clean       : remove everything that can be rebuilt'
146        @echo 'binclean    : fast erase of the binary directory'
147        @echo ' '
148        @groups=`$(cmtexe) show groups -quiet -tag=$(tags)`; \
149          for g in $${groups}; do \
150            echo "$${g} : rebuild all constituents of group $${g}"; \
151          done
152        @echo "Constituents:"; \
153          for c in `$(cmtexe) show constituent_names -quiet -tag=$(tags)` ; do \
154            echo "  $${c}  $${c}clean"; \
155          done
156        @echo ' '
157        @echo 'check :'
158        @echo '              run all applications defined with the -check option'
159        @echo ' '
160
161
162# explicit rule not to remake
163${CMTROOT}/src/Makefile.header : ;
164${CMTROOT}/src/Makefile.core : ;
Note: See TracBrowser for help on using the repository browser.