.PHONY:

CXX_COMPILER  := g++-11
COMPILE_FLAGS := -std=c++14 -O3
PYTHON        := python3.10

LIBS := -lfunc -larmadillo
UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S), Linux)
LINKING_FLAGS := $(LIBS) -fopenmp -lquadmath # assuming g++ is from the gcc
endif

ifeq ($(UNAME_S), Darwin)
LINKING_FLAGS := $(LIBS) -Xpreprocessor -fopenmp -lgomp
#LINKING_FLAGS := $(LIBS)
#LINKING_FLAGS := $(LIBS) -lquadmath -fopenmp # assuming g++ is from the gcc
endif

all: python_plot_mem

# TODO abbreviate LUT names automatically?
python_plot_mem: plot_mem
	time ./$< exactnames1.txt > exact1.dat
	time ./$< chebynames1.txt > cheby1.dat
	time ./$< taylornames1.txt > taylor1.dat
	time ./$< exactnames2.txt > exact2.dat
	time ./$< chebynames2.txt > cheby2.dat
	time ./$< taylornames2.txt > taylor2.dat
	$(PYTHON) plot.py loglog cheby1.dat cheby2.dat taylor1.dat taylor2.dat exact1.dat exact2.dat

plot_mem: plot_mem.cpp
	$(CXX_COMPILER) $(COMPILE_FLAGS) $< -o $@ $(LINKING_FLAGS)

test: test.cpp
	$(CXX_COMPILER) $(COMPILE_FLAGS) $< -o $@ $(LINKING_FLAGS)


clean:
	rm -f plot_mem 
