From 238f36749a3e861b855fd1149ccfe814116e6466 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 12 Apr 2005 18:39:10 +0000 Subject: [PATCH] More progress on the new configurator. All configurations have been converted. The centrum/cz config decides on configuration according to host name. Autoconf is able to auto-detect gcc. --- build/sherlock.cfg | 2 +- lib/autoconf.cfg | 56 +++++++++++++++++++++++++++---------------- lib/perl/Configure.pm | 19 +++++++++++---- 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/build/sherlock.cfg b/build/sherlock.cfg index abdeb4ae..b8d59026 100644 --- a/build/sherlock.cfg +++ b/build/sherlock.cfg @@ -13,7 +13,7 @@ Set("INSTALL_DIR" => "~/run-3.5"); Set("CONFIG_GATHERER"); # The gatherer daemon (requires CONFIG_GATHERER) -UnSet("CONFIG_GATHERD"); +Set("CONFIG_GATHERD"); # Indexer Set("CONFIG_INDEXER"); diff --git a/lib/autoconf.cfg b/lib/autoconf.cfg index 2fea596c..fed6f6c9 100644 --- a/lib/autoconf.cfg +++ b/lib/autoconf.cfg @@ -1,7 +1,19 @@ # Automatic configuration of the UCW Library # (c) 2005 Martin Mares -Set("CC" => "gcc-3.0"); +### Compiler and its Options ### + +# Default compiler +Test("CC", "Checking for C compiler", sub { return "gcc"; }); + +# GCC version +Test("GCCVER", "Checking for GCC version", sub { + my $gcc = Get("CC"); + my $ver = `$gcc --version | sed '2,\$d; s/^\\(.* \\)\\?\\([0-9]*\\.[0-9]*\\).*/\\2/'`; + chomp $ver; + Fail "Unable to determine GCC version" if $? || $ver eq ""; + return $ver; +}); # C flags: tell the compiler we're speaking C99 Set("CLANG" => "-std=gnu99"); @@ -26,34 +38,36 @@ Set("CSHARED" => '-fPIC'); Set("LSHARED" => '-shared -Wl,-soname,lib/$(@F)'); # Extra switches depending on GCC version: -# [FIXME] -#GCCVER:=$(shell $(CC) --version | sed '2,$$d; s/^\(.* \)\?\([0-9]*\.[0-9]*\).*/\2/') -#ifeq ($(GCCVER),3.3) -#CWARNS+=-Wundef -Wredundant-decls -#COPT+=-finline-limit=20000 --param max-inline-insns-auto=1000 -#endif -#ifeq ($(GCCVER),3.4) -#CWARNS+=-Wundef -Wredundant-decls -#COPT+=-finline-limit=5000 --param large-function-insns=5000 --param inline-unit-growth=200 --param large-function-growth=400 -#endif - -# If debugging: -Set("CDEBUG" => '-DDEBUG_ASSERTS -ggdb'); -#CDEBUG+=-DDEBUG_DIE_BY_ABORT +if (Get("GCCVER") eq "3.0") { +} elsif (Get("GCCVER") eq "3.3") { + Append("CWARNS" => "-Wundef -Wredundant-decls"); + Append("COPT" => "-finline-limit=20000 --param max-inline-insns-auto=1000"); +} elsif (Get("GCCVER") eq "3.4") { + Append("CWARNS" => "-Wundef -Wredundant-decls"); + Append("COPT" => "-finline-limit=5000 --param large-function-insns=5000 --param inline-unit-growth=200 --param large-function-growth=400"); +} else { + Log "WARNING: Don't know anything about this GCC version, using default switches.\n"; +} + +if (IsSet("CONFIG_DEBUG")) { + # If debugging: + Set("DEBUG_ASSERTS"); + Set("DEBUG_DIE_BY_ABORT") if Get("CONFIG_DEBUG") > 1; + Set("CDEBUG" => "-ggdb"); +} else { + # If building a release version: + Append("COPT" => "-fomit-frame-pointer"); + Append("LOPT" => "-s"); +} # If debugging memory allocations: #LIBS+=-lefence #CDEBUG+=-DDEBUG_DMALLOC #LIBS+=-ldmalloc -# If building release versions: -#CDEBUG= -#COPT+=-fomit-frame-pointer -#LOPT+=-s - ### CPU Type and Features ### -Set("CPU_ARCH" => 'i686'); +Set("CPU_ARCH" => 'i686') if !IsSet("CPU_ARCH"); Set("CPU_I386"); Set("CPU_LITTLE_ENDIAN"); #CPU_BIG_ENDIAN=1 diff --git a/lib/perl/Configure.pm b/lib/perl/Configure.pm index 6900dbe3..ee1c83df 100644 --- a/lib/perl/Configure.pm +++ b/lib/perl/Configure.pm @@ -16,7 +16,7 @@ BEGIN { our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); $VERSION = 1.0; @ISA = qw(Exporter); - @EXPORT = qw(&Init &Log &Fail &IsSet &Set &UnSet &Override &Get &Test &Include &Finish &FindFile &TryFindFile); + @EXPORT = qw(&Init &Log &Notice &Fail &IsSet &Set &UnSet &Append &Override &Get &Test &Include &Finish &FindFile &TryFindFile); @EXPORT_OK = qw(); %EXPORT_TAGS = (); } @@ -28,6 +28,10 @@ sub Log($) { print @_; } +sub Notice($) { + print @_ if $vars{"VERBOSE"}; +} + sub Fail($) { Log((shift @_) . "\n"); exit 1; @@ -54,6 +58,11 @@ sub UnSet($) { delete $vars{$x} unless $overriden{$x}; } +sub Append($$) { + my ($x,$y) = @_; + Set($x, (IsSet($x) ? (Get($x) . " $y") : $y)); +} + sub Override($;$) { my ($x,$y) = @_; $y=1 unless defined $y; @@ -63,7 +72,7 @@ sub Override($;$) { sub Test($$$) { my ($var,$msg,$sub) = @_; - Log "$msg... "; + Log "$msg ... "; if (!IsSet($var)) { Set $var, &$sub(); } @@ -125,7 +134,7 @@ sub Init($$) { sub Include($) { my ($f) = @_; $f = FindFile($f); - Log "Loading configuration $f\n"; + Notice "Loading configuration $f\n"; require $f; } @@ -148,7 +157,7 @@ sub Finish() { -d "obj/lib" or mkdir("obj/lib", 0777) or Fail "Cannot create obj/lib directory: $!"; Log "done\n"; - Log "Generating autoconf.h... "; + Log "Generating autoconf.h ... "; open X, ">obj/lib/autoconf.h" or Fail $!; print X "/* Generated automatically by $0, please don't touch manually. */\n"; foreach my $x (sort keys %vars) { @@ -162,7 +171,7 @@ sub Finish() { close X; Log "done\n"; - Log "Generating config.mk... "; + Log "Generating config.mk ... "; open X, ">obj/config.mk" or Fail $!; print X "# Generated automatically by $0, please don't touch manually.\n"; foreach my $x (sort keys %vars) { -- 2.39.2