SYSTEM := $(shell uname -s)
CROSS := ppc-amigaos
CC := $(CROSS)-gcc
STRIP := $(CROSS)-strip
RM := rm -f

CFLAGS := -O2 -g -Wall -Werror -I../../include -I../common -Iinclude
ifndef PT36
CFLAGS += -DNOPT36
endif
ifdef DEBUG
CFLAGS += -DDEBUG=$(DEBUG)
endif
LDFLAGS := -g -nostartfiles
PLUGIN_LIBS := 
PLAYER_LIBS := 

PLUGIN := TN_UADE.tnplug
PLAYER := TN_UADE.player
VERSION := 1

ifeq ($(SYSTEM),AmigaOS)
TUNENETDIR := $(shell cat /ENV/AppDir/TuneNet)
endif

.PHONY: all
all: $(PLUGIN) $(PLAYER)

include ../common/Makefile.common

PLUGIN_OBJS := init.o initplayer.o announceplayer.o openplayer.o decodeframeplayer.o \
	donotify.o compression.o pt36.o unixatomic.o amifilemagic.o eagleplayer.o support.o
PLAYER_OBJS := playermain.o playerfunc.o $(COMMONMODULES)

$(PLUGIN): $(PLUGIN).debug
	$(STRIP) -R.comment -o $@ $<

$(PLAYER): $(PLAYER).debug
	$(STRIP) -R.comment -o $@ $<

$(PLUGIN).debug: $(PLUGIN_OBJS)
	$(CC) $(LDFLAGS) -o $@ $^ $(PLUGIN_LIBS)

$(PLAYER).debug: $(PLAYER_OBJS)
	$(CC) $(LDFLAGS) -o $@ $^ $(PLAYER_LIBS)

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

playermain.o: $(PLAYER)_rev.h

ifeq ($(SYSTEM),AmigaOS)
.PHONY: install
install:
	copy $(PLUGIN) $(TUNENETDIR)/Plugins/
	copy $(PLAYER) $(TUNENETDIR)/Plugins/data/
endif

.PHONY: clean
clean:
	$(RM) $(PLUGIN) $(PLAYER) *.debug *.o

revision:
	bumprev $(VERSION) $(PLUGIN)
	bumprev $(VERSION) $(PLAYER)

