configure.in 19 KB

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