fix MinGW
[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 AM_PROG_CC_C_O
41 LT_CONFIG_LTDL_DIR([libltdl])
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 -I../../libltdl $CFLAGS"
145      build_target="mingw"
146      AC_PROG_CXX
147      LIBPREFIX=lib
148      DLLDIR=bin
149      ;;
150 *)
151      AC_MSG_RESULT(Unrecognised OS $host_os)
152      AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
153 ;;
154 esac
155 AC_DEFINE_UNQUOTED([GNUNET_DEFAULT_INTERFACE], $DEFAULT_INTERFACE, [This should be the default choice for the name of the first network interface])
156 AC_SUBST(DEFAULT_INTERFACE)
157
158 AC_MSG_CHECKING([for build target])
159 AM_CONDITIONAL(DARWIN,  test "$build_target" = "darwin")
160 AM_CONDITIONAL(CYGWIN,  test "$build_target" = "cygwin")
161 AM_CONDITIONAL(MINGW,   test "$build_target" = "mingw")
162 AM_CONDITIONAL(SOLARIS, test "$build_target" = "solaris")
163 AM_CONDITIONAL(XFREEBSD, test "$build_target" = "freebsd")
164 AM_CONDITIONAL(OPENBSD, test "$build_target" = "openbsd")
165 AM_CONDITIONAL(LINUX, test "$build_target" = "linux")
166 AC_MSG_RESULT([$build_target])
167 AC_SUBST(build_target)
168 AM_CONDITIONAL([am__fastdepOBJC], false)
169 AC_UNALIGNED_64_ACCESS
170
171 # some other checks for standard libs
172 AC_SEARCH_LIBS([gethostbyname], [nsl ws2_32])
173 AC_CHECK_LIB(socket, socket)
174 AC_CHECK_LIB(m, log)
175 AC_CHECK_LIB(c, getloadavg, AC_DEFINE(HAVE_GETLOADAVG,1,[getloadavg supported]))
176
177 # 'save' libs; only those libs found so far will be
178 # linked against _everywhere_.  For the others, we
179 # will be more selective!
180 SAVE_LIBS=$LIBS
181
182 # libgcrypt
183 gcrypt=0
184 AM_PATH_LIBGCRYPT(1.2.0, gcrypt=1)
185
186 if test $gcrypt = 0
187 then
188   AC_MSG_ERROR([GNUnet needs libgcrypt])
189 fi
190
191
192 # libcurl
193 LIBCURL_CHECK_CONFIG(,7.15.4,,AC_MSG_ERROR([GNUnet requires libcurl >= 7.15.4]))
194 # restore LIBS
195 LIBS=$SAVE_LIBS
196
197 # restore LIBS
198 LIBS=$SAVE_LIBS
199
200 # test for kvm and kstat (for CPU stats under BSD/Solaris)
201 AC_CHECK_LIB([kvm],[kvm_open])
202 AC_CHECK_LIB([kstat],[kstat_open])
203
204 # test for libextractor
205 extractor=0
206 AC_MSG_CHECKING(for libextractor)
207 AC_ARG_WITH(extractor,
208    [  --with-extractor=PFX    base of libextractor installation],
209    [AC_MSG_RESULT([$with_extractor])
210     case $with_extractor in
211       no)
212         ;;
213       yes)
214         AC_CHECK_HEADERS(extractor.h,
215           AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
216             extractor=1))
217         ;;
218       *)
219         LDFLAGS="-L$with_extractor/lib $LDFLAGS"
220         CPPFLAGS="-I$with_extractor/include $CPPFLAGS"
221         AC_CHECK_HEADERS(extractor.h,
222           AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
223             EXT_LIB_PATH="-L$with_extractor/lib $EXT_LIB_PATH"
224             extractor=1))
225         ;;
226     esac
227    ],
228    [AC_MSG_RESULT([--with-extractor not specified])
229     AC_CHECK_HEADERS(extractor.h,
230      AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
231       extractor=1))])
232 if test "$extractor" != 1
233 then
234  AC_MSG_ERROR([GNUnet requires libextractor])
235 fi
236 # restore LIBS
237 LIBS=$SAVE_LIBS
238
239
240 # Checks for standard header files.
241 AC_HEADER_DIRENT
242 AC_HEADER_STDC
243
244 # Check for headers that are ALWAYS required
245 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]))
246
247 # Checks for headers that are only required on some systems or opional (and where we do NOT abort if they are not there)
248 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 argz.h])
249
250 # Check for GMP header (and abort if not present)
251 AC_CHECK_HEADERS([gmp.h],,AC_MSG_ERROR([Compiling GNUnet requires gmp.h (from the GNU MP library, libgmp)]))
252
253 # test for libgmp
254 gmp=0
255 AC_MSG_CHECKING(for libgmp)
256 AC_ARG_WITH(gmp,
257    [  --with-gmp=PFX          base of libgmp installation],
258    [AC_MSG_RESULT([$with_gmp])
259     case $with_gmp in
260       no)
261         ;;
262       yes)
263         AC_CHECK_HEADERS(gmp.h,
264           AC_CHECK_LIB([gmp], [__gmpz_add],
265             gmp=1))
266         ;;
267       *)
268         LDFLAGS="-L$with_gmp/lib $LDFLAGS"
269         CPPFLAGS="-I$with_gmp/include $CPPFLAGS"
270         AC_CHECK_HEADERS(gmp.h,
271           AC_CHECK_LIB([gmp], [__gmpz_add],
272             EXT_LIB_PATH="-L$with_gmp/lib $EXT_LIB_PATH"
273             gmp=1))
274         ;;
275     esac
276    ],
277    [AC_MSG_RESULT([--with-gmp not specified])
278     AC_CHECK_HEADERS(gmp.h,
279      AC_CHECK_LIB([gmp], [__gmpz_add],
280       gmp=1))])
281 if test "$gmp" != 1
282 then
283  AC_MSG_ERROR([GNUnet requires libgmp])
284 fi
285
286 SAVE_LDFLAGS=$LDFLAGS
287 SAVE_CPPFLAGS=$CPPFLAGS
288
289 # test for sqlite
290 sqlite=false
291 AC_MSG_CHECKING(for SQLite)
292 AC_ARG_WITH(sqlite,
293   [  --with-sqlite=PFX       base of SQLite installation],
294   [AC_MSG_RESULT("$with_sqlite")
295    case $with_sqlite in
296    no)
297      ;;
298    yes)
299     AC_CHECK_HEADERS(sqlite3.h,
300      sqlite=true)
301      ;;
302    *)
303     LDFLAGS="-L$with_sqlite/lib $LDFLAGS"
304     CPPFLAGS="-I$with_sqlite/include $CPPFLAGS"
305     AC_CHECK_HEADERS(sqlite3.h,
306      EXT_LIB_PATH="-L$with_sqlite/lib $EXT_LIB_PATH"
307      SQLITE_LDFLAGS="-L$with_sqlite/lib"
308      SQLITE_CPPFLAGS="-I$with_sqlite/include"
309      sqlite=true)
310     LDFLAGS=$SAVE_LDFLAGS
311     CPPFLAGS=$SAVE_CPPFLAGS
312     ;;
313    esac
314   ],
315   [AC_MSG_RESULT([--with-sqlite not specified])
316     AC_CHECK_HEADERS(sqlite3.h, sqlite=true)])
317 AM_CONDITIONAL(HAVE_SQLITE, test x$sqlite = xtrue)
318 AC_SUBST(SQLITE_CPPFLAGS)
319 AC_SUBST(SQLITE_LDFLAGS)
320
321 # test for postgres
322 postgres=false
323 AC_MSG_CHECKING(for postgres)
324 AC_ARG_WITH(postgres,
325   [  --with-postgres=PFX       base of postgres installation],
326   [AC_MSG_RESULT("$with_postgres")
327    case $with_postgres in
328    no)
329      ;;
330    yes)
331     AC_CHECK_HEADERS(postgresql/libpq-fe.h,
332      postgres=true)
333      ;;
334    *)
335     LDFLAGS="-L$with_postgres/lib $LDFLAGS"
336     CPPFLAGS="-I$with_postgres/include $CPPFLAGS"
337     AC_CHECK_HEADERS(postgresql/libpq-fe.h,
338      EXT_LIB_PATH="-L$with_postgres/lib $EXT_LIB_PATH"
339      SQLITE_LDFLAGS="-L$with_postgres/lib"
340      SQLITE_CPPFLAGS="-I$with_postgres/include"
341      postgres=true)
342     LDFLAGS=$SAVE_LDFLAGS
343     CPPFLAGS=$SAVE_CPPFLAGS
344     ;;
345    esac
346   ],
347   [AC_MSG_RESULT([--with-postgres not specified])
348     AC_CHECK_HEADERS(postgresql/libpq-fe.h, postgres=true)])
349 AM_CONDITIONAL(HAVE_POSTGRES, test x$postgres = xtrue)
350 AC_SUBST(POSTGRES_CPPFLAGS)
351 AC_SUBST(POSTGRES_LDFLAGS)
352
353
354 # test for libz (maybe required for linking mysql)
355 zlib=1
356 AC_CHECK_LIB(z, compress,,zlib=0)
357 AM_CONDITIONAL(HAVE_ZLIB, test x$zlib = x1)
358 if test "$zlib" != 1
359 then
360  AC_MSG_ERROR([GNUnet requires zlib])
361 fi
362
363 # mysql & windows
364 AC_CHECK_TYPES([sigset_t, off_t], [], [], [#include <sys/types.h>])
365 AC_CHECK_TYPES([size_t], [], [], [#include <stdio.h>])
366
367 if test "$build_target" = "mingw"
368 then
369   CYGWIN_MYSQL_MAGIC="#include <mysql/my_global.h>"
370 fi
371
372 # test for mysql
373 mysql=false
374 mysqlfail=false
375 SAVE_LDFLAGS=$LDFLAGS
376 SAVE_CPPFLAGS=$CPPFLAGS
377 AC_MSG_CHECKING(for mysql)
378 AC_ARG_WITH(mysql,
379   [  --with-mysql=PFX        base of MySQL installation],
380   [AC_MSG_RESULT("$with_mysql")
381    if test "$with_mysql" != "no"
382    then
383     if test "$with_mysql" != "yes"
384     then
385       LDFLAGS="-L$with_mysql/lib -L$with_mysql/lib/mysql $LDFLAGS $ZLIBS"
386       CPPFLAGS="-I$with_mysql/include $CPPFLAGS"
387     fi
388     AC_CHECK_HEADERS(mysql/mysql.h,
389      AC_CHECK_LIB(mysqlclient, mysql_init,
390       MYSQL_LDFLAGS="-L$with_mysql/lib -L$with_mysql/lib/mysql"
391       MYSQL_CPPFLAGS="-I$with_mysql/include"
392
393       mysql=true), [], [$CYGWIN_MYSQL_MAGIC])
394    fi
395   ],
396   [AC_MSG_RESULT([--with-mysql not specified])
397    LDFLAGS="-L/usr/lib/mysql $LDFLAGS $ZLIBS"
398    AC_CHECK_LIB(mysqlclient, mysql_init,
399     [AC_CHECK_HEADERS(mysql/mysql.h,
400       MYSQL_LDFLAGS="-L/usr/lib/mysql"
401       mysql=true
402
403      , [], [$CYGWIN_MYSQL_MAGIC])])
404   ])
405
406 AC_SUBST(MYSQL_LDFLAGS)
407 AC_SUBST(MYSQL_CPPFLAGS)
408
409 # additional version check for mysql
410 AC_ARG_ENABLE(mysql-version-check, [  --disable-mysql-version-check  do not check MySQL version],, enable_mysql_version_check=yes)
411 if test "$mysql" = "true" -a "x$enable_mysql_version_check" = "xyes"
412 then
413   AC_MSG_CHECKING(mysql version)
414   AC_RUN_IFELSE([AC_LANG_PROGRAM(
415     [[$CYGWIN_MYSQL_MAGIC
416       #include <mysql/mysql.h>]],
417     [[if (MYSQL_VERSION_ID < 40100)
418         return(-1);
419       else
420         return(0);
421     ]])
422     ],mysql=true,mysql=false)
423   if test "$mysql" = "false"
424   then
425     mysqlfail=true
426     AC_MSG_RESULT([fail, >= 4.1 required])
427   else
428     AC_MSG_RESULT(ok)
429   fi
430 fi
431 AM_CONDITIONAL(HAVE_MYSQL, test x$mysql = xtrue)
432 AM_CONDITIONAL(HAVE_MYSQLE, test "0" = "1")
433 # restore LIBS
434 LIBS=$SAVE_LIBS
435 LDFLAGS=$SAVE_LDFLAGS
436 CPPFLAGS=$SAVE_CPPFLAGS
437
438 if test "$sqlite" = 0 -a "$mysql" = 0
439 then
440  AC_MSG_ERROR([GNUnet requires SQLite or MySQL])
441 fi
442
443 # libmicrohttpd
444 lmhd=0
445 AC_MSG_CHECKING([for libmicrohttpd])
446 AC_ARG_WITH(microhttpd,
447    [  --with-microhttpd=PFX   base of libmicrohttpd installation],
448    [AC_MSG_RESULT([$with_microhttpd])
449     case $with_microhttpd in
450       no)
451         ;;
452       yes)
453         AC_CHECK_HEADERS([microhttpd.h],
454           AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
455             AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
456               lmhd=1),
457             [],[#include "src/include/platform.h"
458                 #include <microhttpd.h>]),,
459             [#include "src/include/platform.h"])
460         ;;
461       *)
462         LDFLAGS="-L$with_microhttpd/lib $LDFLAGS"
463         CPPFLAGS="-I$with_microhttpd/include $CPPFLAGS"
464         AC_CHECK_HEADERS(microhttpd.h,
465           AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
466             AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
467               EXT_LIB_PATH="-L$with_microhttpd/lib $EXT_LIB_PATH"
468               lmhd=1),
469             [],[#include "src/include/platform.h"
470                 #include <microhttpd.h>]),,
471             [#include "src/include/platform.h"])
472         ;;
473     esac
474    ],
475    [AC_MSG_RESULT([--with-microhttpd not specified])
476     AC_CHECK_HEADERS([microhttpd.h],
477       AC_CHECK_DECL(MHD_OPTION_PER_IP_CONNECTION_LIMIT,
478         AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
479           lmhd=1),
480         [],[#include "src/include/platform.h"
481             #include <microhttpd.h>]),,
482        [#include "src/include/platform.h"])])
483 AM_CONDITIONAL(HAVE_MHD, test x$lmhd = x1)
484 AC_DEFINE_UNQUOTED([HAVE_MHD], $lmhd, [We have libmicrohttpd])
485 # restore LIBS
486 LIBS=$SAVE_LIBS
487
488 # libesmtp
489 esmtp=0
490 AC_MSG_CHECKING([for libesmtp])
491 AC_ARG_WITH(esmtp,
492    [  --with-esmtp=PFX        base of libesmtp installation],
493    [AC_MSG_RESULT([$with_esmtp])
494     case $with_esmtp in
495       no)
496         ;;
497       yes)
498         AC_CHECK_HEADERS(libesmtp.h,
499           AC_CHECK_LIB([esmtp], [smtp_start_session],
500             esmtp=1))
501         ;;
502       *)
503         LDFLAGS="-L$with_esmtp/lib $LDFLAGS"
504         CPPFLAGS="-I$with_esmtp/include $CPPFLAGS"
505         AC_CHECK_HEADERS(libesmtp.h,
506           AC_CHECK_LIB([esmtp], [smtp_start_session],
507             EXT_LIB_PATH="-L$with_esmtp/lib $EXT_LIB_PATH"
508               esmtp=1))
509         ;;
510     esac
511    ],
512    [AC_MSG_RESULT([--with-esmtp not specified])
513     AC_CHECK_HEADERS(libesmtp.h,
514       AC_CHECK_LIB([esmtp], [smtp_start_session],
515           esmtp=1))])
516 AM_CONDITIONAL(HAVE_ESMTP, test x$esmtp = x1)
517 AC_DEFINE_UNQUOTED([HAVE_ESMTP], $esmtp, [We have libesmtp])
518 # restore LIBS
519 LIBS=$SAVE_LIBS
520
521 # check for gettext
522 AM_GNU_GETTEXT_VERSION([0.16.1])
523 AM_GNU_GETTEXT([external])
524
525 # check for iconv
526 AM_ICONV
527
528 # Checks for standard typedefs, structures, and compiler characteristics.
529 AC_C_CONST
530 AC_TYPE_PID_T
531 AC_TYPE_SIZE_T
532 AC_TYPE_MODE_T
533 AC_HEADER_TIME
534 AC_HEADER_STAT
535 AC_HEADER_STDBOOL
536 AC_STRUCT_TM
537
538 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
539    [ AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1, [Do we have sockaddr_in.sin_len?])
540    ],
541    [],
542    [
543       #include <sys/types.h>
544       #include <sys/socket.h>
545       #include <netinet/in.h>
546    ])
547
548
549
550 # Checks for library functions.
551 AC_FUNC_CLOSEDIR_VOID
552 AC_FUNC_FORK
553 AC_FUNC_VFORK
554 AC_PROG_GCC_TRADITIONAL
555 AC_FUNC_MEMCMP
556 AC_FUNC_SELECT_ARGTYPES
557 AC_FUNC_CHOWN
558
559 AC_TYPE_SIGNAL
560 AC_FUNC_STAT
561 AC_FUNC_STRFTIME
562 AC_FUNC_VPRINTF
563 AC_HEADER_SYS_WAIT
564 AC_TYPE_OFF_T
565 AC_TYPE_UID_T
566 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])
567
568 # restore LIBS
569 LIBS=$SAVE_LIBS
570
571 gn_user_home_dir="~/.gnunet"
572 AC_ARG_WITH(user-home-dir,
573         AC_HELP_STRING(
574                 [--with-user-home-dir=DIR],
575                 [default user home directory (~/.gnunet)]),
576         [gn_user_home_dir=$withval])
577 AC_SUBST(GN_USER_HOME_DIR, $gn_user_home_dir)
578 gn_daemon_home_dir="/var/lib/gnunet"
579 AC_ARG_WITH(daemon-home-dir,
580         AC_HELP_STRING(
581                 [--with-daemon-home-dir=DIR],
582                 [default daemon home directory (/var/lib/gnunet)]),
583         [gn_daemon_home_dir=$withval])
584 AC_SUBST(GN_DAEMON_HOME_DIR, $gn_daemon_home_dir)
585 gn_daemon_config_dir="/etc"
586 AC_ARG_WITH(daemon-config-dir,
587         AC_HELP_STRING(
588                 [--with-daemon-config-dir=DIR],
589                 [default daemon config directory (/etc)]),
590         [gn_daemon_config_dir=$withval])
591 AC_SUBST(GN_DAEMON_CONFIG_DIR, $gn_daemon_config_dir)
592 gn_daemon_pidfile="/var/run/gnunetd/pid"
593 AC_ARG_WITH(daemon-pidfile,
594         AC_HELP_STRING(
595                 [--with-daemon-pidfile=FILE],
596                 [default daemon pidfile (/var/run/gnunetd/pid)]),
597         [gn_daemon_pidfile=$withval])
598 AC_SUBST(GN_DAEMON_PIDFILE, $gn_daemon_pidfile)
599
600 GN_INTLINCL=""
601 GN_LIBINTL="$LTLIBINTL"
602 AC_ARG_ENABLE(framework, [  --enable-framework      enable Mac OS X framework build helpers],enable_framework_build=$enableval)
603 AM_CONDITIONAL(WANT_FRAMEWORK, test x$enable_framework_build = xyes)
604 if test x$enable_framework_build = xyes
605 then
606   AC_DEFINE([FRAMEWORK_BUILD], 1, [Build a Mac OS X Framework])
607   GN_INTLINCL='-I$(top_srcdir)/src/intlemu'
608   GN_LIBINTL='$(top_builddir)/src/intlemu/libintlemu.la -framework CoreFoundation'
609   AC_LIB_APPENDTOVAR([CPPFLAGS], [$GN_INTLINCL]) 
610 fi
611
612 GN_LIB_LDFLAGS="-export-dynamic -no-undefined"
613 GN_PLUGIN_LDFLAGS="-export-dynamic -avoid-version -module -no-undefined"
614
615 AC_SUBST(GN_LIB_LDFLAGS)
616 AC_SUBST(GN_PLUGIN_LDFLAGS)
617 AC_SUBST(GN_INTLINCL)
618 AC_SUBST(GN_LIBINTL)
619
620 AC_SUBST(CPPFLAGS)
621 AC_SUBST(LIBS)
622 AC_SUBST(LDFLAGS)
623 AC_SUBST(EXT_LIB_PATH)
624 AC_SUBST(EXT_LIBS)
625
626 AC_SUBST(LIBPREFIX)
627 AC_SUBST(DLLDIR)
628 AC_SUBST(EXT_LIB_PATH)
629
630
631 # gcov compilation
632 use_gcov=no
633 AC_ARG_ENABLE([coverage], AS_HELP_STRING([--enable-coverage],
634                                         [Compile the library with code coverage support (default is NO)]),
635                                         [use_gcov=yes], [use_gcov=no])
636 AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
637
638
639
640 AC_CONFIG_FILES([ 
641 Makefile
642 contrib/Makefile
643 m4/Makefile
644 po/Makefile.in 
645 src/Makefile
646 src/arm/Makefile
647 src/core/Makefile
648 src/datacache/Makefile
649 src/datastore/Makefile
650 src/fragmentation/Makefile
651 src/fs/Makefile
652 src/hello/Makefile
653 src/include/Makefile
654 src/include/gnunet_directories.h
655 src/hostlist/Makefile
656 src/nat/Makefile
657 src/nat/libnatpmp/Makefile
658 src/nat/miniupnp/Makefile
659 src/peerinfo/Makefile
660 src/statistics/Makefile
661 src/template/Makefile
662 src/testing/Makefile
663 src/topology/Makefile
664 src/transport/Makefile
665 src/util/Makefile
666 ])
667 AC_OUTPUT
668
669 # Finally: summary!
670
671 # warn user if mysql found but not used due to version
672 if test "$mysqlfail" = "true"
673 then
674   AC_MSG_NOTICE([NOTICE: MySQL found, but too old. MySQL support will not be compiled.])
675 fi
676
677 # sqlite
678 if test "x$sqlite" = "x0"
679 then
680   AC_MSG_NOTICE([NOTICE: sqlite not found.  sqLite support will not be compiled.])
681 fi
682
683 if test "x$lmhd" != "x1"
684 then
685  AC_MSG_NOTICE([NOTICE: libmicrohttpd not found, http transport will not be installed.])
686 fi
687
688 AC_MSG_NOTICE([NOTICE: Database support is set to MySQL: $mysql, SQLite: $sqlite])
689
690 if test "$enable_framework_build" = "yes"
691 then
692   AC_MSG_NOTICE([NOTICE: Mac OS X framework build enabled.])
693 fi
694
695 AC_MSG_NOTICE([********************************************
696 You can build GNUnet with
697         make install
698 now. After that, install gnunet-gtk or gnunet-qt and run 
699         gnunet-setup -d wizard-gtk
700 (on graphical systems with GTK) or
701         gnunet-setup -d wizard-qt
702 (on graphical systems with QT) or
703         gnunet-setup -d wizard-curses
704 (on text-based systems with curses) in order to make important configuration
705 settings. If neither works for you, you can find a template configuration
706 file in the contrib/ subdirectory. Copy it to /etc/gnunetd.conf and modify it
707 using your favourite text editor.
708 ********************************************])