From e6d245a3e80c0e0c05476e5bd9c45a77e16fecec Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 14 Apr 2014 12:42:22 +0100 Subject: Replace the configure templating system with something better. A large amount of this code can be removed when buildtool is done as we will not need to worry about the differences between BSD and GNU Make. --- configure | 118 +++----------------------------------------------------------- 1 file changed, 4 insertions(+), 114 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 857541189..45bb0e911 100755 --- a/configure +++ b/configure @@ -253,8 +253,7 @@ if ($interactive) # Clear the screen. system 'tput', 'clear'; - my $revision = get_revision(); - chomp(my $version = `sh src/version.sh`); + my %version = get_version(); # Display Introduction Message.. print <<"STOP" ; @@ -272,12 +271,12 @@ dir, otherwise you won't have a config file! Your operating system is: \e[1;32m$^O\e[0m STOP print "Your InspIRCd version is: \e[1;32m"; - print $revision eq 'release' ? substr($version, 9) : substr($revision, 1); + print "$version{MAJOR}.$version{MINOR}.$version{PATCH}+$version{LABEL}"; print "\e[0m\n\n"; print "The following compiler has been detected: \e[1;32m$cxx{NAME} $cxx{VERSION}\e[0m ($config{CXX})\n\n"; # Check that the user actually wants this version. - if (index($version, '+') != -1) { + if ($version{LABEL} ne 'release') { print <<"EOW" ; \e[1;31mWARNING!\e[0m You are building a development version. This contains code which has not been tested as heavily and may contain various faults which could seriously @@ -417,7 +416,7 @@ if ($config{USE_GNUTLS} || $config{USE_OPENSSL}) { print "Writing \e[1;32m.config.cache\e[0m ...\n"; write_configure_cache(%config); -writefiles(); +parse_templates(\%config, \%cxx); dump_hash(); print "\n"; @@ -430,115 +429,6 @@ if ($config{USE_GNUTLS} || $config{USE_OPENSSL}) { } print "*** \e[1;32mRemember to edit your configuration files!!!\e[0m ***\n\n"; -sub writefiles { - chomp(my $incos = `uname -n -s -r`); - chomp(my $version = `sh src/version.sh`); - my $revision = get_revision(); - my $branch = "InspIRCd-0.0"; - if ($version =~ /^(InspIRCd-[0-9]+\.[0-9]+)\.[0-9]+/) - { - $branch = $1; - } - print "Writing \e[1;32mconfig.h\e[0m\n"; - open(FILEHANDLE, ">include/config.h.tmp"); - print FILEHANDLE <; - close(FILEHANDLE); - - $config{COMPILER} = lc $cxx{NAME}; - $config{SYSTEM} = lc $^O; - - for my $var (qw( - CXX COMPILER SYSTEM BASE_DIR CONFIG_DIR MODULE_DIR BINARY_DIR DATA_DIR UID SOCKETENGINE - )) { - s/\@$var\@/$config{$var}/g; - } - - s/\@VERSION\@/$version/ if defined $version; - - if ($file eq 'main.mk') { - print "Writing \e[1;32mGNUmakefile\e[0m ...\n"; - - my $mk_tmp = $_; - s/\@IFDEF (\S+)/ifdef $1/g; - s/\@IFNDEF (\S+)/ifndef $1/g; - s/\@IFEQ (\S+) (\S+)/ifeq ($1,$2)/g; - s/\@IFNEQ (\S+) (\S+)/ifneq ($1,$2)/g; - s/\@ELSIFEQ (\S+) (\S+)/else ifeq ($1,$2)/g; - s/\@ELSE/else/g; - s/\@ENDIF/endif/g; - s/ *\@BSD_ONLY .*\n//g; - s/\@GNU_ONLY //g; - s/\@DO_EXPORT (.*)/export $1/g; - open MKF, '>GNUmakefile' or die "Can't write to GNUmakefile: $!"; - print MKF $_; - close MKF; - - print "Writing \e[1;32mBSDmakefile\e[0m ...\n"; - $_ = $mk_tmp; - s/\@IFDEF (\S+)/.if defined($1)/g; - s/\@IFNDEF (\S+)/.if !defined($1)/g; - s/\@IFEQ (\S+) (\S+)/.if $1 == $2/g; - s/\@IFNEQ (\S+) (\S+)/.if $1 != $2/g; - s/\@ELSIFEQ (\S+) (\S+)/.elif $1 == $2/g; - s/\@ELSE/.else/g; - s/\@ENDIF/.endif/g; - s/\@BSD_ONLY //g; - s/ *\@GNU_ONLY .*\n//g; - $mk_tmp = $_; - $mk_tmp =~ s#\@DO_EXPORT (.*)#"MAKEENV += ".join ' ', map "$_='\${$_}'", split /\s/, $1#eg; - open MKF, '>BSDmakefile' or die "Can't write to BSDmakefile: $!"; - print MKF $mk_tmp; - close MKF; - } else { - print "Writing \e[1;32m$file\e[0m ...\n"; - open(FILEHANDLE, ">$file") or die("Can't write to $file: $!\n"); - print FILEHANDLE $_; - close(FILEHANDLE); - } - } - - chmod 0750, 'inspircd'; -} - # Routine to list out the extra/ modules that have been enabled. # Note: when getting any filenames out and comparing, it's important to lc it if the # file system is not case-sensitive (== Epoc, MacOS, OS/2 (incl DOS/DJGPP), VMS, Win32 -- cgit v1.2.3