LIBRARY=libgearlib.a

CC:=gcc
AR=ar
CFLAGS=-O3 -Iinclude -g
LDFLAGS=-lglfw -lm

CFILES=$(shell cd src && find -L * -type f -name '*.c')
OBJDIR=obj
OBJ=$(addprefix $(OBJDIR)/, $(CFILES:.c=.o))

$(LIBRARY): $(OBJ) Makefile
	$(AR) rcs $(LIBRARY) $(OBJ)

obj/%.o: src/%.c
	mkdir -p $(OBJDIR)
	$(CC) $(CFLAGS) -c $< -o $@

run: $(LIBRARY)
	make -C examples test
	cd examples && ./test

clean:
	rm -rf $(OBJ) $(LIBRARY)
	make -C test clean
