4
# Automagical conversion of autoreconf results into quilt patches.
6
# Copyright 2006 Eugene Konev
8
# Licensed under the GNU General Public License, version 2. See the file
9
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
11
# The idea behind this is storing changes produced by autoreconf as a
12
# separate patch on quilt stack (on top of stack actually).
13
# The only usable target here is 'autoreconf`. Other targets are not
14
# supposed to be called directly. DO NOT invoke them, unless you know what
16
# The autoreconf target will check if files with names in $(RECONF_CHECKFILES)
17
# were changed during patching (from upstream version or from previously
18
# autoreconfed version) and call actual autoreconfing if they were.
19
# The actual autoreconfing target (doautoreconf) WILL FAIL after
20
# calling autoreconf and pushing changes into quilt stack by design. It
21
# should never be invoked by automatic build process.
22
# The proposed use is adding autoreconf into clean's prerequisites before
25
# + clean: autoreconf xsfclean
26
# This will ensure it is called when you build package with dpkg-buildpackage.
28
# This dir will be used for producing diff of autoreconfed tree
29
RECONF_DIR := xsfautoreconf
31
# This files will be checked for changes
32
RECONF_CHECKFILES += configure.ac Makefile.am
34
# This files will not be hardlinked but copied
35
RECONF_NOLINKFILES += aclocal.m4
37
# This files/dirs will be pruned after autoreconf run
38
RECONF_PRUNEFILES += autom4te.cache config.h.in~ aclocal.m4~
40
# Internal target. Never invoke directly.
41
stampdir_target+=check.md5sum
42
$(STAMP_DIR)/check.md5sum:
44
$(MAKE) -f debian/rules prepare
45
for F in $(RECONF_CHECKFILES); do \
46
find . -wholename ./$(STAMP_DIR) -prune -o -name $$F -print | \
47
LC_ALL=C sort | xargs --no-run-if-empty md5sum >>$@; \
50
# Internal target. Never invoke directly.
51
$(STAMP_DIR)/clean.md5sum:
53
$(MAKE) -f debian/rules unpatch
54
rm -f $(STAMP_DIR)/check.md5sum
55
$(MAKE) -f debian/rules $(STAMP_DIR)/check.md5sum
56
mv $(STAMP_DIR)/check.md5sum $@
58
# Internal target. Never invoke directly.
59
debian/patches/patched.md5sum:
61
[ -f $(STAMP_DIR)/clean.md5sum ] || \
62
$(MAKE) -f debian/rules $(STAMP_DIR)/clean.md5sum
64
$(MAKE) -f debian/rules patch
65
rm -f $(STAMP_DIR)/check.md5sum
66
$(MAKE) -f debian/rules $(STAMP_DIR)/check.md5sum
67
if ! diff $(STAMP_DIR)/clean.md5sum \
68
$(STAMP_DIR)/check.md5sum > /dev/null; then \
69
$(MAKE) -f debian/rules doautoreconf; \
71
mv $(STAMP_DIR)/check.md5sum $@; \
74
# Internal target. Never invoke directly.
77
quilt push -a >>$(STAMP_DIR)/log/autoreconf 2>&1 || true
78
if quilt applied | grep ^autoreconf.diff$$ > /dev/null; then \
79
quilt pop -a >>$(STAMP_DIR)/log/autoreconf 2>&1; \
80
quilt rename -p autoreconf.diff autoreconf-old.diff \
81
>>$(STAMP_DIR)/log/autoreconf 2>&1; \
82
quilt delete autoreconf-old.diff >>$(STAMP_DIR)/log/autoreconf 2>&1; \
83
quilt push -a >>$(STAMP_DIR)/log/autoreconf 2>&1; \
86
if [ -e $(RECONF_DIR) ]; then \
87
echo "ERROR: $(RECONF_DIR) already exists. Cleanup by hand"; \
91
mkdir -p $(RECONF_DIR)/before
92
find . -maxdepth 1 -mindepth 1 ! -wholename ./$(RECONF_DIR) \
93
-a ! -wholename ./debian -a ! -wholename ./patches \
94
-a ! -wholename ./.pc -a ! -wholename ./$(STAMP_DIR) | \
95
xargs -i{} cp -al {} $(RECONF_DIR)/before/
97
for F in $(RECONF_PRUNEFILES); do \
98
find $(RECONF_DIR)/before -name $$F -print | \
99
xargs --no-run-if-empty rm -r; \
102
cp -al $(RECONF_DIR)/before $(RECONF_DIR)/after
104
for F in $(RECONF_NOLINKFILES); do \
105
find . -wholename ./$(RECONF_DIR) -prune -o -wholename ./debian \
106
-prune -o -wholename ./$(STAMP_DIR) -prune -o -name $$F \
108
xargs --no-run-if-empty -i{} cp --remove-destination {} \
109
$(RECONF_DIR)/after/{}; \
112
cd $(RECONF_DIR)/after && autoreconf -v --install && \
113
for F in $(RECONF_PRUNEFILES); do \
114
find . -name $$F -print | \
115
xargs --no-run-if-empty rm -r; \
118
cd $(RECONF_DIR) && diff -Nru before after > autoreconf.diff || true
120
quilt import $(RECONF_DIR)/autoreconf.diff \
121
>>$(STAMP_DIR)/log/autoreconf 2>&1
123
mv $(STAMP_DIR)/check.md5sum debian/patches/patched.md5sum
125
rm -r $(RECONF_DIR) && rm -f patches/autoreconf-old.diff
128
@echo "****************************************************************"
129
@echo " This target is made to fail INTENTIONALLY. It should NEVER "
130
@echo " be invoked during automatic builds. "
132
@echo " This target was invoked because you added/removed/changed "
133
@echo " patches which modify either configure.ac or Makefile.am and, "
134
@echo " thus, require autoreconf run. And all autoreconfing should "
135
@echo " happen before uploading. "
137
@echo " (See also debian/xsfbs/xsfbs-autoreconf.mk) "
139
@echo " If you see this message, autoreconfing actually SUCCEEDED, "
140
@echo " and your build should finish successfully, when rerun. "
141
@echo "****************************************************************"
146
autoreconf: debian/patches/patched.md5sum patch $(STAMP_DIR)/check.md5sum
147
if ! diff $(STAMP_DIR)/check.md5sum \
148
debian/patches/patched.md5sum > /dev/null; then \
149
$(MAKE) -f debian/rules doautoreconf; \