rules 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/usr/bin/make -f
  2. SHELL := sh -e
  3. -include /usr/share/python/python.mk
  4. DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
  5. DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
  6. DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
  7. ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  8. CROSS= --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) CC=$(DEB_HOST_GNU_TYPE)-gcc LD=$(DEB_HOST_GNU_TYPE)-ld
  9. else
  10. CROSS= --build=$(DEB_BUILD_GNU_TYPE)
  11. endif
  12. # HOWMANY is the number of bytes looked at by file
  13. CFLAGS += -DHOWMANY=0x18000
  14. PYTHON_VERSIONS=$(shell pyversions -r debian/control)
  15. %:
  16. dh ${@} --with autotools_dev,python2
  17. override_dh_auto_clean:
  18. dh_auto_clean
  19. rm -rf python/build
  20. override_dh_auto_build:
  21. dh_auto_build
  22. for python in $(PYTHON_VERSIONS); \
  23. do \
  24. (cd python && $$python setup.py build_ext \
  25. -L$(CURDIR)/src/.libs); \
  26. done
  27. for python in $(PYTHON_VERSIONS); do \
  28. (cd python && $$python-dbg setup.py build_ext -L$(CURDIR)/src/.libs); \
  29. done
  30. override_dh_auto_configure:
  31. dh_auto_configure -- $(CROSS) --prefix=/usr --datadir=\$${prefix}/share --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) --mandir=\$${prefix}/share/man --enable-fsect-man5 CFLAGS="$(CFLAGS)"
  32. override_dh_auto_install:
  33. dh_auto_install
  34. mv debian/tmp/usr/share/misc debian/tmp/usr/share/file
  35. install -D -m 0644 magic/magic.local debian/tmp/etc/magic
  36. install -D -m 0644 magic/magic.local debian/tmp/etc/magic.mime
  37. for python in $(PYTHON_VERSIONS); \
  38. do \
  39. (cd python && $$python setup.py install --no-compile \
  40. --root=$(CURDIR)/debian/python-magic $(py_setup_install_args)); \
  41. done
  42. for python in $(PYTHON_VERSIONS); do \
  43. (cd python && $$python-dbg setup.py install --no-compile \
  44. --root=$(CURDIR)/debian/python-magic-dbg $(py_setup_install_args)); \
  45. done
  46. find debian/python-*-dbg ! -type d ! -name '*.so' | xargs rm -f
  47. find debian/python-*-dbg -depth -empty -exec rmdir {} \;
  48. # Installing additional headers
  49. mkdir -p debian/libmagic-dev/usr/include/file
  50. cp src/file.h debian/libmagic-dev/usr/include/file
  51. # Removing useless files
  52. rm -f debian/tmp/usr/lib/*/*.la
  53. override_dh_builddeb:
  54. dh_builddeb -- -Zxz -z9
  55. override_dh_install:
  56. dh_install --fail-missing
  57. override_dh_shlibdeps:
  58. dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
  59. override_dh_strip:
  60. ifeq (,$(findstring -i, $(DH_OPTIONS)))
  61. dh_strip -Npython-magic -Npython-magic-dbg
  62. DH_OPTIONS= dh_strip -ppython-magic --dbg-package=python-magic-dbg
  63. rm -rf debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  64. mkdir -p debian/python-magic-dbg/usr/share/doc
  65. ln -s python-magic debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  66. endif