3 # InspIRCd -- Internet Relay Chat Daemon
5 # Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
6 # Copyright (C) 2019 Anatole Denis <natolumin@rezel.net>
7 # Copyright (C) 2017 emerson <github@emersonveenstra.net>
8 # Copyright (C) 2013-2020 Sadie Powell <sadie@witchery.services>
9 # Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
10 # Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
11 # Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
12 # Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
13 # Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
14 # Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
15 # Copyright (C) 2006-2008 Craig Edwards <brain@inspircd.org>
17 # This file is part of InspIRCd. InspIRCd is free software: you can
18 # redistribute it and/or modify it under the terms of the GNU General Public
19 # License as published by the Free Software Foundation, version 2.
21 # This program is distributed in the hope that it will be useful, but WITHOUT
22 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
26 # You should have received a copy of the GNU General Public License
27 # along with this program. If not, see <http://www.gnu.org/licenses/>.
37 use warnings FATAL => qw(all);
39 use File::Basename qw(basename);
41 use File::Spec::Functions qw(rel2abs);
42 use FindBin qw($RealDir);
43 use Getopt::Long qw(GetOptions);
44 use POSIX qw(getgid getuid);
56 $opt_disable_auto_extras,
57 $opt_disable_interactive,
58 $opt_distribution_label,
72 sub enable_extras (@);
74 sub disable_extras (@);
77 my @opt_disableextras;
79 exit 1 unless GetOptions(
80 'clean' => \&cmd_clean,
82 'update' => \&cmd_update,
84 'binary-dir=s' => \$opt_binary_dir,
85 'config-dir=s' => \$opt_config_dir,
86 'data-dir=s' => \$opt_data_dir,
87 'development' => \$opt_development,
88 'disable-auto-extras' => \$opt_disable_auto_extras,
89 'disable-interactive' => \$opt_disable_interactive,
90 'distribution-label=s' => \$opt_distribution_label,
91 'example-dir=s' => \$opt_example_dir,
93 'log-dir=s' => \$opt_log_dir,
94 'manual-dir=s' => \$opt_manual_dir,
95 'module-dir=s' => \$opt_module_dir,
96 'prefix=s' => \$opt_prefix,
97 'script-dir=s' => \$opt_script_dir,
98 'socketengine=s' => \$opt_socketengine,
99 'system' => \$opt_system,
100 'uid=s' => \$opt_uid,
102 # TODO: when the modulemanager rewrite is done these should be removed.
103 'disable-extras=s@' => \@opt_disableextras,
104 'enable-extras=s@' => \@opt_enableextras,
105 'list-extras' => sub { list_extras; exit 0; },
108 if (scalar(@opt_enableextras) + scalar(@opt_disableextras) > 0) {
109 @opt_enableextras = split /[, ]+/, join(',', @opt_enableextras);
110 @opt_disableextras = split /[, ]+/, join(',', @opt_disableextras);
111 enable_extras(@opt_enableextras);
112 disable_extras(@opt_disableextras);
114 print "Remember: YOU are responsible for making sure any libraries needed have been installed!\n";
118 our $interactive = !(
121 defined $opt_binary_dir ||
122 defined $opt_config_dir ||
123 defined $opt_data_dir ||
124 defined $opt_development ||
125 defined $opt_disable_auto_extras ||
126 defined $opt_disable_interactive ||
127 defined $opt_distribution_label ||
128 defined $opt_example_dir ||
130 defined $opt_log_dir ||
131 defined $opt_manual_dir ||
132 defined $opt_module_dir ||
133 defined $opt_prefix ||
134 defined $opt_script_dir ||
135 defined $opt_socketengine ||
136 defined $opt_system ||
140 my %version = get_version $opt_distribution_label;
141 print_format "<|BOLD Configuring InspIRCd $version{FULL} on $^O.|>\n";
145 %config = read_config_file(CONFIGURE_CACHE_FILE);
146 run_test CONFIGURE_CACHE_FILE, %config;
147 if (!defined $config{VERSION}) {
148 $config{VERSION} = CONFIGURE_CACHE_VERSION;
149 } elsif ($config{VERSION} != CONFIGURE_CACHE_VERSION) {
150 print_warning "ignoring contents of ${\CONFIGURE_CACHE_FILE} as it was generated by an incompatible version of $0!";
151 %config = ('VERSION', CONFIGURE_CACHE_VERSION);
155 $config{CXX} = find_compiler($config{CXX} // $ENV{CXX});
156 unless ($config{CXX}) {
157 say 'A suitable C++ compiler could not be detected on your system!';
158 unless ($interactive) {
159 say 'Set the CXX environment variable to the path to a C++ compiler binary if this is incorrect.';
162 until ($config{CXX}) {
163 my $compiler_path = prompt_string 1, 'Please enter the path to a C++ compiler binary:', 'c++';
164 $config{CXX} = find_compiler $compiler_path;
167 my %compiler = get_compiler_info($config{CXX});
169 $config{HAS_ARC4RANDOM_BUF} = run_test 'arc4random_buf()', test_file($config{CXX}, 'arc4random_buf.cpp');
170 $config{HAS_CLOCK_GETTIME} = run_test 'clock_gettime()', test_file($config{CXX}, 'clock_gettime.cpp', $^O eq 'darwin' ? undef : '-lrt');
171 $config{HAS_EVENTFD} = run_test 'eventfd()', test_file($config{CXX}, 'eventfd.cpp');
174 push @socketengines, 'epoll' if run_test 'epoll', test_header $config{CXX}, 'sys/epoll.h';
175 push @socketengines, 'kqueue' if run_test 'kqueue', test_file $config{CXX}, 'kqueue.cpp';
176 push @socketengines, 'poll' if run_test 'poll', test_header $config{CXX}, 'poll.h';
177 push @socketengines, 'select';
179 if (defined $opt_socketengine) {
180 unless (grep { $_ eq $opt_socketengine } @socketengines) {
181 my $reason = -f "src/socketengines/socketengine_$opt_socketengine.cpp" ? 'is not available on this platform' : 'does not exist';
182 print_error "The socket engine you requested ($opt_socketengine) $reason!",
183 'Available socket engines are:',
184 map { " * $_" } @socketengines;
187 $config{SOCKETENGINE} = $opt_socketengine // $socketengines[0];
189 if (defined $opt_system) {
190 $config{BASE_DIR} = $opt_prefix // '/var/lib/inspircd';
191 $config{BINARY_DIR} = $opt_binary_dir // '/usr/sbin';
192 $config{CONFIG_DIR} = $opt_config_dir // '/etc/inspircd';
193 $config{DATA_DIR} = $opt_data_dir // '/var/inspircd';
194 $config{EXAMPLE_DIR} = $opt_example_dir // '/usr/share/doc/inspircd';
195 $config{LOG_DIR} = $opt_log_dir // '/var/log/inspircd';
196 $config{MANUAL_DIR} = $opt_manual_dir // '/usr/share/man/man1';
197 $config{MODULE_DIR} = $opt_module_dir // '/usr/lib/inspircd';
198 $config{SCRIPT_DIR} = $opt_script_dir // '/usr/share/inspircd'
200 $config{BASE_DIR} = $opt_prefix // $config{BASE_DIR} // rel2abs 'run';
201 $config{BINARY_DIR} = $opt_binary_dir // $config{BINARY_DIR} // rel2abs $config{BASE_DIR} . '/bin';
202 $config{CONFIG_DIR} = $opt_config_dir // $config{CONFIG_DIR} // rel2abs $config{BASE_DIR} . '/conf';
203 $config{DATA_DIR} = $opt_data_dir // $config{DATA_DIR} // rel2abs $config{BASE_DIR} . '/data';
204 $config{EXAMPLE_DIR} = $opt_example_dir // $config{EXAMPLE_DIR} // $config{CONFIG_DIR} . '/examples';
205 $config{LOG_DIR} = $opt_log_dir // $config{LOG_DIR} // rel2abs $config{BASE_DIR} . '/logs';
206 $config{MANUAL_DIR} = $opt_manual_dir // $config{MANUAL_DIR} // rel2abs $config{BASE_DIR} . '/manuals';
207 $config{MODULE_DIR} = $opt_module_dir // $config{MODULE_DIR} // rel2abs $config{BASE_DIR} . '/modules';
208 $config{SCRIPT_DIR} = $opt_script_dir // $config{SCRIPT_DIR} // $config{BASE_DIR};
211 # Parse --gid=123 or --gid=foo and extract the group id.
213 if (defined $opt_gid) {
214 @group = $opt_gid =~ /^\d+$/ ? getgrgid($opt_gid) : getgrnam($opt_gid);
215 print_error "there is no '$opt_gid' group on this system!" unless @group;
217 @group = $opt_system ? getgrnam('irc') : getgrgid($config{GID} // getgid());
218 print_error "you need to specify a group to run as using '--gid [id|name]'!" unless @group;
220 print_warning <<"EOW";
221 You are building as the privileged $group[0] group and have not specified
222 an unprivileged group to run InspIRCd as.
224 This is almost never what you should do. You should probably either create a new
225 unprivileged user/group to build and run as or pass the '--gid [id|name]' flag
226 to specify an unprivileged group to run as.
228 if (!prompt_bool $interactive, "Are you sure you want to build as the $group[0] group?", 0) {
229 # PACKAGERS: You do not need to delete this check. Use `--gid $(id -g)` or `--gid 0` instead.
230 say STDERR "If you are sure you want to build as the $group[0] group pass the --gid $group[2] flag." unless $interactive;
235 $config{GROUP} = $group[0];
236 $config{GID} = $group[2];
238 # Parse --uid=123 or --uid=foo and extract the user id.
240 if (defined $opt_uid) {
241 @user = $opt_uid =~ /^\d+$/ ? getpwuid($opt_uid) : getpwnam($opt_uid);
242 print_error "there is no '$opt_uid' user on this system!" unless @user;
244 @user = $opt_system ? getpwnam('irc') : getpwuid($config{UID} // getuid());
245 print_error "you need to specify a user to run as using '--uid [id|name]'!" unless @user;
247 print_warning <<"EOW";
248 You are building as the privileged $user[0] user and have not specified
249 an unprivileged user to run InspIRCd as.
251 This is almost never what you should do. You should probably either create a new
252 unprivileged user/group to build and run as or pass the '--uid [id|name]' flag
253 to specify an unprivileged user to run as.
255 if (!prompt_bool $interactive, "Are you sure you want to build as the $user[0] user?", 0) {
256 # PACKAGERS: You do not need to delete this check. Use `--uid $(id -u)` or `--uid 0` instead.
257 say STDERR "If you are sure you want to build as the $user[0] user pass the --uid $user[2] flag." unless $interactive;
262 $config{USER} = $user[0];
263 $config{UID} = $user[2];
265 # Warn the user about clock drifting when running on OpenVZ.
266 if (-e '/proc/user_beancounters' || -e '/proc/vz/vzaquota') {
267 print_warning <<'EOW';
268 You are building InspIRCd inside of an OpenVZ container. If you
269 plan to use InspIRCd in this container then you should make sure that NTP is
270 configured on the Hardware Node. Failure to do so may result in clock drifting!
274 # Warn the user about OpenBSD shipping incredibly broken compilers/linkers.
275 if ($^O eq 'openbsd') {
276 print_warning <<'EOW';
277 You are building InspIRCd on OpenBSD. The C++ compilers and linkers
278 that OpenBSD ship are incredibly broken. You may have strange linker errors
279 and crashes. Please consider using a different OS like FreeBSD/NetBSD instead.
283 # Check that the user actually wants this version.
284 if (defined $version{REAL_LABEL}) {
285 print_warning <<'EOW';
286 You are building a development version. This contains code which has
287 not been tested as heavily and may contain various faults which could seriously
288 affect the running of your server. It is recommended that you use a stable
291 You can obtain the latest stable version from https://www.inspircd.org or by
292 running `<|GREEN git checkout $(git describe --abbrev=0 --tags insp3)|>` if you are
295 if (!prompt_bool $interactive, 'I understand this warning and want to continue anyway.', $opt_development // 0) {
296 say STDERR 'If you understand this warning and still want to continue pass the --development flag.' unless $interactive;
301 # Configure directory settings.
302 my $question = <<"EOQ";
303 Currently, InspIRCd is configured with the following paths:
305 <|BOLD Base:|> $config{BASE_DIR}
306 <|BOLD Binary:|> $config{BINARY_DIR}
307 <|BOLD Config:|> $config{CONFIG_DIR}
308 <|BOLD Data:|> $config{DATA_DIR}
309 <|BOLD Log:|> $config{LOG_DIR}
310 <|BOLD Manual:|> $config{MANUAL_DIR}
311 <|BOLD Module:|> $config{MODULE_DIR}
312 <|BOLD Script:|> $config{SCRIPT_DIR}
314 Do you want to change these settings?
316 if (prompt_bool $interactive, $question, 0) {
317 my $original_base_dir = $config{BASE_DIR};
318 $config{BASE_DIR} = prompt_dir $interactive, 'In what directory do you wish to install the InspIRCd base?', $config{BASE_DIR};
319 foreach my $key (qw(BINARY_DIR CONFIG_DIR DATA_DIR LOG_DIR MANUAL_DIR MODULE_DIR SCRIPT_DIR)) {
320 $config{$key} =~ s/^\Q$original_base_dir\E/$config{BASE_DIR}/;
322 $config{BINARY_DIR} = prompt_dir $interactive, 'In what directory should the InspIRCd binary be placed?', $config{BINARY_DIR};
323 $config{CONFIG_DIR} = prompt_dir $interactive, 'In what directory are configuration files to be stored?', $config{CONFIG_DIR};
324 $config{DATA_DIR} = prompt_dir $interactive, 'In what directory are variable data files to be stored?', $config{DATA_DIR};
325 $config{LOG_DIR} = prompt_dir $interactive, 'In what directory are log files to be stored?', $config{LOG_DIR};
326 $config{MANUAL_DIR} = prompt_dir $interactive, 'In what directory are manual pages to be placed?', $config{MANUAL_DIR};
327 $config{MODULE_DIR} = prompt_dir $interactive, 'In what directory are modules to be placed?', $config{MODULE_DIR};
328 $config{SCRIPT_DIR} = prompt_dir $interactive, 'In what directory are scripts to be placed?', $config{SCRIPT_DIR};
329 $config{EXAMPLE_DIR} = $config{CONFIG_DIR} . '/examples';
332 # Configure module settings.
334 Currently, InspIRCd is configured to automatically enable all available extra modules.
336 Would you like to enable extra modules manually?
338 if (prompt_bool $interactive, $question, 0) {
339 foreach my $extra (<src/modules/extra/m_*.cpp>) {
340 my $module_name = basename $extra, '.cpp';
341 if (prompt_bool $interactive, "Would you like to enable $module_name?", 0) {
342 enable_extras "$module_name.cpp";
345 } elsif (!defined $opt_disable_auto_extras) {
346 # TODO: finish modulemanager rewrite and replace this code with:
347 # system './modulemanager', 'enable', '--auto';
349 # Missing: m_ldap, m_regex_stdlib, m_ssl_mbedtls
350 'm_geo_maxmind.cpp' => 'pkg-config --exists libmaxminddb',
351 'm_mysql.cpp' => 'mysql_config --version',
352 'm_pgsql.cpp' => 'pg_config --version',
353 'm_regex_pcre.cpp' => 'pcre-config --version',
354 'm_regex_posix.cpp' => undef,
355 'm_regex_re2.cpp' => 'pkg-config --exists re2',
356 'm_regex_tre.cpp' => 'pkg-config --exists tre',
357 'm_sqlite3.cpp' => 'pkg-config --exists sqlite3',
358 'm_ssl_gnutls.cpp' => 'pkg-config --exists gnutls',
359 'm_ssl_openssl.cpp' => 'pkg-config --exists openssl',
360 'm_sslrehashsignal.cpp' => undef,
362 while (my ($module, $command) = each %modules) {
363 unless (defined $command && system "$command 1>/dev/null 2>/dev/null") {
364 enable_extras $module;
369 # Generate SSL certificates.
371 Would you like to generate a self-signed SSL certificate now? This certificate
372 can be used for testing but <|BOLD should not|> be used on a production network.
374 Note: you can get a <|BOLD free|> CA-signed certificate from Let's Encrypt. See
375 https://letsencrypt.org/getting-started/ for more details.
378 if (<src/modules/m_ssl_*.cpp>) {
379 if (prompt_bool $interactive, $question, $interactive) {
380 system './tools/genssl', 'auto';
383 print_warning <<"EOM";
384 You are building without enabling any SSL modules. This is not
385 recommended as SSL greatly enhances the security and privacy of your IRC server
386 and in a future version will be <|BOLD required|> for linking servers.
388 Please read the following documentation pages on how to enable SSL support:
390 GnuTLS (recommended): https://docs.inspircd.org/3/modules/ssl_gnutls
391 mbedTLS: https://docs.inspircd.org/3/modules/ssl_mbedtls
392 OpenSSL: https://docs.inspircd.org/3/modules/ssl_openssl
396 # Cache the distribution label so that its not lost when --update is run.
397 $config{DISTRIBUTION} = $opt_distribution_label if $opt_distribution_label;
399 write_configure_cache %config;
400 parse_templates \%config, \%compiler, \%version;
402 print_format <<"EOM";
404 Configuration is complete! You have chosen to build with the following settings:
407 <|GREEN Binary:|> $config{CXX}
408 <|GREEN Name:|> $compiler{NAME}
409 <|GREEN Version:|> $compiler{VERSION}
411 <|GREEN Extra Modules:|>
414 for my $file (<src/modules/m_*>) {
415 my $module = basename $file, '.cpp';
416 say " * $module" if -l $file;
419 print_format <<"EOM";
422 <|GREEN Base:|> $config{BASE_DIR}
423 <|GREEN Binary:|> $config{BINARY_DIR}
424 <|GREEN Config:|> $config{CONFIG_DIR}
425 <|GREEN Data:|> $config{DATA_DIR}
426 <|GREEN Example:|> $config{EXAMPLE_DIR}
427 <|GREEN Log:|> $config{LOG_DIR}
428 <|GREEN Manual:|> $config{MANUAL_DIR}
429 <|GREEN Module:|> $config{MODULE_DIR}
430 <|GREEN Script:|> $config{SCRIPT_DIR}
432 <|GREEN Execution Group:|> $config{GROUP} ($config{GID})
433 <|GREEN Execution User:|> $config{USER} ($config{UID})
434 <|GREEN Socket Engine:|> $config{SOCKETENGINE}
436 To build with these settings run '<|GREEN make -j${\(get_cpu_count() + 1)} install|>' now.
440 # Routine to list out the extra/ modules that have been enabled.
441 # Note: when getting any filenames out and comparing, it's important to lc it if the
442 # file system is not case-sensitive (== Epoc, MacOS, OS/2 (incl DOS/DJGPP), VMS, Win32
443 # (incl NetWare, Symbian)). Cygwin may or may not be case-sensitive, depending on
444 # configuration, however, File::Spec does not currently tell us (it assumes Unix behavior).
448 my $srcdir = File::Spec->catdir("src", "modules");
449 my $abs_srcdir = File::Spec->rel2abs($srcdir);
452 opendir $dd, File::Spec->catdir($abs_srcdir, "extra") or die (File::Spec->catdir($abs_srcdir, "extra") . ": $!\n");
453 my @extras = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
456 opendir $dd, $abs_srcdir or die "$abs_srcdir: $!\n";
457 my @sources = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
460 my $maxlen = (sort { $b <=> $a } (map {length($_)} (@extras)))[0];
462 EXTRA: for my $extra (@extras) {
463 next if (File::Spec->curdir() eq $extra || File::Spec->updir() eq $extra);
464 my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
465 my $abs_source = File::Spec->catfile($abs_srcdir, $extra);
466 next unless ($extra =~ m/\.(cpp|h)$/ || (-d $abs_extra)); # C++ Source/Header, or directory
467 if (-l $abs_source) {
468 # Symlink, is it in the right place?
469 my $targ = readlink($abs_source);
470 my $abs_targ = File::Spec->rel2abs($targ, $abs_srcdir);
471 if ($abs_targ eq $abs_extra) {
472 $extras{$extra} = "\e[32;1menabled\e[0m";
474 $extras{$extra} = sprintf("\e[31;1mwrong symlink target (%s)\e[0m", $abs_targ);
476 } elsif (-e $abs_source) {
477 my ($devext, $inoext) = stat($abs_extra);
478 my ($devsrc, $inosrc, undef, $lnksrc) = stat($abs_source);
480 if ($devsrc == $devext && $inosrc == $inoext) {
481 $extras{$extra} = "\e[32;1menabled\e[0m";
483 $extras{$extra} = sprintf("\e[31;1mwrong hardlink target (%d:%d)\e[0m", $devsrc, $inosrc);
486 open my $extfd, "<", $abs_extra;
487 open my $srcfd, "<", $abs_source;
489 if (scalar(<$extfd>) eq scalar(<$srcfd>)) {
490 $extras{$extra} = "\e[32;1menabled\e[0m";
492 $extras{$extra} = sprintf("\e[31;1mout of synch (re-copy)\e[0m");
496 $extras{$extra} = "\e[33;1mdisabled\e[0m";
499 # Now let's add dependency info
500 for my $extra (keys(%extras)) {
501 next unless $extras{$extra} =~ m/enabled/; # only process enabled extras.
502 my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
503 my @deps = split /\s+/, get_directive($abs_extra, 'ModDep', '');
504 for my $dep (@deps) {
505 if (exists($extras{$dep})) {
506 my $ref = \$extras{$dep}; # Take reference.
507 if ($$ref !~ m/needed by/) {
508 # First dependency found.
509 if ($$ref =~ m/enabled/) {
510 $$ref .= " (needed by \e[32;1m$extra\e[0m";
512 $$ref =~ s/\e\[.*?m//g; # Strip out previous coloring. Will be set in bold+red+blink later.
513 $$ref .= " (needed by \e[0;32;1;5m$extra\e[0;31;1;5m";
516 if ($$ref =~ m/enabled/) {
517 $$ref .= ", \e[32;1m$extra\e[0m";
519 $$ref .= ", \e[0;32;1;5m$extra\e[0;31;1;5m";
525 for my $extra (sort {$a cmp $b} keys(%extras)) {
526 my $text = $extras{$extra};
527 if ($text =~ m/needed by/ && $text !~ m/enabled/) {
528 printf "\e[31;1;5m%-*s = %s%s\e[0m\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? ")" : "");
530 printf "%-*s = %s%s\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? "\e[0m)" : "");
533 return keys(%extras) if wantarray; # Can be used by manage_extras.
536 sub enable_extras (@) {
538 for my $extra (@extras) {
539 $extra = "m_$extra" unless $extra =~ /^m_/;
540 $extra = "$extra.cpp" unless $extra =~ /\.cpp$/;
541 my $extrapath = "src/modules/extra/$extra";
542 if (!-e $extrapath) {
543 print STDERR "Cannot enable \e[32;1m$extra\e[0m : No such file or directory in src/modules/extra\n";
546 my $source = "src/modules/$extra";
548 print STDERR "Cannot enable \e[32;1m$extra\e[0m : destination in src/modules exists (might already be enabled?)\n";
551 # Get dependencies, and add them to be processed.
552 my @deps = split /\s+/, get_directive($extrapath, 'ModDep', '');
553 for my $dep (@deps) {
554 next if scalar(grep { $_ eq $dep } (@extras)) > 0; # Skip if we're going to be enabling it anyway.
555 if (!-e "src/modules/$dep" && !-e "include/$dep") {
556 if (-e "src/modules/extra/$dep") {
557 print STDERR "Will also enable extra \e[32;1m$dep\e[0m (needed by \e[32;1m$extra\e[0m)\n";
560 print STDERR "\e[33;1mWARNING:\e[0m module \e[32;1m$extra\e[0m might be missing dependency \e[32;1m$dep\e[0m - YOU are responsible for satisfying it!\n";
564 print "Enabling $extra ... \n";
565 symlink "extra/$extra", $source or print STDERR "$source: Cannot link to 'extra/$extra': $!\n";
569 sub disable_extras (@)
571 opendir my $dd, "src/modules/extra/";
572 my @files = readdir($dd);
575 EXTRA: for my $extra (@extras) {
576 $extra = "m_$extra" unless $extra =~ /^m_/;
577 $extra = "$extra.cpp" unless $extra =~ /\.cpp$/;
578 my $extrapath = "src/modules/extra/$extra";
579 my $source = "src/modules/$extra";
580 if (!-e $extrapath) {
581 print STDERR "Cannot disable \e[32;1m$extra\e[0m : Is not an extra\n";
584 if ((! -l $source) || readlink($source) ne "extra/$extra") {
585 print STDERR "Cannot disable \e[32;1m$extra\e[0m : Source is not a link or doesn't refer to the right file. Remove manually if this is in error.\n";
588 # Check if anything needs this.
589 for my $file (@files) {
590 my @deps = split /\s+/, get_directive("src/modules/extra/$file", 'ModDep', '');
591 # File depends on this extra...
592 if (scalar(grep { $_ eq $extra } @deps) > 0) {
593 # And is both enabled and not about to be disabled.
594 if (-e "src/modules/$file" && scalar(grep { $_ eq $file } @extras) < 1) {
595 print STDERR "Cannot disable \e[32;1m$extra\e[0m : is needed by \e[32;1m$file\e[0m\n";
601 print "Disabling $extra ... \n";
602 unlink "src/modules/$extra" or print STDERR "Cannot disable \e[32;1m$extra\e[0m : $!\n";