configure.ac
author Mikael Hallendal <micke@imendio.com>
Sun, 29 Apr 2007 22:09:44 +0200
changeset 265 ebfc8419758d
parent 252 6aefcc6153f4
child 267 c27883ae51f7
permissions -rw-r--r--
Bumped the version to 1.2.2

AC_INIT(Loudmouth, 1.2.2, loudmouth)
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (C) 2003-2007 Imendio AB])

AC_CONFIG_SRCDIR(loudmouth/loudmouth.h)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(1.9 dist-bzip2 no-define)

AM_MAINTAINER_MODE

AC_CANONICAL_HOST

os_win32=no

case "$host_os" in
  *mingw32*)
    os_win32=yes
esac

if test "$os_win32" = "yes"; then
  if test "$enable_static" = "yes" -o "$enable_static" = ""; then
    AC_MSG_WARN([Disabling static library build, must build as DLL on Windows.])
    enable_static=no
  fi

  if test "$enable_shared" = "no"; then
    AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows.])
  fi

  enable_shared=yes

  CFLAGS="$CFLAGS -mms-bitfields"
  LDFLAGS="$LDFLAGS -no-undefined"
fi

AC_PROG_CC
AC_ISC_POSIX
AC_HEADER_STDC
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL

AM_PATH_GLIB_2_0

AC_CHECK_HEADERS([arpa/inet.h fcntl.h memory.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) 
AC_CHECK_HEADERS([winsock2.h])

if test "$ac_cv_header_winsock2_h" = "yes"; then
  # If we have <winsock2.h>, assume we find the functions
  # in -lws2_32 (ws2_32 is winsock v2, wsock32 is v1.1)
  LIBS="-lws2_32 -lgdi32 $LIBS"
fi

IDT_COMPILE_WARNINGS

changequote(,)dnl
if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
  *[\ \	]-Wall[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac
fi
changequote([,])dnl

AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)

GLIB2_REQUIRED=2.4.0
GNUTLS_REQUIRED=1.4.0
LIBTASN1_REQUIRED=0.2.6

AC_SUBST(GLIB2_REQUIRED)
AC_SUBST(GNUTLS_REQUIRED)
AC_SUBST(LIBTASN1_REQUIRED)

LM_CHECK_TIMEZONE

PKG_CHECK_MODULES(LOUDMOUTH, glib-2.0 >= $GLIB2_REQUIRED)

PKG_CHECK_MODULES(LIBIDN, libidn, have_idn=yes, have_idn=no)
if test "x$have_idn" = "xyes"; then
	AC_DEFINE(HAVE_IDN, 1, [Define if IDN support is included])
fi

# Check Unit test framework (defined in acinclude.m4)
IDT_PATH_CHECK(0.9.2, have_check=yes, have_check=no)

AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xyes)

dnl Gtk doc
GTK_DOC_CHECK(1.0)

dnl define a MAINT-like variable REBUILD which is set if Perl
dnl and awk are found, so autogenerated sources can be rebuilt
AC_ARG_ENABLE(rebuilds,
              AS_HELP_STRING([--enable-rebuilds=@<:@no/yes/auto@:>@],
                             [Enable source autogeneration rules [[default=yes]]]), ,
              enable_rebuilds=yes)

REBUILD=\#
if test "x$enable_rebuilds" = "xyes" && \
     test -n "$PERL" && \
     $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 && \
     test -n "$AWK" ; then
  REBUILD=
fi
AC_SUBST(REBUILD)


dnl +--------------------------------------------------------+
dnl | Checking for libnsl and libsocket need on some systems |-
dnl +--------------------------------------------------------+
AC_CHECK_LIB(nsl,gethostbyname)
AC_CHECK_LIB(socket,socket)

dnl +--------------------------------------------------------+
dnl | Checking for SSL support                               |-
dnl +--------------------------------------------------------+
AC_ARG_WITH(ssl,
	    AS_HELP_STRING([--with-ssl=@<:@gnutls|openssl|no@:>@], 
			   [Which SSL implementation to use [[default=gnutls]]]),
	    ac_ssl=$withval,
	    ac_ssl=gnutls)

