File: rules

package info (click to toggle)
pygtk 2.24.0-5.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 26,760 kB
  • ctags: 8,260
  • sloc: xml: 182,079; sh: 10,297; python: 10,161; ansic: 2,861; makefile: 1,358
file content (209 lines) | stat: -rwxr-xr-x 7,373 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/make -f

include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk
-include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

include /usr/share/python/python.mk

CFLAGS += -Wall -g -O$(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),0,2)

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

configure_flags += --prefix=/usr --enable-thread --build=$(DEB_BUILD_GNU_TYPE)

ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	configure_flags += --host=$(DEB_HOST_GNU_TYPE)
endif

PYDEFAULTVER := $(shell pyversions --default --version)
PYVERS := $(shell pyversions --requested --version debian/control)
PYVERS := $(filter-out $(PYDEFAULTVER), $(PYVERS)) $(PYDEFAULTVER)

.PRECIOUS: build-%/configure-stamp dbg-build-%/configure-stamp

patch-stamp:
	dh_testdir
	# backup the original files to restore them in the clean target
	[ ! -r config.sub ]   || \
	    (cp config.sub   config.sub.orig   && \
	     cp /usr/share/misc/config.sub   config.sub)
	[ ! -r config.guess ] || \
	    (cp config.guess config.guess.orig && \
	     cp /usr/share/misc/config.guess config.guess)
	touch $@

patch: patch-stamp

unpatch:
	rm -f patch-stamp
	# restore files from backup (before unpatching)
	[ ! -r config.sub.orig ]   || \
	    cp config.sub.orig   config.sub
	[ ! -r config.guess.orig ]   || \
	    cp config.guess.orig config.guess
	rm -rf .pc

autoreconf-stamp: patch-stamp
	dh_testdir
	dh_autoreconf autoreconf -- -f -i -I m4
	touch $@

build-%/configure-stamp: autoreconf-stamp
	dh_testdir
	mkdir -p build-$*
	cd build-$* && \
		PYTHON=/usr/bin/python$* CFLAGS="$(CFLAGS)" \
			$(CURDIR)/configure $(configure_flags)
	touch $@

build-%/build-stamp: build-%/configure-stamp
	dh_testdir
	PYTHON=/usr/bin/python$* $(MAKE) -C build-$* pyexecdir=$(call py_libdir_sh, $*)
	touch $@

dbg-build-%/configure-stamp: autoreconf-stamp
	dh_testdir
	mkdir -p dbg-build-$*
	cd dbg-build-$* && \
		PYTHON=/usr/bin/python$*-dbg CFLAGS="$(CFLAGS) -O0" \
			$(CURDIR)/configure $(configure_flags)
	touch $@

dbg-build-%/build-stamp: dbg-build-%/configure-stamp
	dh_testdir
	PYTHON=/usr/bin/python$*-dbg $(MAKE) -C dbg-build-$* pyexecdir=$(call py_libdir_sh, $*)
	touch $@

build: $(PYVERS:%=build-%/build-stamp) $(PYVERS:%=dbg-build-%/build-stamp)
build-arch build-indep: build

build-%/check-stamp: build-%/build-stamp
	dh_testdir
	G_HOME=/ PYTHON=/usr/bin/python$* xvfb-run -a -s "-screen 0 1280x1024x24 -noreset" $(MAKE) -C build-$* check
	touch $@

dbg-build-%/check-stamp: dbg-build-%/build-stamp
	dh_testdir
	G_HOME=/ PYTHON=/usr/bin/python$*-dbg xvfb-run -a -s "-screen 0 1280x1024x24 -noreset" $(MAKE) -C dbg-build-$* check
	touch $@

check: $(PYVERS:%=build-%/check-stamp) $(PYVERS:%=dbg-build-%/check-stamp)

