configure.in 19 KB

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