[go: up one dir, main page]

Menu

[r87]: / trunk / configure.ac  Maximize  Restore  History

Download this file

356 lines (324 with data), 11.4 kB

dnl Process this file with autoconf to produce a configure script.
AC_INIT([ehs],[1.4.11],[ehsdev@fritz-elfert.de])
AC_REVISION([$Id$])
AC_CONFIG_AUX_DIR([conf])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([ehs.cpp])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([foreign no-installinfo no-installman])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])

case $build_os in
    mingw*)
        if test "$build_os" = "$target_os" ; then
            # On native MinGW, the default include/lib paths
            # are /mingw/include resp. /mingw/lib, however
            # several contributed stuff is under /usr/...
            CPPFLAGS="$CPPFLAGS -I/usr/include"
            LDFLAGS="$LDFLAGS -L/usr/lib"
            # On native MinGW, we also want a prefix of /,
            # because we want to install directly in our
            # setupdir's bin (see packaging/win32/Makefile.am)
            if test "x$prefix" = xNONE; then
                prefix=/
            fi
        fi
        ;;
esac

LIBEHS_RES=
PLATFORM_SUBDIRS=
case $target_os in
    mingw*)
        PLATFORM_SUBDIRS=setup
        LIBEHS_RES='ehsrc.lo'
        ;;
esac
AC_SUBST(PLATFORM_SUBDIRS)
AC_SUBST(LIBEHS_RES)

dnl Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

m4_ifdef([LT_INIT],[
LT_INIT([win32-dll pic-only])
case $target_os in
    mingw*)
        LT_LANG([RC])
        ;;
esac
],[
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
case $target_os in
    mingw*)
        tagnames="RC"
        _LT_AC_TAGCONFIG
        ;;
esac
])

dnl Checks for libraries.

AC_ARG_WITH([pcre],AS_HELP_STRING([--with-pcre=DIR],[Specifies the location of the PCRE library]),
    [CPPFLAGS="$CPPFLAGS -I${withval}/include"
     CXXFLAGS="$CXXFLAGS -I${withval}/include"
     LDFLAGS="$LDFLAGS -L${withval}/lib"],[])

ac_cv_dllpath=
AC_ARG_WITH([dllpath],
            AS_HELP_STRING([--with-dllpath=PATH],
                           [Specify path for DLLs (mingw32 crossbuild only)]),
        [ac_cv_dllpath=$withval])


