#
# Makefile redesigned for netgen-1.1
#

NETGENDIR = .
PROGRAMS = netgen netcomp inetcomp ntk2adl

include defs.mak

SRC_DIR = src
INSTALL_CAD_DIRS = lib doc

MAKEFLAGS =

all:
	@${MAKE} mains

tcl:
	@${MAKE} tcllibrary

netgen:	all

force:	clean all

defs.mak:
	@echo No \"defs.mak\" file found.  Run "make config" to make one.

config:
	@${NETGENDIR}/scripts/config

tcllibrary:
	(cd ${SRC_DIR} && ${MAKE} tclnetgen.so)

mains:
	@echo --- making main programs
	(cd ${SRC_DIR} && ${MAKE} module)
	for p in ${PROGRAMS}; do \
		(cd ${SRC_DIR} && ${MAKE} $$p); done

depend:
	(cd ${SRC_DIR} && ${MAKE} depend)

install: install-dirs
	for dir in ${SRC_DIR} ${INSTALL_CAD_DIRS}; do \
		(cd $$dir && ${MAKE} install); done

install-tcl: install-dirs
	for dir in ${SRC_DIR} ${INSTALL_CAD_DIRS}; do \
		(cd $$dir && ${MAKE} install-tcl); done

install-dirs:
	${NETGENDIR}/scripts/mkdirs ${BINDIR} ${MANDIR} ${TCLDIR}

# Note that there is nothing to clean in INSTALL_CAD_DIRS (and no rule for it)
clean:
	for dir in ${SRC_DIR}; do \
		(cd $$dir && ${MAKE} clean); done

veryclean:
	@${MAKE} clean
	${RM} defs.mak old.defs.mak default.conf
	touch defs.mak

clean-mains:
	for p in ${PROGRAMS}; do \
		(cd ${SRC_DIR} && ${RM} $$p); done