AC_ARG_WITH(openssl-includes,
	    AC_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes]),
	    [ use_openssl=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
	    )

AC_ARG_WITH(openssl-libs,
	    AC_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries]),
	    [ use_openssl=yes LDFLAGS="$LDFLAGS -L$withval" ]
	    )

enable_ssl=no
if test "x$ac_ssl" = "xgnutls"; then
  dnl Look for GnuTLS
  AM_PATH_LM_LIBGNUTLS($GNUTLS_REQUIRED, have_libgnutls=yes, have_libgnutls=no)
  if test "x$have_libgnutls" = "xyes"; then
    CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
    LIBS="$LIBS $LIBGNUTLS_LIBS"
    AC_DEFINE(HAVE_GNUTLS, 1, [whether to use GnuTSL support.])
    enable_ssl=GnuTLS
  else
    AC_MSG_ERROR([GnuTLS was not found, use
		--with-ssl=[[no|openssl]] to build without SSL support or
		with OpenSSL])
  fi
elif test "$ac_ssl" = "openssl"; then
  dnl Look for OpenSSL
  AC_CHECK_HEADERS([openssl/ssl.h])
  OLDLIBS="$LIBS"
  AC_CHECK_LIB(crypto, 
	       BIO_f_base64, 
	       [AC_CHECK_LIB(ssl, 
		             SSL_new, 
                             [SSL_LIB="-lssl -lcrypto"
		             AC_DEFINE(HAVE_OPENSSL, 
				       [], 
				       [Have OpenSSL])], 
		             [have_openssl=no], 
			     [-lcrypto])], 
	       [have_openssl=no], 
	       [])

  if test "x$have_openssl" = "xno"; then
    AC_MSG_ERROR([OpenSSL was not found, use --with-ssl=[[no|gnutls]] to
                  build without SSL support or with GnuTLS])
  else 
    LIBS="$OLDLIBS $SSL_LIB"
    enable_ssl=OpenSSL
  fi
else
	echo "Disabling SSL support"
fi

if test x$enable_ssl != xno; then
	AC_DEFINE(HAVE_SSL, 1, [whether to use SSL support.])
else
	if test x$ac_ssl != xno; then
		AC_MSG_ERROR([No SSL implementation was found, if you do not want to build with SSL use --with-ssl=no])
	fi
fi

AM_CONDITIONAL(USE_OPENSSL, test x$enable_ssl = xOpenSSL)
AM_CONDITIONAL(USE_GNUTLS, test x$enable_ssl = xGnuTLS)

dnl +-------------+
dnl | Build Flags |--------------------------------------------
dnl +-------------+
DOC_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $WARN_CFLAGS"
AC_SUBST(DOC_CFLAGS)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
dnl -----------------------------------------------------------

dnl +--------------+
dnl | Debug output |-------------------------------------------
dnl +--------------+

AC_ARG_ENABLE(debug,
              AS_HELP_STRING([--enable-debug=@<:@no/yes/auto@:>@],
                             [Enable debugging [[default=yes]]]), ,
              enable_debug=yes)

if test x$enable_debug = xno ; then
	echo "Debugging disabled"
	LOUDMOUTH_CFLAGS="$LOUDMOUTH_CFLAGS -DLM_NO_DEBUG"
else
	echo "Debugging enabled"
fi

AC_SUBST(LOUDMOUTH_CFLAGS)
AC_SUBST(LOUDMOUTH_LIBS)

AC_OUTPUT([
Makefile
docs/Makefile
docs/reference/Makefile
loudmouth/Makefile
examples/Makefile
tests/Makefile
tests/parser-tests/Makefile
loudmouth-1.0.pc
loudmouth.spec])

dnl ==========================================================================
echo "

        Loudmouth $VERSION from Imendio AB
	=====================================

        prefix:                   ${prefix}
        compiler:                 ${CC}
	Have IDN support:         ${have_idn}
        Enable SSL                ${enable_ssl}
        Enable Debug:             ${enable_debug}
	Enable Unit Tests:        ${have_check}
	Enable Documentation      ${enable_gtk_doc}
	
        Now type 'make' to build Loudmouth
"