dnl Replace `main' with a function in -lpcre:
BFDLIB1=
BFDLIB2=
DWLIB=

dnl The following headers have to be checked *before* invoking
dnl AC_CHECK_LIB for pcrecpp, ssl and crypto in order for those
dnl checks to work correctly in mingw
AC_CHECK_HEADERS([openssl/ssl.h openssl/err.h pcre.h pcrecpp.h])

AC_CHECK_LIB(pcrecpp, main)
AC_CHECK_LIB(pthread, pthread_create)
AC_CHECK_LIB(sokt, socket)
AC_CHECK_LIB(z, inflate)
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(crypto, ERR_free_strings)
AC_CHECK_LIB(ssl, SSL_library_init)
AC_CHECK_LIB(ws2_32, main)
AC_CHECK_LIB(dw, dwfl_begin, DWLIB="-ldw")
AC_CHECK_LIB(bfd, bfd_openr, [BFDLIB1="-lbfd"])
AC_CHECK_LIB(iberty, cplus_demangle, [BFDLIB2="-liberty"])
havessl=$ac_cv_lib_ssl_SSL_library_init$ac_cv_lib_crypto_ERR_free_strings

AC_MSG_CHECKING([whether to build with SSL support])
withval=AUTO
AC_ARG_WITH([ssl],AS_HELP_STRING([--with-ssl],[compile with SSL support (requires OpenSSL)]))
AC_MSG_RESULT([$withval])
case "$withval" in
    [[yY][eE][sS]])
        test "$havessl" = "yesyes" || AC_MSG_ERROR([For compiling with SSL support, OpenSSL is required])
        AC_DEFINE([COMPILE_WITH_SSL],[1],[Whether to compile with SSL support or not])
        ;;
    AUTO)
        if test "$havessl" = "yesyes" ; then
            AC_DEFINE([COMPILE_WITH_SSL],[1],[Whether to compile with SSL support or not])
            AC_MSG_RESULT([configure: OpenSSL is available, enabled SSL support])
        else
            AC_MSG_RESULT([configure: OpenSSL not available, disabled SSL support])
        fi
        ;;
       *)
        if test -d "${withval}/include/openssl" -a "${withval}/lib" ; then
            AC_DEFINE([COMPILE_WITH_SSL],[1],[Whether to compile with SSL support or not])
            CPPFLAGS="-I${withval}/include $CPPFLAGS"
            LDFLAGS="-L${withval}/lib"
        fi
        ;;
esac

AC_MSG_CHECKING([whether to build with debugging information])
enableval=NO
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[compile with debugging information]))
AC_MSG_RESULT([$enableval])
case "$enableval" in
    [[yY][eE][sS]])
        AC_DEFINE([EHS_DEBUG],[1],[Whether to compile with debugging information])
        ;;
esac

AC_MSG_CHECKING([whether to prefer BFD over DWARF])
enableval=NO
PREFER_BFD=NO
AC_ARG_ENABLE(bfd,AS_HELP_STRING([--enable-bfd],[prefer BFD over DWARF (use for ehs_exception sample only)]))
AC_MSG_RESULT([$enableval])
case "$enableval" in
    [[yY][eE][sS]])
        PREFER_BFD=YES
        ;;
esac

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h demangle.h dwarf.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h sys/wait.h termios.h time.h unistd.h execinfo.h conio.h winsock2.h windows.h])

dnl DWARF vs. BFD
DW_CPPFLAGS=
AC_CHECK_HEADERS([libdwfl.h])
if test "$ac_cv_header_libdwfl_h" = "no" ; then
    AC_CHECK_HEADERS([elfutils/libdwfl.h],[DW_CPPFLAGS="-I/usr/include/elfutils"])
fi

if test -n "$DWLIB" -a "$PREFER_BFD" = "NO" ; then
    TRACE_LIBS="$DWLIB"
    TRACE_CPPFLAGS="$DW_CPPFLAGS"
    AC_DEFINE_UNQUOTED([USE_DWARF],1,[Define, if using libdw for resolving symbols])
    AC_MSG_NOTICE([Using DWARF for resolving symbols])
    if test -n "$BFDLIB2" ; then
        TRACE_LIBS="$DWLIB $BFDLIB2"
        AC_DEFINE_UNQUOTED([HAVE_LIBIBERTY],1,[Define, if libiberty is available])
    fi
else
    if test -n "$BFDLIB1" -a -n "$BFDLIB2" ; then
        TRACE_LIBS="$BFDLIB1 $BFDLIB2"
        AC_DEFINE_UNQUOTED([USE_BFD],1,[Define, if using bfd for resolving symbols])
        AC_MSG_NOTICE([Using BFD for resolving symbols])
    else
        AC_MSG_NOTICE([Disabling backtracing])
    fi
fi
AC_SUBST(TRACE_LIBS)
AC_SUBST(TRACE_CPPFLAGS)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_C_CONST

INN_C_GNU_VAMACROS
INN_C_GNU_PRETTY_FUNCTION

dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_FUNC_FORK
AC_CHECK_FUNCS([inet_ntoa memset select setlocale socket strcasecmp strerror strtoul pthread_getw32threadid_np pthread_getw32threadhandle_np])
tmp_LIBS="$LIBS"
LIBS="$LIBS $BFDLIB1 $BFDLIB2"
AC_CHECK_FUNCS([bfd_demangle])
LIBS="$tmp_LIBS"

FE_SVNREV([SVNREV])
AC_DEFINE_UNQUOTED(SVNREV,"$SVNREV",[SVN revision])
FE_RCVERSION

dnl Use modern -pthread gcc option if available.
fe_CHECK_FLAG([C++],[CXXFLAGS],[-pthread])

AC_ARG_ENABLE([warn],
	AS_HELP_STRING([--enable-warn],
		[Enable additional warnings (Default: NO)]),
	[
		AC_MSG_NOTICE([will enable additional warnings])
        fe_CHECK_FLAG([C],[CFLAGS],[-Wimplicit])
        CFLAGS="$CFLAGS $ac_checked_CFLAGS"
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-pedantic])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wall])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wextra])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wchar-subscripts])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wcomment])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wformat])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wformat-security])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wmissing-braces])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wparentheses])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wreturn-type])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wswitch])
        fe_CHECK_FLAG([C++],[CPPFLAGS],[-Wuninitialized])
        CPPFLAGS="$CPPFLAGS $ac_checked_CPPFLAGS"
        fe_CHECK_FLAG([C++],[CXXFLAGS],[-Wctor-dtor-privacy])
        fe_CHECK_FLAG([C++],[CXXFLAGS],[-Wnon-virtual-dtor])
        fe_CHECK_FLAG([C++],[CXXFLAGS],[-Woverloaded-virtual])
        fe_CHECK_FLAG([C++],[CXXFLAGS],[-Weffc++])
        CXXFLAGS="$CXXFLAGS $ac_checked_CXXFLAGS"
	]
)
LIBVERSION="`echo $VERSION|tr . :`"
AC_SUBST(LIBVERSION)

dnl Disable strict aliasing
ac_checked_CXXFLAGS=
fe_CHECK_FLAG([C++],[CXXFLAGS],[-fno-strict-aliasing])
CXXFLAGS="$CXXFLAGS $ac_checked_CXXFLAGS"

dnl Check for std::unique_ptr and std::move
ac_checked_CXXFLAGS=
fe_CHECK_FLAG([C++],[CXXFLAGS],[-std=gnu++0x])
CXXFLAGS="$CXXFLAGS $ac_checked_CXXFLAGS"
AC_MSG_CHECKING([for availability of std::unique_ptr and std::move])
USE_UNIQUE_PTR=0
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[#include <memory>
class foo { public: int bar; };
void mv(std::unique_ptr<foo>p) { int v = p->bar; }]],
[[std::unique_ptr<foo>p(new foo());mv(std::move(p));]]
)],[USE_UNIQUE_PTR=1;AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
AC_LANG_POP
AC_SUBST([USE_UNIQUE_PTR])

dnl findrequires.pl script
AC_CHECK_TARGET_TOOL([OBJDUMP],[objdump],[no])
case ${OBJDUMP}-${target_os} in
    no-mingw*)
        AC_MSG_ERROR([Could not find required tool 'objdump'])
        ;;
esac
AC_ARG_VAR([OBJDUMP],[Path to objdump binary. (required for win32 builds only)])
dnl For the same reason, we require perl
AC_CHECK_TOOL([PERL],[perl],[no])
case ${PERL}-${target_os} in
    no-mingw*)
        AC_MSG_ERROR([Could not find required tool 'perl'])
        ;;
esac

# ISCC env variable
AC_ARG_VAR([ISCC],[Full path of InnoSetup compiler iscc.exe.])dnl
SETUP=
DLLPATH=
PLATFORMDIST=
INSTALL_SAMPLES=

case $target_os in
    linux*)
        AC_CHECK_TOOL([RPMBUILD], [rpmbuild], [no])
        if test "$RPMBUILD" != "no" ; then
            PLATFORMDIST=rpm
        else
            AC_CHECK_TOOL([DPKG_BUILDPACKAGE], [dpkg-buildpackage], [no])
            if test "$DPKG_BUILDPACKAGE" != "no" ; then
                PLATFORMDIST=deb
            fi
        fi
        ;;
    mingw*)
        PLATFORMDIST=setup
        INSTALL_SAMPLES='$(noinst_PROGRAMS)'
        if test "$build_os" = "$target_os" ; then
            DLLPATH="$PATH"
            AC_ARG_WITH([iscc],
                        AS_HELP_STRING([--with-iscc=PATH],[Override ISCC path. (native mingw only)]),
                        [ISCC="$withval"])
            AC_PATH_PROG([ISCC],[iscc],[""],[$PATH])
            if test -z "$ISCC" ; then
                AC_MSG_WARN([InnoSetup compiler is missing, therefore no Setup will be built!])
                SETUP=
            else
                SETUP=nativesetup
            fi
        else
            if test -z "$ac_cv_dllpath" ; then
                AC_MSG_ERROR([Need --with-dllpath option on mingw32 crossbuild])
            fi
            DLLPATH="$ac_cv_dllpath"
            AC_ARG_WITH([wine-iscc],
                        AS_HELP_STRING([--with-wine-iscc=PATH],[Path of ISCC to be run under wine. (mingw32 crossbuild only)]),
                        [ISCC="$withval"])
            if test -z "$ISCC" ; then
                AC_MSG_WARN([InnoSetup compiler is missing, therefore no Setup will be built!])
                SETUP=
            else
                AC_PATH_PROG([WINE],[wine],[""],[$PATH])
                if test -z "$WINE" ; then
                    AC_MSG_WARN([wine is not available, therefore no Setup will be built!])
                    SETUP=
                else
                    SETUP=crosssetup
                fi
            fi
        fi
        ;;
esac

AC_SUBST(SETUP)
AC_SUBST(DLLPATH)
AC_SUBST(PLATFORMDIST)
AC_SUBST(INSTALL_SAMPLES)

dnl
dnl doxygen setup
dnl
DX_HTML_FEATURE(ON)
DX_CHM_FEATURE(OFF)
DX_CHI_FEATURE(OFF)
DX_MAN_FEATURE(OFF)
DX_RTF_FEATURE(OFF)
DX_XML_FEATURE(OFF)
DX_PDF_FEATURE(OFF)
DX_PS_FEATURE(OFF)
DX_INIT_DOXYGEN([EHS], [conf/doxygen.cfg], [doc])

AC_CONFIG_FILES([Makefile samples/Makefile setup/Makefile
                 conf/doxygen.cfg doc/manual.dox conf/ehs.spec
                 setup/findrequires.pl setup/isccwrap.sh ehsrc.rc ehstypes.h])
AC_OUTPUT