#! /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 you 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\"

FINAL_MAKE_COMMAND= $(MAKE) -j 2 -l 2.0
# FINAL_MAKE_COMMAND= $(MAKE) -j 2 -l 2.0 CDEBUGFLAGS=-Wall
# FINAL_MAKE_COMMAND= $(MAKE)

# ... and now the dependcies

athena: wafe_built
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DATHENA \
		-DDEBUG \
		-DXPM \
		-DXAW3D \
		-DLAYOUT \
		-DPLOTTER \
		-DXMGRAPH \
		-DRDD \
		-DHTML 
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND)

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

motif_static: mofe_built
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DMOTIF \
		-DDEBUG \
		-DXPM \
		-DXAW3D \
		-DPLOTTER \
		-DXMGRAPH \
		-DGHOSTVIEW \
		-DRDD \
		-DHTML
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND) XMLIB=/usr/lib/libXm.a

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

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