configure.in 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  1. dnl Copyright (c) 2001-2004, Roger Dingledine
  2. dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  3. dnl Copyright (c) 2007-2008, The Tor Project, Inc.
  4. dnl See LICENSE for licensing information
  5. AC_INIT
  6. AM_INIT_AUTOMAKE(tor, 0.2.3.0-alpha-dev)
  7. AM_CONFIG_HEADER(orconfig.h)
  8. AC_CANONICAL_HOST
  9. if test -f /etc/redhat-release ; then
  10. if test -f /usr/kerberos/include ; then
  11. CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
  12. fi
  13. fi
  14. # Not a no-op; we want to make sure that CPPFLAGS is set before we use
  15. # the += operator on it in src/or/Makefile.am
  16. CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common"
  17. #XXXX020 We should make these enabled or not, before 0.2.0.x-final
  18. AC_ARG_ENABLE(buf-freelists,
  19. AS_HELP_STRING(--disable-buf-freelists, disable freelists for buffer RAM))
  20. AC_ARG_ENABLE(openbsd-malloc,
  21. AS_HELP_STRING(--enable-openbsd-malloc, Use malloc code from openbsd. Linux only))
  22. AC_ARG_ENABLE(instrument-downloads,
  23. AS_HELP_STRING(--enable-instrument-downloads, Instrument downloads of directory resources etc.))
  24. AC_ARG_ENABLE(static-openssl,
  25. AS_HELP_STRING(--enable-static-openssl, Link against a static openssl library. Requires --with-openssl-dir))
  26. AC_ARG_ENABLE(static-libevent,
  27. AS_HELP_STRING(--enable-static-libevent, Link against a static libevent library. Requires --with-libevent-dir))
  28. AC_ARG_ENABLE(static-zlib,
  29. AS_HELP_STRING(--enable-static-zlib, Link against a static zlib library. Requires --with-zlib-dir))
  30. if test x$enable_buf_freelists != xno; then
  31. AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
  32. [Defined if we try to use freelists for buffer RAM chunks])
  33. fi
  34. AM_CONDITIONAL(USE_OPENBSD_MALLOC, test x$enable_openbsd_malloc = xyes)
  35. if test x$enable_instrument_downloads = xyes; then
  36. AC_DEFINE(INSTRUMENT_DOWNLOADS, 1,
  37. [Defined if we want to keep track of how much of each kind of resource we download.])
  38. fi
  39. AC_ARG_ENABLE(transparent,
  40. AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
  41. [case "${enableval}" in
  42. yes) transparent=true ;;
  43. no) transparent=false ;;
  44. *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
  45. esac], [transparent=true])
  46. AC_ARG_ENABLE(asciidoc,
  47. AS_HELP_STRING(--disable-asciidoc, don't use asciidoc (disables building of manpages)),
  48. [case "${enableval}" in
  49. yes) asciidoc=true ;;
  50. no) asciidoc=false ;;
  51. *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;
  52. esac], [asciidoc=true])
  53. # By default, we're not ready to ship a NAT-PMP aware Tor
  54. AC_ARG_ENABLE(nat-pmp,
  55. AS_HELP_STRING(--enable-nat-pmp, enable NAT-PMP support),
  56. [case "${enableval}" in
  57. yes) natpmp=true ;;
  58. no) natpmp=false ;;
  59. * ) AC_MSG_ERROR(bad value for --enable-nat-pmp) ;;
  60. esac], [natpmp=false])
  61. # By default, we're not ready to ship a UPnP aware Tor
  62. AC_ARG_ENABLE(upnp,
  63. AS_HELP_STRING(--enable-upnp, enable UPnP support),
  64. [case "${enableval}" in
  65. yes) upnp=true ;;
  66. no) upnp=false ;;
  67. * ) AC_MSG_ERROR(bad value for --enable-upnp) ;;
  68. esac], [upnp=false])
  69. AC_ARG_ENABLE(threads,
  70. AS_HELP_STRING(--disable-threads, disable multi-threading support))
  71. if test x$enable_threads = x; then
  72. case $host in
  73. *-*-solaris* )
  74. # Don't try multithreading on solaris -- cpuworkers seem to lock.
  75. AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
  76. cpu workers lock up here, so I will disable threads.])
  77. enable_threads="no";;
  78. *)
  79. enable_threads="yes";;
  80. esac
  81. fi
  82. if test "$enable_threads" = "yes"; then
  83. AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
  84. fi
  85. case $host in
  86. *-*-solaris* )
  87. AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
  88. ;;
  89. esac
  90. AC_ARG_ENABLE(gcc-warnings,
  91. AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
  92. AC_ARG_ENABLE(gcc-warnings-advisory,
  93. AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
  94. dnl Adam shostack suggests the following for Windows:
  95. dnl -D_FORTIFY_SOURCE=2 -fstack-protector-all
  96. dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
  97. dnl This requires that we use gcc and that we add -O2 to the CFLAGS.
  98. AC_ARG_ENABLE(gcc-hardening,
  99. AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks),
  100. [if test x$enableval = xyes; then
  101. CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
  102. CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
  103. CFLAGS="$CFLAGS --param ssp-buffer-size=1"
  104. LDFLAGS="$LDFLAGS -pie"
  105. fi])
  106. dnl Linker hardening options
  107. dnl Currently these options are ELF specific - you can't use this with MacOSX
  108. AC_ARG_ENABLE(linker-hardening,
  109. AS_HELP_STRING(--enable-linker-hardening, enable linker security fixups),
  110. [if test x$enableval = xyes; then
  111. LDFLAGS="$LDFLAGS -z relro -z now"
  112. fi])
  113. AC_ARG_ENABLE(local-appdata,
  114. AS_HELP_STRING(--enable-local-appdata, default to host local application data paths on Windows))
  115. if test "$enable_local_appdata" = "yes"; then
  116. AC_DEFINE(ENABLE_LOCAL_APPDATA, 1,
  117. [Defined if we default to host local appdata paths on Windows])
  118. fi
  119. AC_ARG_ENABLE(bufferevents,
  120. AS_HELP_STRING(--enable-bufferevents, use Libevent's buffered IO.))
  121. AC_PROG_CC
  122. AC_PROG_CPP
  123. AC_PROG_MAKE_SET
  124. AC_PROG_RANLIB
  125. dnl autoconf 2.59 appears not to support AC_PROG_SED
  126. AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
  127. dnl check for asciidoc and a2x
  128. AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
  129. AC_PATH_PROG([A2X], [a2x], none)
  130. AM_CONDITIONAL(USE_ASCIIDOC, test x$asciidoc = xtrue)
  131. AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
  132. AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
  133. AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
  134. AM_PROG_CC_C_O
  135. ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
  136. AC_C_FLEXIBLE_ARRAY_MEMBER
  137. ], [
  138. dnl Maybe we've got an old autoconf...
  139. AC_CACHE_CHECK([for flexible array members],
  140. tor_cv_c_flexarray,
  141. [AC_COMPILE_IFELSE(
  142. AC_LANG_PROGRAM([
  143. struct abc { int a; char b[]; };
  144. ], [
  145. struct abc *def = malloc(sizeof(struct abc)+sizeof(char));
  146. def->b[0] = 33;
  147. ]),
  148. [tor_cv_c_flexarray=yes],
  149. [tor_cv_c_flexarray=no])])
  150. if test $tor_cv_flexarray = yes ; then
  151. AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [])
  152. else
  153. AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1])
  154. fi
  155. ])
  156. AC_PATH_PROG([SHA1SUM], [sha1sum], none)
  157. AC_PATH_PROG([OPENSSL], [openssl], none)
  158. TORUSER=_tor
  159. AC_ARG_WITH(tor-user,
  160. [ --with-tor-user=NAME Specify username for tor daemon ],
  161. [
  162. TORUSER=$withval
  163. ]
  164. )
  165. AC_SUBST(TORUSER)
  166. TORGROUP=_tor
  167. AC_ARG_WITH(tor-group,
  168. [ --with-tor-group=NAME Specify group name for tor daemon ],
  169. [
  170. TORGROUP=$withval
  171. ]
  172. )
  173. AC_SUBST(TORGROUP)
  174. dnl If WIN32 is defined and non-zero, we are building for win32
  175. AC_MSG_CHECKING([for win32])
  176. AC_RUN_IFELSE([AC_LANG_SOURCE([
  177. int main(int c, char **v) {
  178. #ifdef WIN32
  179. #if WIN32
  180. return 0;
  181. #else
  182. return 1;
  183. #endif
  184. #else
  185. return 2;
  186. #endif
  187. }])],
  188. bwin32=true; AC_MSG_RESULT([yes]),
  189. bwin32=false; AC_MSG_RESULT([no]),
  190. bwin32=cross; AC_MSG_RESULT([cross])
  191. )
  192. if test "$bwin32" = cross; then
  193. AC_MSG_CHECKING([for win32 (cross)])
  194. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  195. #ifdef WIN32
  196. int main(int c, char **v) {return 0;}
  197. #else
  198. #error
  199. int main(int c, char **v) {return x(y);}
  200. #endif
  201. ])],
  202. bwin32=true; AC_MSG_RESULT([yes]),
  203. bwin32=false; AC_MSG_RESULT([no]))
  204. fi
  205. if test "$bwin32" = true; then
  206. AC_DEFINE(MS_WINDOWS, 1, [Define to 1 if we are building for Windows.])
  207. fi
  208. AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
  209. dnl Enable C99 when compiling with MIPSpro
  210. AC_MSG_CHECKING([for MIPSpro compiler])
  211. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
  212. #if (defined(__sgi) && defined(_COMPILER_VERSION))
  213. #error
  214. return x(y);
  215. #endif
  216. ])],
  217. bmipspro=false; AC_MSG_RESULT(no),
  218. bmipspro=true; AC_MSG_RESULT(yes))
  219. if test "$bmipspro" = true; then
  220. CFLAGS="$CFLAGS -c99"
  221. fi
  222. AC_C_BIGENDIAN
  223. AC_SEARCH_LIBS(socket, [socket])
  224. AC_SEARCH_LIBS(gethostbyname, [nsl])
  225. AC_SEARCH_LIBS(dlopen, [dl])
  226. AC_SEARCH_LIBS(inet_aton, [resolv])
  227. if test "$enable_threads" = "yes"; then
  228. AC_SEARCH_LIBS(pthread_create, [pthread])
  229. AC_SEARCH_LIBS(pthread_detach, [pthread])
  230. fi
  231. dnl -------------------------------------------------------------------
  232. dnl Check for functions before libevent, since libevent-1.2 apparently
  233. dnl exports strlcpy without defining it in a header.
  234. AC_CHECK_FUNCS(
  235. accept4 \
  236. flock \
  237. ftime \
  238. getaddrinfo \
  239. getrlimit \
  240. gettimeofday \
  241. gmtime_r \
  242. inet_aton \
  243. localtime_r \
  244. memmem \
  245. prctl \
  246. socketpair \
  247. strlcat \
  248. strlcpy \
  249. strptime \
  250. strtok_r \
  251. strtoull \
  252. sysconf \
  253. uname \
  254. vasprintf \
  255. )
  256. using_custom_malloc=no
  257. if test x$enable_openbsd_malloc = xyes ; then
  258. AC_DEFINE(HAVE_MALLOC_GOOD_SIZE, 1, [Defined if we have the malloc_good_size function])
  259. using_custom_malloc=yes
  260. fi
  261. if test x$tcmalloc = xyes ; then
  262. using_custom_malloc=yes
  263. fi
  264. if test $using_custom_malloc = no ; then
  265. AC_CHECK_FUNCS(mallinfo malloc_good_size malloc_usable_size)
  266. fi
  267. if test "$enable_threads" = "yes"; then
  268. AC_CHECK_HEADERS(pthread.h)
  269. AC_CHECK_FUNCS(pthread_create)
  270. fi
  271. dnl ------------------------------------------------------
  272. dnl Where do you live, libevent? And how do we call you?
  273. if test "$bwin32" = true; then
  274. TOR_LIB_WS32=-lws2_32
  275. # Some of the cargo-cults recommend -lwsock32 as well, but I don't
  276. # think it's actually necessary.
  277. TOR_LIB_GDI=-lgdi32
  278. else
  279. TOR_LIB_WS32=
  280. TOR_LIB_GDI=
  281. fi
  282. AC_SUBST(TOR_LIB_WS32)
  283. AC_SUBST(TOR_LIB_GDI)
  284. dnl We need to do this before we try our disgusting hack below.
  285. AC_CHECK_HEADERS([sys/types.h])
  286. dnl This is a disgusting hack so we safely include older libevent headers.
  287. AC_CHECK_TYPE(u_int64_t, unsigned long long)
  288. AC_CHECK_TYPE(u_int32_t, unsigned long)
  289. AC_CHECK_TYPE(u_int16_t, unsigned short)
  290. AC_CHECK_TYPE(u_int8_t, unsigned char)
  291. tor_libevent_pkg_redhat="libevent"
  292. tor_libevent_pkg_debian="libevent-dev"
  293. tor_libevent_devpkg_redhat="libevent-devel"
  294. tor_libevent_devpkg_debian="libevent-dev"
  295. dnl On Gnu/Linux or any place we require it, we'll add librt to the Libevent
  296. dnl linking for static builds.
  297. STATIC_LIBEVENT_FLAGS=""
  298. if test "$enable_static_libevent" = "yes"; then
  299. dnl Determine if we have clock_gettime in librt
  300. AC_SEARCH_LIBS([clock_gettime], [rt],
  301. [have_rt=yes])
  302. if test "$have_rt" = yes; then
  303. STATIC_LIBEVENT_FLAGS=" -lrt "
  304. fi
  305. fi
  306. TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32], [
  307. #ifdef WIN32
  308. #include <winsock2.h>
  309. #endif
  310. #include <stdlib.h>
  311. #include <sys/time.h>
  312. #include <sys/types.h>
  313. #include <event.h>], [
  314. #ifdef WIN32
  315. #include <winsock2.h>
  316. #endif
  317. void exit(int); void *event_init(void);],
  318. [
  319. #ifdef WIN32
  320. {WSADATA d; WSAStartup(0x101,&d); }
  321. #endif
  322. event_init(); exit(0);
  323. ], [--with-libevent-dir], [/opt/libevent])
  324. dnl Now check for particular libevent functions.
  325. save_LIBS="$LIBS"
  326. save_LDFLAGS="$LDFLAGS"
  327. save_CPPFLAGS="$CPPFLAGS"
  328. LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
  329. LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
  330. CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
  331. AC_CHECK_FUNCS(event_get_version event_get_version_number event_get_method event_set_log_callback evdns_set_outgoing_bind_address event_base_loopexit)
  332. AC_CHECK_MEMBERS([struct event.min_heap_idx], , ,
  333. [#include <event.h>
  334. ])
  335. AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
  336. LIBS="$save_LIBS"
  337. LDFLAGS="$save_LDFLAGS"
  338. CPPFLAGS="$save_CPPFLAGS"
  339. AM_CONDITIONAL(USE_EXTERNAL_EVDNS, test x$ac_cv_header_event2_dns_h = xyes)
  340. if test "$enable_static_libevent" = "yes"; then
  341. if test "$tor_cv_library_libevent_dir" = "(system)"; then
  342. AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
  343. else
  344. TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
  345. fi
  346. else
  347. TOR_LIBEVENT_LIBS="-levent"
  348. fi
  349. AC_SUBST(TOR_LIBEVENT_LIBS)
  350. dnl This isn't the best test for Libevent 2.0.3-alpha. Once it's released,
  351. dnl we can do much better.
  352. if test "$enable_bufferevents" = "yes" ; then
  353. if test "$ac_cv_header_event2_bufferevent_ssl_h" != "yes" ; then
  354. 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.])
  355. else
  356. CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent"
  357. # Check for the right version. First see if version detection works.
  358. AC_MSG_CHECKING([whether we can detect the Libevent version])
  359. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  360. #include <event2/event.h>
  361. #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 10
  362. #error
  363. int x = y(zz);
  364. #else
  365. int x = 1;
  366. #endif
  367. ])], [event_version_number_works=yes; AC_MSG_RESULT([yes]) ],
  368. [event_version_number_works=no; AC_MSG_RESULT([no])])
  369. if test "$event_version_number_works" != 'yes'; then
  370. AC_MSG_WARN([Version detection on Libevent seems broken. Your Libevent installation is probably screwed up or very old.])
  371. else
  372. AC_MSG_CHECKING([whether Libevent is new enough for bufferevents])
  373. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  374. #include <event2/event.h>
  375. #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000800
  376. #error
  377. int x = y(zz);
  378. #else
  379. int x = 1;
  380. #endif
  381. ])], [ AC_MSG_RESULT([yes]) ],
  382. [ AC_MSG_RESULT([no])
  383. AC_MSG_ERROR([Libevent does not seem new enough to support bufferevents. We require 2.0.8-rc or later]) ] )
  384. fi
  385. fi
  386. fi
  387. LIBS="$save_LIBS"
  388. LDFLAGS="$save_LDFLAGS"
  389. CPPFLAGS="$save_CPPFLAGS"
  390. AM_CONDITIONAL(USE_BUFFEREVENTS, test "$enable_bufferevents" = "yes")
  391. if test "$enable_bufferevents" = "yes"; then
  392. AC_DEFINE(USE_BUFFEREVENTS, 1, [Defined if we're going to use Libevent's buffered IO API])
  393. fi
  394. dnl ------------------------------------------------------
  395. dnl Where do you live, openssl? And how do we call you?
  396. tor_openssl_pkg_redhat="openssl"
  397. tor_openssl_pkg_debian="libssl"
  398. tor_openssl_devpkg_redhat="openssl-devel"
  399. tor_openssl_devpkg_debian="libssl-dev"
  400. ALT_openssl_WITHVAL=""
  401. AC_ARG_WITH(ssl-dir,
  402. [ --with-ssl-dir=PATH Obsolete alias for --with-openssl-dir ],
  403. [
  404. if test "x$withval" != xno && test "x$withval" != "x" ; then
  405. ALT_openssl_WITHVAL="$withval"
  406. fi
  407. ])
  408. TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
  409. [#include <openssl/rand.h>],
  410. [void RAND_add(const void *buf, int num, double entropy);],
  411. [RAND_add((void*)0,0,0); exit(0);], [],
  412. [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
  413. dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
  414. echo "tor_cv_library_openssl_dir is $tor_cv_library_openssl_dir"
  415. if test "$enable_static_openssl" = "yes"; then
  416. if test "$tor_cv_library_openssl_dir" = "(system)"; then
  417. AC_MSG_ERROR("You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl")
  418. else
  419. TOR_OPENSSL_LIBS="$TOR_LIBDIR_openssl/libssl.a $TOR_LIBDIR_openssl/libcrypto.a"
  420. fi
  421. else
  422. TOR_OPENSSL_LIBS="-lssl -lcrypto"
  423. fi
  424. AC_SUBST(TOR_OPENSSL_LIBS)
  425. dnl ------------------------------------------------------
  426. dnl Where do you live, zlib? And how do we call you?
  427. tor_zlib_pkg_redhat="zlib"
  428. tor_zlib_pkg_debian="zlib1g"
  429. tor_zlib_devpkg_redhat="zlib-devel"
  430. tor_zlib_devpkg_debian="zlib1g-dev"
  431. TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
  432. [#include <zlib.h>],
  433. [const char * zlibVersion(void);],
  434. [zlibVersion(); exit(0);], [--with-zlib-dir],
  435. [/opt/zlib])
  436. if test "$enable_static_zlib" = "yes"; then
  437. if test "$tor_cv_library_zlib_dir" = "(system)"; then
  438. AC_MSG_ERROR("You must specify an explicit --with-zlib-dir=x option when
  439. using --enable-static-zlib")
  440. else
  441. TOR_ZLIB_LIBS="$TOR_LIBDIR_zlib/libz.a"
  442. echo "$TOR_LIBDIR_zlib/libz.a"
  443. fi
  444. else
  445. TOR_ZLIB_LIBS="-lz"
  446. fi
  447. AC_SUBST(TOR_ZLIB_LIBS)
  448. dnl Make sure to enable support for large off_t if available.
  449. dnl ------------------------------------------------------
  450. dnl Where do you live, libnatpmp? And how do we call you?
  451. dnl There are no packages for Debian or Redhat as of this patch
  452. if test "$natpmp" = "true"; then
  453. AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
  454. TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp],
  455. [#include <natpmp.h>],
  456. [#include <natpmp.h>],
  457. [ int r;
  458. natpmp_t natpmp;
  459. natpmpresp_t response;
  460. r = initnatpmp(&natpmp);],
  461. [printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
  462. exit(0);],
  463. [--with-libnatpmp-dir],
  464. [/usr/lib/])
  465. fi
  466. dnl ------------------------------------------------------
  467. dnl Where do you live, libminiupnpc? And how do we call you?
  468. dnl There are no packages for Debian or Redhat as of this patch
  469. if test "$upnp" = "true"; then
  470. AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
  471. TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc],
  472. [#include <miniupnpc/miniwget.h>
  473. #include <miniupnpc/miniupnpc.h>
  474. #include <miniupnpc/upnpcommands.h>],
  475. [void upnpDiscover(int delay, const char * multicastif,
  476. const char * minissdpdsock, int sameport);],
  477. [upnpDiscover(1, 0, 0, 0); exit(0);],
  478. [--with-libminiupnpc-dir],
  479. [/usr/lib/])
  480. fi
  481. AC_SYS_LARGEFILE
  482. AC_CHECK_HEADERS(
  483. assert.h \
  484. errno.h \
  485. fcntl.h \
  486. signal.h \
  487. string.h \
  488. sys/fcntl.h \
  489. sys/stat.h \
  490. sys/time.h \
  491. sys/types.h \
  492. time.h \
  493. unistd.h
  494. , , 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.))
  495. dnl These headers are not essential
  496. AC_CHECK_HEADERS(
  497. arpa/inet.h \
  498. grp.h \
  499. inttypes.h \
  500. limits.h \
  501. linux/types.h \
  502. machine/limits.h \
  503. malloc.h \
  504. malloc/malloc.h \
  505. malloc_np.h \
  506. netdb.h \
  507. netinet/in.h \
  508. netinet/in6.h \
  509. pwd.h \
  510. stdint.h \
  511. sys/file.h \
  512. sys/ioctl.h \
  513. sys/limits.h \
  514. sys/mman.h \
  515. sys/param.h \
  516. sys/prctl.h \
  517. sys/resource.h \
  518. sys/socket.h \
  519. sys/syslimits.h \
  520. sys/time.h \
  521. sys/types.h \
  522. sys/un.h \
  523. sys/utime.h \
  524. sys/wait.h \
  525. syslog.h \
  526. utime.h
  527. )
  528. TOR_CHECK_PROTOTYPE(malloc_good_size, HAVE_MALLOC_GOOD_SIZE_PROTOTYPE,
  529. [#ifdef HAVE_MALLOC_H
  530. #include <malloc.h>
  531. #endif
  532. #ifdef HAVE_MALLOC_MALLOC_H
  533. #include <malloc/malloc.h>
  534. #endif])
  535. AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
  536. [#ifdef HAVE_SYS_TYPES_H
  537. #include <sys/types.h>
  538. #endif
  539. #ifdef HAVE_SYS_SOCKET_H
  540. #include <sys/socket.h>
  541. #endif])
  542. AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
  543. [#ifdef HAVE_SYS_TYPES_H
  544. #include <sys/types.h>
  545. #endif
  546. #ifdef HAVE_SYS_SOCKET_H
  547. #include <sys/socket.h>
  548. #endif
  549. #ifdef HAVE_NET_IF_H
  550. #include <net/if.h>
  551. #endif])
  552. AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
  553. linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
  554. [#ifdef HAVE_SYS_TYPES_H
  555. #include <sys/types.h>
  556. #endif
  557. #ifdef HAVE_SYS_SOCKET_H
  558. #include <sys/socket.h>
  559. #endif
  560. #ifdef HAVE_LIMITS_H
  561. #include <limits.h>
  562. #endif
  563. #ifdef HAVE_LINUX_TYPES_H
  564. #include <linux/types.h>
  565. #endif
  566. #ifdef HAVE_NETINET_IN6_H
  567. #include <netinet/in6.h>
  568. #endif
  569. #ifdef HAVE_NETINET_IN_H
  570. #include <netinet/in.h>
  571. #endif])
  572. if test x$transparent = xtrue ; then
  573. transparent_ok=0
  574. if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
  575. transparent_ok=1
  576. fi
  577. if test x$linux_netfilter_ipv4 = x1 ; then
  578. transparent_ok=1
  579. fi
  580. if test x$transparent_ok = x1 ; then
  581. AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
  582. case $host in
  583. *-*-openbsd*)
  584. AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
  585. esac
  586. else
  587. AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
  588. fi
  589. fi
  590. AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
  591. [#ifdef HAVE_SYS_TYPES_H
  592. #include <sys/types.h>
  593. #endif
  594. #ifdef HAVE_SYS_TIME_H
  595. #include <sys/time.h>
  596. #endif])
  597. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  598. dnl Watch out.
  599. AC_CHECK_SIZEOF(int8_t)
  600. AC_CHECK_SIZEOF(int16_t)
  601. AC_CHECK_SIZEOF(int32_t)
  602. AC_CHECK_SIZEOF(int64_t)
  603. AC_CHECK_SIZEOF(uint8_t)
  604. AC_CHECK_SIZEOF(uint16_t)
  605. AC_CHECK_SIZEOF(uint32_t)
  606. AC_CHECK_SIZEOF(uint64_t)
  607. AC_CHECK_SIZEOF(intptr_t)
  608. AC_CHECK_SIZEOF(uintptr_t)
  609. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  610. AC_CHECK_SIZEOF(char)
  611. AC_CHECK_SIZEOF(short)
  612. AC_CHECK_SIZEOF(int)
  613. AC_CHECK_SIZEOF(long)
  614. AC_CHECK_SIZEOF(long long)
  615. AC_CHECK_SIZEOF(__int64)
  616. AC_CHECK_SIZEOF(void *)
  617. AC_CHECK_SIZEOF(time_t)
  618. AC_CHECK_SIZEOF(size_t)
  619. AC_CHECK_TYPES([uint, u_char, ssize_t])
  620. dnl used to include sockaddr_storage, but everybody has that.
  621. AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
  622. [#ifdef HAVE_SYS_TYPES_H
  623. #include <sys/types.h>
  624. #endif
  625. #ifdef HAVE_NETINET_IN_H
  626. #include <netinet/in.h>
  627. #endif
  628. #ifdef HAVE_NETINET_IN6_H
  629. #include <netinet/in6.h>
  630. #endif
  631. #ifdef HAVE_SYS_SOCKET_H
  632. #include <sys/socket.h>
  633. #endif
  634. #ifdef MS_WINDOWS
  635. #define WIN32_WINNT 0x400
  636. #define _WIN32_WINNT 0x400
  637. #define WIN32_LEAN_AND_MEAN
  638. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  639. #include <winsock.h>
  640. #else
  641. #include <winsock2.h>
  642. #include <ws2tcpip.h>
  643. #endif
  644. #endif
  645. ])
  646. AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
  647. [#ifdef HAVE_SYS_TYPES_H
  648. #include <sys/types.h>
  649. #endif
  650. #ifdef HAVE_NETINET_IN_H
  651. #include <netinet/in.h>
  652. #endif
  653. #ifdef HAVE_NETINET_IN6_H
  654. #include <netinet/in6.h>
  655. #endif
  656. #ifdef HAVE_SYS_SOCKET_H
  657. #include <sys/socket.h>
  658. #endif
  659. #ifdef MS_WINDOWS
  660. #define WIN32_WINNT 0x400
  661. #define _WIN32_WINNT 0x400
  662. #define WIN32_LEAN_AND_MEAN
  663. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  664. #include <winsock.h>
  665. #else
  666. #include <winsock2.h>
  667. #include <ws2tcpip.h>
  668. #endif
  669. #endif
  670. ])
  671. AC_CHECK_TYPES([rlim_t], , ,
  672. [#ifdef HAVE_SYS_TYPES_H
  673. #include <sys/types.h>
  674. #endif
  675. #ifdef HAVE_SYS_TIME_H
  676. #include <sys/time.h>
  677. #endif
  678. #ifdef HAVE_SYS_RESOURCE_H
  679. #include <sys/resource.h>
  680. #endif
  681. ])
  682. AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
  683. AC_RUN_IFELSE([AC_LANG_SOURCE([
  684. #ifdef HAVE_SYS_TYPES_H
  685. #include <sys/types.h>
  686. #endif
  687. #ifdef HAVE_SYS_TIME_H
  688. #include <sys/time.h>
  689. #endif
  690. #ifdef HAVE_TIME_H
  691. #include <time.h>
  692. #endif
  693. int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }])],
  694. tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes, tor_cv_time_t_signed=cross)
  695. ])
  696. if test "$tor_cv_time_t_signed" = cross; then
  697. AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
  698. fi
  699. if test "$tor_cv_time_t_signed" != no; then
  700. AC_DEFINE([TIME_T_IS_SIGNED], 1,
  701. [Define to 1 iff time_t is signed])
  702. fi
  703. AC_CACHE_CHECK([whether size_t is signed], tor_cv_size_t_signed, [
  704. AC_RUN_IFELSE([AC_LANG_SOURCE([
  705. #ifdef HAVE_SYS_TYPES_H
  706. #include <sys/types.h>
  707. #endif
  708. int main(int c, char**v) { if (((size_t)-1)<0) return 1; else return 0; }])],
  709. tor_cv_size_t_signed=no, tor_cv_size_t_signed=yes, tor_cv_size_t_signed=cross)
  710. ])
  711. if test "$tor_cv_size_t_signed" = cross; then
  712. AC_MSG_NOTICE([Cross compiling: assuming that size_t is not signed.])
  713. fi
  714. if test "$tor_cv_size_t_signed" = yes; then
  715. AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
  716. fi
  717. AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
  718. #ifdef HAVE_SYS_SOCKET_H
  719. #include <sys/socket.h>
  720. #endif
  721. ])
  722. # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
  723. AC_CHECK_SIZEOF(cell_t)
  724. # Now make sure that NULL can be represented as zero bytes.
  725. AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
  726. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  727. [[#include <stdlib.h>
  728. #include <string.h>
  729. #include <stdio.h>
  730. #ifdef HAVE_STDDEF_H
  731. #include <stddef.h>
  732. #endif
  733. int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
  734. return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
  735. [tor_cv_null_is_zero=yes],
  736. [tor_cv_null_is_zero=no],
  737. [tor_cv_null_is_zero=cross])])
  738. if test "$tor_cv_null_is_zero" = cross ; then
  739. # Cross-compiling; let's hope that the target isn't raving mad.
  740. AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
  741. fi
  742. if test "$tor_cv_null_is_zero" != no; then
  743. AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
  744. [Define to 1 iff memset(0) sets pointers to NULL])
  745. fi
  746. # And what happens when we malloc zero?
  747. AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
  748. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  749. [[#include <stdlib.h>
  750. #include <string.h>
  751. #include <stdio.h>
  752. #ifdef HAVE_STDDEF_H
  753. #include <stddef.h>
  754. #endif
  755. int main () { return malloc(0)?0:1; }]])],
  756. [tor_cv_malloc_zero_works=yes],
  757. [tor_cv_malloc_zero_works=no],
  758. [tor_cv_malloc_zero_works=cross])])
  759. if test "$tor_cv_malloc_zero_works" = cross; then
  760. # Cross-compiling; let's hope that the target isn't raving mad.
  761. AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
  762. fi
  763. if test "$tor_cv_malloc_zero_works" = yes; then
  764. AC_DEFINE([MALLOC_ZERO_WORKS], 1,
  765. [Define to 1 iff malloc(0) returns a pointer])
  766. fi
  767. # whether we seem to be in a 2s-complement world.
  768. AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
  769. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  770. [[int main () { int problem = ((-99) != (~99)+1);
  771. return problem ? 1 : 0; }]])],
  772. [tor_cv_twos_complement=yes],
  773. [tor_cv_twos_complement=no],
  774. [tor_cv_twos_complement=cross])])
  775. if test "$tor_cv_twos_complement" = cross ; then
  776. # Cross-compiling; let's hope that the target isn't raving mad.
  777. AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
  778. fi
  779. if test "$tor_cv_twos_complement" != no ; then
  780. AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
  781. [Define to 1 iff we represent negative integers with two's complement])
  782. fi
  783. # Whether we should use the dmalloc memory allocation debugging library.
  784. AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
  785. AC_ARG_WITH(dmalloc,
  786. [ --with-dmalloc Use debug memory allocation library. ],
  787. [if [[ "$withval" = "yes" ]]; then
  788. dmalloc=1
  789. AC_MSG_RESULT(yes)
  790. else
  791. dmalloc=1
  792. AC_MSG_RESULT(no)
  793. fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
  794. )
  795. if [[ $dmalloc -eq 1 ]]; then
  796. AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
  797. AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
  798. AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
  799. AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
  800. AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
  801. fi
  802. AC_ARG_WITH(tcmalloc,
  803. [ --with-tcmalloc Use tcmalloc memory allocation library. ],
  804. [ tcmalloc=yes ], [ tcmalloc=no ])
  805. if test x$tcmalloc = xyes ; then
  806. LDFLAGS="-ltcmalloc $LDFLAGS"
  807. fi
  808. # By default, we're going to assume we don't have mlockall()
  809. # bionic and other platforms have various broken mlockall subsystems.
  810. # Some systems don't have a working mlockall, some aren't linkable,
  811. # and some have it but don't declare it.
  812. AC_CHECK_FUNCS(mlockall)
  813. AC_CHECK_DECLS([mlockall], , , [
  814. #ifdef HAVE_SYS_MMAN_H
  815. #include <sys/mman.h>
  816. #endif])
  817. # Allow user to specify an alternate syslog facility
  818. AC_ARG_WITH(syslog-facility,
  819. [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
  820. syslog_facility="$withval", syslog_facility="LOG_DAEMON")
  821. AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
  822. AC_SUBST(LOGFACILITY)
  823. # Check if we have getresuid and getresgid
  824. AC_CHECK_FUNCS(getresuid getresgid)
  825. # Check for gethostbyname_r in all its glorious incompatible versions.
  826. # (This logic is based on that in Python's configure.in)
  827. AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
  828. [Define this if you have any gethostbyname_r()])
  829. AC_CHECK_FUNC(gethostbyname_r, [
  830. AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
  831. OLD_CFLAGS=$CFLAGS
  832. CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
  833. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  834. #include <netdb.h>
  835. ], [[
  836. char *cp1, *cp2;
  837. struct hostent *h1, *h2;
  838. int i1, i2;
  839. (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
  840. ]])],[
  841. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  842. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
  843. [Define this if gethostbyname_r takes 6 arguments])
  844. AC_MSG_RESULT(6)
  845. ], [
  846. AC_TRY_COMPILE([
  847. #include <netdb.h>
  848. ], [
  849. char *cp1, *cp2;
  850. struct hostent *h1;
  851. int i1, i2;
  852. (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
  853. ], [
  854. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  855. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
  856. [Define this if gethostbyname_r takes 5 arguments])
  857. AC_MSG_RESULT(5)
  858. ], [
  859. AC_TRY_COMPILE([
  860. #include <netdb.h>
  861. ], [
  862. char *cp1;
  863. struct hostent *h1;
  864. struct hostent_data hd;
  865. (void) gethostbyname_r(cp1,h1,&hd);
  866. ], [
  867. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  868. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
  869. [Define this if gethostbyname_r takes 3 arguments])
  870. AC_MSG_RESULT(3)
  871. ], [
  872. AC_MSG_RESULT(0)
  873. ])
  874. ])
  875. ])
  876. CFLAGS=$OLD_CFLAGS
  877. ])
  878. AC_CACHE_CHECK([whether the C compiler supports __func__],
  879. tor_cv_have_func_macro,
  880. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  881. #include <stdio.h>
  882. int main(int c, char **v) { puts(__func__); }])],
  883. tor_cv_have_func_macro=yes,
  884. tor_cv_have_func_macro=no))
  885. AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
  886. tor_cv_have_FUNC_macro,
  887. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  888. #include <stdio.h>
  889. int main(int c, char **v) { puts(__FUNC__); }])],
  890. tor_cv_have_FUNC_macro=yes,
  891. tor_cv_have_FUNC_macro=no))
  892. AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
  893. tor_cv_have_FUNCTION_macro,
  894. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  895. #include <stdio.h>
  896. int main(int c, char **v) { puts(__FUNCTION__); }])],
  897. tor_cv_have_FUNCTION_macro=yes,
  898. tor_cv_have_FUNCTION_macro=no))
  899. if test "$tor_cv_have_func_macro" = 'yes'; then
  900. AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
  901. fi
  902. if test "$tor_cv_have_FUNC_macro" = 'yes'; then
  903. AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
  904. fi
  905. if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
  906. AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
  907. [Defined if the compiler supports __FUNCTION__])
  908. fi
  909. # $prefix stores the value of the --prefix command line option, or
  910. # NONE if the option wasn't set. In the case that it wasn't set, make
  911. # it be the default, so that we can use it to expand directories now.
  912. if test "x$prefix" = "xNONE"; then
  913. prefix=$ac_default_prefix
  914. fi
  915. # and similarly for $exec_prefix
  916. if test "x$exec_prefix" = "xNONE"; then
  917. exec_prefix=$prefix
  918. fi
  919. if test "x$BUILDDIR" = "x"; then
  920. BUILDDIR=`pwd`
  921. fi
  922. AC_SUBST(BUILDDIR)
  923. AH_TEMPLATE([BUILDDIR],[tor's build directory])
  924. AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
  925. if test "x$CONFDIR" = "x"; then
  926. CONFDIR=`eval echo $sysconfdir/tor`
  927. fi
  928. AC_SUBST(CONFDIR)
  929. AH_TEMPLATE([CONFDIR],[tor's configuration directory])
  930. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  931. BINDIR=`eval echo $bindir`
  932. AC_SUBST(BINDIR)
  933. LOCALSTATEDIR=`eval echo $localstatedir`
  934. AC_SUBST(LOCALSTATEDIR)
  935. if test "$bwin32" = true; then
  936. # Test if the linker supports the --nxcompat and --dynamicbase options
  937. # for Windows
  938. save_LDFLAGS="$LDFLAGS"
  939. LDFLAGS="-Wl,--nxcompat -Wl,--dynamicbase"
  940. AC_MSG_CHECKING([whether the linker supports DllCharacteristics])
  941. AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
  942. [AC_MSG_RESULT([yes])]
  943. [save_LDFLAGS="$save_LDFLAGS $LDFLAGS"],
  944. [AC_MSG_RESULT([no])]
  945. )
  946. LDFLAGS="$save_LDFLAGS"
  947. fi
  948. # Set CFLAGS _after_ all the above checks, since our warnings are stricter
  949. # than autoconf's macros like.
  950. if test "$GCC" = yes; then
  951. # Disable GCC's strict aliasing checks. They are an hours-to-debug
  952. # accident waiting to happen.
  953. CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
  954. else
  955. # Autoconf sets -g -O2 by default. Override optimization level
  956. # for non-gcc compilers
  957. CFLAGS="$CFLAGS -O"
  958. enable_gcc_warnings=no
  959. enable_gcc_warnings_advisory=no
  960. fi
  961. # Add some more warnings which we use in development but not in the
  962. # released versions. (Some relevant gcc versions can't handle these.)
  963. if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xyes; then
  964. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  965. #if !defined(__GNUC__) || (__GNUC__ < 4)
  966. #error
  967. #endif])], have_gcc4=yes, have_gcc4=no)
  968. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  969. #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
  970. #error
  971. #endif])], have_gcc42=yes, have_gcc42=no)
  972. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  973. #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
  974. #error
  975. #endif])], have_gcc43=yes, have_gcc43=no)
  976. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  977. #if !defined(__clang__) || (__clang_major__ > 2) || (__clang_major__ == 2 && __clang_minor__ > 9)
  978. #error
  979. #endif])], have_clang29orlower=yes, have_clang29orlower=no)
  980. save_CFLAGS="$CFLAGS"
  981. CFLAGS="$CFLAGS -Wshorten-64-to-32"
  982. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
  983. have_shorten64_flag=no)
  984. CFLAGS="$save_CFLAGS"
  985. case $host in
  986. *-*-openbsd*)
  987. # Some OpenBSD versions (like 4.8) have -Wsystem-headers by default.
  988. # That's fine, except that the headers don't pass -Wredundant-decls.
  989. # Therefore, let's disable -Wsystem-headers when we're building
  990. # with maximal warnings on OpenBSD.
  991. CFLAGS="$CFLAGS -Wno-system-headers" ;;
  992. esac
  993. CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
  994. CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
  995. CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
  996. CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
  997. CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
  998. if test x$enable_gcc_warnings = xyes; then
  999. CFLAGS="$CFLAGS -Werror"
  1000. fi
  1001. # Disabled, so we can use mallinfo(): -Waggregate-return
  1002. if test x$have_gcc4 = xyes ; then
  1003. # These warnings break gcc 3.3.5 and work on gcc 4.0.2
  1004. CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
  1005. fi
  1006. if test x$have_gcc42 = xyes ; then
  1007. # These warnings break gcc 4.0.2 and work on gcc 4.2
  1008. # XXXX020 See if any of these work with earlier versions.
  1009. CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
  1010. # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
  1011. fi
  1012. if test x$have_gcc42 = xyes && test x$have_clang29orlower = xno; then
  1013. # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
  1014. # We only disable these for clang 2.9 and lower, in case they are
  1015. # supported in later versions.
  1016. CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
  1017. fi
  1018. if test x$have_gcc43 = xyes ; then
  1019. # These warnings break gcc 4.2 and work on gcc 4.3
  1020. # XXXX020 See if any of these work with earlier versions.
  1021. CFLAGS="$CFLAGS -Wextra -Warray-bounds"
  1022. fi
  1023. if test x$have_shorten64_flag = xyes ; then
  1024. CFLAGS="$CFLAGS -Wshorten-64-to-32"
  1025. fi
  1026. ##This will break the world on some 64-bit architectures
  1027. # CFLAGS="$CFLAGS -Winline"
  1028. fi
  1029. CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
  1030. AC_CONFIG_FILES([
  1031. Doxyfile
  1032. Makefile
  1033. contrib/Makefile
  1034. contrib/suse/Makefile
  1035. contrib/suse/tor.sh
  1036. contrib/tor.logrotate
  1037. contrib/tor.sh
  1038. contrib/torctl
  1039. contrib/torify
  1040. doc/Makefile
  1041. src/Makefile
  1042. src/common/Makefile
  1043. src/config/Makefile
  1044. src/config/torrc.sample
  1045. src/or/Makefile
  1046. src/test/Makefile
  1047. src/tools/Makefile
  1048. src/tools/tor-fw-helper/Makefile
  1049. src/win32/Makefile
  1050. tor.spec
  1051. ])
  1052. AC_OUTPUT
  1053. if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
  1054. ./contrib/updateVersions.pl
  1055. fi