#----------------------------------------------------------- # Copyright Christian Arnault LAL-Orsay CNRS # arnault@lal.in2p3.fr # Modified by Grigory Rybkin # See the complete license in cmt_license.txt "http://www.cecill.info". #----------------------------------------------------------- include ${CMTROOT}/src/Makefile.core # # Basic tag management # ifdef tag CMTEXTRATAGS = $(tag) else tag = $(CMTCONFIG) endif tags = $(tag),$(CMTEXTRATAGS) cmt_local_tagfile = $(bin)$(tag).make cmt_broadcast_tagfile = $(bin)$(tag)_broadcast.make cmt_constituents_makefile = $(bin)constituents.make cmt_broadcast_makefile = $(bin)broadcast.make #cmt_final_setup = $(bin)setup.make cmt_check_configurationstamp = $(bin)cmt_check_configuration.stamp #ifdef CMTBCAST #QUICK = 1 #endif ifdef QUICK ifndef CMTBCAST ifneq ($(MAKECMDGOALS),binclean) ifneq ($(MAKECMDGOALS),help) cmt_included = 1 -include $(cmt_local_tagfile) endif endif else ifneq ($(MAKECMDGOALS),help) cmt_included = 1 -include $(cmt_broadcast_tagfile) endif endif endif all :: ifndef CMTBCAST ifndef cmt_included @$(MAKE) $(cmt_constituents_makefile) endif @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ else ifndef cmt_included @$(MAKE) $(cmt_broadcast_makefile) endif @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ endif .DEFAULT : ifndef CMTBCAST ifndef cmt_included @$(MAKE) $(cmt_constituents_makefile) endif @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ else ifndef cmt_included @$(MAKE) $(cmt_broadcast_makefile) endif @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ endif check_config :: +@$(cmtexe) check configuration; retval=$$?; \ if test $${retval} -ne 0; then \ test -z "$(cmtmsg)" || \ echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ fi; exit $${retval} $(cmt_check_configurationstamp) : $(use_requirements) +@$(cmtexe) check configuration; retval=$$?; \ if test $${retval} -ne 0; then \ test -z "$(cmtmsg)" || \ echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ fi; exit $${retval} +$(silent) if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi && \touch $@ # echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; exit 17 ifndef QUICK $(cmt_constituents_makefile) :: #$(cmt_constituents_makefile) : check_config else $(cmt_local_tagfile) $(cmt_constituents_makefile) : $(use_requirements) #$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(cmt_check_configurationstamp) endif +$(echo) "(Makefile.header) Rebuilding $@"; \ if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ $(cmtexe) -tag=$(tags) build constituents_config -out=$(cmt_constituents_makefile); \ retval=$$?; \ if test $${retval} -ne 0; then \ test -z "$(cmtmsg)" || \ echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot rebuild $@" >&2; \ \rm -f $@; \ fi; \ exit $${retval} ifndef QUICK $(cmt_broadcast_makefile) :: #$(cmt_broadcast_makefile) : check_config else $(cmt_broadcast_tagfile) $(cmt_broadcast_makefile) : $(use_requirements) #$(cmt_broadcast_makefile) : $(cmt_check_configurationstamp) endif +$(echo) "(Makefile.header) Rebuilding $@"; \ if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ $(cmtexe) -tag=$(tags) build broadcast_config -out=$(cmt_broadcast_makefile); \ retval=$$?; \ if test $${retval} -ne 0; then \ test -z "$(cmtmsg)" || \ echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot rebuild $@" >&2; \ \rm -f $@; \ fi; \ exit $${retval} # # Ancient mechanism for remote launchers (kept for backward compatibility) # $(gmake_hosts) :: rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; gmake $(MAKEFLAGS) $(target))'" $(make_hosts) :: rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; make $(MAKEFLAGS) $(target))'" everywhere :: $(everywhere) ifndef CMTBCAST binclean :: $(silent)if _bin=`cd $(bin) 2>/dev/null&&pwd -P`&&_cur=`pwd -P`&&[ -n "$${_bin}" ]&&[ "$${_cur#$${_bin}}" = "$${_cur}" ] ; then \ test -z "$(cmtmsg)" || \ echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \ \rm -rf $(bin) ; \ fi endif # # Display all targets # help :: ifndef CMTBCAST @echo '--------------------------------------------------------------------------' @echo 'You may select one of the following make targets :' @echo ' ' @echo 'help : this help' @echo 'all : rebuild all constituents according to the $$(constituents) macro' @echo ' (this is the default target)' @echo 'clean : remove everything that can be rebuilt' @echo 'binclean : fast erase of the binary directory' @echo 'uninstall : remove everything installed in the installation area' @echo ' ' @groups=`$(cmtexe) show groups -tag=$(tags)`; \ for g in $${groups}; do \ echo "$${g} : rebuild all constituents of group $${g}"; \ done @echo "Constituents:"; \ for c in `$(cmtexe) show constituent_names -tag=$(tags)` ; do \ echo " $${c} $${c}clean $${c}uninstall"; \ done @echo ' ' @echo 'check :' @echo ' run all applications defined with the -check option' @echo ' ' @echo 'To switch to BCAST mode, set CMTBCAST to non-empty string.' else @echo 'Targets for BCAST mode:' @echo @echo 'help : this help' ifndef BCAST_ONLY ifndef BCAST_GLOBAL @echo 'all : (re)build all used packages in current project (this is default target)' else @echo 'all : (re)build all used packages in all projects (this is default target)' endif else @echo 'all : (re)build current package (this is default target)' endif @echo 'clean : remove everything that can be rebuilt' @echo 'binclean : fast erase of binary directories (and installation area)' @echo 'uninstall : remove everything installed in the installation area' @echo 'check : run all applications defined with the -check option' @echo ifndef BCAST_GLOBAL @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \ 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}}'`; \ for u in $${uses}; do \ echo "$${u} : (re)build package $${u} ($(_groups))"; \ echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \ echo "$${u}binclean : fast erase of binary directory in package $${u}"; \ echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \ echo "$${u}check : run all applications defined with the -check option in package $${u}"; \ done else @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \ 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}}'`; \ for u in $${uses}; do \ echo "$${u} : (re)build package $${u} ($(_groups))"; \ echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \ echo "$${u}binclean : fast erase of binary directory in package $${u}"; \ echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \ echo "$${u}check : run all applications defined with the -check option in package $${u}"; \ done endif @echo ifndef BCAST_ONLY @echo ' ... with dependencies packages (may be ignored by setting BCAST_ONLY).' else @echo ' ... without dependencies packages (may be included by unsetting BCAST_ONLY).' endif @echo ifndef BCAST_GLOBAL @echo 'To (re)build packages in all projects, set BCAST_GLOBAL.' else @echo 'To (re)build packages in current project, unset BCAST_GLOBAL.' endif ifndef NO_ALL_GROUPS @echo 'To (re)build default group only, set NO_ALL_GROUPS.' ifndef CMTACTIONS @echo 'To also (re)build cmt_actions group, set CMTACTIONS.' endif else @echo 'To (re)build all groups, unset NO_ALL_GROUPS.' endif @echo @echo 'To switch to PACKAGE mode, unset CMTBCAST.' endif ifndef NO_ALL_GROUPS ifndef CMTACTIONS _groups = all groups except cmt_actions else _groups = all groups endif else _groups = default group endif # explicit rule to avoid implicit rule search # and not to remake ${CMTROOT}/src/Makefile.header : ; ${CMTROOT}/src/Makefile.core : ; ifdef use_requirements $(use_requirements) : ; endif # for multiple command line goals, # avoid race conditions when (re)writing constituents.make .NOTPARALLEL :