PREFIX=@prefix@
BINDIR=$(PREFIX)/bin/
LIBDIR=$(PREFIX)/lib/wmradio/
MANDIR=$(PREFIX)/man/man1/

TARGETS=@TARGETS@

CC=@CC@

LIBXOSD_CFLAGS=@LIBXOSD_CFLAGS@
LIBXOSD_LIBS=@LIBXOSD_LIBS@

X_CFLAGS=@X_CFLAGS@
X_LIBS=@X_LIBS@ -lXpm -lXext -lX11 -lm

PANEL_CFLAGS=-DGNOME_RADIO @PANEL_CFLAGS@
PANEL_LIBS=@PANEL_LIBS@

EXTRA_CFLAGS=-Wall -D SKIN_DIR=\"$(LIBDIR)\"

BASESOURCE=skin.c \
           radio.c \
           rc.c lists.c ini.c \
           wmradio.c \
           fifo.c \
           stationnames.c \
           osd.c

WMRADIOSOURCE=wm_envelope.c $(BASESOURCE)
XRADIOSOURCE=x_envelope.c $(BASESOURCE)
GNOMERADIOSOURCE=gnome_applet_envelope.c $(BASESOURCE)

SKINFILES=skins/wave.skin skins/wave.xpm \
          skins/default.skin skins/default.xpm \
          skins/startrek.skin skins/startrek.xpm \
          skins/gdefault.skin skins/gdefault.xpm \
          skins/biggray.skin skins/biggray.xpm

all: $(TARGETS)

wmradio: $(WMRADIOSOURCE)
	$(CC) $(EXTRA_CFLAGS) $(X_CFLAGS) $(LIBXOSD_CFLAGS) \
	$(WMRADIOSOURCE) -o wmradio \
	$(X_LIBS) $(LIBXOSD_LIBS)

xwmradio: $(XRADIOSOURCE)
	$(CC) $(EXTRA_CFLAGS) $(X_CFLAGS) $(LIBXOSD_CFLAGS) \
	$(XRADIOSOURCE) -o xwmradio \
	$(X_LIBS) $(LIBXOSD_LIBS)

gwmradio: $(GNOMERADIOSOURCE)
	$(CC) $(EXTRA_CFLAGS) $(PANEL_CFLAGS) \
	$(GNOMERADIOSOURCE) -o gwmradio \
	$(X_LIBS) $(PANEL_LIBS) $(LIBXOSD_LIBS)

xor: xor.c skin.c
	$(CC) $(CFLAGS) xor.c skin.c -o xor $(LIBFLAGS)

clean:
	/bin/rm -f xor $(TARGETS) *~ *.o

install: wmradio
	install -m 755 -d $(RPM_BUILD_ROOT)$(BINDIR)
	install -m 755 -d $(RPM_BUILD_ROOT)$(MANDIR)
	install -m 755 wmradio $(RPM_BUILD_ROOT)$(BINDIR)
	install -m 755 xwmradio $(RPM_BUILD_ROOT)$(BINDIR)
	install -m 755 wmradio-remote $(RPM_BUILD_ROOT)$(BINDIR)
	install -m 755 config/wmradio-config.py $(RPM_BUILD_ROOT)$(BINDIR)
	install -m 644 doc/wmradio.1 $(RPM_BUILD_ROOT)$(MANDIR)
	install -m 755 -d $(RPM_BUILD_ROOT)`pkg-config gnome-desktop-2.0 --variable=prefix`/share/applications
	install -m 755 -d $(RPM_BUILD_ROOT)`pkg-config gnome-desktop-2.0 --variable=prefix`/share/pixmaps
	install -m 644 misc/wmradio.png $(RPM_BUILD_ROOT)`pkg-config gnome-desktop-2.0 --variable=prefix`/share/pixmaps/
	install -m 644 misc/wmradio.desktop $(RPM_BUILD_ROOT)`pkg-config gnome-desktop-2.0 --variable=prefix`/share/applications/
	install -m 644 misc/wmradio-config.desktop $(RPM_BUILD_ROOT)`pkg-config gnome-desktop-2.0 --variable=prefix`/share/applications/

ginstall: gwmradio
	install -d $(RPM_BUILD_ROOT)`gnome-config --prefix`/share/applets/Multimedia
	install -d $(RPM_BUILD_ROOT)`gnome-config --sysconfdir`/CORBA/servers
	install -m 755 gwmradio $(RPM_BUILD_ROOT)$(BINDIR)
	install -m 644 gwmradio.desktop $(RPM_BUILD_ROOT)`gnome-config --prefix`/share/applets/Multimedia/
	install -m 644 gwmradio.gnorba $(RPM_BUILD_ROOT)`gnome-config --sysconfdir`/CORBA/servers/

install-skins:
	install -m 755 -d $(RPM_BUILD_ROOT)$(LIBDIR)
	install -m 644 $(SKINFILES) $(RPM_BUILD_ROOT)$(LIBDIR)
