############################################################
LIBS	= -lm -llapack -lblas


############################################################
# YOU DO NOT NEED TO CHANGE THE LINES BELOW
############################################################
SYSHOME := $(shell cd ../..; /bin/pwd)
include $(SYSHOME)/src/Rules.make


############################################################
EXE         = $(ANIBIN)/TestAPP.exe

LIBAFT	    = $(ANILIB)/libaft2D-$(version).a 
LIBFEM	    = $(ANILIB)/libfem2D-$(version).a 
LIBANI	    = $(ANILIB)/libani2D-$(version).a 
LIBLU 	    = $(ANILIB)/liblu.a 



OBJ         = main.o graph.o forlibfem.o forlibani.o forlibaft.o 

INCLUDE     = -I$(ANIFEM)

############################################################
all: 	    help

exe: 	    $(EXE) info

run:
	    cd $(ANIBIN) &&  $(EXE)

clean: 
	    @/bin/rm -f *.o  *~ $(ANIBIN)/*.ps $(ANIBIN)/*.exe  

help:
	    @echo "make {exe|run|clean|help|gs}"
	    @echo " "
	    @echo " Compile options:"
	    @echo "     exe - compile the code and link with libaft2D.a"
	    @echo " "
	    @echo " Execute options:"
	    @echo "     run - run code with given boundary"
	    @echo " "
	    @echo " Misceleneous options:"
	    @echo "     gs     - draw the mesh (bin/aft.ps) and solution (bin/iso.ps)"
	    @echo "     clean  - clean the package"
	    @echo "     help   - print this message"
	    @echo " "

info:
	    @echo " "
	    @echo "Executable files are located in   ani2D/bin"
	    @echo "Library files are located in      ani2D/lib"
	    @echo "Postscript figures are located in ani2D/bin"
	    @echo " "

gs:
	    @echo " "
	    @echo "Postscript figures:"
	    @echo "   1. initial mesh"
	    @echo "   2. isolines of the corresponing solution"
	    @echo "   3. final (adapted) mesh"
	    @echo "   4. isolines of the corresponing solution"
	    @echo " "
	    cd $(ANIBIN); gv aft.ps; gv iso.ps; gv hba.ps; gv his.ps




############################################################
$(EXE): $(OBJ) 
	@echo ''
	@echo 'Creating executable bin/Test.exe' 
	@$(FLINKER) $(LDFLAGS) -o $(EXE) $(OBJ) $(LIBAFT) $(LIBFEM) $(LIBANI) $(LIBLU) $(LIBS)
	@echo ''


############################################################
main.o      : main.f  
forlibaft.o : forlibaft.c
forlibfem.o : forlibfem.f
forlibani.o : forlibani.f
graph.o     : graph.f   



############################################################
.f.o:
	@echo $(F77)' -c $(FFLAGS) ' $*.f 
	@$(F77) $(FFLAGS) -c $*.f -o $*.o $(INCLUDE)
.c.o:
	@echo $(CC)'  -c $(CFLAGS) ' $*.c 
	@$(CC)  $(CFLAGS) -c $*.c -o $*.o 

