2 # InspIRCd -- Internet Relay Chat Daemon
4 # Copyright (C) 2012 Peter Powell <petpow@saberuk.com>
5 # Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6 # Copyright (C) 2007-2008 Craig Edwards <craigedwards@brainbox.cc>
7 # Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
8 # Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
10 # This file is part of InspIRCd. InspIRCd is free software: you can
11 # redistribute it and/or modify it under the terms of the GNU General Public
12 # License as published by the Free Software Foundation, version 2.
14 # This program is distributed in the hope that it will be useful, but WITHOUT
15 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 package make::configure;
29 use warnings FATAL => qw(all);
31 use Exporter 'import';
34 our @EXPORT = qw(promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies nopedantic resolve_directory yesno showhelp promptstring_s);
39 my ($flag,$prompt) = @_;
40 print "$prompt [\e[1;32m$main::config{$flag}\e[0m] -> ";
41 chomp(my $tmp = <STDIN>);
42 if ($tmp eq "") { $tmp = $main::config{$flag} }
43 if (($tmp eq "") || ($tmp =~ /^y/i))
45 $main::config{$flag} = "y";
49 $main::config{$flag} = "n";
60 $ret = File::Spec->rel2abs($_[0]);
70 my $data = `git describe --tags 2>/dev/null`;
76 chomp $data; # remove \n
80 sub getcompilerflags {
82 open(FLAGS, $file) or return "";
84 if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
85 my $x = translate_functions($1, $file);
97 open(FLAGS, $file) or return "";
99 if ($_ =~ /^\/\* \$LinkerFlags: (.+) \*\/$/) {
100 my $x = translate_functions($1, $file);
110 sub getdependencies {
112 open(FLAGS, $file) or return "";
114 if ($_ =~ /^\/\* \$ModDep: (.+) \*\/$/) {
115 my $x = translate_functions($1, $file);
127 open(FLAGS, $file) or return "";
129 if ($_ =~ /^\/\* \$NoPedantic \*\/$/) {
130 my $x = translate_functions($_, $file);
148 print "Detecting modules ";
151 opendir(DIRHANDLE, "src/modules") or die("WTF, missing src/modules!");
152 foreach my $name (sort readdir(DIRHANDLE))
154 if ($name =~ /^m_(.+)\.cpp$/)
157 $main::modlist[$i++] = $mod;
168 print "\nOk, $i modules.\n";
172 sub promptnumeric($$)
175 my ($prompt, $configitem) = @_;
178 print "Please enter the maximum $prompt?\n";
179 print "[\e[1;32m$main::config{$configitem}\e[0m] -> ";
180 chomp(my $var = <STDIN>);
183 $var = $main::config{$configitem};
185 if ($var =~ /^\d+$/) {
186 # We don't care what the number is, set it and be on our way.
187 $main::config{$configitem} = $var;
191 print "You must enter a number in this field. Please try again.\n\n";
196 sub promptstring_s($$)
198 my ($prompt,$default) = @_;
201 print "[\e[1;32m$default\e[0m] -> ";
202 chomp($var = <STDIN>);
203 $var = $default if $var eq "";
210 print "\n\e[1;32mPre-build configuration is complete!\e[0m\n\n";
211 print "\e[0mBase install path:\e[1;32m\t\t$main::config{BASE_DIR}\e[0m\n";
212 print "\e[0mConfig path:\e[1;32m\t\t\t$main::config{CONFIG_DIR}\e[0m\n";
213 print "\e[0mModule path:\e[1;32m\t\t\t$main::config{MODULE_DIR}\e[0m\n";
214 print "\e[0mGCC Version Found:\e[1;32m\t\t$main::config{GCCVER}.$main::config{GCCMINOR}\e[0m\n";
215 print "\e[0mCompiler program:\e[1;32m\t\t$main::config{CC}\e[0m\n";
216 print "\e[0mGnuTLS Support:\e[1;32m\t\t\t$main::config{USE_GNUTLS}\e[0m\n";
217 print "\e[0mOpenSSL Support:\e[1;32m\t\t$main::config{USE_OPENSSL}\e[0m\n\n";
218 print "\e[1;32mImportant note: The maximum length values are now configured in the\e[0m\n";
219 print "\e[1;32m configuration file, not in ./configure! See the <limits>\e[0m\n";
220 print "\e[1;32m tag in the configuration file for more information.\e[0m\n\n";
241 chomp(my $PWD = `pwd`);
243 Usage: configure [options]
245 *** NOTE: NON-INTERACTIVE CONFIGURE IS *NOT* SUPPORTED BY THE ***
246 *** INSPIRCD DEVELOPMENT TEAM. DO NOT ASK FOR HELP REGARDING ***
247 *** NON-INTERACTIVE CONFIGURE ON THE FORUMS OR ON IRC! ***
249 Options: [defaults in brackets after descriptions]
251 When no options are specified, interactive
252 configuration is started and you must specify
253 any required values manually. If one or more
254 options are specified, non-interactive configuration
255 is started, and any omitted values are defaulted.
257 Arguments with a single \"-\" symbol, as in
258 InspIRCd 1.0.x, are also allowed.
260 --disable-interactive Sets no options itself, but
261 will disable any interactive prompting.
262 --update Update makefiles and dependencies
263 --clean Remove .config.cache file and go interactive
264 --enable-gnutls Enable GnuTLS module [no]
265 --enable-openssl Enable OpenSSL module [no]
266 --enable-epoll Enable epoll() where supported [set]
267 --enable-kqueue Enable kqueue() where supported [set]
268 --disable-epoll Do not enable epoll(), fall back
269 to select() [not set]
270 --disable-kqueue Do not enable kqueue(), fall back
271 to select() [not set]
272 --disable-ipv6 Do not build IPv6 native InspIRCd [not set]
273 --with-cc=[filename] Use an alternative compiler to
275 --with-maxbuf=[n] Change the per message buffer size [512]
276 DO NOT ALTER THIS OPTION WITHOUT GOOD REASON
277 AS IT *WILL* BREAK CLIENTS!!!
278 --prefix=[directory] Base directory to install into (if defined,
279 can automatically define config, module, bin
280 and library dirs as subdirectories of prefix)
282 --config-dir=[directory] Config file directory for config and SSL certs
284 --module-dir=[directory] Modules directory for loadable modules
286 --binary-dir=[directory] Binaries directory for core binary
288 --library-dir=[directory] Library directory for core libraries
290 --list-extras Show current status of extra modules
291 --enable-extras=[extras] Enable the specified list of extras
292 --disable-extras=[extras] Disable the specified list of extras
293 --help Show this help text and exit