CFLAGS=-std=c99 -Wall -g -O2
INDENTOPTS=-kr --no-tabs --braces-on-func-def-line --indent-level2

TARGETS=approximate-pi linked-list mandelbrot threads circular-buffer structs ncurses-pong bit-fuckery bit-fuckery2 checkcheck multibrot bloom wo-lernen lua-foo binsearch
EXTRAS=mandelbrot.bmp multibrot.png

.PHONY: all
all: $(TARGETS) $(EXTRAS)

.PHONY: clean
clean:
	rm -f $(TARGETS) $(EXTRAS) *~

mandelbrot: mandelbrot.c
	$(CC) $(CFLAGS) $(shell sdl-config --cflags) -o $@ $< $(shell sdl-config --libs) -lm

mandelbrot.bmp: mandelbrot
	./mandelbrot

threads: threads.c
	$(CC) $(CFLAGS) -o $@ $< -pthread

ncurses-pong: ncurses-pong.c
	$(CC) $(CFLAGS) -o $@ $< -lncurses

checkcheck: checkcheck.c
	$(CC) $(CFLAGS) -o $@ $< -lcheck

multibrot: multibrot.c
	$(CC) $(CFLAGS) -o $@ $< -lm -lpng -pthread

multibrot.png: multibrot
	./multibrot -j2

lua-foo: lua-foo.c
	$(CC) $(CFLAGS) -o $@ $< -llua -lm