# This file is part of GNUnet.
# (C) 2001--2013 Christian Grothoff (and other contributing authors)
#
# GNUnet is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2, or (at your
# option) any later version.
#
# GNUnet is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNUnet; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
#
# Process this file with autoconf to produce a configure script.
#
#
AC_PREREQ(2.61)
# Checks for programs.
AC_INIT([gnunet], [0.9.5a],[bug-gnunet@gnu.org])
AC_CANONICAL_TARGET
AC_CANONICAL_HOST
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([gnunet], [0.9.5a])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_HEADERS([gnunet_config.h])
AH_TOP([#define _GNU_SOURCE 1])
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_OBJC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_CC_C_O
LT_INIT([disable-static dlopen win32-dll])
LTDL_INIT
AC_SUBST(LTDLINCL)
AC_SUBST(LIBLTDL)
AC_SUBST(MKDIR_P)
# large file support
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
if test "$enable_shared" = "no"
then
AC_MSG_ERROR([GNUnet only works with shared libraries. Sorry.])
fi
CFLAGS="-Wall $CFLAGS"
# use '-fno-strict-aliasing', but only if the compiler can take it
if gcc -fno-strict-aliasing -S -o /dev/null -xc /dev/null >/dev/null 2>&1;
then
CFLAGS="-fno-strict-aliasing $CFLAGS"
fi
# Use Linux interface name unless the OS has a different preference
DEFAULT_INTERFACE="\"eth0\""
funcstocheck="getnameinfo gethostname gethostbyname gethostbyaddr getaddrinfo"
# Srcdir in a form that native compiler understands (i.e. DOS path on W32)
native_srcdir=$srcdir
# Check system type
case "$host_os" in
*darwin* | *rhapsody* | *macosx*)
AC_DEFINE_UNQUOTED(DARWIN,1,[This is an Apple Darwin system])
CPPFLAGS="-D_APPLE_C_SOURCE $CPPFLAGS"
CFLAGS="-no-cpp-precomp -fno-common $CFLAGS"
AC_MSG_WARN([The VPN application cannot be compiled on your OS])
build_target="darwin"
DEFAULT_INTERFACE="\"en0\""
LIBPREFIX=
DLLDIR=lib
UNIXONLY="#"
;;
linux*)
AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
build_target="linux"
LIBPREFIX=
DLLDIR=lib
UNIXONLY="#"
AC_PATH_XTRA
;;
*freebsd*)
AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
CFLAGS="-D_THREAD_SAFE $CFLAGS"
build_target="freebsd"
LIBPREFIX=
DLLDIR=lib
UNIXONLY="#"
;;
*openbsd*)
AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
LIBS=`echo $LIBS | sed -e "s/-ldl//"`
build_target="openbsd"
LIBPREFIX=
DLLDIR=lib
UNIXONLY="#"
;;
*netbsd*)
AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
LIBPREFIX=
DLLDIR=lib
UNIXONLY="#"
;;
*solaris*)
AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno doesnt work])
AC_CHECK_LIB(resolv, res_init)
AC_CHECK_LIB(rt, nanosleep)
build_target="solaris"
LIBPREFIX=
DLLDIR=lib
UNIXONLY="#"
;;
*arm-linux*)
AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
CFLAGS="-D_REENTRANT -fPIC -pipe $CFLAGS"
build_target="linux"
LIBPREFIX=
DLLDIR=lib
UNIXONLY="#"
;;
*cygwin*)
AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
AC_CHECK_LIB(intl, gettext)
LDFLAGS="$LDFLAGS -no-undefined"
CFLAGS="-mms-bitfields $CFLAGS"
build_target="cygwin"
LIBPREFIX=lib
DLLDIR=bin
AC_PROG_CXX
UNIXONLY=""
;;
*mingw*)
AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
AC_DEFINE_UNQUOTED(_WIN32,1,[This is a Windows system])
AC_CHECK_LIB(intl, gettext)
LDFLAGS="$LDFLAGS -Wl,-no-undefined -Wl,--export-all-symbols"
LIBS="$LIBS -lws2_32 -lplibc -lgnurx -lole32"
CFLAGS="-mms-bitfields $CFLAGS"
CPPFLAGS="-D_WIN32_WINNT=0x0501 -DHAVE_STAT64=1 $CPPFLAGS"
build_target="mingw"
AC_PROG_CXX
LIBPREFIX=lib
DLLDIR=bin
UNIXONLY=""
funcstocheck=""
native_srcdir=$(cd $srcdir; pwd -W)
;;
gnu*)
AC_DEFINE_UNQUOTED(GNU,1,[This is a GNU system])
build_target="gnu"
UNIXONLY="#"
;;
*)
AC_MSG_RESULT(Unrecognised OS $host_os)
AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
UNIXONLY=""
;;
esac
AC_DEFINE_UNQUOTED([GNUNET_DEFAULT_INTERFACE], $DEFAULT_INTERFACE, [This should be the default choice for the name of the first network interface])
AC_SUBST(DEFAULT_INTERFACE)
# Disable TCP-based IPC on systems that support UNIX domain
# sockets in default configuratin:
AC_SUBST(UNIXONLY)
AC_MSG_CHECKING([for build target])
AM_CONDITIONAL(DARWIN, test "$build_target" = "darwin")
AM_CONDITIONAL(CYGWIN, test "$build_target" = "cygwin")
AM_CONDITIONAL(MINGW, test "$build_target" = "mingw")
AM_CONDITIONAL(SOLARIS, test "$build_target" = "solaris")
AM_CONDITIONAL(XFREEBSD, test "$build_target" = "freebsd")
AM_CONDITIONAL(OPENBSD, test "$build_target" = "openbsd")
AM_CONDITIONAL(LINUX, test "$build_target" = "linux")
AM_CONDITIONAL(GNU, test "$build_target" = "gnu")
AC_MSG_RESULT([$build_target])
AC_SUBST(build_target)
AM_CONDITIONAL([am__fastdepOBJC], false)
AC_UNALIGNED_64_ACCESS
# some other checks for standard libs
AC_SEARCH_LIBS([gethostbyname], [nsl ws2_32])
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(m, log)
AC_CHECK_LIB(c, getloadavg, AC_DEFINE(HAVE_GETLOADAVG,1,[getloadavg supported]))
# 'save' libs; only those libs found so far will be
# linked against _everywhere_. For the others, we
# will be more selective!
SAVE_LIBS=$LIBS
# libgnurx (regex library for W32)
gnurx=0
AC_CHECK_LIB(gnurx, regexec, gnurx=1)
if test "x$gnurx" = "x0" -a "x$build_target" = "xmingw"
then
AC_MSG_ERROR([on W32 GNUnet needs libgnurx])
fi
# libgcrypt
gcrypt=0
NEED_LIBGCRYPT_API=1
NEED_LIBGCRYPT_VERSION=1.4.2
AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION", gcrypt=1)
AC_CHECK_DECLS([gcry_mpi_lshift], [], [], [[#include <gcrypt.h>]])
if test $gcrypt = 0
then
AC_MSG_ERROR([[
***
*** You need libgcrypt to build this program.
** This library is for example available at
*** ftp://ftp.gnupg.org/gcrypt/libgcrypt/
*** (at least version $NEED_LIBGCRYPT_VERSION (API $NEED_LIBGCRYPT_API)
*** is required.)
***]])
fi
AC_DEFINE_UNQUOTED([NEED_LIBGCRYPT_VERSION], "$NEED_LIBGCRYPT_VERSION", [required libgcrypt version])
# Adam shostack suggests the following for Windows:
# -D_FORTIFY_SOURCE=2 -fstack-protector-all
AC_ARG_ENABLE(gcc-hardening,
AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks),
[if test x$enableval = xyes; then
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
CFLAGS="$CFLAGS --param ssp-buffer-size=1"
LDFLAGS="$LDFLAGS -pie"
fi])
# Linker hardening options
# Currently these options are ELF specific - you can't use this with MacOSX
AC_ARG_ENABLE(linker-hardening,
AS_HELP_STRING(--enable-linker-hardening, enable linker security fixups),
[if test x$enableval = xyes; then
LDFLAGS="$LDFLAGS -z relro -z now"
fi])
extra_logging=GNUNET_NO
AC_ARG_ENABLE([l