#####################################################################
# OpenOffice QuickStarter
#
# (c) 2002  Kumaran Santhanam  <kumaran@alumni.stanford.org>
#
# This project is released under the GNU General Public License.
# Please see the file COPYING for more details.
#
#####################################################################

VERSION=0.8.3

#####################################################################
# DEFINITIONS
#####################################################################
CLI_TARGET    := ooqstart
CLI_OBJECTS   := model.o console.o

GNOME_TARGET  := ooqstart_applet
GNOME_OBJECTS := model.o gnome.o

KDE_TARGET    := kooqstart
KDE_OBJECTS   := model.o kde.o

OBJECTS       := $(CLI_OBJECTS) $(GNOME_OBJECTS) $(KDE_OBJECTS)
TARGETS       := $(CLI_TARGET)  $(GNOME_TARGET)  $(KDE_TARGET)


#####################################################################
# MAIN RULES
#####################################################################
all : $(CLI_TARGET) $(GNOME_TARGET)

gnome:  $(GNOME_TARGET)
kde:    $(KDE_TARGET)

$(CLI_TARGET) : $(CLI_OBJECTS)
	$(CXX) -o $@ $^

$(GNOME_TARGET) : $(GNOME_OBJECTS)
	$(CXX) -o $@ $^ `gnome-config --libs applets gdk_pixbuf`

$(KDE_TARGET) : $(KDE_OBJECTS)
	$(CXX) -o $@ $^


#####################################################################
# COMPILATION RULES
#####################################################################
CFLAGS=-g -DVERSION='"$(VERSION)"' -Wall -Werror -I.

console.o : console/console.cxx
	$(CXX) $(CFLAGS) -O2 -o $@ -c $<

gnome.o : gnome/gnome.cxx
	$(CXX) $(CFLAGS) `gnome-config --cflags gnomeui gnorba gdk_pixbuf` -O2 -o $@ -c $<

%.o : %.cxx
	$(CXX) $(CFLAGS) -O2 -o $@ -c $<


#####################################################################
# INSTALLATION RULES
#####################################################################
ROOT=
PREFIX=$(ROOT)/usr
BIN=$(PREFIX)/bin
SHARE=$(PREFIX)/share
ETC=$(ROOT)/etc

install-gnome:
	install -D -s -m 755 $(GNOME_TARGET) $(BIN)/$(GNOME_TARGET)
	install -D -m 644 gnome/ooqstart_applet.desktop \
                      $(SHARE)/applets/Utility/ooqstart_applet.desktop
	install -D -m 644 ooqstart.png \
                      $(SHARE)/pixmaps/gnome-ooqstart.png
	install -D -m 644 gnome/ooqstart_applet.gnorba \
                      $(ETC)/CORBA/servers/ooqstart_applet.gnorba
	mkdir -p $(SHARE)/gnome/help/ooqstart_applet/C
	install -D -m 644 help/* $(SHARE)/gnome/help/ooqstart_applet/C


#####################################################################
# TAR DISTRIBUTION
#####################################################################
tarball: clean
	-rm -fr tmp
	mkdir tmp
	cd tmp; ln -s .. ooqstart-$(VERSION)
	cd tmp; tar --exclude ooqstart-$(VERSION)/tmp \
        -czvf ../ooqstart-$(VERSION).tgz ooqstart-$(VERSION)/*
	-rm -fr tmp


#####################################################################
# CLEAN
#####################################################################
clean :
	rm -fr $(OBJECTS) $(TARGETS) .bak* .*~ */.bak* */.*~ *.tgz tmp
