# Portable across GNU make (Linux) and BSD make (FreeBSD).
#
# We do NOT read the make flavor's predefined CFLAGS: BSD make's sys.mk sets it
# to "-O2 -pipe", which would fight our OPT setting. Optimization lives in OPT,
# required language/warning flags in STD/WARN, and EXTRA is yours to append.
#
# OPT defaults to an aggressive, build-on-target profile. -march=native tunes
# for THIS machine's CPU, so only build where you run (which is how this repo
# is used). If you cross-build, override it, e.g.  make OPT="-O2".
CC    ?= cc
OPT   ?= -O3 -march=native
EXTRA ?=

STD  = -std=c11
WARN = -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 \
       -Wcast-align -Wstrict-prototypes -Wmissing-prototypes \
       -Wpointer-arith -Wwrite-strings

TARGETS = pixelflut-render pixelflut-bench

all: $(TARGETS)

pixelflut-render: new.c pixelflut.h
	$(CC) $(STD) $(OPT) -pthread $(WARN) $(EXTRA) -o $@ new.c

pixelflut-bench: bench.c pixelflut.h
	$(CC) $(STD) $(OPT) -pthread $(WARN) $(EXTRA) -o $@ bench.c

clean:
	rm -f $(TARGETS)

.PHONY: all clean
