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 | |
---|
7 | include ${CMTROOT}/src/Makefile.core |
---|
8 | |
---|
9 | # |
---|
10 | # Basic tag management |
---|
11 | # |
---|
12 | ifdef tag |
---|
13 | CMTEXTRATAGS = $(tag) |
---|
14 | else |
---|
15 | tag = $(CMTCONFIG) |
---|
16 | endif |
---|
17 | |
---|
18 | tags = $(tag),$(CMTEXTRATAGS) |
---|
19 | |
---|
20 | ifdef READONLY |
---|
21 | cmt_local_tagfile = /tmp/CMT_$(tag).make$$$$ |
---|
22 | else |
---|
23 | cmt_local_tagfile = $(bin)$(tag).make |
---|
24 | endif |
---|
25 | |
---|
26 | ifdef READONLY |
---|
27 | cmt_constituents_makefile = /tmp/CMT_$(tag)_constituents.make$$$$ |
---|
28 | else |
---|
29 | cmt_constituents_makefile = $(bin)constituents.make |
---|
30 | endif |
---|
31 | |
---|
32 | # |
---|
33 | # Generic entry points for all targets |
---|
34 | # |
---|
35 | ifndef QUICK |
---|
36 | all :: check_config ; |
---|
37 | else |
---|
38 | all :: no_check_config ; |
---|
39 | endif |
---|
40 | |
---|
41 | check_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 | |
---|
49 | no_check_config :: |
---|
50 | @$(MAKE) --no-print-directory target="first config all" common_target |
---|
51 | |
---|
52 | binclean :: |
---|
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 | |
---|
60 | clean :: |
---|
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 | # |
---|
71 | ifdef READONLY |
---|
72 | common_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} |
---|
94 | else |
---|
95 | common_target : $(cmt_constituents_makefile) |
---|
96 | @$(MAKE) --no-print-directory -f $< cmt_lock_pid=$(cmt_lock_pid) $(target) |
---|
97 | endif |
---|
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 | |
---|
109 | ifndef QUICK |
---|
110 | $(cmt_local_tagfile) :: |
---|
111 | else |
---|
112 | $(cmt_local_tagfile) : |
---|
113 | endif |
---|
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 | |
---|
133 | everywhere :: $(everywhere) |
---|
134 | |
---|
135 | # |
---|
136 | # Display all targets |
---|
137 | # |
---|
138 | help :: |
---|
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 : ; |
---|