QT=$(shell ls -1 | sed -n 's/\(qt-.*\)\.tar\.gz/\1/p')
PREFIX=/usr/local/trolltech/qt

all: build-lin32 build

maintainer-clean: clean
	-rm -rf ${QT} ${QT}-lin32

install: install-lin32
	rm -rf ${PREFIX}
	cd ${QT} && make install

${QT}: ${QT}.tar.gz
	tar xzvf $<
	cd $@ && patch -p1 < ../patch/qt-sources-patch.diff

build: ${QT}
	-cd $< && make confclean
	cd $< && (echo "yes" | ./configure -opensource -prefix ${PREFIX})
	cd $< && make

install-lin32:
	rm -rf ${PREFIX}-32bit
	cd ${QT}-lin32 && make install

${QT}-lin32: ${QT}
	cp -a $< $@

build-lin32: ${QT}-lin32
	-cd $< && make confclean
	cd $< && (echo "yes" | ./configure -opensource -platform linux-g++-32 -prefix ${PREFIX}-32bit)
	cd $< && make

.PHONY: maintainer-clean all build install  build-lin32 install-lin32