#-- start of constituent_app_lib ------

cmt_${CONSTITUENT}_${HASTARGETTAG} = 1
cmt_${CONSTITUENT}_${HASPROTOTYPES} = 1
cmt_${CONSTITUENT}_${HASDEPENDENCIES} = 1

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

!if defined (cmt_${CONSTITUENT}_has_target_tag)

cmt_local_tagfile_${CONSTITUENT} = $(bin)$(${PACKAGE}_tag)_${CONSTITUENT}.nmake
cmt_final_setup_${CONSTITUENT} = $(bin)setup_${CONSTITUENT}.nmake
cmt_local_${CONSTITUENT}_makefile = $(bin)${CONSTITUENT}.nmake

${CONSTITUENT}_extratags = -tag_add=target_${CONSTITUENT}

!else

cmt_local_tagfile_${CONSTITUENT} = $(bin)$(${PACKAGE}_tag).nmake
cmt_final_setup_${CONSTITUENT} = $(bin)setup.nmake
cmt_local_${CONSTITUENT}_makefile = $(bin)${CONSTITUENT}.nmake

!endif

!if defined (cmt_${CONSTITUENT}_has_target_tag)

!if "$(QUICK)" == "" || !exist ($(cmt_local_${CONSTITUENT}_makefile)) || !exist ($(cmt_local_tagfile_${CONSTITUENT})) || !exist ($(cmt_final_setup_${CONSTITUENT}))
$(cmt_local_${CONSTITUENT}_makefile) :: $(${CONSTITUENT}compile_dependencies) dirs
	$(echo) (constituents.nmake) Building ${CONSTITUENT}.nmake
	@set include=$(include)
	@set lib=$(lib)
	@$(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build -nmake constituent_config -out=$@ ${CONSTITUENT}
!else
$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}compile_dependencies) $(use_requirements)
	@set include=$(include)
	@set lib=$(lib)
	@if not "$?"=="$(${CONSTITUENT}compile_dependencies)" ((if not "$(cmtmsg)"=="" @echo "$(CMTMSGPREFIX)" "(constituents.nmake) Rebuilding ${CONSTITUENT}.nmake") & $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build -nmake constituent_config -out=$@ ${CONSTITUENT}) else (if not "$(cmtmsg)"=="" @echo "$(CMTMSGPREFIX)" "(constituents.nmake) ${CONSTITUENT}.nmake up-to-date")
!endif

!else

!if "$(QUICK)" == "" || !exist ($(cmt_local_${CONSTITUENT}_makefile)) || !exist ($(cmt_local_tagfile_${CONSTITUENT})) || !exist ($(cmt_final_setup_${CONSTITUENT}))
$(cmt_local_${CONSTITUENT}_makefile) :: $(${CONSTITUENT}compile_dependencies) dirs
	$(echo) (constituents.nmake) Building ${CONSTITUENT}.nmake
	@set include=$(include)
	@set lib=$(lib)
	@$(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build -nmake constituent_makefile -without_cmt -out=$@ ${CONSTITUENT}
!else
$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}compile_dependencies) $(use_requirements) $(bin)${CONSTITUENT}.in
	@set include=$(include)
	@set lib=$(lib)
	@if not "$?"=="$(${CONSTITUENT}compile_dependencies)" ((if not "$(cmtmsg)"=="" @echo "$(CMTMSGPREFIX)" "(constituents.nmake) Rebuilding ${CONSTITUENT}.nmake") & $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build -nmake constituent_makefile -without_cmt -out=$@ ${CONSTITUENT}) else (if not "$(cmtmsg)"=="" @echo "$(CMTMSGPREFIX)" "(constituents.nmake) ${CONSTITUENT}.nmake up-to-date")
!endif

!endif

${CONSTITUENT} :: ${CONSTITUENT}compile ${CONSTITUENT}install ;


!if defined (cmt_${CONSTITUENT}_has_prototypes)

${CONSTITUENT}prototype : $(${CONSTITUENT}prototype_dependencies) $(cmt_local_${CONSTITUENT}_makefile) dirs
	$(echo) (constituents.nmake) Starting $@
	@set include=$(include)
	@set lib=$(lib)
	@$(MAKE) /nologo /f $(cmt_local_${CONSTITUENT}_makefile) /$(MAKEFLAGS) bin=$(bin) build_strategy=keep_makefiles $@ tag=$(tag)
	$(echo) (constituents.nmake) $@ done

