]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/configure.pm
9e9503c16312eec70f7364d0b0a1d9e342203fcc
[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 nopedantic 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 sub nopedantic {
112         my ($file) = @_;
113         open(FLAGS, $file);
114         while (<FLAGS>) {
115                 if ($_ =~ /^\/\* \$NoPedantic \*\/$/) {
116                         close(FLAGS);
117                         return 1;
118                 }
119         }
120         close(FLAGS);
121         return 0;
122 }
123
124 sub getmodules
125 {
126         my $i = 0;
127         print "Detecting modules ";
128         opendir(DIRHANDLE, "src/modules");
129         foreach $name (sort readdir(DIRHANDLE))
130         {
131                 if ($name =~ /^m_(.+)\.cpp$/)
132                 {
133                         $mod = $1;
134                         $main::modlist[$i++] = $mod;
135                         print ".";
136                 }
137         }
138         closedir(DIRHANDLE);
139         print "\nOk, $i modules.\n";
140 }
141
142 sub promptnumeric($$)
143 {
144         my $continue = 0;
145         my ($prompt, $configitem) = @_;
146         while (!$continue)
147         {
148                 print "Please enter the maximum $prompt?\n";
149                 print "[\033[1;32m$main::config{$configitem}\033[0m] -> ";
150                 chomp($var = <STDIN>);
151                 if ($var eq "")
152                 {
153                         $var = $main::config{$configitem};
154                 }
155                 if ($var =~ /^\d+$/) {
156                         # We don't care what the number is, set it and be on our way.
157                         $main::config{$configitem} = $var;
158                         $continue = 1;
159                         print "\n";
160                 } else {
161                         print "You must enter a number in this field. Please try again.\n\n";
162                 }
163         }
164 }
165
166 sub promptstring_s($$)
167 {
168         my ($prompt,$default) = @_;
169         my $var;
170         print "$prompt\n";
171         print "[\033[1;32m$default\033[0m] -> ";
172         chomp($var = <STDIN>);
173         $var = $default if $var eq "";
174         print "\n";
175         return $var;
176 }
177
178 sub dumphash()
179 {
180         print "\n\033[1;32mPre-build configuration is complete!\033[0m\n\n";
181         print "\033[0mBase install path:\033[1;32m\t\t$main::config{BASE_DIR}\033[0m\n";
182         print "\033[0mConfig path:\033[1;32m\t\t\t$main::config{CONFIG_DIR}\033[0m\n";
183         print "\033[0mModule path:\033[1;32m\t\t\t$main::config{MODULE_DIR}\033[0m\n";
184         print "\033[0mLibrary path:\033[1;32m\t\t\t$main::config{LIBRARY_DIR}\033[0m\n";
185         print "\033[0mMax connections:\033[1;32m\t\t$main::config{MAX_CLIENT}\033[0m\n";
186         print "\033[0mMax nickname length:\033[1;32m\t\t$main::config{NICK_LENGT}\033[0m\n";
187         print "\033[0mMax channel length:\033[1;32m\t\t$main::config{CHAN_LENGT}\033[0m\n";
188         print "\033[0mMax mode length:\033[1;32m\t\t$main::config{MAXI_MODES}\033[0m\n";
189         print "\033[0mMax ident length:\033[1;32m\t\t$main::config{MAX_IDENT}\033[0m\n";
190         print "\033[0mMax quit length:\033[1;32m\t\t$main::config{MAX_QUIT}\033[0m\n";
191         print "\033[0mMax topic length:\033[1;32m\t\t$main::config{MAX_TOPIC}\033[0m\n";
192         print "\033[0mMax kick length:\033[1;32m\t\t$main::config{MAX_KICK}\033[0m\n";
193         print "\033[0mMax name length:\033[1;32m\t\t$main::config{MAX_GECOS}\033[0m\n";
194         print "\033[0mMax away length:\033[1;32m\t\t$main::config{MAX_AWAY}\033[0m\n";
195         print "\033[0mGCC Version Found:\033[1;32m\t\t$main::config{GCCVER}.x\033[0m\n";
196         print "\033[0mCompiler program:\033[1;32m\t\t$main::config{CC}\033[0m\n";
197         print "\033[0mIPv6 Support:\033[1;32m\t\t\t$main::config{IPV6}\033[0m\n";
198         print "\033[0mIPv6 to IPv4 Links:\033[1;32m\t\t$main::config{SUPPORT_IP6LINKS}\033[0m\n";
199         print "\033[0mGnuTLS Support:\033[1;32m\t\t\t$main::config{USE_GNUTLS}\033[0m\n";
200         print "\033[0mOpenSSL Support:\033[1;32m\t\t$main::config{USE_OPENSSL}\033[0m\n\n";
201 }
202
203 sub is_dir
204 {
205         my ($path) = @_;
206         if (chdir($path))
207         {
208                 chdir($main::this);
209                 return 1;
210         }
211         else
212         {
213                 # Just in case..
214                 chdir($main::this);
215                 return 0;
216         }
217 }
218
219 sub showhelp
220 {
221         chomp($PWD = `pwd`);
222         print "Usage: configure [options]
223
224 *** NOTE: NON-INTERACTIVE CONFIGURE IS *NOT* SUPPORTED BY THE ***
225 *** INSPIRCD DEVELOPMENT TEAM. DO NOT ASK FOR HELP REGARDING  ***
226 ***     NON-INTERACTIVE CONFIGURE ON THE FORUMS OR ON IRC!    ***
227
228 Options: [defaults in brackets after descriptions]
229
230 When no options are specified, interactive
231 configuration is started and you must specify
232 any required values manually. If one or more
233 options are specified, non-interactive configuration
234 is started, and any omitted values are defaulted.
235
236 Arguments with a single \"-\" symbol, as in
237 InspIRCd 1.0.x, are also allowed.
238
239   --disable-interactive        Sets no options intself, but
240                                will disable any interactive prompting.
241   --update                     Update makefiles and dependencies
242   --modupdate                  Detect new modules and write makefiles
243   --svnupdate {--rebuild}      Update working copy via subversion
244                                 {and optionally rebuild if --rebuild
245                                  is also specified}
246   --clean                      Remove .config.cache file and go interactive
247   --enable-gnutls              Enable GnuTLS module [no]
248   --enable-openssl             Enable OpenSSL module [no]
249   --with-nick-length=[n]       Specify max. nick length [32]
250   --with-channel-length=[n]    Specify max. channel length [64]
251   --with-max-clients=[n]       Specify maximum number of users
252                                which may connect locally
253   --enable-optimization=[n]    Optimize using -O[n] gcc flag
254   --enable-epoll               Enable epoll() where supported [set]
255   --enable-kqueue              Enable kqueue() where supported [set]
256   --disable-epoll              Do not enable epoll(), fall back
257                                to select() [not set]
258   --disable-kqueue             Do not enable kqueue(), fall back
259                                to select() [not set]
260   --enable-ipv6                Build ipv6 native InspIRCd [no]
261   --enable-remote-ipv6         Build with ipv6 support for remote
262                                servers on the network [yes]
263   --disable-remote-ipv6        Do not allow remote ipv6 servers [not set]
264   --with-cc=[filename]         Use an alternative g++ binary to
265                                build InspIRCd [g++]
266   --with-ident-length=[n]      Specify max length of ident [12]
267   --with-quit-length=[n]       Specify max length of quit [200]
268   --with-topic-length=[n]      Specify max length of topic [350]
269   --with-kick-length=[n]       Specify max length of kick [200]
270   --with-gecos-length=[n]      Specify max length of gecos [150]
271   --with-away-length=[n]       Specify max length of away [150]
272   --with-max-modes=[n]         Specify max modes per line which
273                                have parameters [20]
274   --with-maxbuf=[n]            Change the per message buffer size [512]
275                                DO NOT ALTER THIS OPTION WITHOUT GOOD REASON
276                                AS IT *WILL* BREAK CLIENTS!!!
277   --prefix=[directory]         Base directory to install into (if defined,
278                                can automatically define config, module, bin
279                                and library dirs as subdirectories of prefix)
280                                [$PWD]
281   --config-dir=[directory]     Config file directory for config and SSL certs
282                                [$PWD/conf]
283   --module-dir=[directory]     Modules directory for loadable modules
284                                [$PWD/modules]
285   --binary-dir=[directory]     Binaries directory for core binary
286                                [$PWD/bin]
287   --library-dir=[directory]    Library directory for core libraries
288                                [$PWD/lib]
289   --help                       Show this help text and exit
290
291 ";
292         exit(0);
293 }
294
295 1;
296