X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=perl%2FUCW%2FConfigure%2FC.pm;h=730b5145357a87da048b2196b6447e5944c7d113;hb=aec3aea0c865154a35d7f04dfa86da95fdaea4da;hp=e961ca009f9c07ad34a3447759313afae3357b4f;hpb=3d14be2fa32fe908dfef0f6ac3b76067c080a43a;p=leo.git diff --git a/perl/UCW/Configure/C.pm b/perl/UCW/Configure/C.pm index e961ca0..730b514 100644 --- a/perl/UCW/Configure/C.pm +++ b/perl/UCW/Configure/C.pm @@ -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,20 @@ 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 ($arch eq "armhf") { + Set("CPU_ARM"); + UnSet("CPU_64BIT_POINTERS"); + Set("CPU_LITTLE_ENDIAN"); + UnSet("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."; } @@ -119,17 +135,20 @@ Set("LIBS" => ""); # Extra flags for compiling and linking shared libraries Set("CSHARED" => '-fPIC'); -Append("LOPT" => "-Wl,--rpath-link,run/lib"); -if (Get("INSTALL_LIB_DIR") eq "/usr/lib") { +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 { - # FIXME: This is a hack. GCC would otherwise fail to link binaries. my $libdir = Get("INSTALL_LIB_DIR"); - if (IsSet("CONFIG_SHARED") && !(-d $libdir)) { - `install -d -m 755 $libdir`; Fail("Cannot create $libdir") if $?; + if (IsSet("CONFIG_SHARED")) { + `mkdir -p $libdir`; Fail("Cannot create $libdir") if $?; } }; } @@ -167,6 +186,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");