rules 4.3 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. rm -f ltmain.sh
  27. libtoolize --automake
  28. aclocal
  29. automake
  30. autoconf
  31. # Configuring package
  32. mv config.sub config.sub.upstream && ln -s /usr/share/misc/config.sub
  33. mv config.guess config.guess.upstream && ln -s /usr/share/misc/config.guess
  34. CFLAGS="$(CFLAGS)" ./configure $(CROSS) --prefix=/usr --datadir=\$${prefix}/share --mandir=\$${prefix}/share/man --enable-fsect-man5
  35. rm config.sub && mv config.sub.upstream config.sub
  36. rm config.guess && mv config.guess.upstream config.guess
  37. build: build-stamp
  38. build-stamp: config.status
  39. dh_testdir
  40. # Building package
  41. mv libtool libtool.upstream && ln -s /usr/bin/libtool libtool
  42. $(MAKE)
  43. rm libtool && mv libtool.upstream libtool
  44. set -e; \
  45. for python in $(PYTHON_VERSIONS); \
  46. do \
  47. (cd python && $$python setup.py build_ext \
  48. -L$(CURDIR)/src/.libs); \
  49. done
  50. set -e; \
  51. for python in $(PYTHON_VERSIONS); do \
  52. (cd python && $$python-dbg setup.py build_ext -L$(CURDIR)/src/.libs); \
  53. done
  54. touch build-stamp
  55. clean: unpatch
  56. dh_testdir
  57. dh_testroot
  58. rm -f build-stamp
  59. # Cleaning package
  60. [ ! -f Makefile ] || $(MAKE) clean
  61. [ ! -f Makefile ] || $(MAKE) distclean
  62. rm -rf python/build
  63. dh_clean
  64. install: build
  65. dh_testdir
  66. dh_testroot
  67. dh_clean -k
  68. dh_installdirs
  69. # Installing package
  70. mv libtool libtool.upstream && ln -s /usr/bin/libtool libtool
  71. $(MAKE) prefix=$(CURDIR)/debian/tmp/usr install
  72. rm libtool && mv libtool.upstream libtool
  73. install -D -m 0644 magic/magic.local debian/tmp/etc/magic
  74. install -D -m 0644 magic/magic.local debian/tmp/etc/magic.mime
  75. set -e; \
  76. for python in $(PYTHON_VERSIONS); \
  77. do \
  78. (cd python && $$python setup.py install --no-compile \
  79. --root=$(CURDIR)/debian/python-magic); \
  80. done
  81. set -e; \
  82. for python in $(PYTHON_VERSIONS); do \
  83. (cd python && $$python-dbg setup.py install --no-compile \
  84. --root=$(CURDIR)/debian/python-magic-dbg); \
  85. done
  86. find debian/python-*-dbg ! -type d ! -name '*.so' | xargs rm -f
  87. find debian/python-*-dbg -depth -empty -exec rmdir {} \;
  88. # Installing additional headers
  89. mkdir -p debian/libmagic-dev/usr/include/file
  90. cp src/file.h src/patchlevel.h debian/libmagic-dev/usr/include/file
  91. # Installing plain magic.mime for compatibility
  92. install -D -m 0644 debian/legacy/magic.mime debian/libmagic1/usr/share/file/magic.mime
  93. # Installing bug congtrols
  94. install -D -m 0644 debian/bug/presubj debian/file/usr/share/bug/file/presubj
  95. install -D -m 0644 debian/bug/control debian/libmagic1/usr/share/bug/libmagic1/control
  96. install -D -m 0644 debian/bug/presubj-lib debian/libmagic1/usr/share/bug/libmagic1/presubj
  97. install -D -m 0644 debian/bug/control debian/libmagic-dev/usr/share/bug/libmagic-dev/control
  98. binary-indep: build install
  99. binary-arch: build install
  100. dh_testdir
  101. dh_testroot
  102. dh_installchangelogs ChangeLog
  103. dh_installdocs
  104. dh_installexamples
  105. dh_install --sourcedir=debian/tmp
  106. dh_lintian
  107. dh_python
  108. dh_link
  109. ifeq (,$(findstring -i, $(DH_OPTIONS)))
  110. dh_strip -Npython-magic -Npython-magic-dbg
  111. DH_OPTIONS= dh_strip -ppython-magic --dbg-package=python-magic-dbg
  112. rm -rf debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  113. mkdir -p debian/python-magic-dbg/usr/share/doc
  114. ln -s python-magic debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  115. endif
  116. dh_compress
  117. dh_fixperms
  118. dh_makeshlibs
  119. dh_installdeb
  120. dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
  121. dh_gencontrol
  122. dh_md5sums
  123. dh_builddeb
  124. binary: binary-indep binary-arch
  125. .PHONY: build clean binary-indep binary-arch binary install