############################################################################
#** interpcom-3.1   (command interpreter)                                 **
#** test programs for the interpcom library : makefile                    **
#**                                                                       **
#** Copyright (C) 2003  Jean-Marc Drezet                                  **
#**                                                                       **
#**  This library is free software; you can redistribute it and/or        **
#**  modify it under the terms of the GNU Library General Public          **
#**  License as published by the Free Software Foundation; either         **
#**  version 2 of the License, or (at your option) any later version.     **
#**									  **
#**  This library is distributed in the hope that it will be useful,      **
#**  but WITHOUT ANY WARRANTY; without even the implied warranty of       **
#**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    **
#**  Library General Public License for more details. 			  **
#**									  **
#**  You should have received a copy of the GNU Library General Public    **
#**  License along with this library; if not, write to the Free		  **
#**  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   **
#**                                                                       **
#** Please mail any bug reports/fixes/enhancements to me at:              **
#**      drezet@math.jussieu.fr                                           **
#** or                                                                    **
#**      Jean-Marc Drezet                                                 **
#**      Institut de Mathematiques                                        **
#**      UMR 7586 du CNRS                                                 **
#**      173, rue du Chevaleret                                           **
#**      75013 Paris                                                      **
#**      France			 					  **
#**                                                                       **
############################################################################

# : test_dumm test_mapm test_GMP test_matrix test_all

#---------------------------------------------------------------------------
# optimization
#---------------------------------------------------------------------------
#export _OPTIM= -O6 -funroll-loops -malign-double 

# optimization for gcc-3.0.2
#export _OPTIM= -O6 -funroll-loops -minline-all-stringops -fomit-frame-pointer -fno-schedule-insns -fschedule-insns2 -malign-double -fstrict-aliasing -mcpu=pentiumpro


# optimization for gcc-2.95.3
export _OPTIM= -O6 -funroll-loops -fomit-frame-pointer -fno-schedule-insns -fschedule-insns2 -malign-double -fstrict-aliasing -mcpu=pentiumpro
#
#export CC=/d2/gcc-3.0.2/bin/gcc -B/d2/gcc-3.0.2/lib/gcc-lib/i686-pc-linux-gnu/3.0.2/
export CC=gcc

# no optimization
#export _OPTIM = -g
#---------------------------------------------------------------------------



#---------------------------------------------------------------------------
# language
#---------------------------------------------------------------------------
# english
export _LANG= -D_ENG_LANG

# french
# export _LANG= 
#---------------------------------------------------------------------------



#---------------------------------------------------------------------------
# command line editing library
#---------------------------------------------------------------------------
# GNU readline library
export LINE_ED= -D__WITH_READLINE
export LINE_ED_LIBS= -lhistory -lreadline -ltermcap

# libtecla  library
#   export LINE_ED= -D__WITH_LIBTECLA
#   export LINE_ED_LIBS= -ltecla

# no command line editing library
#   export LINE_ED= 
#   export LINE_ED_LIBS= 
#---------------------------------------------------------------------------



export CFLAGS= -Wall $(_LANG) $(_OPTIM) $(LINE_ED)
export LIBS= -lpthread $(LINE_ED_LIBS)


init : 
	@echo
	@echo Options for make :
	@echo "        "   dummy          "   " : application including a new expression evaluator
	@echo "                     "identical to the usual one
	@echo "        "   mapm          "    " : application including a new expression evaluator using the
	@echo "                     "mapm library
	@echo "        "   GMP    "     " : application including a new expression evaluator using the
	@echo "                     "GMP library
	@echo "        "   matrix    "  " : application including a new expression evaluator using
	@echo "                     "2x2 matrices
	@echo "        "   all          "     " : application including all the preceeding
	@echo "                     "new expression evaluators
	
dummy : test_dumm

mapm : test_mapm

GMP : test_GMP

matrix : test_matrix

all : test_all
	
main_dumm.o : main_dumm.c
	$(CC) -c main_dumm.c $(CFLAGS) -I../.. -o main_dumm.o

main_mapm.o : main_mapm.c
	$(CC) -c main_mapm.c $(CFLAGS) -I../.. -o main_mapm.o

main_GMP.o : main_GMP.c
	$(CC) -c main_GMP.c $(CFLAGS) -I../.. -o main_GMP.o

main_matrix.o : main_GMP.c
	$(CC) -c main_matrix.c $(CFLAGS) -I../.. -o main_matrix.o

test_dumm : ../../libinter.a ../../expr_evals/_dummy.o main_dumm.o
	$(CC) ../../expr_evals/_dummy.o main_dumm.o ../../libinter.a -lm $(LIBS) -o test_dumm

../../expr_evals/_dummy.o : 
	cd ../../expr_evals; $(MAKE) dummy

test_mapm : ../../libinter.a ../../expr_evals/_mapm.o main_mapm.o
	$(CC) ../../expr_evals/_mapm.o main_mapm.o ../../libinter.a -lmapm -lm \
$(LIBS) -o test_mapm

test_GMP : ../../libinter.a ../../expr_evals/_GMP.o main_GMP.o
	$(CC) ../../expr_evals/_GMP.o main_GMP.o ../../libinter.a -lgmp -lm \
$(LIBS) -o test_GMP

test_matrix : ../../libinter.a ../../expr_evals/_matrix.o main_matrix.o
	$(CC) ../../expr_evals/_matrix.o main_matrix.o ../../libinter.a -lm \
$(LIBS) -o test_matrix

test_all : ../../libinter.a ../../expr_evals/_dummy.o ../../expr_evals/_matrix.o ../../expr_evals/_mapm.o ../../expr_evals/_GMP.o main_all.o
	$(CC) ../../expr_evals/_dummy.o ../../expr_evals/_mapm.o ../../expr_evals/_matrix.o\
../../expr_evals/_GMP.o main_all.o ../../libinter.a -lmapm -lgmp -lm $(LIBS) -o test_all

../../expr_evals/_mapm.o : 
	cd ../../expr_evals; $(MAKE) mapm

../../expr_evals/_GMP.o : 
	cd ../../expr_evals; $(MAKE) GMP

../../expr_evals/_matrix.o : 
	cd ../../expr_evals; $(MAKE) matrix

clean-all :
	rm -f *.o *bck *% *~ int_ini.c *txt *out test_dumm\
test_mapm *_nothr test_GMP test_all test_matrix
	cd ../../expr_evals; $(MAKE) clean

clean :
	rm -f *.o *bck *% *~ int_ini.c *txt *out
	cd ../../expr_evals; $(MAKE) clean

