]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Removed reference to depricated ./makeconf and updated command to exec to build the...
[user/henk/code/inspircd.git] / configure
index f15498b9ede0ab0df2626804fbddce7b793500b4..f8528dc13101de6375b51dac5ee758d17b076b96 100755 (executable)
--- a/configure
+++ b/configure
@@ -7,27 +7,26 @@
 #
 # $Id$
 #
-# Some shell code based on the configure script of IRC Services.
-# IRC Services is copyright (c) 1996-2002 Andrew Church. 
-# E-mail: <achurch@achurch.org>
-#
 #
 ########################################
 
-# echo -e "\033[1;37mtest\033[0;37m"
-
 echo "Configuring default values..."
 
 ME=`pwd`
 GCCVER=`gcc -dumpversion | cut -c 1`
+GCC34=`gcc -dumpversion | cut -c 3`
 CONFIG_DIR=$ME/conf
 MODULE_DIR=$ME/modules
 BINARY_DIR=$ME/bin
+INSTALL=`which install`
+OPTIMITEMP=0
+OPTIMISATI="-g"
 MAX_CLIENT_T=`ulimit -n`
 NICK_LENGT=32
 CHAN_LENGT=64
 MAX_CHANNE=20
 MAXI_MODES=20
+OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"
 
 if [ -z $MAX_CLIENT_T ] ; then
         MAX_CLIENT_T=1024
@@ -43,7 +42,55 @@ if [ -e ".config.cache" -a -z "$CLEAN" ] ; then
     . .config.cache 
 fi
 
-OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"
+if [ "$1" = "-update" -o "$2" = "-update" ] ; then
+   # They wanna update their Makefile.. good for 'em
+   # Make sure .config.cache exists
+   if [ ! -e ".config.cache" ] ; then
+     echo "You have not run ./configure before. Please do this before trying to run the update script."
+     exit 0
+   fi
+   # Right, load the cache values
+   . .config.cache
+   # Check for modules
+
+   case "$OSNAME" in
+           FreeBSD)
+                   LDLIBS="-Ldl"
+                   FLAGS="-fPIC -frtti $OPTIMISATI"
+                   MAKEPROG="gmake"
+                   ;;
+           *)
+                   LDLIBS="-ldl"
+                   FLAGS="-fPIC -frtti $OPTIMISATI"
+                   MAKEPROG="make"
+                   ;;
+   esac
+
+   MODULES=""
+   for module in src/modules/*.cpp ; do
+           mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
+           MODULES="$MODULES $mod"
+   done
+
+   # Write the new makefile.
+   for file in Makefile; do
+          echo -e "\033[0;37mWriting \033[1;32m$file\033[0;37m"
+          rm -f $file
+          sed -e "
+                  s%@MAKEPROG@%$MAKEPROG%g
+                  s%@FLAGS@%$FLAGS%g
+                  s%@LDLIBS@%$LDLIBS%g
+                  s%@CONFIG_DIR@%$CONFIG_DIR%g
+                  s%@MODULE_DIR@%$MODULE_DIR%g
+                  s%@BINARY_DIR@%$BINARY_DIR%g
+                  s%@MODULES@%$MODULES%g
+          " .${file}.inc >> $file
+   done
+   echo "Complete."
+   exit 1; 
+fi
+
+
 if [ -z $MAX_CLIENT ] ; then
         MAX_CLIENT=$MAX_CLIENT_T
 fi
@@ -51,7 +98,7 @@ fi
 
 c=""
 n=""
-if [ "`eval echo -n 'a'`" = "-n a" ] ; then
+if [ "`eval echo -e -n 'a'`" = "-n a" ] ; then
         c="\c"
 else
         n="-n"
@@ -65,6 +112,13 @@ exists () { # because some shells don't have test -e
     fi
 }
 
+echo "#include <string.h>">.test.cpp
+echo "#include <stdio.h>">>.test.cpp
+echo "int main() { char a[10]; char b[10]; strlcpy(a,b,10); printf(\"%d\\n\",999); }" >>.test.cpp
+g++ -o .test .test.cpp 2>&1
+HAS_STRLCPY=`./.test 2>&1`
+rm -f .test.cpp .test
+
 clear
 echo -e "'\033[1;33m####\033[0;37m:'\033[1;33m##\033[0;37m::: \033[1;33m##\033[0;37m::'\033[1;33m######\033[0;37m::'\033[1;33m########\033[0;37m::'\033[1;33m####\033[0;37m:'\033[1;33m########\033[0;37m:::'\033[1;33m######\033[0;37m::'\033[1;33m########\033[0;37m::"
 echo -e ". \033[1;33m##\033[0;37m:: \033[1;33m###\033[0;37m:: \033[1;33m##\033[0;37m:'\033[1;33m##\033[0;37m... \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:. \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:'\033[1;33m##\033[0;37m... \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:"
@@ -313,6 +367,42 @@ echo ""
   echo ""
 
 ###############################################################################
+# Code Optimisation?
+
+  cheeze=0
+  echo -e "Enter the Level Of Binary optimisation. This is a number between 0 and 3 (inclusive)"
+  echo -e "The InspIRCd Team will _NOT_ support any bug reports above 0."
+  echo -e "Also note, the IRCd behaviour will be different depending on this value."
+  echo -e "Please read the documentation for more information."
+  echo -e ""
+  echo -e "The Higher the number, the more optimised your binary will be. This value will default to 0"
+  echo -e "If you either a) Dont enter a number, or b) Enter a value outside the range."
+  echo -e $n "[\033[1;32m$OPTIMITEMP\033[0;37m] -> $c"
+  read cc
+  if [ -z "$cc" ] ; then
+       cc=$OPTIMITEMP
+  fi
+  case "$cc" in
+        1)
+                OPTIMITEMP=1
+               OPTIMISATI="-O"
+                ;;
+       2)
+               OPTIMITEMP=2
+               OPTIMISATI="-O2"
+               ;;
+       3)
+               OPTIMITEMP=3
+               OPTIMISATI="-O3"
+               ;;
+       *)
+                OPTIMITEMP=0
+                OPTIMISATI="-g"
+                ;;
+  esac
+  echo ""
+
+###############################################################################
 
 
 echo -e "\033[1;32mPre-build configuration is complete!\033[0;37m"
@@ -324,10 +414,18 @@ echo -e "\033[0;37mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
 echo -e "\033[0;37mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
 echo -e "\033[0;37mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
 echo -e "\033[0;37mMax mode length:\033[1;32m\t\t$MAXI_MODES"
-echo -e "\033[0;37mGCC Version Found:\033[1;32m\t\t$GCCVER"
+echo -e "\033[0;37mGCC Version Found:\033[1;32m\t\t$GCCVER.$GCC34"
+echo -e "\033[0;37mOptimatizaton Flag:\033[1;32m\t\t$OPTIMISATI"
 echo -e "\033[0;37m"
 
 echo "Writing cache file for future ./configures ..."
+
+COPY_CONF=0
+if [ "$CONFIG_DIR" != "$ME/conf" ] ; then
+    COPY_CONF=1
+fi
+
+
 if [ -e ".config.cache" ] ; then
        rm .config.cache
 fi
@@ -338,15 +436,24 @@ echo "MAX_CLIENT=\"$MAX_CLIENT\"" >> .config.cache
 echo "MAX_CHANNE=\"$MAX_CHANNE\"" >> .config.cache
 echo "NICK_LENGT=\"$NICK_LENGT\"" >> .config.cache
 echo "MAXI_MODES=\"$MAXI_MODES\"" >> .config.cache 
+echo "OPTIMITEMP=\"$OPTIMITEMP\"" >> .config.cache
+echo "OPTIMISATI=\"$OPTIMISATI\"" >> .config.cache
+echo "GCC34=\"$GCC34\"" >> .config.cache
+echo "HAS_STRLCPY=\"$HAS_STRLCPY\"" >> .config.cache
+echo "COPY_CONF=\"$COPY_CONF\"" >> .config.cache
 
-
-
-echo "Writing include/inspircd_config.h ..."
+echo -e "Writing \033[1;32minspircd_config.h"
 
 echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
 echo "" >>include/inspircd_config.h
 if [ "$GCCVER" -eq "3" ] ; then
 echo "#define GCC3" >>include/inspircd_config.h
+       if [ "$GCC34" -gt "3" ] ; then
+               echo "#define GCC34" >>include/inspircd_config.h
+       fi
+fi
+if [ "$HAS_STRLCPY" -eq "999" ] ; then
+       echo "#define HAS_STRLCPY" >>include/inspircd_config.h
 fi
 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
 echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
@@ -358,20 +465,21 @@ echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
 echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
 echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
 echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
+echo "#define OPTIMISATION $OPTIMITEMP" >>include/inspircd_config.h
 echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
 echo "#define MAXBUF 514">>include/inspircd_config.h
 touch include/inspircd_config.h
 
-echo "Preparing Variables for the Makefile"
-
 case "$OSNAME" in
-       (FreeBSD)
+       FreeBSD)
                LDLIBS="-Ldl"
-               FLAGS="-fPIC -frtti -O3"
+               FLAGS="-fPIC -frtti $OPTIMISATI"
+               MAKEPROG="gmake"
                ;;
-       (*)
+       *)
                LDLIBS="-ldl"
-               FLAGS="-fPIC -frtti -O3"
+               FLAGS="-fPIC -frtti $OPTIMISATI"
+               MAKEPROG="make"
                ;;
 esac
 
@@ -381,10 +489,21 @@ for module in src/modules/*.cpp ; do
        MODULES="$MODULES $mod" 
 done
 
-echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
-echo ""
+for file in Makefile inspircd; do
+       echo -e "\033[0;37mWriting \033[1;32m$file\033[0;37m"
+       rm -f $file
+       sed -e "
+               s%@MAKEPROG@%$MAKEPROG%g
+               s%@FLAGS@%$FLAGS%g
+               s%@LDLIBS@%$LDLIBS%g
+               s%@CONFIG_DIR@%$CONFIG_DIR%g
+               s%@MODULE_DIR@%$MODULE_DIR%g
+               s%@BINARY_DIR@%$BINARY_DIR%g
+               s%@MODULES@%$MODULES%g
+       " .${file}.inc >> $file
+done
 
-. .Makefile.inc
+`chmod 700 inspircd`
 
 echo ""
 
@@ -397,29 +516,15 @@ if [ "$YN" != "n" ] ; then
        echo -e "\033[1;32mCompiling...\033[0;37m"
        echo ""
        cd $ME
-       make
+       $MAKEPROG
        echo ""
         echo "Done!"
-        echo ""
 else
        echo ""
-       echo "Done!"
-       echo ""
-       echo -e "To build your server with these settings, please type '\033[1;32mmake\033[0;37m' now."
-       echo ""
-       echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
-       echo ""
+       echo -e "To build your server with these settings, please type '\033[1;32m$MAKEPROG\033[0;37m' now."
 fi
 
 
 echo ""
-echo "Do you want to run the config file maker?"
-echo -e $n "[\033[1;32my\033[0;37m] $c"
-read YN
-if [ "$YN" != "n" ] ; then
-       sh makeconf
-fi
-
 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
 echo ""
-