]> mj.ucw.cz Git - libucw.git/blob - ucw/perl/UCW/Configure/LibUCW.pm
Main: Poll table turned into a growing array
[libucw.git] / ucw / perl / UCW / Configure / LibUCW.pm
1 # UCW Library configuration system: parameters of the library
2 # (c) 2005--2010 Martin Mares <mj@ucw.cz>
3 # (c) 2006 Robert Spalek <robert@ucw.cz>
4 # (c) 2008 Michal Vaner <vorner@ucw.cz>
5
6 package UCW::Configure::LibUCW;
7 use UCW::Configure;
8
9 use strict;
10 use warnings;
11
12 # Determine page size
13 Test("CPU_PAGE_SIZE", "Determining page size", sub {
14         my $p;
15         if (IsSet("CONFIG_DARWIN")) {
16                 $p = `sysctl -n hw.pagesize`;
17                 defined $p or Fail "sysctl hw.pagesize failed";
18         } elsif (IsSet("CONFIG_LINUX")) {
19                 $p = `getconf PAGE_SIZE`;
20                 defined $p or Fail "getconf PAGE_SIZE failed";
21         }
22         chomp $p;
23         return $p;
24 });
25
26 if (IsSet("CONFIG_LARGE_FILES") && IsSet("CONFIG_LINUX")) {
27         # Use 64-bit versions of file functions
28         Set("CONFIG_LFS");
29 }
30
31 # Decide how will ucw/partmap.c work
32 Set("CONFIG_UCW_PARTMAP_IS_MMAP") if IsSet("CPU_64BIT_POINTERS");
33
34 # Option for ucw/mempool.c
35 Set("CONFIG_UCW_POOL_IS_MMAP");
36
37 # Guess optimal bit width of the radix-sorter
38 if (Get("CPU_ARCH") eq "default" || Get("CPU_ARCH") =~ /^i[345]86$/) {
39         # This should be safe everywhere
40         Set("CONFIG_UCW_RADIX_SORTER_BITS" => 10);
41 } else {
42         # Use this on modern CPU's
43         Set("CONFIG_UCW_RADIX_SORTER_BITS" => 12);
44 }
45
46 # Detect if thread-local storage is supported
47 if (Get("CONFIG_UCW_THREADS")) {
48         TestBool("CONFIG_UCW_TLS", "Checking if GCC supports thread-local storage", sub {
49                 if (UCW::Configure::C::TestCompile("__thread", "__thread int i;\nint main(void) { return 0; }\n")) {
50                         return 1;
51                 } else {
52                         return 0;
53                 }
54         });
55 }
56
57 PostConfig {
58         AtWrite {
59                 UCW::Configure::C::ConfigHeader("ucw/autoconf.h", [
60                         # Excluded symbols (danger of collision)
61                         '^CONFIG_DEBUG$' => 0,
62
63                         # Included symbols
64                         '^CONFIG_' => 1,
65                         '^CPU_' => 1,
66                         '^(SHERLOCK|UCW)_VERSION(_|$)' => 1,
67                         '^MAX_WORD_(BYTES|CHARS)$' => 1,
68
69                 ]);
70         } if Get("CONFIG_INSTALL_API");
71
72         # Include direct FB?
73         if (!IsSet("CONFIG_UCW_THREADS") || !IsSet("CONFIG_DIRECT_IO")) {
74                 if (IsGiven("CONFIG_UCW_FB_DIRECT") && IsSet("CONFIG_UCW_FB_DIRECT")) {
75                         if (!IsSet("CONFIG_UCW_THREADS")) {
76                                 Fail("CONFIG_UCW_FB_DIRECT needs CONFIG_UCW_THREADS");
77                         } else {
78                                 Fail("CONFIG_UCW_FB_DIRECT needs CONFIG_DIRECT_IO");
79                         }
80                 }
81                 UnSet("CONFIG_UCW_FB_DIRECT");
82         }
83 };
84
85 # We succeeded
86 1;