#! /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 -b i486-linuxaout"
# 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 -b i486-linuxaout"
FINAL_MAKE_COMMAND= $(MAKE) -j 2 CDEBUGFLAGS="-Wall -O2 -i486" EXTRA_LDOPTIONS=-L/usr/X11/lib TCL_HOME=../lib/tcl7.4
# FINAL_MAKE_COMMAND= $(MAKE)


### if you want to build multiple version of wafe or mofe, use the
### the first definition of CLEAN_BETWEEN_VERSION_COMPILES

#LEAN_BETWEEN_VERSION_COMPILES = rm -f *.o
CLEAN_BETWEEN_VERSION_COMPILES = 


### various versions, that can be build ##############################

athena: fullwafe
motif: fullmofe

allmofes: minimofe static_mofe fullmofe
allwafes: miniwafe microwafe fullwafe 
everything: allmofes allwafes 

### now the details ##################################################
############################ Athena versions #########################

fullwafe: wafe_built std_wafe_built TOPMAKE
	$(CLEAN_BETWEEN_VERSION_COMPILES)
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DATHENA \
		-DDEBUG \
		-DOTCL \
		-DXPM \
		-DXAW3D \
		-DLAYOUT \
		-DPLOTTER \
		-DRDD \
		-DHTML \
		-DCLOCK \
		-DGHOSTVIEW 
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND)

miniwafe: wafe_built non_std_wafe_built TOPMAKE
	$(CLEAN_BETWEEN_VERSION_COMPILES)
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DATHENA \
		-DXAW3D \
		-DXPM 
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND)
	mv wafe $@

microwafe: wafe_built non_std_wafe_built TOPMAKE
	$(CLEAN_BETWEEN_VERSION_COMPILES)
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DATHENA
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND)
	mv wafe $@

############################ MOTIF versions #########################

fullmofe: mofe_built std_mofe_built TOPMAKE
	$(CLEAN_BETWEEN_VERSION_COMPILES)
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DMOTIF \
		-DDEBUG \
		-DOTCL \
		-DXPM \
		-DLAYOUT \
		-DPLOTTER \
		-DXMGRAPH \
		-DMTREE \
		-DRDD \
		-DHTML \
		-DXEW \
		-DXBAE \
		-DCLOCK \
		-DGHOSTVIEW 
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND)

minimofe: mofe_built non_std_mofe_built TOPMAKE
	$(CLEAN_BETWEEN_VERSION_COMPILES)
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DXPM \
		-DMOTIF
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND)
	mv mofe $@

static_mofe: mofe_built std_mofe_built  TOPMAKE
	$(CLEAN_BETWEEN_VERSION_COMPILES)
	`$(XMKMF) | tail -1` \
		-DCONFIGURATION_VIA_CMDLINE \
		-DMOTIF \
		-DDEBUG \
		-DOTCL \
		-DXPM \
		-DLAYOUT \
		-DPLOTTER \
		-DMTREE \
		-DXMGRAPH \
		-DXBAE \
		-DRDD \
		-DHTML \
		-DXEW \
		-DCLOCK \
		-DGHOSTVIEW 
	$(MAKE) c_code
	$(FINAL_MAKE_COMMAND) XMLIB=/usr/X11/lib/libXm.a
	#$(FINAL_MAKE_COMMAND) XMLIB=/usr/i486-linuxaout/lib/libXm.a
	# SYS_LIBRARIES=/u/neumann/import/regex-0.12/regex.o
	mv mofe $@

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

non_std_mofe_built:
	rm -f *.o std_mofe_built
	touch $@

std_mofe_built:
	rm -f *.o non_std_mofe_built
	touch $@




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

std_wafe_built:
	rm -f *.o non_std_wafe_built
	touch $@

non_std_wafe_built:
	rm -f *.o std_wafe_built
	touch $@
