rules 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. #!/usr/bin/make -f
  2. # -*- makefile -*-
  3. # Sample debian/rules that uses debhelper.
  4. # GNU copyright 1997 to 1999 by Joey Hess.
  5. # Uncomment this to turn on verbose mode.
  6. #export DH_VERBOSE=1
  7. export PACKAGE=tor
  8. include /usr/share/dpatch/dpatch.make
  9. # These are used for cross-compiling and for saving the configure script
  10. # from having to guess our platform (since we know it already)
  11. #
  12. # See /usr/share/doc/autotools-dev/README.Debian.gz which suggests
  13. # this way of passing --build and --host. Also see the thread on
  14. # debian-devel './configure in debian/rules' from February/March 2006,
  15. # starting with <43FF212C.5020800@xs4all.nl> by Pjotr Kourzanov.
  16. export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
  17. export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
  18. ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  19. confflags += --build $(DEB_HOST_GNU_TYPE)
  20. else
  21. confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
  22. endif
  23. CFLAGS ?= -Wall -g
  24. LOCALHOST_IP ?= $(shell getent hosts localhost | awk '{print $$1}')
  25. # Do not optimize the build with "noopt"
  26. ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  27. CFLAGS += -O0
  28. else
  29. CFLAGS += -O2
  30. endif
  31. # Do not strip the binary with "nostrip"
  32. #ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
  33. # INSTALL_PROGRAM += -s
  34. #endif
  35. # Prevent the unit tests from being run with "nocheck"
  36. ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
  37. RUN_TEST = no
  38. endif
  39. ifneq (,$(findstring notest,$(DEB_BUILD_OPTIONS)))
  40. RUN_TEST = no
  41. endif
  42. # Support passing of parallel=<n> in build options
  43. ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  44. NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  45. MAKEFLAGS += -j$(NUMJOBS)
  46. endif
  47. CONF_OPTIONS =
  48. # build against libdmalloc4 - it better be installed
  49. ifneq (,$(findstring with-dmalloc,$(DEB_BUILD_OPTIONS)))
  50. CONF_OPTIONS += --with-dmalloc
  51. endif
  52. # allow building with --enable-openbsd-malloc
  53. ifneq (,$(findstring enable-openbsd-malloc,$(DEB_BUILD_OPTIONS)))
  54. CONF_OPTIONS += --enable-openbsd-malloc
  55. endif
  56. configure: patch-stamp
  57. config.status: configure
  58. # clean up test.h stuff. XXX - expected to no longer be needed after tor-0.2.2.4-alpha
  59. rm -f src/test/test.h.orig
  60. ! [ -e src/test/test.h ] || mv src/test/test.h src/test/test.h.orig
  61. cp debian/src-test-test.h src/test/test.h
  62. @if [ "$(LOCALHOST_IP)" != "127.0.0.1" ]; then echo; echo; echo; echo; echo; echo "######################################################################"; echo "WARNING: This system does not think localhost is 127.0.0.1. Will ignore result of testsuite. Please fix your system/chroot."; echo "######################################################################"; echo; echo; echo; echo; echo "Note: 'getent hosts localhost' should return '127.0.0.1 localhost'"; echo; fi
  63. dh_testdir
  64. CFLAGS="$(CFLAGS)" ./configure \
  65. $(confflags) \
  66. --prefix=/usr \
  67. --mandir=\$${prefix}/share/man \
  68. --infodir=\$${prefix}/share/info \
  69. --localstatedir=/var \
  70. --sysconfdir=/etc \
  71. $(CONF_OPTIONS)
  72. build: build-stamp
  73. build-stamp: config.status
  74. dh_testdir
  75. ! [ debian/micro-revision.i ] || cp debian/micro-revision.i src/or/micro-revision.i
  76. $(MAKE)
  77. @echo
  78. @echo
  79. # Running unit tests
  80. @if [ "$(RUN_TEST)" != "no" ]; then \
  81. if [ "$(LOCALHOST_IP)" != "127.0.0.1" ]; then \
  82. echo; echo; echo "######################################################################"; echo "WARNING: This system does not think localhost is 127.0.0.1. Will ignore result of testsuite. Please fix your system/chroot."; echo "######################################################################"; echo; echo; \
  83. echo "make check || true"; \
  84. make check || true; \
  85. else \
  86. echo "make check"; \
  87. make check; \
  88. fi; \
  89. else \
  90. echo; echo; echo "Skipping unittests"; echo; \
  91. fi
  92. @echo
  93. # XXX
  94. # So, gs-gpl on s390 is broken (#457568) and fails to properly build
  95. # .pdf files from .fig files using fig2dev. Therefore we ship them
  96. # until this bug is fixed.
  97. #
  98. # of course we can always give it a try
  99. #
  100. # the hexdumps were built using something like
  101. # perl -e 'while (<>) { print unpack ("H*", $_); }' interaction.pdf | fold > hexdump-interaction.pdf
  102. #
  103. # And it fails on a bunch of other archs too.
  104. cd doc/design-paper; \
  105. fig2dev -L pdf cell-struct.fig cell-struct.pdf || \
  106. ( echo "** Using shipped pdf file because fig2dev failed"; \
  107. perl -e 'while (<>) { chomp; print pack ("H*", $$_); }' ../../debian/hexdump-cell-struct.pdf > cell-struct.pdf ); \
  108. fig2dev -L pdf interaction.fig interaction.pdf || \
  109. ( echo "** Using shipped pdf file because fig2dev failed"; \
  110. perl -e 'while (<>) { chomp; print pack ("H*", $$_); }' ../../debian/hexdump-interaction.pdf > interaction.pdf ); \
  111. # XXX ends
  112. make -C doc/design-paper tor-design.ps tor-design.pdf
  113. touch build-stamp
  114. clean: unpatch
  115. dh_testdir
  116. dh_testroot
  117. rm -f build-stamp
  118. rm -f src/common/common_sha1.i src/or/or_sha1.i
  119. rm -f src/or/micro-revision.i
  120. [ ! -f Makefile ] || $(MAKE) distclean
  121. # clean up test.h stuff. XXX - expected to no longer be needed after tor-0.2.2.4-alpha
  122. rm -f src/test/test.h
  123. ! [ -e src/test/test.h.orig ] || mv src/test/test.h.orig src/test/test.h
  124. # Normally the .deb wouldn't ship with a ../.git
  125. if [ -d .git ] && which git >/dev/null; then \
  126. echo "\"`git rev-parse --short=16 HEAD`\"" > "debian/micro-revision.i" ; \
  127. fi
  128. dh_clean
  129. install: build
  130. dh_testdir
  131. dh_testroot
  132. dh_clean -k
  133. dh_installdirs
  134. $(MAKE) install DESTDIR=$(CURDIR)/debian/tor
  135. # move tor to where it belongs
  136. mv $(CURDIR)/debian/tor/etc/tor/torrc.sample $(CURDIR)/debian/tor/etc/tor/torrc
  137. mv $(CURDIR)/debian/tor/usr/bin/tor $(CURDIR)/debian/tor/usr/sbin/tor
  138. install -d $(CURDIR)/debian/tor/usr/share/man/man8
  139. mv $(CURDIR)/debian/tor/usr/share/man/man1/tor.1 $(CURDIR)/debian/tor/usr/share/man/man8/tor.8
  140. install -m 755 contrib/torify $(CURDIR)/debian/tor/usr/bin
  141. install -m 644 contrib/torify.1 $(CURDIR)/debian/tor/usr/share/man/man1
  142. install -m 644 contrib/tor-tsocks.conf $(CURDIR)/debian/tor/etc/tor
  143. install -m 644 debian/tor.lintian-override $(CURDIR)/debian/tor/usr/share/lintian/overrides/tor
  144. install -d -m 755 $(CURDIR)/debian/tor/usr/share/doc/tor/spec
  145. for i in doc/spec/*txt; do \
  146. install -m 644 $$i $(CURDIR)/debian/tor/usr/share/doc/tor/spec || exit 1; \
  147. done
  148. dh_link usr/share/man/man8/tor.8 usr/share/man/man5/torrc.5
  149. rm -f $(CURDIR)/debian/tor/usr/bin/tor-control.py
  150. # tor-dbg doc dir
  151. install -d -m 755 $(CURDIR)/debian/tor-dbg/usr/share/doc
  152. ln -s tor $(CURDIR)/debian/tor-dbg/usr/share/doc/tor-dbg
  153. # tor-geoip
  154. mv $(CURDIR)/debian/tor/usr/share/tor/geoip $(CURDIR)/debian/tor-geoipdb/usr/share/tor
  155. rmdir $(CURDIR)/debian/tor/usr/share/tor || true
  156. install -d -m 755 $(CURDIR)/debian/tor-geoipdb/usr/share/doc/tor-geoipdb
  157. ln -s ../tor/changelog.gz $(CURDIR)/debian/tor-geoipdb/usr/share/doc/tor-geoipdb
  158. ln -s ../tor/changelog.Debian.gz $(CURDIR)/debian/tor-geoipdb/usr/share/doc/tor-geoipdb
  159. install -m 644 debian/tor-geoipdb.lintian-override $(CURDIR)/debian/tor-geoipdb/usr/share/lintian/overrides/tor-geoipdb
  160. # Must not depend on anything. This is to be called by
  161. # binary-arch/binary-indep
  162. # in another 'make' thread.
  163. binary-common:
  164. dh_testdir
  165. dh_testroot
  166. dh_installchangelogs --package=tor ChangeLog
  167. dh_installdocs
  168. dh_installexamples
  169. dh_installlogrotate
  170. dh_installinit
  171. dh_installman
  172. dh_link
  173. dh_strip --dbg-package=tor-dbg
  174. dh_compress
  175. dh_fixperms
  176. dh_installdeb
  177. dh_shlibdeps
  178. dh_gencontrol
  179. dh_md5sums
  180. dh_builddeb
  181. # Build architecture independant packages using the common target.
  182. binary-indep: install
  183. $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
  184. # Build architecture dependant packages using the common target.
  185. binary-arch: install
  186. $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
  187. @if [ "$(LOCALHOST_IP)" != "127.0.0.1" ]; then echo; echo; echo; echo; echo; echo "######################################################################"; echo "WARNING: This system does not think localhost is 127.0.0.1. Result of testsuite has been ignored. Please fix your system/chroot."; echo "######################################################################"; echo; echo; echo; echo; echo "Note: 'getent hosts localhost' should return '127.0.0.1 localhost'"; echo; fi
  188. binary: binary-indep binary-arch
  189. .PHONY: build clean binary-common binary-indep binary-arch binary install