CC             = gcc
CC_OPENACC     = pgcc
CFLAGS_OPENACC = -acc -fast -Minfo=accel -ta=tesla:cc80 -ta=tesla:maxregcount:32 -ta=tesla:ptxinfo -g
CFLAGS         = -Wall -Wextra -march=native -mtune=native
LIBS           = -lm

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

PROG          = jacobi_OpenACC_$(SYSTYPE)
PROG_SERIAL   = jacobi_serial_$(SYSTYPE)

HEADERS       = $(wildcard ./include/*.h)
SOURCES       = $(wildcard ./src/*.c)
DEPENDENCIES  = $(SOURCES) $(HEADERS) Makefile

$(PROG): $(DEPENDENCIES)
	$(CC_OPENACC) $(CFLAGS_OPENACC) -O3 -I./include $(SOURCES) -o $@ $(LIBS)
	@echo ' '
	@echo 'Program' $(PROG) 'compiled for' $(SYSTYPE) 'machine'
	@echo ' '

$(PROG_SERIAL): $(DEPENDENCIES)
	$(CC) $(CFLAGS) -O3 -I./include $(SOURCES) -o $@ $(LIBS)
	@echo ' '
	@echo 'Program' $(PROG_SERIAL) 'compiled for' $(SYSTYPE) 'machine'
	@echo ' '
