include  $(COSMOSTOP)/site.config


EXTHDRS	      = $(COSMOSINC)/Zcode.h \
		$(COSMOSINC)/Zevhnp.h \
		$(COSMOSINC)/Zevhnv.h \
		$(COSMOSINC)/Zkfcode.h \
		$(COSMOSINC)/Zmanager.h \
		$(COSMOSINC)/Zmanagerp.h \
		$(COSMOSINC)/Zmass.h \
		$(COSMOSINC)/Zmaxdef.h \
		$(COSMOSINC)/Zptcl.h \
		$(COSMOSINC)/ZstrangeCode.h \
		$(COSMOSINC)/Zunionmap.h

HDRS	      = Zlujets.h


MAKEFILE      = Makefile

OBJS	      = ccos2gheCode.o \
		cdpmjet.o \
		cQGSjet.o \
		cfrevent.o \
		cghe2cos.o \
		cgheDecay.o \
		chAGheisha.o \
		chALund.o \
		chANewLund.o \
		cincdpm3.o \
		cintModels.o \
		ckf2cos.o \
		cjam.o \
		cphits.o \
		cjqmd.o \
		cbertini.o \
		cxsecGheisha.o

PRINT	      = pr

SHELL	      = /bin/sh

SRCS	      = ccos2gheCode.f \
		cdpmjet.f \
		cQGSjet.f \
		cfrevent.f \
		cghe2cos.f \
		cgheDecay.f \
		chAGheisha.f \
		chALund.f \
		chANewLund.f \
		cincdpm3.f \
		cintModels.f \
		ckf2cos.f \
		cjam.f \
		cjphits.f \
		cjqmd.f \
		cbertini.f \
		cxsecGheisha.f

SYSHDRS	      =

all:
	make	Checkdir $(LIBRARY) SeeSubDir "TARGET=$@"

clean:
	@rm -f $(OBJS) core  *~ a.out temp*.o 
	make SeeSubDir "TARGET=$@"

veryclean:
	@rm -f $(OBJS) core  *~ a.out temp*.o temp*.f
	make SeeSubDir "TARGET=$@"


clobber:
	@rm -f $(OBJS) $(LIBRARY) core tags
	make SeeSubDir "TARGET=$@"

depend:
	@mkmf -f $(MAKEFILE) ROOT=$(ROOT)
	make SeeSubDir "TARGET=$@"

echo:
	@echo $(HDRS) $(SRCS)
	make SeeSubDir "TARGET=$@"

extract:
	@ar x $(LIBRARY)


index:
	@ctags -wx $(HDRS) $(SRCS)
	make SeeSubDir "TARGET=$@"

install:	$(LIBRARY)
		@echo "****" Installing $(LIBRARY) into $(DEST)
		$(INSTALL) -f  $(DEST) $(LIBRARY)
		@echo "****" Installing Template files into $(TEMPLATE)
		cp -r  $(COSMOSTOP)/Data  $(COSMOSTOP)/Util *
		 $(COSMOSTOP)/UserHook  $(COSMOSTOP)/Scrpt *
		 $(COSMOSTOP)/Doc        $(TEMPLATE)/
		cp $(COSMOSTOP)/site.config $(TEMPLATE)/
		@echo "****" Installing header files into $(HEADER)
		cp -r $(COSMOSTOP)/cosmos  $(HEADER)/
		@echo "****" Installation ended.
		@echo "****" Owner and group should be changed by hand

print:
	@$(PRINT) $(HDRS) $(SRCS)
	make SeeSubDir "TARGET=$@"

tags:           $(HDRS) $(SRCS)
	@ctags $(HDRS) $(SRCS)
	make SeeSubDir "TARGET=$@"


Checkdir:
	@( cd $(COSMOSTOP)/lib; if [ ! -d  $(ARCH) ]; then  mkdir $(ARCH); fi)



SeeSubDir:
	@for i in  * \
	;do   \
		if [ -d  $$i ] ; then \
			(cd $$i; \
			if [ -f Makefile  -a  $$i != Test \
			-a $$i != Util -a $$i != UC  \
	                -a $$i != Ana  -a $$i != Ceren \
	                -a $$i != Data  -a $$i != cosmos \
	                -a $$i != Misc  -a $$i != MuUg \
	                -a $$i != Obso  -a $$i != TeX \
	                -a $$i != lib  -a $$i != UserHook \
	                -a $$i != Doc  -a $$i != Betterone \
	                -a $$i != Scrpt -a $$i != NotForExport ] ; then \
		            $(MAKE) $(TARGET) \
			;fi) \
		; fi \
	done
###
$(LIBRARY)(ccos2gheCode.o): $(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cdpmjet.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zkfcode.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zevhnv.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zmass.h
$(LIBRARY)(cQGSjet.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zkfcode.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zevhnv.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zmass.h
$(LIBRARY)(cfrevent.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zkfcode.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zmass.h Zlujets.h
$(LIBRARY)(cghe2cos.o): $(COSMOSINC)/Zcode.h
$(LIBRARY)(cgheDecay.o): $(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(chAGheisha.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zcode.h
$(LIBRARY)(chALund.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zevhnv.h \
	$(COSMOSINC)/ZstrangeCode.h
$(LIBRARY)(chANewLund.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zevhnv.h
$(LIBRARY)(cincdpm3.o): $(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zevhnp.h
$(LIBRARY)(cintModels.o): $(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zmanager.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zevhnv.h
$(LIBRARY)(ckf2cos.o): $(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zkfcode.h
$(LIBRARY)(cjam.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zkfcode.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zmass.h

$(LIBRARY)(cxsecGheisha.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h

$(LIBRARY):         \
               $(LIBRARY)(ccos2gheCode.o) \
               $(LIBRARY)(cdpmjet.o) \
               $(LIBRARY)(cQGSjet.o) \
               $(LIBRARY)(cfrevent.o) \
               $(LIBRARY)(cghe2cos.o) \
               $(LIBRARY)(cgheDecay.o) \
               $(LIBRARY)(chAGheisha.o) \
               $(LIBRARY)(chALund.o) \
               $(LIBRARY)(chANewLund.o) \
               $(LIBRARY)(cincdpm3.o) \
               $(LIBRARY)(cintModels.o) \
               $(LIBRARY)(ckf2cos.o) \
               $(LIBRARY)(cjam.o) \
               $(LIBRARY)(cphits.o) \
               $(LIBRARY)(cjqmd.o) \
               $(LIBRARY)(cbertini.o) \
               $(LIBRARY)(cxsecGheisha.o) 
