
CCBASE=/usr/local/devkitadv
CC = $(CCBASE)/bin/arm-agb-elf-gcc
CXX = $(CCBASE)/bin/arm-agb-elf-g++
LD = $(CCBASE)/bin/arm-agb-elf-gcc
AS = $(CCBASE)/bin/arm-agb-elf-as
AR = $(CCBASE)/bin/arm-agb-elf-ar
OBJCOPY = $(CCBASE)/bin/arm-agb-elf-objcopy

INCLUDES = -I.

CFLAGS = $(INCLUDES) -DGP32 -O2 -fno-builtin -ffreestanding -fno-exceptions -mcpu=arm9tdmi -mtune=arm9tdmi -nostdinc -finline-functions
CPPFLAGS = $(INCLUDES) -DGP32 -O3 -fno-builtin -ffreestanding -fno-exceptions -mcpu=arm9tdmi -mtune=arm9tdmi -nostdinc -finline-functions

%.o: %.c
	$(CC) $(CFLAGS) -c $<

%.o: %.cpp
	$(CXX) $(CPPFLAGS) -c $<

%.gxb: %.elf
	$(OBJCOPY) -v -O binary $< $@

%.o: %.s
	$(AS) -o $@ $<
 
%.fxe: %.gxb
	$(CCBASE)/bin/b2fxe $< $@

OBJS =	\
	armdisableinterrupt.o \
	armenableinterrupt.o \
	gpcontrolvolume.o \
	gppaletteset.o \
	gppcminit.o \
	gppcmplay.o \
	gppcmstop.o \
	gpsndmixerinit.o \
	init1330.o \
	initiis.o \
	iis.o \
	rtc.o \
	swi_install_irq.o \
	swi_uninstall_irq.o \
	syscall.o

libgpsound.a: $(OBJS)
	$(AR) rcs $@ $(OBJS)

all: libgpsound.a

clean:
	rm -f *.o *.a


