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