COMPILER_CXX ?= clang++
DEBUG        ?= YES
FLAGS        ?= # -fopenmp # --offload-arch=native -fopenmp-targets=nvptx64-nvidia-cuda

# executable name
EXEC     ?= globals

SYSTYPE ?= $(strip $(shell uname -n))


############ DEBUG configuration ###################################
ifeq ($(DEBUG), YES)
OPT  = -O0 -g
else
OPT  = -O3
endif
####################################################################

.PHONY: clean

HEADERS      = $(shell find . -name "*.hpp" -type f)
SOURCES      = $(shell find . -name "*.cpp" -type f)
DEPENDENCIES = $(SOURCES) $(HEADERS) Makefile
CFLAGS       = -Wall -Wextra -v -march=native -mtune=native

$(EXEC): $(DEPENDENCIES)
	$(COMPILER_CXX) $(CFLAGS) $(FLAGS) $(OPT) $(SOURCES) -o $@
	ldd $(EXEC)
	@echo -e '\n\t Program' $@ 'compiled for' $(SYSTYPE) 'machine \n'

clean:
	rm -rf $(EXEC) *~
