# Makefile for the 2014 NRCM phase-field workshop code (PptCodes2D).
# Updated in 2026 so it builds with current compilers. The C sources are unchanged.
#
# Needs a C compiler with OpenMP headers and FFTW 3 (Ubuntu: sudo apt install libfftw3-dev).
# -fcommon: binary.h defines global variables; GCC 10 and later reject that without it.
# If FFTW is installed outside the default paths (for example with Homebrew), add
#   CFLAGS += -I/opt/homebrew/include   and   LDFLAGS += -L/opt/homebrew/lib
#
# Build: make        Run: ./pptg.out        Clean: make clean

CC      = gcc
CFLAGS  = -std=c99 -O3 -fopenmp -fcommon
LDFLAGS =
LDLIBS  = -lfftw3 -lm

objs = main.o get_input.o init_conf.o evolve.o out_conf.o

pptg.out: $(objs)
	$(CC) $(CFLAGS) -o $@ $(objs) $(LDFLAGS) $(LDLIBS)

%.o: %.c binary.h
	$(CC) $(CFLAGS) -c $<

clean:
	rm -f *.o pptg.out

.PHONY: clean
