source: CMT/v1r20p20081118/src/Makefile.header @ 662

Last change on this file since 662 was 462, checked in by rybkin, 16 years ago

See C.L. 363

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