diff options
| author | svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b <svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-03-28 21:59:56 +0000 |
|---|---|---|
| committer | svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b <svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-03-28 21:59:56 +0000 |
| commit | 55bf4dbcabf378e9472b7d31d6edf87f6ac853e9 (patch) | |
| tree | 7a9454ea6b8750256e242cf6d5fba3ca7a4b5044 /configure | |
Initial Anope Import
git-svn-id: svn://svn.anope.org/anope/trunk@1 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'configure')
| -rwxr-xr-x | configure | 1858 |
1 files changed, 1858 insertions, 0 deletions
diff --git a/configure b/configure new file mode 100755 index 000000000..38693a570 --- /dev/null +++ b/configure @@ -0,0 +1,1858 @@ +#!/bin/sh +# +# Configuration script for Services. +# +# Anope (c) 2003 Anope team +# Contact us at anope@zero.org +# +# This program is free but copyrighted software; see the file COPYING for +# details. +# +# Based on the original code of Epona by PegSoft. +# Based on the original code of Services by Andy Church. + +########################################################################### + +# Nifty handy functions. + +echo2 () { + $ECHO2 "$*$ECHO2SUF" # these are defined later +} + +log () { + echo >&3 "$MODE: $*" +} + +run () { + echo >&3 "$MODE: >>> $*" + $* >&3 2>&3 </dev/null +} + +exists () { # because some shells don't have test -e + if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then + return 0 + else + return 1 + fi +} + +########################################################################### + +# Test for the presence of a given include file or function. If the +# variable TEST is non-empty, it contains code to be placed at the end of +# main(), and should return 0 if everything is okay, else 1. +# +# For includes: Pass the include filename as an argument. The variable +# HAVE_include_name, where "include_name" is the name of the include file +# with letters uppercased and non-alphanumerics replaced by underscores, is +# set to 1 if the include file is present, else 0. +# +# For functions: Pass the return type, function name, and prototype as +# arguments. The variable HAVE_function, where "function" is the name +# of the function with letters uppercased, is set to 1 if the function is +# available, else 0. +# +# For both: The result code of the function will be 0 (true) if the entity +# is present, else 1 (false). + +test_include () { + include="$1" + inc2="`echo $include | sed 'y+abcdefghijklmnopqrstuvwxyz/.-+ABCDEFGHIJKLMNOPQRSTUVWXYZ___+'`" + if [ -f "/usr/include/$include" ] ; then + eval "HAVE_${inc2}=1" + log "found $include in /usr/include" + return 0 + fi + cat >tmp/test.c <<EOT +#include <$include> +int main() { return 0; } +EOT + if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test ; then + eval "HAVE_${inc2}=1" + log "found $include" + return 0 + else + eval "HAVE_${inc2}=0" + log "didn't find $include" + return 1 + fi +} + +test_function () { + rettype="$1" + func="$2" + proto="$3" + if [ ! "$rettype" -o ! "$func" ] ; then + log "test_function: missing parameter(s)" + return 1 + fi + if [ ! "$proto" ] ; then + proto="(...)" + fi + func2=`echo $func | tr '[a-z]' '[A-Z]'` + if [ ! "$TEST" ] ; then + TEST="return 0;" + fi + cat >tmp/test.c <<EOT + int main() { + extern int $func$proto; + $TEST + } +EOT + if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test && run tmp/test ; then + eval "HAVE_${func2}=1" + log "found $func" + return 0 + else + eval "HAVE_${func2}=0" + log "didn't find $func" + return 1 + fi +} + +########################################################################### + +# If something happens that really shouldn't: + +whoa_there () { + echo "" + echo "" + echo "*** WHOA THERE! ***" + echo "" + echo "We suddenly couldn't compile using the C compiler we already tested!" + echo "The command line we used was:" + echo " $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test" + echo "Please try to fix this; if you can't, mail anope@zero.org" + echo "with information about your system, the output from this script," + echo "and the "\`"configure.log' file generated by this script." + echo "" + exit 4 +} + +########################################################################### +########################################################################### + +# Create a temporary directory for our use. + +if [ -d tmp ] ; then + rm -rf tmp +fi +if mkdir tmp ; then : ; else + echo "Failed to create temporary directory! Exiting." + exit 2 +fi +if chmod u+rwx tmp ; then : ; else + echo "Cannot write to temporary directory! Exiting." + exit 2 +fi + +########################################################################### + +# Variable initialization. + +PROGRAM=services +BINDEST=$HOME/services +DATDEST=$HOME/services + +RUNGROUP= +UMASK= +IRCTYPE="no default" +IRCTYPE_DEF= +IRCTYPE_DEF2= +ENCRYPTION= +IMPORTSUPPORT= +THREAD= +MYSQL= +RDB= +HAVE_MYSQL_MYSQL_H= +USE_MODULES= +MODULE_PATH= +HAS_RTLD_LOCAL= +CC_ELIBS= +CC_MLIBS= + + +INSTALL= +CP_ALL= + +CC= +CC_FLAGS=bonkle +CC_LFLAGS=bonkle +CC_LIBS=bonkle + +OSTYPE=bonkle + +TYPE_INT16= +TYPE_INT32= + +HAVE_STRINGS_H= +HAVE_SYS_SELECT_H= +HAVE_SYS_SYSPROTO_H= + +HAVE_GETHOSTBYNAME_R=bonkle + +HAVE_STRERROR= +HAVE_SYS_ERRLIST=0 + +HAVE_SNPRINTF= +BAD_SNPRINTF= +HAVE_STRICMP= +HAVE_STRCASECMP= +HAVE_STRDUP= +HAVE_STRSPN= +HAVE_STRSIGNAL= +HAVE_GETTIMEOFDAY= +HAVE_SETGRENT= +HAVE_UMASK= +HAVE_FORK= +MISSING=bonkle + +########################################################################### + +# How can we echo something without going to the next line? + +ECHO2SUF='' +if [ "`echo -n a ; echo -n b`" = "ab" ] ; then + ECHO2='echo -n' +elif [ "`echo 'a\c' ; echo 'b\c'`" = "ab" ] ; then + ECHO2='echo' ; ECHO2SUF='\c' +elif [ "`printf 'a' 2>&1 ; printf 'b' 2>&1`" = "ab" ] ; then + ECHO2='printf "%s"' +else + # oh well... + ECHO2='echo' +fi +export ECHO2 ECHO2SUF + +########################################################################### + +# Command-line parsing. + +IGNORE_CACHE= ; USER_CC= ; USER_CC_FLAGS=bonkle ; USER_CC_LFLAGS=bonkle +USER_CC_LIBS= ; MYSQL_LIB_DIR=bonkle ; MYSQL_INC_DIR=bonkle + +export IGNORE_CACHE USER_CC USER_CC_FLAGS USER_CC_LFLAGS USER_CC_LIBS MYSQL_LIB_DIR MYSQL_INC_DIR + +while [ $# -gt 0 ] ; do + if [ "$1" = "-ignore-cache" ] ; then + IGNORE_CACHE=bonkle + elif [ "$1" = "-cc" ] ; then + shift + USER_CC=$1 + elif [ "$1" = "-cflags" ] ; then + shift + USER_CC_FLAGS=$1 + elif [ "$1" = "-lflags" ] ; then + shift + USER_CC_LFLAGS=$1 + elif [ "$1" = "-libs" ] ; then + shift + USER_CC_LIBS=$1 + elif [ "$1" = "-os2" ] ; then + PROGRAM=services.exe + elif [ "$1" = "-with-mysql-libs" ] ; then + shift + MYSQL_LIB_DIR=$1 + elif [ "$1" = "-with-mysql-includes" ] ; then + shift + MYSQL_INC_DIR=$1 + else + if [ "$1" != "-help" -a "$1" != "-h" -a "$1" != "--help" ]; then + echo >&2 Unknown option/parameter: "$1" + exitval=1 + else + exitval=0 + fi + cat >&2 <<EOT +Available options: + -ignore-cache Don't use cache file if it exists + -os2 Indicate that this is an OS/2 system. + -cc Specify C compiler to use (overrides cache and check) + -cflags Specify compilation flags (defaults: -O2 for gcc, + -O for other compilers; overrides cache/check) + -lflags Specify link flags for C compiler (default: none) + -libs Specify extra link libraries to use (default: none) + -with-mysql-libs Specify MySQL library directory to use (default: /usr/lib/mysql) + -with-mysql-includes Specify MySQL include directory to use (default: /usr/include) +EOT + exit $exitval + fi + shift +done + +########################################################################### + +echo "" +echo "-========================= A N O P E ==========================-" +echo "For more detailed information on the features of Anope1.5 please" +echo "read the self-named documentation found on the 'docs' directory." +echo "" + +echo "Anope is a set of IRC Service expanded upon Lara's Epona, based" +echo "on Andy Church's IRC Services. For all your Anope needs please" +echo "visit our portal at http://www.anope.org/" +echo "" + +echo "Please read the INSTALL file for install/upgrade instructions." +echo "Reading the FAQ and README files would be a good idea too. (all" +echo "documentation is located on directory 'docs')." +echo "-==============================================================-" +echo "" +echo "Beginning Services configuration." +echo "" + +########################################################################### + +# First, test for the presence of a config.cache file. If found, either +# don't use it (-ignore-cache), or let the user know how to not use it and +# then use it. + +if [ -f config.cache -a -r config.cache -a ! "$IGNORE_CACHE" ] ; then + cat <<EOT +Using defaults from config.cache. To ignore, either rm config.cache +or give the command-line option "-ignore-cache". + +EOT + . config.cache + if [ ! "$HAVE_SNPRINTF" \ + -o ! "$BAD_SNPRINTF" \ + -o ! "$HAVE_STRICMP" \ + -o ! "$HAVE_STRCASECMP" \ + -o ! "$HAVE_STRDUP" \ + -o ! "$HAVE_STRSPN" \ + -o ! "$HAVE_STRSIGNAL" ] ; then + MISSING=bonkle + fi +fi + +########################################################################### + +# Ask the user anything we need to know ahead of time. + +export ok INPUT + +#### + +ok=0 +echo "Note: press Return for the default, or enter a new value." +echo "In what directory do you want the binaries to be installed?" +while [ $ok -eq 0 ] ; do + echo2 "[$BINDEST] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$BINDEST + fi + if [ ! -d "$INPUT" ] ; then + if exists "$INPUT" ; then + echo "$INPUT exists, but is not a directory!" + else + echo "$INPUT does not exist. Create it?" + echo2 "[y] " + read YN + if [ "$YN" != "n" ] ; then + if mkdir -p $INPUT ; then + ok=1 + fi + fi + fi + elif exists "$INPUT/services.h" ; then + echo "You cannot use the Services source directory as a target directory." + else + ok=1 + fi +done +BINDEST=$INPUT +DATDEST=$INPUT +echo "" + +#### + +ok=0 +echo "Where do you want the data files to be installed?" +while [ $ok -eq 0 ] ; do + echo2 "[$DATDEST] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$DATDEST + fi + if [ ! -d "$INPUT" ] ; then + if exists "$INPUT" ; then + echo "$INPUT exists, but is not a directory!" + else + echo "$INPUT does not exist. Create it?" + echo2 "[y] " + read YN + if [ "$YN" != "n" ] ; then + if mkdir -p $INPUT ; then + ok=1 + fi + fi + fi + elif exists "$INPUT/services.h" ; then + echo "You cannot use the Services source directory as a target directory." + else + ok=1 + fi +done +DATDEST=$INPUT +echo "" + +#### + +OLD_RUNGROUP="$RUNGROUP" +if [ "$RUNGROUP" ] ; then + echo "Which group should all Services data files be owned by? (If Services" + echo "should not force files to be owned by a particular group, type "\"none\" + echo "(without the quotes) and press Return.)" +else + echo "Which group should all Services data files be owned by? (If Services" + echo "should not force files to be owned by a particular group, just press" + echo "Return.)" +fi +echo2 "[$RUNGROUP] " +if read INPUT ; then : ; else echo "" ; exit 1 ; fi +if [ "$INPUT" ] ; then + if [ "$INPUT" = "none" ] ; then + RUNGROUP="" + else + RUNGROUP="$INPUT" + fi +fi +echo "" + +#### + +if [ ! "$UMASK" -o "$RUNGROUP" != "$OLD_RUNGROUP" ] ; then + if [ "$RUNGROUP" ] ; then + UMASK=007 + else + UMASK=077 + fi +fi + +ok=0 +echo "What should the default umask for data files be (in octal)?" +echo "(077 = only accessible by owner; 007 = accessible by owner and group)" +while [ $ok -eq 0 ] ; do + echo2 "[$UMASK] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$UMASK + fi + if [ `echo "$INPUT" | grep -c '[^0-7]'` -gt 0 ] ; then + echo "$UMASK is not a valid octal number!" + else + if [ "`echo $INPUT | cut -c1`" != "0" ] ; then + INPUT=0$INPUT + fi + ok=1 + fi +done +UMASK=$INPUT +echo "" + +#### + +ok=0 +echo "Select the closest to the type of server on your IRC network:" +echo " 1) DreamForge 4.6.7 [dated IRCd, upgrade to a current one]" +echo " 2) Bahamut 1.4.27 [or later]" +echo " 3) UnrealIRCd 3.1.1 [or later]" +echo " 4) UltimateIRCd 2.8.2 [or later]" +echo " 5) UltimateIRCd 3.0.0 [alpha26 or later]" +echo " 6) Hybrid IRCd 7.0 [experimental]" +echo " 7) ViagraIRCd 1.3.x [or later]" +echo " 8) PTlink 6.15.0 [experimental]" + +while [ $ok -eq 0 ] ; do + echo2 "[$IRCTYPE] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$IRCTYPE + fi + case $INPUT in + no\ default) + echo "You must specify your IRC server type in order for Services to function" + echo "correctly." + ;; + 1) + IRCTYPE_DEF="IRC_DREAMFORGE" + IRCTYPE_DEF2= + ok=1 + ;; + 2) + IRCTYPE_DEF="IRC_BAHAMUT" + IRCTYPE_DEF2= + ok=1 + ;; + 3) IRCTYPE_DEF="IRC_DREAMFORGE" + IRCTYPE_DEF2="IRC_UNREAL" + ok=1 + ;; + 4) IRCTYPE_DEF="IRC_DREAMFORGE" + IRCTYPE_DEF2="IRC_ULTIMATE" + ok=1 + ;; + 5) IRCTYPE_DEF="IRC_BAHAMUT" + IRCTYPE_DEF2="IRC_ULTIMATE3" + ok=1 + ;; + 6) IRCTYPE_DEF="IRC_HYBRID" + IRCTYPE_DEF2= + ok=1 + ;; + 7) IRCTYPE_DEF="IRC_BAHAMUT" + IRCTYPE_DEF2="IRC_VIAGRA" + ok=1 + ;; + 8) IRCTYPE_DEF="IRC_PTLINK" + IRCTYPE_DEF2= + ok=1 + ;; + *) + echo "Please enter a valid option number." + ;; + esac +done +IRCTYPE=$INPUT +echo "" + +#### + +if [ "$ENCRYPTION" = "ENCRYPT_MD5" ] ; then + DEF=yes +else + DEF=no +fi + +ok=0 +echo "Do you want to use the MD5 message-digest algorithm to encrypt passwords?" +echo "(Selecting "\"yes\"" protects your passwords from being stolen if someone" +echo "gains access to the Services databases, but makes it impossible to recover" +echo "forgotten passwords. There is no way to reverse this operation, so make" +echo "sure you really want to enable it.)" +while [ $ok -eq 0 ] ; do + echo2 "[$DEF] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$DEF + fi + case $INPUT in + n*|N*) + ENCRYPTION= + ok=1 + ;; + y*|Y*) + ENCRYPTION=ENCRYPT_MD5 + ok=1 + ;; + *) + echo "Please enter `yes' or `no'." + ;; + esac +done +echo "" + + + +#### + +if [ "$THREAD" = "USE_THREADS" ] ; then + DEF=yes +else + DEF=no +fi + +ok=0 +echo "Do you want to compile Anope with threading support?" +echo "If you want to use the proxy detector, you MUST have this. If you get" +echo "compilation errors, you should disable this feature and try again." +while [ $ok -eq 0 ] ; do + echo2 "[$DEF] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$DEF + fi + case $INPUT in + n*|N*) + THREAD= + ok=1 + ;; + y*|Y*) + THREAD="USE_THREADS" + ok=1 + ;; + *) + echo "Please enter yes or no." + ;; + esac +done +echo "" + +if [ "$MYSQL" = "USE_MYSQL" ] ; then + DEF=yes +else + DEF=no +fi + +ok=0 +echo "Do you want to compile Anope with MySQL support?" +echo "At this time Anope is able to dump all databases into MySQL. That means" +echo "you get a read-only copy of the data. If you plan to run any module that" +echo "uses MySQL, you should enable this option as well." +while [ $ok -eq 0 ] ; do + echo2 "[$DEF] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$DEF + fi + case $INPUT in + n*|N*) + RDB= + MYSQL= + ok=1 + ;; + y*|Y*) + RDB="USE_RDB" + MYSQL="USE_MYSQL" + ok=1 + ;; + *) + echo "Please enter yes or no." + ;; + esac +done +echo "" + +#### + +if [ "$USE_MODULES" = "USE_MODULES" ] ; then + DEF=yes +else + DEF=no +fi + +ok=0 +echo "Do you want to compile Anope with Module support?" +echo "This will allow you to load and unload external modules of code without" +echo "restarting services. You can find several Anope modules on our website." +echo "This requires libdl, if you have problems compiling disable this option." +echo "(this option is ignored on OpenBSD for the time being)" +while [ $ok -eq 0 ] ; do + echo2 "[$DEF] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$DEF + fi + case $INPUT in + n*|N*) + USE_MODULES= + MODULE_PATH= + ok=1 + ;; + y*|Y*) + USE_MODULES="USE_MODULES" + ok=1 + ;; + *) + echo "Please enter yes or no." + ;; + esac +done +echo "" + +### +if [ "$USE_MODULES" = "USE_MODULES" ] ; then + if [ "$MODULE_PATH" ] ; then + DEF=$MODULE_PATH + else + DEF=$BINDEST/modules/ + fi + ok=0 + echo "Where do you want the modules installed? (The trailing / is important)" + while [ $ok -eq 0 ] ; do + echo2 "[$DEF] " + if read INPUT ; then : ; else echo "" ; exit 1 ; fi + if [ ! "$INPUT" ] ; then + INPUT=$DEF + fi + if [ ! -d "$INPUT" ] ; then + if exists "$INPUT" ; then + echo "$INPUT exists, but is not a directory!" + else + echo "$INPUT does not exist. Create it?" + echo2 "[y] " + read YN + if [ "$YN" != "n" ] ; then + if mkdir -p $INPUT ; then + ok=1 + fi + fi + fi + elif exists "$INPUT/services.h" ; then + echo "You cannot use the Services source directory as a target directory." + else + ok=1 + fi + if [ ! -d "$INPUT/runtime/" ] ; then + if mkdir -p $INPUT/runtime/ ; then + ok=1 + fi + fi + done + MODULE_PATH=$INPUT + echo "" +fi +echo "" + +### + +echo "End of interactive configuration." +echo "" + +########################################################################### + +# Set up log file for automated tests, so we have a clue what's going on if +# something dies. + +exec 3>configure.log + +MODE=" " +TEST="" +export MODE TEST + +########################################################################### + +# Search for a compiler. + +MODE="find_cc " +echo2 "Searching for a suitable compiler... " +if [ "$USER_CC" ] ; then + CC="$USER_CC" + echo "(supplied) using $CC." + log user supplied \`"$USER_CC'" +elif [ "$CC" ] ; then + echo "(cached) using $CC." + log cache supplied \`"$CC'" +elif run gcc --version ; then + echo "great, found gcc!" + CC=gcc + DEF_CC_FLAGS=-O2 + log using \`gcc\' +else + echo "gcc not found." + echo2 " Looking for alternatives... " + echo >tmp/test.c "int main(){return 1;}" + if run cc tmp/test.c -o tmp/test ; then + CC=cc + elif run c89 tmp/test.c -o tmp/test ; then + CC=c89 + else + echo "no C compiler found!" + echo " Use the -cc command line option to specify your C compiler." + log "automatic tests failed" + exit 2 + fi + # See if it handles ANSI. + cat >tmp/test.c <<EOT + int main(int argc, char **argv) { + extern void foo(int bar); + } +EOT + log "test for ANSI..." + if run $CC tmp/test.c -o tmp/test ; then + echo "using $CC." + log using \`"$CC'" + else + echo "found $CC, but it's not ANSI-compliant!" + echo " Use the -cc command line option to specify your C compiler." + log \`"$CC' not ANSI-compliant" + exit 2 + fi + DEF_CC_FLAGS=-O +fi + + +# Test compiler options. + +MODE="find_ccopts " +if [ "$USER_CC_FLAGS" != bonkle ] ; then + CC_FLAGS="$USER_CC_FLAGS" + echo "Compiler flags supplied: $CC_FLAGS" + log user supplied flags: \`"$CC_FLAGS'" +elif [ "$CC_FLAGS" != bonkle ] ; then + echo "Compiler flags: (cached) $CC_FLAGS" + log cache supplied flags: \`"$CC_FLAGS'" +else + CC_FLAGS=$DEF_CC_FLAGS + echo2 "Testing default compiler flags ($CC_FLAGS)... " + cat >tmp/test.c <<EOT + int main(int argc, char **argv) { + extern void foo(int bar); + } +EOT + if run $CC $CC_FLAGS -c tmp/test.c -o tmp/test.o ; then + echo "looks good." + else + echo "no luck! Using no flags." + echo " If you know what flags you want, use the -cflags option to configure." + CC_FLAGS= + fi + log using flags: \`"$CC_FLAGS'" +fi + +########################################################################### + +# Set linker flags. + +MODE="find_lflags " +if [ "$USER_CC_LFLAGS" != "bonkle" ] ; then + CC_LFLAGS=$USER_CC_LFLAGS + log user supplied \`"$CC_LFLAGS'" +elif [ "$CC_LFLAGS" != "bonkle" ] ; then + log cache supplied \`"$CC_LFLAGS'" +else + log using no flags + CC_LFLAGS="" +fi + +########################################################################### + +# See what libraries we have that we might need. + +MODE="find_libs " +echo2 "Let's see what libraries are lying around... " +if [ "$CC_LIBS" != bonkle ] ; then + if [ "$CC_LIBS" ] ; then + echo "(cached) $CC_LIBS" + else + echo "(cached) none" + fi + log cache supplied \`"$CC_LIBS'" +else + CC_LIBS= + if run $CC $CC_FLAGS tmp/test.c -lnsl -o tmp/test ; then + CC_LIBS="$CC_LIBS -lnsl" + echo2 "-lnsl " + fi + if run $CC $CC_FLAGS tmp/test.c -lsocket -o tmp/test ; then + CC_LIBS="$CC_LIBS -lsocket" + echo2 "-lsocket " + fi + if run $CC $CC_FLAGS tmp/test.c -lresolv -o tmp/test ; then + CC_LIBS="$CC_LIBS -lresolv" + echo2 "-lresolv " + fi + if run $CC $CC_FLAGS tmp/test.c -lbsd -o tmp/test ; then + CC_LIBS="$CC_LIBS -lbsd" + echo2 "-lbsd " + fi + + if [ "$THREAD" = "USE_THREADS" ] ; then + if run $CC $CC_FLAGS -D_REENTRANT tmp/test.c -pthread -o tmp/test ; then + CC_FLAGS="$CC_FLAGS -D_REENTRANT" + CC_LIBS="$CC_LIBS -pthread" + echo2 "-pthread " + elif run $CC $CC_FLAGS -D_REENTRANT tmp/test.c -lpthread -o tmp/test ; then + CC_FLAGS="$CC_FLAGS -D_REENTRANT" + CC_LIBS="$CC_LIBS -lpthread" + echo2 "-lpthread " + else + THREAD="" + echo "" + echo "Configure was not able to determine how to compile Anope" + echo "with threading support; disabled it." + fi + fi + + if [ "$MYSQL" = "USE_MYSQL" ] ; then + if [ "$MYSQL_LIB_DIR" = bonkle ] ; then + # Let's try to find it... + MYSQL_LIB_DIR="`mysql_config --libs 2> /dev/null | awk '{print $1}' | sed s/-L//g | sed s/\'//g`" + if [ -f "$MYSQL_LIB_DIR/libmysqlclient.so" ] ; then + MYSQL_LIB_DIR="$MYSQL_LIB_DIR" + elif [ -f "/usr/lib/libmysqlclient.so" ] ; then + MYSQL_LIB_DIR="/usr/lib" + elif [ -f "/usr/lib/mysql/libmysqlclient.so" ] ; then + MYSQL_LIB_DIR="/usr/lib/mysql" + elif [ -f "/usr/local/lib/mysql/libmysqlclient.so" ] ; then + MYSQL_LIB_DIR="/usr/local/lib/mysql" + else + echo "" + echo "Couldn't find default MySQL lib directory." + echo "Specify your MySQL lib directory manually." + echo "Run $0 with:" + echo "-with-mysql-libs /path/to/libmysqlclient.so" + echo "" + echo "Exiting..." + exit 4 + fi + else + if [ ! -f "${MYSQL_LIB_DIR}/libmysqlclient.so" ] ; then + echo "" + echo "Couldn't find MySQL library files. Check" + echo "that your MySQL lib directory is correct" + echo "Exiting..." + exit 4 + else + export LD_LIBRARY_PATH="${MYSQL_LIB_DIR}:${LD_LIBRARY_PATH}" + MYSQL_LIBDIR_WARN="MYSQL_LIBDIR_WARN" + fi + fi + + if [ "$MYSQL_INC_DIR" = bonkle ] ; then + # Same deal as before + MYSQL_INC_DIR="`mysql_config --cflags 2> /dev/null | sed s/-I//g | sed s/\'//g`" + if [ -d "$MYSQL_INC_DIR" ] && [ -f "$MYSQL_INC_DIR/mysql/mysql.h" ] ; then + MYSQL_INC_DIR="$MYSQL_INC_DIR" + elif [ -f "$MYSQL_INC_DIR/mysql.h" ] ; then + MYSQL_INC_DIR="$MYSQL_INC_DIR" + HAVE_MYSQL_MYSQL_H="HAVE_MYSQL_MYSQL_H" + elif [ -d "/usr/include/mysql" ] && [ -f "/usr/include/mysql/mysql.h" ] ; then + MYSQL_INC_DIR="/usr/include" + elif [ -f "/usr/include/mysql.h" ] ; then + MYSQL_INC_DIR="/usr/include" + HAVE_MYSQL_MYSQL_H="HAVE_MYSQL_MYSQL_H" + elif [ -d "/usr/local/include" ] && [ -f "/usr/local/include/mysql/mysql.h" ] ; then + MYSQL_INC_DIR="/usr/local/include" + elif [ -f "/usr/local/include/mysql.h" ] ; then + MYSQL_INC_DIR="/usr/local/include" + HAVE_MYSQL_MYSQL_H="HAVE_MYSQL_MYSQL_H" + else + echo "" + echo "Couldn't find default MySQL include directory." + echo "Specify your MySQL include directory manually." + echo "Run $0 with:" + echo "-with-mysql-includes /path/to/mysql.h" + echo "" + echo "Exiting..." + exit 4 + fi + else + if [ -f "${MYSQL_INC_DIR}/mysql/mysql.h" ] ; then + MYSQL_INC_DIR="${MYSQL_INC_DIR}/mysql" + HAVE_MYSQL_MYSQL_H="HAVE_MYSQL_MYSQL_H" + elif [ -f "${MYSQL_INC_DIR}/mysql.h" ] ; then + HAVE_MYSQL_MYSQL_H="HAVE_MYSQL_MYSQL_H" + else + echo "" + echo "Couldn't find MySQL include files. Check that" + echo "your MySQL include directory is correct." + echo "Exiting..." + exit 4 + fi + + fi + + if [ "$HAVE_MYSQL_MYSQL_H" = "HAVE_MYSQL_MYSQL_H" ] ; then + cat >tmp/test.c <<EOT + #include <mysql.h> + int main(void) { return 0; } +EOT + else + cat >tmp/test.c <<EOT + #include <mysql/mysql.h> + int main(void) { return 0; } +EOT + fi + + if run $CC $CC_FLAGS -I$MYSQL_INC_DIR -L$MYSQL_LIB_DIR -lmysqlclient tmp/test.c ; then + CC_LIBS="$CC_LIBS -L$MYSQL_LIB_DIR -lmysqlclient -lz" + CC_FLAGS="$CC_FLAGS -I$MYSQL_INC_DIR" + echo2 "-lmysqlclient " + else + echo "" + echo "Unable to compile with MySQL support. Check that the include" + echo "and library directories are correct." + exit 4 + fi + + fi + + echo "" + CC_LIBS="`echo $CC_LIBS | sed 's/^ +//'`" +fi + +if [ "$USER_CC_LIBS" ] ; then + CC_LIBS="$CC_LIBS $USER_CC_LIBS" + echo "Additional user-supplied libraries: $USER_CC_LIBS" + log user added \`"$USER_CC_LIBS'" +fi + + +if [ "$USE_MODULES" = "USE_MODULES" ] ; then + cat >tmp/test.c <<EOT + #include <dlfcn.h> + int main(void) { return RTLD_LOCAL; } +EOT + if run $CC $CC_FLAGS tmp/test.c ; then + HAS_RTLD_LOCAL="yes" + echo "has RTLD_LOCAL " + else + echo "no RTLD_LOCAL" + fi +fi + + + +########################################################################### + +# OS specific behaviour + +echo2 "Looking for OS specific needs... " +if [ "$OSTYPE" != bonkle ] ; then + if [ "$OSTYPE" = "LINUX20" ] ; then + echo2 "(cached) Linux 2.0 or 2.1 thread handling; " + fi + if [ "$OSTYPE" = "LINUX22" ] ; then + echo2 "(cached) Linux 2.2+ thread handling; " + fi + if [ "$OSTYPE" = "JAGUAR" ] ; then + echo2 "(cached) Jaguar (MacOS X 10.2.x); " + fi + if [ "$OSTYPE" = "MACOSX" ] ; then + echo2 "(cached) MacOS X (10.0.x, 10.1.x); " + fi +else + if [ "$THREAD" = "USE_THREADS" -a `uname -s` = "Linux" ] ; then + VER=`uname -r` + case $VER in + 2.0*|2.1*) + OSTYPE="LINUX20" + echo2 "Linux 2.0 or 2.1 thread handling; " + ;; + *) + OSTYPE="LINUX22" + echo2 "Linux 2.2+ thread handling; " + ;; + esac + else + if [ `uname -s` = "Darwin" ] ; then + VER=`uname -r` + case $VER in + 6.*) + OSTYPE="JAGUAR" + echo2 "Jaguar (MacOS X 10.2.x); " + ;; + *) + OSTYPE="MACOSX" + echo2 "MacOS X (10.0.x, 10.1.x); " + ;; + esac + fi + fi +fi + +echo "" + +########################################################################### + +# See what sizes various types are. + +MODE="check_int16 " +echo2 "Looking for a 16-bit integer type... " +if [ "$TYPE_INT16" ] ; then + echo "(cached) $TYPE_INT16" + log "cache supplied $TYPE_INT16" +else + cat >tmp/test.c <<EOT + int main() { + int a; + short b; + printf("%d %d", sizeof(a), sizeof(b)); + return 0; + } +EOT + if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test ; then + a="`tmp/test`" + log "test program output (sizeof(int) sizeof(short)): $a" + if [ ! "$a" ] ; then + echo "test program failed! Assuming short." + log "assuming short" + TYPE_INT16=short + else + size_int=`echo $a | cut -d\ -f1` + size_short=`echo $a | cut -d\ -f2` + if [ $size_int = 2 ] ; then + echo int + log "int is 16 bits" + TYPE_INT16=int + elif [ $size_short = 2 ] ; then + echo short + log "short is 16 bits" + TYPE_INT16=short + else + echo "none found?! Assuming short." + log "no 16-bit type found, assuming short" + TYPE_INT16=short + fi + fi + else + whoa_there + fi +fi + +MODE="check_int32 " +echo2 "Looking for a 32-bit integer type... " +if [ "$TYPE_INT32" ] ; then + echo "(cached) $TYPE_INT32" + log "cache supplied $TYPE_INT32" +else + cat >tmp/test.c <<EOT + int main() { + int a; + long b; + printf("%d %d", sizeof(a), sizeof(b)); + return 0; + } +EOT + if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test ; then + a="`tmp/test`" + log "test program output (sizeof(int) sizeof(long)): $a" + if [ ! "$a" ] ; then + echo "test program failed! Assuming long." + log "assuming long" + TYPE_INT32=long + else + size_int=`echo $a | cut -d\ -f1` + size_long=`echo $a | cut -d\ -f2` + if [ $size_int = 4 ] ; then + echo int + log "int is 32 bits" + TYPE_INT32=int + elif [ $size_long = 4 ] ; then + echo long + log "long is 32 bits" + TYPE_INT32=long + else + echo "none found?! Assuming long." + log "no 32-bit type found, assuming long" + TYPE_INT32=long + fi + fi + else + whoa_there + fi +fi + +########################################################################### + +# Look for include files that might or might not be here. +echo "Checking for presence of include files (it's okay if some aren't there):" + +MODE="check_strings " +echo2 " strings.h... " +if [ "$HAVE_STRINGS_H" ] ; then + if [ "$HAVE_STRINGS_H" = 1 ] ; then + echo "(cached) present" + log "cache says present" + else + echo "(cached) not present" + log "cache says not present" + fi +else + if test_include strings.h ; then + echo "present" + else + echo "not present" + fi +fi + +MODE="check_sysselect " +echo2 " sys/select.h... " +if [ "$HAVE_SYS_SELECT_H" ] ; then + if [ "$HAVE_SYS_SELECT_H" = 1 ] ; then + echo "(cached) present" + log "cache says present" + else + echo "(cached) not present" + log "cache says not present" + fi +else + if test_include sys/select.h ; then + echo "present" + else + echo "not present" + fi +fi + +MODE="check_sysproto " +echo2 " sys/sysproto.h... " +if [ "$HAVE_SYS_SYSPROTO_H" ] ; then + if [ "$HAVE_SYS_SYSPROTO_H" = 1 ] ; then + echo "(cached) present" + log "cache says present" + else + echo "(cached) not present" + log "cache says not present" + fi +else + if test_include sys/sysproto.h ; then + echo "present" + else + echo "not present" + fi +fi + +########################################################################### + +# AIX workaround. + +MODE="check_aix_intNN " +echo2 "Seeing if your system defines int16/int32... " +res="`run egrep int16\|int32 /usr/include/sys/systypes.h`" +if [ "$res" ] ; then + echo "found." + echo " (This is bad, but we can work around it.)" + log "int16/int32 types found, enabling workaround" + INTTYPE_WORKAROUND=1 +else + echo "not found (this is good)." + log "int16/int32 types not found" + INTTYPE_WORKAROUND=0 +fi + +########################################################################### + +# How to use gethostbyname_r() ... + +if [ "$THREAD" = "USE_THREADS" ] ; then + MODE="check_gethostbyname_r " + echo2 "Figuring out how to call gethostbyname_r on your system... " + + if [ "$HAVE_GETHOSTBYNAME_R" != "bonkle" ] ; then + if [ "$HAVE_GETHOSTBYNAME_R" = "HAVE_GETHOSTBYNAME_R6" ] ; then + echo "(cached) with 6 parameters." + log "cache supplied with 6 parameters." + elif [ "$HAVE_GETHOSTBYNAME_R" = "HAVE_GETHOSTBYNAME_R5" ] ; then + echo "(cached) with 5 parameters." + log "cache supplied with 5 parameters." + elif [ "$HAVE_GETHOSTBYNAME_R" = "HAVE_GETHOSTBYNAME_R3" ] ; then + echo "(cached) with 3 parameters." + log "cache supplied with 3 parameters." + else + THREAD= + echo "(cached) no compatible gethostbyname_r()" + log "cache supplied no compatible gethostbyna |
