-our $topdir = getcwd();
-our %config = read_configure_cache();
-
-print "Checking for cache from previous configure... ";
-print %config ? "found\n" : "not found\n";
-
-$config{BASE_DIR} = $topdir."/run";
-
-if (defined $opt_base_dir) {
- $config{BASE_DIR} = $opt_base_dir;
-} elsif (defined $opt_system) {
- $config{BASE_DIR} = '/var/lib/inspircd';
-}
-
-if (defined $opt_system) {
- $config{UID} = $opt_uid || 'ircd';
- $config{CONFIG_DIR} = '/etc/inspircd';
- $config{MODULE_DIR} = '/usr/lib/inspircd';
- $config{BINARY_DIR} = '/usr/sbin/';
- $config{BUILD_DIR} = $topdir."/build";
- $config{DATA_DIR} = '/var/inspircd';
- $config{LOG_DIR} = '/var/log/inspircd';
-} else {
- $config{UID} = $opt_uid || $<;
- $config{CONFIG_DIR} = rel2abs($config{BASE_DIR}."/conf");
- $config{MODULE_DIR} = rel2abs($config{BASE_DIR}."/modules");
- $config{BINARY_DIR} = rel2abs($config{BASE_DIR}."/bin");
- $config{BUILD_DIR} = rel2abs($topdir."/build");
- $config{DATA_DIR} = rel2abs($config{BASE_DIR}."/data");
- $config{LOG_DIR} = rel2abs($config{BASE_DIR}."/logs");
-}
-
-if (defined $opt_config_dir) {
- $config{CONFIG_DIR} = $opt_config_dir;
-}
-if (defined $opt_module_dir) {
- $config{MODULE_DIR} = $opt_module_dir;
-}
-if (defined $opt_binary_dir) {
- $config{BINARY_DIR} = $opt_binary_dir;
-}
-if (defined $opt_data_dir) {
- $config{DATA_DIR} = $opt_data_dir;
-}
-if (defined $opt_log_dir) {
- $config{LOG_DIR} = $opt_log_dir;
-}
-chomp($config{HAS_GNUTLS} = `pkg-config --modversion gnutls 2>/dev/null`);
-chomp($config{HAS_OPENSSL} = `pkg-config --modversion openssl 2>/dev/null`);
-
-chomp(our $gnutls_ver = $config{HAS_GNUTLS});
-chomp(our $openssl_ver = $config{HAS_OPENSSL});
-$config{USE_GNUTLS} = 0;
-if (defined $opt_use_gnutls)
-{
- $config{USE_GNUTLS} = "y"; # Use gnutls.
-}
-$config{USE_OPENSSL} = 0; # Use openssl.
-if (defined $opt_use_openssl)
-{
- $config{USE_OPENSSL} = "y";
-}
-
-$config{STARTSCRIPT} = $^O eq 'darwin' ? 'org.inspircd.plist' : 'inspircd';
-
-$config{CXX} = defined $ENV{CXX} && !system("$ENV{CXX} -v > /dev/null 2>&1") ? $ENV{CXX} : find_compiler();
-if ($config{CXX} eq "") {
- print "A C++ compiler could not be detected on your system!\n";
- print "Set the CXX environment variable to the full path if this is incorrect.\n";
- exit 1;
-}
-
-our %cxx = get_compiler_info($config{CXX});
-if ($cxx{UNSUPPORTED}) {
- print "Your C++ compiler is too old to build InspIRCd!\n";
- print "Reason: $cxx{REASON}\n";
- exit 1;
+my %version = get_version $opt_distribution_label;
+print_format "<|BOLD Configuring InspIRCd $version{FULL} on $^O.|>\n";
+
+my %config;
+if ($interactive) {
+ %config = read_config_file(CONFIGURE_CACHE_FILE);
+ run_test CONFIGURE_CACHE_FILE, %config;
+ if (!defined $config{VERSION}) {
+ $config{VERSION} = CONFIGURE_CACHE_VERSION;
+ } elsif ($config{VERSION} != CONFIGURE_CACHE_VERSION) {
+ print_warning "ignoring contents of ${\CONFIGURE_CACHE_FILE} as it was generated by an incompatible version of $0!";
+ %config = ('VERSION', CONFIGURE_CACHE_VERSION);
+ }