]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Removed 'irregular' output caused by Brains test for strlcpy
[user/henk/code/inspircd.git] / configure
index 393943ef61b876e6c2fd468952a187191f8026b7..258ed77b6b8a5d216d298c13d0fff0226b4ca513 100755 (executable)
--- a/configure
+++ b/configure
@@ -54,12 +54,12 @@ if [ "$1" = "-update" -o "$2" = "-update" ] ; then
    # Check for modules
 
    case "$OSNAME" in
-           (FreeBSD)
+           FreeBSD)
                    LDLIBS="-Ldl"
                    FLAGS="-fPIC -frtti $OPTIMISATI"
                    MAKEPROG="gmake"
                    ;;
-           (*)
+           *)
                    LDLIBS="-ldl"
                    FLAGS="-fPIC -frtti $OPTIMISATI"
                    MAKEPROG="make"
@@ -73,7 +73,47 @@ if [ "$1" = "-update" -o "$2" = "-update" ] ; then
    done
 
    # Write the new makefile.
-   . .Makefile.inc
+   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 -e "\033[0;37mWriting \033[1;32msrc/modules/Makefile\033[0;37m"
+   rm -f src/modules/Makefile
+
+   # Generate the Header..
+
+   echo "# (C) ChatSpike development team" >> src/modules/Makefile
+   echo "# Makefile by <Craig@ChatSpike.net>" >> src/modules/Makefile
+   echo "# Many Thanks to Andrew Church <achurch@achurch.org>" >> src/modules/Makefile
+   echo "#    for assisting with making this work right." >> src/modules/Makefile
+   echo "#" >> src/modules/Makefile
+   echo "# Automatically Generated by ./configure to add a module" >> src/modules/Makefile
+   echo "# please run ./configure --update" >> src/modules/Makefile
+   echo "" >> src/modules/Makefile
+   echo "all: \$(MODULES)" >> src/modules/Makefile
+   echo "" >> src/modules/Makefile
+
+
+   for module in src/modules/*.cpp ; do
+        flags=`grep '$CompileFlags: ' $module | sed 's/\/\* $CompileFlags://' | sed 's/\*\///'`
+        mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
+       mod2=`echo $module | sed 's/src\/modules\///'`
+        echo "$mod: $mod2 ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h" >> src/modules/Makefile
+        echo " \$(CC) -I../../include \$(FLAGS) -shared$flags -o $mod $mod2" >> src/modules/Makefile
+       echo "  @cp $mod \$(MODPATH)/" >> src/modules/Makefile
+        echo "" >> src/modules/Makefile
+   done
+
+
    echo "Complete."
    exit 1; 
 fi
@@ -102,9 +142,11 @@ exists () { # because some shells don't have test -e
 
 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
-HAS_STRLCPY=`./.test`
+echo "int main() { char a[10]; char b[10]; strlcpy(a,b,10); printf(\"%d\\n\",9); }" >>.test.cpp
+g++ -o .test .test.cpp 2>&1
+if [ ! -e ".test" ] ; then
+       HAS_STRLCPY=1
+fi 
 rm -f .test.cpp .test
 
 clear
@@ -371,19 +413,19 @@ echo ""
        cc=$OPTIMITEMP
   fi
   case "$cc" in
-        (1)
+        1)
                 OPTIMITEMP=1
                OPTIMISATI="-O"
                 ;;
-       (2)
+       2)
                OPTIMITEMP=2
                OPTIMISATI="-O2"
                ;;
-       (3)
+       3)
                OPTIMITEMP=3
                OPTIMISATI="-O3"
                ;;
-       (*)
+       *)
                 OPTIMITEMP=0
                 OPTIMISATI="-g"
                 ;;
@@ -408,6 +450,7 @@ 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
@@ -429,7 +472,7 @@ 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
@@ -439,7 +482,7 @@ echo "#define GCC3" >>include/inspircd_config.h
                echo "#define GCC34" >>include/inspircd_config.h
        fi
 fi
-if [ "$HAS_STRLCPY" -eq "999" ] ; then
+if [ $HAS_STRLCPY != "1" ] ; then
        echo "#define HAS_STRLCPY" >>include/inspircd_config.h
 fi
 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
@@ -457,15 +500,13 @@ 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 $OPTIMISATI"
                MAKEPROG="gmake"
                ;;
-       (*)
+       *)
                LDLIBS="-ldl"
                FLAGS="-fPIC -frtti $OPTIMISATI"
                MAKEPROG="make"
@@ -478,10 +519,47 @@ 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
+`chmod 700 inspircd`
+
+echo -e "\033[0;37mWriting \033[1;32msrc/modules/Makefile\033[0;37m"
+rm -f src/modules/Makefile
+
+# Generate the Header..
+
+echo "# (C) ChatSpike development team" >> src/modules/Makefile
+echo "# Makefile by <Craig@ChatSpike.net>" >> src/modules/Makefile
+echo "# Many Thanks to Andrew Church <achurch@achurch.org>" >> src/modules/Makefile
+echo "#    for assisting with making this work right." >> src/modules/Makefile
+echo "#" >> src/modules/Makefile
+echo "# Automatically Generated by ./configure to add a module" >> src/modules/Makefile
+echo "# please run ./configure --update" >> src/modules/Makefile
+echo "" >> src/modules/Makefile
+echo "all: \$(MODULES)" >> src/modules/Makefile
+echo "" >> src/modules/Makefile
+
+for module in src/modules/*.cpp ; do
+     flags=`grep '$CompileFlags: ' $module | sed 's/\/\* $CompileFlags://' | sed 's/\*\///'`
+     mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
+     mod2=`echo $module | sed 's/src\/modules\///'`
+     echo "$mod: $mod2 ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h" >> src/modules/Makefile
+     echo "    \$(CC) -I../../include \$(FLAGS) -shared$flags -o $mod $mod2" >> src/modules/Makefile
+     echo "    @cp $mod \$(MODPATH)/" >> src/modules/Makefile
+     echo "" >> src/modules/Makefile
+done
 
-. .Makefile.inc
 
 echo ""
 
@@ -497,25 +575,12 @@ if [ "$YN" != "n" ] ; then
        $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 ""