
$(bin)${CONSTITUENT}.make :: build_library_links dirs
	@echo "------> (constituents.make) Building ${CONSTITUENT}.make"; \
	  $(cmtexe) build constituent_makefile ${CONSTITUENT} -quiet -tag=$(tags); \
	  if test ! "$(bin)" = "./"; then /bin/mv -f ${CONSTITUENT}.make $(bin); fi

#------------------------------------------------------------------------------------
#  Create a lock file while building the constituent. keep sleeping while another
# process builds this constituent.
#  This is only useful when the result of the build is in some shared directory
#  (eg for code generators)
#
${CONSTITUENT} :: $(${CONSTITUENT}_dependencies) $(bin)${CONSTITUENT}.make
	@a=`ls ${CONSTITUENT}_*.lock 2>/dev/null`; \
	if test ! "$${a}" = ""; then \
	  echo "==> ${CONSTITUENT} being built, waiting for completion..."; \
	  while test -f $${a}; do \
	    sleep 1; \
	  done; \
	  echo finished; \
	else \
	  lockfile=${CONSTITUENT}_$$$$.lock; \
	  trap '/bin/rm -f $${lockfile}; exit $${status}' 0 1 2 15; \
	  touch $${lockfile}; \
	  echo "------> (constituents.make) Starting ${CONSTITUENT}"; \
	  $(MAKE) -f $(bin)${CONSTITUENT}.make $(MAKEFLAGS) ${CONSTITUENT}; \
	  status=$$?; \
	fi

${CONSTITUENT}clean :: $(${CONSTITUENT}clean_dependencies) ##$(bin)${CONSTITUENT}.make
	@if test -f $(bin)${CONSTITUENT}.make; then \
	  echo "------> (constituents.make) Starting ${CONSTITUENT}clean"; \
	  $(MAKE) -f $(bin)${CONSTITUENT}.make $(MAKEFLAGS) ${CONSTITUENT}clean; \
	  /bin/rm -f $(bin)${CONSTITUENT}.make $(bin)${CONSTITUENT}_dependencies.make; \
	fi; \
	/bin/rm -f ${CONSTITUENT.stamp}



