CC=gcc
CFLAGS=-Wall -g -O0
LDFLAGS=-static -lm

.PHONY: default
default: bin/hybridGrouping

bin/hybridGrouping: build/memlib_memoryInspect.o build/memlib_pfnInspect.o \
	build/memlib_util.o build/hammerlib_afunc.o build/hammerlib_hammer.o \
 	build/hammerlib_util.o build/helper.o build/group.o build/measure.o \
	build/hybridGrouping.o build/bankSequence.o
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

build/memlib_%.o: memlib/%.c memlib/%.h
	-mkdir -p build/memlib/
	$(CC) $(CFLAGS) -c -o $@ $(word 1, $^)

build/hammerlib_%.o: hammerlib/%.c hammerlib/%.h
	-mkdir -p build/hammerlib/
	$(CC) $(CFLAGS) -c -o $@ $(word 1, $^)

build/%.o: %.c %.h asm.h
	-mkdir -p build/
	$(CC) $(CFLAGS) -c -o $@ $(word 1, $^)

.PHONY: clean
clean:
	-rm -rf build/*

.PHONY: cleanall
cleanall: clean
	-rm -f bin/hybridGrouping
