]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - configure
Added Support for GCC 2 back.
[user/henk/code/inspircd.git] / configure
1 #!/bin/sh
2 # InspIRCd Configuration Script
3 #
4 # Copyright 2003 The ChatSpike Development Team
5 # <brain@chatspike.net>
6 # <Craig@chatspike.net>
7 #
8 # $Id$
9 #
10 # Some shell code based on the configure script of IRC Services.
11 # IRC Services is copyright (c) 1996-2002 Andrew Church. 
12 # E-mail: <achurch@achurch.org>
13 #
14 #
15 ########################################
16
17 # echo -e "\033[1;37mtest\033[0;37m"
18
19 echo "Configuring default values..."
20 mkdir fdscount
21 echo "#include <sys/types.h>" >> fdscount/fdcounter.c
22 echo "#include <sys/socket.h>" >> fdscount/fdcounter.c
23 echo "main()" >> fdscount/fdcounter.c
24 echo "{" >> fdscount/fdcounter.c
25 echo "        int  i;" >> fdscount/fdcounter.c
26 echo "        int  s;" >> fdscount/fdcounter.c
27 echo "" >> fdscount/fdcounter.c
28 echo "        for (i = 1; i <= 10000; i++)" >> fdscount/fdcounter.c
29 echo "        {" >> fdscount/fdcounter.c
30 echo "                s = socket(AF_INET, SOCK_STREAM, 0);" >> fdscount/fdcounter.c
31 echo "                if (s < 0)" >> fdscount/fdcounter.c
32 echo "                {" >> fdscount/fdcounter.c
33 echo "                        printf(\"%i\", i + 2);" >> fdscount/fdcounter.c
34 echo "                  exit(-1);" >> fdscount/fdcounter.c
35 echo "                }" >> fdscount/fdcounter.c
36 echo "        }" >> fdscount/fdcounter.c
37 echo "}" >> fdscount/fdcounter.c
38
39 echo "PROGS     = fdcounter" >> fdscount/Makefile
40 echo "OBJS = fdcounter.o" >> fdscount/Makefile
41 echo "" >> fdscount/Makefile
42 echo "CC = gcc" >> fdscount/Makefile
43 echo "CXXFLAGS = -fPIC -frtti -O" >> fdscount/Makefile
44 echo "" >> fdscount/Makefile
45 echo "all : \$(PROGS)" >> fdscount/Makefile
46 echo "" >> fdscount/Makefile
47 echo "\$(PROGS): \$(OBJS)" >> fdscount/Makefile
48 echo "  \$(CXX) -rdynamic \$^ -o \$@" >> fdscount/Makefile
49 echo "" >> fdscount/Makefile
50 echo ".PHONY: clean" >> fdscount/Makefile
51 echo "clean:" >> fdscount/Makefile
52 echo "  rm -f *.o core" >> fdscount/Makefile
53
54 cd fdscount
55 make >> /dev/null
56 cd ..
57
58 ME=`pwd`
59 GCCVER=`gcc -dumpversion | cut -c 1`
60 CONFIG_DIR=$ME/conf
61 MODULE_DIR=$ME/modules
62 MAX_CLIENT=`fdscount/fdcounter`
63 NICK_LENGT=32
64 CHAN_LENGT=64
65 MAX_CHANNE=20
66 MAXI_MODES=20
67
68 rm -rf fdscount
69
70 if [ -z $MAX_CLIENT ] ; then
71         MAX_CLIENT=1024
72         SCAN_FAILED=1
73 fi
74
75 if [ "$1" = "-clean" -o "$2" = "-clean" ] ; then
76   `rm -rf config.cache`
77 fi
78
79 if [ -e "config.cache" -a -z "$CLEAN" ] ; then
80     . config.cache 
81 fi
82
83 OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"
84
85
86 c=""
87 n=""
88 if [ "`eval echo -n 'a'`" = "-n a" ] ; then
89         c="\c"
90 else
91         n="-n"
92 fi
93
94 exists () { # because some shells don't have test -e
95     if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
96         return 0
97     else
98         return 1
99     fi
100 }
101
102 clear
103 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::"
104 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:"
105 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:"
106 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:"
107 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:"
108 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:"
109 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::"
110 echo -e "\033[0;37m\033[0;37m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::"
111 echo ""
112 echo -e "\033[1;37mWelcome to the InspIRCd Configuration program!"
113 echo ""
114 echo "*** If you are unsure of any of these values, leave it blank for    ***"
115 echo "*** standard settings that will work, and your server will run      ***"
116 echo "*** using them. If you are running this server as part of a         ***"
117 echo "*** larger network, you must consult with your network admins       ***"
118 echo "*** for the proper values to use, or server links will be unstable! ***"
119 echo -e "\033[0;37m"
120 echo -e "Press \033[1;37m<RETURN>\033[0;37m to accept the default for any option, or enter"
121 echo -e "a new value. Please note: You will \033[1;37mHAVE\033[0;37m to read the docs"
122 echo -e "dir, otherwise you won't have a config file!"
123 echo ""
124 echo -e "Your operating system is: \033[1;37m$OSNAME\033[0;37m (`uname -mnr`), fdmax: $MAX_CLIENT"
125 echo ""
126
127 #############################################################################
128
129     ok=0
130     asked=1
131     echo "In what directory are the configuration files?"
132     while [ $ok -eq 0 ] ; do
133         echo -e $n "[\033[1;32m$CONFIG_DIR\033[0;37m] -> $c"
134         if read INPUT ; then : ; else echo "" ; exit 1 ; fi
135         if [ ! "$INPUT" ] ; then
136             INPUT=$CONFIG_DIR
137             default=1
138         fi
139         if echo "$INPUT" | grep -q \[\'\"\\\] ; then
140             echo 'Please use a pathname without the characters: '\'' " \'
141         elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
142             if exists "$INPUT" ; then
143                 echo "$INPUT exists, but is not a directory!"
144             else
145                 echo "$INPUT does not exist.  Create it?"
146                 echo -e $n "[\033[1;32my\033[0;37m] $c"
147                 read YN
148                 if [ "$YN" != "n" ] ; then
149                     if mkdir -p "$INPUT" ; then
150                         ok=1
151                     fi
152                 fi
153             fi
154             else
155             ok=1
156         fi
157     done
158     CONFIG_DIR=$INPUT
159     echo ""
160
161
162 ##############################################################################
163
164     ok=0
165     asked=1
166     echo "In What directory are the modules to be compiled to?"
167     while [ $ok -eq 0 ] ; do
168         echo -e $n "[\033[1;32m$MODULE_DIR\033[0;37m] -> $c"
169         if read INPUT ; then : ; else echo "" ; exit 1 ; fi
170         if [ ! "$INPUT" ] ; then
171             INPUT=$MODULE_DIR
172             default=1
173         fi
174         if echo "$INPUT" | grep -q \[\'\"\\\] ; then
175             echo 'Please use a pathname without the characters: '\'' " \'
176         elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
177             if exists "$INPUT" ; then
178                 echo "$INPUT exists, but is not a directory!"
179             else
180                 echo "$INPUT does not exist.  Create it?"
181                 echo -e $n "[\033[1;32my\033[0;37m] $c"
182                 read YN
183                 if [ "$YN" != "n" ] ; then
184                     if mkdir -p "$INPUT" ; then
185                         ok=1
186                     fi
187                 fi
188             fi
189             else
190             ok=1
191         fi
192     done
193     MODULE_DIR=$INPUT
194     echo ""
195
196
197 ###############################################################################
198 # Craigs Version 2 With Extra Cheeze :p
199
200   cheeze=0
201   echo -e "Maximum number of clients at any one time (\033[1;32m1-$MAX_CLIENT\033[0;37m)?"
202   while [ "$cheeze" -eq "0" ] ; do
203         echo -e $n "[\033[1;32m$MAX_CLIENT\033[0;37m] -> $c"
204         read cc
205         if [ "$cc" ] ; then
206                 case "$cc" in
207                         [0-9]*)
208                         if [ "$cc" > "$MAX_CLIENT" ] ; then
209                                 ASK=1
210                         else
211                                 MAX_CLIENT=$cc
212                         fi
213                         cheeze=1
214                         ;;
215                         *)
216                         echo ""
217                         echo "You Must Enter a Number in this field. Please Try Again."
218                         cheeze=0
219                         ;;
220                 esac
221         else
222                 cheeze=1
223         fi
224         if [ "$cheeze" -eq "1" ] ; then
225                 if [ -z "$SCAN_FAILED" ] ; then
226                         if [ "$ASK" -eq "1" ] ; then
227                                 echo "WARNING: Our scans have indicated that you are"
228                                 echo "         Attempting to use more sockets than"
229                                 echo "         there are avaliable, do you wish to"
230                                 echo "         do this? [y/n]"
231                                 echo -e $n "[\033[1;32mn\033[0;37m] $c"
232                                 read YN
233                                 if [ "$YN" == "y" ] ; then
234                                         MAX_CLIENT=$cc
235                                 else
236                                         cheeze=0
237                                         echo ""
238                                         echo "Please Enter the Correct number of sockets:"
239                                 fi
240                         fi
241                 fi
242         fi
243   done
244   echo ""
245
246 ###############################################################################
247
248   cheeze=0
249   echo -e "What is the Maximum length of nicknames?"
250   while [ "$cheeze" -eq "0" ] ; do
251         echo -e $n "[\033[1;32m$NICK_LENGT\033[0;37m] -> $c"
252         read cc
253         if [ "$cc" ] ; then
254                 case "$cc" in
255                         [0-9]*)
256                         NICK_LENGT=$cc
257                         cheeze=1
258                         ;;
259                         *)
260                         echo ""
261                         echo "You Must Enter a Number in this field. Please Try Again."
262                         cheeze=0
263                         ;;
264                 esac
265         else
266                 cheeze=1
267         fi
268   done
269   echo ""
270
271 ###############################################################################
272
273   cheeze=0
274   echo -e "What is the Maximum length of channel names?"
275   while [ "$cheeze" -eq "0" ] ; do
276         echo -e $n "[\033[1;32m$MAX_CHANNE\033[0;37m] -> $c"
277         read cc
278         if [ "$cc" ] ; then
279                 case "$cc" in
280                         [0-9]*)
281                         MAX_CHANNE=$cc
282                         cheeze=1
283                         ;;
284                         *)
285                         echo ""
286                         echo "You Must Enter a Number in this field. Please Try Again."
287                         cheeze=0
288                         ;;
289                 esac
290         else
291                 cheeze=1
292         fi
293   done
294   echo ""
295
296 ###############################################################################
297
298   cheeze=0
299   echo -e "What is the Maximum number of mode changes in one line?"
300   while [ "$cheeze" -eq "0" ] ; do
301         echo -e $n "[\033[1;32m$MAXI_MODES\033[0;37m] -> $c"
302         read cc
303         if [ "$cc" ] ; then
304                 case "$cc" in
305                         [0-9]*)
306                         MAXI_MODES=$cc
307                         cheeze=1
308                         ;;
309                         *)
310                         echo ""
311                         echo "You Must Enter a Number in this field. Please Try Again."
312                         cheeze=0
313                         ;;
314                 esac
315         else
316                 cheeze=1
317         fi
318   done
319   echo ""
320
321 ###############################################################################
322
323
324 echo -e "\033[1;32mPre-build configuration is complete!\033[0;37m"
325 echo ""
326 echo -e "\033[0;37mConfig path:\033[1;32m\t\t\t$CONFIG_DIR"
327 echo -e "\033[0;37mModule path:\033[1;32m\t\t\t$MODULE_DIR"
328 echo -e "\033[0;37mMax connections:\033[1;32m\t\t$MAX_CLIENT"
329 echo -e "\033[0;37mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
330 echo -e "\033[0;37mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
331 echo -e "\033[0;37mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
332 echo -e "\033[0;37mMax mode length:\033[1;32m\t\t$MAXI_MODES"
333 echo -e "\033[0;37mGCC Version Found:\033[1;32m\t\t$GCCVER"
334 echo -e "\033[0;37m"
335
336 echo "Writing cache file for future ./configures ..."
337 if [ -e "config.cache" ] ; then
338         rm config.cache
339 fi
340 echo "CONFIG_DIR=\"$CONFIG_DIR\"" >> config.cache
341 echo "MODULE_DIR=\"$MODULE_DIR\"" >> config.cache
342 echo "MAX_CLIENT=\"$MAX_CLIENT\"" >> config.cache
343 echo "MAX_CHANNE=\"$MAX_CHANNE\"" >> config.cache
344 echo "NICK_LENGT=\"$NICK_LENGT\"" >> config.cache
345 echo "MAXI_MODES=\"$MAXI_MODES\"" >> config.cache 
346
347
348
349 echo "Writing include/inspircd_config.h ..."
350
351 echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
352 echo "" >>include/inspircd_config.h
353 if [ "$GCCVER" -eq "3" ] ; then
354 echo "#define GCC3" >>include/inspircd_config.h
355 fi
356 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
357 echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
358 echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
359 echo "#define MOD_PATH \"$MODULE_DIR\"" >>include/inspircd_config.h
360 echo "#define VERSION \"`sh ./src/version.sh`\"" >>include/inspircd_config.h
361 echo "#define MAXCLIENTS $MAX_CLIENT" >>include/inspircd_config.h
362 echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
363 echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
364 echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
365 echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
366 echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
367 echo "#define MAXBUF 514">>include/inspircd_config.h
368
369 touch include/inspircd_config.h
370
371 echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
372 echo ""
373
374 if exists "Makefile.$OSNAME" ; then
375         echo "Operating system supported."
376 else
377         echo "Your operating system, \"$OSNAME\", is not supported!"
378         exit
379 fi
380
381 echo ""
382
383 cp -f Makefile.$OSNAME Makefile
384 cp -f src/Makefile.$OSNAME src/Makefile
385 cp -f src/modules/Makefile.$OSNAME src/modules/Makefile
386
387 echo ""
388 echo "Do you want to compile the IRCd binaries?"
389 echo -e $n "[\033[1;32my\033[0;37m] $c"
390 read YN
391 if [ "$YN" != "n" ] ; then
392         echo ""
393         echo -e "\033[1;32mCompiling...\033[0;37m"
394         echo ""
395         cd $ME
396         make
397         echo ""
398         echo "Done!"
399         echo ""
400 else
401         echo ""
402         echo "Done!"
403         echo ""
404         echo -e "To build your server with these settings, please type '\033[1;32mmake\033[0;37m' now."
405         echo ""
406         echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
407         echo ""
408 fi
409
410
411 echo ""
412 echo "Do you want to run the config file maker?"
413 echo -e $n "[\033[1;32my\033[0;37m] $c"
414 read YN
415 if [ "$YN" != "n" ] ; then
416         sh makeconf
417 fi
418
419 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
420 echo ""
421