#-- start of packages_header ------

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

include $(cmt_broadcast_tagfile)

ifndef BCAST_CMD
BCAST_CMD = $(cmtexe) make
endif

ifdef LOG_LOCATION
LOG_SUFFIX = .log
endif

ifndef CMTACTIONS
Cmt_actions_handler = test "$$group" != cmt_actions || continue ;
else
Cmt_actions_handler =
endif

# -- Special macro to change the behavior on a failure of a package
#    (complementary to the option '-k')
#  Allowed values for PACKAGE_FAILURE_POLICY:
#    stop:   do not continue (default)
#    skip:   if a group fails, continue with the next package
#    ignore: try all the groups even if one fails before going to the next package
#            (may result in duplicated errors within a package)
# Taken from https://svnweb.cern.ch/trac/gaudi/browser/Gaudi/trunk/Makefile.cmt (Modified)
Package_failure_handler = test $$BUILD_RESULT -eq 0 || exit $$BUILD_RESULT ;
ifdef PACKAGE_FAILURE_POLICY
ifeq ($(PACKAGE_FAILURE_POLICY),stop)
Package_failure_handler = test $$BUILD_RESULT -eq 0 || exit $$BUILD_RESULT ;
else
ifeq ($(PACKAGE_FAILURE_POLICY),skip)
Package_failure_handler = test $$BUILD_RESULT -eq 0 || break ;
else
ifeq ($(PACKAGE_FAILURE_POLICY),ignore)
Package_failure_handler = test $$BUILD_RESULT -eq 0 || : ;
else
$(error Unknown PACKAGE_FAILURE_POLICY "$(PACKAGE_FAILURE_POLICY)". Allowed values: "stop" (default), "skip", "ignore")
endif
endif
endif
endif
# -----------------------------------------------------------------

all : ;

ifdef BCAST_ONLY
all : ${PACKAGE}
clean : ${PACKAGE}clean
binclean : ${PACKAGE}binclean
uninstall : ${PACKAGE}uninstall
check : ${PACKAGE}check
endif
#--------------------------------------------------------

${CMTROOT}/src/Makefile.core : ;
$(cmt_broadcast_tagfile) : ;
ifdef use_requirements
$(use_requirements) : ;
endif

ifndef PEDANTIC
.DEFAULT :
	$(echo) "(packages) $@: No rule for such target" >&2
endif

#-- end of packages_header ------
