MAKE = make
CC   = gcc -mcrt=newlib
CXX  = g++ -mcrt=newlib
CP	 = copy
RM   = delete

# Change these as required
OPTIMIZE = -O3
DEBUG =
CFLAGS = $(OPTIMIZE) $(DEBUG) -Iinclude -Ibsplay #-DDEBUG
CXXFLAGS = $(CFLAGS)

# Flags passed to gcc during linking
LINK = $(OPTIMIZE) $(DEBUG)

# Additional linker libraries
LIBS = 

# Name of the "thing" to build
TARGET  = TN_BS.tnplug
PSFBIN  = TN_BS.bin
VERSION = 1

# Source code files used in this project
# Add any additional files to this line

SRCS = init.c initplayer.c announceplayer.c \
	openplayer.c decodeframeplayer.c donotify.c

PSF_OBJS = playerproc.o \
	bsplay/Player.o bsplay/Module.o bsplay/LSoundPlayer.o \
	bsplay/Instrument.o bsplay/LChannel.o

# -------------------------------------------------------------
# Nothing should need changing below this line

OBJS = $(SRCS:.c=.o)

all: $(TARGET) data/$(PSFBIN)

# Rules for building
$(TARGET): $(OBJS)
	$(CC) $(LINK) -nostartfiles -o $@ $^ $(LIBS)

init.o announceplayer.o: $(TARGET)_rev.h

data/$(PSFBIN): $(PSF_OBJS)
	$(CXX) $(LINK) -nostartfiles -o $@ $^ $(LIBS)

playerproc.o: $(PSFBIN)_rev.h

.PHONY: install
install: $(TARGET) data/$(PSFBIN)
	$(CP) $(TARGET) Apps:TuneNet/Plugins/
	$(CP) data/$(PSFBIN) Apps:TuneNet/Plugins/data/

.PHONY: clean
clean: distclean
	$(RM) $(TARGET) data/$(PSFBIN)

.PHONY: distclean
distclean:
	$(RM) $(OBJS) $(PSF_OBJS)

.PHONY: revision
revision:
	bumprev $(VERSION) $(TARGET)
	bumprev $(VERSION) $(PSFBIN)
