fixes
[oweals/gnunet.git] / configure.ac
1 # This file is part of GNUnet.
2 # (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.0pre0],[bug-gnunet@gnu.org])
25 AM_INIT_AUTOMAKE([gnunet], [0.9.0pre0])
26 AC_CONFIG_HEADERS([gnunet_config.h])
27
28 AH_TOP([#define _GNU_SOURCE  1])
29
30 # Checks for programs.
31 AC_CANONICAL_HOST
32 AC_PROG_AWK
33 AC_PROG_CC
34 AC_PROG_CPP
35 AC_PROG_CXX
36 AC_PROG_OBJC
37 AC_PROG_INSTALL
38 AC_PROG_LN_S
39 AC_PROG_MAKE_SET
40 LT_CONFIG_LTDL_DIR([libltdl])
41 AC_CANONICAL_HOST
42 LT_INIT([disable-static dlopen win32-dll])
43 LTDL_INIT
44 AC_SUBST(LTDLINCL)
45 AC_SUBST(LIBLTDL)
46 AC_SUBST(MKDIR_P)
47
48 # large file support
49 AC_SYS_LARGEFILE
50 AC_FUNC_FSEEKO
51
52
53 if test "$enable_shared" = "no"
54 then
55  AC_MSG_ERROR([GNUnet only works with shared libraries. Sorry.])
56 fi
57
58 CFLAGS="-Wall $CFLAGS"
59 # use '-fno-strict-aliasing', but only if the compiler can take it
60 if gcc -fno-strict-aliasing -S -o /dev/null -xc /dev/null >/dev/null 2>&1;
61 then
62  CFLAGS="-fno-strict-aliasing $CFLAGS"
63 fi
64
65 # Use Linux interface name unless the OS has a different preference
66 DEFAULT_INTERFACE="\"eth0\""
67
68 # Check system type
69 case "$host_os" in
70 *darwin* | *rhapsody* | *macosx*)
71      AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system])
72      CFLAGS="-no-cpp-precomp -fno-common $CFLAGS"
73      AC_MSG_WARN([The VPN application cannot be compiled on your OS])
74      build_target="macosx"
75      DEFAULT_INTERFACE="\"en0\""
76      LIBPREFIX=
77      DLLDIR=lib
78      ;;
79 linux*)
80      AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
81      build_target="linux"
82      LIBPREFIX=
83      DLLDIR=lib
84      AC_PATH_XTRA
85      ;;
86 freebsd*)
87      AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
88      AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
89      CFLAGS="-D_THREAD_SAFE $CFLAGS"
90      build_target="freebsd"
91      LIBPREFIX=
92      DLLDIR=lib
93      ;;
94 openbsd*)
95      AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
96      AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
97      LIBS=`echo $LIBS | sed -e "s/-ldl//"`
98      build_target="openbsd"
99      LIBPREFIX=
100      DLLDIR=lib
101      ;;
102 netbsd*)
103      AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
104      AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
105      LIBPREFIX=
106      DLLDIR=lib
107      ;;
108 *solaris*)
109      AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
110      AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno doesnt work])
111      AC_CHECK_LIB(resolv, res_init)
112      AC_CHECK_LIB(rt, nanosleep)
113      build_target="solaris"
114      LIBPREFIX=
115      DLLDIR=lib
116      ;;
117 *arm-linux*)
118      AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
119      CFLAGS="-D_REENTRANT -fPIC -pipe $CFLAGS"
120      build_target="linux"
121      LIBPREFIX=
122      DLLDIR=lib
123      ;;
124 *cygwin*)
125      AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
126      AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
127      AC_CHECK_LIB(intl, gettext)
128      LDFLAGS="$LDFLAGS -no-undefined"
129      CFLAGS="-mms-bitfields $CFLAGS"
130      build_target="cygwin"
131      LIBPREFIX=lib
132      DLLDIR=bin
133      AC_PROG_CXX
134      ;;
135 *mingw*)
136      AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
137      AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
138      AC_DEFINE_UNQUOTED(_WIN32,1,[This is a Windows system])
139      AC_CHECK_LIB(intl, gettext)
140      LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols"
141      LIBS="$LIBS -lws2_32 -lplibc"
142      CFLAGS="-mms-bitfields $CFLAGS"
143      build_target="mingw"
144      AC_PROG_CXX
145      LIBPREFIX=lib
146      DLLDIR=bin
147      ;;
148 *)
149      AC_MSG_RESULT(Unrecognised OS $host_os)
150      AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
151 ;;
152 esac
153 AC_DEFINE_UNQUOTED([GNUNET_DEFAULT_INTERFACE], $DEFAULT_INTERFACE, [This should be the default choice for the name of the first network interface])
154 AC_SUBST(DEFAULT_INTERFACE)
155
156 AC_MSG_CHECKING([for build target])
157 AM_CONDITIONAL(MACOSX,  test "$build_target" = "macosx")
158 AM_CONDITIONAL(CYGWIN,  test "$build_target" = "cygwin")
159 AM_CONDITIONAL(MINGW,   test "$build_target" = "mingw")
160 AM_CONDITIONAL(SOLARIS, test "$build_target" = "solaris")
161 AM_CONDITIONAL(XFREEBSD, test "$build_target" = "freebsd")
162 AM_CONDITIONAL(OPENBSD, test "$build_target" = "openbsd")
163 AM_CONDITIONAL(LINUX, test "$build_target" = "linux")
164 AC_MSG_RESULT([$build_target])
165 AC_SUBST(build_target)
166 AM_CONDITIONAL([am__fastdepOBJC], false)
167 AC_UNALIGNED_64_ACCESS
168
169 # some other checks for standard libs
170 AC_SEARCH_LIBS([gethostbyname], [nsl ws2_32])
171 AC_CHECK_LIB(socket, socket)
172 AC_CHECK_LIB(m, log)
173 AC_CHECK_LIB(c, getloadavg, AC_DEFINE(HAVE_GETLOADAVG,1,[getloadavg supported]))
174
175 # 'save' libs; only those libs found so far will be
176 # linked against _everywhere_.  For the others, we
177 # will be more selective!
178 SAVE_LIBS=$LIBS
179
180 # libgcrypt
181 gcrypt=0
182 AM_PATH_LIBGCRYPT(1.2.0, gcrypt=1)
183
184 if test $gcrypt = 0
185 then
186   AC_MSG_ERROR([GNUnet needs libgcrypt])
187 fi
188
189
190 # libcurl
191 LIBCURL_CHECK_CONFIG(,7.15.4,,AC_MSG_ERROR([GNUnet requires libcurl >= 7.15.4]))
192 # restore LIBS
193 LIBS=$SAVE_LIBS
194
195 # restore LIBS
196 LIBS=$SAVE_LIBS
197
198 # test for kvm and kstat (for CPU stats under BSD/Solaris)
199 AC_CHECK_LIB([kvm],[kvm_open])
200 AC_CHECK_LIB([kstat],[kstat_open])
201
202 # test for libextractor
203 extractor=0
204 AC_MSG_CHECKING(for libextractor)
205 AC_ARG_WITH(extractor,
206    [  --with-extractor=PFX    base of libextractor installation],
207    [AC_MSG_RESULT([$with_extractor])
208     case $with_extractor in
209       no)
210         ;;
211       yes)
212         AC_CHECK_HEADERS(extractor.h,
213           AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
214             extractor=1))
215         ;;
216       *)
217         LDFLAGS="-L$with_extractor/lib $LDFLAGS"
218         CPPFLAGS="-I$with_extractor/include $CPPFLAGS"
219         AC_CHECK_HEADERS(extractor.h,
220           AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
221             EXT_LIB_PATH="-L$with_extractor/lib $EXT_LIB_PATH"
222             extractor=1))
223         ;;
224     esac
225    ],
226    [AC_MSG_RESULT([--with-extractor not specified])
227     AC_CHECK_HEADERS(extractor.h,
228      AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
229       extractor=1))])
230 if test "$extractor" != 1
231 then
232  AC_MSG_ERROR([GNUnet requires libextractor])
233 fi
234 # restore LIBS
235 LIBS=$SAVE_LIBS
236
237
238 # Checks for standard header files.
239 AC_HEADER_DIRENT
240 AC_HEADER_STDC
241
242 # Check for headers that are ALWAYS required
243 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]))
244
245 # Checks for headers that are only required on some systems or opional (and where we do NOT abort if they are not there)
246 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 sys/ioctl.h sys/socket.h sys/time.h unistd.h kstat.h sys/sysinfo.h kvm.h sys/file.h sys/resource.h iconv.h ifaddrs.h mach/mach.h stddef.h sys/timeb.h terminos.h])
247
248 # Check for GMP header (and abort if not present)
249 AC_CHECK_HEADERS([gmp.h],,AC_MSG_ERROR([Compiling GNUnet requires gmp.h (from the GNU MP library, libgmp)]))
250
251 # test for libgmp
252 gmp=0
253 AC_MSG_CHECKING(for libgmp)
254 AC_ARG_WITH(gmp,
255    [  --with-gmp=PFX          base of libgmp installation],
256    [AC_MSG_RESULT([$with_gmp])
257     case $with_gmp in
258       no)
259         ;;
260       yes)
261         AC_CHECK_HEADERS(gmp.h,
262           AC_CHECK_LIB([gmp], [__gmpz_add],
263             gmp=1))
264         ;;
265       *)
266         LDFLAGS="-L$with_gmp/lib $LDFLAGS"
267         CPPFLAGS="-I$with_gmp/include $CPPFLAGS"
268         AC_CHECK_HEADERS(gmp.h,
269           AC_CHECK_LIB([gmp], [__gmpz_add],
270             EXT_LIB_PATH="-L$with_gmp/lib $EXT_LIB_PATH"
271             gmp=1))
272         ;;
273     esac
274    ],
275    [AC_MSG_RESULT([--with-gmp not specified])
276     AC_CHECK_HEADERS(gmp.h,
277      AC_CHECK_LIB([gmp], [__gmpz_add],
278       gmp=1))])
279 if test "$gmp" != 1
280 then
281  AC_MSG_ERROR([GNUnet requires libgmp])
282 fi
283
284 SAVE_LDFLAGS=$LDFLAGS
285 SAVE_CPPFLAGS=$CPPFLAGS
286
287 # test for sqlite
288 sqlite=false
289 AC_MSG_CHECKING(for SQLite)
290 AC_ARG_WITH(sqlite,
291   [  --with-sqlite=PFX       base of SQLite installation],
292   [AC_MSG_RESULT("$with_sqlite")
293    case $with_sqlite in
294    no)
295      ;;
296    yes)
297     AC_CHECK_HEADERS(sqlite3.h,
298      sqlite=true)
299      ;;
300    *)
301     LDFLAGS="-L$with_sqlite/lib $LDFLAGS"
302     CPPFLAGS="-I$with_sqlite/include $CPPFLAGS"
303     AC_CHECK_HEADERS(sqlite3.h,
304      EXT_LIB_PATH="-L$with_sqlite/lib $EXT_LIB_PATH"
305      SQLITE_LDFLAGS="-L$with_sqlite/lib"
306      SQLITE_CPPFLAGS="-I$with_sqlite/include"
307      sqlite=true)
308     LDFLAGS=$SAVE_LDFLAGS
309     CPPFLAGS=$SAVE_CPPFLAGS
310     ;;
311    esac
312   ],
313   [AC_MSG_RESULT([--with-sqlite not specified])
314     AC_CHECK_HEADERS(sqlite3.h, sqlite=true)])
315 AM_CONDITIONAL(HAVE_SQLITE, test x$sqlite = xtrue)
316 AC_SUBST(SQLITE_CPPFLAGS)
317 AC_SUBST(SQLITE_LDFLAGS)
318
319 # test for postgres
320 postgres=false
321 AC_MSG_CHECKING(for postgres)
322 AC_ARG_WITH(postgres,
323   [  --with-postgres=PFX       base of postgres installation],
324   [AC_MSG_RESULT("$with_postgres")
325    case $with_postgres in
326    no)
327      ;;
328    yes)
329     AC_CHECK_HEADERS(postgresql/libpq-fe.h,
330      postgres=true)
331      ;;
332    *)
333     LDFLAGS="-L$with_postgres/lib $LDFLAGS"
334     CPPFLAGS="-I$with_postgres/include $CPPFLAGS"
335     AC_CHECK_HEADERS(postgresql/libpq-fe.h,
336      EXT_LIB_PATH="-L$with_postgres/lib $EXT_LIB_PATH"
337      SQLITE_LDFLAGS="-L$with_postgres/lib"
338      SQLITE_CPPFLAGS="-I$with_postgres/include"
339      postgres=true)
340     LDFLAGS=$SAVE_LDFLAGS
341     CPPFLAGS=$SAVE_CPPFLAGS
342     ;;
343    esac
344   ],
345   [AC_MSG_RESULT([--with-postgres not specified])
346     AC_CHECK_HEADERS(postgresql/libpq-fe.h, postgres=true)])
347 AM_CONDITIONAL(HAVE_POSTGRES, test x$postgres = xtrue)
348 AC_SUBST(POSTGRES_CPPFLAGS)
349 AC_SUBST(POSTGRES_LDFLAGS)
350
351
352 # test for libz (maybe required for linking mysql)
353 zlib=1
354 AC_CHECK_LIB(z, compress,,zlib=0)
355 AM_CONDITIONAL(HAVE_ZLIB, test x$zlib = x1)
356 if test "$zlib" != 1
357 then
358  AC_MSG_ERROR([GNUnet requires zlib])
359 fi
360
361 # mysql & windows
362 AC_CHECK_TYPES([sigset_t, off_t], [], [], [#include <sys/types.h>])
363 AC_CHECK_TYPES([size_t], [], [], [#include <stdio.h>])
364
365 if test "$build_target" = "mingw"
366 then
367   CYGWIN_MYSQL_MAGIC="#include <mysql/my_global.h>"
368 fi
369
370 # test for mysql
371 mysql=false
372 mysqlfail=false
373 SAVE_LDFLAGS=$LDFLAGS
374 SAVE_CPPFLAGS=$CPPFLAGS
375 AC_MSG_CHECKING(for mysql)
376 AC_ARG_WITH(mysql,
377   [  --with-mysql=PFX        base of MySQL installation],
378   [AC_MSG_RESULT("$with_mysql")
379    if test "$with_mysql" != "no"
380    then
381     if test "$with_mysql" != "yes"
382     then
383       LDFLAGS="-L$with_mysql/lib -L$with_mysql/lib/mysql $LDFLAGS $ZLIBS"
384       CPPFLAGS="-I$with_mysql/include $CPPFLAGS"
385     fi
386     AC_CHECK_HEADERS(mysql/mysql.h,
387      AC_CHECK_LIB(mysqlclient, mysql_init,
388       MYSQL_LDFLAGS="-L$with_mysql/lib -L$with_mysql/lib/mysql"
389       MYSQL_CPPFLAGS="-I$with_mysql/include"
390
391       mysql=true), [], [$CYGWIN_MYSQL_MAGIC])
392    fi
393   ],
394   [AC_MSG_RESULT([--with-mysql not specified])
395    LDFLAGS="-L/usr/lib/mysql $LDFLAGS $ZLIBS"
396    AC_CHECK_LIB(mysqlclient, mysql_init,
397     [AC_CHECK_HEADERS(mysql/mysql.h,
398       MYSQL_LDFLAGS="-L/usr/lib/mysql"
399       mysql=true
400
401      , [], [$CYGWIN_MYSQL_MAGIC])])
402   ])
403
404 AC_SUBST(MYSQL_LDFLAGS)
405 AC_SUBST(MYSQL_CPPFLAGS)
406
407 # additional version check for mysql
408 AC_ARG_ENABLE(mysql-version-check, [  --disable-mysql-version-check  do not check MySQL version],, enable_mysql_version_check=yes)
409 if test "$mysql" = "true" -a "x$enable_mysql_version_check" = "xyes"
410 then
411   AC_MSG_CHECKING(mysql version)
412   AC_RUN_IFELSE([AC_LANG_PROGRAM(
413     [[$CYGWIN_MYSQL_MAGIC
414       #include <mysql/mysql.h>]],
415     [[if (MYSQL_VERSION_ID < 40100)
416         return(-1);
417       else
418         return(0);
419     ]])
420     ],mysql=true,mysql=false)
421   if test "$mysql" = "false"
422   then
423     mysqlfail=true
424     AC_MSG_RESULT([fail, >= 4.1 required])
425   else
426     AC_MSG_RESULT(ok)
427   fi
428 fi
429 AM_CONDITIONAL(HAVE_MYSQL, test x$mysql = xtrue)
430 AM_CONDITIONAL(HAVE_MYSQLE, test "0" = "1")
431 # restore LIBS
432 LIBS=$SAVE_LIBS
433 LDFLAGS=$SAVE_LDFLAGS
434 CPPFLAGS=$SAVE_CPPFLAGS
435
436 if test "$sqlite" = 0 -a "$mysql" = 0
437 then
438  AC_MSG_ERROR([GNUnet requires SQLite or MySQL])
439 fi
440
441 # GNUnet Setup
442 dialog=0
443 LIBS="-lm $LIBS"
444 AC_CHECK_LIB([ncursesw],[wmove])
445 AC_MSG_CHECKING([for dialog 1.0-20051207])
446 AC_ARG_WITH(dialog,
447    [  --with-dialog=PFX       base of dialog installation],
448    [AC_MSG_RESULT([$with_dialog])
449     case $with_dialog in
450       no)
451         ;;
452       yes)
453         AC_CHECK_HEADERS(dialog.h,
454           AC_CHECK_LIB([dialog], [dlg_menu],
455             dialog=1))
456         ;;
457       *)
458         LDFLAGS="-L$with_dialog/lib $LDFLAGS"
459         CPPFLAGS="-I$with_dialog/include $CPPFLAGS"
460         AC_CHECK_HEADERS(dialog.h,
461           AC_CHECK_LIB([dialog], [dlg_menu],
462             EXT_LIB_PATH="-L$with_dialog/lib $EXT_LIB_PATH"
463               dialog=1))
464         ;;
465     esac
466    ],
467    [AC_MSG_RESULT([--with-dialog not specified])
468     AC_CHECK_HEADERS(dialog.h,
469       AC_CHECK_LIB([dialog], [dlg_menu],
470           dialog=1))])
471
472 AM_CONDITIONAL(HAVE_DIALOG, test x$dialog = x1)
473 AC_DEFINE_UNQUOTED([HAVE_DIALOG], $dialog, [We have dialog])
474
475 cdialog=0
476 AC_ARG_WITH(cdialog,
477    [  --with-cdialog=PFX      base of cdialog installation],
478    [AC_MSG_RESULT([$with_cdialog])
479     case $with_cdialog in
480       no)
481         ;;
482       yes)
483         AC_CHECK_HEADERS(cdialog/dialog.h,
484           AC_CHECK_LIB([cdialog], [dlg_menu],
485             cdialog=1))
486         ;;
487       *)
488         LDFLAGS="-L$with_cdialog/lib $LDFLAGS"
489         CPPFLAGS="-I$with_cdialog/include $CPPFLAGS"
490         AC_CHECK_HEADERS(cdialog/dialog.h,
491           AC_CHECK_LIB([cdialog], [dlg_menu],
492             EXT_LIB_PATH="-L$with_cdialog/lib $EXT_LIB_PATH"
493               cdialog=1))
494         ;;
495     esac
496    ],
497    [AC_MSG_RESULT([--with-cdialog not specified])
498     AC_CHECK_HEADERS(cdialog/dialog.h,
499       AC_CHECK_LIB([cdialog], [dlg_menu],
500           cdialog=1))])
501
502 AM_CONDITIONAL(HAVE_CDIALOG, test x$cdialog = x1)
503 AC_DEFINE_UNQUOTED([HAVE_CDIALOG], $cdialog, [We have cdialog])
504 # restore LIBS
505 LIBS=$SAVE_LIBS
506
507 # libmicrohttpd
508 lmhd=0
509 AC_MSG_CHECKING([for libmicrohttpd])
510 AC_ARG_WITH(microhttpd,
511    [  --with-microhttpd=PFX   base of libmicrohttpd installation],
512    [AC_MSG_RESULT([$with_microhttpd])
513     case $with_microhttpd in
514       no)
515         ;;
516       yes)
517         AC_CHECK_HEADERS([microhttpd.h],
518           AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
519             AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
520               lmhd=1),
521             [],[#include "src/include/platform.h"
522                 #include <microhttpd.h>]),,
523             [#include "src/include/platform.h"])
524         ;;
525       *)
526         LDFLAGS="-L$with_microhttpd/lib $LDFLAGS"
527         CPPFLAGS="-I$with_microhttpd/include $CPPFLAGS"
528         AC_CHECK_HEADERS(microhttpd.h,
529           AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
530             AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
531               EXT_LIB_PATH="-L$with_microhttpd/lib $EXT_LIB_PATH"
532               lmhd=1),
533             [],[#include "src/include/platform.h"
534                 #include <microhttpd.h>]),,
535             [#include "src/include/platform.h"])
536         ;;
537     esac
538    ],
539    [AC_MSG_RESULT([--with-microhttpd not specified])
540     AC_CHECK_HEADERS([microhttpd.h],
541       AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
542         AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
543           lmhd=1),
544         [],[#include "src/include/platform.h"
545             #include <microhttpd.h>]),,
546        [#include "src/include/platform.h"])])
547 AM_CONDITIONAL(HAVE_MHD, test x$lmhd = x1)
548 AC_DEFINE_UNQUOTED([HAVE_MHD], $lmhd, [We have libmicrohttpd])
549 # restore LIBS
550 LIBS=$SAVE_LIBS
551
552 # libesmtp
553 esmtp=0
554 AC_MSG_CHECKING([for libesmtp])
555 AC_ARG_WITH(esmtp,
556    [  --with-esmtp=PFX        base of libesmtp installation],
557    [AC_MSG_RESULT([$with_esmtp])
558     case $with_esmtp in
559       no)
560         ;;
561       yes)
562         AC_CHECK_HEADERS(libesmtp.h,
563           AC_CHECK_LIB([esmtp], [smtp_start_session],
564             esmtp=1))
565         ;;
566       *)
567         LDFLAGS="-L$with_esmtp/lib $LDFLAGS"
568         CPPFLAGS="-I$with_esmtp/include $CPPFLAGS"
569         AC_CHECK_HEADERS(libesmtp.h,
570           AC_CHECK_LIB([esmtp], [smtp_start_session],
571             EXT_LIB_PATH="-L$with_esmtp/lib $EXT_LIB_PATH"
572               esmtp=1))
573         ;;
574     esac
575    ],
576    [AC_MSG_RESULT([--with-esmtp not specified])
577     AC_CHECK_HEADERS(libesmtp.h,
578       AC_CHECK_LIB([esmtp], [smtp_start_session],
579           esmtp=1))])
580 AM_CONDITIONAL(HAVE_ESMTP, test x$esmtp = x1)
581 AC_DEFINE_UNQUOTED([HAVE_ESMTP], $esmtp, [We have libesmtp])
582 # restore LIBS
583 LIBS=$SAVE_LIBS
584
585 # check for gettext
586 AM_GNU_GETTEXT_VERSION([0.16.1])
587 AM_GNU_GETTEXT([external])
588
589 # check for iconv
590 AM_ICONV
591
592 # Checks for standard typedefs, structures, and compiler characteristics.
593 AC_C_CONST
594 AC_TYPE_PID_T
595 AC_TYPE_SIZE_T
596 AC_TYPE_MODE_T
597 AC_HEADER_TIME
598 AC_HEADER_STAT
599 AC_HEADER_STDBOOL
600 AC_STRUCT_TM
601
602
603
604
605 # Checks for library functions.
606 AC_FUNC_CLOSEDIR_VOID
607 AC_FUNC_FORK
608 AC_PROG_GCC_TRADITIONAL
609 AC_FUNC_MEMCMP
610 AC_FUNC_SELECT_ARGTYPES
611 AC_FUNC_CHOWN
612
613 AC_TYPE_SIGNAL
614 AC_FUNC_STAT
615 AC_FUNC_STRFTIME
616 AC_FUNC_VPRINTF
617 AC_HEADER_SYS_WAIT
618 AC_TYPE_OFF_T
619 AC_TYPE_UID_T
620 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 gethostbyaddr initgroups getifaddrs freeifaddrs getnameinfo getaddrinfo inet_ntoa localtime_r nl_langinfo putenv realpath strndup gethostbyname2 gethostbyname])
621
622 # restore LIBS
623 LIBS=$SAVE_LIBS
624
625
626
627 # check for guile
628 guile=0
629 AC_MSG_CHECKING(for guile 1.8)
630 AC_ARG_WITH(guile,
631    [  --with-guile=PFX        base of guile installation],
632    [AC_MSG_RESULT([$with_guile])
633     case $with_guile in
634       no)
635         ;;
636       yes)
637         AC_CHECK_HEADERS(libguile.h,
638           AC_CHECK_LIB([guile], [scm_c_define_gsubr],
639             guile=1, [],
640             -lgmp $LIBLTDL))
641         ;;
642       *)
643         LDFLAGS="-L$with_guile/lib $LDFLAGS"
644         CPPFLAGS="-I$with_guile/include $CPPFLAGS"
645         AC_CHECK_HEADERS(libguile.h,
646           AC_CHECK_LIB([guile], [scm_c_define_gsubr],
647             EXT_LIB_PATH="-L$with_guile/lib $EXT_LIB_PATH"
648             guile=1, [],
649             -lgmp $LIBLTDL))
650         ;;
651     esac
652    ],
653    [AC_MSG_RESULT([--with-guile not specified])
654     AC_CHECK_HEADERS(libguile.h,
655      AC_CHECK_LIB([guile], [scm_c_define_gsubr],
656       guile=1, [], -lgmp $LIBLTDL))])
657
658 if test "$guile" = 1
659 then
660  AC_CHECK_LIB([guile], [scm_init_guile], [],
661         AC_MSG_ERROR([Guile doesn't provide scm_init_guile(). Please report to bug-gnunet@gnu.org]), -lgmp $LIBLTDL)
662  AC_DEFINE_UNQUOTED([HAVE_GUILE], 1, [We have GUILE])
663 else
664  AC_DEFINE_UNQUOTED([HAVE_GUILE], 0, [We do NOT have GUILE])
665 fi
666 AM_CONDITIONAL(HAVE_GUILE, test x$guile = x1)
667 # restore LIBS
668 LIBS=$SAVE_LIBS
669
670 gn_user_home_dir="~/.gnunet"
671 AC_ARG_WITH(user-home-dir,
672         AC_HELP_STRING(
673                 [--with-user-home-dir=DIR],
674                 [default user home directory (~/.gnunet)]),
675         [gn_user_home_dir=$withval])
676 AC_SUBST(GN_USER_HOME_DIR, $gn_user_home_dir)
677 gn_daemon_home_dir="/var/lib/gnunet"
678 AC_ARG_WITH(daemon-home-dir,
679         AC_HELP_STRING(
680                 [--with-daemon-home-dir=DIR],
681                 [default daemon home directory (/var/lib/gnunet)]),
682         [gn_daemon_home_dir=$withval])
683 AC_SUBST(GN_DAEMON_HOME_DIR, $gn_daemon_home_dir)
684 gn_daemon_config_dir="/etc"
685 AC_ARG_WITH(daemon-config-dir,
686         AC_HELP_STRING(
687                 [--with-daemon-config-dir=DIR],
688                 [default daemon config directory (/etc)]),
689         [gn_daemon_config_dir=$withval])
690 AC_SUBST(GN_DAEMON_CONFIG_DIR, $gn_daemon_config_dir)
691 gn_daemon_pidfile="/var/run/gnunetd/pid"
692 AC_ARG_WITH(daemon-pidfile,
693         AC_HELP_STRING(
694                 [--with-daemon-pidfile=FILE],
695                 [default daemon pidfile (/var/run/gnunetd/pid)]),
696         [gn_daemon_pidfile=$withval])
697 AC_SUBST(GN_DAEMON_PIDFILE, $gn_daemon_pidfile)
698
699 GN_INTLINCL=""
700 GN_LIBINTL="$LTLIBINTL"
701 AC_ARG_ENABLE(framework, [  --enable-framework      enable Mac OS X framework build helpers],enable_framework_build=$enableval)
702 AM_CONDITIONAL(WANT_FRAMEWORK, test x$enable_framework_build = xyes)
703 if test x$enable_framework_build = xyes
704 then
705   AC_DEFINE([FRAMEWORK_BUILD], 1, [Build a Mac OS X Framework])
706   GN_INTLINCL='-I$(top_srcdir)/src/intlemu'
707   GN_LIBINTL='$(top_builddir)/src/intlemu/libintlemu.la -framework CoreFoundation'
708   AC_LIB_APPENDTOVAR([CPPFLAGS], [$GN_INTLINCL]) 
709 fi
710
711 GN_LIB_LDFLAGS="-export-dynamic -no-undefined"
712 GN_PLUGIN_LDFLAGS="-export-dynamic -avoid-version -module -no-undefined"
713 dnl TODO insert a proper check here
714 AC_CACHE_CHECK([whether -export-symbols-regex works],
715  gn_cv_export_symbols_regex_works, 
716  [
717   case "$host_os" in
718   mingw*) gn_cv_export_symbols_regex_works=no;;
719   *) gn_cv_export_symbols_regex_works=yes;;
720   esac
721  ])
722 if test "x$gn_cv_export_symbols_regex_works" = "xyes"
723 then
724  GN_LIB_LDFLAGS="$GN_LIB_LDFLAGS -export-symbols-regex \"GNUNET_@<:@a-zA-Z0-9_@:>@*\""
725  GN_PLUGIN_LDFLAGS="$GN_PLUGIN_LDFLAGS -export-symbols-regex \"@<:@a-zA-Z0-9_@:>@*\""
726 fi
727 AC_SUBST(GN_LIB_LDFLAGS)
728 AC_SUBST(GN_PLUGIN_LDFLAGS)
729 AC_SUBST(GN_INTLINCL)
730 AC_SUBST(GN_LIBINTL)
731
732 AC_SUBST(CPPFLAGS)
733 AC_SUBST(LIBS)
734 AC_SUBST(LDFLAGS)
735 AC_SUBST(EXT_LIB_PATH)
736 AC_SUBST(EXT_LIBS)
737
738 AC_SUBST(LIBPREFIX)
739 AC_SUBST(DLLDIR)
740 AC_SUBST(EXT_LIB_PATH)
741
742
743 # gcov compilation
744 use_gcov=no
745 AC_ARG_ENABLE([coverage], AS_HELP_STRING([--enable-coverage],
746                                         [Compile the library with code coverage support (default is NO)]),
747                                         [use_gcov=yes], [use_gcov=no])
748 AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
749
750
751
752 AC_CONFIG_FILES([ po/Makefile.in m4/Makefile
753 Makefile
754 contrib/Makefile
755 src/Makefile
756 src/arm/Makefile
757 src/core/Makefile
758 src/include/Makefile
759 src/include/gnunet_directories.h
760 src/util/Makefile
761 src/fragmentation/Makefile
762 src/hello/Makefile
763 src/peerinfo/Makefile
764 src/resolver/Makefile
765 src/statistics/Makefile
766 src/template/Makefile
767 src/transport/Makefile
768 ])
769 AC_OUTPUT
770
771 # Finally: summary!
772
773 # warn user if mysql found but not used due to version
774 if test "$mysqlfail" = "true"
775 then
776   AC_MSG_NOTICE([NOTICE: MySQL found, but too old. MySQL support will not be compiled.])
777 fi
778
779 # sqlite
780 if test "x$sqlite" = "x0"
781 then
782   AC_MSG_NOTICE([NOTICE: sqlite not found.  sqLite support will not be compiled.])
783 fi
784
785 if test "x$dialog" != "x1" -a "x$cdialog" != "x1"
786 then
787  AC_MSG_NOTICE([NOTICE: curses based gnunet-setup frontends will not be installed.])
788 fi
789
790 if test "x$lmhd" != "x1"
791 then
792  AC_MSG_NOTICE([NOTICE: libmicrohttpd not found, http transport will not be installed.])
793 fi
794
795 AC_MSG_NOTICE([NOTICE: Database support is set to MySQL: $mysql, SQLite: $sqlite])
796
797 # guile
798 if test "x$guile" = "x0"
799 then
800  AC_MSG_NOTICE([WARNING: Guile not found, gnunet-setup will not be installed.])
801 fi
802
803 if test "$enable_framework_build" = "yes"
804 then
805   AC_MSG_NOTICE([NOTICE: Mac OS X framework build enabled.])
806 fi
807
808 AC_MSG_NOTICE([********************************************
809 You can build GNUnet with
810         make install
811 now. After that, install gnunet-gtk or gnunet-qt and run 
812         gnunet-setup -d wizard-gtk
813 (on graphical systems with GTK) or
814         gnunet-setup -d wizard-qt
815 (on graphical systems with QT) or
816         gnunet-setup -d wizard-curses
817 (on text-based systems with curses) in order to make important configuration
818 settings. If neither works for you, you can find a template configuration
819 file in the contrib/ subdirectory. Copy it to /etc/gnunetd.conf and modify it
820 using your favourite text editor.
821 ********************************************])