${CONSTITUENT}compile : ${CONSTITUENT}prototype

!if defined (cmt_${CONSTITUENT}_has_dependencies)

${CONSTITUENT}dependencies : ${CONSTITUENT}prototype

!endif

!endif


!if defined (cmt_${CONSTITUENT}_has_dependencies)

${CONSTITUENT}dependencies : $(cmt_local_${CONSTITUENT}_makefile) dirs
	$(echo) (constituents.nmake) Starting $@
	@set include=$(include)
	@set lib=$(lib)
	@$(MAKE) /nologo /f $(cmt_local_${CONSTITUENT}_makefile) /$(MAKEFLAGS) bin=$(bin) build_strategy=keep_makefiles dependencies tag=$(tag)
	$(echo) (constituents.nmake) $@ done

${CONSTITUENT}compile : ${CONSTITUENT}dependencies

!endif

${CONSTITUENT}compile : $(${CONSTITUENT}compile_dependencies) $(cmt_local_${CONSTITUENT}_makefile) dirs
	$(echo) (constituents.nmake) Starting $@
	@set include=$(include)
	@set lib=$(lib)
	@$(MAKE) /nologo /f $(cmt_local_${CONSTITUENT}_makefile) /$(MAKEFLAGS) bin=$(bin) build_strategy=keep_makefiles $@ tag=$(tag)
	$(echo) (constituents.nmake) $@ done

clean :: ${CONSTITUENT}clean ;

${CONSTITUENT}clean :: $(${CONSTITUENT}clean_dependencies) ##$(cmt_local_${CONSTITUENT}_makefile)
	$(echo) (constituents.nmake) Starting $@
	@set include=$(include)
	@set lib=$(lib)
	@-if exist $(cmt_local_${CONSTITUENT}_makefile) $(MAKE) /nologo /f $(cmt_local_${CONSTITUENT}_makefile) /$(MAKEFLAGS) bin=$(bin) build_strategy=keep_makefiles $@ tag=$(tag)
	$(echo) (constituents.nmake) $@ done
#	@$(MAKE) /nologo /f $(cmt_local_${CONSTITUENT}_makefile) /$(MAKEFLAGS) bin=$(bin) build_strategy=keep_makefiles ${CONSTITUENT}clean tag=$(tag)

install :: ${CONSTITUENT}install ;

${CONSTITUENT}install :: ${CONSTITUENT}compile $(${CONSTITUENT}_dependencies) $(cmt_local_${CONSTITUENT}_makefile)
	$(echo) (constituents.nmake) Starting $@
	@set include=$(include)
	@set lib=$(lib)
	@$(MAKE) /nologo /f $(cmt_local_${CONSTITUENT}_makefile) /$(MAKEFLAGS) bin=$(bin) build_strategy=keep_makefiles install tag=$(tag)
	$(echo) (constituents.nmake) $@ done

uninstall :: ${CONSTITUENT}uninstall ;

${CONSTITUENT}uninstall :: $(${CONSTITUENT}uninstall_dependencies)
	$(echo) (constituents.nmake) Starting $@
	@set include=$(include)
	@set lib=$(lib)
	@-if exist $(cmt_local_${CONSTITUENT}_makefile) $(MAKE) /nologo /f $(cmt_local_${CONSTITUENT}_makefile) /$(MAKEFLAGS) bin=$(bin) build_strategy=keep_makefiles uninstall tag=$(tag)
#	@if not exist $(cmt_local_${CONSTITUENT}_makefile) $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build -nmake constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
#	@if not exist $(cmt_local_${CONSTITUENT}_makefile) $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build -nmake constituent_makefile -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
#	@-$(MAKE) /nologo /f $(cmt_local_${CONSTITUENT}_makefile) /$(MAKEFLAGS) bin=$(bin) build_strategy=keep_makefiles uninstall tag=$(tag)
	$(echo) (constituents.nmake) $@ done

#-- end of constituent_app_lib ------
