]> mj.ucw.cz Git - libucw.git/blob - lib/autoconf.cfg
fed6f6c933906d31f7c3a6e24ed2245442a97d40
[libucw.git] / lib / autoconf.cfg
1 # Automatic configuration of the UCW Library
2 # (c) 2005 Martin Mares <mj@ucw.cz>
3
4 ### Compiler and its Options ###
5
6 # Default compiler
7 Test("CC", "Checking for C compiler", sub { return "gcc"; });
8
9 # GCC version
10 Test("GCCVER", "Checking for GCC version", sub {
11         my $gcc = Get("CC");
12         my $ver = `$gcc --version | sed '2,\$d; s/^\\(.* \\)\\?\\([0-9]*\\.[0-9]*\\).*/\\2/'`;
13         chomp $ver;
14         Fail "Unable to determine GCC version" if $? || $ver eq "";
15         return $ver;
16 });
17
18 # C flags: tell the compiler we're speaking C99
19 Set("CLANG" => "-std=gnu99");
20
21 # C optimizations
22 Set("COPT" => '-O2 -fstrict-aliasing -march=$(CPU_ARCH)');
23
24 # C optimizations for highly exposed code
25 Set("COPT2" => '-O3');
26
27 # Warnings
28 Set("CWARNS" => '-Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline');
29
30 # Linker flags
31 Set("LOPT" => "");
32
33 # Extra libraries
34 Set("LIBS" => "");
35
36 # Extra flags for compiling and linking shared libraries
37 Set("CSHARED" => '-fPIC');
38 Set("LSHARED" => '-shared -Wl,-soname,lib/$(@F)');
39
40 # Extra switches depending on GCC version:
41 if (Get("GCCVER") eq "3.0") {
42 } elsif (Get("GCCVER") eq "3.3") {
43         Append("CWARNS" => "-Wundef -Wredundant-decls");
44         Append("COPT" => "-finline-limit=20000 --param max-inline-insns-auto=1000");
45 } elsif (Get("GCCVER") eq "3.4") {
46         Append("CWARNS" => "-Wundef -Wredundant-decls");
47         Append("COPT" => "-finline-limit=5000 --param large-function-insns=5000 --param inline-unit-growth=200 --param large-function-growth=400");
48 } else {
49         Log "WARNING: Don't know anything about this GCC version, using default switches.\n";
50 }
51
52 if (IsSet("CONFIG_DEBUG")) {
53         # If debugging:
54         Set("DEBUG_ASSERTS");
55         Set("DEBUG_DIE_BY_ABORT") if Get("CONFIG_DEBUG") > 1;
56         Set("CDEBUG" => "-ggdb");
57 } else {
58         # If building a release version:
59         Append("COPT" => "-fomit-frame-pointer");
60         Append("LOPT" => "-s");
61 }
62
63 # If debugging memory allocations:
64 #LIBS+=-lefence
65 #CDEBUG+=-DDEBUG_DMALLOC
66 #LIBS+=-ldmalloc
67
68 ### CPU Type and Features ###
69
70 Set("CPU_ARCH" => 'i686') if !IsSet("CPU_ARCH");
71 Set("CPU_I386");
72 Set("CPU_LITTLE_ENDIAN");
73 #CPU_BIG_ENDIAN=1
74 Set("CPU_ALLOW_UNALIGNED");
75 Set("CPU_STRUCT_ALIGN" => 4);
76 Set("CPU_64BIT_POINTERS");
77
78 ### OS Type ###
79
80 Set("CONFIG_LINUX");
81
82 # Return success
83 1;