include  $(COSMOSTOP)/site.config


EXTHDRS	      = $(COSMOSINC)/Zcinippxc.h \
		$(COSMOSINC)/Zcode.h \
		$(COSMOSINC)/Zevhnp.h \
		$(COSMOSINC)/Zevhnv.h \
		$(COSMOSINC)/Zmass.h \
		$(COSMOSINC)/Zptcl.h \
		$(COSMOSINC)/Zunionmap.h

HDRS	      =


MAKEFILE      = Makefile

OBJS	      = cconsvChg.o \
		cgnlp.o \
		cgrap.o \
		chncol.o \
		cinipipx.o \
		cinippx.o \
		cs2lp.o \
		csampPolAng.o \
		csnchp.o \
		csptxy.o \
		cspwpt.o

PRINT	      = pr

SHELL	      = /bin/sh

SRCS	      = cconsvChg.f \
		cgnlp.f \
		cgrap.f \
		chncol.f \
		cinipipx.f \
		cinippx.f \
		cs2lp.f \
		csampPolAng.f \
		csnchp.f \
		csptxy.f \
		cspwpt.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)(cconsvChg.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zcode.h
$(LIBRARY)(cgnlp.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zmass.h \
	$(COSMOSINC)/Zevhnv.h \
	$(COSMOSINC)/Zevhnp.h \
	$(COSMOSINC)/Zcode.h
$(LIBRARY)(cgrap.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h
$(LIBRARY)(chncol.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zevhnv.h \
	$(COSMOSINC)/Zcode.h
$(LIBRARY)(cinipipx.o): $(COSMOSINC)/Zcinippxc.h
$(LIBRARY)(cinippx.o): $(COSMOSINC)/Zcinippxc.h
$(LIBRARY)(cs2lp.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zmass.h \
	$(COSMOSINC)/Zevhnv.h \
	$(COSMOSINC)/Zcinippxc.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zevhnp.h
$(LIBRARY)(csnchp.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h \
	$(COSMOSINC)/Zmass.h \
	$(COSMOSINC)/Zevhnv.h \
	$(COSMOSINC)/Zcode.h \
	$(COSMOSINC)/Zevhnp.h
$(LIBRARY)(csptxy.o): $(COSMOSINC)/Zptcl.h \
	$(COSMOSINC)/Zunionmap.h

$(LIBRARY):         \
               $(LIBRARY)(cconsvChg.o) \
               $(LIBRARY)(cgnlp.o) \
               $(LIBRARY)(cgrap.o) \
               $(LIBRARY)(chncol.o) \
               $(LIBRARY)(cinipipx.o) \
               $(LIBRARY)(cinippx.o) \
               $(LIBRARY)(cs2lp.o) \
               $(LIBRARY)(csampPolAng.o) \
               $(LIBRARY)(csnchp.o) \
               $(LIBRARY)(csptxy.o) \
               $(LIBRARY)(cspwpt.o) 
