[2] | 1 | #----------------------------------------------------------- |
---|
| 2 | # Copyright Christian Arnault LAL-Orsay CNRS |
---|
| 3 | # arnault@lal.in2p3.fr |
---|
[663] | 4 | # Modified by Grigory Rybkin |
---|
[2] | 5 | # See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
| 6 | #----------------------------------------------------------- |
---|
| 7 | |
---|
| 8 | include ${CMTROOT}/src/Makefile.core |
---|
| 9 | |
---|
| 10 | # |
---|
| 11 | # Basic tag management |
---|
| 12 | # |
---|
| 13 | ifdef tag |
---|
| 14 | CMTEXTRATAGS = $(tag) |
---|
| 15 | else |
---|
| 16 | tag = $(CMTCONFIG) |
---|
| 17 | endif |
---|
| 18 | |
---|
| 19 | tags = $(tag),$(CMTEXTRATAGS) |
---|
| 20 | |
---|
[434] | 21 | cmt_local_tagfile = $(bin)$(tag).make |
---|
[588] | 22 | cmt_broadcast_tagfile = $(bin)$(tag)_broadcast.make |
---|
[2] | 23 | |
---|
[434] | 24 | cmt_constituents_makefile = $(bin)constituents.make |
---|
[588] | 25 | cmt_broadcast_makefile = $(bin)broadcast.make |
---|
[434] | 26 | |
---|
[595] | 27 | #cmt_final_setup = $(bin)setup.make |
---|
[487] | 28 | |
---|
[588] | 29 | cmt_check_configurationstamp = $(bin)cmt_check_configuration.stamp |
---|
[2] | 30 | |
---|
[595] | 31 | #ifdef CMTBCAST |
---|
| 32 | #QUICK = 1 |
---|
| 33 | #endif |
---|
[2] | 34 | |
---|
[588] | 35 | ifdef QUICK |
---|
| 36 | ifndef CMTBCAST |
---|
[434] | 37 | |
---|
[588] | 38 | ifneq ($(MAKECMDGOALS),binclean) |
---|
| 39 | ifneq ($(MAKECMDGOALS),help) |
---|
| 40 | cmt_included = 1 |
---|
| 41 | -include $(cmt_local_tagfile) |
---|
| 42 | endif |
---|
| 43 | endif |
---|
[547] | 44 | |
---|
[588] | 45 | else |
---|
[2] | 46 | |
---|
[588] | 47 | ifneq ($(MAKECMDGOALS),help) |
---|
| 48 | cmt_included = 1 |
---|
| 49 | -include $(cmt_broadcast_tagfile) |
---|
| 50 | endif |
---|
[2] | 51 | |
---|
[588] | 52 | endif |
---|
| 53 | endif |
---|
| 54 | |
---|
| 55 | all :: |
---|
| 56 | ifndef CMTBCAST |
---|
| 57 | ifndef cmt_included |
---|
[547] | 58 | @$(MAKE) $(cmt_constituents_makefile) |
---|
[588] | 59 | endif |
---|
[616] | 60 | @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ |
---|
[588] | 61 | else |
---|
| 62 | ifndef cmt_included |
---|
| 63 | @$(MAKE) $(cmt_broadcast_makefile) |
---|
| 64 | endif |
---|
| 65 | @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ |
---|
| 66 | endif |
---|
| 67 | |
---|
| 68 | .DEFAULT : |
---|
| 69 | ifndef CMTBCAST |
---|
| 70 | ifndef cmt_included |
---|
| 71 | @$(MAKE) $(cmt_constituents_makefile) |
---|
| 72 | endif |
---|
[547] | 73 | @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ |
---|
[588] | 74 | else |
---|
| 75 | ifndef cmt_included |
---|
| 76 | @$(MAKE) $(cmt_broadcast_makefile) |
---|
| 77 | endif |
---|
| 78 | @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ |
---|
| 79 | endif |
---|
[547] | 80 | |
---|
[588] | 81 | check_config :: |
---|
| 82 | +@$(cmtexe) check configuration; retval=$$?; \ |
---|
| 83 | if test $${retval} -ne 0; then \ |
---|
| 84 | test -z "$(cmtmsg)" || \ |
---|
| 85 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ |
---|
| 86 | fi; exit $${retval} |
---|
[2] | 87 | |
---|
[588] | 88 | $(cmt_check_configurationstamp) : $(use_requirements) |
---|
| 89 | +@$(cmtexe) check configuration; retval=$$?; \ |
---|
| 90 | if test $${retval} -ne 0; then \ |
---|
| 91 | test -z "$(cmtmsg)" || \ |
---|
| 92 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ |
---|
| 93 | fi; exit $${retval} |
---|
| 94 | +$(silent) if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi && \touch $@ |
---|
| 95 | # echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; exit 17 |
---|
[2] | 96 | |
---|
[547] | 97 | ifndef QUICK |
---|
[588] | 98 | $(cmt_constituents_makefile) :: |
---|
| 99 | #$(cmt_constituents_makefile) : check_config |
---|
[547] | 100 | else |
---|
[588] | 101 | $(cmt_local_tagfile) $(cmt_constituents_makefile) : $(use_requirements) |
---|
| 102 | #$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(cmt_check_configurationstamp) |
---|
[547] | 103 | endif |
---|
[588] | 104 | +$(echo) "(Makefile.header) Rebuilding $@"; \ |
---|
[434] | 105 | if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ |
---|
[588] | 106 | $(cmtexe) -tag=$(tags) build constituents_config -out=$(cmt_constituents_makefile); \ |
---|
[434] | 107 | retval=$$?; \ |
---|
[547] | 108 | if test $${retval} -ne 0; then \ |
---|
[527] | 109 | test -z "$(cmtmsg)" || \ |
---|
[595] | 110 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot rebuild $@" >&2; \ |
---|
[527] | 111 | \rm -f $@; \ |
---|
| 112 | fi; \ |
---|
[434] | 113 | exit $${retval} |
---|
[2] | 114 | |
---|
[434] | 115 | ifndef QUICK |
---|
[588] | 116 | $(cmt_broadcast_makefile) :: |
---|
| 117 | #$(cmt_broadcast_makefile) : check_config |
---|
[434] | 118 | else |
---|
[588] | 119 | $(cmt_broadcast_tagfile) $(cmt_broadcast_makefile) : $(use_requirements) |
---|
| 120 | #$(cmt_broadcast_makefile) : $(cmt_check_configurationstamp) |
---|
[434] | 121 | endif |
---|
[588] | 122 | +$(echo) "(Makefile.header) Rebuilding $@"; \ |
---|
| 123 | if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ |
---|
| 124 | $(cmtexe) -tag=$(tags) build broadcast_config -out=$(cmt_broadcast_makefile); \ |
---|
| 125 | retval=$$?; \ |
---|
| 126 | if test $${retval} -ne 0; then \ |
---|
| 127 | test -z "$(cmtmsg)" || \ |
---|
[595] | 128 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot rebuild $@" >&2; \ |
---|
[588] | 129 | \rm -f $@; \ |
---|
| 130 | fi; \ |
---|
| 131 | exit $${retval} |
---|
[434] | 132 | |
---|
[2] | 133 | # |
---|
| 134 | # Ancient mechanism for remote launchers (kept for backward compatibility) |
---|
| 135 | # |
---|
| 136 | $(gmake_hosts) :: |
---|
[459] | 137 | rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; gmake $(MAKEFLAGS) $(target))'" |
---|
[2] | 138 | |
---|
| 139 | $(make_hosts) :: |
---|
| 140 | rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; make $(MAKEFLAGS) $(target))'" |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | everywhere :: $(everywhere) |
---|
| 144 | |
---|
[588] | 145 | ifndef CMTBCAST |
---|
| 146 | binclean :: |
---|
[616] | 147 | $(silent)if _bin=`cd $(bin) 2>/dev/null&&pwd -P`&&_cur=`pwd -P`&&[ -n "$${_bin}" ]&&[ "$${_cur#$${_bin}}" = "$${_cur}" ] ; then \ |
---|
[588] | 148 | test -z "$(cmtmsg)" || \ |
---|
| 149 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \ |
---|
| 150 | \rm -rf $(bin) ; \ |
---|
| 151 | fi |
---|
| 152 | endif |
---|
| 153 | |
---|
[2] | 154 | # |
---|
| 155 | # Display all targets |
---|
| 156 | # |
---|
| 157 | help :: |
---|
[588] | 158 | ifndef CMTBCAST |
---|
[2] | 159 | @echo '--------------------------------------------------------------------------' |
---|
| 160 | @echo 'You may select one of the following make targets :' |
---|
| 161 | @echo ' ' |
---|
| 162 | @echo 'help : this help' |
---|
| 163 | @echo 'all : rebuild all constituents according to the $$(constituents) macro' |
---|
| 164 | @echo ' (this is the default target)' |
---|
| 165 | @echo 'clean : remove everything that can be rebuilt' |
---|
| 166 | @echo 'binclean : fast erase of the binary directory' |
---|
[487] | 167 | @echo 'uninstall : remove everything installed in the installation area' |
---|
[2] | 168 | @echo ' ' |
---|
[459] | 169 | @groups=`$(cmtexe) show groups -tag=$(tags)`; \ |
---|
[2] | 170 | for g in $${groups}; do \ |
---|
| 171 | echo "$${g} : rebuild all constituents of group $${g}"; \ |
---|
| 172 | done |
---|
| 173 | @echo "Constituents:"; \ |
---|
[459] | 174 | for c in `$(cmtexe) show constituent_names -tag=$(tags)` ; do \ |
---|
[487] | 175 | echo " $${c} $${c}clean $${c}uninstall"; \ |
---|
[2] | 176 | done |
---|
| 177 | @echo ' ' |
---|
| 178 | @echo 'check :' |
---|
| 179 | @echo ' run all applications defined with the -check option' |
---|
| 180 | @echo ' ' |
---|
[588] | 181 | @echo 'To switch to BCAST mode, set CMTBCAST to non-empty string.' |
---|
| 182 | else |
---|
| 183 | @echo 'Targets for BCAST mode:' |
---|
| 184 | @echo |
---|
| 185 | @echo 'help : this help' |
---|
| 186 | ifndef BCAST_ONLY |
---|
| 187 | ifndef BCAST_GLOBAL |
---|
| 188 | @echo 'all : (re)build all used packages in current project (this is default target)' |
---|
| 189 | else |
---|
| 190 | @echo 'all : (re)build all used packages in all projects (this is default target)' |
---|
| 191 | endif |
---|
| 192 | else |
---|
| 193 | @echo 'all : (re)build current package (this is default target)' |
---|
| 194 | endif |
---|
| 195 | @echo 'clean : remove everything that can be rebuilt' |
---|
| 196 | @echo 'binclean : fast erase of binary directories (and installation area)' |
---|
| 197 | @echo 'uninstall : remove everything installed in the installation area' |
---|
[595] | 198 | @echo 'check : run all applications defined with the -check option' |
---|
[588] | 199 | @echo |
---|
| 200 | ifndef BCAST_GLOBAL |
---|
[652] | 201 | @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \ |
---|
| 202 | 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] | 203 | for u in $${uses}; do \ |
---|
| 204 | echo "$${u} : (re)build package $${u} ($(_groups))"; \ |
---|
| 205 | echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \ |
---|
| 206 | echo "$${u}binclean : fast erase of binary directory in package $${u}"; \ |
---|
| 207 | echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \ |
---|
[600] | 208 | echo "$${u}check : run all applications defined with the -check option in package $${u}"; \ |
---|
[588] | 209 | done |
---|
| 210 | else |
---|
[652] | 211 | @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \ |
---|
| 212 | 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] | 213 | for u in $${uses}; do \ |
---|
| 214 | echo "$${u} : (re)build package $${u} ($(_groups))"; \ |
---|
| 215 | echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \ |
---|
| 216 | echo "$${u}binclean : fast erase of binary directory in package $${u}"; \ |
---|
| 217 | echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \ |
---|
[600] | 218 | echo "$${u}check : run all applications defined with the -check option in package $${u}"; \ |
---|
[588] | 219 | done |
---|
| 220 | endif |
---|
| 221 | @echo |
---|
| 222 | ifndef BCAST_ONLY |
---|
| 223 | @echo ' ... with dependencies packages (may be ignored by setting BCAST_ONLY).' |
---|
| 224 | else |
---|
| 225 | @echo ' ... without dependencies packages (may be included by unsetting BCAST_ONLY).' |
---|
| 226 | endif |
---|
| 227 | @echo |
---|
| 228 | ifndef BCAST_GLOBAL |
---|
| 229 | @echo 'To (re)build packages in all projects, set BCAST_GLOBAL.' |
---|
| 230 | else |
---|
| 231 | @echo 'To (re)build packages in current project, unset BCAST_GLOBAL.' |
---|
| 232 | endif |
---|
| 233 | ifndef NO_ALL_GROUPS |
---|
| 234 | @echo 'To (re)build default group only, set NO_ALL_GROUPS.' |
---|
| 235 | ifndef CMTACTIONS |
---|
| 236 | @echo 'To also (re)build cmt_actions group, set CMTACTIONS.' |
---|
| 237 | endif |
---|
| 238 | else |
---|
| 239 | @echo 'To (re)build all groups, unset NO_ALL_GROUPS.' |
---|
| 240 | endif |
---|
| 241 | @echo |
---|
| 242 | @echo 'To switch to PACKAGE mode, unset CMTBCAST.' |
---|
| 243 | endif |
---|
[2] | 244 | |
---|
[588] | 245 | ifndef NO_ALL_GROUPS |
---|
| 246 | ifndef CMTACTIONS |
---|
| 247 | _groups = all groups except cmt_actions |
---|
| 248 | else |
---|
| 249 | _groups = all groups |
---|
| 250 | endif |
---|
| 251 | else |
---|
| 252 | _groups = default group |
---|
| 253 | endif |
---|
[2] | 254 | |
---|
[588] | 255 | # explicit rule to avoid implicit rule search |
---|
| 256 | # and not to remake |
---|
[434] | 257 | ${CMTROOT}/src/Makefile.header : ; |
---|
[588] | 258 | ${CMTROOT}/src/Makefile.core : ; |
---|
| 259 | ifdef use_requirements |
---|
| 260 | $(use_requirements) : ; |
---|
| 261 | endif |
---|
[547] | 262 | |
---|
| 263 | # for multiple command line goals, |
---|
| 264 | # avoid race conditions when (re)writing constituents.make |
---|
| 265 | .NOTPARALLEL : |
---|