GEOM=.
include ${GEOM}/makefiles/Makedefs.global
include Makedefs
include ${GEOM}/makefiles/Makedefs.SUBDIRS

first:	prep all

all ${TARGETS} ${LIB} ${COMMONLIB} ${OBJS}:
	@${DO_DIRS_THIS_MACH}

rm_libs rm_depend:
	@${DO_DIRS}

install:	prep  demand_GEOMROOT
	@${DO_DIRS_THIS_MACH}

installh:
	@${DO_DIRS_THIS_MACH}

clobber:	clean rm_libs rm_depend

depend:
	@if [ -d O.${MACHTYPE} ] ; then				\
	  CC=${CC} ${MKDEP} -f O.${MACHTYPE}/${MKDEPFILE}	\
		-P ../ ${CFLAGS} ${SRCS} ;			\
	fi
	@${DO_DIRS_NO_OBJ}

clean:
	-rm -f ${DIRT}
	@${DO_DIRS}

distclean:
	-rm -f ${DIRT} ${DISTDIRT}
	@${DO_DIRS}

OTHER_DISTFILES_CMD = (echo DISTLIST.all; cat DATAFILES)

prep:
	@mkdir lib lib/${MACHTYPE} \
		bin bin/${MACHTYPE} \
		modules modules/${MACHTYPE} 2>&- || :

# Note: target RFILES takes several minutes to build; this affects
#   both DISTLIST and all.tar.Z


# DISTLIST:	RFILES
# all.tar.Z:	DISTLIST

DISTLIST.sgi:	_always
	-/bin/rm -f $@
	( GEOM=`pwd` ; export GEOM ; $$GEOM/tools/distlist O.sgi ) > $@
	${GEOM}/tools/manlist < $@ >> $@

DISTLIST.next:	_always
	-/bin/rm -f $@
	( GEOM=`pwd` ; export GEOM ; $$GEOM/tools/distlist O.next ) > $@
	${GEOM}/tools/manlist < $@ >> $@

DISTLIST.sun4:	_always
	-/bin/rm -f $@
	( GEOM=`pwd` ; export GEOM ; $$GEOM/tools/distlist O.sun4 ) > $@
	${GEOM}/tools/manlist < $@ >> $@

DISTLIST.all:	_always
	-/bin/rm -f $@
	( GEOM=`pwd` ; export GEOM ; $$GEOM/tools/distlist O.next O.sgi ) > $@
	${GEOM}/tools/manlist < $@ >> $@

DISTLIST.x11:	_always
	-/bin/rm -f $@
	( GEOM=`pwd` ; export GEOM; \
	    cd $$GEOM/src/bin/geomview/x11; \
	       $$GEOM/tools/distlist -p ./Geomview/src/bin/geomview/x11; \
	    cd $$GEOM/src/lib/mg/x11; \
	       $$GEOM/tools/distlist -p ./Geomview/src/lib/mg/x11; \
	) > $@

all.tar.Z:	_always
	-/bin/rm -f $@
	-( ${GEOM}/tools/dist-exceptions \
	      < DISTLIST.all | gnutar -cZ -T -  -f $@ )

x11.tar.Z:	_always
	-/bin/rm -f $@
	-( sort -u DISTLIST.sun4 DISTLIST.x11 DISTLIST.all | \
		egrep -v '/mg/ri/|/gl/|next/' | \
		${GEOM}/tools/dist-exceptions | \
		gnutar -cZ -T - -f $@ )


### BINDISTLIST:	_BINDISTLIST
### 
### _BINDISTLIST:
### 	-/bin/rm -f BINDISTLIST || :
### 	@( cat BINFILES DATAFILES ; \
### 	   egrep '^./man' DISTLIST ) > BINDISTLIST
### 	@( GEOM=`pwd` ; export GEOM ; \
### 	  cd doc ; $$GEOM/tools/distlist -p ./doc O.sgi ) >> BINDISTLIST


