configure.ac 50 KB

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