rules 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. # Installing bug congtrols
  87. install -D -m 0644 debian/bug/presubj debian/file/usr/share/bug/file/presubj
  88. install -D -m 0644 debian/bug/control debian/libmagic1/usr/share/bug/libmagic1/control
  89. install -D -m 0644 debian/bug/presubj-lib debian/libmagic1/usr/share/bug/libmagic1/presubj
  90. install -D -m 0644 debian/bug/control debian/libmagic-dev/usr/share/bug/libmagic-dev/control
  91. # Installing lintian overrides
  92. set -e; for LINTIAN in debian/lintian/*; \
  93. do \
  94. install -D -m 0644 $$LINTIAN debian/`basename $$LINTIAN`/usr/share/lintian/overrides/`basename $$LINTIAN`; \
  95. done
  96. binary-indep: build install
  97. binary-arch: build install
  98. dh_testdir
  99. dh_testroot
  100. dh_installchangelogs ChangeLog
  101. dh_installdocs
  102. dh_installexamples
  103. dh_install --sourcedir=debian/tmp
  104. dh_python
  105. dh_link
  106. ifeq (,$(findstring -i, $(DH_OPTIONS)))
  107. dh_strip -Npython-magic -Npython-magic-dbg
  108. DH_OPTIONS= dh_strip -ppython-magic --dbg-package=python-magic-dbg
  109. rm -rf debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  110. mkdir -p debian/python-magic-dbg/usr/share/doc
  111. ln -s python-magic debian/python-magic-dbg/usr/share/doc/python-magic-dbg
  112. endif
  113. dh_compress
  114. dh_fixperms
  115. dh_makeshlibs
  116. dh_installdeb
  117. dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
  118. dh_gencontrol
  119. dh_md5sums
  120. dh_builddeb
  121. binary: binary-indep binary-arch
  122. .PHONY: build clean binary-indep binary-arch binary install