rules 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
  12. export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
  13. CFLAGS ?= -Wall -g
  14. ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  15. confflags += --build $(DEB_HOST_GNU_TYPE)
  16. else
  17. confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
  18. endif
  19. LOCALHOST_IP ?= $(shell getent hosts localhost | awk '{print $$1}')
  20. # Do not optimize the build with "noopt"
  21. ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  22. CFLAGS += -O0
  23. else
  24. CFLAGS += -O2
  25. endif
  26. # Do not strip the binary with "nostrip"
  27. #ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
  28. # INSTALL_PROGRAM += -s
  29. #endif
  30. # Prevent the design paper from being built with "nodoc"
  31. ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
  32. BUILD_DOC = no
  33. endif
  34. # Prevent the unit tests from being run with "nocheck"
  35. ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
  36. RUN_TEST = no
  37. endif
  38. ifneq (,$(findstring notest,$(DEB_BUILD_OPTIONS)))
  39. RUN_TEST = no
  40. endif
  41. CONF_OPTIONS =
  42. # build against libdmalloc4 - it better be installed
  43. ifneq (,$(findstring with-dmalloc,$(DEB_BUILD_OPTIONS)))
  44. CONF_OPTIONS += --with-dmalloc
  45. endif
  46. configure: patch-stamp
  47. config.status: configure
  48. @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
  49. dh_testdir
  50. CFLAGS="$(CFLAGS)" ./configure \
  51. $(confflags) \
  52. --prefix=/usr \
  53. --mandir=\$${prefix}/share/man \
  54. --infodir=\$${prefix}/share/info \
  55. --localstatedir=/var \
  56. --sysconfdir=/etc \
  57. $(CONF_OPTIONS)
  58. build: build-stamp
  59. build-stamp: config.status
  60. dh_testdir
  61. $(MAKE)
  62. @echo
  63. @echo
  64. # Running unit tests
  65. @if [ "$(RUN_TEST)" != "no" ]; then \
  66. if [ "$(LOCALHOST_IP)" != "127.0.0.1" ]; then \
  67. 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; \
  68. echo "src/or/test || true"; \
  69. src/or/test || true; \
  70. else \
  71. echo "src/or/test"; \
  72. src/or/test; \
  73. fi; \
  74. else \
  75. echo -e "\n\nSkipping unittests\n\n"; \
  76. fi
  77. @echo
  78. # XXX
  79. # So, gs-gpl on s390 is broken (#321435) and fails to properly build
  80. # .pdf files from .fig files using fig2dev. Therefore we ship them
  81. # until this bug is fixed.
  82. #
  83. # of course we can always give it a try
  84. #
  85. # the hexdumps were built using something like
  86. # perl -e 'while (<>) { print unpack ("H*", $_); }' interaction.pdf | fold > hexdump-interaction.pdf
  87. if [ "$(DEB_BUILD_GNU_TYPE)" = "s390-linux-gnu" ]; then \
  88. cd doc/design-paper; \
  89. fig2dev -L pdf cell-struct.fig cell-struct.pdf || \
  90. ( echo "** Using shipped pdf file because fig2dev failed"; \
  91. perl -e 'while (<>) { chomp; print pack ("H*", $$_); }' ../../debian/hexdump-cell-struct.pdf > cell-struct.pdf ); \
  92. fig2dev -L pdf interaction.fig interaction.pdf || \
  93. ( echo "** Using shipped pdf file because fig2dev failed"; \
  94. perl -e 'while (<>) { chomp; print pack ("H*", $$_); }' ../../debian/hexdump-interaction.pdf > interaction.pdf ); \
  95. fi
  96. # XXX ends
  97. if [ "$(BUILD_DOC)" != "no" ]; then \
  98. make -C doc/design-paper tor-design.ps tor-design.pdf || \
  99. ( echo -e "*\n*\n*\n*"; \
  100. echo "* Building some docs failed, perhaps because you did not install the"; \
  101. echo "* declared build dependencies and then used -o with dpkg-buildpackage."; \
  102. echo "*"; \
  103. echo "* If you want to skip this part, you can set nodoc in DEB_BUILD_OPTIONS" ; \
  104. echo "* and start the build again. DEB_BUILD_OPTIONS=nodoc dpkg-buildpackage.."; \
  105. echo -e "*\n*\n*\n*"; \
  106. false ); \
  107. else \
  108. echo -e "\n\nSkipping tor-design.{ps,pdf}\n\n"; \
  109. fi
  110. touch build-stamp
  111. clean: unpatch
  112. dh_testdir
  113. dh_testroot
  114. rm -f build-stamp
  115. -$(MAKE) distclean
  116. dh_clean
  117. install: build
  118. dh_testdir
  119. dh_testroot
  120. dh_clean -k
  121. dh_installdirs
  122. $(MAKE) install DESTDIR=$(CURDIR)/debian/tor
  123. # move tor to where it belongs
  124. mv $(CURDIR)/debian/tor/etc/tor/torrc.sample $(CURDIR)/debian/tor/etc/tor/torrc
  125. mv $(CURDIR)/debian/tor/usr/bin/tor $(CURDIR)/debian/tor/usr/sbin/tor
  126. install -d $(CURDIR)/debian/tor/usr/share/man/man8
  127. mv $(CURDIR)/debian/tor/usr/share/man/man1/tor.1 $(CURDIR)/debian/tor/usr/share/man/man8/tor.8
  128. install -m 755 contrib/torify $(CURDIR)/debian/tor/usr/bin
  129. install -m 644 contrib/torify.1 $(CURDIR)/debian/tor/usr/share/man/man1
  130. install -m 644 contrib/tor-tsocks.conf $(CURDIR)/debian/tor/etc/tor
  131. install -m 644 debian/tor.lintian-override $(CURDIR)/debian/tor/usr/share/lintian/overrides/tor
  132. dh_link usr/share/man/man8/tor.8 usr/share/man/man5/torrc.5
  133. rm -f $(CURDIR)/debian/tor/usr/bin/tor-control.py
  134. install -d -m 755 $(CURDIR)/debian/tor-dbg/usr/share/doc
  135. ln -s tor $(CURDIR)/debian/tor-dbg/usr/share/doc/tor-dbg
  136. # Build architecture-independent files here.
  137. binary-indep: build install
  138. # We have nothing to do by default.
  139. # Build architecture-dependent files here.
  140. binary-arch: build install
  141. dh_testdir
  142. dh_testroot
  143. dh_installchangelogs ChangeLog
  144. dh_installdocs
  145. if [ "$(BUILD_DOC)" != "no" ]; then \
  146. install -m 644 doc/design-paper/tor-design.ps $(CURDIR)/debian/tor/usr/share/doc/tor/; \
  147. install -m 644 doc/design-paper/tor-design.pdf $(CURDIR)/debian/tor/usr/share/doc/tor/; \
  148. fi
  149. dh_installexamples
  150. # dh_install
  151. # dh_installdebconf
  152. dh_installlogrotate
  153. # dh_installemacsen
  154. # dh_installmime
  155. dh_installinit
  156. # dh_installcron
  157. dh_installman
  158. dh_link
  159. # Change this for debhelper compatibility level 5 or later!
  160. dh_strip --dbg-package=tor
  161. dh_compress
  162. dh_fixperms
  163. dh_installdeb
  164. dh_shlibdeps
  165. dh_gencontrol
  166. dh_md5sums
  167. dh_builddeb
  168. @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
  169. binary: binary-indep binary-arch
  170. .PHONY: build clean binary-indep binary-arch binary install