#compiler	=icpc
EXE		=gridTest

compiler	=g++

GSL_INCLUDES	=-I/usr/include/gsl
GSL_LIBS 	=-L/usr/lib -lgsl -lgslcblas
RM=rm -f

compiler?=g++

ifeq ($(compiler),g++)
	CPPFLAGS= -Wall -O3
	CPP=g++
endif

ifeq ($(compiler),icpc)
	CPPFLAGS= -Wall -O3 -gxx-name=/usr/bin/g++-7 -std=c++11
	CPP=icpc
endif

OBJS = parse.o gridRoutines.o main.o 

all: $(EXE)

# pull in dependency info for *existing* .o files
-include $(OBJS:.o=.d)

parse.o: parse.cpp parse.h parse.hpp
	$(CPP) $(CPPFLAGS) -c parse.cpp -o parse.o
	$(CPP) -MM parse.cpp > parse.d

gridRoutines.o: gridRoutines.cpp gridRoutines.h parse.h
	$(CPP) $(CPPFLAGS) -c gridRoutines.cpp -o gridRoutines.o
	$(CPP) -MM gridRoutines.cpp > gridRoutines.d

main.o: main.cpp gridRoutines.cpp gridRoutines.h parse.h
	$(CPP) $(CPPFLAGS) -c  main.cpp -o main.o
	$(CPP) -MM main.cpp > main.d

$(EXE): $(OBJS)
	$(CPP) $(CPPFLAGS) $(GSL_INCLUDES) $(OBJS) -o $(EXE) $(GSL_LIBS)

.PHONY: clean
clean:
	rm -f $(EXE) $(OBJS) *.d

