include  $(COSMOSTOP)/site.config


EXTHDRS	      = $(COSMOSINC)/BlockData/cblkElemag.h \
		$(COSMOSINC)/BlockData/cblkEvhnp.h \
		$(COSMOSINC)/BlockData/cblkGene.h \
		$(COSMOSINC)/BlockData/cblkHeavy.h \
		$(COSMOSINC)/BlockData/cblkIncident.h \
		$(COSMOSINC)/BlockData/cblkManager.h \
		$(COSMOSINC)/BlockData/cblkMuInt.h \
		$(COSMOSINC)/BlockData/cblkObs.h \
		$(COSMOSINC)/BlockData/cblkTracking.h \
		$(COSMOSINC)/BlockData/cblkXsec.h \
		$(COSMOSINC)/BlockData/cblkdedx.h \
		$(COSMOSINC)/Zcmuint.h \
		$(COSMOSINC)/Zcode.h \
		$(COSMOSINC)/Zcondc.h \
		$(COSMOSINC)/Zcoord.h \
		$(COSMOSINC)/ZcosmosBD.h \
		$(COSMOSINC)/ZdedxAir.h \
		$(COSMOSINC)/Zdirec.h \
		$(COSMOSINC)/Zelemagp.h \
		$(COSMOSINC)/Zevhnp.h \
		$(COSMOSINC)/Zheavyp.h \
		$(COSMOSINC)/Zheavyv.h \
		$(COSMOSINC)/ZincForNameL.h \
		$(COSMOSINC)/Zincidentp.h \
		$(COSMOSINC)/Zmagfield.h \
		$(COSMOSINC)/Zmanager.h \
		$(COSMOSINC)/Zmanagerp.h \
		$(COSMOSINC)/Zmaxdef.h \
		$(COSMOSINC)/Znamelist.h \
		$(COSMOSINC)/Znamelist1.h \
		$(COSMOSINC)/Znamelist2.h \
		$(COSMOSINC)/Zobs.h \
		$(COSMOSINC)/Zobsp.h \
		$(COSMOSINC)/Zobsv.h \
		$(COSMOSINC)/Zpos.h \
		$(COSMOSINC)/Zprimary.h \
		$(COSMOSINC)/Zprimaryv.h \
		$(COSMOSINC)/Zptcl.h \
		$(COSMOSINC)/Zreadonly.h \
		$(COSMOSINC)/Ztrack.h \
		$(COSMOSINC)/Ztrackp.h \
		$(COSMOSINC)/Ztrackv.h \
		$(COSMOSINC)/Zunionmap.h \
		$(COSMOSINC)/Zxsectionp.h

HDRS	      =


MAKEFILE      = Makefile

OBJS	      = c2lowerCase.o \
		cbeginRun.o \
		cblkData.o \
		cendRun.o \
		cerrorMsg.o \
		ceventLoop.o \
		cgetLoginN.o \
		cmanager.o \
		copenf.o \
		creadParam.o \
		cskipComment.o \
		cwriteParam.o

PRINT	      = pr

SHELL	      = /bin/sh

SRCS	      = c2lowerCase.f \
		cbeginRun.f \
		cblkData.f \
		cendRun.f \
		cerrorMsg.f \
		ceventLoop.f \
		cgetLoginN.f \
		cmanager.f \
		copenf.f \
		creadParam.f \
		cskipComment.f \
		cwriteParam.f

SYSHDRS	      =

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

