configure.ac 49 KB

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