]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/perl/UCW/Configure/LibUCW.pm
UCW::CGI: Escaping functions silently convert undef to undef
[libucw.git] / ucw / perl / UCW / Configure / LibUCW.pm
index 8653fcdb049ac98a2e93a391cc64fd6ce0b74fff..7feef1e29dbc2c0faeb3f96d113868c058d56123 100644 (file)
@@ -1,5 +1,5 @@
 # UCW Library configuration system: parameters of the library
-# (c) 2005--2010 Martin Mares <mj@ucw.cz>
+# (c) 2005--2012 Martin Mares <mj@ucw.cz>
 # (c) 2006 Robert Spalek <robert@ucw.cz>
 # (c) 2008 Michal Vaner <vorner@ucw.cz>
 
@@ -9,6 +9,11 @@ use UCW::Configure;
 use strict;
 use warnings;
 
+# Turn on debugging support if CONFIG_DEBUG
+if (Get("CONFIG_DEBUG")) {
+       Set("CONFIG_UCW_DEBUG");
+}
+
 # Determine page size
 Test("CPU_PAGE_SIZE", "Determining page size", sub {
        my $p;
@@ -23,11 +28,6 @@ Test("CPU_PAGE_SIZE", "Determining page size", sub {
        return $p;
 });
 
-if (IsSet("CONFIG_LARGE_FILES") && IsSet("CONFIG_LINUX")) {
-       # Use 64-bit versions of file functions
-       Set("CONFIG_LFS");
-}
-
 # Decide how will ucw/partmap.c work
 Set("CONFIG_UCW_PARTMAP_IS_MMAP") if IsSet("CPU_64BIT_POINTERS");
 
@@ -35,13 +35,15 @@ Set("CONFIG_UCW_PARTMAP_IS_MMAP") if IsSet("CPU_64BIT_POINTERS");
 Set("CONFIG_UCW_POOL_IS_MMAP");
 
 # Guess optimal bit width of the radix-sorter
-if (Get("CPU_ARCH") eq "default" || Get("CPU_ARCH") =~ /^i[345]86$/) {
-       # This should be safe everywhere
-       Set("CONFIG_UCW_RADIX_SORTER_BITS" => 10);
-} else {
-       # Use this on modern CPU's
-       Set("CONFIG_UCW_RADIX_SORTER_BITS" => 12);
-}
+Test("CONFIG_UCW_RADIX_SORTER_BITS", "Determining radix sorter bucket width", sub {
+       if (Get("CPU_AMD64")) {
+               # All amd64 CPUs have large enough L1 cache
+               return 12;
+       } else {
+               # This should be safe everywhere
+               return 10;
+       }
+});
 
 # Detect if thread-local storage is supported
 if (Get("CONFIG_UCW_THREADS")) {
@@ -66,18 +68,34 @@ int main(void)
 FINIS
 });
 
+# Check if we want to use monotonic clock
+TestBool("CONFIG_UCW_MONOTONIC_CLOCK", "Checking for monotonic clock", sub {
+       return Get("CONFIG_LINUX");
+});
+
+if (IsSet("CONFIG_DARWIN")) {
+       # Darwin does not support BSD regexes, fix up
+       if (!IsSet("CONFIG_UCW_POSIX_REGEX") && !IsSet("CONFIG_UCW_PCRE")) {
+               Set("CONFIG_UCW_POSIX_REGEX" => 1);
+               Warn "BSD regex library on Darwin isn't compatible, using POSIX regex.\n";
+       }
+
+       # Fill in some constants not found in the system header files
+       Set("SOL_TCP" => 6);            # missing in /usr/include/netinet/tcp.h
+       if (IsGiven("CONFIG_UCW_DIRECT_IO") && IsSet("CONFIG_UCW_DIRECT_IO")) {
+               Fail("Direct I/O is not available on darwin");
+       } else {
+               UnSet("CONFIG_UCW_DIRECT_IO");
+       }
+}
+
 PostConfig {
        AtWrite {
                UCW::Configure::C::ConfigHeader("ucw/autoconf.h", [
-                       # Excluded symbols (danger of collision)
-                       '^CONFIG_DEBUG$' => 0,
-
                        # Included symbols
-                       '^CONFIG_' => 1,
+                       '^CONFIG_UCW_' => 1,
                        '^CPU_' => 1,
-                       '^(SHERLOCK|UCW)_VERSION(_|$)' => 1,
-                       '^MAX_WORD_(BYTES|CHARS)$' => 1,
-
+                       '^UCW_VERSION(_|$)' => 1,
                ]);
        } if Get("CONFIG_INSTALL_API");