configure.in 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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.1.15-rc-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([struct timeval { long tv_sec; long tv_usec; };
  118. typedef unsigned char u_char; typedef unsigned long size_t;
  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. int main(void) { return OPENSSL_VERSION_NUMBER == SSLeay(); }],
  271. right_version=yes, right_version=no)
  272. if test "$right_version" = yes; then
  273. if test -z "$ssl_extra" ; then
  274. ac_cv_openssl_linker_option='(none)'
  275. else
  276. ac_cv_openssl_linker_option=$ssl_extra
  277. fi
  278. ssl_runs=yes
  279. break
  280. fi
  281. fi
  282. done
  283. if test $ssl_runs = no ; then
  284. if test "$linked_with" = 'nothing' ; then
  285. 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?])
  286. else
  287. if test -z "$linked_with" ; then
  288. ac_cv_openssl_linker_option='(none)'
  289. else
  290. ac_cv_openssl_linker_option=$linked_with
  291. fi
  292. AC_MSG_WARN([I managed to make OpenSSL link and run, but I couldn't make it run with the same version as the headers made us expect.])
  293. fi
  294. fi
  295. LDFLAGS="$saved_LDFLAGS"
  296. ])
  297. if test "$ac_cv_openssl_linker_option" != '(none)' ; then
  298. LDFLAGS="$ac_cv_openssl_linker_option $LDFLAGS"
  299. fi
  300. dnl Make sure to enable support for large off_t if avalable.
  301. AC_SYS_LARGEFILE
  302. dnl The warning message here is no longer strictly accurate.
  303. 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))
  304. AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.))
  305. 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.))
  306. dnl These headers are not essential
  307. 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)
  308. 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)
  309. if test $enable_threads = "yes"; then
  310. AC_CHECK_HEADERS(pthread.h)
  311. AC_CHECK_FUNCS(pthread_create)
  312. fi
  313. AC_FUNC_FSEEKO
  314. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  315. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  316. dnl Watch out.
  317. AC_CHECK_SIZEOF(int8_t)
  318. AC_CHECK_SIZEOF(int16_t)
  319. AC_CHECK_SIZEOF(int32_t)
  320. AC_CHECK_SIZEOF(int64_t)
  321. AC_CHECK_SIZEOF(uint8_t)
  322. AC_CHECK_SIZEOF(uint16_t)
  323. AC_CHECK_SIZEOF(uint32_t)
  324. AC_CHECK_SIZEOF(uint64_t)
  325. AC_CHECK_SIZEOF(intptr_t)
  326. AC_CHECK_SIZEOF(uintptr_t)
  327. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  328. AC_CHECK_SIZEOF(char)
  329. AC_CHECK_SIZEOF(short)
  330. AC_CHECK_SIZEOF(int)
  331. AC_CHECK_SIZEOF(long)
  332. AC_CHECK_SIZEOF(long long)
  333. AC_CHECK_SIZEOF(__int64)
  334. AC_CHECK_SIZEOF(void *)
  335. AC_CHECK_SIZEOF(time_t)
  336. AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
  337. AC_TRY_RUN([
  338. int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }],
  339. tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes)
  340. ])
  341. if test $tor_cv_time_t_signed = yes; then
  342. AC_DEFINE([TIME_T_IS_SIGNED], 1,
  343. [Define to 1 iff time_t is signed])
  344. fi
  345. AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
  346. #ifdef HAVE_SYS_SOCKET_H
  347. #include <sys/socket.h>
  348. #endif
  349. ])
  350. # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
  351. AC_CHECK_SIZEOF(cell_t)
  352. # Now, let's see about alignment requirements. On some platforms, we override
  353. # the default.
  354. case $host in
  355. ia64-*-* | arm-*-* | sparc-*-* | sparc64-*-* )
  356. tor_cv_unaligned_ok=no
  357. ;;
  358. # On the following architectures unaligned access works, but is not done in
  359. # hardware. This means that when you try to do unaligned access the kernel
  360. # gets to sort out an exception and then work around to somehow make your
  361. # reqest work, which is quite expensive. Therefore it's probably better to
  362. # not even do it.
  363. alpha-*-* | mips-*-* | mipsel-*-* )
  364. tor_cv_unaligned_ok=no
  365. ;;
  366. *)
  367. AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
  368. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  369. [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
  370. return *(int*)(&s[1]); }]])],
  371. [tor_cv_unaligned_ok=yes],
  372. [tor_cv_unaligned_ok=no],
  373. [tor_cv_unaligned_ok=cross])])
  374. esac
  375. if test $tor_cv_unaligned_ok = yes; then
  376. AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
  377. [Define to 1 iff unaligned int access is allowed])
  378. fi
  379. # Now make sure that NULL can be represented as zero bytes.
  380. AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
  381. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  382. [[#include <stdlib.h>
  383. #include <string.h>
  384. #include <stdio.h>
  385. #ifdef HAVE_STDDEF_H
  386. #include <stddef.h>
  387. #endif
  388. int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
  389. return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
  390. [tor_cv_null_is_zero=yes],
  391. [tor_cv_null_is_zero=no],
  392. [tor_cv_null_is_zero=cross])])
  393. if test $tor_cv_null_is_zero = yes; then
  394. AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
  395. [Define to 1 iff memset(0) sets pointers to NULL])
  396. fi
  397. # Whether we should use the dmalloc memory allocation debugging library.
  398. AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
  399. AC_ARG_WITH(dmalloc,
  400. [ --with-dmalloc Use debug memory allocation library. ],
  401. [if [[ "$withval" = "yes" ]]; then
  402. dmalloc=1
  403. AC_MSG_RESULT(yes)
  404. else
  405. dmalloc=1
  406. AC_MSG_RESULT(no)
  407. fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
  408. )
  409. if [[ $dmalloc -eq 1 ]]; then
  410. AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
  411. AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
  412. AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
  413. AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
  414. fi
  415. # Allow user to specify an alternate syslog facility
  416. AC_ARG_WITH(syslog-facility,
  417. [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
  418. syslog_facility="$withval", syslog_facility="LOG_DAEMON")
  419. AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
  420. AC_SUBST(LOGFACILITY)
  421. # Check for gethostbyname_r in all its glorious incompatible versions.
  422. # (This logic is based on that in Python's configure.in)
  423. AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
  424. [Define this if you have any gethostbyname_r()])
  425. AC_CHECK_FUNC(gethostbyname_r, [
  426. AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
  427. OLD_CFLAGS=$CFLAGS
  428. CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
  429. AC_TRY_COMPILE([
  430. #include <netdb.h>
  431. ], [
  432. char *cp1, *cp2;
  433. struct hostent *h1, *h2;
  434. int i1, i2;
  435. (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
  436. ], [
  437. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  438. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
  439. [Define this if gethostbyname_r takes 6 arguments])
  440. AC_MSG_RESULT(6)
  441. ], [
  442. AC_TRY_COMPILE([
  443. #include <netdb.h>
  444. ], [
  445. char *cp1, *cp2;
  446. struct hostent *h1;
  447. int i1, i2;
  448. (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
  449. ], [
  450. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  451. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
  452. [Define this if gethostbyname_r takes 5 arguments])
  453. AC_MSG_RESULT(5)
  454. ], [
  455. AC_TRY_COMPILE([
  456. #include <netdb.h>
  457. ], [
  458. char *cp1;
  459. struct hostent *h1;
  460. struct hostent_data hd;
  461. (void) gethostbyname_r(cp1,h1,&hd);
  462. ], [
  463. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  464. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
  465. [Define this if gethostbyname_r takes 3 arguments])
  466. AC_MSG_RESULT(3)
  467. ], [
  468. AC_MSG_RESULT(0)
  469. ])
  470. ])
  471. ])
  472. CFLAGS=$OLD_CFLAGS
  473. ])
  474. AC_CACHE_CHECK([whether the C compiler supports __func__],
  475. ac_cv_have_func_macro,
  476. AC_COMPILE_IFELSE([
  477. #include <stdio.h>
  478. int main(int c, char **v) { puts(__func__); }],
  479. ac_cv_have_func_macro=yes,
  480. ac_cv_have_func_macro=no))
  481. AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
  482. ac_cv_have_FUNC_macro,
  483. AC_COMPILE_IFELSE([
  484. #include <stdio.h>
  485. int main(int c, char **v) { puts(__FUNC__); }],
  486. ac_cv_have_FUNC_macro=yes,
  487. ac_cv_have_FUNC_macro=no))
  488. AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
  489. ac_cv_have_FUNCTION_macro,
  490. AC_COMPILE_IFELSE([
  491. #include <stdio.h>
  492. int main(int c, char **v) { puts(__FUNCTION__); }],
  493. ac_cv_have_FUNCTION_macro=yes,
  494. ac_cv_have_FUNCTION_macro=no))
  495. if test $ac_cv_have_func_macro = 'yes'; then
  496. AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
  497. fi
  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_FUNCTION_macro = 'yes'; then
  502. AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
  503. [Defined if the compiler supports __FUNCTION__])
  504. fi
  505. # $prefix stores the value of the --prefix command line option, or
  506. # NONE if the option wasn't set. In the case that it wasn't set, make
  507. # it be the default, so that we can use it to expand directories now.
  508. if test "x$prefix" = "xNONE"; then
  509. prefix=$ac_default_prefix
  510. fi
  511. # and similarly for $exec_prefix
  512. if test "x$exec_prefix" = "xNONE"; then
  513. exec_prefix=$prefix
  514. fi
  515. CONFDIR=`eval echo $sysconfdir/tor`
  516. AC_SUBST(CONFDIR)
  517. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  518. AC_DEFINE([CONFDIR], [], [tor's configuration directory])
  519. BINDIR=`eval echo $bindir`
  520. AC_SUBST(BINDIR)
  521. LOCALSTATEDIR=`eval echo $localstatedir`
  522. AC_SUBST(LOCALSTATEDIR)
  523. AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$LOCALSTATEDIR")
  524. AC_DEFINE([LOCALSTATEDIR], [], [Default location to store state files.])
  525. # Set CFLAGS _after_ all the above checks, since our warnings are stricter
  526. # than autoconf's macros like.
  527. CFLAGS="$CFLAGS -Wall -g -O2"
  528. # Add some more warnings which we use in the cvs version but not in the
  529. # released versions. (Some relevant gcc versions can't handle these.)
  530. #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"
  531. # Add these in when you feel like fun.
  532. #CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement -Wold-style-definition"
  533. echo "confdir: $CONFDIR"
  534. 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)
  535. if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
  536. ./contrib/updateVersions.pl
  537. fi