
# Compiler name
F77    = g77
INCLUDE_DIR = -I. -I/usr/include
LIB_DIR = . 
#LIBS = -llammpi++ -llammpio -lpmpi -llamf77mpi -lmpi -llam -lnsl 


#*******************************************************************

PGM    = EvalFn
OBJS   = $(PGM).o \
         location_constraint.o linear_constraint.o\
         head_constraint.o\
	 costac.o costao.o\
         feval.o writewel.o readhead.o

OBJS1   = $(PGM).o \
          location_constraint.o linear_constraint.o\
          postproc.o head_constraint.o\
	  costac.o costao.o writemfn.o\
          feval.o writewel.o readhead.o

# Default location to link executables on installation
BINDIR = /home/gagray/apps-community
BDir   = /home/gagray/apps-community
EXE    = $(BDir)/evalHC
BIN    = $(BINDIR)/$(PGM)

# Rules
all: chkdir $(EXE) install
	@echo; echo Done making all, files are now up-to-date.

$(EXE): $(OBJS)
	@echo
	$(F77) $(INCLUDE_DIR) $(FFLAGS) $(OBJS)  -L$(LIB_DIR) $(LIBS) -o $@
#	strip $@

chkdir:
# Create ../bin directory, if necessary
	@if [ ! -d $(BDir) ]; then \
		mkdir $(BDir); echo Created directory $(BDir); fi

install:
# Create directory for binary, if necessary
	@if [ ! -d $(BINDIR) ]; then \
		mkdir $(BINDIR); echo Created directory $(BINDIR); fi
# Link executable to BINDIR
	@if [ ! -s $(EXE) ]; then \
		echo Executable $(EXE) does not exist,; \
		echo use one of the following commands to generate it:; \
		echo "      make"; echo "      make all"; \
	else \
		if [ $(BINDIR) != $(BDir) ]; then \
			rm -f $(BIN); \
			cd ..; ln -s `pwd`/bin/$(PGM) $(BIN); \
			echo; echo Executable $(BIN) has been updated.; \
			echo; echo Be sure directory $(BINDIR) is in your PATH.; \
		else \
			cd $(BDir); echo; echo Be sure directory `pwd` is in your PATH.; \
		fi; \
	fi
clean:
	@if [ $(BINDIR) != $(BDir) ]; \
		then rm -f $(BIN); \
	fi
	rm -f $(EXE) *.o *%
	@echo; echo Removed files generated by make.

.f.o:
	$(F77) $(INCLUDE_DIR) $(FFLAGS) $(PG) -c $<

