configure.in 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. dnl $Id$
  2. dnl Copyright (c) 2001-2004, Roger Dingledine
  3. dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  4. dnl See LICENSE for licensing information
  5. AC_INIT
  6. AM_INIT_AUTOMAKE(tor, 0.1.2.0-alpha-cvs)
  7. AM_CONFIG_HEADER(orconfig.h)
  8. AC_CANONICAL_HOST
  9. if test -f /etc/redhat-release; then
  10. CFLAGS="$CFLAGS -I/usr/kerberos/include"
  11. fi
  12. AC_ARG_ENABLE(debug,
  13. AC_HELP_STRING(--enable-debug, compile with debugging info),
  14. [if test x$enableval = xyes; then
  15. CFLAGS="$CFLAGS -g"
  16. fi])
  17. AC_ARG_ENABLE(threads,
  18. AC_HELP_STRING(--disable-threads, disable multi-threading support))
  19. if test x$enable_threads = x; then
  20. case $host in
  21. *-*-netbsd* | *-*-openbsd* )
  22. # Don't try multithreading on netbsd -- there is no threadsafe DNS
  23. # lookup function there.
  24. AC_MSG_NOTICE([You are running OpenBSD or NetBSD; I am assuming that
  25. getaddrinfo is not threadsafe here, so I will disable threads.])
  26. enable_threads="no";;
  27. *-*-solaris* )
  28. # Don't try multithreading on solaris -- cpuworkers seem to lock.
  29. AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
  30. cpu workers lock up here, so I will disable threads.])
  31. enable_threads="no";;
  32. *)
  33. enable_threads="yes";;
  34. esac
  35. fi
  36. if test $enable_threads = "yes"; then
  37. AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
  38. fi
  39. case $host in
  40. *-*-solaris* )
  41. AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
  42. ;;
  43. esac
  44. AC_PROG_CC
  45. AC_PROG_MAKE_SET
  46. AC_PROG_RANLIB
  47. # The big search for OpenSSL
  48. # copied from openssh's configure.ac
  49. tryssldir=""
  50. AC_ARG_WITH(ssl-dir,
  51. [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
  52. [
  53. if test "x$withval" != "xno" ; then
  54. tryssldir=$withval
  55. fi
  56. ]
  57. )
  58. trylibeventdir=""
  59. AC_ARG_WITH(libevent-dir,
  60. [ --with-libevent-dir=PATH Specify path to Libevent installation ],
  61. [
  62. if test "x$withval" != "xno" ; then
  63. trylibeventdir=$withval
  64. fi
  65. ]
  66. )
  67. TORUSER=_tor
  68. AC_ARG_WITH(tor-user,
  69. [ --with-tor-user=NAME Specify username for tor daemon ],
  70. [
  71. TORUSER=$withval
  72. ]
  73. )
  74. AC_SUBST(TORUSER)
  75. TORGROUP=_tor
  76. AC_ARG_WITH(tor-group,
  77. [ --with-tor-group=NAME Specify group name for tor daemon ],
  78. [
  79. TORGROUP=$withval
  80. ]
  81. )
  82. AC_SUBST(TORGROUP)
  83. AC_SEARCH_LIBS(socket, [socket])
  84. AC_SEARCH_LIBS(gethostbyname, [nsl])
  85. AC_SEARCH_LIBS(dlopen, [dl])
  86. if test $enable_threads = "yes"; then
  87. AC_SEARCH_LIBS(pthread_create, [pthread])
  88. AC_SEARCH_LIBS(pthread_detach, [pthread])
  89. fi
  90. dnl ------------------------------------------------------
  91. dnl Where do you live, libevent? And how do we call you?
  92. AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [
  93. saved_LIBS="$LIBS"
  94. saved_LDFLAGS="$LDFLAGS"
  95. saved_CPPFLAGS="$CPPFLAGS"
  96. le_found=no
  97. for ledir in $trylibeventdir "" $prefix /usr/local ; do
  98. LDFLAGS="$saved_LDFLAGS"
  99. LIBS="$saved_LIBS -levent"
  100. # Skip the directory if it isn't there.
  101. if test ! -z "$ledir" -a ! -d "$ledir" ; then
  102. continue;
  103. fi
  104. if test ! -z "$ledir" ; then
  105. if test -d "$ledir/lib" ; then
  106. LDFLAGS="-L$ledir/lib $LDFLAGS"
  107. else
  108. LDFLAGS="-L$ledir $LDFLAGS"
  109. fi
  110. if test -d "$ledir/include" ; then
  111. CPPFLAGS="-I$ledir/include $CPPFLAGS"
  112. else
  113. CPPFLAGS="-I$ledir $CPPFLAGS"
  114. fi
  115. fi
  116. # Can I compile and link it?
  117. AC_TRY_LINK([#include <sys/time.h>
  118. #include <sys/types.h>
  119. #include <event.h>], [ event_init(); ],
  120. [ libevent_linked=yes ], [ libevent_linked=no ])
  121. if test $libevent_linked = yes; then
  122. if test ! -z "$ledir" ; then
  123. ac_cv_libevent_dir=$ledir
  124. else
  125. ac_cv_libevent_dir="(system)"
  126. fi
  127. le_found=yes
  128. break
  129. fi
  130. done
  131. LIBS="$saved_LIBS"
  132. LDFLAGS="$saved_LDFLAGS"
  133. CPPFLAGS="$saved_CPPFLAGS"
  134. if test $le_found = no ; then
  135. AC_MSG_ERROR([Could not find a linkable libevent. You can specify an explicit path using --with-libevent-dir])
  136. fi
  137. ])
  138. LIBS="$LIBS -levent"
  139. if test $ac_cv_libevent_dir != "(system)"; then
  140. if test -d "$ac_cv_libevent_dir/lib" ; then
  141. LDFLAGS="-L$ac_cv_libevent_dir/lib $LDFLAGS"
  142. le_libdir="$ac_cv_libevent_dir/lib"
  143. else
  144. LDFLAGS="-L$ac_cv_libevent_dir $LDFLAGS"
  145. le_libdir="$ac_cv_libevent_dir"
  146. fi
  147. if test -d "$ac_cv_libevent_dir/include" ; then
  148. CPPFLAGS="-I$ac_cv_libevent_dir/include $CPPFLAGS"
  149. else
  150. CPPFLAGS="-I$ac_cv_libevent_dir $CPPFLAGS"
  151. fi
  152. fi
  153. AC_CACHE_CHECK([whether we need extra options to link libevent],
  154. ac_cv_libevent_linker_option, [
  155. saved_LDFLAGS="$LDFLAGS"
  156. le_runs=no
  157. linked_with=nothing
  158. for le_extra in "" "-Wl,-R$le_libdir" "-R$le_libdir" ; do
  159. LDFLAGS="$le_extra $saved_LDFLAGS"
  160. AC_TRY_RUN([void *event_init(void);
  161. int main(int c, char **v) {
  162. event_init(); return 0;
  163. }],
  164. libevent_runs=yes, libevent_runs=no)
  165. if test $libevent_runs = yes ; then
  166. if test -z "$le_extra" ; then
  167. ac_cv_libevent_linker_option='(none)'
  168. else
  169. ac_cv_libevent_linker_option=$le_extra
  170. fi
  171. le_runs=yes
  172. break
  173. fi
  174. done
  175. if test $le_runs = no ; then
  176. AC_MSG_ERROR([Found linkable libevent in $ac_cv_libevent_dir, but it doesn't run, even with -R. Maybe specify another using --with-libevent-dir?])
  177. fi
  178. LDFLAGS="$saved_LDFLAGS"
  179. ])
  180. if test $ac_cv_libevent_linker_option != '(none)' ; then
  181. LDFLAGS="$ac_cv_libevent_linker_option $LDFLAGS"
  182. fi
  183. dnl ------------------------------------------------------
  184. dnl Where do you live, openssl? And how do we call you?
  185. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssl_dir, [
  186. saved_LIBS="$LIBS"
  187. saved_LDFLAGS="$LDFLAGS"
  188. saved_CPPFLAGS="$CPPFLAGS"
  189. ssl_found=no
  190. for ssldir in $tryssldir "" $prefix /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
  191. LDFLAGS="$saved_LDFLAGS"
  192. LIBS="$saved_LIBS -lssl -lcrypto"
  193. # Skip the directory if it isn't there.
  194. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  195. continue;
  196. fi
  197. if test ! -z "$ssldir" ; then
  198. if test -d "$ssldir/lib" ; then
  199. LDFLAGS="-L$ssldir/lib $LDFLAGS"
  200. else
  201. LDFLAGS="-L$ssldir $LDFLAGS"
  202. fi
  203. if test -d "$ssldir/include" ; then
  204. CPPFLAGS="-I$ssldir/include $CPPFLAGS"
  205. else
  206. CPPFLAGS="-I$ssldir $CPPFLAGS"
  207. fi
  208. fi
  209. # Can I link it?
  210. AC_TRY_LINK([#include <openssl/rand.h>],
  211. [ RAND_add((void*)0,0,0); ],
  212. [ openssl_linked=yes ], [ openssl_linked=no ])
  213. if test $openssl_linked = yes; then
  214. if test ! -z "$ssldir" ; then
  215. ac_cv_openssl_dir=$ssldir
  216. else
  217. ac_cv_openssl_dir="(system)"
  218. fi
  219. ssl_found=yes
  220. break
  221. fi
  222. done
  223. LIBS="$saved_LIBS"
  224. LDFLAGS="$saved_LDFLAGS"
  225. CPPFLAGS="$saved_CPPFLAGS"
  226. if test $ssl_found = no ; then
  227. AC_MSG_ERROR([Could not find a linkable OpenSSL. You can specify an explicit path using --with-ssl-dir])
  228. fi
  229. ])
  230. LIBS="$LIBS -lssl -lcrypto"
  231. if test "$ac_cv_openssl_dir" != "(system)"; then
  232. if test -d "$ac_cv_openssl_dir/lib" ; then
  233. LDFLAGS="-L$ac_cv_openssl_dir/lib $LDFLAGS"
  234. ssl_libdir="$ac_cv_openssl_dir/lib"
  235. else
  236. LDFLAGS="-L$ac_cv_openssl_dir $LDFLAGS"
  237. ssl_libdir="$ac_cv_openssl_dir"
  238. fi
  239. if test -d "$ac_cv_openssl_dir/include" ; then
  240. CPPFLAGS="-I$ac_cv_openssl_dir/include $CPPFLAGS"
  241. else
  242. CPPFLAGS="-I$ac_cv_openssl_dir $CPPFLAGS"
  243. fi
  244. fi
  245. AC_CACHE_CHECK([whether we need extra options to link OpenSSL],
  246. ac_cv_openssl_linker_option, [
  247. saved_LDFLAGS="$LDFLAGS"
  248. ssl_runs=no
  249. linked_with=nothing
  250. for ssl_extra in "" "-Wl,-R$ssl_libdir" "-R$ssl_libdir" ; do
  251. LDFLAGS="$ssl_extra $saved_LDFLAGS"
  252. AC_TRY_RUN([
  253. #include <string.h>
  254. #include <openssl/rand.h>
  255. int main(void)
  256. {
  257. char a[2048];
  258. memset(a, 0, sizeof(a));
  259. RAND_add(a, sizeof(a), sizeof(a));
  260. return(RAND_status() <= 0);
  261. }
  262. ],
  263. openssl_runs=yes, openssl_runs=no)
  264. if test $openssl_runs = yes ; then
  265. if test "$linked_with" = nothing; then
  266. linked_with="$ssl_extra"
  267. fi
  268. AC_TRY_RUN([
  269. #include <openssl/opensslv.h>
  270. #include <openssl/crypto.h>
  271. int main(void) {
  272. return (OPENSSL_VERSION_NUMBER == SSLeay()) == 0;
  273. }],
  274. right_version=yes, right_version=no)
  275. if test "$right_version" = yes; then
  276. if test -z "$ssl_extra" ; then
  277. ac_cv_openssl_linker_option='(none)'
  278. else
  279. ac_cv_openssl_linker_option=$ssl_extra
  280. fi
  281. ssl_runs=yes
  282. break
  283. fi
  284. fi
  285. done
  286. if test $ssl_runs = no ; then
  287. if test "$linked_with" = 'nothing' ; then
  288. AC_MSG_ERROR([Found linkable OpenSSL in $ac_cv_openssl_dir, but it doesn't run, even with -R. Maybe specify another using --with-ssl-dir?])
  289. else
  290. if test -z "$linked_with" ; then
  291. ac_cv_openssl_linker_option='(none)'
  292. else
  293. ac_cv_openssl_linker_option=$linked_with
  294. fi
  295. AC_MSG_WARN([I managed to make OpenSSL link and run, but I couldn't make it link against the same version I found header files for.])
  296. fi
  297. fi
  298. LDFLAGS="$saved_LDFLAGS"
  299. ])
  300. if test "$ac_cv_openssl_linker_option" != '(none)' ; then
  301. LDFLAGS="$ac_cv_openssl_linker_option $LDFLAGS"
  302. fi
  303. dnl Make sure to enable support for large off_t if avalable.
  304. AC_SYS_LARGEFILE
  305. dnl The warning message here is no longer strictly accurate.
  306. AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h sys/stat.h sys/types.h fcntl.h sys/fcntl.h sys/ioctl.h sys/socket.h sys/time.h netinet/in.h arpa/inet.h errno.h assert.h time.h pwd.h grp.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
  307. AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.))
  308. AC_CHECK_HEADERS(zlib.h, , AC_MSG_ERROR(Zlib header (zlib.h) not found. Tor requires zlib to build. You may need to install a zlib development package.))
  309. dnl These headers are not essential
  310. AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h stddef.h inttypes.h utime.h sys/utime.h)
  311. AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam getpwuid ftello getaddrinfo localtime_r gmtime_r event_get_version event_get_method event_set_log_callback memmem)
  312. if test $enable_threads = "yes"; then
  313. AC_CHECK_HEADERS(pthread.h)
  314. AC_CHECK_FUNCS(pthread_create)
  315. fi
  316. AC_FUNC_FSEEKO
  317. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  318. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  319. dnl Watch out.
  320. AC_CHECK_SIZEOF(int8_t)
  321. AC_CHECK_SIZEOF(int16_t)
  322. AC_CHECK_SIZEOF(int32_t)
  323. AC_CHECK_SIZEOF(int64_t)
  324. AC_CHECK_SIZEOF(uint8_t)
  325. AC_CHECK_SIZEOF(uint16_t)
  326. AC_CHECK_SIZEOF(uint32_t)
  327. AC_CHECK_SIZEOF(uint64_t)
  328. AC_CHECK_SIZEOF(intptr_t)
  329. AC_CHECK_SIZEOF(uintptr_t)
  330. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  331. AC_CHECK_SIZEOF(char)
  332. AC_CHECK_SIZEOF(short)
  333. AC_CHECK_SIZEOF(int)
  334. AC_CHECK_SIZEOF(long)
  335. AC_CHECK_SIZEOF(long long)
  336. AC_CHECK_SIZEOF(__int64)
  337. AC_CHECK_SIZEOF(void *)
  338. AC_CHECK_SIZEOF(time_t)
  339. AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
  340. AC_TRY_RUN([
  341. int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }],
  342. tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes)
  343. ])
  344. if test $tor_cv_time_t_signed = yes; then
  345. AC_DEFINE([TIME_T_IS_SIGNED], 1,
  346. [Define to 1 iff time_t is signed])
  347. fi
  348. AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
  349. #ifdef HAVE_SYS_SOCKET_H
  350. #include <sys/socket.h>
  351. #endif
  352. ])
  353. # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
  354. AC_CHECK_SIZEOF(cell_t)
  355. # Now, let's see about alignment requirements. On some platforms, we override
  356. # the default.
  357. case $host in
  358. ia64-*-* | arm-*-* | sparc-*-* | sparc64-*-* )
  359. tor_cv_unaligned_ok=no
  360. ;;
  361. # On the following architectures unaligned access works, but is not done in
  362. # hardware. This means that when you try to do unaligned access the kernel
  363. # gets to sort out an exception and then work around to somehow make your
  364. # reqest work, which is quite expensive. Therefore it's probably better to
  365. # not even do it.
  366. alpha-*-* | mips-*-* | mipsel-*-* )
  367. tor_cv_unaligned_ok=no
  368. ;;
  369. *)
  370. AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
  371. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  372. [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
  373. return *(int*)(&s[1]); }]])],
  374. [tor_cv_unaligned_ok=yes],
  375. [tor_cv_unaligned_ok=no],
  376. [tor_cv_unaligned_ok=cross])])
  377. esac
  378. if test $tor_cv_unaligned_ok = yes; then
  379. AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
  380. [Define to 1 iff unaligned int access is allowed])
  381. fi
  382. # Now make sure that NULL can be represented as zero bytes.
  383. AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
  384. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  385. [[#include <stdlib.h>
  386. #include <string.h>
  387. #include <stdio.h>
  388. #ifdef HAVE_STDDEF_H
  389. #include <stddef.h>
  390. #endif
  391. int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
  392. return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
  393. [tor_cv_null_is_zero=yes],
  394. [tor_cv_null_is_zero=no],
  395. [tor_cv_null_is_zero=cross])])
  396. if test $tor_cv_null_is_zero = yes; then
  397. AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
  398. [Define to 1 iff memset(0) sets pointers to NULL])
  399. fi
  400. # Whether we should use the dmalloc memory allocation debugging library.
  401. AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
  402. AC_ARG_WITH(dmalloc,
  403. [ --with-dmalloc Use debug memory allocation library. ],
  404. [if [[ "$withval" = "yes" ]]; then
  405. dmalloc=1
  406. AC_MSG_RESULT(yes)
  407. else
  408. dmalloc=1
  409. AC_MSG_RESULT(no)
  410. fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
  411. )
  412. if [[ $dmalloc -eq 1 ]]; then
  413. AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
  414. AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
  415. AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
  416. AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
  417. fi
  418. # Allow user to specify an alternate syslog facility
  419. AC_ARG_WITH(syslog-facility,
  420. [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
  421. syslog_facility="$withval", syslog_facility="LOG_DAEMON")
  422. AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
  423. AC_SUBST(LOGFACILITY)
  424. # Check for gethostbyname_r in all its glorious incompatible versions.
  425. # (This logic is based on that in Python's configure.in)
  426. AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
  427. [Define this if you have any gethostbyname_r()])
  428. AC_CHECK_FUNC(gethostbyname_r, [
  429. AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
  430. OLD_CFLAGS=$CFLAGS
  431. CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
  432. AC_TRY_COMPILE([
  433. #include <netdb.h>
  434. ], [
  435. char *cp1, *cp2;
  436. struct hostent *h1, *h2;
  437. int i1, i2;
  438. (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
  439. ], [
  440. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  441. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
  442. [Define this if gethostbyname_r takes 6 arguments])
  443. AC_MSG_RESULT(6)
  444. ], [
  445. AC_TRY_COMPILE([
  446. #include <netdb.h>
  447. ], [
  448. char *cp1, *cp2;
  449. struct hostent *h1;
  450. int i1, i2;
  451. (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
  452. ], [
  453. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  454. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
  455. [Define this if gethostbyname_r takes 5 arguments])
  456. AC_MSG_RESULT(5)
  457. ], [
  458. AC_TRY_COMPILE([
  459. #include <netdb.h>
  460. ], [
  461. char *cp1;
  462. struct hostent *h1;
  463. struct hostent_data hd;
  464. (void) gethostbyname_r(cp1,h1,&hd);
  465. ], [
  466. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  467. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
  468. [Define this if gethostbyname_r takes 3 arguments])
  469. AC_MSG_RESULT(3)
  470. ], [
  471. AC_MSG_RESULT(0)
  472. ])
  473. ])
  474. ])
  475. CFLAGS=$OLD_CFLAGS
  476. ])
  477. AC_CACHE_CHECK([whether the C compiler supports __func__],
  478. ac_cv_have_func_macro,
  479. AC_COMPILE_IFELSE([
  480. #include <stdio.h>
  481. int main(int c, char **v) { puts(__func__); }],
  482. ac_cv_have_func_macro=yes,
  483. ac_cv_have_func_macro=no))
  484. AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
  485. ac_cv_have_FUNC_macro,
  486. AC_COMPILE_IFELSE([
  487. #include <stdio.h>
  488. int main(int c, char **v) { puts(__FUNC__); }],
  489. ac_cv_have_FUNC_macro=yes,
  490. ac_cv_have_FUNC_macro=no))
  491. AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
  492. ac_cv_have_FUNCTION_macro,
  493. AC_COMPILE_IFELSE([
  494. #include <stdio.h>
  495. int main(int c, char **v) { puts(__FUNCTION__); }],
  496. ac_cv_have_FUNCTION_macro=yes,
  497. ac_cv_have_FUNCTION_macro=no))
  498. if test $ac_cv_have_func_macro = 'yes'; then
  499. AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
  500. fi
  501. if test $ac_cv_have_FUNC_macro = 'yes'; then
  502. AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
  503. fi
  504. if test $ac_cv_have_FUNCTION_macro = 'yes'; then
  505. AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
  506. [Defined if the compiler supports __FUNCTION__])
  507. fi
  508. # $prefix stores the value of the --prefix command line option, or
  509. # NONE if the option wasn't set. In the case that it wasn't set, make
  510. # it be the default, so that we can use it to expand directories now.
  511. if test "x$prefix" = "xNONE"; then
  512. prefix=$ac_default_prefix
  513. fi
  514. # and similarly for $exec_prefix
  515. if test "x$exec_prefix" = "xNONE"; then
  516. exec_prefix=$prefix
  517. fi
  518. CONFDIR=`eval echo $sysconfdir/tor`
  519. AC_SUBST(CONFDIR)
  520. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  521. AC_DEFINE([CONFDIR], [], [tor's configuration directory])
  522. BINDIR=`eval echo $bindir`
  523. AC_SUBST(BINDIR)
  524. LOCALSTATEDIR=`eval echo $localstatedir`
  525. AC_SUBST(LOCALSTATEDIR)
  526. AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$LOCALSTATEDIR")
  527. AC_DEFINE([LOCALSTATEDIR], [], [Default location to store state files.])
  528. # Set CFLAGS _after_ all the above checks, since our warnings are stricter
  529. # than autoconf's macros like.
  530. if test $ac_cv_c_compiler_gnu = yes; then
  531. CFLAGS="$CFLAGS -Wall -g -O2"
  532. else
  533. CFLAGS="$CFLAGS -g -O"
  534. fi
  535. # Add some more warnings which we use in the cvs version but not in the
  536. # released versions. (Some relevant gcc versions can't handle these.)
  537. #CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Winit-self -Wwrite-strings -Waggregate-return -Wmissing-declarations -Wmissing-field-initializers -Wredundant-decls -Winline"
  538. # Add these in when you feel like fun.
  539. #CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement -Wold-style-definition"
  540. echo "confdir: $CONFDIR"
  541. AC_OUTPUT(Makefile tor.spec contrib/tor.sh contrib/torctl contrib/torify contrib/tor.logrotate contrib/Makefile contrib/osx/Makefile contrib/osx/TorBundleDesc.plist contrib/osx/TorBundleInfo.plist contrib/osx/TorDesc.plist contrib/osx/TorInfo.plist contrib/osx/TorStartupDesc.plist src/config/torrc.sample doc/tor.1 src/Makefile doc/Makefile doc/design-paper/Makefile src/config/Makefile src/common/Makefile src/or/Makefile src/win32/Makefile src/tools/Makefile)
  542. if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
  543. ./contrib/updateVersions.pl
  544. fi