]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/perl/UCW/Configure/C.pm
Configure: Settings for powerpc
[libucw.git] / ucw / perl / UCW / Configure / C.pm
index 0143c31d136b23e2dc67888f8e8372680f7d2612..b14759258ff9c83eb9a45311be989eb6482c25a9 100644 (file)
@@ -65,6 +65,8 @@ Test("ARCH", "Checking for machine architecture", sub {
                return "i386";
        } elsif ($mach =~ /^(x86[_-]|amd)64$/) {
                return "amd64";
+       } elsif ($mach eq 'powerpc') {
+               return $mach;
        } else {
                return "unknown ($mach)";
        }
@@ -85,6 +87,13 @@ if ($arch eq 'i386') {
        UnSet("CPU_BIG_ENDIAN");
        Set("CPU_ALLOW_UNALIGNED");
        Set("CPU_STRUCT_ALIGN" => 8);
+} elsif ($arch eq "powerpc") {
+       Set("CPU_AMD64");
+       UnSet("CPU_64BIT_POINTERS");
+       UnSet("CPU_LITTLE_ENDIAN");
+       Set("CPU_BIG_ENDIAN");
+       UnSet("CPU_ALLOW_UNALIGNED");
+       Set("CPU_STRUCT_ALIGN" => 4);
 } elsif (!Get("CPU_LITTLE_ENDIAN") && !Get("CPU_BIG_ENDIAN")) {
        Fail "Architecture not recognized, please set CPU_xxx variables manually.";
 }
@@ -108,7 +117,7 @@ if ($arch =~ /^(i386|amd64)$/ && Get("CONFIG_EXACT_CPU")) {
 Set("COPT2" => '-O3');
 
 # Warnings
-Set("CWARNS" => '-Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline');
+Set("CWARNS" => '-Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes');
 Set("CWARNS_OFF" => '');
 
 # Linker flags
@@ -119,15 +128,27 @@ Set("LIBS" => "");
 
 # Extra flags for compiling and linking shared libraries
 Set("CSHARED" => '-fPIC');
-if (IsSet("CONFIG_LOCAL")) {
-       Set("SONAME_PREFIX" => "lib/");
-} else {
-       Set("SONAME_PREFIX" => "");
+Append("LOPT" => "-Wl,--rpath-link,run/lib -Lrun/lib");
+if (!IsSet("CONFIG_LOCAL")) {
+       # Beware that in non-local builds the INSTALL_LIB_DIR must exist in
+       # standard search paths for shared libraries.
+       Set("SO_LINK_PATH" => '');
+}
+else {
+       # In local builds, we need to link binaries with custom --rpath.
+       # GCC seems to fail when this directory does not exist.
+       Set("SO_LINK_PATH" => "-Wl,--rpath," . Get("INSTALL_LIB_DIR"));
+       AtWrite {
+               my $libdir = Get("INSTALL_LIB_DIR");
+               if (IsSet("CONFIG_SHARED")) {
+                       `mkdir -p $libdir`; Fail("Cannot create $libdir") if $?;
+               }
+       };
 }
 if (IsSet("CONFIG_DARWIN")) {
-       Set("LSHARED" => '-dynamiclib -install_name $(SONAME_PREFIX)$(@F)$(SONAME_SUFFIX) -undefined dynamic_lookup');
+       Set("LSHARED" => '-dynamiclib -install_name $(@F)$(SONAME_SUFFIX) -undefined dynamic_lookup');
 } else {
-       Set("LSHARED" => '-shared -Wl,-soname,$(SONAME_PREFIX)$(@F)$(SONAME_SUFFIX)');
+       Set("LSHARED" => '-shared -Wl,-soname,$(@F)$(SONAME_SUFFIX)');
 }
 
 # Extra switches depending on GCC version:
@@ -143,9 +164,6 @@ if ($gccver == 3000) {
        Append("CWARNS" => "-Wundef -Wredundant-decls -Wno-pointer-sign -Wdisabled-optimization -Wno-missing-field-initializers");
        Append("CWARNS_OFF" => "-Wno-pointer-sign");
        Append("COPT" => "-finline-limit=5000 --param large-function-insns=5000 --param inline-unit-growth=200 --param large-function-growth=400");
-       if ($gccver >= 4002) {
-               Append("COPT" => "-fgnu89-inline");
-       }
 } else {
        Warn "Don't know anything about this GCC version, using default switches.\n";
 }
@@ -161,6 +179,16 @@ if (IsSet("CONFIG_DEBUG")) {
        Append("LOPT" => "-s");
 }
 
+# Link-time optimization (experimental)
+# This is currently very inefficient, because we do not attempt to disable
+# optimizations when compiling individual modules. Therefore, we optimize
+# each shared library module twice: when compiling and when linking.
+# Doing it properly would require hacking makefiles.
+if (IsSet("CONFIG_LTO")) {
+       Append("LOPT", "-flto");
+       Append("COPT", "-flto");
+}
+
 if (IsSet("CONFIG_DARWIN")) {
        # gcc-4.0 on Darwin doesn't set this in the gnu99 mode
        Append("CLANG" => "-fnested-functions");