configure.ac 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570
  1. dnl Copyright (c) 2001-2004, Roger Dingledine
  2. dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  3. dnl Copyright (c) 2007-2013, The Tor Project, Inc.
  4. dnl See LICENSE for licensing information
  5. AC_INIT([tor],[0.2.5.2-alpha])
  6. AC_CONFIG_SRCDIR([src/or/main.c])
  7. AC_CONFIG_MACRO_DIR([m4])
  8. AM_INIT_AUTOMAKE
  9. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  10. AC_CONFIG_HEADERS([orconfig.h])
  11. AC_CANONICAL_HOST
  12. if test -f /etc/redhat-release ; then
  13. if test -f /usr/kerberos/include ; then
  14. CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
  15. fi
  16. fi
  17. # Not a no-op; we want to make sure that CPPFLAGS is set before we use
  18. # the += operator on it in src/or/Makefile.am
  19. CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common"
  20. #XXXX020 We should make these enabled or not, before 0.2.0.x-final
  21. AC_ARG_ENABLE(buf-freelists,
  22. AS_HELP_STRING(--disable-buf-freelists, disable freelists for buffer RAM))
  23. AC_ARG_ENABLE(openbsd-malloc,
  24. AS_HELP_STRING(--enable-openbsd-malloc, Use malloc code from openbsd. Linux only))
  25. AC_ARG_ENABLE(instrument-downloads,
  26. AS_HELP_STRING(--enable-instrument-downloads, Instrument downloads of directory resources etc.))
  27. AC_ARG_ENABLE(static-openssl,
  28. AS_HELP_STRING(--enable-static-openssl, Link against a static openssl library. Requires --with-openssl-dir))
  29. AC_ARG_ENABLE(static-libevent,
  30. AS_HELP_STRING(--enable-static-libevent, Link against a static libevent library. Requires --with-libevent-dir))
  31. AC_ARG_ENABLE(static-zlib,
  32. AS_HELP_STRING(--enable-static-zlib, Link against a static zlib library. Requires --with-zlib-dir))
  33. AC_ARG_ENABLE(static-tor,
  34. AS_HELP_STRING(--enable-static-tor, Create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir))
  35. AC_ARG_ENABLE(curve25519,
  36. AS_HELP_STRING(--disable-curve25519, Build Tor with no curve25519 elliptic-curve crypto support))
  37. AC_ARG_ENABLE(unittests,
  38. AS_HELP_STRING(--disable-unittests, [Don't build unit tests for Tor. Risky!]))
  39. AC_ARG_ENABLE(coverage,
  40. AS_HELP_STRING(--enable-coverage, [Enable coverage support in the unit-test build]))
  41. AM_CONDITIONAL(UNITTESTS_ENABLED, test x$enable_unittests != xno)
  42. AM_CONDITIONAL(COVERAGE_ENABLED, test x$enable_coverage = xyes)
  43. if test "$enable_static_tor" = "yes"; then
  44. enable_static_libevent="yes";
  45. enable_static_openssl="yes";
  46. enable_static_zlib="yes";
  47. CFLAGS="$CFLAGS -static"
  48. fi
  49. if test x$enable_buf_freelists != xno; then
  50. AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
  51. [Defined if we try to use freelists for buffer RAM chunks])
  52. fi
  53. AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
  54. if test x$enable_instrument_downloads = xyes; then
  55. AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
  56. [Defined if we want to keep track of how much of each kind of resource we download.])
  57. fi
  58. AC_ARG_ENABLE(transparent,
  59. AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
  60. [case "${enableval}" in
  61. yes) transparent=true ;;
  62. no) transparent=false ;;
  63. *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
  64. esac], [transparent=true])
  65. AC_ARG_ENABLE(asciidoc,
  66. AS_HELP_STRING(--disable-asciidoc, don't use asciidoc (disables building of manpages)),
  67. [case "${enableval}" in
  68. yes) asciidoc=true ;;
  69. no) asciidoc=false ;;
  70. *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
  71. esac], [asciidoc=true])
  72. # By default, we're not ready to ship a NAT-PMP aware Tor
  73. AC_ARG_ENABLE(nat-pmp,
  74. AS_HELP_STRING(--enable-nat-pmp, enable NAT-PMP support),
  75. [case "${enableval}" in
  76. yes) natpmp=true ;;
  77. no) natpmp=false ;;
  78. * ) AC_MSG_ERROR(bad value for --enable-nat-pmp) ;;
  79. esac], [natpmp=false])
  80. # By default, we're not ready to ship a UPnP aware Tor
  81. AC_ARG_ENABLE(upnp,
  82. AS_HELP_STRING(--enable-upnp, enable UPnP support),
  83. [case "${enableval}" in
  84. yes) upnp=true ;;
  85. no) upnp=false ;;
  86. * ) AC_MSG_ERROR(bad value for --enable-upnp) ;;
  87. esac], [upnp=false])
  88. AC_ARG_ENABLE(threads,
  89. AS_HELP_STRING(--disable-threads, disable multi-threading support))
  90. if test x$enable_threads = x; then
  91. case $host in
  92. *-*-solaris* )
  93. # Don't try multithreading on solaris -- cpuworkers seem to lock.
  94. AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
  95. cpu workers lock up here, so I will disable threads.])
  96. enable_threads="no";;
  97. *)
  98. enable_threads="yes";;
  99. esac
  100. fi
  101. if test "$enable_threads" = "yes"; then
  102. AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
  103. fi
  104. case $host in
  105. *-*-solaris* )
  106. AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
  107. ;;
  108. esac
  109. AC_ARG_ENABLE(gcc-warnings,
  110. AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
  111. AC_ARG_ENABLE(gcc-warnings-advisory,
  112. AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
  113. dnl Adam shostack suggests the following for Windows:
  114. dnl -D_FORTIFY_SOURCE=2 -fstack-protector-all
  115. dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
  116. dnl This requires that we use gcc and that we add -O2 to the CFLAGS.
  117. AC_ARG_ENABLE(gcc-hardening,
  118. AS_HELP_STRING(--disable-gcc-hardening, disable compiler security checks))
  119. dnl Linker hardening options
  120. dnl Currently these options are ELF specific - you can't use this with MacOSX
  121. AC_ARG_ENABLE(linker-hardening,
  122. AS_HELP_STRING(--disable-linker-hardening, disable linker security fixups))
  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. # Tor2web mode flag
  130. AC_ARG_ENABLE(tor2web-mode,
  131. AS_HELP_STRING(--enable-tor2web-mode, support tor2web non-anonymous mode),
  132. [if test x$enableval = xyes; then
  133. CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1"
  134. fi])
  135. AC_ARG_ENABLE(bufferevents,
  136. AS_HELP_STRING(--enable-bufferevents, use Libevent's buffered IO.))
  137. AC_ARG_ENABLE(tool-name-check,
  138. AS_HELP_STRING(--disable-tool-name-check, check for sanely named toolchain when cross-compiling))
  139. dnl check for the correct "ar" when cross-compiling
  140. AN_MAKEVAR([AR], [AC_PROG_AR])
  141. AN_PROGRAM([ar], [AC_PROG_AR])
  142. AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])])
  143. AC_PROG_AR
  144. dnl Check whether the above macro has settled for a simply named tool even
  145. dnl though we're cross compiling. We must do this before running AC_PROG_CC,
  146. dnl because that will find any cc on the system, not only the cross-compiler,
  147. dnl and then verify that a binary built with this compiler runs on the
  148. dnl build system. It will then come to the false conclusion that we're not
  149. dnl cross-compiling.
  150. if test x$enable_tool_name_check != xno; then
  151. if test x$ac_tool_warned = xyes; then
  152. AC_MSG_ERROR([We are cross compiling but could not find a properly named toolchain. Do you have your cross-compiling toolchain in PATH? (You can --disable-tool-name-check to ignore this.)])
  153. elif test "x$ac_ct_AR" != x -a x$cross_compiling = xmaybe; then
  154. AC_MSG_ERROR([We think we are cross compiling but could not find a properly named toolchain. Do you have your cross-compiling toolchain in PATH? (You can --disable-tool-name-check to ignore this.)])
  155. fi
  156. fi
  157. AC_PROG_CC
  158. AC_PROG_CPP
  159. AC_PROG_MAKE_SET
  160. AC_PROG_RANLIB
  161. dnl autoconf 2.59 appears not to support AC_PROG_SED
  162. AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
  163. dnl check for asciidoc and a2x
  164. AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
  165. AC_PATH_PROG([A2X], [a2x], none)
  166. AM_CONDITIONAL(USE_ASCIIDOC, test x$asciidoc = xtrue)
  167. AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
  168. AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
  169. AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
  170. AM_PROG_CC_C_O
  171. AC_ARG_VAR(PYTHON)
  172. AC_CHECK_PROGS(PYTHON, [python python2 python3])
  173. if test "x$PYTHON" = "x"; then
  174. AC_MSG_WARN([Python unavailable; some tests will not be run.])
  175. fi
  176. AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"])
  177. ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
  178. AC_C_FLEXIBLE_ARRAY_MEMBER
  179. ], [
  180. dnl Maybe we've got an old autoconf...
  181. AC_CACHE_CHECK([for flexible array members],
  182. tor_cv_c_flexarray,
  183. [AC_COMPILE_IFELSE(
  184. AC_LANG_PROGRAM([
  185. struct abc { int a; char b[]; };
  186. ], [
  187. struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
  188. def->b[0] = 33;
  189. ]),
  190. [tor_cv_c_flexarray=yes],
  191. [tor_cv_c_flexarray=no])])
  192. if test $tor_cv_flexarray = yes ; then
  193. AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
  194. else
  195. AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1], [Define to nothing if C supports flexible array members, and to 1 if it does not.])
  196. fi
  197. ])
  198. AC_PATH_PROG([SHA1SUM], [sha1sum], none)
  199. AC_PATH_PROG([OPENSSL], [openssl], none)
  200. TORUSER=_tor
  201. AC_ARG_WITH(tor-user,
  202. [ --with-tor-user=NAME Specify username for tor daemon ],
  203. [
  204. TORUSER=$withval
  205. ]
  206. )
  207. AC_SUBST(TORUSER)
  208. TORGROUP=_tor
  209. AC_ARG_WITH(tor-group,
  210. [ --with-tor-group=NAME Specify group name for tor daemon ],
  211. [
  212. TORGROUP=$withval
  213. ]
  214. )
  215. AC_SUBST(TORGROUP)
  216. dnl If _WIN32 is defined and non-zero, we are building for win32
  217. AC_MSG_CHECKING([for win32])
  218. AC_RUN_IFELSE([AC_LANG_SOURCE([
  219. int main(int c, char **v) {
  220. #ifdef _WIN32
  221. #if _WIN32
  222. return 0;
  223. #else
  224. return 1;
  225. #endif
  226. #else
  227. return 2;
  228. #endif
  229. }])],
  230. bwin32=true; AC_MSG_RESULT([yes]),
  231. bwin32=false; AC_MSG_RESULT([no]),
  232. bwin32=cross; AC_MSG_RESULT([cross])
  233. )
  234. if test "$bwin32" = cross; then
  235. AC_MSG_CHECKING([for win32 (cross)])
  236. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  237. #ifdef _WIN32
  238. int main(int c, char **v) {return 0;}
  239. #else
  240. #error
  241. int main(int c, char **v) {return x(y);}
  242. #endif
  243. ])],
  244. bwin32=true; AC_MSG_RESULT([yes]),
  245. bwin32=false; AC_MSG_RESULT([no]))
  246. fi
  247. AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
  248. dnl Enable C99 when compiling with MIPSpro
  249. AC_MSG_CHECKING([for MIPSpro compiler])
  250. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
  251. #if (defined(__sgi) && defined(_COMPILER_VERSION))
  252. #error
  253. return x(y);
  254. #endif
  255. ])],
  256. bmipspro=false; AC_MSG_RESULT(no),
  257. bmipspro=true; AC_MSG_RESULT(yes))
  258. if test "$bmipspro" = true; then
  259. CFLAGS="$CFLAGS -c99"
  260. fi
  261. AC_C_BIGENDIAN
  262. AC_SEARCH_LIBS(socket, [socket network])
  263. AC_SEARCH_LIBS(gethostbyname, [nsl])
  264. AC_SEARCH_LIBS(dlopen, [dl])
  265. AC_SEARCH_LIBS(inet_aton, [resolv])
  266. saved_LIBS="$LIBS"
  267. AC_SEARCH_LIBS([clock_gettime], [rt])
  268. if test "$LIBS" != "$saved_LIBS"; then
  269. # Looks like we need -lrt for clock_gettime().
  270. have_rt=yes
  271. fi
  272. if test "$enable_threads" = "yes"; then
  273. AC_SEARCH_LIBS(pthread_create, [pthread])
  274. AC_SEARCH_LIBS(pthread_detach, [pthread])
  275. fi
  276. dnl -------------------------------------------------------------------
  277. dnl Check for functions before libevent, since libevent-1.2 apparently
  278. dnl exports strlcpy without defining it in a header.
  279. AC_CHECK_FUNCS(
  280. _NSGetEnviron \
  281. accept4 \
  282. backtrace \
  283. backtrace_symbols_fd \
  284. clock_gettime \
  285. flock \
  286. ftime \
  287. getaddrinfo \
  288. getifaddrs \
  289. getrlimit \
  290. gettimeofday \
  291. gmtime_r \
  292. inet_aton \
  293. ioctl \
  294. issetugid \
  295. llround \
  296. localtime_r \
  297. lround \
  298. memmem \
  299. prctl \
  300. rint \
  301. sigaction \
  302. socketpair \
  303. strlcat \
  304. strlcpy \
  305. strptime \
  306. strtok_r \
  307. strtoull \
  308. sysconf \
  309. uname \
  310. vasprintf \
  311. _vscprintf
  312. )
  313. if test "$enable_threads" = "yes"; then
  314. AC_CHECK_HEADERS(pthread.h)
  315. AC_CHECK_FUNCS(pthread_create)
  316. fi
  317. dnl ------------------------------------------------------
  318. dnl Where do you live, libevent? And how do we call you?
  319. if test "$bwin32" = true; then
  320. TOR_LIB_WS32=-lws2_32
  321. TOR_LIB_IPHLPAPI=-liphlpapi
  322. # Some of the cargo-cults recommend -lwsock32 as well, but I don't
  323. # think it's actually necessary.
  324. TOR_LIB_GDI=-lgdi32
  325. else
  326. TOR_LIB_WS32=
  327. TOR_LIB_GDI=
  328. fi
  329. AC_SUBST(TOR_LIB_WS32)
  330. AC_SUBST(TOR_LIB_GDI)
  331. AC_SUBST(TOR_LIB_IPHLPAPI)
  332. dnl We need to do this before we try our disgusting hack below.
  333. AC_CHECK_HEADERS([sys/types.h])
  334. dnl This is a disgusting hack so we safely include older libevent headers.
  335. AC_CHECK_TYPE(u_int64_t, unsigned long long)
  336. AC_CHECK_TYPE(u_int32_t, unsigned long)
  337. AC_CHECK_TYPE(u_int16_t, unsigned short)
  338. AC_CHECK_TYPE(u_int8_t, unsigned char)
  339. tor_libevent_pkg_redhat="libevent"
  340. tor_libevent_pkg_debian="libevent-dev"
  341. tor_libevent_devpkg_redhat="libevent-devel"
  342. tor_libevent_devpkg_debian="libevent-dev"
  343. dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
  344. dnl linking for static builds.
  345. STATIC_LIBEVENT_FLAGS=""
  346. if test "$enable_static_libevent" = "yes"; then
  347. if test "$have_rt" = yes; then
  348. STATIC_LIBEVENT_FLAGS=" -lrt "
  349. fi
  350. fi
  351. TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
  352. #ifdef _WIN32
  353. #include <winsock2.h>
  354. #endif
  355. #include <stdlib.h>
  356. #include <sys/time.h>
  357. #include <sys/types.h>
  358. #include <event.h>], [
  359. #ifdef _WIN32
  360. #include <winsock2.h>
  361. #endif
  362. void exit(int); void *event_init(void);],
  363. [
  364. #ifdef _WIN32
  365. {WSADATA d; WSAStartup(0x101,&d); }
  366. #endif
  367. event_init(); exit(0);
  368. ], [--with-libevent-dir], [/opt/libevent])
  369. dnl Now check for particular libevent functions.
  370. save_LIBS="$LIBS"
  371. save_LDFLAGS="$LDFLAGS"
  372. save_CPPFLAGS="$CPPFLAGS"
  373. LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
  374. LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
  375. CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
  376. AC_CHECK_FUNCS([event_get_version \
  377. event_get_version_number \
  378. event_get_method \
  379. event_set_log_callback \
  380. evdns_set_outgoing_bind_address \
  381. evutil_secure_rng_set_urandom_device_file \
  382. event_base_loopexit])
  383. AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
  384. [#include <event.h>
  385. ])
  386. AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
  387. LIBS="$save_LIBS"
  388. LDFLAGS="$save_LDFLAGS"
  389. CPPFLAGS="$save_CPPFLAGS"
  390. AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
  391. if test "$enable_static_libevent" = "yes"; then
  392. if test "$tor_cv_library_libevent_dir" = "(system)"; then
  393. AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
  394. else
  395. TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
  396. fi
  397. else
  398. TOR_LIBEVENT_LIBS="-levent"
  399. fi
  400. dnl This isn't the best test for Libevent 2.0.3-alpha. Once it's released,
  401. dnl we can do much better.
  402. if test "$enable_bufferevents" = "yes" ; then
  403. if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
  404. 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.])
  405. else
  406. CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
  407. # Check for the right version. First see if version detection works.
  408. AC_MSG_CHECKING([whether we can detect the Libevent version])
  409. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  410. #include <event2/event.h>
  411. #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
  412. #error
  413. int x = y(zz);
  414. #else
  415. int x = 1;
  416. #endif
  417. ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
  418. [event_version_number_works=no; AC_MSG_RESULT([no])])
  419. if test "$event_version_number_works" != 'yes'; then
  420. AC_MSG_WARN([Version detection on Libevent seems broken. Your Libevent installation is probably screwed up or very old.])
  421. else
  422. AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
  423. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  424. #include <event2/event.h>
  425. #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000d00
  426. #error
  427. int x = y(zz);
  428. #else
  429. int x = 1;
  430. #endif
  431. ])], [ AC_MSG_RESULT([yes]) ],
  432. [ AC_MSG_RESULT([no])
  433. AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents. We require 2.0.13-stable or later]) ] )
  434. fi
  435. fi
  436. fi
  437. LIBS="$save_LIBS"
  438. LDFLAGS="$save_LDFLAGS"
  439. CPPFLAGS="$save_CPPFLAGS"
  440. AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
  441. if test "$enable_bufferevents" = "yes"; then
  442. AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
  443. if test "$enable_static_libevent" = "yes"; then
  444. TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent_openssl.a $TOR_LIBEVENT_LIBS"
  445. else
  446. TOR_LIBEVENT_LIBS="-levent_openssl $TOR_LIBEVENT_LIBS"
  447. fi
  448. fi
  449. AC_SUBST(TOR_LIBEVENT_LIBS)
  450. dnl ------------------------------------------------------
  451. dnl Where do you live, libm?
  452. dnl On some platforms (Haiku/BeOS) the math library is
  453. dnl part of libroot. In which case don't link against lm
  454. TOR_LIB_MATH=""
  455. save_LIBS="$LIBS"
  456. AC_SEARCH_LIBS(pow, [m], , AC_MSG_ERROR([Could not find pow in libm or libc.]))
  457. if test "$ac_cv_search_pow" != "none required"; then
  458. TOR_LIB_MATH="$ac_cv_search_pow"
  459. fi
  460. LIBS="$save_LIBS"
  461. AC_SUBST(TOR_LIB_MATH)
  462. dnl ------------------------------------------------------
  463. dnl Where do you live, openssl? And how do we call you?
  464. tor_openssl_pkg_redhat="openssl"
  465. tor_openssl_pkg_debian="libssl-dev"
  466. tor_openssl_devpkg_redhat="openssl-devel"
  467. tor_openssl_devpkg_debian="libssl-dev"
  468. ALT_openssl_WITHVAL=""
  469. AC_ARG_WITH(ssl-dir,
  470. [ --with-ssl-dir=PATH Obsolete alias for --with-openssl-dir ],
  471. [
  472. if test "x$withval" != xno && test "x$withval" != "x" ; then
  473. ALT_openssl_WITHVAL="$withval"
  474. fi
  475. ])
  476. TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
  477. [#include <openssl/rand.h>],
  478. [void RAND_add(const void *buf, int num, double entropy);],
  479. [RAND_add((void*)0,0,0); exit(0);], [],
  480. [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
  481. dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
  482. if test "$enable_static_openssl" = "yes"; then
  483. if test "$tor_cv_library_openssl_dir" = "(system)"; then
  484. AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
  485. else
  486. TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
  487. fi
  488. else
  489. TOR_OPENSSL_LIBS="-lssl -lcrypto"
  490. fi
  491. AC_SUBST(TOR_OPENSSL_LIBS)
  492. dnl ------------------------------------------------------
  493. dnl Where do you live, zlib? And how do we call you?
  494. tor_zlib_pkg_redhat="zlib"
  495. tor_zlib_pkg_debian="zlib1g"
  496. tor_zlib_devpkg_redhat="zlib-devel"
  497. tor_zlib_devpkg_debian="zlib1g-dev"
  498. TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
  499. [#include <zlib.h>],
  500. [const char * zlibVersion(void);],
  501. [zlibVersion(); exit(0);], [--with-zlib-dir],
  502. [/opt/zlib])
  503. if test "$enable_static_zlib" = "yes"; then
  504. if test "$tor_cv_library_zlib_dir" = "(system)"; then
  505. AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
  506. using --enable-static-zlib")
  507. else
  508. TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
  509. fi
  510. else
  511. TOR_ZLIB_LIBS="-lz"
  512. fi
  513. AC_SUBST(TOR_ZLIB_LIBS)
  514. dnl ---------------------------------------------------------------------
  515. dnl Now that we know about our major libraries, we can check for compiler
  516. dnl and linker hardening options. We need to do this with the libraries known,
  517. dnl since sometimes the linker will like an option but not be willing to
  518. dnl use it with a build of a library.
  519. all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
  520. all_libs_for_check="$TOR_ZLIB_LIBS $TOR_LIB_MATH $TOR_LIBEVENT_LIBS $TOR_OPENSSL_LIBS $TOR_LIB_WS32 $TOR_LIB_GDI"
  521. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  522. #if !defined(__clang__)
  523. #error
  524. #endif])], have_clang=yes, have_clang=no)
  525. if test x$enable_gcc_hardening != xno; then
  526. CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
  527. if test x$have_clang = xyes; then
  528. TOR_CHECK_CFLAGS(-Qunused-arguments)
  529. fi
  530. TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
  531. AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
  532. AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
  533. AS_VAR_IF(can_compile, [yes],
  534. AS_VAR_IF(can_link, [yes],
  535. [],
  536. AC_MSG_ERROR([We tried to build with stack protection; it looks like your compiler supports it but your libc does not provide it. Are you missing libssp? (You can --disable-gcc-hardening to ignore this error.)]))
  537. )
  538. AS_VAR_POPDEF([can_link])
  539. AS_VAR_POPDEF([can_compile])
  540. TOR_CHECK_CFLAGS(-Wstack-protector)
  541. TOR_CHECK_CFLAGS(-fwrapv)
  542. TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)
  543. if test "$bwin32" = "false"; then
  544. TOR_CHECK_CFLAGS(-fPIE)
  545. TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check")
  546. fi
  547. fi
  548. if test x$enable_linker_hardening != xno; then
  549. TOR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
  550. fi
  551. # For backtrace support
  552. TOR_CHECK_LDFLAGS(-rdynamic)
  553. dnl ------------------------------------------------------
  554. dnl Now see if we have a -fomit-frame-pointer compiler option.
  555. saved_CFLAGS="$CFLAGS"
  556. TOR_CHECK_CFLAGS(-fomit-frame-pointer)
  557. if test "$saved_CFLAGS" != "$CFLAGS"; then
  558. F_OMIT_FRAME_POINTER='-fomit-frame-pointer'
  559. else
  560. F_OMIT_FRAME_POINTER=''
  561. fi
  562. CFLAGS="$saved_CFLAGS"
  563. AC_SUBST(F_OMIT_FRAME_POINTER)
  564. dnl ------------------------------------------------------
  565. dnl Where do you live, libnatpmp? And how do we call you?
  566. dnl There are no packages for Debian or Redhat as of this patch
  567. if test "$natpmp" = "true"; then
  568. AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
  569. TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
  570. [#include <natpmp.h>],
  571. [#ifdef _WIN32
  572. #define STATICLIB
  573. #endif
  574. #include <natpmp.h>],
  575. [ int r;
  576. natpmp_t natpmp;
  577. natpmpresp_t response;
  578. r = initnatpmp(&natpmp, 0, 0);],
  579. [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
  580. exit(0);],
  581. [--with-libnatpmp-dir],
  582. [/usr/lib/])
  583. fi
  584. dnl ------------------------------------------------------
  585. dnl Where do you live, libminiupnpc? And how do we call you?
  586. dnl There are no packages for Debian or Redhat as of this patch
  587. if test "$upnp" = "true"; then
  588. AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
  589. dnl Before we call TOR_SEARCH_LIBRARY we'll do a quick compile test
  590. dnl to see if we have miniupnpc-1.5 or -1.6
  591. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
  592. [upnpDiscover(1, 0, 0, 0);exit(0);])],[miniupnpc15="true"],[miniupnpc15="false"])
  593. if test "$miniupnpc15" = "true" ; then
  594. AC_DEFINE([MINIUPNPC15],[1],[libminiupnpc version 1.5 found])
  595. TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
  596. [#include <miniupnpc/miniwget.h>
  597. #include <miniupnpc/miniupnpc.h>
  598. #include <miniupnpc/upnpcommands.h>],
  599. [void upnpDiscover(int delay, const char * multicastif,
  600. const char * minissdpdsock, int sameport);],
  601. [upnpDiscover(1, 0, 0, 0); exit(0);],
  602. [--with-libminiupnpc-dir],
  603. [/usr/lib/])
  604. else
  605. TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
  606. [#include <miniupnpc/miniwget.h>
  607. #include <miniupnpc/miniupnpc.h>
  608. #include <miniupnpc/upnpcommands.h>],
  609. [void upnpDiscover(int delay, const char * multicastif,
  610. const char * minissdpdsock, int sameport, int ipv6, int * error);],
  611. [upnpDiscover(1, 0, 0, 0, 0, 0); exit(0);],
  612. [--with-libminiupnpc-dir],
  613. [/usr/lib/])
  614. fi
  615. fi
  616. dnl ============================================================
  617. dnl Check for libseccomp
  618. AC_CHECK_HEADERS([seccomp.h])
  619. AC_SEARCH_LIBS(seccomp_init, [seccomp])
  620. dnl ============================================================
  621. dnl We need an implementation of curve25519.
  622. dnl set these defaults.
  623. have_a_curve25519=no
  624. build_curve25519_donna=no
  625. build_curve25519_donna_c64=no
  626. use_curve25519_donna=no
  627. use_curve25519_nacl=no
  628. CURVE25519_LIBS=
  629. if test x$enable_curve25519 != xno; then
  630. dnl The best choice is using curve25519-donna-c64, but that requires
  631. dnl that we
  632. AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
  633. tor_cv_can_use_curve25519_donna_c64,
  634. [AC_RUN_IFELSE(
  635. [AC_LANG_PROGRAM([dnl
  636. #include <stdint.h>
  637. typedef unsigned uint128_t __attribute__((mode(TI)));
  638. int func(uint64_t a, uint64_t b) {
  639. uint128_t c = ((uint128_t)a) * b;
  640. int ok = ((uint64_t)(c>>96)) == 522859 &&
  641. (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
  642. (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
  643. (((uint64_t)(c))&0xffffffffL) == 0;
  644. return ok;
  645. }
  646. ], [dnl
  647. int ok = func( ((uint64_t)2000000000) * 1000000000,
  648. ((uint64_t)1234567890) << 24);
  649. return !ok;
  650. ])],
  651. [tor_cv_can_use_curve25519_donna_c64=yes],
  652. [tor_cv_can_use_curve25519_donna_c64=no],
  653. [AC_COMPILE_IFELSE(
  654. [AC_LANG_PROGRAM([dnl
  655. #include <stdint.h>
  656. typedef unsigned uint128_t __attribute__((mode(TI)));
  657. int func(uint64_t a, uint64_t b) {
  658. uint128_t c = ((uint128_t)a) * b;
  659. int ok = ((uint64_t)(c>>96)) == 522859 &&
  660. (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
  661. (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
  662. (((uint64_t)(c))&0xffffffffL) == 0;
  663. return ok;
  664. }
  665. ], [dnl
  666. int ok = func( ((uint64_t)2000000000) * 1000000000,
  667. ((uint64_t)1234567890) << 24);
  668. return !ok;
  669. ])],
  670. [tor_cv_can_use_curve25519_donna_c64=cross],
  671. [tor_cv_can_use_curve25519_donna_c64=no])])])
  672. AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
  673. nacl/crypto_scalarmult_curve25519.h])
  674. AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
  675. tor_cv_can_use_curve25519_nacl,
  676. [tor_saved_LIBS="$LIBS"
  677. LIBS="$LIBS -lnacl"
  678. AC_LINK_IFELSE(
  679. [AC_LANG_PROGRAM([dnl
  680. #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
  681. #include <crypto_scalarmult_curve25519.h>
  682. #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
  683. #include <nacl/crypto_scalarmult_curve25519.h>
  684. #endif
  685. #ifdef crypto_scalarmult_curve25519_ref_BYTES
  686. #error Hey, this is the reference implementation! That's not fast.
  687. #endif
  688. ], [
  689. unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
  690. ])], [tor_cv_can_use_curve25519_nacl=yes],
  691. [tor_cv_can_use_curve25519_nacl=no])
  692. LIBS="$tor_saved_LIBS" ])
  693. dnl Okay, now we need to figure out which one to actually use. Fall back
  694. dnl to curve25519-donna.c
  695. if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
  696. build_curve25519_donna_c64=yes
  697. use_curve25519_donna=yes
  698. elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
  699. use_curve25519_nacl=yes
  700. CURVE25519_LIBS=-lnacl
  701. else
  702. build_curve25519_donna=yes
  703. use_curve25519_donna=yes
  704. fi
  705. have_a_curve25519=yes
  706. fi
  707. if test x$have_a_curve25519 = xyes; then
  708. AC_DEFINE(CURVE25519_ENABLED, 1,
  709. [Defined if we have a curve25519 implementation])
  710. fi
  711. if test x$use_curve25519_donna = xyes; then
  712. AC_DEFINE(USE_CURVE25519_DONNA, 1,
  713. [Defined if we should use an internal curve25519_donna{,_c64} implementation])
  714. fi
  715. if test x$use_curve25519_nacl = xyes; then
  716. AC_DEFINE(USE_CURVE25519_NACL, 1,
  717. [Defined if we should use a curve25519 from nacl])
  718. fi
  719. AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
  720. AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
  721. AM_CONDITIONAL(CURVE25519_ENABLED, test x$have_a_curve25519 = xyes)
  722. AC_SUBST(CURVE25519_LIBS)
  723. dnl Make sure to enable support for large off_t if available.
  724. AC_SYS_LARGEFILE
  725. AC_CHECK_HEADERS(
  726. assert.h \
  727. errno.h \
  728. fcntl.h \
  729. signal.h \
  730. string.h \
  731. sys/fcntl.h \
  732. sys/stat.h \
  733. sys/time.h \
  734. sys/types.h \
  735. time.h \
  736. unistd.h
  737. , , 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.))
  738. dnl These headers are not essential
  739. AC_CHECK_HEADERS(
  740. arpa/inet.h \
  741. crt_externs.h \
  742. execinfo.h \
  743. grp.h \
  744. ifaddrs.h \
  745. inttypes.h \
  746. limits.h \
  747. linux/types.h \
  748. machine/limits.h \
  749. malloc.h \
  750. malloc/malloc.h \
  751. malloc_np.h \
  752. netdb.h \
  753. netinet/in.h \
  754. netinet/in6.h \
  755. pwd.h \
  756. stdint.h \
  757. sys/file.h \
  758. sys/ioctl.h \
  759. sys/limits.h \
  760. sys/mman.h \
  761. sys/param.h \
  762. sys/prctl.h \
  763. sys/resource.h \
  764. sys/socket.h \
  765. sys/syslimits.h \
  766. sys/time.h \
  767. sys/types.h \
  768. sys/un.h \
  769. sys/utime.h \
  770. sys/wait.h \
  771. syslog.h \
  772. utime.h
  773. )
  774. AC_CHECK_HEADERS(sys/param.h)
  775. AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
  776. [#ifdef HAVE_SYS_TYPES_H
  777. #include <sys/types.h>
  778. #endif
  779. #ifdef HAVE_SYS_SOCKET_H
  780. #include <sys/socket.h>
  781. #endif])
  782. AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
  783. [#ifdef HAVE_SYS_TYPES_H
  784. #include <sys/types.h>
  785. #endif
  786. #ifdef HAVE_SYS_SOCKET_H
  787. #include <sys/socket.h>
  788. #endif
  789. #ifdef HAVE_NET_IF_H
  790. #include <net/if.h>
  791. #endif])
  792. AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
  793. linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
  794. [#ifdef HAVE_SYS_TYPES_H
  795. #include <sys/types.h>
  796. #endif
  797. #ifdef HAVE_SYS_SOCKET_H
  798. #include <sys/socket.h>
  799. #endif
  800. #ifdef HAVE_LIMITS_H
  801. #include <limits.h>
  802. #endif
  803. #ifdef HAVE_LINUX_TYPES_H
  804. #include <linux/types.h>
  805. #endif
  806. #ifdef HAVE_NETINET_IN6_H
  807. #include <netinet/in6.h>
  808. #endif
  809. #ifdef HAVE_NETINET_IN_H
  810. #include <netinet/in.h>
  811. #endif])
  812. if test x$transparent = xtrue ; then
  813. transparent_ok=0
  814. if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
  815. transparent_ok=1
  816. fi
  817. if test x$linux_netfilter_ipv4 = x1 ; then
  818. transparent_ok=1
  819. fi
  820. if test x$transparent_ok = x1 ; then
  821. AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
  822. case $host in
  823. *-*-openbsd* | *-*-bitrig*)
  824. AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
  825. esac
  826. else
  827. AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
  828. fi
  829. fi
  830. AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
  831. [#ifdef HAVE_SYS_TYPES_H
  832. #include <sys/types.h>
  833. #endif
  834. #ifdef HAVE_SYS_TIME_H
  835. #include <sys/time.h>
  836. #endif])
  837. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  838. dnl Watch out.
  839. AC_CHECK_SIZEOF(int8_t)
  840. AC_CHECK_SIZEOF(int16_t)
  841. AC_CHECK_SIZEOF(int32_t)
  842. AC_CHECK_SIZEOF(int64_t)
  843. AC_CHECK_SIZEOF(uint8_t)
  844. AC_CHECK_SIZEOF(uint16_t)
  845. AC_CHECK_SIZEOF(uint32_t)
  846. AC_CHECK_SIZEOF(uint64_t)
  847. AC_CHECK_SIZEOF(intptr_t)
  848. AC_CHECK_SIZEOF(uintptr_t)
  849. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  850. AC_CHECK_SIZEOF(char)
  851. AC_CHECK_SIZEOF(short)
  852. AC_CHECK_SIZEOF(int)
  853. AC_CHECK_SIZEOF(long)
  854. AC_CHECK_SIZEOF(long long)
  855. AC_CHECK_SIZEOF(__int64)
  856. AC_CHECK_SIZEOF(void *)
  857. AC_CHECK_SIZEOF(time_t)
  858. AC_CHECK_SIZEOF(size_t)
  859. AC_CHECK_SIZEOF(pid_t)
  860. AC_CHECK_TYPES([uint, u_char, ssize_t])
  861. AC_PC_FROM_UCONTEXT([/bin/true])
  862. dnl used to include sockaddr_storage, but everybody has that.
  863. AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
  864. [#ifdef HAVE_SYS_TYPES_H
  865. #include <sys/types.h>
  866. #endif
  867. #ifdef HAVE_NETINET_IN_H
  868. #include <netinet/in.h>
  869. #endif
  870. #ifdef HAVE_NETINET_IN6_H
  871. #include <netinet/in6.h>
  872. #endif
  873. #ifdef HAVE_SYS_SOCKET_H
  874. #include <sys/socket.h>
  875. #endif
  876. #ifdef _WIN32
  877. #define _WIN32_WINNT 0x0501
  878. #define WIN32_LEAN_AND_MEAN
  879. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  880. #include <winsock.h>
  881. #else
  882. #include <winsock2.h>
  883. #include <ws2tcpip.h>
  884. #endif
  885. #endif
  886. ])
  887. AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
  888. [#ifdef HAVE_SYS_TYPES_H
  889. #include <sys/types.h>
  890. #endif
  891. #ifdef HAVE_NETINET_IN_H
  892. #include <netinet/in.h>
  893. #endif
  894. #ifdef HAVE_NETINET_IN6_H
  895. #include <netinet/in6.h>
  896. #endif
  897. #ifdef HAVE_SYS_SOCKET_H
  898. #include <sys/socket.h>
  899. #endif
  900. #ifdef _WIN32
  901. #define _WIN32_WINNT 0x0501
  902. #define WIN32_LEAN_AND_MEAN
  903. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  904. #include <winsock.h>
  905. #else
  906. #include <winsock2.h>
  907. #include <ws2tcpip.h>
  908. #endif
  909. #endif
  910. ])
  911. AC_CHECK_TYPES([rlim_t], , ,
  912. [#ifdef HAVE_SYS_TYPES_H
  913. #include <sys/types.h>
  914. #endif
  915. #ifdef HAVE_SYS_TIME_H
  916. #include <sys/time.h>
  917. #endif
  918. #ifdef HAVE_SYS_RESOURCE_H
  919. #include <sys/resource.h>
  920. #endif
  921. ])
  922. AX_CHECK_SIGN([time_t],
  923. [ AC_DEFINE(TIME_T_IS_SIGNED, 1, [Define if time_t is signed]) ],
  924. [ : ], [
  925. #ifdef HAVE_SYS_TYPES_H
  926. #include <sys/types.h>
  927. #endif
  928. #ifdef HAVE_SYS_TIME_H
  929. #include <sys/time.h>
  930. #endif
  931. #ifdef HAVE_TIME_H
  932. #include <time.h>
  933. #endif
  934. ])
  935. if test "$ax_cv_decl_time_t_signed" = no; then
  936. AC_MSG_WARN([You have an unsigned time_t; some things will probably break. Please tell the Tor developers about your interesting platform.])
  937. fi
  938. AX_CHECK_SIGN([size_t],
  939. [ tor_cv_size_t_signed=yes ],
  940. [ tor_cv_size_t_signed=no ], [
  941. #ifdef HAVE_SYS_TYPES_H
  942. #include <sys/types.h>
  943. #endif
  944. ])
  945. if test "$ax_cv_decl_size_t_signed" = yes; then
  946. AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
  947. fi
  948. AX_CHECK_SIGN([enum always],
  949. [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
  950. [ : ], [
  951. enum always { AAA, BBB, CCC };
  952. ])
  953. AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
  954. #ifdef HAVE_SYS_SOCKET_H
  955. #include <sys/socket.h>
  956. #endif
  957. ])
  958. # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
  959. AC_CHECK_SIZEOF(cell_t)
  960. # Now make sure that NULL can be represented as zero bytes.
  961. AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
  962. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  963. [[#include <stdlib.h>
  964. #include <string.h>
  965. #include <stdio.h>
  966. #ifdef HAVE_STDDEF_H
  967. #include <stddef.h>
  968. #endif
  969. int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
  970. return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
  971. [tor_cv_null_is_zero=yes],
  972. [tor_cv_null_is_zero=no],
  973. [tor_cv_null_is_zero=cross])])
  974. if test "$tor_cv_null_is_zero" = cross ; then
  975. # Cross-compiling; let's hope that the target isn't raving mad.
  976. AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
  977. fi
  978. if test "$tor_cv_null_is_zero" != no; then
  979. AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
  980. [Define to 1 iff memset(0) sets pointers to NULL])
  981. fi
  982. AC_CACHE_CHECK([whether memset(0) sets doubles to 0.0], tor_cv_dbl0_is_zero,
  983. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  984. [[#include <stdlib.h>
  985. #include <string.h>
  986. #include <stdio.h>
  987. #ifdef HAVE_STDDEF_H
  988. #include <stddef.h>
  989. #endif
  990. int main () { double d1,d2; d1=0; memset(&d2,0,sizeof(d2));
  991. return memcmp(&d1,&d2,sizeof(d1))?1:0; }]])],
  992. [tor_cv_dbl0_is_zero=yes],
  993. [tor_cv_dbl0_is_zero=no],
  994. [tor_cv_dbl0_is_zero=cross])])
  995. if test "$tor_cv_dbl0_is_zero" = cross ; then
  996. # Cross-compiling; let's hope that the target isn't raving mad.
  997. AC_MSG_NOTICE([Cross-compiling: we'll assume that 0.0 can be represented as a sequence of 0-valued bytes.])
  998. fi
  999. if test "$tor_cv_dbl0_is_zero" != no; then
  1000. AC_DEFINE([DOUBLE_0_REP_IS_ZERO_BYTES], 1,
  1001. [Define to 1 iff memset(0) sets doubles to 0.0])
  1002. fi
  1003. # And what happens when we malloc zero?
  1004. AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
  1005. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  1006. [[#include <stdlib.h>
  1007. #include <string.h>
  1008. #include <stdio.h>
  1009. #ifdef HAVE_STDDEF_H
  1010. #include <stddef.h>
  1011. #endif
  1012. int main () { return malloc(0)?0:1; }]])],
  1013. [tor_cv_malloc_zero_works=yes],
  1014. [tor_cv_malloc_zero_works=no],
  1015. [tor_cv_malloc_zero_works=cross])])
  1016. if test "$tor_cv_malloc_zero_works" = cross; then
  1017. # Cross-compiling; let's hope that the target isn't raving mad.
  1018. AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
  1019. fi
  1020. if test "$tor_cv_malloc_zero_works" = yes; then
  1021. AC_DEFINE([MALLOC_ZERO_WORKS], 1,
  1022. [Define to 1 iff malloc(0) returns a pointer])
  1023. fi
  1024. # whether we seem to be in a 2s-complement world.
  1025. AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
  1026. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  1027. [[int main () { int problem = ((-99) != (~99)+1);
  1028. return problem ? 1 : 0; }]])],
  1029. [tor_cv_twos_complement=yes],
  1030. [tor_cv_twos_complement=no],
  1031. [tor_cv_twos_complement=cross])])
  1032. if test "$tor_cv_twos_complement" = cross ; then
  1033. # Cross-compiling; let's hope that the target isn't raving mad.
  1034. AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
  1035. fi
  1036. if test "$tor_cv_twos_complement" != no ; then
  1037. AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
  1038. [Define to 1 iff we represent negative integers with two's complement])
  1039. fi
  1040. # What does shifting a negative value do?
  1041. AC_CACHE_CHECK([whether right-shift on negative values does sign-extension], tor_cv_sign_extend,
  1042. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  1043. [[int main () { int okay = (-60 >> 8) == -1; return okay ? 0 : 1; }]])],
  1044. [tor_cv_sign_extend=yes],
  1045. [tor_cv_sign_extend=no],
  1046. [tor_cv_sign_extend=cross])])
  1047. if test "$tor_cv_sign_extend" = cross ; then
  1048. # Cross-compiling; let's hope that the target isn't raving mad.
  1049. AC_MSG_NOTICE([Cross-compiling: we'll assume that right-shifting negative integers causes sign-extension])
  1050. fi
  1051. if test "$tor_cv_sign_extend" != no ; then
  1052. AC_DEFINE([RSHIFT_DOES_SIGN_EXTEND], 1,
  1053. [Define to 1 iff right-shifting a negative value performs sign-extension])
  1054. fi
  1055. # Whether we should use the dmalloc memory allocation debugging library.
  1056. AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
  1057. AC_ARG_WITH(dmalloc,
  1058. [ --with-dmalloc Use debug memory allocation library. ],
  1059. [if [[ "$withval" = "yes" ]]; then
  1060. dmalloc=1
  1061. AC_MSG_RESULT(yes)
  1062. else
  1063. dmalloc=1
  1064. AC_MSG_RESULT(no)
  1065. fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
  1066. )
  1067. if [[ $dmalloc -eq 1 ]]; then
  1068. AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
  1069. AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
  1070. AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
  1071. AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
  1072. AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
  1073. fi
  1074. AC_ARG_WITH(tcmalloc,
  1075. [ --with-tcmalloc Use tcmalloc memory allocation library. ],
  1076. [ tcmalloc=yes ], [ tcmalloc=no ])
  1077. if test x$tcmalloc = xyes ; then
  1078. LDFLAGS="-ltcmalloc $LDFLAGS"
  1079. fi
  1080. using_custom_malloc=no
  1081. if test x$enable_openbsd_malloc = xyes ; then
  1082. using_custom_malloc=yes
  1083. fi
  1084. if test x$tcmalloc = xyes ; then
  1085. using_custom_malloc=yes
  1086. fi
  1087. if test $using_custom_malloc = no ; then
  1088. AC_CHECK_FUNCS(mallinfo)
  1089. fi
  1090. # By default, we're going to assume we don't have mlockall()
  1091. # bionic and other platforms have various broken mlockall subsystems.
  1092. # Some systems don't have a working mlockall, some aren't linkable,
  1093. # and some have it but don't declare it.
  1094. AC_CHECK_FUNCS(mlockall)
  1095. AC_CHECK_DECLS([mlockall], , , [
  1096. #ifdef HAVE_SYS_MMAN_H
  1097. #include <sys/mman.h>
  1098. #endif])
  1099. # Allow user to specify an alternate syslog facility
  1100. AC_ARG_WITH(syslog-facility,
  1101. [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
  1102. syslog_facility="$withval", syslog_facility="LOG_DAEMON")
  1103. AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
  1104. AC_SUBST(LOGFACILITY)
  1105. # Check if we have getresuid and getresgid
  1106. AC_CHECK_FUNCS(getresuid getresgid)
  1107. # Check for gethostbyname_r in all its glorious incompatible versions.
  1108. # (This logic is based on that in Python's configure.in)
  1109. AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
  1110. [Define this if you have any gethostbyname_r()])
  1111. AC_CHECK_FUNC(gethostbyname_r, [
  1112. AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
  1113. OLD_CFLAGS=$CFLAGS
  1114. CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
  1115. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  1116. #include <netdb.h>
  1117. ], [[
  1118. char *cp1, *cp2;
  1119. struct hostent *h1, *h2;
  1120. int i1, i2;
  1121. (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
  1122. ]])],[
  1123. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  1124. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
  1125. [Define this if gethostbyname_r takes 6 arguments])
  1126. AC_MSG_RESULT(6)
  1127. ], [
  1128. AC_TRY_COMPILE([
  1129. #include <netdb.h>
  1130. ], [
  1131. char *cp1, *cp2;
  1132. struct hostent *h1;
  1133. int i1, i2;
  1134. (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
  1135. ], [
  1136. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  1137. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
  1138. [Define this if gethostbyname_r takes 5 arguments])
  1139. AC_MSG_RESULT(5)
  1140. ], [
  1141. AC_TRY_COMPILE([
  1142. #include <netdb.h>
  1143. ], [
  1144. char *cp1;
  1145. struct hostent *h1;
  1146. struct hostent_data hd;
  1147. (void) gethostbyname_r(cp1,h1,&hd);
  1148. ], [
  1149. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  1150. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
  1151. [Define this if gethostbyname_r takes 3 arguments])
  1152. AC_MSG_RESULT(3)
  1153. ], [
  1154. AC_MSG_RESULT(0)
  1155. ])
  1156. ])
  1157. ])
  1158. CFLAGS=$OLD_CFLAGS
  1159. ])
  1160. AC_CACHE_CHECK([whether the C compiler supports __func__],
  1161. tor_cv_have_func_macro,
  1162. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  1163. #include <stdio.h>
  1164. int main(int c, char **v) { puts(__func__); }])],
  1165. tor_cv_have_func_macro=yes,
  1166. tor_cv_have_func_macro=no))
  1167. AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
  1168. tor_cv_have_FUNC_macro,
  1169. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  1170. #include <stdio.h>
  1171. int main(int c, char **v) { puts(__FUNC__); }])],
  1172. tor_cv_have_FUNC_macro=yes,
  1173. tor_cv_have_FUNC_macro=no))
  1174. AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
  1175. tor_cv_have_FUNCTION_macro,
  1176. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  1177. #include <stdio.h>
  1178. int main(int c, char **v) { puts(__FUNCTION__); }])],
  1179. tor_cv_have_FUNCTION_macro=yes,
  1180. tor_cv_have_FUNCTION_macro=no))
  1181. AC_CACHE_CHECK([whether we have extern char **environ already declared],
  1182. tor_cv_have_environ_declared,
  1183. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  1184. /* We define _GNU_SOURCE here because it is also defined in compat.c.
  1185. * Without it environ doesn't get declared. */
  1186. #define _GNU_SOURCE
  1187. #ifdef HAVE_UNISTD_H
  1188. #include <unistd.h>
  1189. #endif
  1190. #include <stdlib.h>
  1191. int main(int c, char **v) { char **t = environ; }])],
  1192. tor_cv_have_environ_declared=yes,
  1193. tor_cv_have_environ_declared=no))
  1194. if test "$tor_cv_have_func_macro" = 'yes'; then
  1195. AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
  1196. fi
  1197. if test "$tor_cv_have_FUNC_macro" = 'yes'; then
  1198. AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
  1199. fi
  1200. if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
  1201. AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
  1202. [Defined if the compiler supports __FUNCTION__])
  1203. fi
  1204. if test "$tor_cv_have_environ_declared" = 'yes'; then
  1205. AC_DEFINE(HAVE_EXTERN_ENVIRON_DECLARED, 1,
  1206. [Defined if we have extern char **environ already declared])
  1207. fi
  1208. # $prefix stores the value of the --prefix command line option, or
  1209. # NONE if the option wasn't set. In the case that it wasn't set, make
  1210. # it be the default, so that we can use it to expand directories now.
  1211. if test "x$prefix" = "xNONE"; then
  1212. prefix=$ac_default_prefix
  1213. fi
  1214. # and similarly for $exec_prefix
  1215. if test "x$exec_prefix" = "xNONE"; then
  1216. exec_prefix=$prefix
  1217. fi
  1218. if test "x$BUILDDIR" = "x"; then
  1219. BUILDDIR=`pwd`
  1220. fi
  1221. AC_SUBST(BUILDDIR)
  1222. AH_TEMPLATE([BUILDDIR],[tor's build directory])
  1223. AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
  1224. if test "x$CONFDIR" = "x"; then
  1225. CONFDIR=`eval echo $sysconfdir/tor`
  1226. fi
  1227. AC_SUBST(CONFDIR)
  1228. AH_TEMPLATE([CONFDIR],[tor's configuration directory])
  1229. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  1230. BINDIR=`eval echo $bindir`
  1231. AC_SUBST(BINDIR)
  1232. LOCALSTATEDIR=`eval echo $localstatedir`
  1233. AC_SUBST(LOCALSTATEDIR)
  1234. if test "$bwin32" = true; then
  1235. # Test if the linker supports the --nxcompat and --dynamicbase options
  1236. # for Windows
  1237. save_LDFLAGS="$LDFLAGS"
  1238. LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
  1239. AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
  1240. AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
  1241. [AC_MSG_RESULT([yes])]
  1242. [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
  1243. [AC_MSG_RESULT([no])]
  1244. )
  1245. LDFLAGS="$save_LDFLAGS"
  1246. fi
  1247. # Set CFLAGS _after_ all the above checks, since our warnings are stricter
  1248. # than autoconf's macros like.
  1249. if test "$GCC" = yes; then
  1250. # Disable GCC's strict aliasing checks. They are an hours-to-debug
  1251. # accident waiting to happen.
  1252. CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
  1253. else
  1254. # Autoconf sets -g -O2 by default. Override optimization level
  1255. # for non-gcc compilers
  1256. CFLAGS="$CFLAGS -O"
  1257. enable_gcc_warnings=no
  1258. enable_gcc_warnings_advisory=no
  1259. fi
  1260. # OS X Lion started deprecating the system openssl. Let's just disable
  1261. # all deprecation warnings on OS X. Also, to potentially make the binary
  1262. # a little smaller, let's enable dead_strip.
  1263. case "$host_os" in
  1264. darwin*)
  1265. CFLAGS="$CFLAGS -Wno-deprecated-declarations"
  1266. LDFLAGS="$LDFLAGS -dead_strip" ;;
  1267. esac
  1268. # Add some more warnings which we use in development but not in the
  1269. # released versions. (Some relevant gcc versions can't handle these.)
  1270. if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
  1271. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  1272. #if !defined(__GNUC__) || (__GNUC__ < 4)
  1273. #error
  1274. #endif])], have_gcc4=yes, have_gcc4=no)
  1275. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  1276. #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
  1277. #error
  1278. #endif])], have_gcc42=yes, have_gcc42=no)
  1279. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  1280. #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
  1281. #error
  1282. #endif])], have_gcc43=yes, have_gcc43=no)
  1283. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  1284. #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
  1285. #error
  1286. #endif])], have_gcc46=yes, have_gcc46=no)
  1287. save_CFLAGS="$CFLAGS"
  1288. CFLAGS="$CFLAGS -Wshorten-64-to-32"
  1289. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
  1290. have_shorten64_flag=no)
  1291. CFLAGS="$save_CFLAGS"
  1292. case $host in
  1293. *-*-openbsd* | *-*-bitrig*)
  1294. # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
  1295. # That's fine, except that the headers don't pass -Wredundant-decls.
  1296. # Therefore, let's disable -Wsystem-headers when we're building
  1297. # with maximal warnings on OpenBSD.
  1298. CFLAGS="$CFLAGS -Wno-system-headers" ;;
  1299. esac
  1300. CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
  1301. CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
  1302. CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
  1303. CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
  1304. CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
  1305. if test x$enable_gcc_warnings = xyes; then
  1306. CFLAGS="$CFLAGS -Werror"
  1307. fi
  1308. # Disabled, so we can use mallinfo(): -Waggregate-return
  1309. if test x$have_gcc4 = xyes ; then
  1310. # These warnings break gcc 3.3.5 and work on gcc 4.0.2
  1311. CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
  1312. fi
  1313. if test x$have_gcc42 = xyes ; then
  1314. # These warnings break gcc 4.0.2 and work on gcc 4.2
  1315. # XXXX020 See if any of these work with earlier versions.
  1316. CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
  1317. # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
  1318. fi
  1319. if test x$have_gcc42 = xyes && test x$have_clang = xno; then
  1320. # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
  1321. CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
  1322. fi
  1323. if test x$have_gcc43 = xyes ; then
  1324. # These warnings break gcc 4.2 and work on gcc 4.3
  1325. # XXXX020 See if any of these work with earlier versions.
  1326. CFLAGS="$CFLAGS -Wextra -Warray-bounds"
  1327. fi
  1328. if test x$have_gcc46 = xyes ; then
  1329. # This warning was added in gcc 4.3, but it appears to generate
  1330. # spurious warnings in gcc 4.4. I don't know if it works in 4.5.
  1331. CFLAGS="$CFLAGS -Wlogical-op"
  1332. fi
  1333. if test x$have_shorten64_flag = xyes ; then
  1334. CFLAGS="$CFLAGS -Wshorten-64-to-32"
  1335. fi
  1336. ##This will break the world on some 64-bit architectures
  1337. # CFLAGS="$CFLAGS -Winline"
  1338. fi
  1339. if test "$enable_coverage" = yes && test "$have_clang" = "no"; then
  1340. case "$host_os" in
  1341. darwin*)
  1342. AC_MSG_WARN([Tried to enable coverage on OSX without using the clang compiler. This might not work! If coverage fails, use CC=clang when configuring with --enable-profiling.])
  1343. esac
  1344. fi
  1345. CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
  1346. AC_CONFIG_FILES([
  1347. Doxyfile
  1348. Makefile
  1349. contrib/suse/tor.sh
  1350. contrib/tor.logrotate
  1351. contrib/tor.sh
  1352. contrib/torctl
  1353. src/config/torrc.sample
  1354. ])
  1355. if test x$asciidoc = xtrue && test "$ASCIIDOC" = "none" ; then
  1356. regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
  1357. for file in $regular_mans ; do
  1358. if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
  1359. echo "==================================";
  1360. echo;
  1361. echo "You need asciidoc installed to be able to build the manpage.";
  1362. echo "To build without manpages, use the --disable-asciidoc argument";
  1363. echo "when calling configure.";
  1364. echo;
  1365. echo "==================================";
  1366. exit 1;
  1367. fi
  1368. done
  1369. fi
  1370. AC_OUTPUT
  1371. if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
  1372. ./contrib/updateVersions.pl
  1373. fi