]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/configure.pm
Remove the last uses of localised fake clients. This removes a lot of allocations...
[user/henk/code/inspircd.git] / make / configure.pm
1 #       +------------------------------------+
2 #       | Inspire Internet Relay Chat Daemon |
3 #       +------------------------------------+
4 #
5 #  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 # See: http://www.inspircd.org/wiki/index.php/Credits
7 #
8 # This program is free but copyrighted software; see
9 #      the file COPYING for details.
10 #
11 # ---------------------------------------------------
12
13 package make::configure;
14
15 require 5.8.0;
16
17 use Exporter 'import';
18 use POSIX;
19 use make::utilities;
20 @EXPORT = qw(promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies resolve_directory yesno showhelp promptstring_s);
21
22 my $no_svn = 0;
23
24 sub yesno {
25         my ($flag,$prompt) = @_;
26         print "$prompt [\033[1;32m$main::config{$flag}\033[0m] -> ";
27         chomp($tmp = <STDIN>);
28         if ($tmp eq "") { $tmp = $main::config{$flag} }
29         if (($tmp eq "") || ($tmp =~ /^y/i))
30         {
31                 $main::config{$flag} = "y";
32         }
33         else
34         {
35                 $main::config{$flag} = "n";
36         }
37         return;
38 }
39
40 sub resolve_directory
41 {
42         my $ret = $_[0];
43         eval
44         {
45                 use File::Spec;
46                 $ret = File::Spec->rel2abs($_[0]);
47         };
48         return $ret;
49 }
50
51 sub getrevision {
52         if ($no_svn)
53         {
54                 return "0";
55         }
56         my $data = `svn info`;
57         if ($data eq "")
58         {
59                 $no_svn = 1;
60                 $rev = "0";
61                 return $rev;
62         }
63         $data =~ /Revision: (\d+)/;
64         my $rev = $1;
65         if (!defined($rev))
66         {
67                 $rev = "0";
68         }
69         return $rev;
70 }
71
72 sub getcompilerflags {
73         my ($file) = @_;
74         open(FLAGS, $file);
75         while (<FLAGS>) {
76                 if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
77                         close(FLAGS);
78                         return translate_functions($1,$file);
79                 }
80         }
81         close(FLAGS);
82         return undef;
83 }
84
85 sub getlinkerflags {
86         my ($file) = @_;
87         open(FLAGS, $file);
88         while (<FLAGS>) {
89                 if ($_ =~ /^\/\* \$LinkerFlags: (.+) \*\/$/) {
90                         close(FLAGS);
91                         return translate_functions($1,$file);
92                 }
93         }
94         close(FLAGS);
95         return undef;
96 }
97
98 sub getdependencies {
99         my ($file) = @_;
100         open(FLAGS, $file);
101         while (<FLAGS>) {
102                 if ($_ =~ /^\/\* \$ModDep: (.+) \*\/$/) {
103                         close(FLAGS);
104                         return translate_functions($1,$file);
105                 }
106         }
107         close(FLAGS);
108         return undef;
109 }
110
111
112 sub getmodules
113 {
114         my $i = 0;
115         print "Detecting modules ";
116         opendir(DIRHANDLE, "src/modules");
117         foreach $name (sort readdir(DIRHANDLE))
118         {
119                 if ($name =~ /^m_(.+)\.cpp$/)
120                 {
121                         $mod = $1;
122                         $main::modlist[$i++] = $mod;
123                         print ".";
124                 }
125         }
126         closedir(DIRHANDLE);
127         print "\nOk, $i modules.\n";
128 }
129
130 sub promptnumeric($$)
131 {
132         my $continue = 0;
133         my ($prompt, $configitem) = @_;
134         while (!$continue)
135         {
136                 print "Please enter the maximum $prompt?\n";
137                 print "[\033[1;32m$main::config{$configitem}\033[0m] -> ";
138                 chomp($var = <STDIN>);
139                 if ($var eq "")
140                 {
141                         $var = $main::config{$configitem};
142                 }
143                 if ($var =~ /^\d+$/) {
144                         # We don't care what the number is, set it and be on our way.
145                         $main::config{$configitem} = $var;
146                         $continue = 1;
147                         print "\n";
148                 } else {
149                         print "You must enter a number in this field. Please try again.\n\n";
150                 }
151         }
152 }
153
154 sub promptstring_s($$)
155 {
156         my ($prompt,$default) = @_;
157         my $var;
158         print "$prompt\n";
159         print "[\033[1;32m$default\033[0m] -> ";
160         chomp($var = <STDIN>);
161         $var = $default if $var eq "";
162         print "\n";
163         return $var;
164 }
165
166 sub dumphash()
167 {
168         print "\n\033[1;32mPre-build configuration is complete!\033[0m\n\n";
169         print "\033[0mBase install path:\033[1;32m\t\t$main::config{BASE_DIR}\033[0m\n";
170         print "\033[0mConfig path:\033[1;32m\t\t\t$main::config{CONFIG_DIR}\033[0m\n";
171         print "\033[0mModule path:\033[1;32m\t\t\t$main::config{MODULE_DIR}\033[0m\n";
172         print "\033[0mLibrary path:\033[1;32m\t\t\t$main::config{LIBRARY_DIR}\033[0m\n";
173         print "\033[0mMax connections:\033[1;32m\t\t$main::config{MAX_CLIENT}\033[0m\n";
174         print "\033[0mMax nickname length:\033[1;32m\t\t$main::config{NICK_LENGT}\033[0m\n";
175         print "\033[0mMax channel length:\033[1;32m\t\t$main::config{CHAN_LENGT}\033[0m\n";
176         print "\033[0mMax mode length:\033[1;32m\t\t$main::config{MAXI_MODES}\033[0m\n";
177         print "\033[0mMax ident length:\033[1;32m\t\t$main::config{MAX_IDENT}\033[0m\n";
178         print "\033[0mMax quit length:\033[1;32m\t\t$main::config{MAX_QUIT}\033[0m\n";
179         print "\033[0mMax topic length:\033[1;32m\t\t$main::config{MAX_TOPIC}\033[0m\n";
180         print "\033[0mMax kick length:\033[1;32m\t\t$main::config{MAX_KICK}\033[0m\n";
181         print "\033[0mMax name length:\033[1;32m\t\t$main::config{MAX_GECOS}\033[0m\n";
182         print "\033[0mMax away length:\033[1;32m\t\t$main::config{MAX_AWAY}\033[0m\n";
183         print "\033[0mGCC Version Found:\033[1;32m\t\t$main::config{GCCVER}.x\033[0m\n";
184         print "\033[0mCompiler program:\033[1;32m\t\t$main::config{CC}\033[0m\n";
185         print "\033[0mIPv6 Support:\033[1;32m\t\t\t$main::config{IPV6}\033[0m\n";
186         print "\033[0mIPv6 to IPv4 Links:\033[1;32m\t\t$main::config{SUPPORT_IP6LINKS}\033[0m\n";
187         print "\033[0mGnuTLS Support:\033[1;32m\t\t\t$main::config{USE_GNUTLS}\033[0m\n";
188         print "\033[0mOpenSSL Support:\033[1;32m\t\t$main::config{USE_OPENSSL}\033[0m\n\n";
189 }
190
191 sub is_dir
192 {
193         my ($path) = @_;
194         if (chdir($path))
195         {
196                 chdir($main::this);
197                 return 1;
198         }
199         else
200         {
201                 # Just in case..
202                 chdir($main::this);
203                 return 0;
204         }
205 }
206
207 sub showhelp
208 {
209         chomp($PWD = `pwd`);
210         print "Usage: configure [options]
211
212 *** NOTE: NON-INTERACTIVE CONFIGURE IS *NOT* SUPPORTED BY THE ***
213 *** INSPIRCD DEVELOPMENT TEAM. DO NOT ASK FOR HELP REGARDING  ***
214 ***     NON-INTERACTIVE CONFIGURE ON THE FORUMS OR ON IRC!    ***
215
216 Options: [defaults in brackets after descriptions]
217
218 When no options are specified, interactive
219 configuration is started and you must specify
220 any required values manually. If one or more
221 options are specified, non-interactive configuration
222 is started, and any omitted values are defaulted.
223
224 Arguments with a single \"-\" symbol, as in
225 InspIRCd 1.0.x, are also allowed.
226
227   --disable-interactive        Sets no options intself, but
228                                will disable any interactive prompting.
229   --update                     Update makefiles and dependencies
230   --modupdate                  Detect new modules and write makefiles
231   --svnupdate {--rebuild}      Update working copy via subversion
232                                 {and optionally rebuild if --rebuild
233                                  is also specified}
234   --clean                      Remove .config.cache file and go interactive
235   --enable-gnutls              Enable GnuTLS module [no]
236   --enable-openssl             Enable OpenSSL module [no]
237   --with-nick-length=[n]       Specify max. nick length [32]
238   --with-channel-length=[n]    Specify max. channel length [64]
239   --with-max-clients=[n]       Specify maximum number of users
240                                which may connect locally
241   --enable-optimization=[n]    Optimize using -O[n] gcc flag
242   --enable-epoll               Enable epoll() where supported [set]
243   --enable-kqueue              Enable kqueue() where supported [set]
244   --disable-epoll              Do not enable epoll(), fall back
245                                to select() [not set]
246   --disable-kqueue             Do not enable kqueue(), fall back
247                                to select() [not set]
248   --enable-ipv6                Build ipv6 native InspIRCd [no]
249   --enable-remote-ipv6         Build with ipv6 support for remote
250                                servers on the network [yes]
251   --disable-remote-ipv6        Do not allow remote ipv6 servers [not set]
252   --with-cc=[filename]         Use an alternative g++ binary to
253                                build InspIRCd [g++]
254   --with-ident-length=[n]      Specify max length of ident [12]
255   --with-quit-length=[n]       Specify max length of quit [200]
256   --with-topic-length=[n]      Specify max length of topic [350]
257   --with-kick-length=[n]       Specify max length of kick [200]
258   --with-gecos-length=[n]      Specify max length of gecos [150]
259   --with-away-length=[n]       Specify max length of away [150]
260   --with-max-modes=[n]         Specify max modes per line which
261                                have parameters [20]
262   --with-maxbuf=[n]            Change the per message buffer size [512]
263                                DO NOT ALTER THIS OPTION WITHOUT GOOD REASON
264                                AS IT *WILL* BREAK CLIENTS!!!
265   --prefix=[directory]         Base directory to install into (if defined,
266                                can automatically define config, module, bin
267                                and library dirs as subdirectories of prefix)
268                                [$PWD]
269   --config-dir=[directory]     Config file directory for config and SSL certs
270                                [$PWD/conf]
271   --module-dir=[directory]     Modules directory for loadable modules
272                                [$PWD/modules]
273   --binary-dir=[directory]     Binaries directory for core binary
274                                [$PWD/bin]
275   --library-dir=[directory]    Library directory for core libraries
276                                [$PWD/lib]
277   --help                       Show this help text and exit
278
279 ";
280         exit(0);
281 }
282
283 1;
284