configure.ac 50 KB

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