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