ifeq ($(DEBUG),1)
LIBS := -lefence
CFLAGS := -g -ggdb
endif

LIBS += $(shell xmms-config --libs) $(shell allegro-config --libs) -lpthread
CFLAGS += $(shell xmms-config --cflags) $(shell allegro-config --cflags)

all: xpyre.so

xpyre.so: xpyre.o xmms.o font.o
	$(CC) $(LDFLAGS) -shared -fPIC -o $@ $^ $(LIBS)

xmms.o: xmms.c xpyre.h
	$(CC) $(CFLAGS) -c -o $@ $<

xpyre.o: xpyre.c xpyre.h font.h
	$(CC) $(CFLAGS) -c -o $@ $<

font.s font.h: font.dat
	dat2s -p "my" -h font.h -o font.s $<

clean:
	-rm -f xpyre.so *.o font.s font.h xpyre.tar.bz2

install: all
	cp -f xpyre.so $(HOME)/.xmms/Plugins
	grep -q '^\[xpyre\]$$' $(HOME)/.xmms/config || \
			(echo; cat config) >> $(HOME)/.xmms/config

xpyre.tar.bz2: clean
	cd ..; tar cf - xpyre | bzip2 - > xpyre/xpyre.tar.bz2

tar: xpyre.tar.bz2

.PHONY: all clean install tar
