# paths etc
include ../../gbalib/master.mk
XMCONVERT:=../../xmply/xmconvert
CFLAGS += -I../../libsxmp/


# the files to convert
XM_FILES= $(wildcard *.xm)

# the rest of this is fairly standard

LIBMODULE := libmodule.a
MODULE_OFILES:=module_structure.o module_data.o 


all: modules.h $(LIBMODULE)

clean:
	@-rm -f *.o
	@-rm -f module_structure.c module_data.s


module_structure.c module_data.s modules.h: $(XM_FILES) $(XMCONVERT)
	@echo Converting $(XM_FILES)
	@$(XMCONVERT) $(XM_FILES)


$(LIBMODULE): $(MODULE_OFILES)
	@echo creating $@
	@$(AR) rcs $@ $(MODULE_OFILES)
	@echo ...done

%.o: %.c
	@echo compile thumb $<
	@$(GCC) $(CFLAGS) -mthumb -c -o $@ $<

%.o: %.s
	@echo compile thumb $<
	@$(GCC) $(CFLAGS) -mthumb -c -o $@ $<
