#----------------------------------------------------------- # Copyright Christian Arnault LAL-Orsay CNRS # arnault@lal.in2p3.fr # 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) ifdef READONLY cmt_local_tagfile = /tmp/CMT_$(tag).make$$$$ else cmt_local_tagfile = $(bin)$(tag).make endif ifdef READONLY cmt_constituents_makefile = /tmp/CMT_$(tag)_constituents.make$$$$ else cmt_constituents_makefile = $(bin)constituents.make endif # # Generic entry points for all targets # ifndef QUICK all :: check_config ; else all :: no_check_config ; endif check_config :: @$(cmtexe) check configuration; retval=$$?; \ if test $${retval} = 0; then \ $(MAKE) --no-print-directory target="first config all" common_target; \ else \ echo "#CMT> There are configuration errors. Please correct them before running gmake"; \ fi no_check_config :: @$(MAKE) --no-print-directory target="first config all" common_target binclean :: @if test ! "$(bin)" = "./"; then \ if test -d $(bin) ; then \ echo "------> (Makefile.header) Cleaning all from $(bin)"; \ /bin/rm -rf $(bin) ; \ fi ; \ fi clean :: @$(cmtexe) check configuration @$(MAKE) --no-print-directory target="$@" common_target .DEFAULT :: @$(cmtexe) check configuration @$(MAKE) --no-print-directory target="config $@" common_target # # Capture all possible targets # ifdef READONLY common_target :: @tmpdir=/tmp; \ if test ! "${TMPDIR}" = ""; then tmpdir=${TMPDIR}; fi; \ cmt_lock_pid=`mkdir -p $${tmpdir}; mktemp $${tmpdir}/CMT_XXXXXX | sed -e 's#'"$${tmpdir}"'/CMT_##'`; \ temp_marker=$${tmpdir}/CMT_$${cmt_lock_pid}; \ temp_lock=$${tmpdir}/CMT_lock$${cmt_lock_pid}.make; \ temp_constituents=$${tmpdir}/CMT_constituents$${cmt_lock_pid}; \ if test ! "${CMTMAKEDEBUG}" = 1; then\ trap '/bin/rm -f $${temp_lock} $${temp_constituents} $${temp_marker}; exit $${status}' 0 1 2 15; \ fi; \ /bin/rm -f $${temp_marker}; \ /bin/rm -f $${temp_lock}; \ echo "------> (Makefile.header) Rebuilding constituents.make"; \ $(cmtexe) -quiet -tag=$(tags) build constituents_makefile -out=$${temp_constituents}; status=$$?; \ if test $${status} = 0; then \ /bin/rm -f $(cmt_local_tagfile); \ $(MAKE) --no-print-directory -f $${temp_constituents} cmt_lock_pid=$${cmt_lock_pid} $(target); \ status=$$?; \ else \ echo "#CMT> Error generating constituents makefile"; \ fi; \ exit $${status} else common_target : $(cmt_constituents_makefile) @$(MAKE) --no-print-directory -f $< cmt_lock_pid=$(cmt_lock_pid) $(target) endif $(cmt_constituents_makefile) : $(cmt_local_tagfile) $(echo) "(Makefile.header) Rebuilding $@"; \ if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ $(cmtexe) -quiet -tag=$(tags) build constituents_makefile -out=$@; \ retval=$$?; \ if test $${retval} != 0; then \ echo "#CMT> Error: $@: Cannot generate" >&2; \ /bin/rm -f $@; fi; \ exit $${retval} ifndef QUICK $(cmt_local_tagfile) :: else $(cmt_local_tagfile) : endif $(echo) "(Makefile.header) Rebuilding $@"; \ if test -f $@; then rm -f $@; fi; \ if test ! -d $(@D); then $(mkdir) -p $(@D); fi; \ $(cmtexe) -quiet -tag=$(tags) build tag_makefile >$@ # && /bin/echo $@ ok # $(echo) CMTCONFIG=$(CMTCONFIG) ; \ # # # Ancient mechanism for remote launchers (kept for backward compatibility) # $(gmake_hosts) :: rsh $@ "sh -c '(cd `$(cmtexe) show pwd -quiet`; . setup.sh; gmake $(MAKEFLAGS) $(target))'" $(make_hosts) :: rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; make $(MAKEFLAGS) $(target))'" everywhere :: $(everywhere) # # Display all targets # help :: @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 ' ' @groups=`$(cmtexe) show groups -quiet -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 -quiet -tag=$(tags)` ; do \ echo " $${c} $${c}clean"; \ done @echo ' ' @echo 'check :' @echo ' run all applications defined with the -check option' @echo ' ' # explicit rule not to remake ${CMTROOT}/src/Makefile.header : ; ${CMTROOT}/src/Makefile.core : ;