[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 | |
---|
| 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 | |
---|
[434] | 20 | cmt_local_tagfile = $(bin)$(tag).make |
---|
[588] | 21 | cmt_broadcast_tagfile = $(bin)$(tag)_broadcast.make |
---|
[2] | 22 | |
---|
[434] | 23 | cmt_constituents_makefile = $(bin)constituents.make |
---|
[588] | 24 | cmt_broadcast_makefile = $(bin)broadcast.make |
---|
[434] | 25 | |
---|
[595] | 26 | #cmt_final_setup = $(bin)setup.make |
---|
[487] | 27 | |
---|
[588] | 28 | cmt_check_configurationstamp = $(bin)cmt_check_configuration.stamp |
---|
[2] | 29 | |
---|
[595] | 30 | #ifdef CMTBCAST |
---|
| 31 | #QUICK = 1 |
---|
| 32 | #endif |
---|
[2] | 33 | |
---|
[588] | 34 | ifdef QUICK |
---|
| 35 | ifndef CMTBCAST |
---|
[434] | 36 | |
---|
[588] | 37 | ifneq ($(MAKECMDGOALS),binclean) |
---|
| 38 | ifneq ($(MAKECMDGOALS),help) |
---|
| 39 | cmt_included = 1 |
---|
| 40 | -include $(cmt_local_tagfile) |
---|
| 41 | endif |
---|
| 42 | endif |
---|
[547] | 43 | |
---|
[588] | 44 | else |
---|
[2] | 45 | |
---|
[588] | 46 | ifneq ($(MAKECMDGOALS),help) |
---|
| 47 | cmt_included = 1 |
---|
| 48 | -include $(cmt_broadcast_tagfile) |
---|
| 49 | endif |
---|
[2] | 50 | |
---|
[588] | 51 | endif |
---|
| 52 | endif |
---|
| 53 | |
---|
| 54 | all :: |
---|
| 55 | ifndef CMTBCAST |
---|
| 56 | ifndef cmt_included |
---|
[547] | 57 | @$(MAKE) $(cmt_constituents_makefile) |
---|
[588] | 58 | endif |
---|
[616] | 59 | @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ |
---|
[588] | 60 | else |
---|
| 61 | ifndef cmt_included |
---|
| 62 | @$(MAKE) $(cmt_broadcast_makefile) |
---|
| 63 | endif |
---|
| 64 | @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ |
---|
| 65 | endif |
---|
| 66 | |
---|
| 67 | .DEFAULT : |
---|
| 68 | ifndef CMTBCAST |
---|
| 69 | ifndef cmt_included |
---|
| 70 | @$(MAKE) $(cmt_constituents_makefile) |
---|
| 71 | endif |
---|
[547] | 72 | @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ |
---|
[588] | 73 | else |
---|
| 74 | ifndef cmt_included |
---|
| 75 | @$(MAKE) $(cmt_broadcast_makefile) |
---|
| 76 | endif |
---|
| 77 | @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ |
---|
| 78 | endif |
---|
[547] | 79 | |
---|
[588] | 80 | check_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] | 96 | ifndef QUICK |
---|
[588] | 97 | $(cmt_constituents_makefile) :: |
---|
| 98 | #$(cmt_constituents_makefile) : check_config |
---|
[547] | 99 | else |
---|
[588] | 100 | $(cmt_local_tagfile) $(cmt_constituents_makefile) : $(use_requirements) |
---|
| 101 | #$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(cmt_check_configurationstamp) |
---|
[547] | 102 | endif |
---|
[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] | 114 | ifndef QUICK |
---|
[588] | 115 | $(cmt_broadcast_makefile) :: |
---|
| 116 | #$(cmt_broadcast_makefile) : check_config |
---|
[434] | 117 | else |
---|
[588] | 118 | $(cmt_broadcast_tagfile) $(cmt_broadcast_makefile) : $(use_requirements) |
---|
| 119 | #$(cmt_broadcast_makefile) : $(cmt_check_configurationstamp) |
---|
[434] | 120 | endif |
---|
[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 | |
---|
| 142 | everywhere :: $(everywhere) |
---|
| 143 | |
---|
[588] | 144 | ifndef CMTBCAST |
---|
| 145 | binclean :: |
---|
[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 |
---|
| 151 | endif |
---|
| 152 | |
---|
[2] | 153 | # |
---|
| 154 | # Display all targets |
---|
| 155 | # |
---|
| 156 | help :: |
---|
[588] | 157 | ifndef 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.' |
---|
| 181 | else |
---|
| 182 | @echo 'Targets for BCAST mode:' |
---|
| 183 | @echo |
---|
| 184 | @echo 'help : this help' |
---|
| 185 | ifndef BCAST_ONLY |
---|
| 186 | ifndef BCAST_GLOBAL |
---|
| 187 | @echo 'all : (re)build all used packages in current project (this is default target)' |
---|
| 188 | else |
---|
| 189 | @echo 'all : (re)build all used packages in all projects (this is default target)' |
---|
| 190 | endif |
---|
| 191 | else |
---|
| 192 | @echo 'all : (re)build current package (this is default target)' |
---|
| 193 | endif |
---|
| 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 |
---|
| 199 | ifndef 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 |
---|
| 209 | else |
---|
[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 |
---|
| 219 | endif |
---|
| 220 | @echo |
---|
| 221 | ifndef BCAST_ONLY |
---|
| 222 | @echo ' ... with dependencies packages (may be ignored by setting BCAST_ONLY).' |
---|
| 223 | else |
---|
| 224 | @echo ' ... without dependencies packages (may be included by unsetting BCAST_ONLY).' |
---|
| 225 | endif |
---|
| 226 | @echo |
---|
| 227 | ifndef BCAST_GLOBAL |
---|
| 228 | @echo 'To (re)build packages in all projects, set BCAST_GLOBAL.' |
---|
| 229 | else |
---|
| 230 | @echo 'To (re)build packages in current project, unset BCAST_GLOBAL.' |
---|
| 231 | endif |
---|
| 232 | ifndef NO_ALL_GROUPS |
---|
| 233 | @echo 'To (re)build default group only, set NO_ALL_GROUPS.' |
---|
| 234 | ifndef CMTACTIONS |
---|
| 235 | @echo 'To also (re)build cmt_actions group, set CMTACTIONS.' |
---|
| 236 | endif |
---|
| 237 | else |
---|
| 238 | @echo 'To (re)build all groups, unset NO_ALL_GROUPS.' |
---|
| 239 | endif |
---|
| 240 | @echo |
---|
| 241 | @echo 'To switch to PACKAGE mode, unset CMTBCAST.' |
---|
| 242 | endif |
---|
[2] | 243 | |
---|
[588] | 244 | ifndef NO_ALL_GROUPS |
---|
| 245 | ifndef CMTACTIONS |
---|
| 246 | _groups = all groups except cmt_actions |
---|
| 247 | else |
---|
| 248 | _groups = all groups |
---|
| 249 | endif |
---|
| 250 | else |
---|
| 251 | _groups = default group |
---|
| 252 | endif |
---|
[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 : ; |
---|
| 258 | ifdef use_requirements |
---|
| 259 | $(use_requirements) : ; |
---|
| 260 | endif |
---|
[547] | 261 | |
---|
| 262 | # for multiple command line goals, |
---|
| 263 | # avoid race conditions when (re)writing constituents.make |
---|
| 264 | .NOTPARALLEL : |
---|