X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Fconfigure.pm;h=90523383505f24d4fa6caf96bb83e710e84b64fd;hb=00660293338f6a78278e52d05f6cf9a7ef9acc64;hp=2864240808883b5ce94b4fef470d59e182d20e55;hpb=3070548ceeffd3c09ce26d816a1d225dbe9d137e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/configure.pm b/make/configure.pm index 286424080..905233835 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -1,7 +1,7 @@ # # InspIRCd -- Internet Relay Chat Daemon # -# Copyright (C) 2012 Peter Powell +# Copyright (C) 2012-2014 Peter Powell # Copyright (C) 2008 Robin Burchell # Copyright (C) 2007-2008 Craig Edwards # Copyright (C) 2008 Thomas Stagner @@ -30,8 +30,9 @@ package make::configure; use strict; use warnings FATAL => qw(all); -use Cwd; +use Cwd 'getcwd'; use Exporter 'import'; +use File::Basename 'basename'; use make::utilities; @@ -39,10 +40,7 @@ our @EXPORT = qw(cmd_clean cmd_help cmd_update read_configure_cache write_configure_cache get_compiler_info find_compiler run_test test_file test_header - get_property get_revision - dump_hash); - -my $revision; + dump_hash get_property parse_templates); sub __get_socketengines() { my @socketengines; @@ -53,6 +51,34 @@ sub __get_socketengines() { return @socketengines; } +# TODO: when buildtool is done this can be mostly removed with +# the remainder being merged into parse_templates. +sub __get_template_settings($$) { + + # These are actually hash references + my ($config, $compiler) = @_; + + # Start off by populating with the config + my %settings = %$config; + + # Compiler information + while (my ($key, $value) = each %{$compiler}) { + $settings{'COMPILER_' . $key} = $value; + } + + # Version information + my %version = get_version(); + while (my ($key, $value) = each %version) { + $settings{'VERSION_' . $key} = $value; + } + + # Miscellaneous information + $settings{SYSTEM_NAME} = lc $^O; + chomp($settings{SYSTEM_NAME_VERSION} = `uname -sr 2>/dev/null`); + + return %settings; +} + sub cmd_clean { unlink '.config.cache'; } @@ -129,10 +155,9 @@ sub cmd_update { exit 1; } print "Updating...\n"; - %main::config = read_configure_cache(); - %main::cxx = get_compiler_info($main::config{CXX}); - $main::topdir = getcwd(); - main::writefiles(); + my %config = read_configure_cache(); + my %compiler = get_compiler_info($config{CXX}); + parse_templates(\%config, \%compiler); print "Update complete!\n"; exit 0; } @@ -242,15 +267,7 @@ sub get_property($$;$) return defined $default ? $default : ''; } -sub get_revision { - return $revision if defined $revision; - chomp(my $tags = `git describe --tags 2>/dev/null`); - $revision = $tags || 'release'; - return $revision; -} - -sub dump_hash() -{ +sub dump_hash() { print "\n\e[1;32mPre-build configuration is complete!\e[0m\n\n"; print "\e[0mBase install path:\e[1;32m\t\t$main::config{BASE_DIR}\e[0m\n"; print "\e[0mConfig path:\e[1;32m\t\t\t$main::config{CONFIG_DIR}\e[0m\n"; @@ -263,4 +280,163 @@ sub dump_hash() print "\e[0mOpenSSL support:\e[1;32m\t\t$main::config{USE_OPENSSL}\e[0m\n"; } +sub parse_templates($$) { + + # These are actually hash references + my ($config, $compiler) = @_; + + # Collect settings to be used when generating files + my %settings = __get_template_settings($config, $compiler); + + # Iterate through files in make/template. + foreach () { + print "Parsing $_...\n"; + open(TEMPLATE, $_); + my (@lines, $mode, @platforms, %targets); + + # First pass: parse template variables and directives. + while (my $line =