tarzan: geomview-only.tar.Z mathooglrib.tar.Z geomstuff.tar.Z 4dview.tar.Z \
	eucsyms.tar.Z hinge.tar.Z trigrp.tar.Z animate.tar.Z linkmover.tar.Z \
	sweep.tar.Z warp.tar.Z flythrough.tar.Z nose.tar.Z corners.tar.Z \
	ginsu.tar.Z tackdown.tar.Z crayola.tar.Z graffiti.tar.Z pssnap.tar.Z \
	transformer.tar.Z geomutil.tar.Z maniview.tar.Z stereo.tar.Z

geomview.tar.Z:	_always
	${GEOM}/tools/makepackage < BINDISTLIST

geomview-only.tar.Z:	_always
	${GEOM}/tools/makepackage geomview-only < BINDISTLIST

mathooglrib.tar.Z:	_always
	${GEOM}/tools/makepackage mathooglrib < BINDISTLIST

geomstuff.tar.Z:	_always
	${GEOM}/tools/makepackage geomstuff < BINDISTLIST

4dview.tar.Z:	_always
	${GEOM}/tools/makepackage 4dview < BINDISTLIST

eucsyms.tar.Z:	_always
	${GEOM}/tools/makepackage eucsyms < BINDISTLIST

hinge.tar.Z:	_always
	${GEOM}/tools/makepackage hinge < BINDISTLIST

trigrp.tar.Z:	_always
	${GEOM}/tools/makepackage trigrp < BINDISTLIST

animate.tar.Z:	_always
	${GEOM}/tools/makepackage animate < BINDISTLIST

linkmover.tar.Z:	_always
	${GEOM}/tools/makepackage linkmover < BINDISTLIST

sweep.tar.Z:	_always
	${GEOM}/tools/makepackage sweep < BINDISTLIST

warp.tar.Z:	_always
	${GEOM}/tools/makepackage warp < BINDISTLIST

flythrough.tar.Z:	_always
	${GEOM}/tools/makepackage flythrough < BINDISTLIST

nose.tar.Z:	_always
	${GEOM}/tools/makepackage nose < BINDISTLIST

corners.tar.Z:	_always
	${GEOM}/tools/makepackage corners < BINDISTLIST

ginsu.tar.Z:	_always
	${GEOM}/tools/makepackage ginsu < BINDISTLIST

tackdown.tar.Z:	_always
	${GEOM}/tools/makepackage tackdown < BINDISTLIST

crayola.tar.Z:	_always
	${GEOM}/tools/makepackage crayola < BINDISTLIST

graffiti.tar.Z:	_always
	${GEOM}/tools/makepackage graffiti < BINDISTLIST

pssnap.tar.Z:	_always
	${GEOM}/tools/makepackage pssnap < BINDISTLIST

transformer.tar.Z:	_always
	${GEOM}/tools/makepackage transformer < BINDISTLIST

maniview.tar.Z:	_always
	${GEOM}/tools/makepackage maniview < BINDISTLIST

geomutil.tar.Z:	_always
	${GEOM}/tools/makepackage geomutil < BINDISTLIST

stellico.tar.Z: _always
	gnutar -c -h -v -Z ./data/geom/stellico/*.off \
			   ./data/geom/stellico/README -f $@

mathooglrib.next.tar.Z:	_always
	${GEOM}/tools/makepackage mathooglrib.next < NEXTDISTLIST

# WARNING: "make bin.tar.Z" does not imply "make all".  But you better
#  be sure that the binary geomview is in bin/${MACHTYPE} !!

bin.tar.Z:	BINDISTLIST
	-/bin/rm -f $@
	tools/dist-geomview BINDISTLIST | gnutar -cvZ -T - -f $@

tree.tar.Z:
	find . \! -type d -print -o -name RCS -prune | \
	  eggrep -v 'O.next|O.sun4|~' | \
	  gnutar -cvZ -T - -f tree.tar.Z

tape:
	find . \! -type d -print -o -name RCS -prune | \
	  eggrep -v 'O.next|O.sun4|~' | \
	  gnutar -cv -b 126 -T - -f /dev/tape

include ${GEOM}/makefiles/Makerules.common
