summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2014-04-14 12:42:22 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-05-23 14:13:51 +0200
commite6d245a3e80c0e0c05476e5bd9c45a77e16fecec (patch)
tree490b8e34f3bd0f9b85959782a1760e2c7e55fcea /configure
parentb512f1b9667ca0479d42e771082f3bc8d92c63a2 (diff)
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.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure118
1 files changed, 4 insertions, 114 deletions
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 <<EOF;
-/* Auto generated by configure, do not modify! */
-#pragma once
-
-#define BRANCH "$branch"
-#define VERSION "$version"
-#define REVISION "$revision"
-#define SYSTEM "$incos"
-#define INSPIRCD_SOCKETENGINE_NAME "$config{SOCKETENGINE}"
-
-#define CONFIG_PATH "$config{CONFIG_DIR}"
-#define DATA_PATH "$config{DATA_DIR}"
-#define LOG_PATH "$config{LOG_DIR}"
-#define MOD_PATH "$config{MODULE_DIR}"
-
-EOF
-
- if ($config{HAS_EVENTFD}) {
- print FILEHANDLE "#define HAS_EVENTFD\n";
- }
- if ($config{HAS_CLOCK_GETTIME}) {
- print FILEHANDLE "#define HAS_CLOCK_GETTIME\n";
- }
-
- print FILEHANDLE "\n#include \"threadengines/threadengine_pthread.h\"\n";
- close(FILEHANDLE);
-
- unlink 'include/config.h';
- rename 'include/config.h.tmp', 'include/config.h';
-
- # Do this once here, and cache it in the .*.inc files,
- # rather than attempting to read src/version.sh from
- # compiled code -- we might not have the source to hand.
-
- my @dotfiles = qw(main.mk inspircd);
- push @dotfiles, 'org.inspircd.plist' if $^O eq 'darwin';
-
- foreach my $file (@dotfiles) {
- open(FILEHANDLE, "make/template/$file") or die "Can't open make/template/$file: $!";
- $_ = join '', <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