#=======================================
# MODPALEO - Makefile
#=======================================
#
# Lixiang Luo, 5-May-2011
# lixiang.luo@lehigh.edu
# Department of Physics, Lehigh University
#
# You need to change the environment variables MMMFC and FFLAGS according
# to your compiler requirements.
#
# Default target is testpaleo, which doesn't include debug info.
# To build default target:
#
#   $ make
#
# To clean up all binaries:
#
#   $ make clean
#
# To generate the debugging-ready target:
#
#   $ make clean
#   $ make debug

testpaleo := testpaleo
objects   := testpaleo.o modpaleo.o

# Default to gfortran for maximum compatibility
ifeq ($(origin MMMFC), undefined)
   MMMFC:=gfortran
endif

FFLAGS := -O3
#FFLAGS := -O3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -finit-real=nan

all : $(testpaleo)

.PHONY : debug
debug : FFLAGS := $(subst -O3,-g,$(FFLAGS))
debug : $(testpaleo)

testpaleo.o : modpaleo.o

$(testpaleo) : $(objects)
	$(MMMFC) -o $(testpaleo) $(objects)

.PHONY : clean
clean :
	rm -f testpaleo testpaleo.exe *.MOD *.mod *.o

%.o : %.f90
	$(MMMFC) -c $(FFLAGS) $< -o $@

