GEOM = ../../../../..
include ${GEOM}/makefiles/Makedefs.global
include ../Makedefs
include ../../common/Makedefs.common
include ${GEOM}/makefiles/Makerules.obj

MORECOPTS = -Wf,-XNl4096

MALLOCLIB = -lmalloc
#MALLOCLIB = -lmallocdebug

FORMSLIBS = -lforms -lfm_s

OOGLLIBS = -L${LIBDIR} -lmg -lcamera -lwindow \
	   -lgeom -lquad -lpolylist -lvect -lbezier -lmesh -lvect \
	   -lsphere -linst -ltlist -llist -ldg -lcomment -lbbox \
	   -lstub -lgeom -lshade -loogl -l3d -lcolor


L = ${GEOM}/lib/sgi
LIBDEPS = ${L}/libforms.a \
	${L}/libmg.a ${L}/libcamera.a ${L}/libcomment.a \
	${L}/libgeom.a ${L}/libquad.a ${L}/libpolylist.a ${L}/libvect.a \
	${L}/libbezier.a ${L}/libmesh.a ${L}/libvect.a ${L}/libdg.a \
	${L}/libstub.a \
	${L}/libshade.a ${L}/liboogl.a ${L}/lib3d.a ${L}/libcolor.a

../common/clang.c ../common/clang.h:
	cd ../../common ; ${MAKE} clang.c

_panelstuff:	../panel.c ../panel.h

# only check on the following if we're at the Geometry Center; 
#  --- assume that if /u/gcg exists, then we're there !!

panel.c: ../panel.c
panel.h: ../panel.h

# Need to cp rather than ln here to ensure that, after executing,
# panel.? is really newer than ../panel.?

panel.c panel.h:
	rm -f $@
	cp ../$@ .

glui.o: panel.c panel.h

#../panel.c ../panel.h:	../panel.fd
#	@if [ -d /u/gcg/ ] ; then \
#	  echo "" ; \
#	  echo " WARNING " ; \
#	  echo "" ; \
#	  echo "    panel.fd has been modified more recently than" ; \
#	  echo "    panel.c and/or panel.h.  You need to run fdesign2" ; \
#	  echo "    to regenerate panel.c and panel.h" ; \
#	  echo "" ; \
#	fi

install:	install_bin

#
# NOTE: gvx gets installed into ${GEOM}/bin/${MACHTYPE}, *not*
#   ${BINDIR} !!  This is because the "geomview" shell script needs to
#   be able to find it, and it knows the Geomview root dir location,
#   but not the ${BINDIR} location.
#
install_bin:	gvx
	${INSTALL} -O -v -F ${GEOM}/bin/${MACHTYPE} gvx
	( cd ${GEOM}/bin/${MACHTYPE} ; chmod 775 gvx )

${GEOM}/lib/sgi/libforms.a:
	cd ${GEOM}/src/lib/forms ; ${MAKE} install

${COMMON_OBJS} :
	rm -f $@ ${@:o=c}
	ln ../../common/${@:o=c} .
	${CC} -I../../common -I.. -DRMAN ${CFLAGS} -c ${@:o=c}

gvx:	${COMMON_OBJS} ${OBJS} ${LIBDEPS}
	rm -f gvx ../gvx
	(echo 'char builddate[] = "'"`date +%y%m%d%H%M`"'";'; \
	 echo 'char buildinfo1[] = "'"  By `whoami`@`hostname`[`uname -r`]"'";'; \
	 echo 'char buildinfo2[] = "'"  On `date`"'";'; \
	) > buildinfo.c
	$(CC) -g ${MORECOPTS} -o $@ ${COMMON_OBJS} ${OBJS} buildinfo.c \
	  ${OOGLLIBS} \
	  ${FORMSLIBS} \
	  ${MALLOCLIB} -lgl_s -lm -lc_s
	ln gvx ..
