diff options
Diffstat (limited to 'debian/rules')
-rwxr-xr-x | debian/rules | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..30178b8 --- /dev/null +++ b/debian/rules @@ -0,0 +1,241 @@ +#!/usr/bin/make -f +ifneq ($(shell which tclsh8.6),) +TCL_VER := 8.6 +else +TCL_VER := 8.5 +endif +MAJOR_VER := 10 +#CASSERT_FLAGS := --enable-cassert + +CATVERSION = $(shell awk '/CATALOG_VERSION_NO/ { print $$3 }' src/include/catalog/catversion.h) + +DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH) + +# find tclconfig in multi-arch location (still in /usr/lib in wheezy and precise) +DEB_HOST_MULTIARCH = $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) +ifneq ($(wildcard /usr/lib/$(DEB_HOST_MULTIARCH)/tcl$(TCL_VER)),) +TCL_CONFIG_DIR := /usr/lib/$(DEB_HOST_MULTIARCH) +else +TCL_CONFIG_DIR := /usr/lib +endif + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +#PIE# # On jessie/zesty and older, uncomment the #PIE# lines +#PIE# # "-pie" because it would break linking our .so files +#PIE# export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/buildflags.mk +#PIE# # skip -pie on 32bit archs for performance and stability reasons +#PIE# # (http://www.postgresql.org/message-id/20140519115318.GB7296@msgid.df7cb.de, #797530) +#PIE# ifneq ($(shell dpkg-architecture -qDEB_HOST_ARCH_BITS || :),32) +#PIE# CFLAGS+= -fPIC -pie +#PIE# else +#PIE# # if gcc recognizes -no-pie, add it to CFLAGS (exit is 4 for unknown options) +#PIE# CFLAGS+= $(shell gcc -no-pie 2> /dev/null; [ $$? = 1 ] && echo "-no-pie") +#PIE# endif + +# Facilitate hierarchical profile generation on amd64 (#730134) +ifeq ($(shell dpkg-architecture -qDEB_HOST_ARCH),amd64) +CFLAGS+= -fno-omit-frame-pointer +endif + +export DPKG_GENSYMBOLS_CHECK_LEVEL=4 + +# PostgreSQL 9.5+ does not have native spinlock support on this platform +ifneq ($(findstring $(DEB_HOST_ARCH), alpha),) +SPINLOCK_FLAGS = --disable-spinlocks +endif + +ifeq ($(shell dpkg-architecture -qDEB_HOST_ARCH_OS),linux) +SYSTEMD_FLAGS = --with-systemd +# --with-selinux needs libselinux 2.1.10 +# (we don't put that in debian/control so we can use the same source also on older dists) +SEVERSION = $(shell dpkg-query -f '$${Version}' --show libselinux1-dev) +ifeq ($(shell dpkg --compare-versions "$(SEVERSION)" ge 2.1.10 && echo yes),yes) +SELINUX_FLAGS= --with-selinux +endif +endif + +COMMON_CONFIGURE_FLAGS= \ + --mandir=/usr/share/postgresql/$(MAJOR_VER)/man \ + --docdir=/usr/share/doc/postgresql-doc-$(MAJOR_VER) \ + --sysconfdir=/etc/postgresql-common \ + --datarootdir=/usr/share/ \ + --datadir=/usr/share/postgresql/$(MAJOR_VER) \ + --bindir=/usr/lib/postgresql/$(MAJOR_VER)/bin \ + --libdir=/usr/lib/$(DEB_HOST_MULTIARCH)/ \ + --libexecdir=/usr/lib/postgresql/ \ + --includedir=/usr/include/postgresql/ \ + --enable-nls \ + --enable-integer-datetimes \ + --enable-thread-safety \ + --enable-tap-tests \ + --enable-debug \ + $(CASSERT_FLAGS) \ + --disable-rpath \ + --with-uuid=e2fs \ + --with-gnu-ld \ + --with-pgport=5432 \ + --with-system-tzdata=/usr/share/zoneinfo \ + $(SYSTEMD_FLAGS) \ + $(SPINLOCK_FLAGS) \ + CFLAGS='$(CFLAGS)' \ + LDFLAGS='$(LDFLAGS)' + +# allow missing krb5 and ldap during bootstrapping +ifeq ($(DEB_STAGE),stage1) +BOOTSTRAP_FLAGS= +else +BOOTSTRAP_FLAGS= --with-gssapi --with-ldap \ + --with-includes=/usr/include/mit-krb5 \ + --with-libs=/usr/lib/mit-krb5 \ + --with-libs=/usr/lib/$(DEB_HOST_MULTIARCH)/mit-krb5 +endif + +# build should fail on test suite failures on all arches +TESTSUITE_FAIL_CMD=exit 1 +# hurd doesn't implement semaphores shared between processes yet; succeed anyway so they at least have libpq5 +# plperl currently fails on kfreebsd-* +ifneq ($(filter $(DEB_HOST_ARCH), hurd-i386 kfreebsd-amd64 kfreebsd-i386),) +TESTSUITE_FAIL_CMD=exit 0 +endif + +%: + dh $@ + +override_dh_auto_configure-indep: stamp/configure-build +override_dh_auto_configure-arch: stamp/configure-build stamp/configure-build-py3 + +stamp/configure-build: + mkdir -p stamp build + cd build && ../configure \ + --with-icu \ + --with-tcl \ + --with-perl \ + --with-python \ + --with-pam \ + --with-openssl \ + --with-libxml \ + --with-libxslt \ + --with-tclconfig=$(TCL_CONFIG_DIR)/tcl$(TCL_VER) \ + --with-includes=/usr/include/tcl$(TCL_VER) \ + PYTHON=/usr/bin/python \ + $(COMMON_CONFIGURE_FLAGS) \ + $(BOOTSTRAP_FLAGS) \ + $(SELINUX_FLAGS) + # remove pre-built documentation + rm -fv doc/src/sgml/*-stamp + touch "$@" + +stamp/configure-build-py3: + mkdir -p stamp build-py3 + cd build-py3 && ../configure \ + --with-python \ + PYTHON=/usr/bin/python3 \ + $(COMMON_CONFIGURE_FLAGS) + touch "$@" + +override_dh_auto_build-indep: + $(MAKE) -C build/doc all # build man + html + +override_dh_auto_build-arch: stamp/build stamp/build-py3 + +stamp/build: stamp/configure-build + $(MAKE) -C build/doc man # build man only + $(MAKE) -C build/src all + $(MAKE) -C build/config all + $(MAKE) -C build/contrib all + # build tutorial stuff + $(MAKE) -C build/src/tutorial NO_PGXS=1 + touch "$@" + +stamp/build-py3: stamp/configure-build-py3 + $(MAKE) -C build-py3/src/pl/plpython + $(MAKE) -C build-py3/contrib/hstore_plpython + touch "$@" + +override_dh_auto_install-arch: + $(MAKE) -C build/doc/src/sgml install-man DESTDIR=$(CURDIR)/debian/tmp + $(MAKE) -C build/src install DESTDIR=$(CURDIR)/debian/tmp + $(MAKE) -C build/config install DESTDIR=$(CURDIR)/debian/tmp + $(MAKE) -C build/contrib install DESTDIR=$(CURDIR)/debian/tmp + $(MAKE) -C build-py3/src/pl/plpython install DESTDIR=$(CURDIR)/debian/postgresql-plpython3-$(MAJOR_VER) + $(MAKE) -C build-py3/contrib/hstore_plpython install DESTDIR=$(CURDIR)/debian/postgresql-plpython3-$(MAJOR_VER) + # remove files duplicated from postgresql and -server-dev + rm -rf debian/postgresql-plpython3-$(MAJOR_VER)/usr/include + rm -rf debian/postgresql-plpython3-$(MAJOR_VER)/usr/share/locale + # remove files from the "wrong" python package + rm -v debian/postgresql-plpython3-$(MAJOR_VER)/usr/share/postgresql/$(MAJOR_VER)/extension/*plpython[2u]* + # move SPI examples into server package (they wouldn't be in the doc package in an -A build) + mkdir -p debian/postgresql-$(MAJOR_VER)/usr/share/doc/postgresql-$(MAJOR_VER) + mv debian/tmp/usr/share/doc/postgresql-doc-$(MAJOR_VER)/extension debian/postgresql-$(MAJOR_VER)/usr/share/doc/postgresql-$(MAJOR_VER)/examples + +override_dh_auto_install-indep: + $(MAKE) -C build/doc install DESTDIR=$(CURDIR)/debian/tmp + +override_dh_makeshlibs: + dh_makeshlibs -Xusr/lib/postgresql/$(MAJOR_VER) + +override_dh_auto_clean: + rm -rf build* stamp + +override_dh_installchangelogs: + dh_installchangelogs HISTORY + +override_dh_compress: + dh_compress -X.source -X.c + # compress manpages + gzip -9n $(CURDIR)/debian/*/usr/share/postgresql/*/man/man*/*.[137] + +override_dh_install-arch: + dh_install --fail-missing + + # link README.Debian.gz to postgresql-common + mkdir -p debian/postgresql-$(MAJOR_VER)/usr/share/doc/postgresql-$(MAJOR_VER) + ln -s ../postgresql-common/README.Debian.gz debian/postgresql-$(MAJOR_VER)/usr/share/doc/postgresql-$(MAJOR_VER)/README.Debian.gz + + # these are shipped in the pl packages + bash -c "rm debian/postgresql-$(MAJOR_VER)/usr/share/postgresql/$(MAJOR_VER)/extension/{plperl,plpython,pltcl,*_pl}*" + bash -c "rm debian/postgresql-$(MAJOR_VER)/usr/lib/postgresql/$(MAJOR_VER)/lib/{plperl,plpython,pltcl,*_pl}*" + + # record catversion in a file + echo $(CATVERSION) > debian/postgresql-$(MAJOR_VER)/usr/share/postgresql/$(MAJOR_VER)/catalog_version + +override_dh_install-indep: + dh_install --fail-missing + + if [ -d debian/postgresql-doc-$(MAJOR_VER) ]; then set -e; \ + install -d debian/postgresql-doc-$(MAJOR_VER)/usr/share/doc/postgresql-doc-$(MAJOR_VER)/tutorial; \ + install src/tutorial/*.c src/tutorial/*.source src/tutorial/Makefile src/tutorial/README debian/postgresql-doc-$(MAJOR_VER)/usr/share/doc/postgresql-doc-$(MAJOR_VER)/tutorial; \ + fi + +override_dh_auto_test-indep: + # nothing to do + +override_dh_auto_test-arch: +ifeq (, $(findstring nocheck, $(DEB_BUILD_OPTIONS))) + # when tests fail, print newest 3 log files + # temp-install wants to be invoked from a top-level make, unset MAKELEVEL here + unset MAKELEVEL; if ! make -C build check-world EXTRA_REGRESS_OPTS='--port=$(shell perl -le 'print 1024 + int(rand(64000))')'; then \ + for l in `find build \( -name regression.diffs -o -name initdb.log -o -name postmaster.log \) | perl -we 'print map { "$$_\n"; } sort { (stat $$a)[9] <=> (stat $$b)[9] } map { chomp; $$_; } <>' | tail -3`; do \ + echo "******** $$l ********"; \ + cat $$l; \ + done; \ + $(TESTSUITE_FAIL_CMD); \ + fi +endif + +override_dh_strip: + dh_strip --dbg-package=postgresql-$(MAJOR_VER)-dbg + +override_dh_installdeb-arch: + dh_installdeb + # record catversion in preinst + sed -i -e 's/@CATVERSION@/$(CATVERSION)/' debian/postgresql-$(MAJOR_VER)/DEBIAN/preinst + +override_dh_gencontrol: + # record catversion in .deb control file + dh_gencontrol -- -Vpostgresql:Catversion=$(CATVERSION) + +override_dh_builddeb: + dh_builddeb -- -Zxz # explicit xz compression for wheezy and precise |