include Makeconf

emu-objs := $(addsuffix .o,$(modules))
clean-objs := $(emu-objs) libemu.a vgbc vgbc.test
test-srcs := $(wildcard tests/*.cpp)

.PHONY: all test clean

all: vgbc $(test-targets)

clean:
	rm -rf $(clean-objs)

test: vgbc.test
	@./$<

%.o: %.cpp
	g++ $(CXX_FLAGS) -c -o $@ $^

libemu.a: $(emu-objs)
	ar -rc $@ $^

vgbc: main.c libemu.a
	g++ $(CXX_FLAGS) -o $@ $^

vgbc.test: $(test-srcs) libemu.a
	g++ $(CXX_FLAGS) -o $@ $^