configure.in 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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. AC_ARG_ENABLE(eventdns,
  40. AC_HELP_STRING(--enable-eventdns, enable asynchronous dns module),
  41. [case "${enableval}" in
  42. yes) eventdns=true ;;
  43. no) eventdns=false ;;
  44. *) AC_MSG_ERROR(bad value for --enable-eventdns) ;;
  45. esac], [eventdns=false])
  46. AM_CONDITIONAL(EVENTDNS, test x$eventdns = xtrue)
  47. if test x$eventdns = xtrue; then
  48. AC_DEFINE([USE_EVENTDNS], 1, "Define to 1 if we'll be using eventdns.c")
  49. fi
  50. case $host in
  51. *-*-solaris* )
  52. AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
  53. ;;
  54. esac
  55. AC_PROG_CC
  56. AC_PROG_MAKE_SET
  57. AC_PROG_RANLIB
  58. # The big search for OpenSSL
  59. # copied from openssh's configure.ac
  60. tryssldir=""
  61. AC_ARG_WITH(ssl-dir,
  62. [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
  63. [
  64. if test "x$withval" != "xno" ; then
  65. tryssldir=$withval
  66. fi
  67. ]
  68. )
  69. trylibeventdir=""
  70. AC_ARG_WITH(libevent-dir,
  71. [ --with-libevent-dir=PATH Specify path to Libevent installation ],
  72. [
  73. if test "x$withval" != "xno" ; then
  74. trylibeventdir=$withval
  75. fi
  76. ]
  77. )
  78. TORUSER=_tor
  79. AC_ARG_WITH(tor-user,
  80. [ --with-tor-user=NAME Specify username for tor daemon ],
  81. [
  82. TORUSER=$withval
  83. ]
  84. )
  85. AC_SUBST(TORUSER)
  86. TORGROUP=_tor
  87. AC_ARG_WITH(tor-group,
  88. [ --with-tor-group=NAME Specify group name for tor daemon ],
  89. [
  90. TORGROUP=$withval
  91. ]
  92. )
  93. AC_SUBST(TORGROUP)
  94. AC_SEARCH_LIBS(socket, [socket])
  95. AC_SEARCH_LIBS(gethostbyname, [nsl])
  96. AC_SEARCH_LIBS(dlopen, [dl])
  97. if test $enable_threads = "yes"; then
  98. AC_SEARCH_LIBS(pthread_create, [pthread])
  99. AC_SEARCH_LIBS(pthread_detach, [pthread])
  100. fi
  101. dnl ------------------------------------------------------
  102. dnl Where do you live, libevent? And how do we call you?
  103. AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [
  104. saved_LIBS="$LIBS"
  105. saved_LDFLAGS="$LDFLAGS"
  106. saved_CPPFLAGS="$CPPFLAGS"
  107. le_found=no
  108. for ledir in $trylibeventdir "" $prefix /usr/local ; do
  109. LDFLAGS="$saved_LDFLAGS"
  110. LIBS="$saved_LIBS -levent"
  111. # Skip the directory if it isn't there.
  112. if test ! -z "$ledir" -a ! -d "$ledir" ; then
  113. continue;
  114. fi
  115. if test ! -z "$ledir" ; then
  116. if test -d "$ledir/lib" ; then
  117. LDFLAGS="-L$ledir/lib $LDFLAGS"
  118. else
  119. LDFLAGS="-L$ledir $LDFLAGS"
  120. fi
  121. if test -d "$ledir/include" ; then
  122. CPPFLAGS="-I$ledir/include $CPPFLAGS"
  123. else
  124. CPPFLAGS="-I$ledir $CPPFLAGS"
  125. fi
  126. fi
  127. # Can I compile and link it?
  128. AC_TRY_LINK([#include <sys/time.h>
  129. #include <sys/types.h>
  130. #include <event.h>], [ event_init(); ],
  131. [ libevent_linked=yes ], [ libevent_linked=no ])
  132. if test $libevent_linked = yes; then
  133. if test ! -z "$ledir" ; then
  134. ac_cv_libevent_dir=$ledir
  135. else
  136. ac_cv_libevent_dir="(system)"
  137. fi
  138. le_found=yes
  139. break
  140. fi
  141. done
  142. LIBS="$saved_LIBS"
  143. LDFLAGS="$saved_LDFLAGS"
  144. CPPFLAGS="$saved_CPPFLAGS"
  145. if test $le_found = no ; then
  146. AC_MSG_ERROR([Could not find a linkable libevent. You can specify an explicit path using --with-libevent-dir])
  147. fi
  148. ])
  149. LIBS="$LIBS -levent"
  150. if test $ac_cv_libevent_dir != "(system)"; then
  151. if test -d "$ac_cv_libevent_dir/lib" ; then
  152. LDFLAGS="-L$ac_cv_libevent_dir/lib $LDFLAGS"
  153. le_libdir="$ac_cv_libevent_dir/lib"
  154. else
  155. LDFLAGS="-L$ac_cv_libevent_dir $LDFLAGS"
  156. le_libdir="$ac_cv_libevent_dir"
  157. fi
  158. if test -d "$ac_cv_libevent_dir/include" ; then
  159. CPPFLAGS="-I$ac_cv_libevent_dir/include $CPPFLAGS"
  160. else
  161. CPPFLAGS="-I$ac_cv_libevent_dir $CPPFLAGS"
  162. fi
  163. fi
  164. if test -z "$CROSS_COMPILE"; then
  165. AC_CACHE_CHECK([whether we need extra options to link libevent],
  166. ac_cv_libevent_linker_option, [
  167. saved_LDFLAGS="$LDFLAGS"
  168. le_runs=no
  169. linked_with=nothing
  170. for le_extra in "" "-Wl,-R$le_libdir" "-R$le_libdir" ; do
  171. LDFLAGS="$le_extra $saved_LDFLAGS"
  172. AC_TRY_RUN([void *event_init(void);
  173. int main(int c, char **v) {
  174. event_init(); return 0;
  175. }],
  176. libevent_runs=yes, libevent_runs=no)
  177. if test $libevent_runs = yes ; then
  178. if test -z "$le_extra" ; then
  179. ac_cv_libevent_linker_option='(none)'
  180. else
  181. ac_cv_libevent_linker_option=$le_extra
  182. fi
  183. le_runs=yes
  184. break
  185. fi
  186. done
  187. if test $le_runs = no ; then
  188. 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?])
  189. fi
  190. LDFLAGS="$saved_LDFLAGS"
  191. ])
  192. if test $ac_cv_libevent_linker_option != '(none)' ; then
  193. LDFLAGS="$ac_cv_libevent_linker_option $LDFLAGS"
  194. fi
  195. fi
  196. dnl ------------------------------------------------------
  197. dnl Where do you live, openssl? And how do we call you?
  198. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssl_dir, [
  199. saved_LIBS="$LIBS"
  200. saved_LDFLAGS="$LDFLAGS"
  201. saved_CPPFLAGS="$CPPFLAGS"
  202. ssl_found=no
  203. 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
  204. LDFLAGS="$saved_LDFLAGS"
  205. LIBS="$saved_LIBS -lssl -lcrypto"
  206. # Skip the directory if it isn't there.
  207. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  208. continue;
  209. fi
  210. if test ! -z "$ssldir" ; then
  211. if test -d "$ssldir/lib" ; then
  212. LDFLAGS="-L$ssldir/lib $LDFLAGS"
  213. else
  214. LDFLAGS="-L$ssldir $LDFLAGS"
  215. fi
  216. if test -d "$ssldir/include" ; then
  217. CPPFLAGS="-I$ssldir/include $CPPFLAGS"
  218. else
  219. CPPFLAGS="-I$ssldir $CPPFLAGS"
  220. fi
  221. fi
  222. # Can I link it?
  223. AC_TRY_LINK([#include <openssl/rand.h>],
  224. [ RAND_add((void*)0,0,0); ],
  225. [ openssl_linked=yes ], [ openssl_linked=no ])
  226. if test $openssl_linked = yes; then
  227. if test ! -z "$ssldir" ; then
  228. ac_cv_openssl_dir=$ssldir
  229. else
  230. ac_cv_openssl_dir="(system)"
  231. fi
  232. ssl_found=yes
  233. break
  234. fi
  235. done
  236. LIBS="$saved_LIBS"
  237. LDFLAGS="$saved_LDFLAGS"
  238. CPPFLAGS="$saved_CPPFLAGS"
  239. if test $ssl_found = no ; then
  240. AC_MSG_ERROR([Could not find a linkable OpenSSL. You can specify an explicit path using --with-ssl-dir])
  241. fi
  242. ])
  243. LIBS="$LIBS -lssl -lcrypto"
  244. if test "$ac_cv_openssl_dir" != "(system)"; then
  245. if test -d "$ac_cv_openssl_dir/lib" ; then
  246. LDFLAGS="-L$ac_cv_openssl_dir/lib $LDFLAGS"
  247. ssl_libdir="$ac_cv_openssl_dir/lib"
  248. else
  249. LDFLAGS="-L$ac_cv_openssl_dir $LDFLAGS"
  250. ssl_libdir="$ac_cv_openssl_dir"
  251. fi
  252. if test -d "$ac_cv_openssl_dir/include" ; then
  253. CPPFLAGS="-I$ac_cv_openssl_dir/include $CPPFLAGS"
  254. else
  255. CPPFLAGS="-I$ac_cv_openssl_dir $CPPFLAGS"
  256. fi
  257. fi
  258. if test -z $CROSS_COMPILE
  259. then
  260. AC_CACHE_CHECK([whether we need extra options to link OpenSSL],
  261. ac_cv_openssl_linker_option, [
  262. saved_LDFLAGS="$LDFLAGS"
  263. ssl_runs=no
  264. linked_with=nothing
  265. for ssl_extra in "" "-Wl,-R$ssl_libdir" "-R$ssl_libdir" ; do
  266. LDFLAGS="$ssl_extra $saved_LDFLAGS"
  267. AC_TRY_RUN([
  268. #include <string.h>
  269. #include <openssl/rand.h>
  270. int main(void)
  271. {
  272. char a[2048];
  273. memset(a, 0, sizeof(a));
  274. RAND_add(a, sizeof(a), sizeof(a));
  275. return(RAND_status() <= 0);
  276. }
  277. ],
  278. openssl_runs=yes, openssl_runs=no)
  279. if test $openssl_runs = yes ; then
  280. if test "$linked_with" = nothing; then
  281. linked_with="$ssl_extra"
  282. fi
  283. AC_TRY_RUN([
  284. #include <openssl/opensslv.h>
  285. #include <openssl/crypto.h>
  286. int main(void) {
  287. return (OPENSSL_VERSION_NUMBER == SSLeay()) == 0;
  288. }],
  289. right_version=yes, right_version=no)
  290. if test "$right_version" = yes; then
  291. if test -z "$ssl_extra" ; then
  292. ac_cv_openssl_linker_option='(none)'
  293. else
  294. ac_cv_openssl_linker_option=$ssl_extra
  295. fi
  296. ssl_runs=yes
  297. break
  298. fi
  299. fi
  300. done
  301. if test $ssl_runs = no ; then
  302. if test "$linked_with" = 'nothing' ; then
  303. 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?])
  304. else
  305. if test -z "$linked_with" ; then
  306. ac_cv_openssl_linker_option='(none)'
  307. else
  308. ac_cv_openssl_linker_option=$linked_with
  309. fi
  310. 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.])
  311. fi
  312. fi
  313. LDFLAGS="$saved_LDFLAGS"
  314. ])
  315. if test "$ac_cv_openssl_linker_option" != '(none)' ; then
  316. LDFLAGS="$ac_cv_openssl_linker_option $LDFLAGS"
  317. fi
  318. fi
  319. dnl Make sure to enable support for large off_t if avalable.
  320. AC_SYS_LARGEFILE
  321. dnl The warning message here is no longer strictly accurate.
  322. 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))
  323. AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.))
  324. 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.))
  325. dnl These headers are not essential
  326. AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h limits.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 sys/mman.h alloca.h)
  327. 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 mmap strtok_r)
  328. if test $enable_threads = "yes"; then
  329. AC_CHECK_HEADERS(pthread.h)
  330. AC_CHECK_FUNCS(pthread_create)
  331. fi
  332. AC_FUNC_FSEEKO
  333. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  334. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  335. dnl Watch out.
  336. AC_CHECK_SIZEOF(int8_t)
  337. AC_CHECK_SIZEOF(int16_t)
  338. AC_CHECK_SIZEOF(int32_t)
  339. AC_CHECK_SIZEOF(int64_t)
  340. AC_CHECK_SIZEOF(uint8_t)
  341. AC_CHECK_SIZEOF(uint16_t)
  342. AC_CHECK_SIZEOF(uint32_t)
  343. AC_CHECK_SIZEOF(uint64_t)
  344. AC_CHECK_SIZEOF(intptr_t)
  345. AC_CHECK_SIZEOF(uintptr_t)
  346. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  347. AC_CHECK_SIZEOF(char)
  348. AC_CHECK_SIZEOF(short)
  349. AC_CHECK_SIZEOF(int)
  350. AC_CHECK_SIZEOF(long)
  351. AC_CHECK_SIZEOF(long long)
  352. AC_CHECK_SIZEOF(__int64)
  353. AC_CHECK_SIZEOF(void *)
  354. AC_CHECK_SIZEOF(time_t)
  355. if test -z "$CROSS_COMPILE"; then
  356. AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
  357. AC_TRY_RUN([
  358. int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }],
  359. tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes)
  360. ])
  361. else
  362. # Cross-compiling; let's hope the target platform isn't loony.
  363. AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
  364. tor_cv_time_t_signed=yes
  365. fi
  366. if test $tor_cv_time_t_signed = yes; then
  367. AC_DEFINE([TIME_T_IS_SIGNED], 1,
  368. [Define to 1 iff time_t is signed])
  369. fi
  370. AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
  371. #ifdef HAVE_SYS_SOCKET_H
  372. #include <sys/socket.h>
  373. #endif
  374. ])
  375. # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
  376. AC_CHECK_SIZEOF(cell_t)
  377. # Now make sure that NULL can be represented as zero bytes.
  378. if test -z "$CROSS_COMPILE"; then
  379. AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
  380. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  381. [[#include <stdlib.h>
  382. #include <string.h>
  383. #include <stdio.h>
  384. #ifdef HAVE_STDDEF_H
  385. #include <stddef.h>
  386. #endif
  387. int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
  388. return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
  389. [tor_cv_null_is_zero=yes],
  390. [tor_cv_null_is_zero=no],
  391. [tor_cv_null_is_zero=cross])])
  392. else
  393. # Cross-compiling; let's hope that the target isn't raving mad.
  394. AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
  395. tor_cv_null_is_zero=yes
  396. fi
  397. if test $tor_cv_null_is_zero = yes; then
  398. AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
  399. [Define to 1 iff memset(0) sets pointers to NULL])
  400. fi
  401. # Whether we should use the dmalloc memory allocation debugging library.
  402. AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
  403. AC_ARG_WITH(dmalloc,
  404. [ --with-dmalloc Use debug memory allocation library. ],
  405. [if [[ "$withval" = "yes" ]]; then
  406. dmalloc=1
  407. AC_MSG_RESULT(yes)
  408. else
  409. dmalloc=1
  410. AC_MSG_RESULT(no)
  411. fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
  412. )
  413. if [[ $dmalloc -eq 1 ]]; then
  414. AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
  415. AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
  416. AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
  417. AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
  418. fi
  419. # Allow user to specify an alternate syslog facility
  420. AC_ARG_WITH(syslog-facility,
  421. [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
  422. syslog_facility="$withval", syslog_facility="LOG_DAEMON")
  423. AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
  424. AC_SUBST(LOGFACILITY)
  425. # Check for gethostbyname_r in all its glorious incompatible versions.
  426. # (This logic is based on that in Python's configure.in)
  427. AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
  428. [Define this if you have any gethostbyname_r()])
  429. AC_CHECK_FUNC(gethostbyname_r, [
  430. AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
  431. OLD_CFLAGS=$CFLAGS
  432. CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
  433. AC_TRY_COMPILE([
  434. #include <netdb.h>
  435. ], [
  436. char *cp1, *cp2;
  437. struct hostent *h1, *h2;
  438. int i1, i2;
  439. (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
  440. ], [
  441. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  442. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
  443. [Define this if gethostbyname_r takes 6 arguments])
  444. AC_MSG_RESULT(6)
  445. ], [
  446. AC_TRY_COMPILE([
  447. #include <netdb.h>
  448. ], [
  449. char *cp1, *cp2;
  450. struct hostent *h1;
  451. int i1, i2;
  452. (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
  453. ], [
  454. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  455. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
  456. [Define this if gethostbyname_r takes 5 arguments])
  457. AC_MSG_RESULT(5)
  458. ], [
  459. AC_TRY_COMPILE([
  460. #include <netdb.h>
  461. ], [
  462. char *cp1;
  463. struct hostent *h1;
  464. struct hostent_data hd;
  465. (void) gethostbyname_r(cp1,h1,&hd);
  466. ], [
  467. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  468. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
  469. [Define this if gethostbyname_r takes 3 arguments])
  470. AC_MSG_RESULT(3)
  471. ], [
  472. AC_MSG_RESULT(0)
  473. ])
  474. ])
  475. ])
  476. CFLAGS=$OLD_CFLAGS
  477. ])
  478. AC_CACHE_CHECK([whether the C compiler supports __func__],
  479. ac_cv_have_func_macro,
  480. AC_COMPILE_IFELSE([
  481. #include <stdio.h>
  482. int main(int c, char **v) { puts(__func__); }],
  483. ac_cv_have_func_macro=yes,
  484. ac_cv_have_func_macro=no))
  485. AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
  486. ac_cv_have_FUNC_macro,
  487. AC_COMPILE_IFELSE([
  488. #include <stdio.h>
  489. int main(int c, char **v) { puts(__FUNC__); }],
  490. ac_cv_have_FUNC_macro=yes,
  491. ac_cv_have_FUNC_macro=no))
  492. AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
  493. ac_cv_have_FUNCTION_macro,
  494. AC_COMPILE_IFELSE([
  495. #include <stdio.h>
  496. int main(int c, char **v) { puts(__FUNCTION__); }],
  497. ac_cv_have_FUNCTION_macro=yes,
  498. ac_cv_have_FUNCTION_macro=no))
  499. if test $ac_cv_have_func_macro = 'yes'; then
  500. AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
  501. fi
  502. if test $ac_cv_have_FUNC_macro = 'yes'; then
  503. AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
  504. fi
  505. if test $ac_cv_have_FUNCTION_macro = 'yes'; then
  506. AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
  507. [Defined if the compiler supports __FUNCTION__])
  508. fi
  509. # $prefix stores the value of the --prefix command line option, or
  510. # NONE if the option wasn't set. In the case that it wasn't set, make
  511. # it be the default, so that we can use it to expand directories now.
  512. if test "x$prefix" = "xNONE"; then
  513. prefix=$ac_default_prefix
  514. fi
  515. # and similarly for $exec_prefix
  516. if test "x$exec_prefix" = "xNONE"; then
  517. exec_prefix=$prefix
  518. fi
  519. CONFDIR=`eval echo $sysconfdir/tor`
  520. AC_SUBST(CONFDIR)
  521. AH_TEMPLATE([CONFDIR],[tor's configuration directory])
  522. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  523. BINDIR=`eval echo $bindir`
  524. AC_SUBST(BINDIR)
  525. LOCALSTATEDIR=`eval echo $localstatedir`
  526. AC_SUBST(LOCALSTATEDIR)
  527. AH_TEMPLATE([LOCALSTATEDIR], [Default location to store state files.])
  528. AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$LOCALSTATEDIR")
  529. # Set CFLAGS _after_ all the above checks, since our warnings are stricter
  530. # than autoconf's macros like.
  531. if test $ac_cv_c_compiler_gnu = yes; then
  532. CFLAGS="$CFLAGS -Wall -g -O2"
  533. else
  534. CFLAGS="$CFLAGS -g -O"
  535. fi
  536. # Add some more warnings which we use in the cvs version but not in the
  537. # released versions. (Some relevant gcc versions can't handle these.)
  538. #CFLAGS="$CFLAGS -W -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"
  539. # Add these in when you feel like fun.
  540. #CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement -Wold-style-definition"
  541. echo "confdir: $CONFDIR"
  542. 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 contrib/suse/Makefile contrib/suse/tor.sh)
  543. if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
  544. ./contrib/updateVersions.pl
  545. fi