CC=gcc -Wall
USEFULFLAGS=-pipe -g `sdl-config --cflags`

OBJECT=src/functions/*/*.o
SRC=src/functions/*/*.c
# for now
#DEFINES=-DNO_DEBUG

HEADERS=inc/*.h

LIBS=-lreadline `sdl-config --libs`

TREES=trees

all: functions trees_main

functions: $(SRC) $(HEADERS)
	for i in $(SRC); do $(CC) $(USEFULFLAGS) $(DEFINES) -c -o "$${i/.c}.o" $$i; echo "compiled $$i"; done

trees.o: functions src/main.c $(HEADERS)
	$(CC) $(USEFULFLAGS) $(DEFINES) -c -o trees.o src/main.c

clean:
	rm -f $(OBJECT) trees.o
	find . -name '*~' -exec rm -f {} \;

cleanall: clean
	rm -f $(TREES)

trees_main: functions trees.o
	$(CC) $(USEFULFLAGS) $(LIBS) -o $(TREES) $(OBJECT) trees.o