build-%/install-stamp: build-%/build-stamp
	dh_testdir
	dh_testroot
	PYTHON=/usr/bin/python$* $(MAKE) -C build-$* install DESTDIR=$(CURDIR)/debian/tmp pyexecdir=$(call py_libdir_sh, $*)
	# move installed files to a per python runtime location to allow
	# comparison of the resulting files across runtimes or shipping
	# multiple versions
	# pkg-config file (this is shipped twice because of varying pyexecdir)
	mkdir debian/tmp/usr/lib/pkgconfig/python$*
	mv debian/tmp/usr/lib/pkgconfig/*.pc debian/tmp/usr/lib/pkgconfig/python$*
	# defs files, should be the same whatever the build-time python runtime
	mkdir debian/tmp/usr/share/pygtk/2.0/defs/python$*
	mv debian/tmp/usr/share/pygtk/2.0/defs/*.defs debian/tmp/usr/share/pygtk/2.0/defs/python$*
	# headers, should be the same whatever the build-time python runtime
	mkdir debian/tmp/usr/include/python$*
	mv debian/tmp/usr/include/pygtk-2.0 debian/tmp/usr/include/python$*

dbg-build-%/install-stamp: dbg-build-%/build-stamp
	dh_testdir
	dh_testroot
	PYTHON=/usr/bin/python$* $(MAKE) -C dbg-build-$* install DESTDIR=$(CURDIR)/debian/python-gtk2-dbg pyexecdir=$(call py_libdir_sh, $*)
	find debian/python-gtk2-dbg ! -type d ! -name '*.so' | xargs rm -f
	find debian/python-gtk2-dbg -depth -empty -exec rmdir {} \;
	touch $@

install-stamp:
	dh_testdir
	dh_testroot
	# remove the install stamps to force a reinstall (since dh_clean is
	# removing the package dirs)
	rm -f $(PYVERS:%=build-%/install-stamp) $(PYVERS:%=dbg-build-%/install-stamp)
	dh_prep
	$(MAKE) -f debian/rules $(PYVERS:%=build-%/install-stamp) $(PYVERS:%=dbg-build-%/install-stamp)
	# check that all builds with various Python runtimes produced the same
	# *.defs files (or fail)
	for v in $(PYVERS); do \
	    echo "Comparing defs files for the default Python version ($(PYDEFAULTVER)) with defs files for Python $$v"; \
	    diff --brief --recursive debian/tmp/usr/share/pygtk/2.0/defs/python$(PYDEFAULTVER) debian/tmp/usr/share/pygtk/2.0/defs/python$$v; \
	    echo "Comparing headers for the default Python version ($(PYDEFAULTVER)) with headers for Python $$v"; \
	    diff --brief --recursive debian/tmp/usr/include/python$(PYDEFAULTVER) debian/tmp/usr/include/python$$v; \
	done
	# since all Python runtimes produced the same files, only keep one set
	echo "Cleaning up"
	mv debian/tmp/usr/share/pygtk/2.0/defs/python$(PYDEFAULTVER)/*.defs debian/tmp/usr/share/pygtk/2.0/defs
	mv debian/tmp/usr/include/python$(PYDEFAULTVER)/* debian/tmp/usr/include
	for v in $(PYVERS); do \
	    rm --force --recursive debian/tmp/usr/share/pygtk/2.0/defs/python$$v; \
	    rm --force --recursive debian/tmp/usr/include/python$$v; \
	done
	# finally, install files from DESTDIR in the per-package dirs
	dh_install
	# install rtupdate script to handle Python default runtime change
	install -d debian/python-gtk2-dev/usr/share/python/runtime.d
	install debian/python-gtk2-dev.rtupdate debian/python-gtk2-dev/usr/share/python/runtime.d
	for i in $$(find debian/python-*-dbg -name '*.so'); do \
	  b=$$(basename $$i .so); \
	  mv $$i $$(dirname $$i)/$${b}_d.so; \
	done

install: install-stamp

clean::
	dh_testdir
	dh_testroot
	rm -f install-stamp
	rm -rf debian/tmp-*
	rm -rf build-* dbg-build-*
	rm -f tests/*.pyc
	rm -f autoreconf-stamp
	dh_autoreconf_clean
	$(MAKE) -f debian/rules unpatch
	dh_clean

maybe_check = $(if $(findstring nocheck,$(DEB_BUILD_OPTIONS)),,check)

binary-indep: build install $(maybe_check)
	dh_testdir
	dh_testroot
	dh_installdocs -i
	dh_installexamples -i
	find debian/python-gtk2-doc/usr/share/doc -name '*.py[co]' -delete
	dh_installchangelogs -i ChangeLog
	dh_link -i
	dh_compress -i -X.py -X.glade
	dh_fixperms -i
	# More permission fixing
	grep -rlZ "^#\!.*python" debian/python-gtk2-dev/usr | xargs -0r chmod 755
	dh_python2 -ppython-gtk2-doc /usr/share/pygtk
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: build install $(maybe_check)
	dh_testdir
	dh_testroot
	dh_installdocs -s
	dh_installexamples -s
	dh_installchangelogs ChangeLog -s
	dh_strip -s -Npython-gtk2-dbg --dbg-package=python-gtk2-dbg
	rm -rf debian/python-gtk2-dbg/usr/share/doc/python-gtk2-dbg
	ln -s python-gtk2 debian/python-gtk2-dbg/usr/share/doc/python-gtk2-dbg
	dh_link -s
	dh_compress -s -X.py -X.glade
	dh_fixperms -s
	dh_python2 -a
	if ! dpkg-vendor --is ubuntu; then \
		dh_numpy -s -ppython-gtk2; \
	fi
	dh_installdeb -s
	dh_shlibdeps -s
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s

binary: binary-arch binary-indep
.PHONY: patch unpatch build-indep build-arch build check install clean binary-indep binary-arch binary