]> mj.ucw.cz Git - libucw.git/commitdiff
Added first pieces of the new configuration mechanism. (Not connected
authorMartin Mares <mj@ucw.cz>
Tue, 12 Apr 2005 13:25:34 +0000 (13:25 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 12 Apr 2005 13:25:34 +0000 (13:25 +0000)
to the rest of Sherlock yet, so you can still build Sherlock as usually.)

build/sherlock.cfg [new file with mode: 0644]
lib/autoconf.cfg [new file with mode: 0644]
lib/perl/Configure.pm [new file with mode: 0644]

diff --git a/build/sherlock.cfg b/build/sherlock.cfg
new file mode 100644 (file)
index 0000000..a94eb57
--- /dev/null
@@ -0,0 +1,148 @@
+# Configuration variables of Sherlock and their default values
+# (c) 2005 Martin Mares <mj@ucw.cz>
+
+# Version of the whole package
+Set("SHERLOCK_VERSION" => "3.5");
+
+# Installation directory for `make install'
+Set("INSTALL_DIR" => "~/run-3.5");
+
+### Standard modules available in all releases of Sherlock ###
+
+# Gatherer (the gatherer library and some utilities) [FIXME: decide automatically?]
+Set("CONFIG_GATHERER");
+
+# The gatherer daemon (requires CONFIG_GATHERER)
+UnSet("CONFIG_GATHERD");
+
+# Indexer
+Set("CONFIG_INDEXER");
+
+# Search server
+Set("CONFIG_SEARCH");
+
+# Watson: The Monitoring System
+UnSet("CONFIG_WATSON");
+
+#ifndef CONFIG_FREE
+### These are available in the commercial version only: ###
+
+# The Shepherd daemon (requires CONFIG_GATHERER and CONFIG_SHEPHERD_PROTOCOL)
+UnSet("CONFIG_SHEPHERD");
+
+# Support for Shepherd protocols everywhere (distributed indexing etc.)
+UnSet("CONFIG_SHEPHERD_PROTOCOL");
+
+# The reaper daemon, used by Shepherd to download the pages (requires CONFIG_GATHERER)
+UnSet("CONFIG_REAPD");
+
+# The multiplexer
+UnSet("CONFIG_MUX");
+
+#endif
+
+### Optional Modules & Features ###
+
+# Number of sections we remember limits for
+Set("SHERLOCK_NUM_SECTIONS" => 4);
+
+# Use shared libraries
+UnSet("CONFIG_SHARED");
+
+# Gathering of PDF files
+Set("CONFIG_PDF");
+
+# Searching by last modification time
+Set("CONFIG_LASTMOD");
+
+# Searching by file type
+Set("CONFIG_FILETYPE");
+
+# Language processing (requires CONFIG_FILETYPE)
+Set("CONFIG_LANG");
+
+# Spelling checker
+Set("CONFIG_SPELL");
+
+# Enable indexing of context-dependent words and set maximum number
+# of context slots (undef, 256 or 32768). Lower values save memory, higher time.
+Set("CONFIG_MAX_CONTEXTS" => 256);
+
+# Enable more than 16-bit word positions in references
+Set("CONFIG_32BIT_REFERENCES");
+
+# Debugging tools
+Set("CONFIG_DEBUG");
+
+# Search server: Enable EXPLAIN command (slows searching down slightly)
+Set("CONFIG_EXPLAIN");
+
+# If your system doesn't contain GNU libc 2.3 or newer, it's recommended to let Sherlock
+# use its own regex library (a copy of the glibc one), because the default regex library
+# is likely to be crappy.
+Set("CONFIG_OWN_REGEX");
+
+# Include custom builtin functions in filtering language
+UnSet("CONFIG_CUSTOM_FILTER");
+
+# Install libraries and their API includes
+UnSet("CONFIG_INSTALL_API");
+
+#ifndef CONFIG_FREE
+# Number of refresh frequencies we allow
+Set("SHERLOCK_NUM_FREQS" => 5);
+
+# Gathering and indexing split to areas
+UnSet("CONFIG_AREAS");
+
+# Site compression
+UnSet("CONFIG_SITES");
+
+# Gathering of images
+UnSet("CONFIG_IMAGES");
+
+# Gathering of MS Word files
+UnSet("CONFIG_MSWORD");
+
+# Gathering of MS Excel files
+UnSet("CONFIG_EXCEL");
+
+# Extra stuff for Centrum
+UnSet("CONFIG_CENTRUM");
+
+# Configuration for Morfeo
+UnSet("CONFIG_MORFEO");
+
+# Stemmer by UFAL and its dictionaries
+UnSet("CONFIG_UFAL_STEMMER");
+UnSet("CONFIG_UFAL_DICT_CS");
+UnSet("CONFIG_UFAL_DICT_SK");
+
+# Stemmer for Polish with its dictionary
+UnSet("CONFIG_PL_STEMMER");
+
+# Dynamic weights
+Set("CONFIG_WEIGHTS");
+
+#endif
+
+### These are internal settings which shouldn't be modified by custom configs ###
+
+# Default configuration file
+Set("DEFAULT_CONFIG" => "cf/sherlock");
+
+# Configuration of parts of the UCW library
+Set("CONFIG_UCW_PERL" => 1);
+Set("CONFIG_SHELL_UTILS" => 1);
+
+# Configuration of the language library
+Set("CONFIG_LANG_DETECT" => 1);
+
+# We always want to be able to use large files
+Set("CONFIG_LFS" => 1);
+
+# Maximum word length common for Sherlock and liblang, see comments in sherlock/index.h
+Set("MAX_WORD_LEN" => 64);
+
+# Return success
+1;
diff --git a/lib/autoconf.cfg b/lib/autoconf.cfg
new file mode 100644 (file)
index 0000000..2fea596
--- /dev/null
@@ -0,0 +1,69 @@
+# Automatic configuration of the UCW Library
+# (c) 2005 Martin Mares <mj@ucw.cz>
+
+Set("CC" => "gcc-3.0");
+
+# C flags: tell the compiler we're speaking C99
+Set("CLANG" => "-std=gnu99");
+
+# C optimizations
+Set("COPT" => '-O2 -fstrict-aliasing -march=$(CPU_ARCH)');
+
+# C optimizations for highly exposed code
+Set("COPT2" => '-O3');
+
+# Warnings
+Set("CWARNS" => '-Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline');
+
+# Linker flags
+Set("LOPT" => "");
+
+# Extra libraries
+Set("LIBS" => "");
+
+# Extra flags for compiling and linking shared libraries
+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 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_I386");
+Set("CPU_LITTLE_ENDIAN");
+#CPU_BIG_ENDIAN=1
+Set("CPU_ALLOW_UNALIGNED");
+Set("CPU_STRUCT_ALIGN" => 4);
+Set("CPU_64BIT_POINTERS");
+
+### OS Type ###
+
+Set("CONFIG_LINUX");
+
+# Return success
+1;
diff --git a/lib/perl/Configure.pm b/lib/perl/Configure.pm
new file mode 100644 (file)
index 0000000..bbc6e82
--- /dev/null
@@ -0,0 +1,132 @@
+#      Perl module for UCW Configure Scripts
+#
+#      (c) 2005 Martin Mares <mj@ucw.cz>
+#
+#      This software may be freely distributed and used according to the terms
+#      of the GNU Lesser General Public License.
+
+package UCW::Configure;
+
+use strict;
+use warnings;
+
+BEGIN {
+       # The somewhat hairy Perl export mechanism
+       use Exporter();
+       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);
+       @EXPORT_OK = qw();
+       %EXPORT_TAGS = ();
+}
+
+our %vars = ();
+our %overriden = ();
+
+sub Log($) {
+       print @_;
+}
+
+sub Fail($) {
+       Log((shift @_) . "\n");
+       exit 1;
+}
+
+sub IsSet($) {
+       my ($x) = @_;
+       return exists $vars{$x};
+}
+
+sub Get($) {
+       my ($x) = @_;
+       return $vars{$x};
+}
+
+sub Set($;$) {
+       my ($x,$y) = @_;
+       $y=1 unless defined $y;
+       $vars{$x}=$y unless $overriden{$x};
+}
+
+sub UnSet($) {
+       my ($x) = @_;
+       delete $vars{$x} unless $overriden{$x};
+}
+
+sub Override($;$) {
+       my ($x,$y) = @_;
+       $y=1 unless defined $y;
+       $vars{$x}=$y;
+       $overriden{$x} = 1;
+}
+
+sub Test($$$) {
+       my ($var,$msg,$sub) = @_;
+       Log "$msg... ";
+       if (!IsSet($var)) {
+               Set $var, &$sub();
+       }
+       Log Get($var) . "\n";
+}
+
+sub TryFindFile($) {
+       my ($f) = @_;
+       if (-f $f) {
+               return $f;
+       } elsif ($f !~ /^\// && -f (Get("SRCDIR")."/$f")) {
+               return Get("SRCDIR")."/$f";
+       } else {
+               return undef;
+       }
+}
+
+sub FindFile($) {
+       my ($f) = @_;
+       my $F;
+       defined ($F = TryFindFile($f)) or Fail "Cannot find file $f";
+       return $F;
+}
+
+sub Init($$) {
+       my ($srcdir,$defconfig) = @_;
+       if ((!defined $defconfig && !@ARGV) || @ARGV && $ARGV[0] eq "--help") {
+               print STDERR "Usage: [<srcdir>/]configure " . (defined $defconfig ? "[" : "") . "<config-name>" . (defined $defconfig ? "]" : "") .
+                       " [<option>[=<value>] | -<option>] ...\n";
+               exit 1;
+       }
+       if (@ARGV && $ARGV[0] !~ /=/) {
+               Set('CONFIG' => shift @ARGV);
+       } else {
+               Set('CONFIG' => $defconfig);
+       }
+       Set("SRCDIR", $srcdir);
+
+       foreach my $x (@ARGV) {
+               if ($x =~ /^(\w+)=(.*)/) {
+                       Override($1 => $2);
+               } elsif ($x =~ /^-(\w+)$/) {
+                       Override($1 => 1);
+                       delete $vars{$1};
+               } elsif ($x =~ /^(\w+)$/) {
+                       Override($1 => 1);
+               } else {
+                       print STDERR "Invalid option $_\n";
+                       exit 1;
+               }
+       }
+
+       if (!TryFindFile(Get("CONFIG"))) {
+               TryFindFile(Get("CONFIG")."/config") or Fail "Cannot find configuration " . Get("CONFIG");
+               Override("CONFIG" => Get("CONFIG")."/config");
+       }
+}
+
+sub Include($) {
+       my ($f) = @_;
+       $f = FindFile($f);
+       Log "Loading configuration $f\n";
+       require $f;
+}
+
+1;  # OK