rules 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #!/usr/bin/make -f
  2. # Uncomment this to turn on verbose mode.
  3. #export DH_VERBOSE=1
  4. include /usr/share/dpatch/dpatch.make
  5. # These are used for cross-compiling and for saving the configure script
  6. # from having to guess our platform (since we know it already)
  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. ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  10. CROSS= --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
  11. 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. CFLAGS += -Wall -g
  18. ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  19. CFLAGS += -O0
  20. else
  21. CFLAGS += -O2
  22. endif
  23. PYTHON_VERSIONS=$(shell pyversions -r debian/control)
  24. config.status: configure patch
  25. dh_testdir
  26. # Configuring package
  27. mv config.sub config.sub.upstream && ln -s /usr/share/misc/config.sub
  28. mv config.guess config.guess.upstream && ln -s /usr/share/misc/config.guess
  29. CFLAGS="$(CFLAGS)" ./configure $(CROSS) --prefix=/usr --datadir=\$${prefix}/share --mandir=\$${prefix}/share/man --enable-fsect-man5
  30. rm config.sub && mv config.sub.upstream config.sub
  31. rm config.guess && mv config.guess.upstream config.guess
  32. build: build-stamp
  33. build-stamp: config.status
  34. dh_testdir
  35. # Building package
  36. mv libtool libtool.upstream && ln -s /usr/bin/libtool libtool
  37. $(MAKE)
  38. rm libtool && mv libtool.upstream libtool
  39. set -e; \
  40. for python in $(PYTHON_VERSIONS); \
  41. do \
  42. (cd python && $$python setup.py build_ext \
  43. -L$(CURDIR)/src/.libs); \
  44. done
  45. set -e; \
  46. for python in $(PYTHON_VERSIONS); do \
  47. (cd python && $$python-dbg setup.py build_ext -L$(CURDIR)/src/.libs); \
  48. done
  49. touch build-stamp
  50. clean: unpatch
  51. dh_testdir
  52. dh_testroot
  53. rm -f build-stamp
  54. # Cleaning package
  55. [ ! -f Makefile ] || $(MAKE) clean
  56. [ ! -f Makefile ] || $(MAKE) distclean
  57. rm -rf python/build
  58. dh_clean
  59. install: build
  60. dh_testdir
  61. dh_testroot
  62. dh_clean -k
  63. dh_installdirs
  64. # Installing package
  65. mv libtool libtool.upstream && ln -s /usr/bin/libtool libtool
  66. $(MAKE) prefix=$(CURDIR)/debian/tmp/usr install
  67. rm libtool && mv libtool.upstream libtool
  68. install -D -m 0644 magic/magic.local debian/tmp/etc/magic
  69. install -D -m 0644 magic/magic.local debian/tmp/etc/magic.mime
  70. set -e; \
  71. for python in $(PYTHON_VERSIONS); \
  72. do \
  73. (cd python && $$python setup.py install --no-compile \
  74. --root=$(CURDIR)/debian/python-magic); \
  75. done
  76. set -e; \
  77. for python in $(PYTHON_VERSIONS); do \
  78. (cd python && $$python-dbg setup.py install --no-compile \
  79. --root=$(CURDIR)/debian/python-magic-dbg); \
  80. done
  81. find debian/python-*-dbg ! -type d ! -name '*.so' | xargs rm -f
  82. find debian/python-*-dbg -depth -empty -exec rmdir {} \;
  83. # Installing additional headers
  84. mkdir -p debian/libmagic-dev/usr/include/file
  85. cp src/file.h src/patchlevel.h debian/libmagic-dev/usr/include/file
  86. # Build plain magic files for compatibility
  87. install -D -m 0644 debian/legacy/magic.mime debian/libmagic1/usr/share/file/magic.mime
  88. cp magic/Header debian/libmagic1/usr/share/file/magic
  89. cat magic/Localstuff >> debian/libmagic1/usr/share/file/magic
  90. set -e; for FILE in magic/Magdir/*; \
  91. do \
  92. grep -v "^!:" $$FILE >> debian/libmagic1/usr/share/file/magic; \
  93. done
  94. # Installing bug congtrols
  95. install -D -m 0644 debian/bug/presubj debian/file/usr/share/bug/file/presubj
  96. install -D -m 0644 debian/bug/control debian/libmagic1/usr/share/bug/libmagic1/control
  97. install -D -m 0644 debian/bug/presubj-lib debian/libmagic1/usr/share/bug/libmagic1/presubj
  98. install -D -m 0644 debian/bug/control debian/libmagic-dev/usr/share/bug/libmagic-dev/control
  99. binary-indep: build install
  100. binary-arch: build install
  101. dh_testdir
  102. dh_testroot
  103. dh_installchangelogs ChangeLog
  104. dh_installdocs
  105. dh_installexamples
  106. dh_install --sourcedir=debian/tmp
  107. dh_lintian
  108. dh_python
  109. dh_link
  110. ifeq (,$(findstring -i, $(DH_OPTIONS)))
  111. dh_strip -Npython-magic -Npython-magic-dbg
  112. DH_OPTIONS= dh_strip -ppython-magic --dbg-package=python-magic-dbg
  113. rm -rf debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  114. mkdir -p debian/python-magic-dbg/usr/share/doc
  115. ln -s python-magic debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  116. endif
  117. dh_compress
  118. dh_fixperms
  119. dh_makeshlibs
  120. dh_installdeb
  121. dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
  122. dh_gencontrol
  123. dh_md5sums
  124. dh_builddeb
  125. binary: binary-indep binary-arch
  126. .PHONY: build clean binary-indep binary-arch binary install