1 # Automatic configuration of the UCW Library
2 # (c) 2005 Martin Mares <mj@ucw.cz>
4 ### Compiler and its Options ###
7 Test("CC", "Checking for C compiler", sub { return "gcc"; });
10 Test("GCCVER", "Checking for GCC version", sub {
12 my $ver = `$gcc --version | sed '2,\$d; s/^\\(.* \\)\\?\\([0-9]*\\.[0-9]*\\).*/\\2/'`;
14 Fail "Unable to determine GCC version" if $? || $ver eq "";
18 # C flags: tell the compiler we're speaking C99
19 Set("CLANG" => "-std=gnu99");
22 Set("COPT" => '-O2 -fstrict-aliasing -march=$(CPU_ARCH)');
24 # C optimizations for highly exposed code
25 Set("COPT2" => '-O3');
28 Set("CWARNS" => '-Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline');
36 # Extra flags for compiling and linking shared libraries
37 Set("CSHARED" => '-fPIC');
38 Set("LSHARED" => '-shared -Wl,-soname,lib/$(@F)');
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");
49 Log "WARNING: Don't know anything about this GCC version, using default switches.\n";
52 if (IsSet("CONFIG_DEBUG")) {
55 Set("DEBUG_DIE_BY_ABORT") if Get("CONFIG_DEBUG") > 1;
56 Set("CDEBUG" => "-ggdb");
58 # If building a release version:
59 Append("COPT" => "-fomit-frame-pointer");
60 Append("LOPT" => "-s");
63 # If debugging memory allocations:
65 #CDEBUG+=-DDEBUG_DMALLOC
68 ### CPU Type and Features ###
70 Set("CPU_ARCH" => 'i686') if !IsSet("CPU_ARCH");
72 Set("CPU_LITTLE_ENDIAN");
74 Set("CPU_ALLOW_UNALIGNED");
75 Set("CPU_STRUCT_ALIGN" => 4);
76 Set("CPU_64BIT_POINTERS");