my %version = get_version();
print_format "<|BOLD Configuring InspIRCd $version{MAJOR}.$version{MINOR}.$version{PATCH}+$version{LABEL} on $^O.|>\n";
-our %config = read_configure_cache();
-
-print "Checking for cache from previous configure... ";
-print %config ? "found\n" : "not found\n";
+our %config;
+if ($interactive) {
+ %config = read_configure_cache();
+ 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);
+ }
+}
$config{CXX} = defined $ENV{CXX} && !system("$ENV{CXX} -v > /dev/null 2>&1") ? $ENV{CXX} : find_compiler();
if ($config{CXX} eq "") {
system './tools/genssl', 'auto';
}
-write_configure_cache %config;
+write_configure_cache %config if $interactive;
parse_templates \%config, \%compiler;
print_format <<"EOM";
use make::console;
use make::utilities;
-our @EXPORT = qw(cmd_clean
+use constant CONFIGURE_CACHE_FILE => '.configure.cache';
+use constant CONFIGURE_CACHE_VERSION => '1';
+
+our @EXPORT = qw(CONFIGURE_CACHE_FILE
+ CONFIGURE_CACHE_VERSION
+ cmd_clean
cmd_help
cmd_update
read_configure_cache
}
# Miscellaneous information
+ $settings{CONFIGURE_CACHE_FILE} = CONFIGURE_CACHE_FILE;
$settings{SYSTEM_NAME} = lc $^O;
chomp($settings{SYSTEM_NAME_VERSION} = `uname -sr 2>/dev/null`);
}
sub cmd_clean {
- unlink '.config.cache';
+ unlink CONFIGURE_CACHE_FILE;
}
sub cmd_help {
}
sub cmd_update {
- print_error "You have not run $0 before. Please do this before trying to update the generated files." unless -f '.config.cache';
+ print_error "You have not run $0 before. Please do this before trying to update the generated files." unless -f CONFIGURE_CACHE_FILE;
print "Updating...\n";
my %config = read_configure_cache();
my %compiler = get_compiler_info($config{CXX});
}
sub read_configure_cache {
- my %cfg = ();
- open(CACHE, '.config.cache') or return %cfg;
+ my %config;
+ open(CACHE, CONFIGURE_CACHE_FILE) or return %config;
while (my $line = <CACHE>) {
next if $line =~ /^\s*($|\#)/;
my ($key, $value) = ($line =~ /^(\S+)="(.*)"$/);
- $cfg{$key} = $value;
+ $config{$key} = $value;
}
close(CACHE);
- return %cfg;
+ return %config;
}
sub write_configure_cache(%) {
- print_format "Writing <|GREEN .config.cache|> ...\n";
- my %cfg = @_;
- open(CACHE, '>.config.cache') or print_error "unable to write .config.cache: $!";
- while (my ($key, $value) = each %cfg) {
- $value = "" unless defined $value;
+ print_format "Writing <|GREEN ${\CONFIGURE_CACHE_FILE}|> ...\n";
+ my %config = @_;
+ open(CACHE, '>', CONFIGURE_CACHE_FILE) or print_error "unable to write ${\CONFIGURE_CACHE_FILE}: $!";
+ while (my ($key, $value) = each %config) {
+ $value = '' unless defined $value;
print CACHE "$key=\"$value\"\n";
}
close(CACHE);
@echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
@echo 'Examples are available at:' $(CONPATH)/examples/
-GNUmakefile BSDmakefile: make/template/main.mk src/version.sh configure .config.cache
+@TARGET BSD_MAKE CONFIGURE_CACHE_FILE = @CONFIGURE_CACHE_FILE@
+@TARGET GNU_MAKE CONFIGURE_CACHE_FILE = $(wildcard @CONFIGURE_CACHE_FILE@)
+
+GNUmakefile BSDmakefile: make/template/main.mk src/version.sh configure $(CONFIGURE_CACHE_FILE)
./configure -update
@TARGET BSD_MAKE .MAKEFILEDEPS: BSDmakefile
-rm -f $(BASE)/org.inspircd.plist
configureclean:
- rm -f .config.cache
rm -f BSDmakefile
rm -f GNUmakefile
rm -f include/config.h
rm -f inspircd-genssl.1
-rm -f inspircd.service
-rm -f org.inspircd.plist
+ -rm -f @CONFIGURE_CACHE_FILE@
distclean: clean configureclean
-rm -rf $(SOURCEPATH)/run