
default: all

include makefile.include

subdirs = measures zipcodes google usgs

all install: FORCE
	for dir in $(subdirs); do (cd $$dir; $(MAKE) $@); done

clean: FORCE
	rm -f *.fasl source.tgz
	for dir in $(subdirs); do (cd $$dir; $(MAKE) $@); done

cvsdiff: FORCE
	for dir in $(subdirs); do (cd $$dir; cvs diff); done

TMPROOT = /tmp/copysourcetmp
TMPDIR  = /tmp/copysourcetmp/usgs

STATIC_ROOT_SOURCE_FILES = Makefile makefile.include .clinit.cl

USGS_TGZ = usgs-1.0.tar.gz
USGS_ZIP = usgs-1.0.zip

source: $(USGS_TGZ)

usgs.tgz usgs.zip $(USGS_TGZ): FORCE
	rm -rf $(USGS_TGZ) $(TMPROOT)
	mkdir -p $(TMPDIR)
	@for dir in $(subdirs); do \
		(cd $$dir; \
		 $(MAKE) ROOT=$(TMPDIR) SOURCE_DEST=$(TMPDIR)/$$dir \
		 	 copysource); \
	done
	cp -p $(STATIC_ROOT_SOURCE_FILES) $(TMPDIR)
	cp -p README.ROOT $(TMPDIR)/readme.txt
	tar zcf $(USGS_TGZ) -C $(TMPROOT) .
	cd $(TMPROOT) && find usgs -type f -print | xargs zip -9 -@ usgs.zip
	mv $(TMPROOT)/usgs.zip $(USGS_ZIP)
	rm -fr $(TMPROOT)

FORCE:
