~ubuntu-branches/debian/lenny/xserver-xorg-video-suncg14/lenny

2 by Jurij Smakov
* Bump the version of xserver-xorg-core dependency to (>= 2:1.1.1-1).
1
#!/usr/bin/make -f
3 by Julien Cristau, David Nusinow, Brice Goglin, Timo Aaltonen
[ David Nusinow ]
2
# $Id$
2 by Jurij Smakov
* Bump the version of xserver-xorg-core dependency to (>= 2:1.1.1-1).
3
4
# Automagical conversion of autoreconf results into quilt patches.
5
6
# Copyright 2006 Eugene Konev
7
#
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>.
10
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
15
# you are doing.
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
23
# xsfclean like:
24
# - clean: xsfclean
25
# + clean: autoreconf xsfclean
26
# This will ensure it is called when you build package with dpkg-buildpackage.
27
28
# This dir will be used for producing diff of autoreconfed tree
29
RECONF_DIR := xsfautoreconf
30
31
# This files will be checked for changes
32
RECONF_CHECKFILES += configure.ac Makefile.am
33
34
# This files will not be hardlinked but copied
35
RECONF_NOLINKFILES += aclocal.m4
36
37
# This files/dirs will be pruned after autoreconf run
38
RECONF_PRUNEFILES += autom4te.cache config.h.in~ aclocal.m4~
39
40
# Internal target. Never invoke directly.
41
stampdir_target+=check.md5sum
42
$(STAMP_DIR)/check.md5sum:
43
	dh_testdir
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 >>$@; \
48
	done
49
50
# Internal target. Never invoke directly.
51
$(STAMP_DIR)/clean.md5sum:
52
	dh_testdir
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 $@
57
58
# Internal target. Never invoke directly.
59
debian/patches/patched.md5sum:
60
	dh_testdir
61
	[ -f $(STAMP_DIR)/clean.md5sum ] || \
62
	  $(MAKE) -f debian/rules $(STAMP_DIR)/clean.md5sum
63
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; \
70
	else \
71
	  mv $(STAMP_DIR)/check.md5sum $@; \
72
	fi
73
74
# Internal target. Never invoke directly.
75
,PHONY: doautoreconf
76
doautoreconf: patch
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; \
84
	fi
85
86
	if [ -e $(RECONF_DIR) ]; then \
87
	  echo "ERROR: $(RECONF_DIR) already exists. Cleanup by hand"; \
88
	  exit 1; \
89
	fi
90
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/
96
97
	for F in $(RECONF_PRUNEFILES); do \
98
	  find $(RECONF_DIR)/before -name $$F -print | \
99
	    xargs --no-run-if-empty rm -r; \
100
	done
101
102
	cp -al $(RECONF_DIR)/before $(RECONF_DIR)/after
103
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 \
107
	       -print | \
108
	    xargs --no-run-if-empty -i{} cp --remove-destination {} \
109
	      $(RECONF_DIR)/after/{}; \
110
	done
111
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; \
116
	  done
117
118
	cd $(RECONF_DIR) && diff -Nru before after > autoreconf.diff || true
119
120
	quilt import $(RECONF_DIR)/autoreconf.diff \
121
	      >>$(STAMP_DIR)/log/autoreconf 2>&1
122
123
	mv $(STAMP_DIR)/check.md5sum debian/patches/patched.md5sum
124
125
	rm -r $(RECONF_DIR) && rm -f patches/autoreconf-old.diff
126
127
	@echo 
128
	@echo "****************************************************************"
129
	@echo "  This target is made to fail INTENTIONALLY. It should NEVER    "
130
	@echo "  be invoked during automatic builds.                           "
131
	@echo 
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.                                      "
136
	@echo 
137
	@echo "  (See also debian/xsfbs/xsfbs-autoreconf.mk)                   "
138
	@echo 
139
	@echo "  If you see this message, autoreconfing actually SUCCEEDED,    "
140
	@echo "  and your build should finish successfully, when rerun.        "
141
	@echo "****************************************************************"
142
	@echo 
143
	exit 1;
144
145
.PHONY: autoreconf
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; \
150
	fi