]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/configure.pm
448ad90da1910acec57bd368c67793b912cade4b
[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 use Exporter 'import';
15 use POSIX;
16 use make::utilities;
17 @EXPORT = qw(promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies resolve_directory yesno showhelp promptstring_s);
18
19 my $no_svn = 0;
20
21 sub yesno {
22         my ($flag,$prompt) = @_;
23         print "$prompt [\033[1;32m$main::config{$flag}\033[0m] -> ";
24         chomp($tmp = <STDIN>);
25         if ($tmp eq "") { $tmp = $main::config{$flag} }
26         if (($tmp eq "") || ($tmp =~ /^y/i))
27         {
28                 $main::config{$flag} = "y";
29         }
30         else
31         {
32                 $main::config{$flag} = "n";
33         }
34         return;
35 }
36
37 sub resolve_directory
38 {
39         my $ret = $_[0];
40         eval
41         {
42                 use File::Spec;
43                 $ret = File::Spec->rel2abs($_[0]);
44         };
45         return $ret;
46 }
47
48 sub getrevision {
49         if ($no_svn)
50         {
51                 return "0";
52         }
53         my $data = `svn info`;
54         if ($data eq "")
55         {
56                 $no_svn = 1;
57                 $rev = "0";
58                 return $rev;
59         }
60         $data =~ /Revision: (\d+)/;
61         my $rev = $1;
62         if (!defined($rev))
63         {
64                 $rev = "0";
65         }
66         return $rev;
67 }
68
69 sub getcompilerflags {
70         my ($file) = @_;
71         open(FLAGS, $file);
72         while (<FLAGS>) {
73                 if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
74                         close(FLAGS);
75                         return translate_functions($1,$file);
76                 }
77         }
78         close(FLAGS);
79         return undef;
80 }
81
82 sub getlinkerflags {
83         my ($file) = @_;
84         open(FLAGS, $file);
85         while (<FLAGS>) {
86                 if ($_ =~ /^\/\* \$LinkerFlags: (.+) \*\/$/) {
87                         close(FLAGS);
88                         return translate_functions($1,$file);
89                 }
90         }
91         close(FLAGS);
92         return undef;
93 }
94
95 sub getdependencies {
96         my ($file) = @_;
97         open(FLAGS, $file);
98         while (<FLAGS>) {
99                 if ($_ =~ /^\/\* \$ModDep: (.+) \*\/$/) {
100                         close(FLAGS);
101                         return translate_functions($1,$file);
102                 }
103         }
104         close(FLAGS);
105         return undef;
106 }
107
108
109 sub getmodules
110 {
111         my $i = 0;
112         print "Detecting modules ";
113         opendir(DIRHANDLE, "src/modules");
114         foreach $name (sort readdir(DIRHANDLE))
115         {
116                 if ($name =~ /^m_(.+)\.cpp$/)
117                 {
118                         $mod = $1;
119                         $main::modlist[$i++] = $mod;
120                         print ".";
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[0mIPv6 Support:\033[1;32m\t\t\t$main::config{IPV6}\033[0m\n";
183         print "\033[0mIPv6 to IPv4 Links:\033[1;32m\t\t$main::config{SUPPORT_IP6LINKS}\033[0m\n";
184         print "\033[0mGnuTLS Support:\033[1;32m\t\t\t$main::config{USE_GNUTLS}\033[0m\n";
185         print "\033[0mOpenSSL Support:\033[1;32m\t\t$main::config{USE_OPENSSL}\033[0m\n\n";
186 }
187
188 sub is_dir
189 {
190         my ($path) = @_;
191         if (chdir($path))
192         {
193                 chdir($main::this);
194                 return 1;
195         }
196         else
197         {
198                 # Just in case..
199                 chdir($main::this);
200                 return 0;
201         }
202 }
203
204 sub showhelp
205 {
206         chomp($PWD = `pwd`);
207         print "Usage: configure [options]
208
209 *** NOTE: NON-INTERACTIVE CONFIGURE IS *NOT* SUPPORTED BY THE ***
210 *** INSPIRCD DEVELOPMENT TEAM. DO NOT ASK FOR HELP REGARDING  ***
211 ***     NON-INTERACTIVE CONFIGURE ON THE FORUMS OR ON IRC!    ***
212
213 Options: [defaults in brackets after descriptions]
214
215 When no options are specified, interactive
216 configuration is started and you must specify
217 any required values manually. If one or more
218 options are specified, non-interactive configuration
219 is started, and any omitted values are defaulted.
220
221 Arguments with a single \"-\" symbol, as in
222 InspIRCd 1.0.x, are also allowed.
223
224   --disable-interactive        Sets no options intself, but
225                                will disable any interactive prompting.
226   --update                     Update makefiles and dependencies
227   --modupdate                  Detect new modules and write makefiles
228   --svnupdate {--rebuild}      Update working copy via subversion
229                                 {and optionally rebuild if --rebuild
230                                  is also specified}
231   --clean                      Remove .config.cache file and go interactive
232   --enable-gnutls              Enable GnuTLS module [no]
233   --enable-openssl             Enable OpenSSL module [no]
234   --with-nick-length=[n]       Specify max. nick length [32]
235   --with-channel-length=[n]    Specify max. channel length [64]
236   --with-max-clients=[n]       Specify maximum number of users
237                                which may connect locally
238   --enable-optimization=[n]    Optimize using -O[n] gcc flag
239   --enable-epoll               Enable epoll() where supported [set]
240   --enable-kqueue              Enable kqueue() where supported [set]
241   --disable-epoll              Do not enable epoll(), fall back
242                                to select() [not set]
243   --disable-kqueue             Do not enable kqueue(), fall back
244                                to select() [not set]
245   --enable-ipv6                Build ipv6 native InspIRCd [no]
246   --enable-remote-ipv6         Build with ipv6 support for remote
247                                servers on the network [yes]
248   --disable-remote-ipv6        Do not allow remote ipv6 servers [not set]
249   --with-cc=[filename]         Use an alternative g++ binary to
250                                build InspIRCd [g++]
251   --with-ident-length=[n]      Specify max length of ident [12]
252   --with-quit-length=[n]       Specify max length of quit [200]
253   --with-topic-length=[n]      Specify max length of topic [350]
254   --with-kick-length=[n]       Specify max length of kick [200]
255   --with-gecos-length=[n]      Specify max length of gecos [150]
256   --with-away-length=[n]       Specify max length of away [150]
257   --with-max-modes=[n]         Specify max modes per line which
258                                have parameters [20]
259   --with-maxbuf=[n]            Change the per message buffer size [512]
260                                DO NOT ALTER THIS OPTION WITHOUT GOOD REASON
261                                AS IT *WILL* BREAK CLIENTS!!!
262   --prefix=[directory]         Base directory to install into (if defined,
263                                can automatically define config, module, bin
264                                and library dirs as subdirectories of prefix)
265                                [$PWD]
266   --config-dir=[directory]     Config file directory for config and SSL certs
267                                [$PWD/conf]
268   --module-dir=[directory]     Modules directory for loadable modules
269                                [$PWD/modules]
270   --binary-dir=[directory]     Binaries directory for core binary
271                                [$PWD/bin]
272   --library-dir=[directory]    Library directory for core libraries
273                                [$PWD/lib]
274   --help                       Show this help text and exit
275
276 ";
277         exit(0);
278 }
279
280 1;
281