# Makefile for KColorEditor
# 	by Michael Riedel

CC=g++
MOC=moc

# including debugging info:
CPPFLAGS=-O0 -Wall -I$(QTDIR)/include -I$(KDEDIR)/include -I.\
		   -Imoc -DSTDC_HEADERS -g -pipe

# optimized:
_CPPFLAGS=-O3 -Wall -I$(QTDIR)/include -I$(KDEDIR)/include -I.\
		   -Imoc -DSTDC_HEADERS -pipe
# fast compile:
_CPPFLAGS=-O0 -Wall -I$(QTDIR)/include -I$(KDEDIR)/include -I.\
		   -Imoc -DSTDC_HEADERS -pipe

LDFLAGS=	   -L/usr/X11/lib -L/usr/lib -L$(KDEDIR)/lib -L$(QTDIR)/lib \
	           -rdynamic
#################################
	
LDLIBS=		-lkdecore -lkdeui -lqt -lXext
#		-ldl -lg
DATA_FILES=	Editor.o KColorMLE.o KCMLEKeys.o KCMLEFile.o KCMLESearch.o\
		Colorizer.o SyntaxState.o StateCache.o \
		Maker.o Action.o FindReplace.o MainEditor.o
DLGS_FILES=	Dlgs/EditorSettingsDlg.o Dlgs/EditorSettingsData.o \
		Dlgs/ColorSet.o Dlgs/ColorSetData.o
DLGMOC_FILES=	moc/EditorSettings.o moc/EditorSettingsData.o \
		moc/ColorSet.o moc/ColorSetData.o

all:            moc dlgs $(DATA_FILES) $(DLGS_FILES)
		$(CC) -o kcoloreditor \
			$(DATA_FILES) $(DLGS_FILES) \
			$(LDFLAGS) $(LDLIBS)

ook:

version:	ook
		@if [ ! -f .version ]; then \
			echo 1 > .version; \
		else \
			expr 0`cat .version` + 1 > .version; \
		fi
		@echo "// DO NOT MODIFY THIS FILE" > version.h
		@echo "// Automatically generated by Makefile" >> version.h
		@echo >> version.h
		@echo \#define VERSION \"Build \#`cat .version` on `date`\" >> version.h

moc:		ook
		@make -C moc all

dlgs:		ook
		@make -C Dlgs all

doc:
		kdoc *.h -dHTML


install:	all
		cp kcoloreditor $(KDEDIR)/bin/kcoloreditor
		if ! test -e $(KDEDIR)/share/apps/KColorEditor; then\
			mkdir $(KDEDIR)/share/apps/KColorEditor;\
		fi
		if ! test -e $(KDEDIR)/share/apps/KColorEditor/Keywords; then\
			mkdir $(KDEDIR)/share/apps/KColorEditor/Keywords;\
		fi
		cp ./Keywords/*.rules $(KDEDIR)/share/apps/KColorEditor/Keywords
		cp ./locale/kcoloreditor.mo $(KDEDIR)/share/locale/de/LC_MESSAGES


uninstall:
		if test -e $(KDEDIR)/bin/kcoloreditor; then \
			rm $(KDEDIR)/bin/kcoloreditor;      \
		fi
		if test -e $(KDEDIR)/share/apps/KColorEditor/Keywords; then \
			rm $(KDEDIR)/share/apps/KColorEditor/Keywords/*;    \
			rmdir $(KDEDIR)/share/apps/KColorEditor/Keywords;      \
		fi
		if test -e $(KDEDIR)/share/apps/KColorEditor; then \
			rmdir $(KDEDIR)/share/apps/KColorEditor;      \
		fi
		rm $(KDEDIR)/share/locale/de/LC_MESSAGES/kcoloreditor.mo


clean:
		rm -f editor version.h $(DATA_FILES)
		@make -C moc clean
		rm -f $(DLGS_FILES)


### MAKEFILE DEPENDENCIES ###

%.o: %.cpp moc/%.moc %.h
	$(CC) $(CPPFLAGS) -c $<

%.o: %.C moc/%.moc %.h
	$(CC) $(CPPFLAGS) -c $<