clean:
	@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)(cbeginRun.o): $(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zelemagp.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Ztrack.h \
	$(COSMOSINC)/Zcondc.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zcoord.h \
	$(COSMOSINC)/Zpos.h \
	$(COSMOSINC)/Zdirec.h \
	$(COSMOSINC)/Zmagfield.h \
	$(COSMOSINC)/Ztrackv.h \
	$(COSMOSINC)/Ztrackp.h \
	$(COSMOSINC)/Zincidentp.h \
	$(COSMOSINC)/Zprimary.h \
	$(COSMOSINC)/Zprimaryv.h \
	$(COSMOSINC)/Zobs.h \
	$(COSMOSINC)/Zobsp.h \
	$(COSMOSINC)/Zobsv.h \
	$(COSMOSINC)/Zheavyv.h
$(LIBRARY)(cblkData.o): $(COSMOSINC)/ZcosmosBD.h \
	$(COSMOSINC)/BlockData/cblkGene.h \
	$(COSMOSINC)/BlockData/cblkElemag.h \
	$(COSMOSINC)/Zelemagp.h \
	$(COSMOSINC)/BlockData/cblkEvhnp.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/BlockData/cblkHeavy.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zheavyp.h \
	$(COSMOSINC)/BlockData/cblkIncident.h \
	$(COSMOSINC)/Zincidentp.h \
	$(COSMOSINC)/BlockData/cblkManager.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/BlockData/cblkMuInt.h \
	$(COSMOSINC)/Zcmuint.h \
	$(COSMOSINC)/BlockData/cblkObs.h \
	$(COSMOSINC)/Zobs.h \
	$(COSMOSINC)/Zobsp.h \
	$(COSMOSINC)/BlockData/cblkTracking.h \
	$(COSMOSINC)/Ztrackp.h \
	$(COSMOSINC)/BlockData/cblkXsec.h \
	$(COSMOSINC)/Zxsectionp.h \
	$(COSMOSINC)/BlockData/cblkdedx.h \
	$(COSMOSINC)/ZdedxAir.h
$(LIBRARY)(cendRun.o): $(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zprimary.h \
	$(COSMOSINC)/Zprimaryv.h
$(LIBRARY)(cerrorMsg.o): $(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h
$(LIBRARY)(ceventLoop.o): $(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zmanager.h \
	$(COSMOSINC)/Ztrack.h \
	$(COSMOSINC)/Zcondc.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zcoord.h \
	$(COSMOSINC)/Zpos.h \
	$(COSMOSINC)/Zdirec.h \
	$(COSMOSINC)/Zmagfield.h \
	$(COSMOSINC)/Zprimary.h \
	$(COSMOSINC)/Zprimaryv.h
$(LIBRARY)(cmanager.o): $(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Zmaxdef.h
$(LIBRARY)(copenf.o): $(COSMOSINC)/Zreadonly.h
$(LIBRARY)(creadParam.o): $(COSMOSINC)/ZincForNameL.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zheavyp.h \
	$(COSMOSINC)/Zelemagp.h \
	$(COSMOSINC)/Zxsectionp.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zincidentp.h \
	$(COSMOSINC)/Zobs.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zobsp.h \
	$(COSMOSINC)/Ztrackp.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Znamelist.h \
	$(COSMOSINC)/Znamelist1.h \
	$(COSMOSINC)/Znamelist2.h
$(LIBRARY)(cwriteParam.o): $(COSMOSINC)/ZincForNameL.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zheavyp.h \
	$(COSMOSINC)/Zelemagp.h \
	$(COSMOSINC)/Zxsectionp.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zincidentp.h \
	$(COSMOSINC)/Zobs.h \
	$(COSMOSINC)/Zmaxdef.h \
	$(COSMOSINC)/Zobsp.h \
	$(COSMOSINC)/Ztrackp.h \
	$(COSMOSINC)/Zmanagerp.h \
	$(COSMOSINC)/Znamelist.h \
	$(COSMOSINC)/Znamelist1.h \
	$(COSMOSINC)/Znamelist2.h

$(LIBRARY):         \
               $(LIBRARY)(c2lowerCase.o) \
               $(LIBRARY)(cbeginRun.o) \
               $(LIBRARY)(cblkData.o) \
               $(LIBRARY)(cendRun.o) \
               $(LIBRARY)(cerrorMsg.o) \
               $(LIBRARY)(ceventLoop.o) \
               $(LIBRARY)(cgetLoginN.o) \
               $(LIBRARY)(cmanager.o) \
               $(LIBRARY)(copenf.o) \
               $(LIBRARY)(creadParam.o) \
               $(LIBRARY)(cskipComment.o) \
               $(LIBRARY)(cwriteParam.o) 
