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