view gub/specs/darwin/cross/gcc.py @ 6185:71587882ddc3

{darwin-x86,freebsd-*}::cross/gcc: add rpath to LDFLAGS Fixes "libmpfr.so.1 not found" problem. /home/janneke/vc/gub/target/darwin-x86/build/cross/gcc-4.3.2/./gcc/cc1: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory
author Jan Nieuwenhuizen <janneke@gnu.org>
date Sat, 25 Aug 2012 12:21:41 +0200
parents 1e36ec372b52
children b8d258e3350a
line wrap: on
line source

import os
#
from gub.specs.cross import gcc as cross_gcc
from gub import loggedos
from gub import cross

class Gcc__darwin (cross_gcc.Gcc):
    source = 'ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.1.1/gcc-4.1.1.tar.bz2'
    dependencies = ['odcctools']
#    dependencies = ([x for x in cross_gcc.Gcc.dependencies
#                     if 'cross/binutils' not in x]
#                    + ['odcctools'])
    def patch (self):
        self.file_sub ([('/usr/bin/libtool', '%(cross_prefix)s/bin/%(target_architecture)s-libtool')],
                       '%(srcdir)s/gcc/config/darwin.h')

        self.file_sub ([('--strip-underscores', '--strip-underscore')],
                       '%(srcdir)s/libstdc++-v3/scripts/make_exports.pl')
        cross.AutoBuild.patch (self)
    def languages (self):
        # objective-c is used for quartz's Carbon/Carbon.h in pango, gtk+
        return cross_gcc.Gcc.languages (self) + ['objc', 'obj-c++']
    def rewire_gcc_libs (self):
        # FIXME: why do we skip, please document?
        # I get
        '''
/home/janneke/vc/gub/target/darwin-x86/root/usr/cross/bin/i686-apple-darwin8-ld: warning can't open dynamic library: /home/janneke/vc/gub/target/darwin-x86/root/home/janneke/vc/gub/target/darwin-x86/root/usr/cross/i686-apple-darwin8/lib/libgcc_s.1.dylib referenced from: /home/janneke/vc/gub/target/darwin-x86/root/usr/lib/libstdc++.dylib (checking for undefined symbols may be affected) (No such file or directory, errno = 2)
'''
        # let's try adding libstdc++.dylib?, nah, let's not
        skip_libs = ['libgcc_s'] #, 'libstdc++']

        def rewire_one (logger, file):
            found_skips = [s for s in skip_libs if file.find (s) >= 0]
            if found_skips:
                return
            id = loggedos.read_pipe (logger,
                                     self.expand ('%(toolchain_prefix)sotool -L %(file)s', 
                                                 locals ()),
                                     env=self.get_substitution_dict ()).split ()[1]
            id = os.path.split (id)[1]
            loggedos.system (logger, 
                             self.expand ('%(toolchain_prefix)sinstall_name_tool -id /usr/lib/%(id)s %(file)s',
                                          locals ()),
                             env=self.get_substitution_dict ())
        self.map_locate (rewire_one,
                         self.expand ('%(install_prefix)s/lib/'),
                         '*.dylib')
    def install (self):
        cross_gcc.Gcc.install (self)
        # conflicts with darwin-SDK
        self.system ('mv %(install_prefix)s/lib/libsupc++.a %(install_prefix)s/lib/libsupc++.a-')
        self.rewire_gcc_libs ()
    
class Gcc__darwin__x86 (Gcc__darwin):
    source = 'ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.3.2/gcc-4.3.2.tar.bz2'
    patches = ['gcc-4.3.2-no-fixed-includes.patch']
    dependencies = Gcc__darwin.dependencies + ['tools::mpfr']
    configure_command = (''' LDFLAGS='-L%(tools_prefix)s/lib %(rpath)s' '''
                         + Gcc__darwin.configure_command)

class Version_bump_builds_but_needs_a_test_Gcc__darwin__ppc (Gcc__darwin__x86):
    pass

class Not_used__Gcc__darwin (Gcc__darwin):
    def configure (self):
        cross_gcc.Gcc.configure (self)
    def install (self):
        cross_gcc.Gcc.install (self)
        self.rewire_gcc_libs ()