rules 3.3 KB

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