configure.in 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. dnl Copyright (c) 2001-2004, Roger Dingledine
  2. dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  3. dnl Copyright (c) 2007-2008, The Tor Project, Inc.
  4. dnl See LICENSE for licensing information
  5. AC_INIT
  6. AM_INIT_AUTOMAKE(tor, 0.2.3.0-alpha-dev)
  7. AM_CONFIG_HEADER(orconfig.h)
  8. AC_CANONICAL_HOST
  9. if test -f /etc/redhat-release ; then
  10. if test -f /usr/kerberos/include ; then
  11. CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
  12. fi
  13. fi
  14. # Not a no-op; we want to make sure that CPPFLAGS is set before we use
  15. # the += operator on it in src/or/Makefile.am
  16. CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common"
  17. #XXXX020 We should make these enabled or not, before 0.2.0.x-final
  18. AC_ARG_ENABLE(buf-freelists,
  19. AS_HELP_STRING(--disable-buf-freelists, disable freelists for buffer RAM))
  20. AC_ARG_ENABLE(openbsd-malloc,
  21. AS_HELP_STRING(--enable-openbsd-malloc, Use malloc code from openbsd. Linux only))
  22. AC_ARG_ENABLE(instrument-downloads,
  23. AS_HELP_STRING(--enable-instrument-downloads, Instrument downloads of directory resources etc.))
  24. AC_ARG_ENABLE(static-openssl,
  25. AS_HELP_STRING(--enable-static-openssl, Link against a static openssl library. Requires --with-openssl-dir))
  26. AC_ARG_ENABLE(static-libevent,
  27. AS_HELP_STRING(--enable-static-libevent, Link against a static libevent library. Requires --with-libevent-dir))
  28. AC_ARG_ENABLE(static-zlib,
  29. AS_HELP_STRING(--enable-static-zlib, Link against a static zlib library. Requires --with-zlib-dir))
  30. AC_ARG_ENABLE(static-tor,
  31. AS_HELP_STRING(--enable-static-tor, Create an entirely static Tor binary. Requires --static-openssl
  32. --static-libevent and --static-zlib))
  33. if test "$enable_static_tor" = "yes"; then
  34. enable_static_libevent="yes";
  35. enable_static_openssl="yes";
  36. enable_static_zlib="yes";
  37. AC_MSG_NOTICE("We're attempting to build a static Tor.")
  38. CFLAGS="$CFLAGS -static"
  39. fi
  40. if test x$enable_buf_freelists != xno; then
  41. AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
  42. [Defined if we try to use freelists for buffer RAM chunks])
  43. fi
  44. AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
  45. if test x$enable_instrument_downloads = xyes; then
  46. AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
  47. [Defined if we want to keep track of how much of each kind of resource we download.])
  48. fi
  49. AC_ARG_ENABLE(transparent,
  50. AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
  51. [case "${enableval}" in
  52. yes) transparent=true ;;
  53. no) transparent=false ;;
  54. *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
  55. esac], [transparent=true])
  56. AC_ARG_ENABLE(asciidoc,
  57. AS_HELP_STRING(--disable-asciidoc, don't use asciidoc (disables building of manpages)),
  58. [case "${enableval}" in
  59. yes) asciidoc=true ;;
  60. no) asciidoc=false ;;
  61. *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
  62. esac], [asciidoc=true])
  63. # By default, we're not ready to ship a NAT-PMP aware Tor
  64. AC_ARG_ENABLE(nat-pmp,
  65. AS_HELP_STRING(--enable-nat-pmp, enable NAT-PMP support),
  66. [case "${enableval}" in
  67. yes) natpmp=true ;;
  68. no) natpmp=false ;;
  69. * ) AC_MSG_ERROR(bad value for --enable-nat-pmp) ;;
  70. esac], [natpmp=false])
  71. # By default, we're not ready to ship a UPnP aware Tor
  72. AC_ARG_ENABLE(upnp,
  73. AS_HELP_STRING(--enable-upnp, enable UPnP support),
  74. [case "${enableval}" in
  75. yes) upnp=true ;;
  76. no) upnp=false ;;
  77. * ) AC_MSG_ERROR(bad value for --enable-upnp) ;;
  78. esac], [upnp=false])
  79. AC_ARG_ENABLE(threads,
  80. AS_HELP_STRING(--disable-threads, disable multi-threading support))
  81. if test x$enable_threads = x; then
  82. case $host in
  83. *-*-solaris* )
  84. # Don't try multithreading on solaris -- cpuworkers seem to lock.
  85. AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
  86. cpu workers lock up here, so I will disable threads.])
  87. enable_threads="no";;
  88. *)
  89. enable_threads="yes";;
  90. esac
  91. fi
  92. if test "$enable_threads" = "yes"; then
  93. AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
  94. fi
  95. case $host in
  96. *-*-solaris* )
  97. AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
  98. ;;
  99. esac
  100. AC_ARG_ENABLE(gcc-warnings,
  101. AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
  102. AC_ARG_ENABLE(gcc-warnings-advisory,
  103. AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
  104. dnl Adam shostack suggests the following for Windows:
  105. dnl -D_FORTIFY_SOURCE=2 -fstack-protector-all
  106. dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
  107. dnl This requires that we use gcc and that we add -O2 to the CFLAGS.
  108. AC_ARG_ENABLE(gcc-hardening,
  109. AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks),
  110. [if test x$enableval = xyes; then
  111. CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
  112. CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
  113. CFLAGS="$CFLAGS --param ssp-buffer-size=1"
  114. LDFLAGS="$LDFLAGS -pie"
  115. fi])
  116. dnl Linker hardening options
  117. dnl Currently these options are ELF specific - you can't use this with MacOSX
  118. AC_ARG_ENABLE(linker-hardening,
  119. AS_HELP_STRING(--enable-linker-hardening, enable linker security fixups),
  120. [if test x$enableval = xyes; then
  121. LDFLAGS="$LDFLAGS -z relro -z now"
  122. fi])
  123. AC_ARG_ENABLE(local-appdata,
  124. AS_HELP_STRING(--enable-local-appdata, default to host local application data paths on Windows))
  125. if test "$enable_local_appdata" = "yes"; then
  126. AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
  127. [Defined if we default to host local appdata paths on Windows])
  128. fi
  129. AC_ARG_ENABLE(bufferevents,
  130. AS_HELP_STRING(--enable-bufferevents, use Libevent's buffered IO.))
  131. AC_PROG_CC
  132. AC_PROG_CPP
  133. AC_PROG_MAKE_SET
  134. AC_PROG_RANLIB
  135. dnl autoconf 2.59 appears not to support AC_PROG_SED
  136. AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
  137. dnl check for asciidoc and a2x
  138. AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
  139. AC_PATH_PROG([A2X], [a2x], none)
  140. AM_CONDITIONAL(USE_ASCIIDOC, test x$asciidoc = xtrue)
  141. AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
  142. AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
  143. AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
  144. AM_PROG_CC_C_O
  145. ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
  146. AC_C_FLEXIBLE_ARRAY_MEMBER
  147. ], [
  148. dnl Maybe we've got an old autoconf...
  149. AC_CACHE_CHECK([for flexible array members],
  150. tor_cv_c_flexarray,
  151. [AC_COMPILE_IFELSE(
  152. AC_LANG_PROGRAM([
  153. struct abc { int a; char b[]; };
  154. ], [
  155. struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
  156. def->b[0] = 33;
  157. ]),
  158. [tor_cv_c_flexarray=yes],
  159. [tor_cv_c_flexarray=no])])
  160. if test $tor_cv_flexarray = yes ; then
  161. AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [])
  162. else
  163. AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1])
  164. fi
  165. ])
  166. AC_PATH_PROG([SHA1SUM], [sha1sum], none)
  167. AC_PATH_PROG([OPENSSL], [openssl], none)
  168. TORUSER=_tor
  169. AC_ARG_WITH(tor-user,
  170. [ --with-tor-user=NAME Specify username for tor daemon ],
  171. [
  172. TORUSER=$withval
  173. ]
  174. )
  175. AC_SUBST(TORUSER)
  176. TORGROUP=_tor
  177. AC_ARG_WITH(tor-group,
  178. [ --with-tor-group=NAME Specify group name for tor daemon ],
  179. [
  180. TORGROUP=$withval
  181. ]
  182. )
  183. AC_SUBST(TORGROUP)
  184. dnl If WIN32 is defined and non-zero, we are building for win32
  185. AC_MSG_CHECKING([for win32])
  186. AC_RUN_IFELSE([AC_LANG_SOURCE([
  187. int main(int c, char **v) {
  188. #ifdef WIN32
  189. #if WIN32
  190. return 0;
  191. #else
  192. return 1;
  193. #endif
  194. #else
  195. return 2;
  196. #endif
  197. }])],
  198. bwin32=true; AC_MSG_RESULT([yes]),
  199. bwin32=false; AC_MSG_RESULT([no]),
  200. bwin32=cross; AC_MSG_RESULT([cross])
  201. )
  202. if test "$bwin32" = cross; then
  203. AC_MSG_CHECKING([for win32 (cross)])
  204. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  205. #ifdef WIN32
  206. int main(int c, char **v) {return 0;}
  207. #else
  208. #error
  209. int main(int c, char **v) {return x(y);}
  210. #endif
  211. ])],
  212. bwin32=true; AC_MSG_RESULT([yes]),
  213. bwin32=false; AC_MSG_RESULT([no]))
  214. fi
  215. if test "$bwin32" = true; then
  216. AC_DEFINE(MS_WINDOWS, 1, [Define to 1 if we are building for Windows.])
  217. fi
  218. AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
  219. dnl Enable C99 when compiling with MIPSpro
  220. AC_MSG_CHECKING([for MIPSpro compiler])
  221. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
  222. #if (defined(__sgi) && defined(_COMPILER_VERSION))
  223. #error
  224. return x(y);
  225. #endif
  226. ])],
  227. bmipspro=false; AC_MSG_RESULT(no),
  228. bmipspro=true; AC_MSG_RESULT(yes))
  229. if test "$bmipspro" = true; then
  230. CFLAGS="$CFLAGS -c99"
  231. fi
  232. AC_C_BIGENDIAN
  233. AC_SEARCH_LIBS(socket, [socket])
  234. AC_SEARCH_LIBS(gethostbyname, [nsl])
  235. AC_SEARCH_LIBS(dlopen, [dl])
  236. AC_SEARCH_LIBS(inet_aton, [resolv])
  237. if test "$enable_threads" = "yes"; then
  238. AC_SEARCH_LIBS(pthread_create, [pthread])
  239. AC_SEARCH_LIBS(pthread_detach, [pthread])
  240. fi
  241. dnl -------------------------------------------------------------------
  242. dnl Check for functions before libevent, since libevent-1.2 apparently
  243. dnl exports strlcpy without defining it in a header.
  244. AC_CHECK_FUNCS(
  245. accept4 \
  246. flock \
  247. ftime \
  248. getaddrinfo \
  249. getrlimit \
  250. gettimeofday \
  251. gmtime_r \
  252. inet_aton \
  253. localtime_r \
  254. memmem \
  255. prctl \
  256. socketpair \
  257. strlcat \
  258. strlcpy \
  259. strptime \
  260. strtok_r \
  261. strtoull \
  262. sysconf \
  263. uname \
  264. vasprintf \
  265. )
  266. using_custom_malloc=no
  267. if test x$enable_openbsd_malloc = xyes ; then
  268. AC_DEFINE(HAVE_MALLOC_GOOD_SIZE, 1, [Defined if we have the malloc_good_size function])
  269. using_custom_malloc=yes
  270. fi
  271. if test x$tcmalloc = xyes ; then
  272. using_custom_malloc=yes
  273. fi
  274. if test $using_custom_malloc = no ; then
  275. AC_CHECK_FUNCS(mallinfo malloc_good_size malloc_usable_size)
  276. fi
  277. if test "$enable_threads" = "yes"; then
  278. AC_CHECK_HEADERS(pthread.h)
  279. AC_CHECK_FUNCS(pthread_create)
  280. fi
  281. dnl ------------------------------------------------------
  282. dnl Where do you live, libevent? And how do we call you?
  283. if test "$bwin32" = true; then
  284. TOR_LIB_WS32=-lws2_32
  285. # Some of the cargo-cults recommend -lwsock32 as well, but I don't
  286. # think it's actually necessary.
  287. TOR_LIB_GDI=-lgdi32
  288. else
  289. TOR_LIB_WS32=
  290. TOR_LIB_GDI=
  291. fi
  292. AC_SUBST(TOR_LIB_WS32)
  293. AC_SUBST(TOR_LIB_GDI)
  294. dnl We need to do this before we try our disgusting hack below.
  295. AC_CHECK_HEADERS([sys/types.h])
  296. dnl This is a disgusting hack so we safely include older libevent headers.
  297. AC_CHECK_TYPE(u_int64_t, unsigned long long)
  298. AC_CHECK_TYPE(u_int32_t, unsigned long)
  299. AC_CHECK_TYPE(u_int16_t, unsigned short)
  300. AC_CHECK_TYPE(u_int8_t, unsigned char)
  301. tor_libevent_pkg_redhat="libevent"
  302. tor_libevent_pkg_debian="libevent-dev"
  303. tor_libevent_devpkg_redhat="libevent-devel"
  304. tor_libevent_devpkg_debian="libevent-dev"
  305. dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
  306. dnl linking for static builds.
  307. STATIC_LIBEVENT_FLAGS=""
  308. if test "$enable_static_libevent" = "yes"; then
  309. dnl Determine if we have clock_gettime in librt
  310. AC_SEARCH_LIBS([clock_gettime], [rt],
  311. [have_rt=yes])
  312. if test "$have_rt" = yes; then
  313. STATIC_LIBEVENT_FLAGS=" -lrt "
  314. fi
  315. fi
  316. TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
  317. #ifdef WIN32
  318. #include <winsock2.h>
  319. #endif
  320. #include <stdlib.h>
  321. #include <sys/time.h>
  322. #include <sys/types.h>
  323. #include <event.h>], [
  324. #ifdef WIN32
  325. #include <winsock2.h>
  326. #endif
  327. void exit(int); void *event_init(void);],
  328. [
  329. #ifdef WIN32
  330. {WSADATA d; WSAStartup(0x101,&d); }
  331. #endif
  332. event_init(); exit(0);
  333. ], [--with-libevent-dir], [/opt/libevent])
  334. dnl Now check for particular libevent functions.
  335. save_LIBS="$LIBS"
  336. save_LDFLAGS="$LDFLAGS"
  337. save_CPPFLAGS="$CPPFLAGS"
  338. LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
  339. LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
  340. CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
  341. AC_CHECK_FUNCS(event_get_version event_get_version_number event_get_method event_set_log_callback evdns_set_outgoing_bind_address event_base_loopexit)
  342. AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
  343. [#include <event.h>
  344. ])
  345. AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
  346. LIBS="$save_LIBS"
  347. LDFLAGS="$save_LDFLAGS"
  348. CPPFLAGS="$save_CPPFLAGS"
  349. AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
  350. if test "$enable_static_libevent" = "yes"; then
  351. if test "$tor_cv_library_libevent_dir" = "(system)"; then
  352. AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
  353. else
  354. TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
  355. fi
  356. else
  357. TOR_LIBEVENT_LIBS="-levent"
  358. fi
  359. AC_SUBST(TOR_LIBEVENT_LIBS)
  360. dnl This isn't the best test for Libevent 2.0.3-alpha. Once it's released,
  361. dnl we can do much better.
  362. if test "$enable_bufferevents" = "yes" ; then
  363. if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
  364. AC_MSG_ERROR([You've asked for bufferevent support, but you're using a version of Libevent without SSL support. This won't work. We need Libevent 2.0.8-rc or later, and you don't seem to even have Libevent 2.0.3-alpha.])
  365. else
  366. CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
  367. # Check for the right version. First see if version detection works.
  368. AC_MSG_CHECKING([whether we can detect the Libevent version])
  369. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  370. #include <event2/event.h>
  371. #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
  372. #error
  373. int x = y(zz);
  374. #else
  375. int x = 1;
  376. #endif
  377. ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
  378. [event_version_number_works=no; AC_MSG_RESULT([no])])
  379. if test "$event_version_number_works" != 'yes'; then
  380. AC_MSG_WARN([Version detection on Libevent seems broken. Your Libevent installation is probably screwed up or very old.])
  381. else
  382. AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
  383. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  384. #include <event2/event.h>
  385. #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000800
  386. #error
  387. int x = y(zz);
  388. #else
  389. int x = 1;
  390. #endif
  391. ])], [ AC_MSG_RESULT([yes]) ],
  392. [ AC_MSG_RESULT([no])
  393. AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents. We require 2.0.8-rc or later]) ] )
  394. fi
  395. fi
  396. fi
  397. LIBS="$save_LIBS"
  398. LDFLAGS="$save_LDFLAGS"
  399. CPPFLAGS="$save_CPPFLAGS"
  400. AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
  401. if test "$enable_bufferevents" = "yes"; then
  402. AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
  403. fi
  404. dnl ------------------------------------------------------
  405. dnl Where do you live, openssl? And how do we call you?
  406. tor_openssl_pkg_redhat="openssl"
  407. tor_openssl_pkg_debian="libssl"
  408. tor_openssl_devpkg_redhat="openssl-devel"
  409. tor_openssl_devpkg_debian="libssl-dev"
  410. ALT_openssl_WITHVAL=""
  411. AC_ARG_WITH(ssl-dir,
  412. [ --with-ssl-dir=PATH Obsolete alias for --with-openssl-dir ],
  413. [
  414. if test "x$withval" != xno && test "x$withval" != "x" ; then
  415. ALT_openssl_WITHVAL="$withval"
  416. fi
  417. ])
  418. TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
  419. [#include <openssl/rand.h>],
  420. [void RAND_add(const void *buf, int num, double entropy);],
  421. [RAND_add((void*)0,0,0); exit(0);], [],
  422. [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
  423. dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
  424. echo "tor_cv_library_openssl_dir is $tor_cv_library_openssl_dir"
  425. if test "$enable_static_openssl" = "yes"; then
  426. if test "$tor_cv_library_openssl_dir" = "(system)"; then
  427. AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
  428. else
  429. TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
  430. fi
  431. else
  432. TOR_OPENSSL_LIBS="-lssl -lcrypto"
  433. fi
  434. AC_SUBST(TOR_OPENSSL_LIBS)
  435. dnl ------------------------------------------------------
  436. dnl Where do you live, zlib? And how do we call you?
  437. tor_zlib_pkg_redhat="zlib"
  438. tor_zlib_pkg_debian="zlib1g"
  439. tor_zlib_devpkg_redhat="zlib-devel"
  440. tor_zlib_devpkg_debian="zlib1g-dev"
  441. TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
  442. [#include <zlib.h>],
  443. [const char * zlibVersion(void);],
  444. [zlibVersion(); exit(0);], [--with-zlib-dir],
  445. [/opt/zlib])
  446. if test "$enable_static_zlib" = "yes"; then
  447. if test "$tor_cv_library_zlib_dir" = "(system)"; then
  448. AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
  449. using --enable-static-zlib")
  450. else
  451. TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
  452. echo "$TOR_LIBDIR_zlib/libz.a"
  453. fi
  454. else
  455. TOR_ZLIB_LIBS="-lz"
  456. fi
  457. AC_SUBST(TOR_ZLIB_LIBS)
  458. if test "$enable_static_tor" = "yes"; then
  459. if test "$enable_static_libevent" = "no"; then
  460. AC_MSG_ERROR("You must configure with --enable-static-libevent")
  461. fi
  462. if test "$enable_static_openssl" = "no"; then
  463. AC_MSG_ERROR("You must configure with --enable-static-openssl")
  464. fi
  465. if test "$enable_static_zlib" = "no"; then
  466. AC_MSG_ERROR("You must configure with --enable-static-zlib")
  467. fi
  468. AC_MSG_NOTICE("We're attempting to build a static Tor.")
  469. CFLAGS="$CFLAGS -static"
  470. fi
  471. dnl Make sure to enable support for large off_t if available.
  472. dnl ------------------------------------------------------
  473. dnl Where do you live, libnatpmp? And how do we call you?
  474. dnl There are no packages for Debian or Redhat as of this patch
  475. if test "$natpmp" = "true"; then
  476. AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
  477. TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp],
  478. [#include <natpmp.h>],
  479. [#include <natpmp.h>],
  480. [ int r;
  481. natpmp_t natpmp;
  482. natpmpresp_t response;
  483. r = initnatpmp(&natpmp);],
  484. [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
  485. exit(0);],
  486. [--with-libnatpmp-dir],
  487. [/usr/lib/])
  488. fi
  489. dnl ------------------------------------------------------
  490. dnl Where do you live, libminiupnpc? And how do we call you?
  491. dnl There are no packages for Debian or Redhat as of this patch
  492. if test "$upnp" = "true"; then
  493. AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
  494. TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc],
  495. [#include <miniupnpc/miniwget.h>
  496. #include <miniupnpc/miniupnpc.h>
  497. #include <miniupnpc/upnpcommands.h>],
  498. [void upnpDiscover(int delay, const char * multicastif,
  499. const char * minissdpdsock, int sameport);],
  500. [upnpDiscover(1, 0, 0, 0); exit(0);],
  501. [--with-libminiupnpc-dir],
  502. [/usr/lib/])
  503. fi
  504. AC_SYS_LARGEFILE
  505. AC_CHECK_HEADERS(
  506. assert.h \
  507. errno.h \
  508. fcntl.h \
  509. signal.h \
  510. string.h \
  511. sys/fcntl.h \
  512. sys/stat.h \
  513. sys/time.h \
  514. sys/types.h \
  515. time.h \
  516. unistd.h
  517. , , AC_MSG_WARN(Some headers were not found, compilation may fail. If compilation succeeds, please send your orconfig.h to the developers so we can fix this warning.))
  518. dnl These headers are not essential
  519. AC_CHECK_HEADERS(
  520. arpa/inet.h \
  521. grp.h \
  522. inttypes.h \
  523. limits.h \
  524. linux/types.h \
  525. machine/limits.h \
  526. malloc.h \
  527. malloc/malloc.h \
  528. malloc_np.h \
  529. netdb.h \
  530. netinet/in.h \
  531. netinet/in6.h \
  532. pwd.h \
  533. stdint.h \
  534. sys/file.h \
  535. sys/ioctl.h \
  536. sys/limits.h \
  537. sys/mman.h \
  538. sys/param.h \
  539. sys/prctl.h \
  540. sys/resource.h \
  541. sys/socket.h \
  542. sys/syslimits.h \
  543. sys/time.h \
  544. sys/types.h \
  545. sys/un.h \
  546. sys/utime.h \
  547. sys/wait.h \
  548. syslog.h \
  549. utime.h
  550. )
  551. TOR_CHECK_PROTOTYPE(malloc_good_size, HAVE_MALLOC_GOOD_SIZE_PROTOTYPE,
  552. [#ifdef HAVE_MALLOC_H
  553. #include <malloc.h>
  554. #endif
  555. #ifdef HAVE_MALLOC_MALLOC_H
  556. #include <malloc/malloc.h>
  557. #endif])
  558. AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
  559. [#ifdef HAVE_SYS_TYPES_H
  560. #include <sys/types.h>
  561. #endif
  562. #ifdef HAVE_SYS_SOCKET_H
  563. #include <sys/socket.h>
  564. #endif])
  565. AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
  566. [#ifdef HAVE_SYS_TYPES_H
  567. #include <sys/types.h>
  568. #endif
  569. #ifdef HAVE_SYS_SOCKET_H
  570. #include <sys/socket.h>
  571. #endif
  572. #ifdef HAVE_NET_IF_H
  573. #include <net/if.h>
  574. #endif])
  575. AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
  576. linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
  577. [#ifdef HAVE_SYS_TYPES_H
  578. #include <sys/types.h>
  579. #endif
  580. #ifdef HAVE_SYS_SOCKET_H
  581. #include <sys/socket.h>
  582. #endif
  583. #ifdef HAVE_LIMITS_H
  584. #include <limits.h>
  585. #endif
  586. #ifdef HAVE_LINUX_TYPES_H
  587. #include <linux/types.h>
  588. #endif
  589. #ifdef HAVE_NETINET_IN6_H
  590. #include <netinet/in6.h>
  591. #endif
  592. #ifdef HAVE_NETINET_IN_H
  593. #include <netinet/in.h>
  594. #endif])
  595. if test x$transparent = xtrue ; then
  596. transparent_ok=0
  597. if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
  598. transparent_ok=1
  599. fi
  600. if test x$linux_netfilter_ipv4 = x1 ; then
  601. transparent_ok=1
  602. fi
  603. if test x$transparent_ok = x1 ; then
  604. AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
  605. case $host in
  606. *-*-openbsd*)
  607. AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
  608. esac
  609. else
  610. AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
  611. fi
  612. fi
  613. AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
  614. [#ifdef HAVE_SYS_TYPES_H
  615. #include <sys/types.h>
  616. #endif
  617. #ifdef HAVE_SYS_TIME_H
  618. #include <sys/time.h>
  619. #endif])
  620. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  621. dnl Watch out.
  622. AC_CHECK_SIZEOF(int8_t)
  623. AC_CHECK_SIZEOF(int16_t)
  624. AC_CHECK_SIZEOF(int32_t)
  625. AC_CHECK_SIZEOF(int64_t)
  626. AC_CHECK_SIZEOF(uint8_t)
  627. AC_CHECK_SIZEOF(uint16_t)
  628. AC_CHECK_SIZEOF(uint32_t)
  629. AC_CHECK_SIZEOF(uint64_t)
  630. AC_CHECK_SIZEOF(intptr_t)
  631. AC_CHECK_SIZEOF(uintptr_t)
  632. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  633. AC_CHECK_SIZEOF(char)
  634. AC_CHECK_SIZEOF(short)
  635. AC_CHECK_SIZEOF(int)
  636. AC_CHECK_SIZEOF(long)
  637. AC_CHECK_SIZEOF(long long)
  638. AC_CHECK_SIZEOF(__int64)
  639. AC_CHECK_SIZEOF(void *)
  640. AC_CHECK_SIZEOF(time_t)
  641. AC_CHECK_SIZEOF(size_t)
  642. AC_CHECK_TYPES([uint, u_char, ssize_t])
  643. dnl used to include sockaddr_storage, but everybody has that.
  644. AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
  645. [#ifdef HAVE_SYS_TYPES_H
  646. #include <sys/types.h>
  647. #endif
  648. #ifdef HAVE_NETINET_IN_H
  649. #include <netinet/in.h>
  650. #endif
  651. #ifdef HAVE_NETINET_IN6_H
  652. #include <netinet/in6.h>
  653. #endif
  654. #ifdef HAVE_SYS_SOCKET_H
  655. #include <sys/socket.h>
  656. #endif
  657. #ifdef MS_WINDOWS
  658. #define WIN32_WINNT 0x400
  659. #define _WIN32_WINNT 0x400
  660. #define WIN32_LEAN_AND_MEAN
  661. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  662. #include <winsock.h>
  663. #else
  664. #include <winsock2.h>
  665. #include <ws2tcpip.h>
  666. #endif
  667. #endif
  668. ])
  669. AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
  670. [#ifdef HAVE_SYS_TYPES_H
  671. #include <sys/types.h>
  672. #endif
  673. #ifdef HAVE_NETINET_IN_H
  674. #include <netinet/in.h>
  675. #endif
  676. #ifdef HAVE_NETINET_IN6_H
  677. #include <netinet/in6.h>
  678. #endif
  679. #ifdef HAVE_SYS_SOCKET_H
  680. #include <sys/socket.h>
  681. #endif
  682. #ifdef MS_WINDOWS
  683. #define WIN32_WINNT 0x400
  684. #define _WIN32_WINNT 0x400
  685. #define WIN32_LEAN_AND_MEAN
  686. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  687. #include <winsock.h>
  688. #else
  689. #include <winsock2.h>
  690. #include <ws2tcpip.h>
  691. #endif
  692. #endif
  693. ])
  694. AC_CHECK_TYPES([rlim_t], , ,
  695. [#ifdef HAVE_SYS_TYPES_H
  696. #include <sys/types.h>
  697. #endif
  698. #ifdef HAVE_SYS_TIME_H
  699. #include <sys/time.h>
  700. #endif
  701. #ifdef HAVE_SYS_RESOURCE_H
  702. #include <sys/resource.h>
  703. #endif
  704. ])
  705. AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
  706. AC_RUN_IFELSE([AC_LANG_SOURCE([
  707. #ifdef HAVE_SYS_TYPES_H
  708. #include <sys/types.h>
  709. #endif
  710. #ifdef HAVE_SYS_TIME_H
  711. #include <sys/time.h>
  712. #endif
  713. #ifdef HAVE_TIME_H
  714. #include <time.h>
  715. #endif
  716. int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }])],
  717. tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes, tor_cv_time_t_signed=cross)
  718. ])
  719. if test "$tor_cv_time_t_signed" = cross; then
  720. AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
  721. fi
  722. if test "$tor_cv_time_t_signed" != no; then
  723. AC_DEFINE([TIME_T_IS_SIGNED], 1,
  724. [Define to 1 iff time_t is signed])
  725. fi
  726. AC_CACHE_CHECK([whether size_t is signed], tor_cv_size_t_signed, [
  727. AC_RUN_IFELSE([AC_LANG_SOURCE([
  728. #ifdef HAVE_SYS_TYPES_H
  729. #include <sys/types.h>
  730. #endif
  731. int main(int c, char**v) { if (((size_t)-1)<0) return 1; else return 0; }])],
  732. tor_cv_size_t_signed=no, tor_cv_size_t_signed=yes, tor_cv_size_t_signed=cross)
  733. ])
  734. if test "$tor_cv_size_t_signed" = cross; then
  735. AC_MSG_NOTICE([Cross compiling: assuming that size_t is not signed.])
  736. fi
  737. if test "$tor_cv_size_t_signed" = yes; then
  738. AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
  739. fi
  740. AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
  741. #ifdef HAVE_SYS_SOCKET_H
  742. #include <sys/socket.h>
  743. #endif
  744. ])
  745. # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
  746. AC_CHECK_SIZEOF(cell_t)
  747. # Now make sure that NULL can be represented as zero bytes.
  748. AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
  749. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  750. [[#include <stdlib.h>
  751. #include <string.h>
  752. #include <stdio.h>
  753. #ifdef HAVE_STDDEF_H
  754. #include <stddef.h>
  755. #endif
  756. int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
  757. return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
  758. [tor_cv_null_is_zero=yes],
  759. [tor_cv_null_is_zero=no],
  760. [tor_cv_null_is_zero=cross])])
  761. if test "$tor_cv_null_is_zero" = cross ; then
  762. # Cross-compiling; let's hope that the target isn't raving mad.
  763. AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
  764. fi
  765. if test "$tor_cv_null_is_zero" != no; then
  766. AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
  767. [Define to 1 iff memset(0) sets pointers to NULL])
  768. fi
  769. # And what happens when we malloc zero?
  770. AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
  771. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  772. [[#include <stdlib.h>
  773. #include <string.h>
  774. #include <stdio.h>
  775. #ifdef HAVE_STDDEF_H
  776. #include <stddef.h>
  777. #endif
  778. int main () { return malloc(0)?0:1; }]])],
  779. [tor_cv_malloc_zero_works=yes],
  780. [tor_cv_malloc_zero_works=no],
  781. [tor_cv_malloc_zero_works=cross])])
  782. if test "$tor_cv_malloc_zero_works" = cross; then
  783. # Cross-compiling; let's hope that the target isn't raving mad.
  784. AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
  785. fi
  786. if test "$tor_cv_malloc_zero_works" = yes; then
  787. AC_DEFINE([MALLOC_ZERO_WORKS], 1,
  788. [Define to 1 iff malloc(0) returns a pointer])
  789. fi
  790. # whether we seem to be in a 2s-complement world.
  791. AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
  792. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  793. [[int main () { int problem = ((-99) != (~99)+1);
  794. return problem ? 1 : 0; }]])],
  795. [tor_cv_twos_complement=yes],
  796. [tor_cv_twos_complement=no],
  797. [tor_cv_twos_complement=cross])])
  798. if test "$tor_cv_twos_complement" = cross ; then
  799. # Cross-compiling; let's hope that the target isn't raving mad.
  800. AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
  801. fi
  802. if test "$tor_cv_twos_complement" != no ; then
  803. AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
  804. [Define to 1 iff we represent negative integers with two's complement])
  805. fi
  806. # Whether we should use the dmalloc memory allocation debugging library.
  807. AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
  808. AC_ARG_WITH(dmalloc,
  809. [ --with-dmalloc Use debug memory allocation library. ],
  810. [if [[ "$withval" = "yes" ]]; then
  811. dmalloc=1
  812. AC_MSG_RESULT(yes)
  813. else
  814. dmalloc=1
  815. AC_MSG_RESULT(no)
  816. fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
  817. )
  818. if [[ $dmalloc -eq 1 ]]; then
  819. AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
  820. AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
  821. AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
  822. AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
  823. AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
  824. fi
  825. AC_ARG_WITH(tcmalloc,
  826. [ --with-tcmalloc Use tcmalloc memory allocation library. ],
  827. [ tcmalloc=yes ], [ tcmalloc=no ])
  828. if test x$tcmalloc = xyes ; then
  829. LDFLAGS="-ltcmalloc $LDFLAGS"
  830. fi
  831. # By default, we're going to assume we don't have mlockall()
  832. # bionic and other platforms have various broken mlockall subsystems.
  833. # Some systems don't have a working mlockall, some aren't linkable,
  834. # and some have it but don't declare it.
  835. AC_CHECK_FUNCS(mlockall)
  836. AC_CHECK_DECLS([mlockall], , , [
  837. #ifdef HAVE_SYS_MMAN_H
  838. #include <sys/mman.h>
  839. #endif])
  840. # Allow user to specify an alternate syslog facility
  841. AC_ARG_WITH(syslog-facility,
  842. [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
  843. syslog_facility="$withval", syslog_facility="LOG_DAEMON")
  844. AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
  845. AC_SUBST(LOGFACILITY)
  846. # Check if we have getresuid and getresgid
  847. AC_CHECK_FUNCS(getresuid getresgid)
  848. # Check for gethostbyname_r in all its glorious incompatible versions.
  849. # (This logic is based on that in Python's configure.in)
  850. AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
  851. [Define this if you have any gethostbyname_r()])
  852. AC_CHECK_FUNC(gethostbyname_r, [
  853. AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
  854. OLD_CFLAGS=$CFLAGS
  855. CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
  856. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  857. #include <netdb.h>
  858. ], [[
  859. char *cp1, *cp2;
  860. struct hostent *h1, *h2;
  861. int i1, i2;
  862. (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
  863. ]])],[
  864. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  865. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
  866. [Define this if gethostbyname_r takes 6 arguments])
  867. AC_MSG_RESULT(6)
  868. ], [
  869. AC_TRY_COMPILE([
  870. #include <netdb.h>
  871. ], [
  872. char *cp1, *cp2;
  873. struct hostent *h1;
  874. int i1, i2;
  875. (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
  876. ], [
  877. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  878. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
  879. [Define this if gethostbyname_r takes 5 arguments])
  880. AC_MSG_RESULT(5)
  881. ], [
  882. AC_TRY_COMPILE([
  883. #include <netdb.h>
  884. ], [
  885. char *cp1;
  886. struct hostent *h1;
  887. struct hostent_data hd;
  888. (void) gethostbyname_r(cp1,h1,&hd);
  889. ], [
  890. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  891. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
  892. [Define this if gethostbyname_r takes 3 arguments])
  893. AC_MSG_RESULT(3)
  894. ], [
  895. AC_MSG_RESULT(0)
  896. ])
  897. ])
  898. ])
  899. CFLAGS=$OLD_CFLAGS
  900. ])
  901. AC_CACHE_CHECK([whether the C compiler supports __func__],
  902. tor_cv_have_func_macro,
  903. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  904. #include <stdio.h>
  905. int main(int c, char **v) { puts(__func__); }])],
  906. tor_cv_have_func_macro=yes,
  907. tor_cv_have_func_macro=no))
  908. AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
  909. tor_cv_have_FUNC_macro,
  910. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  911. #include <stdio.h>
  912. int main(int c, char **v) { puts(__FUNC__); }])],
  913. tor_cv_have_FUNC_macro=yes,
  914. tor_cv_have_FUNC_macro=no))
  915. AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
  916. tor_cv_have_FUNCTION_macro,
  917. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  918. #include <stdio.h>
  919. int main(int c, char **v) { puts(__FUNCTION__); }])],
  920. tor_cv_have_FUNCTION_macro=yes,
  921. tor_cv_have_FUNCTION_macro=no))
  922. if test "$tor_cv_have_func_macro" = 'yes'; then
  923. AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
  924. fi
  925. if test "$tor_cv_have_FUNC_macro" = 'yes'; then
  926. AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
  927. fi
  928. if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
  929. AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
  930. [Defined if the compiler supports __FUNCTION__])
  931. fi
  932. # $prefix stores the value of the --prefix command line option, or
  933. # NONE if the option wasn't set. In the case that it wasn't set, make
  934. # it be the default, so that we can use it to expand directories now.
  935. if test "x$prefix" = "xNONE"; then
  936. prefix=$ac_default_prefix
  937. fi
  938. # and similarly for $exec_prefix
  939. if test "x$exec_prefix" = "xNONE"; then
  940. exec_prefix=$prefix
  941. fi
  942. if test "x$BUILDDIR" = "x"; then
  943. BUILDDIR=`pwd`
  944. fi
  945. AC_SUBST(BUILDDIR)
  946. AH_TEMPLATE([BUILDDIR],[tor's build directory])
  947. AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
  948. if test "x$CONFDIR" = "x"; then
  949. CONFDIR=`eval echo $sysconfdir/tor`
  950. fi
  951. AC_SUBST(CONFDIR)
  952. AH_TEMPLATE([CONFDIR],[tor's configuration directory])
  953. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  954. BINDIR=`eval echo $bindir`
  955. AC_SUBST(BINDIR)
  956. LOCALSTATEDIR=`eval echo $localstatedir`
  957. AC_SUBST(LOCALSTATEDIR)
  958. if test "$bwin32" = true; then
  959. # Test if the linker supports the --nxcompat and --dynamicbase options
  960. # for Windows
  961. save_LDFLAGS="$LDFLAGS"
  962. LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
  963. AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
  964. AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
  965. [AC_MSG_RESULT([yes])]
  966. [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
  967. [AC_MSG_RESULT([no])]
  968. )
  969. LDFLAGS="$save_LDFLAGS"
  970. fi
  971. # Set CFLAGS _after_ all the above checks, since our warnings are stricter
  972. # than autoconf's macros like.
  973. if test "$GCC" = yes; then
  974. # Disable GCC's strict aliasing checks. They are an hours-to-debug
  975. # accident waiting to happen.
  976. CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
  977. else
  978. # Autoconf sets -g -O2 by default. Override optimization level
  979. # for non-gcc compilers
  980. CFLAGS="$CFLAGS -O"
  981. enable_gcc_warnings=no
  982. enable_gcc_warnings_advisory=no
  983. fi
  984. # Add some more warnings which we use in development but not in the
  985. # released versions. (Some relevant gcc versions can't handle these.)
  986. if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
  987. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  988. #if !defined(__GNUC__) || (__GNUC__ < 4)
  989. #error
  990. #endif])], have_gcc4=yes, have_gcc4=no)
  991. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  992. #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
  993. #error
  994. #endif])], have_gcc42=yes, have_gcc42=no)
  995. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  996. #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
  997. #error
  998. #endif])], have_gcc43=yes, have_gcc43=no)
  999. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  1000. #if !defined(__clang__) || (__clang_major__ > 2) || (__clang_major__ == 2 && __clang_minor__ > 9)
  1001. #error
  1002. #endif])], have_clang29orlower=yes, have_clang29orlower=no)
  1003. save_CFLAGS="$CFLAGS"
  1004. CFLAGS="$CFLAGS -Wshorten-64-to-32"
  1005. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
  1006. have_shorten64_flag=no)
  1007. CFLAGS="$save_CFLAGS"
  1008. case $host in
  1009. *-*-openbsd*)
  1010. # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
  1011. # That's fine, except that the headers don't pass -Wredundant-decls.
  1012. # Therefore, let's disable -Wsystem-headers when we're building
  1013. # with maximal warnings on OpenBSD.
  1014. CFLAGS="$CFLAGS -Wno-system-headers" ;;
  1015. esac
  1016. CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
  1017. CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
  1018. CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
  1019. CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
  1020. CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
  1021. if test x$enable_gcc_warnings = xyes; then
  1022. CFLAGS="$CFLAGS -Werror"
  1023. fi
  1024. # Disabled, so we can use mallinfo(): -Waggregate-return
  1025. if test x$have_gcc4 = xyes ; then
  1026. # These warnings break gcc 3.3.5 and work on gcc 4.0.2
  1027. CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
  1028. fi
  1029. if test x$have_gcc42 = xyes ; then
  1030. # These warnings break gcc 4.0.2 and work on gcc 4.2
  1031. # XXXX020 See if any of these work with earlier versions.
  1032. CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
  1033. # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
  1034. fi
  1035. if test x$have_gcc42 = xyes && test x$have_clang29orlower = xno; then
  1036. # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
  1037. # We only disable these for clang 2.9 and lower, in case they are
  1038. # supported in later versions.
  1039. CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
  1040. fi
  1041. if test x$have_gcc43 = xyes ; then
  1042. # These warnings break gcc 4.2 and work on gcc 4.3
  1043. # XXXX020 See if any of these work with earlier versions.
  1044. CFLAGS="$CFLAGS -Wextra -Warray-bounds"
  1045. fi
  1046. if test x$have_shorten64_flag = xyes ; then
  1047. CFLAGS="$CFLAGS -Wshorten-64-to-32"
  1048. fi
  1049. ##This will break the world on some 64-bit architectures
  1050. # CFLAGS="$CFLAGS -Winline"
  1051. fi
  1052. CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
  1053. AC_CONFIG_FILES([
  1054. Doxyfile
  1055. Makefile
  1056. contrib/Makefile
  1057. contrib/suse/Makefile
  1058. contrib/suse/tor.sh
  1059. contrib/tor.logrotate
  1060. contrib/tor.sh
  1061. contrib/torctl
  1062. contrib/torify
  1063. doc/Makefile
  1064. src/Makefile
  1065. src/common/Makefile
  1066. src/config/Makefile
  1067. src/config/torrc.sample
  1068. src/or/Makefile
  1069. src/test/Makefile
  1070. src/tools/Makefile
  1071. src/tools/tor-fw-helper/Makefile
  1072. src/win32/Makefile
  1073. tor.spec
  1074. ])
  1075. AC_OUTPUT
  1076. if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
  1077. ./contrib/updateVersions.pl
  1078. fi