diff options
| author | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-12-29 06:57:30 +0000 |
|---|---|---|
| committer | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-12-29 06:57:30 +0000 |
| commit | 432edbf68f41a3257e421427ee33c6634b030e77 (patch) | |
| tree | 8ca9f0ca5d7d9e3074111ce281b2cc30af0bb4e2 | |
| parent | f5209be18aa0ca53715aa7bb6244804b3913cfad (diff) | |
Merge branch 'cmake'
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1871 5417fbe8-f217-4b02-8779-1006273d7864
| -rw-r--r-- | CMakeLists.txt | 11 | ||||
| -rwxr-xr-x | Config | 115 | ||||
| -rw-r--r-- | Makefile.in | 102 | ||||
| -rw-r--r-- | aclocal.m4 | 871 | ||||
| -rw-r--r-- | anope.m4 | 39 | ||||
| -rwxr-xr-x | autogen.sh | 13 | ||||
| -rw-r--r-- | config.guess | 1526 | ||||
| -rw-r--r-- | config.sub | 1662 | ||||
| -rwxr-xr-x | configure | 8159 | ||||
| -rw-r--r-- | configure.in | 290 | ||||
| -rw-r--r-- | docs/INSTALL | 38 | ||||
| -rw-r--r-- | docs/WIN32.txt | 146 | ||||
| -rw-r--r-- | include/Makefile | 20 | ||||
| -rw-r--r-- | include/sysconf.h.in | 122 | ||||
| -rw-r--r-- | install-script | 29 | ||||
| -rw-r--r-- | install-sh | 0 | ||||
| -rw-r--r-- | lang/Makefile | 82 | ||||
| -rwxr-xr-x | run-cc.pl | 17 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/Makefile | 135 | ||||
| -rw-r--r-- | src/bin/anoperc.cmake | 8 | ||||
| -rw-r--r-- | src/bin/anoperc.in | 141 | ||||
| -rw-r--r-- | src/core/Makefile | 46 | ||||
| -rw-r--r-- | src/core/Makefile.sub | 29 | ||||
| -rwxr-xr-x | src/core/configure | 60 | ||||
| -rw-r--r-- | src/modules/Makefile | 49 | ||||
| -rw-r--r-- | src/modules/Makefile.sub | 28 | ||||
| -rwxr-xr-x | src/modules/configure | 65 | ||||
| -rw-r--r-- | src/protocol/Makefile | 51 | ||||
| -rw-r--r-- | src/protocol/Makefile.sub | 32 | ||||
| -rwxr-xr-x | src/protocol/configure | 60 | ||||
| -rw-r--r-- | src/tools/Makefile | 39 |
32 files changed, 13878 insertions, 111 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a56c1d4f6..8b3d6c544 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,11 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) +# If the Source dir and the Binary dir are the same, we are building in-source, which we will disallow due to Autotools being there (but only on non-Windows) +if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} AND NOT WIN32) + message(FATAL_ERROR "You can not use CMake to build Anope from the root of it's source tree! Remove the CMakeCache.txt file from this directory, then create a separate directory (either below this directory or elsewhere), and then re-run CMake from there.") +endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} AND NOT WIN32) + # Detect is we are using CMake 2.6 or better, these versions include functions that require less work than CMake 2.4 does if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) set(CMAKE26_OR_BETTER TRUE) @@ -286,9 +291,9 @@ find_program(PERL perl) # If perl is included on the system and the user wants to use run-cc.pl, change the commands for compiling and linking if(PERL AND USE_RUN_CC_PL) - set(CMAKE_CXX_COMPILE_OBJECT "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_COMPILE_OBJECT}") - set(CMAKE_CXX_LINK_EXECUTABLE "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_LINK_EXECUTABLE}") - set(CMAKE_CXX_CREATE_SHARED_MODULE "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_CREATE_SHARED_MODULE}") + set(CMAKE_CXX_COMPILE_OBJECT "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl -q ${CMAKE_CXX_COMPILE_OBJECT}") + set(CMAKE_CXX_LINK_EXECUTABLE "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl -q ${CMAKE_CXX_LINK_EXECUTABLE}") + set(CMAKE_CXX_CREATE_SHARED_MODULE "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl -q ${CMAKE_CXX_CREATE_SHARED_MODULE}") endif(PERL AND USE_RUN_CC_PL) # If a INSTDIR was passed in to CMake, use it as the install prefix, otherwise set the default install prefix to the services directory under the user's home directory @@ -36,7 +36,7 @@ Load_Cache () { fi } -Run_CMake () { +Run_Build_System () { WITH_INST="" WITH_RUN="" WITH_PERM="" @@ -44,42 +44,77 @@ Run_CMake () { RUN_CC_PL="" GEN_TYPE="" - if [ "$INSTDEST" != "" ] ; then - WITH_INST="-DINSTDIR:STRING=$INSTDEST" + if [ "$INSTDIR" != "" ] ; then + if [ "$BUILD_SYSTEM" = "cmake" ] ; then + WITH_INST="-DINSTDIR:STRING=$INSTDIR" + else + WITH_INST="--with-instdir=$INSTDIR" + fi fi if [ "$RUNGROUP" != "" ] ; then - WITH_RUN="-DRUNGROUP:STRING=$RUNGROUP" + if [ "$BUILD_SYSTEM" = "cmake" ] ; then + WITH_RUN="-DRUNGROUP:STRING=$RUNGROUP" + else + WITH_RUN="--with-rungroup=$RUNGROUP" + fi fi if [ "$UMASK" != "" ] ; then - WITH_PERM="-DDEFUMASK:STRING=$UMASK" + if [ "$BUILD_SYSTEM" = "cmake" ] ; then + WITH_PERM="-DDEFUMASK:STRING=$UMASK" + else + WITH_PERM="--with-permissions=$UMASK" + fi fi if [ "$DEBUG" = "yes" ] ; then - BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=DEBUG" + if [ "$BUILD_SYSTEM" = "cmake" ] ; then + BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=DEBUG" + else + BUILD_TYPE="--with-debugsym" + fi else - BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=RELEASE" + if [ "$BUILD_SYSTEM" = "cmake" ] ; then + BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=RELEASE" + fi fi if [ "$USE_RUN_CC_PL" = "yes" ] ; then - RUN_CC_PL="-DUSE_RUN_CC_PL:BOOLEAN=ON" + if [ "$BUILD_SYSTEM" = "cmake" ] ; then + RUN_CC_PL="-DUSE_RUN_CC_PL:BOOLEAN=ON" + else + pwdsave=`pwd` + cd "`dirname $SOURCE_DIR/run-cc.pl`" + RUN_CC_PL="--with-makebin=`pwd`/run-cc.pl" + cd "$pwdsave" + fi else - RUN_CC_PL="-DUSE_RUN_CC_PL:BOOLEAN=OFF" + if [ "$BUILD_SYSTEM" = "cmake" ] ; then + RUN_CC_PL="-DUSE_RUN_CC_PL:BOOLEAN=OFF" + else + RUN_CC_PL="--with-makebin=" + fi fi - case `uname -s` in - MINGW*) - GEN_TYPE="-G\"MSYS Makefiles\"" - ;; - esac + if [ "$BUILD_SYSTEM" = "cmake" ] ; then + case `uname -s` in + MINGW*) + GEN_TYPE="-G\"MSYS Makefiles\"" + ;; + esac - echo "cmake $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $SOURCE_DIR" + echo "cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $SOURCE_DIR" - cmake $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $SOURCE_DIR + cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $SOURCE_DIR - echo "" - echo "Now run make to build Anope." + echo "" + echo "Now run make to build Anope." + else + echo "./configure $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL" + + ./configure $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL + fi } ECHO2SUF='' @@ -99,10 +134,11 @@ export ECHO2 ECHO2SUF # Init values ########################################################################### -INSTDEST=$HOME/services +BUILD_SYSTEM="cmake" +INSTDIR=$HOME/services RUNGROUP= UMASK= -DEBUG="no" +DEBUG="yes" USE_RUN_CC_PL="no" CAN_QUICK="no" SOURCE_DIR=`dirname $0` @@ -127,7 +163,7 @@ while [ $# -ge 1 ] ; do elif [ $1 = "-quick" -o $1 = "-q" ] ; then Load_Cache if [ "$CAN_QUICK" = "yes" ] ; then - Run_CMake + Run_Build_System else echo "" echo "Can't find cache file (config.cache), aborting..." @@ -175,12 +211,36 @@ export ok INPUT ok=0 echo "Note: press Return for the default, or enter a new value." +echo "Are you using configure or cmake?" +while [ $ok -eq 0 ] ; do + echo2 "[$BUILD_SYSTEM] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$BUILD_SYSTEM + fi + case $INPUT in + cmake) + ok=1 + ;; + configure) + ok=1 + ;; + *) + echo "That is not a valid choice!" + ok=0 + ;; + esac +done +BUILD_SYSTEM=$INPUT +echo "" + +ok=0 echo "In what directory do you want the binaries to be installed?" while [ $ok -eq 0 ] ; do - echo2 "[$INSTDEST] " + echo2 "[$INSTDIR] " if read INPUT ; then : ; else echo "" ; exit 1 ; fi if [ ! "$INPUT" ] ; then - INPUT=$INSTDEST + INPUT=$INSTDIR fi if [ ! -d "$INPUT" ] ; then if exists "$INPUT" ; then @@ -201,7 +261,7 @@ while [ $ok -eq 0 ] ; do ok=1 fi done -INSTDEST=$INPUT +INSTDIR=$INPUT echo "" @@ -310,7 +370,8 @@ echo "" echo2 "Saving configuration results in config.cache... " cat <<EOT >$SOURCE_DIR/config.cache -INSTDEST="$INSTDEST" +BUILD_SYSTEM="$BUILD_SYSTEM" +INSTDIR="$INSTDIR" RUNGROUP="$RUNGROUP" UMASK=$UMASK DEBUG="$DEBUG" @@ -320,7 +381,7 @@ echo "done." ################################################################################ -# Build the CMake string +# Build the build system string ################################################################################ -Run_CMake +Run_Build_System diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 000000000..ec73b009f --- /dev/null +++ b/Makefile.in @@ -0,0 +1,102 @@ +CC=g++ # probably wrong but oh well. +INCLUDEDIR=../include +ANOPELIBS=@ANOPELIBS@ +CFLAGS=@CFLAGS@ -Wall -ansi -pedantic -Wshadow +PROFILE=-pg +LDPROFILE= +SHELL=/bin/sh +INSTDIR=@INSTDIR@ +MAKEBIN=@MAKEBIN@ +INSTALL=@INSTALL@ +RM=@RM@ +CP=@CP@ +TOUCH=@TOUCH@ +LDFLAGS=@LDFLAGS@ +RUNGROUP=@RUNGROUP@ +SHARED=@SHARED@ +MODULEFLAGS=@MODULEFLAGS@ + +all: language headers build core protocols tools modules +profile: language headers profile_build profile_core profile_protocols profile_tools profile_modules + +MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ + 'LDFLAGS=${LDFLAGS}' 'INSTDIR=${INSTDIR}' 'INSTALL=${INSTALL}' \ + 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \ + 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' \ + 'RUNGROUP=${RUNGROUP}' \ + 'SHARED=${SHARED}' 'MODULEFLAGS=${MODULEFLAGS}' \ + 'MAKEBIN=${MAKEBIN}' + +build: language headers + @${MAKE} -C src ${MAKEARGS} all + +profile_build: + @${MAKE} -C src ${MAKEARGS} 'CFLAGS=${CFLAGS} $(PROFILE)' 'LDFLAGS=${LDFLAGS} ${PROFILE}' all + +modules: build + @src/modules/configure src/modules + @${MAKE} -C src/modules ${MAKEARGS} all + @echo "*** All done, now (g)make install to install Anope/Modules"; + +clean_modules: + @${MAKE} -C src ${MAKEARGS} clean_modules + +distclean_modules: + @${MAKE} -C src ${MAKEARGS} distclean_modules + +protocols: build + @echo "*** Building protocol support"; + @src/protocol/configure src/protocol + @${MAKE} -C src/protocol ${MAKEARGS} all + +profile_protocols: build + @echo "*** Building protocol support"; + @src/protocol/configure src/protocol + @${MAKE} -C src/protocol ${MAKEARGS} 'CFLAGS=${CFLAGS} ${PROFILE}' 'PROFILE=${PROFILE}' all + +core: build + @echo "*** Building Core modules"; + @${MAKE} -C src ${MAKEARGS} core + +profile_core: build + @echo "*** Building Core modules"; + @${MAKE} -C src ${MAKEARGS} 'CFLAGS=${CFLAGS} ${PROFILE}' 'PROFILE=${PROFILE}' core + +tools: build + @${MAKE} -C src/tools ${MAKEARGS} all + @echo "*** All done, now (g)make install to install Anope/Modules/Tools"; + +profile_tools: profile_build + @${MAKE} -C src/tools ${MAKEARGS} 'CFLAGS=${CFLAGS} $(PROFILE)' all + @echo "*** All done, now (g)make install to install Anope/Modules/Tools"; + +profile_modules: profile_build + @src/modules/configure src/modules + @${MAKE} -C src/modules ${MAKEARGS} 'CFLAGS=${CFLAGS} ${PROFILE}' 'PROFILE=${PROFILE}' all + @echo "*** All done, now (g)make install to install Anope/Modules"; + +language: + @$(MAKE) -C lang ${MAKEARGS} all language.h + +headers: + @${MAKE} -C include ${MAKEARGS} + +clean: + ${MAKE} -C lang ${MAKEARGS} clean + ${MAKE} -C include ${MAKEARGS} clean + ${MAKE} -C src ${MAKEARGS} clean + ${MAKE} -C src/tools ${MAKEARGS} clean + +distclean: clean + ${MAKE} -C lang ${MAKEARGS} distclean + ${MAKE} -C include ${MAKEARGS} distclean + ${MAKE} -C src ${MAKEARGS} distclean + ${MAKE} -C src/tools ${MAKEARGS} distclean + rm -f config.log config.status config.cache Makefile src/bin/anoperc + +install: DUMMY + ${MAKE} -C src ${MAKEARGS} install + ${MAKE} -C src/tools ${MAKEARGS} install + @echo "*** All done, Anope is now installed. Please read docs/INSTALL for details on what to do now."; + +DUMMY: diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 000000000..c2a6ca0bb --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,871 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4-p6 + +dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +# lib-prefix.m4 serial 4 (gettext-0.14.2) +dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +# lib-link.m4 serial 6 (gettext-0.14.3) +dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_PREREQ(2.50) + +dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and +dnl augments the CPPFLAGS variable. +AC_DEFUN([AC_LIB_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + ac_cv_lib[]Name[]_libs="$LIB[]NAME" + ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" + ac_cv_lib[]Name[]_cppflags="$INC[]NAME" + ]) + LIB[]NAME="$ac_cv_lib[]Name[]_libs" + LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" + INC[]NAME="$ac_cv_lib[]Name[]_cppflags" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the + dnl results of this search when this library appears as a dependency. + HAVE_LIB[]NAME=yes + undefine([Name]) + undefine([NAME]) +]) + +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) +dnl searches for libname and the libraries corresponding to explicit and +dnl implicit dependencies, together with the specified include files and +dnl the ability to compile and link the specified testcode. If found, it +dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and +dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs +dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. +AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + + dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + + dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, + dnl because if the user has installed lib[]Name and not disabled its use + dnl via --without-lib[]Name-prefix, he wants to use it. + ac_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + + AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ + ac_save_LIBS="$LIBS" + LIBS="$LIBS $LIB[]NAME" + AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) + LIBS="$ac_save_LIBS" + ]) + if test "$ac_cv_lib[]Name" = yes; then + HAVE_LIB[]NAME=yes + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) + AC_MSG_CHECKING([how to link with lib[]$1]) + AC_MSG_RESULT([$LIB[]NAME]) + else + HAVE_LIB[]NAME=no + dnl If $LIB[]NAME didn't lead to a usable library, we don't need + dnl $INC[]NAME either. + CPPFLAGS="$ac_save_CPPFLAGS" + LIB[]NAME= + LTLIB[]NAME= + fi + AC_SUBST([HAVE_LIB]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + undefine([Name]) + undefine([NAME]) +]) + +dnl Determine the platform dependent parameters needed to use rpath: +dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, +dnl hardcode_direct, hardcode_minus_L. +AC_DEFUN([AC_LIB_RPATH], +[ + dnl Tell automake >= 1.10 to complain if config.rpath is missing. + m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE(rpath, + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib$1-prefix], +[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib + --without-lib$1-prefix don't search for lib$1 in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + hav |
