Author: dnusinow
Date: 2006-02-26 23:48:29 -0500 (Sun, 26 Feb 2006)
New Revision: 1351

Added:
   trunk/xsfbs/xsfbs-autoreconf.mk
Modified:
   trunk/xsfbs/xsfbs.mk
Log:
Add xsfbs-autoreconf.mk, written by Eugene Konev.

Added: trunk/xsfbs/xsfbs-autoreconf.mk
===================================================================
--- trunk/xsfbs/xsfbs-autoreconf.mk     2006-02-27 04:35:37 UTC (rev 1350)
+++ trunk/xsfbs/xsfbs-autoreconf.mk     2006-02-27 04:48:29 UTC (rev 1351)
@@ -0,0 +1,120 @@
+#!/usr/bin/make -f
+# $Id$
+
+# Automagical conversion of autoreconf results into quilt patches.
+
+# Copyright 2006 Eugene Konev
+#
+# Licensed under the GNU General Public License, version 2.  See the file
+# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
+
+# The idea behind this is storing changes produced by autoreconf as a 
+# separate patch on quilt stack (on top of stack actually).
+# The only usable target here is 'autoreconf`. Other targets are not
+# supposed to be called directly. DO NOT invoke them, unless you know what
+# you are doing.
+# The autoreconf target will check if configure.ac and/or Makefile.am's 
+# were changed during patching (from upstream version or from previously
+# autoreconfed version) and call actual autoreconfing if they were.
+# The actual autoreconfing target (doautoreconf) WILL FAIL after 
+# calling autoreconf and pushing changes into quilt stack by design. It
+# should never be invoked by automatic build process.
+# The proposed use is including xsfbs-autoreconf.mk AFTER xsfbs.mk, as it 
+# depends on some targets from xsfbs.mk and adding autoreconf into clean's 
+# prerequisites before xsfclean like:
+# - clean: xsfclean
+# + clean: autoreconf xsfclean
+# This will ensure it is called when you build package with dpkg-buildpackage.
+
+# This dir will be used for producing diff of autoreconfed tree
+RECONF_DIR:=xsfautoreconf
+
+# Internal target. Never invoke directly.
+stampdir_target+=check.md5sum
+$(STAMP_DIR)/check.md5sum:
+       dh_testdir
+       $(MAKE) -f debian/rules prepare
+       find . -wholename ./$(STAMP_DIR) -prune -o -name configure.ac -print \
+              -o -name Makefile.am -print | xargs md5sum >$@
+
+# Internal target. Never invoke directly.
+debian/patches/clean.md5sum:
+       dh_testdir
+       $(MAKE) -f debian/rules unpatch
+       rm -f $(STAMP_DIR)/check.md5sum
+       $(MAKE) -f debian/rules $(STAMP_DIR)/check.md5sum
+       mv $(STAMP_DIR)/check.md5sum $@
+
+# Internal target. Never invoke directly.
+debian/patches/patched.md5sum: debian/patches/clean.md5sum
+       dh_testdir
+       $(MAKE) -f debian/rules patch
+       rm -f $(STAMP_DIR)/check.md5sum
+       $(MAKE) -f debian/rules $(STAMP_DIR)/check.md5sum
+       if ! diff debian/patches/clean.md5sum \
+                 $(STAMP_DIR)/check.md5sum > /dev/null; then \
+         $(MAKE) -f debian/rules doautoreconf; \
+       else \
+         mv $(STAMP_DIR)/check.md5sum $@; \
+       fi
+
+# Internal target. Never invoke directly.
+,PHONY: doautoreconf
+doautoreconf: patch
+       quilt push -a >$(STAMP_DIR)/log/autoreconf 2>&1 || true
+       if quilt applied | grep ^autoreconf.diff$$ > /dev/null; then \
+         quilt pop -a >$(STAMP_DIR)/log/autoreconf 2>&1; \
+         quilt rename -p autoreconf.diff autoreconf-old.diff \
+              >$(STAMP_DIR)/log/autoreconf 2>&1; \
+         quilt delete autoreconf-old.diff >$(STAMP_DIR)/log/autoreconf 2>&1; \
+         quilt push -a >$(STAMP_DIR)/log/autoreconf 2>&1; \
+       fi
+
+       if [ -e $(RECONF_DIR) ]; then \
+         echo "ERROR: $(RECONF_DIR) already exists. Cleanup by hand"; \
+         exit 1; \
+       fi
+
+       mkdir -p $(RECONF_DIR)/before
+       find . -maxdepth 1 -mindepth 1 ! -wholename ./$(RECONF_DIR) \
+            -a ! -wholename ./debian -a ! -wholename ./patches \
+            -a ! -wholename ./.pc -a ! -wholename ./$(STAMP_DIR) | \
+         xargs -i{} cp -al {} $(RECONF_DIR)/before
+       cp -al $(RECONF_DIR)/before $(RECONF_DIR)/after
+
+       cd $(RECONF_DIR)/after && autoreconf -v --install && \
+         rm -r autom4te.cache && rm -f *~
+
+       cd $(RECONF_DIR) && diff -Nru before after > autoreconf.diff || true
+
+       quilt import $(RECONF_DIR)/autoreconf.diff \
+             >$(STAMP_DIR)/log/autoreconf 2>&1
+
+       mv $(STAMP_DIR)/check.md5sum debian/patches/patched.md5sum
+
+       rm -r $(RECONF_DIR) && rm -f patches/autoreconf-old.diff
+
+       @echo 
+       @echo "****************************************************************"
+       @echo "  This target is made to fail INTENTIONALLY. It should NEVER    "
+       @echo "  be invoked during automatic builds.                           "
+       @echo 
+       @echo "  This target was invoked because you added/removed/changed     "
+       @echo "  patches which modify either configure.ac or Makefile.am and,  "
+       @echo "  thus, require autoreconf run. And all autoreconfing should    "
+       @echo "  happen before uploading.                                      "
+       @echo 
+       @echo "  (See also debian/xsfbs/xsfbs-autoreconf.mk)                   "
+       @echo 
+       @echo "  If you see this message, autoreconfing actually SUCCEEDED,    "
+       @echo "  and your build should finish successfully, when rerun.        "
+       @echo "****************************************************************"
+       @echo 
+       exit 1;
+
+.PHONY: autoreconf
+autoreconf: debian/patches/clean.md5sum patch debian/patches/patched.md5sum 
$(STAMP_DIR)/check.md5sum
+       if ! diff $(STAMP_DIR)/check.md5sum \
+                 debian/patches/patched.md5sum > /dev/null; then \
+         $(MAKE) -f debian/rules doautoreconf; \
+       fi

Modified: trunk/xsfbs/xsfbs.mk
===================================================================
--- trunk/xsfbs/xsfbs.mk        2006-02-27 04:35:37 UTC (rev 1350)
+++ trunk/xsfbs/xsfbs.mk        2006-02-27 04:48:29 UTC (rev 1351)
@@ -19,6 +19,8 @@
 # Modified by David Nusinow <[EMAIL PROTECTED]>
 # Acknowledgements to Manoj Srivastava.
 
+include debian/xsfbs/xsfbs-autoreconf.mk
+
 # Pass $(DH_OPTIONS) into the environment for debhelper's benefit.
 export DH_OPTIONS
 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to