+sub __test_compiler($) {
+ my $compiler = shift;
+ return 0 unless run_test("`$compiler`", !system "$compiler -v ${\CONFIGURE_ERROR_PIPE}");
+ return 0 unless run_test("`$compiler`", test_file($compiler, 'compiler.cpp', '-fno-rtti'), 'compatible');
+ return 1;
+}
+
+sub cmd_clean {
+ unlink CONFIGURE_CACHE_FILE;
+}
+
+sub cmd_help {
+ my $SELIST = join ', ', __get_socketengines();
+ print console_format <<EOH;
+<|GREEN Usage:|> <|BOLD $0 [OPTIONS|>]
+
+When no options are specified, configure runs in interactive mode and you must
+specify any required values manually. If one or more options are specified,
+non-interactive configuration is started and any omitted values are defaulted.
+
+<|GREEN PATH OPTIONS|>
+
+ <|BOLD --portable|> Automatically set up the installation paths for
+ portable installation.
+ <|BOLD --system|> Automatically set up the installation paths for
+ system-wide installation.
+ <|BOLD --prefix <DIR>|> The root install directory. If this is set then
+ all subdirectories will be adjusted accordingly.
+ [${\CONFIGURE_ROOT}/run]
+ <|BOLD --binary-dir <DIR>|> The location where the main server binary is
+ stored.
+ [${\CONFIGURE_ROOT}/run/bin]
+ <|BOLD --config-dir <DIR>|> The location where the configuration files and
+ SSL certificates are stored.
+ [${\CONFIGURE_ROOT}/run/conf]
+ <|BOLD --data-dir <DIR>|> The location where the data files, such as the
+ xline database, are stored.
+ [${\CONFIGURE_ROOT}/run/data]
+ <|BOLD --example-dir <DIR>|> The location where the example configuration
+ files and SQL schemas are stored.
+ [${\CONFIGURE_ROOT}/run/conf/examples]
+ <|BOLD --log-dir <DIR>|> The location where the log files are stored.
+ [${\CONFIGURE_ROOT}/run/logs]
+ <|BOLD --manual-dir <DIR>|> The location where the manual files are stored.
+ [${\CONFIGURE_ROOT}/run/manuals]
+ <|BOLD --module-dir <DIR>|> The location where the loadable modules are
+ stored.
+ [${\CONFIGURE_ROOT}/run/modules]
+ <|BOLD --runtime-dir <DIR>|> The location where the runtime files, such as
+ the pid file, are stored.
+ [${\CONFIGURE_ROOT}/run/data]
+ <|BOLD --script-dir <DIR>|> The location where the scripts, such as the
+ init scripts, are stored.
+ [${\CONFIGURE_ROOT}/run]
+
+<|GREEN EXTRA MODULE OPTIONS|>
+
+ <|BOLD --enable-extras <MODULE>|> Enables a comma separated list of extra modules.
+ <|BOLD --disable-extras <MODULE>|> Disables a comma separated list of extra modules.
+ <|BOLD --list-extras|> Shows the availability status of all extra
+ modules.
+
+<|GREEN MISC OPTIONS|>
+
+ <|BOLD --clean|> Remove the configuration cache file and start
+ the interactive configuration wizard.
+ <|BOLD --disable-auto-extras|> Disables automatically enabling extra modules
+ for which the dependencies are available.
+ <|BOLD --disable-interactive|> Disables the interactive configuration wizard.
+ <|BOLD --distribution-label <TEXT>|> Sets a distribution specific version label in
+ the build configuration.
+ <|BOLD --gid <ID|NAME>|> Sets the group to run InspIRCd as.
+ <|BOLD --help|> Show this message and exit.
+ <|BOLD --socketengine <NAME>|> Sets the socket engine to be used. Possible
+ values are $SELIST.
+ <|BOLD --uid [ID|NAME]|> Sets the user to run InspIRCd as.
+ <|BOLD --update|> Updates the build environment with the settings
+ from the cache.
+
+<|GREEN FLAGS|>
+
+ <|BOLD CXX=<NAME>|> Sets the C++ compiler to use when building the
+ server. If not specified then the build system
+ will search for c++, g++, clang++ or icpc.
+ <|BOLD INSPIRCD_VERBOSE=<0|1>|> Shows additional information for debugging.
+
+If you have any problems with configuring InspIRCd then visit our IRC channel
+at irc.inspircd.org #InspIRCd or create a support discussion at
+https://github.com/inspircd/inspircd/discussions.
+
+Packagers: see https://docs.inspircd.org/packaging/ for packaging advice.
+EOH
+ exit 0;
+}
+
+sub cmd_update {
+ print_error "You have not run $0 before. Please do this before trying to update the generated files." unless -f CONFIGURE_CACHE_FILE;
+ say 'Updating...';
+ my %config = read_config_file(CONFIGURE_CACHE_FILE);
+ $config{EXAMPLE_DIR} //= catdir $config{CONFIG_DIR}, 'examples';
+ $config{RUNTIME_DIR} //= $config{DATA_DIR};
+ my %compiler = get_compiler_info($config{CXX});
+ my %version = get_version $config{DISTRIBUTION};
+ parse_templates(\%config, \%compiler, \%version);
+ say 'Update complete!';
+ exit 0;
+}
+
+sub run_test($$;$) {
+ my ($what, $result, $adjective) = @_;
+ $adjective //= 'available';
+ print console_format "Checking whether <|GREEN $what|> is $adjective ... ";
+ say console_format($result ? "<|GREEN yes|>" : "<|RED no|>");