CFLAGS= -Wall -Os -DXP_UNIX -DMOZ_X11 -DXTHREADS $(shell mozilla-config --cflags xpcom)
OBJ=main_thread.o observer_thread.o threadqueue.o slavesdir.o storage.o
INSTALL=install -Dp -g root -o root
LIBPREFIX=$(DESTDIR)/usr/lib

CXXFLAGS=${CFLAGS}

all: genres.so

genres.so : $(OBJ)
	$(CC) -shared -o $@ $^ $(CFLAGS)

local-install: genres.so
	mkdir -p ~/.mozilla/plugins/
	mkdir -p ~/.mozilla/genres/slaves/video
	cp -dpf genres.so ~/.mozilla/plugins/
	cp -dpf config.pl ~/.mozilla/genres/
	cp -dpf slaves/video/mplayer.pl ~/.mozilla/genres/
	ln -sf ../../mplayer.pl ~/.mozilla/genres/slaves/video/mpeg
	ln -sf ../../mplayer.pl ~/.mozilla/genres/slaves/video/mjpeg

install: genres.so
	$(INSTALL) genres.so $(LIBPREFIX)/mozilla/plugins/genres.so
	$(INSTALL) -d $(LIBPREFIX)/mozilla-firefox/plugins
	ln -sf ../../mozilla/plugins/genres.so $(LIBPREFIX)/mozilla-firefox/plugins/genres.so
	$(INSTALL) config.pl $(LIBPREFIX)/genres/config.pl
	$(INSTALL) slaves/video/mplayer.pl $(LIBPREFIX)/genres/mplayer.pl
	$(INSTALL) -d $(LIBPREFIX)/genres/slaves/video
	ln -sf ../../mplayer.pl $(LIBPREFIX)/genres/slaves/video/mpeg
	ln -sf ../../mplayer.pl $(LIBPREFIX)/genres/slaves/video/mjpeg

clean:
	rm -f *.o genres.so
