CFLAGS = -O2 -Wall `pkg-config gtk+-2.0 --cflags`
LIBS = `pkg-config gtk+-2.0 --libs`
install = cp
mkdir = mkdir
ifndef prefix
    prefix=/usr/local
endif

plugindir = $(prefix)/lib/xchat/plugins
plugin = systray.so

all: $(plugin)

xchatpng.h: images/xchat.png
	gdk-pixbuf-csource --name=xchatpng images/xchat.png > xchatpng.h

xchatsettings.h: images/settings.xpm
	gdk-pixbuf-csource --name=xchatsettings images/settings.xpm > xchatsettings.h

xchatemail.h: images/email.png
	gdk-pixbuf-csource --name=xchatemail images/email.png > xchatemail.h

xchatbrowser.h: images/browser.png
	gdk-pixbuf-csource --name=xchatbrowser images/browser.png > xchatbrowser.h

xchatplayer.h: images/player.png
	gdk-pixbuf-csource --name=xchatplayer images/player.png > xchatplayer.h

xchatbluepng.h: images/xchatblue.png
	gdk-pixbuf-csource --name=xchatbluepng images/xchatblue.png > xchatbluepng.h

xchatredpng.h: images/xchatred.png
	gdk-pixbuf-csource --name=xchatredpng images/xchatred.png > xchatredpng.h

xchatquitpng.h: images/quit.png
	gdk-pixbuf-csource --name=xchatquitpng images/quit.png > xchatquitpng.h

xchatdccxpm.h: images/dccalert.xpm
	gdk-pixbuf-csource --name=xchatdccxpm images/dccalert.xpm > xchatdccxpm.h

xchatdiscxpm.h: images/disconnected.xpm
	gdk-pixbuf-csource --name=xchatdiscxpm images/disconnected.xpm > xchatdiscxpm.h

xchatinvxpm.h: images/invite.xpm
	gdk-pixbuf-csource --name=xchatinvxpm images/invite.xpm > xchatinvxpm.h

xchatminxpm.h: images/min.xpm
	gdk-pixbuf-csource --name=xchatminxpm images/min.xpm > xchatminxpm.h

xchatmaxxpm.h: images/max.xpm
	gdk-pixbuf-csource --name=xchatmaxxpm images/max.xpm > xchatmaxxpm.h

xchatnotinxpm.h: images/notifyin.xpm
	gdk-pixbuf-csource --name=xchatnotinxpm images/notifyin.xpm > xchatnotinxpm.h

xchatnotoutxpm.h: images/notifyout.xpm
	gdk-pixbuf-csource --name=xchatnotoutxpm images/notifyout.xpm > xchatnotoutxpm.h

xchatbackaway.h: images/backaway.png
	gdk-pixbuf-csource --name=backawaypng images/backaway.png > xchatbackaway.h

xchatgoaway.h: images/goaway.png
	gdk-pixbuf-csource --name=goawaypng images/goaway.png > xchatgoaway.h


systray.so: xchatpng.h xchatbluepng.h xchatquitpng.h xchatbackaway.h xchatgoaway.h xchatsettings.h xchatdccxpm.h xchatdiscxpm.h xchatemail.h xchatinvxpm.h xchatnotoutxpm.h xchatnotinxpm.h xchatmaxxpm.h xchatminxpm.h xchatredpng.h xchatbrowser.h xchatplayer.h systray.o eggtrayicon.o
	$(CC) $(LIBS) systray.o eggtrayicon.o -shared -o $(plugin)

.c.obj:
	$(CC) $(CFLAGS) -c $<

install: all
	$(mkdir) -p $(plugindir)
	$(install) $(plugin) $(plugindir)/$(plugin)

clean:
	rm -f *.o *.so *.*~ *.core  xchatpng.h xchatbackaway.h xchatgoaway.h xchatbluepng.h xchatsettings.h xchatquitpng.h xchatdccxpm.h xchatdiscxpm.h xchatinvxpm.h xchatnotoutxpm.h xchatnotinxpm.h xchatmaxxpm.h xchatminxpm.h xchatredpng.h xchatbrowser.h xchatplayer.h xchatemail.h
