include  $(COSMOSTOP)/site.config


EXTHDRS	      = $(COSMOSINC)/Zcode.h \
		$(COSMOSINC)/Zheavyp.h \
		$(COSMOSINC)/Zmass.h \
		$(COSMOSINC)/Zptcl.h \
		$(COSMOSINC)/ZsaveStruc.h \
		$(COSMOSINC)/Zunionmap.h

HDRS	      =


MAKEFILE      = Makefile

OBJS	      = c2bdcy.o \
		cadjm.o \
		cbst0.o \
		cbst1.o \
		cgeqm.o \
		cgetRotMat4.o \
		cgetcm.o \
		cgetlf.o \
		cibst1.o \
		cloreb.o \
		clorep.o \
		clorez.o \
		cmkptc.o \
		cnbdcy.o \
		cpm2e.o \
		cpxyzp.o \
		crot3mom.o \
		crot3vec.o \
		ctestOnShell.o \
		cyeta.o

PRINT	      = pr

SHELL	      = /bin/sh

SRCS	      = c2bdcy.f \
		cadjm.f \
		cbst0.f \
		cbst1.f \
		cgeqm.f \
		cgetRotMat4.f \
		cgetcm.f \
		cgetlf.f \
		cibst1.f \
		cloreb.f \
		clorep.f \
		clorez.f \
		cmkptc.f \
		cnbdcy.f \
		cpm2e.f \
		cpxyzp.f \
		crot3mom.f \
		crot3vec.f \
		ctestOnShell.f \
		cyeta.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)(c2bdcy.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cadjm.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cbst0.o): $(COSMOSINC)/ZsaveStruc.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cbst1.o): $(COSMOSINC)/ZsaveStruc.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cgeqm.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cgetRotMat4.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cgetcm.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cgetlf.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cibst1.o): $(COSMOSINC)/ZsaveStruc.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cloreb.o): $(COSMOSINC)/ZsaveStruc.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(clorep.o): $(COSMOSINC)/ZsaveStruc.h \
	$(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(clorez.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cmkptc.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zmass.h \
	$(COSMOSINC)/Zheavyp.h
$(LIBRARY)(cnbdcy.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cpm2e.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cpxyzp.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(crot3mom.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(crot3vec.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(ctestOnShell.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(cyeta.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h

$(LIBRARY):         \
               $(LIBRARY)(c2bdcy.o) \
               $(LIBRARY)(cadjm.o) \
               $(LIBRARY)(cbst0.o) \
               $(LIBRARY)(cbst1.o) \
               $(LIBRARY)(cgeqm.o) \
               $(LIBRARY)(cgetRotMat4.o) \
               $(LIBRARY)(cgetcm.o) \
               $(LIBRARY)(cgetlf.o) \
               $(LIBRARY)(cibst1.o) \
               $(LIBRARY)(cloreb.o) \
               $(LIBRARY)(clorep.o) \
               $(LIBRARY)(clorez.o) \
               $(LIBRARY)(cmkptc.o) \
               $(LIBRARY)(cnbdcy.o) \
               $(LIBRARY)(cpm2e.o) \
               $(LIBRARY)(cpxyzp.o) \
               $(LIBRARY)(crot3mom.o) \
               $(LIBRARY)(crot3vec.o) \
               $(LIBRARY)(ctestOnShell.o) \
               $(LIBRARY)(cyeta.o) 
