SHELL = /bin/sh
prefix = @prefix@

# @CXXFLAGS@     : is set to -g -Wall (when debuging) or -O2 -Wall (when not)
# @all_includes@ : is set to all needed include paths for QT, KDE and X11
# -I..           : needed for config.h
# Debugging      : -DKPACKDEBUG
CFLAGS= @CXXFLAGS@ @all_includes@ -DHAVE_CONFIG_H -I. -I..

# @LDFLAGS@       : is set to -s (when not debuging) for stripping
# @all_libraries@ : is set to all needed libraries paths for QT, KDE and X11
LFLAGS = @LDFLAGS@ @all_libraries@ -lkhtmlw -lkimgio -ljpeg -lpng -ltiff -lz -ljscript -lkfile -lkfm -lkdeui -lkdecore -lqt -lXext -lX11

# both are clear, I think
CC      = @CXX@
MOC     = @MOC@

####### Files

SOURCE	=	ktreeview.cpp KPackViewer.cpp
	         
OBJECT	=	ktreeview.o KPackViewer.o
				
SRCMETA	=	ktreeview.h KPackViewer.cpp
				
OBJMETA	=	ktreeview.moc KPackViewer.moc
				
TARGET	=	KPackViewer

####### Implicit rules

.SUFFIXES: .cpp

.cpp.o:
	$(CC) -c $(CFLAGS) $<

####### Build rules

all: $(OBJECT)
	$(CC) $(CFLAGS) -o $(TARGET) $(OBJECT) $(LFLAGS)
	
$(OBJECT): $(OBJMETA)
	$(CC) $(CFLAGS) -c -o ktreeview.o ktreeview.cpp
	$(CC) $(CFLAGS) -c -o KPackViewer.o KPackViewer.cpp

####### Meta objects

$(OBJMETA):
	$(MOC) ktreeview.h -o ktreeview.moc
	$(MOC) KPackViewer.cpp -o KPackViewer.moc

depend:
	@makedepend $(SOURCE) 2> /dev/null

clean:
	@rm -f `find . -name '*.bak' -o -name '*~' -o -name '*%' -o -name '#*' `
	@rm -f $(OBJECT) $(OBJMETA)
	@rm -f $(TARGET)

install:
	@cp -f KPackViewer @prefix@/bin
	@cp -f ./icons/KPackViewer.xpm @kde_icondir@
	@rm -rf @kde_datadir@/KPackViewer
	@mkdir @kde_datadir@/KPackViewer
	@cp -f ./icons/*.xpm @kde_datadir@/KPackViewer
	@cp -f ./kpackviewer.kdelnk @prefix@/share/applnk
	@rm -rf @prefix@/share/doc/HTML/en/KPackViewer
	@mkdir @prefix@/share/doc/HTML/en/KPackViewer
	@cp -f ./html/* @prefix@/share/doc/HTML/en/KPackViewer	
	@cp -f ./po/KPV.fr.mo    @prefix@/share/locale/fr/LC_MESSAGES/KPackViewer.mo
	@cp -f ./po/KPV.pt_BR.mo @prefix@/share/locale/pt_BR/LC_MESSAGES/KPackViewer.mo

register:
	@cp -f ./icons/kpv_mini.xpm @kde_icondir@/mini/KPackViewer.xpm
	@cp -f ./icons/debian_logo.xpm @kde_icondir@/mini/deb_mini.xpm
	@cp -f ./icons/rpmlogo.xpm @kde_icondir@/mini/rpm_mini.xpm
	@cp -f ./icons/slack.xpm @kde_icondir@/mini/slak_mini.xpm
	@cp -f ./icons/zip.xpm @kde_icondir@/mini/zip_mini.xpm
	@cp -f ./x-*.kdelnk @prefix@/share/mimelnk/application

uninstall:
	@rm -f @prefix@/bin/KPackViewer
	@rm -f @kde_icondir@/KPackViewer.xpm
	@rm -rf @kde_datadir@/KPackViewer
	@rm -r @prefix@/share/applnk/kpackviewer.kdelnk
	@rm -rf @prefix@/share/doc/HTML/en/KPackViewer	
	@rm -f @prefix@/share/locale/fr/LC_MESSAGES/KPackViewer.mo
	@rm -f @prefix@/share/locale/pt_BR/LC_MESSAGES/KPackViewer.mo

# DO NOT DELETE THIS LINE -- make depend depends on it.

