Some errors fixed, most of them where buffer-position errors.
[oweals/gnunet.git] / configure.ac
1 # This file is part of GNUnet.
2 # (C) 2001--2010 Christian Grothoff (and other contributing authors)
3 #
4 # GNUnet is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published
6 # by the Free Software Foundation; either version 2, or (at your
7 # option) any later version.
8 #
9 # GNUnet is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNUnet; see the file COPYING.  If not, write to the
16 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
18 #
19 #
20 # Process this file with autoconf to produce a configure script.
21 #
22 #
23 AC_PREREQ(2.61)
24 AC_INIT([gnunet], [0.9.0pre2],[bug-gnunet@gnu.org])
25 AM_INIT_AUTOMAKE([gnunet], [0.9.0pre2])
26 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
27 AC_CONFIG_HEADERS([gnunet_config.h])
28
29 AH_TOP([#define _GNU_SOURCE  1])
30
31 # Checks for programs.
32 AC_CANONICAL_HOST
33 AC_PROG_AWK
34 AC_PROG_CC
35 AC_PROG_CPP
36 AC_PROG_CXX
37 AC_PROG_OBJC
38 AC_PROG_INSTALL
39 AC_PROG_LN_S
40 AC_PROG_MAKE_SET
41 AM_PROG_CC_C_O
42 AC_CANONICAL_HOST
43 LT_INIT([disable-static dlopen win32-dll])
44 LTDL_INIT
45 AC_SUBST(LTDLINCL)
46 AC_SUBST(LIBLTDL)
47 AC_SUBST(MKDIR_P)
48
49 # large file support
50 AC_SYS_LARGEFILE
51 AC_FUNC_FSEEKO
52
53
54 if test "$enable_shared" = "no"
55 then
56  AC_MSG_ERROR([GNUnet only works with shared libraries. Sorry.])
57 fi
58
59 CFLAGS="-Wall $CFLAGS"
60 # use '-fno-strict-aliasing', but only if the compiler can take it
61 if gcc -fno-strict-aliasing -S -o /dev/null -xc /dev/null >/dev/null 2>&1;
62 then
63  CFLAGS="-fno-strict-aliasing $CFLAGS"
64 fi
65
66 # Use Linux interface name unless the OS has a different preference
67 DEFAULT_INTERFACE="\"eth0\""
68
69 # Check system type
70 case "$host_os" in
71 *darwin* | *rhapsody* | *macosx*)
72      AC_DEFINE_UNQUOTED(DARWIN,1,[This is an Apple Darwin system])
73      CPPFLAGS="-D_APPLE_C_SOURCE $CPPFLAGS"
74      CFLAGS="-no-cpp-precomp -fno-common $CFLAGS"
75      AC_MSG_WARN([The VPN application cannot be compiled on your OS])
76      build_target="darwin"
77      DEFAULT_INTERFACE="\"en0\""
78      LIBPREFIX=
79      DLLDIR=lib
80      ;;
81 linux*)
82      AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
83      build_target="linux"
84      LIBPREFIX=
85      DLLDIR=lib
86      AC_PATH_XTRA
87      ;;
88 freebsd*)
89      AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
90      AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
91      CFLAGS="-D_THREAD_SAFE $CFLAGS"
92      build_target="freebsd"
93      LIBPREFIX=
94      DLLDIR=lib
95      ;;
96 openbsd*)
97      AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
98      AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
99      LIBS=`echo $LIBS | sed -e "s/-ldl//"`
100      build_target="openbsd"
101      LIBPREFIX=
102      DLLDIR=lib
103      ;;
104 netbsd*)
105      AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
106      AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
107      LIBPREFIX=
108      DLLDIR=lib
109      ;;
110 *solaris*)
111      AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
112      AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno doesnt work])
113      AC_CHECK_LIB(resolv, res_init)
114      AC_CHECK_LIB(rt, nanosleep)
115      build_target="solaris"
116      LIBPREFIX=
117      DLLDIR=lib
118      ;;
119 *arm-linux*)
120      AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
121      CFLAGS="-D_REENTRANT -fPIC -pipe $CFLAGS"
122      build_target="linux"
123      LIBPREFIX=
124      DLLDIR=lib
125      ;;
126 *cygwin*)
127      AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
128      AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
129      AC_CHECK_LIB(intl, gettext)
130      LDFLAGS="$LDFLAGS -no-undefined"
131      CFLAGS="-mms-bitfields $CFLAGS"
132      build_target="cygwin"
133      LIBPREFIX=lib
134      DLLDIR=bin
135      AC_PROG_CXX
136      ;;
137 *mingw*)
138      AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
139      AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
140      AC_DEFINE_UNQUOTED(_WIN32,1,[This is a Windows system])
141      AC_CHECK_LIB(intl, gettext)
142      LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols"
143      LIBS="$LIBS -lws2_32 -lplibc"
144      CFLAGS="-mms-bitfields $CFLAGS"
145      CPPFLAGS="-D_WIN32_WINNT=0x0501 $CPPFLAGS"
146      build_target="mingw"
147      AC_PROG_CXX
148      LIBPREFIX=lib
149      DLLDIR=bin
150      ;;
151 *)
152      AC_MSG_RESULT(Unrecognised OS $host_os)
153      AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
154 ;;
155 esac
156 AC_DEFINE_UNQUOTED([GNUNET_DEFAULT_INTERFACE], $DEFAULT_INTERFACE, [This should be the default choice for the name of the first network interface])
157 AC_SUBST(DEFAULT_INTERFACE)
158
159 AC_MSG_CHECKING([for build target])
160 AM_CONDITIONAL(DARWIN,  test "$build_target" = "darwin")
161 AM_CONDITIONAL(CYGWIN,  test "$build_target" = "cygwin")
162 AM_CONDITIONAL(MINGW,   test "$build_target" = "mingw")
163 AM_CONDITIONAL(SOLARIS, test "$build_target" = "solaris")
164 AM_CONDITIONAL(XFREEBSD, test "$build_target" = "freebsd")
165 AM_CONDITIONAL(OPENBSD, test "$build_target" = "openbsd")
166 AM_CONDITIONAL(LINUX, test "$build_target" = "linux")
167
168 AC_MSG_RESULT([$build_target])
169 AC_SUBST(build_target)
170 AM_CONDITIONAL([am__fastdepOBJC], false)
171 AC_UNALIGNED_64_ACCESS
172
173 # some other checks for standard libs
174 AC_SEARCH_LIBS([gethostbyname], [nsl ws2_32])
175 AC_CHECK_LIB(socket, socket)
176 AC_CHECK_LIB(m, log)
177 AC_CHECK_LIB(c, getloadavg, AC_DEFINE(HAVE_GETLOADAVG,1,[getloadavg supported]))
178
179 # 'save' libs; only those libs found so far will be
180 # linked against _everywhere_.  For the others, we
181 # will be more selective!
182 SAVE_LIBS=$LIBS
183
184 # libgcrypt
185 gcrypt=0
186 AM_PATH_LIBGCRYPT(1.2.0, gcrypt=1)
187 AC_CHECK_DECLS([gcry_mpi_lshift], [], [], [[#include <gcrypt.h>]])
188
189 if test $gcrypt = 0
190 then
191   AC_MSG_ERROR([GNUnet needs libgcrypt])
192 fi
193
194 AC_MSG_CHECKING([for working HMAC])
195 AC_LANG_PUSH(C)
196 LIBS="$LIBS $LIBGCRYPT_LIBS"
197 CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
198 AC_RUN_IFELSE(
199   [AC_LANG_PROGRAM([#include <gcrypt.h>], [[
200         gcry_md_hd_t mac;
201       
202         unsigned char data[] = { 0xbf, 0x16, 0x6e, 0x46, 0x3a, 0x6c, 0xf3, 0x93, 0xa7, 0x72,
203             0x11, 0xa1, 0xdc, 0x0b, 0x07, 0xdb, 0x1a, 0x5e, 0xd9, 0xb9, 0x81, 0xbe,
204             0xea, 0xe4, 0x31, 0x5f, 0x24, 0xff, 0xfe, 0x50, 0x8a, 0xde };
205         unsigned char key[] = { 0xfc, 0x62, 0x76, 0x35 };
206         unsigned char result[] = {0xa2, 0xb, 0x1, 0xd9, 0xc0, 0x8b, 0x5a, 0x12, 0x80,
207             0xd5, 0x50, 0x12, 0x8e, 0xd0, 0x5b, 0xb6, 0x5c, 0x87, 0x24, 0xe2, 0xd0,
208             0xd2, 0xaf, 0x63, 0xae, 0xd1, 0xd6, 0x64, 0x14, 0xe3, 0x6e, 0x61, 0x5b,
209             0xd, 0xba, 0x17, 0x7d, 0xd3, 0x10, 0xb1, 0x37, 0x41, 0x91, 0x7d, 0xeb,
210             0x1, 0x4d, 0x71, 0xe8, 0x59, 0x71, 0x42, 0x8e, 0xd6, 0xf3, 0x29, 0x3b,
211             0x90, 0xf2, 0xd1, 0xaf, 0x65, 0x1e, 0xb3};
212       
213         if (!gcry_check_version (GCRYPT_VERSION))
214           return 1;
215   
216         gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
217         gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
218   
219         if (gcry_md_open(&mac, GCRY_MD_SHA512, GCRY_MD_FLAG_HMAC) != GPG_ERR_NO_ERROR)
220           return 2;
221   
222         gcry_md_setkey (mac, key, sizeof (key));
223         gcry_md_write (mac, data, sizeof (data));
224   
225         if (memcmp(gcry_md_read (mac, 0), result, gcry_md_get_algo_dlen (gcry_md_get_algo (mac))) != 0)
226           return 3;
227   
228         gcry_md_close (mac);
229   
230         return 0;
231     ]])],
232   [AC_MSG_RESULT([yes])],
233   [
234    if test $? = 3
235    then
236      AC_MSG_FAILURE([HMAC test vector does not match. This is a known problem with libgcrypt 1.2.2 on Windows and fixed in 1.4.6.])
237    else
238      AC_MSG_FAILURE([HMAC test failed])
239    fi
240   ])
241 AC_LANG_POP(C)
242
243 # libcurl
244 LIBCURL_CHECK_CONFIG(,7.20.1,,AC_MSG_ERROR([GNUnet requires libcurl >= 7.20.1]))
245 # restore LIBS
246 LIBS=$SAVE_LIBS
247
248 # test for kvm and kstat (for CPU stats under BSD/Solaris)
249 AC_CHECK_LIB([kvm],[kvm_open])
250 AC_CHECK_LIB([kstat],[kstat_open])
251
252 # test for libextractor
253 extractor=0
254 AC_MSG_CHECKING(for libextractor)
255 AC_ARG_WITH(extractor,
256    [  --with-extractor=PFX    base of libextractor installation],
257    [AC_MSG_RESULT([$with_extractor])
258     case $with_extractor in
259       no)
260         ;;
261       yes)
262         AC_CHECK_HEADERS(extractor.h,
263           AC_CHECK_LIB([extractor], [EXTRACTOR_plugin_add_defaults],
264             extractor=1))
265         ;;
266       *)
267         LDFLAGS="-L$with_extractor/lib $LDFLAGS"
268         CPPFLAGS="-I$with_extractor/include $CPPFLAGS"
269         AC_CHECK_HEADERS(extractor.h,
270           AC_CHECK_LIB([extractor], [EXTRACTOR_plugin_add_defaults],
271             EXT_LIB_PATH="-L$with_extractor/lib $EXT_LIB_PATH"
272             extractor=1))
273         ;;
274     esac
275    ],
276    [AC_MSG_RESULT([--with-extractor not specified])
277     AC_CHECK_HEADERS(extractor.h,
278      AC_CHECK_LIB([extractor], [EXTRACTOR_plugin_add_defaults],
279       extractor=1))])
280 if test "$extractor" != 1
281 then
282  AC_MSG_ERROR([GNUnet requires libextractor])
283 fi
284 # restore LIBS
285 LIBS=$SAVE_LIBS
286
287
288 # Checks for standard header files.
289 AC_HEADER_DIRENT
290 AC_HEADER_STDC
291
292 # Check for headers that are ALWAYS required
293 AC_CHECK_HEADERS([fcntl.h math.h errno.h ctype.h limits.h stdio.h stdlib.h string.h unistd.h stdarg.h signal.h locale.h sys/stat.h sys/types.h],,AC_MSG_ERROR([Compiling GNUnet requires standard UNIX headers files]))
294
295 # Checks for headers that are only required on some systems or opional (and where we do NOT abort if they are not there)
296 AC_CHECK_HEADERS([langinfo.h sys/param.h sys/mount.h sys/statvfs.h sys/select.h sockLib.h sys/mman.h sys/msg.h sys/vfs.h arpa/inet.h fcntl.h libintl.h netdb.h netinet/in.h netinet/in_systm.h sys/ioctl.h sys/socket.h sys/time.h unistd.h kstat.h sys/sysinfo.h kvm.h sys/file.h sys/resource.h ifaddrs.h mach/mach.h stddef.h sys/timeb.h terminos.h argz.h])
297
298 SAVE_LDFLAGS=$LDFLAGS
299 SAVE_CPPFLAGS=$CPPFLAGS
300
301 # test for sqlite
302 sqlite=false
303 AC_MSG_CHECKING(for SQLite)
304 AC_ARG_WITH(sqlite,
305   [  --with-sqlite=PFX       base of SQLite installation],
306   [AC_MSG_RESULT("$with_sqlite")
307    case $with_sqlite in
308    no)
309      ;;
310    yes)
311     AC_CHECK_HEADERS(sqlite3.h,
312      sqlite=true)
313      ;;
314    *)
315     LDFLAGS="-L$with_sqlite/lib $LDFLAGS"
316     CPPFLAGS="-I$with_sqlite/include $CPPFLAGS"
317     AC_CHECK_HEADERS(sqlite3.h,
318      EXT_LIB_PATH="-L$with_sqlite/lib $EXT_LIB_PATH"
319      SQLITE_LDFLAGS="-L$with_sqlite/lib"
320      SQLITE_CPPFLAGS="-I$with_sqlite/include"
321      sqlite=true)
322     LDFLAGS=$SAVE_LDFLAGS
323     CPPFLAGS=$SAVE_CPPFLAGS
324     ;;
325    esac
326   ],
327   [AC_MSG_RESULT([--with-sqlite not specified])
328     AC_CHECK_HEADERS(sqlite3.h, sqlite=true)])
329 AM_CONDITIONAL(HAVE_SQLITE, test x$sqlite = xtrue)
330 AC_SUBST(SQLITE_CPPFLAGS)
331 AC_SUBST(SQLITE_LDFLAGS)
332
333 # test for postgres
334 postgres=false
335 AC_MSG_CHECKING(for postgres)
336 AC_ARG_WITH(postgres,
337   [  --with-postgres=PFX       base of postgres installation],
338   [AC_MSG_RESULT("$with_postgres")
339    case $with_postgres in
340    no)
341      ;;
342    yes)
343     AC_CHECK_HEADERS(postgresql/libpq-fe.h,
344      postgres=true)
345      ;;
346    *)
347     LDFLAGS="-L$with_postgres/lib $LDFLAGS"
348     CPPFLAGS="-I$with_postgres/include $CPPFLAGS"
349     AC_CHECK_HEADERS(postgresql/libpq-fe.h,
350      EXT_LIB_PATH="-L$with_postgres/lib $EXT_LIB_PATH"
351      POSTGRES_LDFLAGS="-L$with_postgres/lib"
352      POSTGRES_CPPFLAGS="-I$with_postgres/include"
353      postgres=true)
354     LDFLAGS=$SAVE_LDFLAGS
355     CPPFLAGS=$SAVE_CPPFLAGS
356     ;;
357    esac
358   ],
359   [AC_MSG_RESULT([--with-postgres not specified])
360     AC_CHECK_HEADERS(postgresql/libpq-fe.h, postgres=true)])
361 AM_CONDITIONAL(HAVE_POSTGRES, test x$postgres = xtrue)
362 AC_SUBST(POSTGRES_CPPFLAGS)
363 AC_SUBST(POSTGRES_LDFLAGS)
364
365 # test for pcap
366 pcap=0
367 AC_MSG_CHECKING(for libpcap)
368 AC_ARG_WITH(pcap,
369   [  --with-pcap=PFX       base of pcap installation],
370   [AC_MSG_RESULT("$with_pcap")
371    case $with_pcap in
372    no)
373      ;;
374    yes)
375     AC_CHECK_HEADERS(pcap.h,
376      pcap=1)
377      ;;
378    *)
379     LDFLAGS="-L$with_pcap/lib $LDFLAGS"
380     CPPFLAGS="-I$with_pcap/include $CPPFLAGS"
381     AC_CHECK_HEADERS(pcap.h,
382      EXT_LIB_PATH="-L$with_pcap/lib $EXT_LIB_PATH"
383      PCAP_LDFLAGS="-L$with_pcap/lib"
384      PCAP_CPPFLAGS="-I$with_pcap/include"
385      pcap=1)
386     LDFLAGS=$SAVE_LDFLAGS
387     CPPFLAGS=$SAVE_CPPFLAGS
388     ;;
389    esac
390   ],
391   [AC_MSG_RESULT([--with-pcap not specified])
392     AC_CHECK_HEADERS(pcap.h, pcap=1)])
393 AM_CONDITIONAL(HAVE_PCAP, test x$pcap = x1)
394 AC_SUBST(PCAP_CPPFLAGS)
395 AC_SUBST(PCAP_LDFLAGS)
396
397
398 # test for libz (maybe required for linking mysql)
399 zlib=1
400 AC_CHECK_LIB(z, compress,,zlib=0)
401 AM_CONDITIONAL(HAVE_ZLIB, test x$zlib = x1)
402 if test "$zlib" != 1
403 then
404  AC_MSG_ERROR([GNUnet requires zlib])
405 fi
406
407 # mysql & windows
408 AC_CHECK_TYPES([sigset_t, off_t], [], [], [#include <sys/types.h>])
409 AC_CHECK_TYPES([size_t], [], [], [#include <stdio.h>])
410
411 if test "$build_target" = "mingw"
412 then
413   CYGWIN_MYSQL_MAGIC="#include <mysql/my_global.h>"
414 fi
415
416 # test for mysql
417 mysql=false
418 mysqlfail=false
419 SAVE_LDFLAGS=$LDFLAGS
420 SAVE_CPPFLAGS=$CPPFLAGS
421 AC_MSG_CHECKING(for mysql)
422 AC_ARG_WITH(mysql,
423   [  --with-mysql=PFX        base of MySQL installation],
424   [AC_MSG_RESULT("$with_mysql")
425    if test "$with_mysql" != "no"
426    then
427     if test "$with_mysql" != "yes"
428     then
429       LDFLAGS="-L$with_mysql/lib -L$with_mysql/lib/mysql $LDFLAGS $ZLIBS"
430       CPPFLAGS="-I$with_mysql/include $CPPFLAGS"
431     fi
432     AC_CHECK_HEADERS(mysql/mysql.h,
433      AC_CHECK_LIB(mysqlclient, mysql_init,
434       MYSQL_LDFLAGS="-L$with_mysql/lib -L$with_mysql/lib/mysql"
435       MYSQL_CPPFLAGS="-I$with_mysql/include"
436
437       mysql=true), [], [$CYGWIN_MYSQL_MAGIC])
438    fi
439   ],
440   [AC_MSG_RESULT([--with-mysql not specified])
441    LDFLAGS="-L/usr/lib/mysql $LDFLAGS $ZLIBS"
442    AC_CHECK_LIB(mysqlclient, mysql_init,
443     [AC_CHECK_HEADERS(mysql/mysql.h,
444       MYSQL_LDFLAGS="-L/usr/lib/mysql"
445       mysql=true
446
447      , [], [$CYGWIN_MYSQL_MAGIC])])
448   ])
449
450 AC_SUBST(MYSQL_LDFLAGS)
451 AC_SUBST(MYSQL_CPPFLAGS)
452
453 # additional version check for mysql
454 AC_ARG_ENABLE(mysql-version-check, [  --disable-mysql-version-check  do not check MySQL version],, enable_mysql_version_check=yes)
455 if test "$mysql" = "true" -a "x$enable_mysql_version_check" = "xyes"
456 then
457   AC_MSG_CHECKING(mysql version)
458   AC_RUN_IFELSE([AC_LANG_PROGRAM(
459     [[$CYGWIN_MYSQL_MAGIC
460       #include <mysql/mysql.h>]],
461     [[if (MYSQL_VERSION_ID < 40100)
462         return(-1);
463       else
464         return(0);
465     ]])
466     ],mysql=true,mysql=false)
467   if test "$mysql" = "false"
468   then
469     mysqlfail=true
470     AC_MSG_RESULT([fail, >= 4.1 required])
471   else
472     AC_MSG_RESULT(ok)
473   fi
474 fi
475 AM_CONDITIONAL(HAVE_MYSQL, test x$mysql = xtrue)
476 AM_CONDITIONAL(HAVE_MYSQLE, test "0" = "1")
477 # restore LIBS
478 LIBS=$SAVE_LIBS
479 LDFLAGS=$SAVE_LDFLAGS
480 CPPFLAGS=$SAVE_CPPFLAGS
481
482 if test "$sqlite" = 0 -a "$mysql" = 0
483 then
484  AC_MSG_ERROR([GNUnet requires SQLite or MySQL])
485 fi
486
487 # libmicrohttpd
488 lmhd=0
489 AC_MSG_CHECKING([for libmicrohttpd])
490 AC_ARG_WITH(microhttpd,
491    [  --with-microhttpd=PFX   base of libmicrohttpd installation],
492    [AC_MSG_RESULT([$with_microhttpd])
493     case $with_microhttpd in
494       no)
495         ;;
496       yes)
497         AC_CHECK_HEADERS([microhttpd.h],
498           AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
499             AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
500               lmhd=1),
501             [],[#include "src/include/platform.h"
502                 #include <microhttpd.h>]),,
503             [#include "src/include/platform.h"])
504         ;;
505       *)
506         LDFLAGS="-L$with_microhttpd/lib $LDFLAGS"
507         CPPFLAGS="-I$with_microhttpd/include $CPPFLAGS"
508         AC_CHECK_HEADERS(microhttpd.h,
509           AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
510             AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
511               EXT_LIB_PATH="-L$with_microhttpd/lib $EXT_LIB_PATH"
512               lmhd=1),
513             [],[#include "src/include/platform.h"
514                 #include <microhttpd.h>]),,
515             [#include "src/include/platform.h"])
516         ;;
517     esac
518    ],
519    [AC_MSG_RESULT([--with-microhttpd not specified])
520     AC_CHECK_HEADERS([microhttpd.h],
521       AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
522         AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
523           lmhd=1),
524         [],[#include "src/include/platform.h"
525             #include <microhttpd.h>]),,
526        [#include "src/include/platform.h"])])
527 AM_CONDITIONAL(HAVE_MHD, test x$lmhd = x1)
528 AC_DEFINE_UNQUOTED([HAVE_MHD], $lmhd, [We have libmicrohttpd])
529
530
531 # openssl
532 openssl=0
533 AC_MSG_CHECKING([for openssl])
534 AC_ARG_WITH(openssl,
535    [  --with-openssl=PFX   base of openssl installation],
536    [AC_MSG_RESULT([$with_openssl])
537     case $with_openssl in
538       no)
539         ;;
540       yes)
541         AC_CHECK_HEADERS([openssl/ssl.h],
542             AC_CHECK_LIB([ssl], [SSL_new],
543              openssl=1))
544         ;;
545       *)
546         LDFLAGS="-L$with_openssl/lib $LDFLAGS"
547         CPPFLAGS="-I$with_openssl/include $CPPFLAGS"
548         AC_CHECK_HEADERS([openssl/ssl.h],
549             AC_CHECK_LIB([ssl], [SSL_new],
550               EXT_LIB_PATH="-L$with_openssl/lib $EXT_LIB_PATH"
551               openssl=1))
552         ;;
553     esac
554    ],
555    [AC_MSG_RESULT([--with-openssl not specified])
556     AC_CHECK_HEADERS([openssl/ssl.h],
557         AC_CHECK_LIB([ssl], [SSL_new],
558           openssl=1))])
559 AM_CONDITIONAL(HAVE_OPENSSL, test x$openssl = x1)
560 AC_DEFINE_UNQUOTED([HAVE_OPENSSL], $openssl, [We have openssl])
561
562
563
564
565
566
567 # restore LIBS
568 LIBS=$SAVE_LIBS
569
570 # check for python & pexpect (used for some testcases only)
571 AM_PATH_PYTHON([2.5],, [:])
572 AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
573
574 if test "$PYTHON" != :
575 then
576   AC_MSG_CHECKING([for pexpect])
577   $PYTHON -c "import pexpect" > /dev/null 2> /dev/null
578   PYEX=$?
579   AM_CONDITIONAL(HAVE_PYTHON_PEXPECT, test $PYEX -eq 0)
580   if test $PYEX -eq 0
581   then
582     AC_MSG_RESULT([yes])
583   else
584     AC_MSG_RESULT([not found])
585   fi
586 else
587   AM_CONDITIONAL(HAVE_PYTHON_PEXPECT, 0)
588 fi
589
590 # libesmtp
591 esmtp=0
592 AC_MSG_CHECKING([for libesmtp])
593 AC_ARG_WITH(esmtp,
594    [  --with-esmtp=PFX        base of libesmtp installation],
595    [AC_MSG_RESULT([$with_esmtp])
596     case $with_esmtp in
597       no)
598         ;;
599       yes)
600         AC_CHECK_HEADERS(libesmtp.h,
601           AC_CHECK_LIB([esmtp], [smtp_start_session],
602             esmtp=1))
603         ;;
604       *)
605         LDFLAGS="-L$with_esmtp/lib $LDFLAGS"
606         CPPFLAGS="-I$with_esmtp/include $CPPFLAGS"
607         AC_CHECK_HEADERS(libesmtp.h,
608           AC_CHECK_LIB([esmtp], [smtp_start_session],
609             EXT_LIB_PATH="-L$with_esmtp/lib $EXT_LIB_PATH"
610               esmtp=1))
611         ;;
612     esac
613    ],
614    [AC_MSG_RESULT([--with-esmtp not specified])
615     AC_CHECK_HEADERS(libesmtp.h,
616       AC_CHECK_LIB([esmtp], [smtp_start_session],
617           esmtp=1))])
618 AM_CONDITIONAL(HAVE_ESMTP, test x$esmtp = x1)
619 AC_DEFINE_UNQUOTED([HAVE_ESMTP], $esmtp, [We have libesmtp])
620 # restore LIBS
621 LIBS=$SAVE_LIBS
622
623 # check for gettext
624 AM_GNU_GETTEXT([external])
625 AM_GNU_GETTEXT_VERSION([0.16.1])
626
627 # check for iconv
628 AM_ICONV
629
630 # Checks for standard typedefs, structures, and compiler characteristics.
631 AC_TYPE_PID_T
632 AC_TYPE_SIZE_T
633 AC_TYPE_MODE_T
634 AC_HEADER_TIME
635 AC_HEADER_STAT
636 AC_HEADER_STDBOOL
637 AC_STRUCT_TM
638
639 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
640    [ AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1, [Do we have sockaddr_in.sin_len?])
641    ],
642    [],
643    [
644       #include <sys/types.h>
645       #include <sys/socket.h>
646       #include <netinet/in.h>
647    ])
648
649
650
651 # Checks for library functions.
652 AC_FUNC_CLOSEDIR_VOID
653 AC_FUNC_FORK
654 AC_FUNC_VFORK
655 AC_PROG_GCC_TRADITIONAL
656 AC_FUNC_MEMCMP
657 AC_FUNC_SELECT_ARGTYPES
658 AC_FUNC_CHOWN
659
660 AC_TYPE_SIGNAL
661 AC_FUNC_STAT
662 AC_FUNC_STRFTIME
663 AC_FUNC_VPRINTF
664 AC_HEADER_SYS_WAIT
665 AC_TYPE_OFF_T
666 AC_TYPE_UID_T
667 AC_CHECK_FUNCS([floor gethostname memmove rmdir strncasecmp strrchr strtol atoll dup2 fdatasync ftruncate gettimeofday memset mkdir mkfifo select socket strcasecmp strchr strdup strerror strstr clock_gettime getrusage rand uname setlocale getcwd mktime gmtime_r gmtime strlcpy strlcat ftruncate stat64 sbrk mmap mremap setrlimit sysconf gethostbyaddr initgroups getifaddrs freeifaddrs getnameinfo getaddrinfo inet_ntoa localtime_r nl_langinfo putenv realpath strndup gethostbyname2 gethostbyname])
668
669 # restore LIBS
670 LIBS=$SAVE_LIBS
671
672 gn_user_home_dir="~/.gnunet"
673 AC_ARG_WITH(user-home-dir,
674         AC_HELP_STRING(
675                 [--with-user-home-dir=DIR],
676                 [default user home directory (~/.gnunet)]),
677         [gn_user_home_dir=$withval])
678 AC_SUBST(GN_USER_HOME_DIR, $gn_user_home_dir)
679 gn_daemon_home_dir="/var/lib/gnunet"
680 AC_ARG_WITH(daemon-home-dir,
681         AC_HELP_STRING(
682                 [--with-daemon-home-dir=DIR],
683                 [default daemon home directory (/var/lib/gnunet)]),
684         [gn_daemon_home_dir=$withval])
685 AC_SUBST(GN_DAEMON_HOME_DIR, $gn_daemon_home_dir)
686 gn_daemon_config_dir="/etc"
687 AC_ARG_WITH(daemon-config-dir,
688         AC_HELP_STRING(
689                 [--with-daemon-config-dir=DIR],
690                 [default daemon config directory (/etc)]),
691         [gn_daemon_config_dir=$withval])
692 AC_SUBST(GN_DAEMON_CONFIG_DIR, $gn_daemon_config_dir)
693
694 GN_INTLINCL=""
695 GN_LIBINTL="$LTLIBINTL"
696 AC_ARG_ENABLE(framework, [  --enable-framework      enable Mac OS X framework build helpers],enable_framework_build=$enableval)
697 AM_CONDITIONAL(WANT_FRAMEWORK, test x$enable_framework_build = xyes)
698 if test x$enable_framework_build = xyes
699 then
700   AC_DEFINE([FRAMEWORK_BUILD], 1, [Build a Mac OS X Framework])
701   GN_INTLINCL='-I$(top_srcdir)/src/intlemu'
702   GN_LIBINTL='$(top_builddir)/src/intlemu/libintlemu.la -framework CoreFoundation'
703   AC_LIB_APPENDTOVAR([CPPFLAGS], [$GN_INTLINCL]) 
704 fi
705
706 GN_LIB_LDFLAGS="-export-dynamic -no-undefined"
707 GN_PLUGIN_LDFLAGS="-export-dynamic -avoid-version -module -no-undefined"
708
709 AC_SUBST(GN_LIB_LDFLAGS)
710 AC_SUBST(GN_PLUGIN_LDFLAGS)
711 AC_SUBST(GN_INTLINCL)
712 AC_SUBST(GN_LIBINTL)
713
714 AC_SUBST(CPPFLAGS)
715 AC_SUBST(LIBS)
716 AC_SUBST(LDFLAGS)
717 AC_SUBST(EXT_LIB_PATH)
718 AC_SUBST(EXT_LIBS)
719
720 AC_SUBST(LIBPREFIX)
721 AC_SUBST(DLLDIR)
722 AC_SUBST(EXT_LIB_PATH)
723
724
725 # should 'make check' run tests?
726 AC_MSG_CHECKING(whether to run tests)
727 AC_ARG_ENABLE(testruns,
728    [AS_HELP_STRING([--enable-testruns=yes/no],
729                [disable running tests on make check (default is YES)])],
730    [enable_tests_run=$enableval],
731    [enable_tests_run="yes"])
732 AC_MSG_RESULT($enable_test_run)
733 AM_CONDITIONAL([DISABLE_TEST_RUN], [test "x$enable_tests_run" = "xno"])
734
735 # should experimental code be compiled (code that may not yet compile)?
736 disable_experimental=yes
737 AC_MSG_CHECKING(whether to compile experimental code)
738 AC_ARG_ENABLE(experimental,
739    [AS_HELP_STRING([--enable-experimental],
740                [enable compiling experimental code])],
741    [enable_experimental=$enableval],
742    [enable_experimental="no"])
743 AC_MSG_RESULT($enable_experimental)
744 AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
745
746 # should malicious code be compiled (code used for testing with malicious peers)
747 enable_malicious=0
748 AC_MSG_CHECKING(whether to compile malicious code)
749 AC_ARG_ENABLE(malicious,
750    [AS_HELP_STRING([--enable-malicious],
751                [enable compiling malicious code (only for developers for testing)])],
752    [enable_malicious=1],
753    [enable_malicious=0])
754 AC_MSG_RESULT($enable_malicious)
755 AM_CONDITIONAL([HAVE_MALICIOUS], [test "x$enable_malicious" = "x1"])
756 AC_DEFINE_UNQUOTED([HAVE_MALICIOUS], $enable_malicious, [Compile malicious code])
757
758 # should code be enabled that works around missing OS functionality on Windows?
759 # used for test cases
760 AC_ARG_ENABLE(windows_workarounds, [AS_HELP_STRING([--enable-windows_workarounds],
761                [enable workarounds used on Windows (only useful for test cases)])])
762 if test $build_target = "mingw"
763 then
764         workarounds=1
765 else
766         if test x$enable_windows_workarounds = "xyes"
767         then
768                 workarounds=1
769         else
770                 workarounds=0
771         fi
772 fi
773 AC_DEFINE_UNQUOTED([ENABLE_WINDOWS_WORKAROUNDS], $workarounds, [enable workarounds used on Windows (only useful for test cases)])
774
775 # gcov compilation
776 use_gcov=no
777 AC_ARG_ENABLE([coverage], AS_HELP_STRING([--enable-coverage],
778                                         [Compile the library with code coverage support (default is NO)]),
779                                         [use_gcov=yes], [use_gcov=no])
780 AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
781
782 AC_CONFIG_FILES([ 
783 Makefile
784 contrib/Makefile
785 m4/Makefile
786 po/Makefile.in 
787 src/Makefile
788 src/arm/Makefile
789 src/block/Makefile
790 src/core/Makefile
791 src/datacache/Makefile
792 src/datastore/Makefile
793 src/dht/Makefile
794 src/dv/Makefile
795 src/fragmentation/Makefile
796 src/fs/Makefile
797 src/hello/Makefile
798 src/include/Makefile
799 src/include/gnunet_directories.h
800 src/hostlist/Makefile
801 src/mesh/Makefile
802 src/monkey/Makefile
803 src/nat/Makefile
804 src/peerinfo/Makefile
805 src/peerinfo-tool/Makefile
806 src/statistics/Makefile
807 src/template/Makefile
808 src/testing/Makefile
809 src/topology/Makefile
810 src/transport/Makefile
811 src/util/Makefile
812 src/vpn/Makefile
813 src/chat/Makefile
814 pkgconfig/Makefile
815 pkgconfig/gnunetarm.pc
816 pkgconfig/gnunetblock.pc
817 pkgconfig/gnunetcore.pc
818 pkgconfig/gnunetdatacache.pc
819 pkgconfig/gnunetdatastore.pc
820 pkgconfig/gnunetdht.pc
821 pkgconfig/gnunetdhtlog.pc
822 pkgconfig/gnunetdv.pc
823 pkgconfig/gnunetfragmentation.pc
824 pkgconfig/gnunetfs.pc
825 pkgconfig/gnunethello.pc
826 pkgconfig/gnunetpeerinfo.pc
827 pkgconfig/gnunetstatistics.pc
828 pkgconfig/gnunettesting.pc
829 pkgconfig/gnunettransport.pc
830 pkgconfig/gnunetutil.pc
831 ])
832 AC_OUTPUT
833
834 # Finally: summary!
835
836 # warn user if mysql found but not used due to version
837 if test "$mysqlfail" = "true"
838 then
839   AC_MSG_NOTICE([NOTICE: MySQL found, but too old. MySQL support will not be compiled.])
840 fi
841
842 # sqlite
843 if test "x$sqlite" = "x0"
844 then
845   AC_MSG_NOTICE([NOTICE: sqlite not found.  sqLite support will not be compiled.])
846 fi
847
848 if test "x$lmhd" != "x1"
849 then
850  AC_MSG_NOTICE([NOTICE: libmicrohttpd not found, http transport will not be installed.])
851 fi
852
853 if test "x$esmtp" != "x1"
854 then
855  AC_MSG_NOTICE([NOTICE: libesmtp not found, monkey will not be installed.])
856 fi
857
858 if test "x$pcap" != "x1"
859 then
860  AC_MSG_NOTICE([NOTICE: libpcap not found, WiFi support will not be installed.])
861 fi
862
863 if test "x$openssl" != "x1"
864 then
865  AC_MSG_NOTICE([NOTICE: OpenSSL not found, monkey will not be installed.])
866 fi
867
868 AC_MSG_NOTICE([NOTICE: Database support is set to MySQL: $mysql, SQLite: $sqlite, Postgres: $postgres])
869
870 if test "$enable_framework_build" = "yes"
871 then
872   AC_MSG_NOTICE([NOTICE: Mac OS X framework build enabled.])
873 fi
874
875 AC_MSG_NOTICE([********************************************
876 You can compile GNUnet with
877         make
878 now. After that, run (if necessary as 'root')
879         make install
880 to install everything. You may want to create a new user account
881 to run the GNUnet service:
882         adduser gnunet
883 You also need to create an configuration file that should
884 specify the path where GNUnet should store data.  For example,
885 you could store in "/etc/gnunet.conf" the following lines:
886
887 [[PATHS]]
888 SERVICEHOME = /var/lib/gnunet
889 DEFAULTCONFIG = /etc/gnunet.conf
890
891 Now, in order to start your peer, run as the 'gnunet' user
892         gnunet-arm -s
893
894 Each GNUnet user should also create an (at least initially) empty
895 configuration file:
896         mkdir $HOME/.gnunet/
897         touch $HOME/.gnunet/gnunet.conf
898         
899 Optionally, download and compile gnunet-gtk to get a GUI.
900 ********************************************])