#
# This make file is the main make file of the IRIT solid modeller and its
# auxilary tools, under UNIX.
#
#				Gershon Elber, Nov. 1991
#

include makeflag.unx

#
# All subdirectories to recurse into.
#
ALL_DIRS = xtra_lib misc_lib cagd_lib symb_lib triv_lib trim_lib \
	trng_lib user_lib prsr_lib geom_lib bool_lib circlink \
	grapdrvs irit poly3d-h irender illustrt filters docs

#
# 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-\"" \
		  "" \
		  "	if shared library are used then" \
		  "" \
		  "setenv LD_LIBRARY_PATH $(LD_LIBRARY_PATH):$(LIB_DIR)" \
		  "" \
		  "	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-h/*.hdn
	-rm irender/*.rle
	-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 irender illustrt filters; do \
		(cd $$f && csh -f test-unx); \
	done

depend:
	-for f in $(ALL_DIRS); do \
		(cd $$f && makedepend -Y -I../include -fmakefile.unx *.c \
			&& makedepend -Y -I../include -fmakefile.os2 *.c ) \
	done
