#
# This make file is the main make file of the IRIT solid modeller and its
# auxilary tools, under UNIX.
#
# Do the following before run make:
#
# 1. Edit 'makeflag.unx' for the exact path names to be used for libraries and
#    binaries. Set the proper C compiler and graphics library flags in
#    makeflag.unx as well.
# 2. The libgif.a is not provided here. See the documentation on how to get
#    it. Without it poly3d-r cannot be build.
#    The make files are set as if libgif.a IS NOT PROVIDED.
#
#				Gershon Elber, Nov. 1991
#

include makeflag.unx

#
# All subdirectories to recurse into.
#
ALL_DIRS = misc_lib cagd_lib prsr_lib geom_lib \
	grapdrvs irit poly3d-h illustrt iritfltr docs # poly3d-r

#
# Uncommend the following variable to only see the actions taken.
#
# VIEW_ONLY = -n

SHELL = /bin/sh

all: 	binaries doc init

#
# Print info regarding initialization.
#
init:
	-for f in "" \
		  "Before executing the test suite and/or any usage of this" \
		  "package you will have to issue the following commands:" \
		  "" \
		  "set path = (\$$path $(BIN_DIR))" \
		  "setenv IRIT_PATH $(BIN_DIR)/" \
		  "setenv IRIT_DISPLAY \"x11drvs -s-\"" \
		  "" \
		  "and optionally the following commands:" \
		  "" \
		  "setenv IRIT_BIN_IPC 1" \
		  "setenv IRIT_SERVER_HOST `hostname`" \
		  "setenv IRIT_SERVER_PORT 5432" \
		  "" \
		  "or similar."; do \
		(echo $$f) \
	done

binaries:
	-for f in $(ALL_DIRS); do \
		(cd $$f \
		 && echo ----------- `pwd` ------------- \
		 && make $(VIEW_ONLY) -f makefile.unx install); \
	done
	-strip $(BIN_DIR)/*

#
# Make hardcopy documentation.
#
doc:
	(cd docs && \
	 make $(VIEW_ONLY) -f makefile.unx irit.tex irit.doc)

clean:
	-rm .~* .\#*			# Emacs backup files.
	-for f in $(ALL_DIRS); do \
		(rm $$f/*.a $$f/*.o $$f/*mon.out $$f/.~* $$f/.\#* $$f/*mon.out); \
	done
	-rm poly3d-r/*.gif
	-rm poly3d-h/*.hdn
	-rm irit/*.dat
	-rm lib/*.a
	-rm docs/irithlp docs/irithlp.o

#
# Test some of the above programs. Make sure $(BIN_DIR) is in your path
# and that IRIT_LCLDISP is set ('setenv IRIT_LCLDISP x11drvs').
#
test:
	-(cd irit && irit demo)
	-for f in poly3d-h illustrt iritfltr; do \
		(cd $$f && csh -f test-unx); \
	done
