configure.ac 49 KB

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