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

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

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

# Additional linker libraries
LIBS = -lz

# Name of the "thing" to build
TARGET  = TN_YMAmp.tnplug
VERSION = 1
YM_BIN   = TN_YMAmp.bin

# 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

YM_SRCS = ym_bin.c ymamp/ym2151.c ymamp/ym2612.c ymamp/sn76496.c

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

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

YM_OBJS = $(YM_SRCS:.c=.o)

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

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

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

data/$(YM_BIN): $(YM_OBJS)
	$(CC) $(LINK) -nostartfiles -o $@ $^ $(LIBS)

qsfbin.o: $(YM_BIN)_rev.h

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

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

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

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