#! /usr/bin/make -f
#
# If various versions of Wafe are built with various packages
# compiled, one might find this makefile useful, which can be
# used "on top" of the usual xmkmf. You might want to add other
# definitions here...
#
#     make -f MAKEFILE athena
#     make -f MAKEFILE motif

# If various instances of the X tree are installed, choose the
# "right" one with the appropriate xmkmf
XMKMF = xmkmf

# If Gnu Make is installed, try the following options to speed up compilation
# time. The parameter after -j is the max number of jobs that can be run
# in parallel, the parameter after -j is the maximum load permitted
# On my Linux system the following parameter lead to faster compiles
# than with the plain make (no big difference however, but your mileage might
# vary). 
#
# The C code has to be generated sequentially, since it writes
# and reads context information from a textfile (callback.perl), which
# might be partially overwritten under by parallel make executions
#
# Note that it is also possible to override definitions of Makefile
# variables by adding these in form VAR=VALUE to the make command below
# eg.  WAFELIB=\"/GoodStuff/lib/wafe\"
#
# Note further, that one can specify compiler or loader flags in the file
# in this directory in the file site.def. this file might contain e.g. 
# the line "#define ExtraLoadFlags -Wl,-qmagic"
#

# FINAL_MAKE_COMMAND= $(MAKE) -j 2 -l 2.0 CDEBUGFLAGS="-g -Wall"
# FINAL_MAKE_COMMAND= $(MAKE) -j 2 -l 2.0 CDEBUGFLAGS="-Wall -Wconversion -O2"
# FINAL_MAKE_COMMAND= $(MAKE) -j 2 -l 2.0 CDEBUGFLAGS="-Wall -Wshadow -O2"
 FINAL_MAKE_COMMAND= $(MAKE) -j 2 -l 2.0 CDEBUGFLAGS="-Wall -O2"
# FINAL_MAKE_COMMAND= $(MAKE)

# ... and now the dependcies

athena: wafe_built
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DATHENA \
		-DDEBUG \
		-DXPM \
		-DXAW3D \
		-DLAYOUT \
		-DPLOTTER \
		-DRDD \
		-DHTML
	$(MAKE) c_code
	#$(FINAL_MAKE_COMMAND)
	$(FINAL_MAKE_COMMAND) XAW3D_HOME=/u/neumann/import/kaleb/Xaw3d

motif: mofe_built
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DMOTIF \
		-DDEBUG \
		-DXPM \
		-DLAYOUT \
		-DPLOTTER \
		-DXMGRAPH \
		-DMTREE \
		-DRDD \
		-DHTML 
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND)

#		-DBUILD_TCL TCL_HOME=/u/neumann/import/tcl7.4b2
#	$(MAKE) c_code
#	$(FINAL_MAKE_COMMAND) TCL_HOME=/u/neumann/import/tcl7.4b2

mmotif: mofe_built
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DMOTIF \
		-DDEBUG 
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND)

motif_static: mofe_built
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DMOTIF \
		-DDEBUG \
		-DXPM \
		-DLAYOUT \
		-DPLOTTER \
		-DMTREE \
		-DXMGRAPH \
		-DXBAE \
		-DGHOSTVIEW \
		-DRDD \
		-DHTML
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND) XMLIB=/usr/lib/libXm.a \
		SYS_LIBRARIES=/u/neumann/import/regex-0.12/regex.o

wafe_built:
	$(MAKE) clean_version
	rm -f mofe_built
	touch $@

mofe_built:
	$(MAKE) clean_version
	rm -f wafe_built
	touch $@
