KJEWEL_VERSION = 0.91
KDEINCLUDES = /opt/kde/include
LIB_X11 = -lX11
LIB_QT	= -lqt-mt $(LIB_X11)
# LIB_KDECORE = -lkdecore -lXext $(LIB_QT)
# LIB_KDEUI = -lkdeui $(LIB_KDECORE)
LIB_KDEUI = -lkdecore -lkdeui -lqt-mt
DEBUG = -g

XINCDIR = /usr/X11/lib
INCDIR	= $(QTDIR)/include
KDIR	= $(KDEDIR)/include
LFLAGS	= -L$(XINCDIR) -L$(QTDIR)/lib -L$(KDEDIR)/lib $(LIB_KDEUI)
CC	= g++
MOC	= $(QTDIR)/bin/moc
######## Suffix rules
.SUFFIXES: .cpp

%.o: %.cpp
	$(CC) $(DEBUG) -c $(CFLAGS) -I$(INCDIR) -I$(KDIR) -I. $<
######## The files
SOURCES = highscorelist.cpp jewel.cpp playfield.cpp previewfield.cpp kjewel.cpp
OBJECTS	= kjewel.o playfield.o jewel.o previewfield.o highscorelist.o
SRCMETA	= mpreviewfield.cpp mplayfield.cpp mkjewel.cpp
OBJMETA = mpreviewfield.o mplayfield.o mkjewel.o 
TARGET	= kjewel

all: $(TARGET)

$(TARGET): $(SOURCES) $(OBJECTS) $(OBJMETA)
	g++ $(DEBUG) -o $@ $(OBJECTS) $(OBJMETA) $(LFLAGS)
depend: makefile.dep

makefile.dep:
	[ -f makefile.dep ] || touch makefile.dep
	makedepend -f makefile.dep -I/usr/include/g++ -I$(GPPINC) \
	-I$(INCDIR) -I$(KDIR) -I. $(SOURCES)
clean:
	- rm $(TARGET) $(SRCMETA) $(OBJMETA) $(OBJECTS) *~ *.bak makefile.dep

install: kjewel
	cp -r HTML/en $(KDEDIR)/share/doc/HTML/en/kjewel
	test -d $(KDEDIR)/share/apps/kjewel || mkdir $(KDEDIR)/share/apps/kjewel
	test -d $(KDEDIR)/share/apps/kjewel/pics || mkdir $(KDEDIR)/share/apps/kjewel/pics
	cp jewels/*.png $(KDEDIR)/share/apps/kjewel/pics
	cp icons/kjewel16x16.png $(KDEDIR)/share/icons/hicolor/16x16/kjewel.png
	cp icons/kjewel32x32.png $(KDEDIR)/share/icons/hicolor/32x32/kjewel.png
	cp kjewel $(KDEDIR)/bin
	test -d /var/games || mkdir /var/games
	cp kjewelscore /var/games/kjewelscore
	chmod 666 /var/games/kjewelscore

package: clean
	( \
	cd ..; \
	tar cfvz kjewel-$(KJEWEL_VERSION).tar.gz kjewel \
	)

mplayfield.cpp: playfield.h
	$(MOC) -o $@ playfield.h
mpreviewfield.cpp: previewfield.h 
	$(MOC) -o $@ previewfield.h
mkjewel.cpp: kjewel.h
	$(MOC) -o $@ kjewel.h

-include makefile.dep
