
include ${CMTROOT}/src/Makefile.core

ifdef tag
CMTEXTRATAGS = $(tag)
else
tag       = $(CMTCONFIG)
endif

tags      = $(CMTCONFIG),$(CMTEXTRATAGS)

${PACKAGE}_tag = $(tag)

#--------------------------------------------------------

cmt_lock_setup = lock$(cmt_lock_pid).make
cmt_setup_pid  = $(bin)setup$(cmt_lock_pid).make

first :: $(${PACKAGE}_tag).make
	@echo " ---> first: $(${PACKAGE}_tag).make ok"

$(${PACKAGE}_tag).make : $(cmt_lock_setup)
	@echo "------> (constituents.make) Rebuilding setup.make $(${PACKAGE}_tag).make"; \
	\
	if test -f $(${PACKAGE}_tag).make; then /bin/rm -f $(${PACKAGE}_tag).make; fi; \
	$(cmtexe) -quiet -tag=$(tags) build tag_makefile >t$(cmt_lock_pid); \
	mv t$(cmt_lock_pid) $(${PACKAGE}_tag).make ; \
	\
	if test ! -d $(bin) ; then $(mkdir) -p $(bin) ; fi; \
	if test -f $(cmt_setup_pid); then /bin/rm -f $(cmt_setup_pid); fi; \
	echo "----------> uses"                     >$(cmt_setup_pid); \
	$(cmtexe) -quiet -tag=$(tags) show uses    >>$(cmt_setup_pid); \
	echo "----------> tags"                    >>$(cmt_setup_pid); \
	$(cmtexe) -tag=$(tags) show tags           >>$(cmt_setup_pid); \
	echo "----------> CMTPATH"                 >>$(cmt_setup_pid); \
	$(cmtexe) show path -tag=$(tags) -quiet    >>$(cmt_setup_pid); \
	/bin/mv $(cmt_setup_pid) $(bin)${PACKAGE}setup.make; \
	/bin/echo setup.make ok

-include $(${PACKAGE}_tag).make

config :: checkuses ##$(${PACKAGE}_tag).make

env.make ::
	printenv >env.make.tmp; $(cmtexe) -quiet check files env.make.tmp env.make

all :: build_library_links

javadirs ::
	@if test ! -d $(javabin) ; then $(mkdir) -p $(javabin) ; fi

srcdirs ::
	@if test ! -d $(src) ; then $(mkdir) -p $(src) ; fi

dirs ::
	@if test ! -r requirements ; then echo "No requirements file" ; fi; \
	  if test ! -d $(bin) ; then $(mkdir) -p $(bin) ; fi

build_library_links : dirs requirements
	@echo "------> (constituents.make) Rebuilding library links"; \
	if test ! -d $(bin) ; then $(mkdir) -p $(bin) ; fi; \
	$(build_library_links)

.DEFAULT :
	@if test "$@" = "$(cmt_lock_setup)"; then \
	  /bin/rm -f $(cmt_lock_setup); \
	  touch $(cmt_lock_setup); \
	fi

