# Makefile for gtool4
# vi: set ts=8 sw=4:

all:
	cd src; $(MAKE)
	cd gtlist; $(MAKE)
	cd gtcopy; $(MAKE)
	cd gtview; $(MAKE)
	cd gtattr; $(MAKE)
	cd gtprint; $(MAKE)
	cd gtunary; $(MAKE)
	cd gtbinary; $(MAKE)
	cd f90grep; $(MAKE)
	cd gt4frt; $(MAKE)
	cd gtavg; $(MAKE)

install: all
	cd src; $(MAKE) $@
	cd gtavg; $(MAKE) $@
	cd gtlist; $(MAKE) $@
	cd gtcopy; $(MAKE) $@
	cd gtview; $(MAKE) $@ gtool.nc
	cd gtattr; $(MAKE) $@
	cd gtprint; $(MAKE) $@
	cd gtunary; $(MAKE) $@
	cd gtbinary; $(MAKE) $@
	cd f90grep; $(MAKE) $@
	cd gt4frt; $(MAKE) $@

install-doc:
	cd doc ; $(MAKE) install

clean:
	cd src; $(MAKE) $@
	cd gtavg; $(MAKE) $@
	cd gtlist; $(MAKE) $@
	cd gtcopy; $(MAKE) $@
	cd gtview; $(MAKE) $@
	cd gtattr; $(MAKE) $@
	cd gtprint; $(MAKE) $@
	cd gtunary; $(MAKE) $@
	cd gtbinary; $(MAKE) $@
	cd f90grep; $(MAKE) $@
	cd gt4frt; $(MAKE) $@
	cd test; $(MAKE) $@

distclean: clean
	-rm -f config.status chkfort.cfg config.cache config.log Config.mk
	@echo removing Config.mk, you should rerun configure to build gtool4.

test-f: all
	cd test; $(MAKE) $@

test: all
	cd test; $(MAKE) $@

tags:
	perl src/f90tags src/*.f90

SUBMF = gtlist/Makefile gtcopy/Makefile gtattr/Makefile \
	gtprint/Makefile gtunary/Makefile gtbinary/Makefile gtavg/Makefile \
	f90grep/Makefile

submf: $(SUBMF)

$(SUBMF): gtview/Makefile
	for path in $(SUBMF) ;\
	do \
		dir=`dirname $$path` ;\
		sed s/gtview/$$dir/g gtview/Makefile > $$path ;\
	done
