# $Log: Makefile,v $
# Revision 1.3  2005/11/08 21:29:54  khlut
# issues with make of debian package fixed
#
# Revision 1.2  2005/11/04 19:31:40  khlut
# mozilla-conf path autodetection
#
# Revision 1.1.1.1  2005/11/04 09:07:01  khlut
# Release 0.7
# First CVS submition
# Many bugs were fixed
# All source files edited to conform to GPL (copyright and license notices were added)
# GenReS was moved to savannah.nongnu.org
#
PATH:=${PATH}:/usr/local/mozilla/bin:/usr/lib/mozilla/bin:/opt/mozilla/bin
CFLAGS= -Wall -Os -DXP_UNIX -DMOZ_X11 -DXTHREADS ` 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
ifdef DESTDIR
MOZILLAD=$(LIBPREFIX)/mozilla
FIREFOXD=$(LIBPREFIX)/mozilla-firefox
LNMF=ln -sf ../../mozilla/plugins/genres.so $(FIREFOXD)/plugins/genres.so
else
MOZILLAD=$(shell mozilla --help | head -1 | sed -e 's/[^ ]\+ //' -e 's|/[^/ ]\+ .*||')
FIREFOXD=$(shell firefox --help | head -1 | sed -e 's/[^ ]\+ //' -e 's|/[^/ ]\+ .*||')
LNMF=ln -sf $(MOZILLAD)/plugins/genres.so $(FIREFOXD)/plugins/genres.so
endif

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
	test -z "$(MOZILLAD)" || $(INSTALL) genres.so $(MOZILLAD)/plugins/genres.so
	test -z "$(FIREFOXD)" || $(INSTALL) -d $(FIREFOXD)/plugins
	test -z "$(FIREFOXD)" -o -z "$(MOZILLAD)" || $(LNMF)
	test -z "$(FIREFOXD)" -o ! -z "$(MOZILLAD)"|| $(INSTALL) genres.so $(FIREFOXD)/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
