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