.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 > exact.dat
	time ./$< Chebynames.txt > cheby.dat
	time ./$< Taylornames.txt > 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 
