configure.in 33 KB

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