rules 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/usr/bin/make -f
  2. export DEB_BUILD_MAINT_OPTIONS = hardening=+all
  3. SHELL := sh -e
  4. ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
  5. -include /usr/share/python/python.mk
  6. endif
  7. DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
  8. DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
  9. DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
  10. ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  11. CROSS= --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) CC=$(DEB_HOST_GNU_TYPE)-gcc LD=$(DEB_HOST_GNU_TYPE)-ld
  12. else
  13. CROSS= --build=$(DEB_BUILD_GNU_TYPE)
  14. endif
  15. # HOWMANY is the number of bytes looked at by file
  16. CFLAGS += -DHOWMANY=0x18000
  17. ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
  18. PYTHON_VERSIONS=$(shell pyversions -r debian/control)
  19. PYTHON3_VERSIONS=$(shell py3versions -r debian/control)
  20. endif
  21. %:
  22. ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
  23. dh ${@} --with autoreconf,python2,python3
  24. else
  25. dh ${@} --with autoreconf
  26. endif
  27. override_dh_auto_clean:
  28. dh_auto_clean
  29. rm -rf python/build
  30. rm -rf python/__pycache__
  31. rm -f python/*.pyc
  32. override_dh_auto_build:
  33. dh_auto_build
  34. ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
  35. for python in $(PYTHON_VERSIONS); \
  36. do \
  37. (cd python && $$python setup.py build_ext \
  38. -L$(CURDIR)/src/.libs); \
  39. done
  40. for python in $(PYTHON3_VERSIONS); \
  41. do \
  42. (cd python && $$python setup.py build_ext \
  43. -L$(CURDIR)/src/.libs); \
  44. done
  45. endif
  46. override_dh_auto_configure:
  47. dh_auto_configure -- $(CROSS) --prefix=/usr --datadir=\$${prefix}/share --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) --mandir=\$${prefix}/share/man --enable-fsect-man5 --enable-static --disable-silent-rules CFLAGS="$(CFLAGS)"
  48. override_dh_auto_install:
  49. dh_auto_install
  50. mv debian/tmp/usr/share/misc debian/tmp/usr/share/file
  51. install -D -m 0644 magic/magic.local debian/tmp/etc/magic
  52. install -D -m 0644 magic/magic.local debian/tmp/etc/magic.mime
  53. ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
  54. for python in $(PYTHON_VERSIONS); \
  55. do \
  56. (cd python && $$python setup.py install --no-compile \
  57. --root=$(CURDIR)/debian/python-magic $(py_setup_install_args)); \
  58. done
  59. for python in $(PYTHON3_VERSIONS); \
  60. do \
  61. (cd python && $$python setup.py install --no-compile \
  62. --root=$(CURDIR)/debian/python3-magic $(py_setup_install_args)); \
  63. done
  64. endif
  65. # Installing additional headers
  66. mkdir -p debian/libmagic-dev/usr/include/file
  67. cp src/file.h debian/libmagic-dev/usr/include/file
  68. # Removing useless files
  69. rm -f debian/tmp/usr/lib/*/*.la
  70. override_dh_builddeb:
  71. dh_builddeb -- -Zxz
  72. override_dh_install:
  73. dh_install --fail-missing
  74. override_dh_shlibdeps:
  75. ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
  76. # use just built file in dh_shlibdeps
  77. PATH=$(CURDIR)/debian/file/usr/bin:$$PATH \
  78. LD_LIBRARY_PATH=$(CURDIR)/debian/libmagic1/usr/lib/$(DEB_HOST_MULTIARCH)$${LD_LIBRARY_PATH+:$${LD_LIBRARY_PATH}} \
  79. MAGIC=$(CURDIR)/debian/libmagic1/usr/share/file/magic.mgc \
  80. dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
  81. else
  82. dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
  83. endif
  84. override_dh_strip:
  85. ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
  86. # use just built file in dh_strip
  87. PATH=$(CURDIR)/debian/file/usr/bin:$$PATH \
  88. LD_LIBRARY_PATH=$(CURDIR)/debian/libmagic1/usr/lib/$(DEB_HOST_MULTIARCH)$${LD_LIBRARY_PATH+:$${LD_LIBRARY_PATH}} \
  89. MAGIC=$(CURDIR)/debian/libmagic1/usr/share/file/magic.mgc \
  90. dh_strip --dbg-package=file-dbg
  91. else
  92. dh_strip --dbg-package=file-dbg
  93. endif