# libmikmod Makefile for targetting GP32
# Edit compiler/linker flags, etc. to meet your needs

LIBMIRKO = ../libmirko
TARGET   = arm-none-eabi

CC = $(TARGET)-gcc
LD = $(TARGET)-gcc
AS = $(TARGET)-as
AR = $(TARGET)-ar
RANLIB = $(TARGET)-ranlib

INCLUDES=-I$(LIBMIRKO)/include -I../gp32 -I../include
CPPFLAGS=-DMIKMOD_BUILD -DDRV_GP32 -DHAVE_LIMITS_H
# disable support for module depackers
#CPPFLAGS+=-DNO_DEPACKERS
# disable the high quality mixer (build only with the standart mixer)
#CPPFLAGS+=-DNO_HQMIXER
CFLAGS  =-O2 -Wall -DLITTLE_ENDIAN -DGP32 -mtune=arm9tdmi
ARFLAGS = cr

COMPILE=$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCLUDES)

.SUFFIXES:
.SUFFIXES: .o .c

LIBS=libmikmod.a

OBJ=drv_gp32.o drv_nos.o \
    load_669.o load_amf.o load_asy.o load_dsm.o load_far.o load_gdm.o load_gt2.o \
    load_it.o load_imf.o load_m15.o load_med.o load_mod.o load_mtm.o load_okt.o \
    load_s3m.o load_stm.o load_stx.o load_ult.o load_umx.o load_uni.o load_xm.o \
    mmalloc.o mmerror.o mmio.o mdriver.o mdreg.o \
    mmcmp.o pp20.o s404.o xpk.o strcasecmp.o \
    mloader.o mlreg.o mlutil.o mplayer.o munitrk.o mwav.o \
    npertab.o sloader.o virtch.o virtch2.o virtch_common.o
#   mdulaw.o

libmikmod.a: $(OBJ)
	$(AR) $(ARFLAGS) $@ $(OBJ)
	$(RANLIB) $@

clean:
	rm -f $(LIBS) *.o

HEADER_DEPS=../include/mikmod.h ../include/mikmod_internals.h ../include/mikmod_ctype.h
drv_gp32.o: ../drivers/drv_gp32.c $(HEADER_DEPS)
	$(COMPILE) ../drivers/drv_gp32.c -o drv_gp32.o
drv_nos.o: ../drivers/drv_nos.c $(HEADER_DEPS)
	$(COMPILE) ../drivers/drv_nos.c -o drv_nos.o
load_669.o: ../loaders/load_669.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_669.c -o load_669.o
load_amf.o: ../loaders/load_amf.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_amf.c -o load_amf.o
load_asy.o: ../loaders/load_asy.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_asy.c -o load_asy.o
load_dsm.o: ../loaders/load_dsm.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_dsm.c -o load_dsm.o
load_far.o: ../loaders/load_far.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_far.c -o load_far.o
load_gdm.o: ../loaders/load_gdm.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_gdm.c -o load_gdm.o
load_gt2.o: ../loaders/load_gt2.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_gt2.c -o load_gt2.o
load_it.o: ../loaders/load_it.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_it.c -o load_it.o
load_imf.o: ../loaders/load_imf.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_imf.c -o load_imf.o
load_m15.o: ../loaders/load_m15.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_m15.c -o load_m15.o
load_med.o: ../loaders/load_med.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_med.c -o load_med.o
load_mod.o: ../loaders/load_mod.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_mod.c -o load_mod.o
load_mtm.o: ../loaders/load_mtm.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_mtm.c -o load_mtm.o
load_okt.o: ../loaders/load_okt.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_okt.c -o load_okt.o
load_s3m.o: ../loaders/load_s3m.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_s3m.c -o load_s3m.o
load_stm.o: ../loaders/load_stm.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_stm.c -o load_stm.o
load_stx.o: ../loaders/load_stx.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_stx.c -o load_stx.o
load_ult.o: ../loaders/load_ult.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_ult.c -o load_ult.o
load_umx.o: ../loaders/load_umx.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_umx.c -o load_umx.o
load_uni.o: ../loaders/load_uni.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_uni.c -o load_uni.o
load_xm.o: ../loaders/load_xm.c $(HEADER_DEPS)
	$(COMPILE) ../loaders/load_xm.c -o load_xm.o
mmalloc.o: ../mmio/mmalloc.c $(HEADER_DEPS)
	$(COMPILE) ../mmio/mmalloc.c -o mmalloc.o
mmerror.o: ../mmio/mmerror.c $(HEADER_DEPS)
	$(COMPILE) ../mmio/mmerror.c -o mmerror.o
mmio.o: ../mmio/mmio.c $(HEADER_DEPS)
	$(COMPILE) ../mmio/mmio.c -o mmio.o
mmcmp.o: ../depackers/mmcmp.c $(HEADER_DEPS)
	$(COMPILE) ../depackers/mmcmp.c -o mmcmp.o
pp20.o: ../depackers/pp20.c $(HEADER_DEPS)
	$(COMPILE) ../depackers/pp20.c -o pp20.o
s404.o: ../depackers/s404.c $(HEADER_DEPS)
	$(COMPILE) ../depackers/s404.c -o s404.o
xpk.o: ../depackers/xpk.c $(HEADER_DEPS)
	$(COMPILE) ../depackers/xpk.c -o xpk.o
mdriver.o: ../playercode/mdriver.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/mdriver.c -o mdriver.o
mdreg.o: ../playercode/mdreg.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/mdreg.c -o mdreg.o
mdulaw.o: ../playercode/mdulaw.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/mdulaw.c -o mdulaw.o
mloader.o: ../playercode/mloader.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/mloader.c -o mloader.o
mlreg.o: ../playercode/mlreg.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/mlreg.c -o mlreg.o
mlutil.o: ../playercode/mlutil.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/mlutil.c -o mlutil.o
mplayer.o: ../playercode/mplayer.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/mplayer.c -o mplayer.o
munitrk.o: ../playercode/munitrk.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/munitrk.c -o munitrk.o
mwav.o: ../playercode/mwav.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/mwav.c -o mwav.o
npertab.o: ../playercode/npertab.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/npertab.c -o npertab.o
sloader.o: ../playercode/sloader.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/sloader.c -o sloader.o
virtch.o: ../playercode/virtch.c ../playercode/virtch_common.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/virtch.c -o virtch.o
virtch2.o: ../playercode/virtch2.c ../playercode/virtch_common.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/virtch2.c -o virtch2.o
virtch_common.o: ../playercode/virtch_common.c $(HEADER_DEPS)
	$(COMPILE) ../playercode/virtch_common.c -o virtch_common.o
strcasecmp.o: ../posix/strcasecmp.c $(HEADER_DEPS)
	$(COMPILE) ../posix/strcasecmp.c -o strcasecmp.o
