.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

python_plot_mem: plot_mem
	time ./$< exactnames.txt  1000 100000 0 > exact.dat
	time ./$< chebynames.txt  1000 100000 0 > cheby.dat
	time ./$< taylornames.txt 1000 100000 0 > taylor.dat
	$(PYTHON) plot.py loglog cheby.dat taylor.dat exact.dat

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

clean:
	rm -f plot_mem 
