rules 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. echo "Reading magic from $$FILE"; \
  93. grep -v "^!:" $$FILE >> debian/libmagic1/usr/share/file/magic; \
  94. done
  95. # Instead of the installed magic.mgc use the compiled form of the
  96. # plain magic file, as a workaround for #488562 (avoiding RC bug
  97. # #481247).
  98. rm -f debian/libmagic1/usr/share/file/magic.mgc
  99. ( cd debian/libmagic1/usr/share/file && ../../../../../src/file -m magic -C )
  100. # Installing bug congtrols
  101. install -D -m 0644 debian/bug/presubj debian/file/usr/share/bug/file/presubj
  102. install -D -m 0644 debian/bug/control debian/libmagic1/usr/share/bug/libmagic1/control
  103. install -D -m 0644 debian/bug/presubj-lib debian/libmagic1/usr/share/bug/libmagic1/presubj
  104. install -D -m 0644 debian/bug/control debian/libmagic-dev/usr/share/bug/libmagic-dev/control
  105. binary-indep: build install
  106. binary-arch: build install
  107. dh_testdir
  108. dh_testroot
  109. dh_installchangelogs ChangeLog
  110. dh_installdocs
  111. dh_installexamples
  112. dh_install --sourcedir=debian/tmp
  113. dh_lintian
  114. dh_python
  115. dh_link
  116. ifeq (,$(findstring -i, $(DH_OPTIONS)))
  117. dh_strip -Npython-magic -Npython-magic-dbg
  118. DH_OPTIONS= dh_strip -ppython-magic --dbg-package=python-magic-dbg
  119. rm -rf debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  120. mkdir -p debian/python-magic-dbg/usr/share/doc
  121. ln -s python-magic debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  122. endif
  123. dh_compress
  124. dh_fixperms
  125. dh_makeshlibs
  126. dh_installdeb
  127. dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
  128. dh_gencontrol
  129. dh_md5sums
  130. dh_builddeb
  131. binary: binary-indep binary-arch
  132. .PHONY: build clean binary-indep binary-arch binary install