rules 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #!/usr/bin/make -f
  2. # debian/rules for the dpkg suite.
  3. # Copyright © 2004 Scott James Remnant <scott@netsplit.com>
  4. # Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
  5. WFLAGS := -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
  6. # XXX: Stack Protector Strong is only available in gcc >= 4.9
  7. cc_version = $(shell $(CC) -dumpversion 2>/dev/null)
  8. cc_version_lt = $(shell dpkg --compare-versions "$(cc_version)" lt-nl "$(1)" && echo yes)
  9. hardening_old = DEB_BUILD_MAINT_OPTIONS="hardening=-stackprotectorstrong"
  10. # Use the in-tree dpkg-buildflags
  11. dpkg_buildflags = \
  12. $(if $(call cc_version_lt,4.9),$(hardening_old)) \
  13. DEB_CFLAGS_MAINT_APPEND="$(WFLAGS)" \
  14. DEB_CXXFLAGS_MAINT_APPEND="$(WFLAGS)" \
  15. $(CURDIR)/run-script perl scripts/dpkg-buildflags.pl
  16. DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
  17. DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
  18. DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
  19. DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
  20. # Support cross-compiling.
  21. ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  22. confflags += --build=$(DEB_HOST_GNU_TYPE)
  23. else
  24. confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
  25. endif
  26. # Do not enable everything on all platforms.
  27. ifeq ($(DEB_HOST_ARCH_OS),linux)
  28. confflags += --with-selinux
  29. endif
  30. ifeq (,$(filter maintainer-build,$(DEB_BUILD_OPTIONS)))
  31. confflags += --disable-silent-rules
  32. endif
  33. D := $(CURDIR)/debian/tmp
  34. D_MA := $(D)/usr/lib/$(DEB_HOST_MULTIARCH)
  35. # Create configure script if necessary, automake handles rebuilding it.
  36. configure:
  37. dh_testdir
  38. autoreconf -v -i
  39. # Configure the build tree
  40. build-tree/config.status: configure
  41. dh_testdir
  42. install -d build-tree
  43. cd build-tree && ../configure $(confflags) \
  44. $(shell $(dpkg_buildflags) --export=configure) \
  45. --prefix=/usr \
  46. --mandir=\$${datadir}/man \
  47. --infodir=\$${datadir}/info \
  48. --sysconfdir=/etc \
  49. --sbindir=/sbin \
  50. --localstatedir=/var \
  51. --with-zlib \
  52. --with-liblzma \
  53. --with-bz2
  54. # Build the package in build-tree
  55. build-indep build-arch build: build-tree/config.status
  56. dh_testdir
  57. cd build-tree && $(MAKE)
  58. # Run the test suites
  59. check: build
  60. dh_testdir
  61. ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
  62. cd build-tree && $(MAKE) VERBOSE=1 check
  63. endif
  64. # Install the package underneath debian/tmp
  65. install: check
  66. dh_testdir
  67. dh_testroot
  68. dh_prep
  69. dh_installdirs
  70. cd build-tree && $(MAKE) DESTDIR=$(D) install
  71. # Passing --libdir to configure has too many side effects, install
  72. # the paths into Multi-Arch directories here instead.
  73. mkdir -p $(D_MA)
  74. mv $(D)/usr/lib/libdpkg.a $(D_MA)
  75. ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
  76. # Ubuntu's «i386» architecture is built for i686 (the Debian default
  77. # is i586).
  78. sed -ri 's/^(i386[[:space:]]+)[^[:space:]]+/\1i686/' \
  79. $(D)/usr/share/dpkg/cputable
  80. endif
  81. define dpkg-installmanl10n
  82. for f in `sed -e 's:\*:*/*:' debian/$(1).manpages`; do \
  83. test -e $$f && \
  84. install -D $$f `echo $$f | sed -e 's:^debian/tmp:debian/$(1):'`; \
  85. done
  86. endef
  87. # Put together the dpkg and dselect packages
  88. binary-arch: install
  89. dh_testdir -a
  90. dh_testroot -a
  91. dh_install -a
  92. dh_installcron -a
  93. dh_installlogrotate -a
  94. dh_installchangelogs -a ChangeLog*
  95. dh_installdocs -a
  96. $(call dpkg-installmanl10n,dpkg)
  97. $(call dpkg-installmanl10n,dselect)
  98. dh_installman -a
  99. dh_link -a
  100. dh_lintian -a
  101. dh_strip -a
  102. dh_compress -a
  103. dh_fixperms -a
  104. dh_installdeb -a
  105. dh_shlibdeps -a
  106. dh_gencontrol -a
  107. dh_md5sums -a
  108. # Make debootstrap life easier on non-Debian based systems by
  109. # compressing dpkg.deb with gzip instead of xz.
  110. dh_builddeb -pdpkg -- -Zgzip
  111. dh_builddeb -a -Ndpkg
  112. # Put together the dpkg-dev package
  113. binary-indep: install
  114. dh_testdir -i
  115. dh_testroot -i
  116. dh_install -i
  117. dh_installcron -i
  118. dh_installchangelogs -i ChangeLog*
  119. dh_installdocs -i
  120. $(call dpkg-installmanl10n,dpkg-dev)
  121. dh_installman -i
  122. dh_link -i
  123. dh_lintian -i
  124. dh_strip -i
  125. dh_compress -i
  126. dh_fixperms -i
  127. dh_installdeb -i
  128. dh_gencontrol -i
  129. dh_md5sums -i
  130. dh_builddeb -i
  131. binary: binary-arch binary-indep
  132. # Clean up the mess we made
  133. clean:
  134. dh_testdir
  135. [ ! -f Makefile ] || $(MAKE) distclean
  136. rm -rf build-tree
  137. dh_clean
  138. .PHONY: build check install binary-arch binary-indep binary clean