diff -ruN -x .svn ../../ffmpeg-free-pkg/debian/changelog ./debian/changelog
--- ../../ffmpeg-free-pkg/debian/changelog	2008-06-26 17:12:15.000000000 +0100
+++ ./debian/changelog	2008-06-26 17:52:07.000000000 +0100
@@ -26,6 +26,16 @@
     + Removed ffmpeg-config, use pkg-config instead (maintainers of affected
       packages have been informed, see #487917 to #487922).
 
+  [ Darren Salt ]
+  * Added patch 900_doxyfile: tell doxyfile to ignore debian* directories.
+  * debian/rules:
+    - Reworked building so that separate source & build directories are
+      used. This makes cleanup simpler and speeds up maintenance by avoiding
+      complete rebuilds when using "debuild binary".
+    - Removed some file installation 'cp' commands, made unnecessary due to
+      the build reworking.
+    - Unpatching is now done *after* cleaning.
+
  -- Fabian Greffrath <fabian@debian-unofficial.org>  Wed, 25 Jun 2008 10:26:13 +0200
 
 ffmpeg-free (0.svn20080206-8) unstable; urgency=low
diff -ruN -x .svn ../../ffmpeg-free-pkg/debian/patches/900_doxyfile ./debian/patches/900_doxyfile
--- ../../ffmpeg-free-pkg/debian/patches/900_doxyfile	1970-01-01 01:00:00.000000000 +0100
+++ ./debian/patches/900_doxyfile	2008-06-26 17:01:36.000000000 +0100
@@ -0,0 +1,13 @@
+Index: ffmpeg-0.svn20080626/Doxyfile
+===================================================================
+--- ffmpeg-0.svn20080626.orig/Doxyfile	2008-06-26 15:36:33.000000000 +0100
++++ ffmpeg-0.svn20080626/Doxyfile	2008-06-26 15:37:40.000000000 +0100
+@@ -359,7 +359,7 @@
+ # excluded from the INPUT source files. This way you can easily exclude a
+ # subdirectory from a directory tree whose root is specified with the INPUT tag.
+ 
+-EXCLUDE                =
++EXCLUDE                = debian debian-shared debian-static
+ 
+ # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
+ # that are symbolic links (a Unix filesystem feature) are excluded from the input.
diff -ruN -x .svn ../../ffmpeg-free-pkg/debian/patches/series ./debian/patches/series
--- ../../ffmpeg-free-pkg/debian/patches/series	2008-06-26 17:12:15.000000000 +0100
+++ ./debian/patches/series	2008-06-26 17:30:12.000000000 +0100
@@ -3,3 +3,4 @@
 015_reenable-img_convert.diff
 020_fix_libswscale_pic_code
 300_c++_compliant_headers.diff
+900_doxyfile
diff -ruN -x .svn ../../ffmpeg-free-pkg/debian/rules ./debian/rules
--- ../../ffmpeg-free-pkg/debian/rules	2008-06-26 17:12:15.000000000 +0100
+++ ./debian/rules	2008-06-26 17:44:58.000000000 +0100
@@ -101,68 +101,76 @@
 config-extra-includes.h:
 	sh debian/fixup-config.sh > config-extra-includes.h
 
-build: config-extra-includes.h $(QUILT_STAMPFN) build-stamp
-build-stamp:
+configure-static: configure-static-stamp
+configure-static-stamp: $(QUILT_STAMPFN) config-extra-includes.h
 	dh_testdir
-
-	# Build static libraries
-	./configure $(static_build_confflags)
+	mkdir -p debian-static
+	cd debian-static && ../configure $(static_build_confflags)
 
 ifeq (,$(findstring internalencoders,$(DEB_BUILD_OPTIONS)))
-	echo "#include \"config-extra-includes.h\"" >> config.h
+	echo "#include \"config-extra-includes.h\"" >> debian-static/config.h
 endif
 
-	$(MAKE) -j $(NJOBS)
-
-	# Backup static libraries
-	for d in $(LIBS); do \
-	  mv -f $$d/$$d.a $$d/$$d.a.bak ; \
-	done
-
-	$(MAKE) clean
+	touch $@
 
-	# Build ffmpeg and shared libraries
-	./configure $(shared_build_confflags)
+configure-shared: configure-shared-stamp
+configure-shared-stamp: $(QUILT_STAMPFN) config-extra-includes.h
+	dh_testdir
+	mkdir -p debian-shared
+	cd debian-shared && ../configure $(shared_build_confflags)
 
 ifeq (,$(findstring internalencoders,$(DEB_BUILD_OPTIONS)))
-	echo "#include \"config-extra-includes.h\"" >> config.h
+	echo "#include \"config-extra-includes.h\"" >> debian-shared/config.h
 endif
 
-	$(MAKE) -j $(NJOBS)
+	touch $@
 
-	# Restore static libraries and fix timestamps
-	for d in $(LIBS); do \
-	  mv -f $$d/$$d.a.bak $$d/$$d.a ; \
-	  touch $$d/$$d.a ; \
-	done
-	touch ffmpeg ffmpeg_g ffplay ffplay_g
+build-static: build-static-stamp
+build-static-stamp: configure-static-stamp
+	dh_testdir
 
-	# Build qt-faststart
-	$(MAKE) tools/qt-faststart
+	# Build static libraries
+	$(MAKE) -C debian-static -j $(NJOBS)
 
-	# Build doxygen documentation
-	doxygen
+	touch $@
+
+build-shared: build-shared-stamp
+build-shared-stamp: configure-shared-stamp
+	dh_testdir
+
+	# Build ffmpeg and shared libraries
+	$(MAKE) -C debian-shared -j $(NJOBS)
+
+	# Build qt-faststart
+	$(MAKE) -C debian-shared tools/qt-faststart
 
 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
-	-$(MAKE) test
+	-$(MAKE) -C debian-shared test
 endif
 
 	touch $@
 
-clean: unpatch
+build-doxy: build-doxy-stamp
+build-doxy-stamp:
+	dh_testdir
+	# Build doxygen documentation
+	doxygen
+	touch $@
+
+build: build-stamp
+build-stamp: config-extra-includes.h build-static build-shared build-doxy
+	touch $@
+
+clean: clean-real unpatch
+clean-real:
 	dh_testdir
 	dh_testroot
-	rm -f build-stamp
-	[ ! -f Makefile ] || [ ! -f config.mak ] || $(MAKE) distclean
-	for d in $(LIBS); do \
-	  rm -f $$d/$$d.a.bak $$d-unistalled.pc $$d.pc ; \
-	done
-	rm -rf doxy/
-	dh_clean config.log config-extra-includes.h config.h
+	rm -f build-stamp build-*-stamp configure-*-stamp patch-stamp
+	rm -rf debian-static debian-shared doxy
+	dh_clean config-extra-includes.h debian/tmp.debhelper.log
 
 get-orig-source:
 	dh_testdir
-
 ifeq (,$(findstring internalencoders,$(DEB_BUILD_OPTIONS)))
         # Disable potentially dangerous patented code
 	chmod +x debian/strip.sh
@@ -178,21 +186,17 @@
 	dh_testdir
 	dh_testroot
 	dh_clean -k
-	dh_installdirs -ptmp usr/share/doc/ffmpeg/html etc usr/include/ffmpeg
-	dh_installdirs -ptmp usr/lib usr/bin usr/share/man/man1 usr/include/postproc
+	dh_installdirs -ptmp usr/share/doc/ffmpeg/html etc
 	dh_installdirs -ptmp usr/share/doc/ffmpeg-doc/html
 
-	$(MAKE) install DESTDIR=`pwd`/debian/tmp/ mandir=`pwd`/debian/tmp/usr/share/man
-	cp libavcodec/dsputil.h debian/tmp/usr/include/ffmpeg
-	cp libpostproc/libpostproc.a debian/tmp/usr/lib
-	cp libpostproc/postprocess.h debian/tmp/usr/include/postproc
-	cp libpostproc.pc debian/tmp/usr/lib/pkgconfig/
-	for d in $(LIBS); do cp $$d/$$d.so* debian/tmp/usr/lib; done
-	cp doc/*.html debian/tmp/usr/share/doc/ffmpeg/html/
+	$(MAKE) -C debian-static install DESTDIR=`pwd`/debian/tmp/ mandir=`pwd`/debian/tmp/usr/share/man
+	$(MAKE) -C debian-shared install DESTDIR=`pwd`/debian/tmp/ mandir=`pwd`/debian/tmp/usr/share/man
+	cp -a libavcodec/dsputil.h debian/tmp/usr/include/ffmpeg
+	cp debian-shared/doc/*.html debian/tmp/usr/share/doc/ffmpeg/html/
 	cp doxy/html/* debian/tmp/usr/share/doc/ffmpeg-doc/html/
 	cp doc/ffserver.conf debian/tmp/etc/
 
-	cp tools/qt-faststart debian/tmp/usr/bin/qt-faststart
+	cp debian-shared/tools/qt-faststart debian/tmp/usr/bin/qt-faststart
 
 	dh_install --fail-missing --sourcedir=debian/tmp
 
@@ -223,4 +227,10 @@
 	dh_builddeb
 
 binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
+
+.PHONY: build build-shared build-static build-doxy \
+	clean clean-real \
+	configure configure-shared configure-static \
+	binary binary-indep binary-arch \
+	install \
+	patch
