]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/configure.pm
a082492239c28ba0d7f2a59470a91660266e5f2a
[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 nickname length:\033[1;32m\t\t$main::config{NICK_LENGT}\033[0m\n";
151         print "\033[0mMax channel length:\033[1;32m\t\t$main::config{CHAN_LENGT}\033[0m\n";
152         print "\033[0mMax mode length:\033[1;32m\t\t$main::config{MAXI_MODES}\033[0m\n";
153         print "\033[0mMax ident length:\033[1;32m\t\t$main::config{MAX_IDENT}\033[0m\n";
154         print "\033[0mMax quit length:\033[1;32m\t\t$main::config{MAX_QUIT}\033[0m\n";
155         print "\033[0mMax topic length:\033[1;32m\t\t$main::config{MAX_TOPIC}\033[0m\n";
156         print "\033[0mMax kick length:\033[1;32m\t\t$main::config{MAX_KICK}\033[0m\n";
157         print "\033[0mMax name length:\033[1;32m\t\t$main::config{MAX_GECOS}\033[0m\n";
158         print "\033[0mMax away length:\033[1;32m\t\t$main::config{MAX_AWAY}\033[0m\n";
159         print "\033[0mGCC Version Found:\033[1;32m\t\t$main::config{GCCVER}.x\033[0m\n";
160         print "\033[0mCompiler program:\033[1;32m\t\t$main::config{CC}\033[0m\n";
161         print "\033[0mStatic modules:\033[1;32m\t\t\t$main::config{STATIC_LINK}\033[0m\n";
162         print "\033[0mIPv6 Support:\033[1;32m\t\t\t$main::config{IPV6}\033[0m\n";
163         print "\033[0mIPv6 to IPv4 Links:\033[1;32m\t\t$main::config{SUPPORT_IP6LINKS}\033[0m\n";
164         print "\033[0mGnuTLS Support:\033[1;32m\t\t\t$main::config{USE_GNUTLS}\033[0m\n";
165         print "\033[0mOpenSSL Support:\033[1;32m\t\t$main::config{USE_OPENSSL}\033[0m\n\n";
166 }
167
168 sub is_dir
169 {
170         my ($path) = @_;
171         if (chdir($path))
172         {
173                 chdir($main::this);
174                 return 1;
175         }
176         else
177         {
178                 # Just in case..
179                 chdir($main::this);
180                 return 0;
181         }
182 }
183
184 sub showhelp
185 {
186         chomp($PWD = `pwd`);
187         print "Usage: configure [options]
188
189 *** NOTE: NON-INTERACTIVE CONFIGURE IS *NOT* SUPPORTED BY THE ***
190 *** INSPIRCD DEVELOPMENT TEAM. DO NOT ASK FOR HELP REGARDING  ***
191 ***     NON-INTERACTIVE CONFIGURE ON THE FORUMS OR ON IRC!    ***
192
193 Options: [defaults in brackets after descriptions]
194
195 When no options are specified, interactive
196 configuration is started and you must specify
197 any required values manually. If one or more
198 options are specified, non-interactive configuration
199 is started, and any omitted values are defaulted.
200
201 Arguments with a single \"-\" symbol, as in
202 InspIRCd 1.0.x, are also allowed.
203
204   --disable-interactive        Sets no options intself, but
205                                will disable any interactive prompting.
206   --update                     Update makefiles and dependencies
207   --modupdate                  Detect new modules and write makefiles
208   --svnupdate {--rebuild}      Update working copy via subversion
209                                 {and optionally rebuild if --rebuild
210                                  is also specified}
211   --clean                      Remove .config.cache file and go interactive
212   --enable-gnutls              Enable GnuTLS module [no]
213   --enable-openssl             Enable OpenSSL module [no]
214   --with-nick-length=[n]       Specify max. nick length [32]
215   --with-channel-length=[n]    Specify max. channel length [64]
216   --with-max-clients=[n]       Specify maximum number of users
217                                which may connect locally
218   --enable-optimization=[n]    Optimize using -O[n] gcc flag
219   --enable-epoll               Enable epoll() where supported [set]
220   --enable-kqueue              Enable kqueue() where supported [set]
221   --disable-epoll              Do not enable epoll(), fall back
222                                to select() [not set]
223   --disable-kqueue             Do not enable kqueue(), fall back
224                                to select() [not set]
225   --enable-ipv6                Build ipv6 native InspIRCd [no]
226   --enable-remote-ipv6         Build with ipv6 support for remote
227                                servers on the network [yes]
228   --disable-remote-ipv6        Do not allow remote ipv6 servers [not set]
229   --with-cc=[filename]         Use an alternative g++ binary to
230                                build InspIRCd [g++]
231   --with-ident-length=[n]      Specify max length of ident [12]
232   --with-quit-length=[n]       Specify max length of quit [200]
233   --with-topic-length=[n]      Specify max length of topic [350]
234   --with-kick-length=[n]       Specify max length of kick [200]
235   --with-gecos-length=[n]      Specify max length of gecos [150]
236   --with-away-length=[n]       Specify max length of away [150]
237   --with-max-modes=[n]         Specify max modes per line which
238                                have parameters [20]
239   --prefix=[directory]         Base directory to install into (if defined,
240                                can automatically define config, module, bin
241                                and library dirs as subdirectories of prefix)
242                                [$PWD]
243   --config-dir=[directory]     Config file directory for config and SSL certs
244                                [$PWD/conf]
245   --module-dir=[directory]     Modules directory for loadable modules
246                                [$PWD/modules]
247   --binary-dir=[directory]     Binaries directory for core binary
248                                [$PWD/bin]
249   --library-dir=[directory]    Library directory for core libraries
250                                [$PWD/lib]
251   --help                       Show this help text and exit
252
253 ";
254         exit(0);
255 }
256
257 1;
258