| 1 | #!/usr/bin/make -f |
|---|
| 2 | |
|---|
| 3 | include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk |
|---|
| 4 | -include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk |
|---|
| 5 | |
|---|
| 6 | CFLAGS += -Wall -g -O$(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),0,2) |
|---|
| 7 | |
|---|
| 8 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) |
|---|
| 9 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) |
|---|
| 10 | |
|---|
| 11 | configure_flags += --prefix=/usr --enable-thread --build=$(DEB_BUILD_GNU_TYPE) |
|---|
| 12 | |
|---|
| 13 | ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) |
|---|
| 14 | configure_flags += --host=$(DEB_HOST_GNU_TYPE) |
|---|
| 15 | endif |
|---|
| 16 | |
|---|
| 17 | PYDEFAULTVER := $(shell pyversions --default --version) |
|---|
| 18 | PYVERS := $(shell pyversions --requested --version debian/control) |
|---|
| 19 | PYVERS := $(filter-out $(PYDEFAULTVER), $(PYVERS)) $(PYDEFAULTVER) |
|---|
| 20 | |
|---|
| 21 | .PRECIOUS: build-%/configure-stamp dbg-build-%/configure-stamp |
|---|
| 22 | |
|---|
| 23 | # how to call quilt |
|---|
| 24 | PATCH_DIR := $(CURDIR)/debian/patches |
|---|
| 25 | QUILT := QUILT_PATCHES=$(PATCH_DIR) quilt --quiltrc /dev/null |
|---|
| 26 | |
|---|
| 27 | patch-stamp: |
|---|
| 28 | dh_testdir |
|---|
| 29 | # apply patches |
|---|
| 30 | $(QUILT) push -a || test $$? = 2 |
|---|
| 31 | # backup the original files to restore them in the clean target |
|---|
| 32 | [ ! -r config.sub ] || \ |
|---|
| 33 | (cp config.sub config.sub.orig && \ |
|---|
| 34 | cp /usr/share/misc/config.sub config.sub) |
|---|
| 35 | [ ! -r config.guess ] || \ |
|---|
| 36 | (cp config.guess config.guess.orig && \ |
|---|
| 37 | cp /usr/share/misc/config.guess config.guess) |
|---|
| 38 | touch $@ |
|---|
| 39 | |
|---|
| 40 | patch: patch-stamp |
|---|
| 41 | |
|---|
| 42 | unpatch: |
|---|
| 43 | rm -f patch-stamp |
|---|
| 44 | # restore files from backup (before unpatching) |
|---|
| 45 | [ ! -r config.sub.orig ] || \ |
|---|
| 46 | cp config.sub.orig config.sub |
|---|
| 47 | [ ! -r config.guess.orig ] || \ |
|---|
| 48 | cp config.guess.orig config.guess |
|---|
| 49 | # unapply patches, if any |
|---|
| 50 | $(QUILT) pop -a || test $$? = 2 |
|---|
| 51 | rm -rf .pc |
|---|
| 52 | |
|---|
| 53 | build-%/configure-stamp: patch-stamp |
|---|
| 54 | dh_testdir |
|---|
| 55 | mkdir -p build-$* |
|---|
| 56 | cd build-$* && \ |
|---|
| 57 | PYTHON=/usr/bin/python$* CFLAGS="$(CFLAGS)" \ |
|---|
| 58 | $(CURDIR)/configure $(configure_flags) |
|---|
| 59 | touch $@ |
|---|
| 60 | |
|---|
| 61 | build-%/build-stamp: build-%/configure-stamp |
|---|
| 62 | dh_testdir |
|---|
| 63 | PYTHON=/usr/bin/python$* $(MAKE) -C build-$* pyexecdir=/var/lib/python-support/python$* |
|---|
| 64 | xvfb-run -s -noreset $(MAKE) -C build-$* check |
|---|
| 65 | touch $@ |
|---|
| 66 | |
|---|
| 67 | dbg-build-%/configure-stamp: patch-stamp |
|---|
| 68 | dh_testdir |
|---|
| 69 | mkdir -p dbg-build-$* |
|---|
| 70 | cd dbg-build-$* && \ |
|---|
| 71 | PYTHON=/usr/bin/python$*-dbg CFLAGS="$(CFLAGS) -O0" \ |
|---|
| 72 | $(CURDIR)/configure $(configure_flags) |
|---|
| 73 | touch $@ |
|---|
| 74 | |
|---|
| 75 | dbg-build-%/build-stamp: dbg-build-%/configure-stamp |
|---|
| 76 | dh_testdir |
|---|
| 77 | PYTHON=/usr/bin/python$*-dbg $(MAKE) -C dbg-build-$* |
|---|
| 78 | touch $@ |
|---|
| 79 | |
|---|
| 80 | build: $(PYVERS:%=build-%/build-stamp) $(PYVERS:%=dbg-build-%/build-stamp) |
|---|
| 81 | |
|---|
| 82 | build-%/install-stamp: build-%/build-stamp |
|---|
| 83 | dh_testdir |
|---|
| 84 | dh_testroot |
|---|
| 85 | PYTHON=/usr/bin/python$* $(MAKE) -C build-$* install DESTDIR=$(CURDIR)/debian/tmp pyexecdir=/var/lib/python-support/python$* |
|---|
| 86 | # move installed files to a per python runtime location to allow |
|---|
| 87 | # comparison of the resulting files across runtimes or shipping |
|---|
| 88 | # multiple versions |
|---|
| 89 | # pkg-config file (this is shipped twice because of varying pyexecdir) |
|---|
| 90 | mkdir debian/tmp/usr/lib/pkgconfig/python$* |
|---|
| 91 | mv debian/tmp/usr/lib/pkgconfig/*.pc debian/tmp/usr/lib/pkgconfig/python$* |
|---|
| 92 | # defs files, should be the same whatever the build-time python runtime |
|---|
| 93 | mkdir debian/tmp/usr/share/pygtk/2.0/defs/python$* |
|---|
| 94 | mv debian/tmp/usr/share/pygtk/2.0/defs/*.defs debian/tmp/usr/share/pygtk/2.0/defs/python$* |
|---|
| 95 | # headers, should be the same whatever the build-time python runtime |
|---|
| 96 | mkdir debian/tmp/usr/include/python$* |
|---|
| 97 | mv debian/tmp/usr/include/pygtk-2.0 debian/tmp/usr/include/python$* |
|---|
| 98 | |
|---|
| 99 | dbg-build-%/install-stamp: dbg-build-%/build-stamp |
|---|
| 100 | dh_testdir |
|---|
| 101 | dh_testroot |
|---|
| 102 | PYTHON=/usr/bin/python$* $(MAKE) -C dbg-build-$* install DESTDIR=$(CURDIR)/debian/python-gtk2-dbg |
|---|
| 103 | find debian/python-gtk2-dbg ! -type d ! -name '*.so' | xargs rm -f |
|---|
| 104 | find debian/python-gtk2-dbg -depth -empty -exec rmdir {} \; |
|---|
| 105 | touch $@ |
|---|
| 106 | |
|---|
| 107 | install-stamp: |
|---|
| 108 | dh_testdir |
|---|
| 109 | dh_testroot |
|---|
| 110 | # remove the install stamps to force a reinstall (since dh_clean is |
|---|
| 111 | # removing the package dirs) |
|---|
| 112 | dh_clean -k $(PYVERS:%=build-%/install-stamp) $(PYVERS:%=dbg-build-%/install-stamp) |
|---|
| 113 | $(MAKE) -f debian/rules $(PYVERS:%=build-%/install-stamp) $(PYVERS:%=dbg-build-%/install-stamp) |
|---|
| 114 | # check that all builds with various Python runtimes produced the same |
|---|
| 115 | # *.defs files (or fail) |
|---|
| 116 | for v in $(PYVERS); do \ |
|---|
| 117 | echo "Comparing defs files for the default Python version ($(PYDEFAULTVER)) with defs files for Python $$v"; \ |
|---|
| 118 | diff --brief --recursive debian/tmp/usr/share/pygtk/2.0/defs/python$(PYDEFAULTVER) debian/tmp/usr/share/pygtk/2.0/defs/python$$v; \ |
|---|
| 119 | echo "Comparing headers for the default Python version ($(PYDEFAULTVER)) with headers for Python $$v"; \ |
|---|
| 120 | diff --brief --recursive debian/tmp/usr/include/python$(PYDEFAULTVER) debian/tmp/usr/include/python$$v; \ |
|---|
| 121 | done |
|---|
| 122 | # since all Python runtimes produced the same files, only keep one set |
|---|
| 123 | echo "Cleaning up" |
|---|
| 124 | mv debian/tmp/usr/share/pygtk/2.0/defs/python$(PYDEFAULTVER)/*.defs debian/tmp/usr/share/pygtk/2.0/defs |
|---|
| 125 | mv debian/tmp/usr/include/python$(PYDEFAULTVER)/* debian/tmp/usr/include |
|---|
| 126 | for v in $(PYVERS); do \ |
|---|
| 127 | rm --force --recursive debian/tmp/usr/share/pygtk/2.0/defs/python$$v; \ |
|---|
| 128 | rm --force --recursive debian/tmp/usr/share/include/python$$v; \ |
|---|
| 129 | done |
|---|
| 130 | # finally, install files from DESTDIR in the per-package dirs |
|---|
| 131 | dh_install |
|---|
| 132 | # install rtupdate script to handle Python default runtime change |
|---|
| 133 | install -d debian/python-gtk2-dev/usr/share/python/runtime.d |
|---|
| 134 | install debian/python-gtk2-dev.rtupdate debian/python-gtk2-dev/usr/share/python/runtime.d |
|---|
| 135 | for i in $$(find debian/python-*-dbg -name '*.so'); do \ |
|---|
| 136 | b=$$(basename $$i .so); \ |
|---|
| 137 | mv $$i $$(dirname $$i)/$${b}_d.so; \ |
|---|
| 138 | done |
|---|
| 139 | |
|---|
| 140 | install: install-stamp |
|---|
| 141 | |
|---|
| 142 | clean:: |
|---|
| 143 | dh_testdir |
|---|
| 144 | dh_testroot |
|---|
| 145 | rm -f install-stamp |
|---|
| 146 | rm -rf debian/tmp-* |
|---|
| 147 | rm -rf build-* dbg-build-* |
|---|
| 148 | $(MAKE) -f debian/rules unpatch |
|---|
| 149 | dh_clean |
|---|
| 150 | |
|---|
| 151 | binary-indep: build install |
|---|
| 152 | dh_testdir |
|---|
| 153 | dh_testroot |
|---|
| 154 | dh_installdocs -i |
|---|
| 155 | dh_installexamples -i |
|---|
| 156 | find debian/python-gtk2-doc/usr/share/doc -name '*.py[co]' -delete |
|---|
| 157 | dh_installchangelogs -i ChangeLog |
|---|
| 158 | dh_link -i |
|---|
| 159 | dh_compress -i -X.py -X.glade |
|---|
| 160 | dh_fixperms -i |
|---|
| 161 | # More permission fixing |
|---|
| 162 | grep -rlZ "^#\!.*python" debian/python-gtk2-dev/usr | xargs -0r chmod 755 |
|---|
| 163 | dh_pysupport -ppython-gtk2-doc /usr/share/pygtk |
|---|
| 164 | dh_installdeb -i |
|---|
| 165 | dh_gencontrol -i |
|---|
| 166 | dh_md5sums -i |
|---|
| 167 | dh_builddeb -i |
|---|
| 168 | |
|---|
| 169 | binary-arch: build install |
|---|
| 170 | dh_testdir |
|---|
| 171 | dh_testroot |
|---|
| 172 | dh_installdocs -s |
|---|
| 173 | dh_installexamples -s |
|---|
| 174 | dh_installchangelogs ChangeLog -s |
|---|
| 175 | dh_strip -s -Npython-gtk2-dbg --dbg-package=python-gtk2-dbg |
|---|
| 176 | rm -rf debian/python-gtk2-dbg/usr/share/doc/python-gtk2-dbg |
|---|
| 177 | ln -s python-gtk2 debian/python-gtk2-dbg/usr/share/doc/python-gtk2-dbg |
|---|
| 178 | dh_link -s |
|---|
| 179 | dh_compress -s -X.py -X.glade |
|---|
| 180 | dh_fixperms -s |
|---|
| 181 | dh_pysupport -s |
|---|
| 182 | dh_installdeb -s |
|---|
| 183 | dh_shlibdeps -s |
|---|
| 184 | dh_gencontrol -s |
|---|
| 185 | dh_md5sums -s |
|---|
| 186 | dh_builddeb -s |
|---|
| 187 | |
|---|
| 188 | binary: binary-arch binary-indep |
|---|
| 189 | .PHONY: patch unpatch build install clean binary-indep binary-arch binary |
|---|