DISTPATH = $(shell pwd)
DISTDIR = $(shell basename $(DISTPATH))

SUBDIRS = libical/src/libical libical/src/libicalss qtcompat microkde \
   libkcal libkdepim kabc libkabcwrap pluginqtopiakabc pluginopiekabc \
	 korganizer kalarmd kaddressbook
all: tmake
	for i in $(SUBDIRS); do pushd $$i; \
          make -f Makefile$(PLATFORM) || exit 1; popd; \
          done

objects:
	for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done

clean:
	for i in $(SUBDIRS); do pushd $$i; make clean; \
          rm -f obj/$(PLATFORM)/*; rm -f moc/*; rm Makefile$(PLATFORM); popd; \
          done

install:
    cd bin/kdepimpi; make install
	cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop
	cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop

dist:
	@echo Dont forget to do "make install" before "make dist"
	cd ..; tar czf korge-dist.src.tgz --exclude=obj --exclude=moc $(DISTDIR)
	tar czPf ../korge-dist.i386.tgz  \
		/opt/Qtopia/bin/korganizer \
		/opt/Qtopia/apps/Applications/korganizer.desktop \
		/opt/Qtopia/pics/KOrganizer.png \
		/opt/Qtopia/pics/korganizer

tmake: objects qtcompat/Makefile$(PLATFORM) microkde/Makefile$(PLATFORM) \
       libkcal/Makefile$(PLATFORM) \
       libkabcwrap/Makefile$(PLATFORM) \
       pluginqtopiakabc/Makefile$(PLATFORM) \
       pluginopiekabc/Makefile$(PLATFORM) \
       libkdepim/Makefile$(PLATFORM) korganizer/Makefile$(PLATFORM) \
       kalarmd/Makefile$(PLATFORM) \
       libical/src/libical/Makefile$(PLATFORM) \
       libical/src/libicalss/Makefile$(PLATFORM) \
       kabc/Makefile$(PLATFORM) \
       kaddressbook/Makefile$(PLATFORM)

qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro
	cd qtcompat; tmake qtcompat.pro -o Makefile$(PLATFORM)

microkde/Makefile$(PLATFORM): microkde/microkdeE.pro
	cd microkde; tmake microkdeE.pro -o Makefile$(PLATFORM)

libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro
	cd libkcal; tmake libkcalE.pro -o Makefile$(PLATFORM)

libkabcwrap/Makefile$(PLATFORM): libkabcwrap/libkabcwrapE.pro
	cd libkabcwrap; tmake libkabcwrapE.pro -o Makefile$(PLATFORM)

pluginqtopiakabc/Makefile$(PLATFORM): pluginqtopiakabc/pluginqtopiakabcE.pro
	cd pluginqtopiakabc; tmake pluginqtopiakabcE.pro -o Makefile$(PLATFORM)

pluginopiekabc/Makefile$(PLATFORM): pluginopiekabc/pluginopiekabcE.pro
	cd pluginopiekabc; tmake pluginopiekabcE.pro -o Makefile$(PLATFORM)


libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro
	cd libkdepim; tmake libkdepimE.pro -o Makefile$(PLATFORM)

kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro
	cd kalarmd; tmake kalarmdE.pro -o Makefile$(PLATFORM)

korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro
	cd korganizer; tmake korganizerE.pro -o Makefile$(PLATFORM)

libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro
	cd libical/src/libical; tmake libicalE.pro -o Makefile$(PLATFORM)

libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro
	cd libical/src/libicalss; tmake libicalssE.pro -o Makefile$(PLATFORM)

kabc/Makefile$(PLATFORM): kabc/kabcE.pro
	cd kabc; tmake kabcE.pro -o Makefile$(PLATFORM)

kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro
	cd kaddressbook; tmake kaddressbookE.pro -o Makefile$(PLATFORM)