~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to tools/wafadmin/Tools/gxx.py

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# encoding: utf-8
3
 
# Thomas Nagy, 2006 (ita)
4
 
# Ralf Habacker, 2006 (rh)
5
 
# Yinon Ehrlich, 2009
6
 
 
7
 
import os, sys
8
 
import Configure, Options, Utils
9
 
import ccroot, ar
10
 
from Configure import conftest
11
 
 
12
 
@conftest
13
 
def find_gxx(conf):
14
 
        cxx = conf.find_program(['g++', 'c++'], var='CXX', mandatory=True)
15
 
        cxx = conf.cmd_to_list(cxx)
16
 
        ccroot.get_cc_version(conf, cxx, gcc=True)
17
 
        conf.env.CXX_NAME = 'gcc'
18
 
        conf.env.CXX      = cxx
19
 
 
20
 
@conftest
21
 
def gxx_common_flags(conf):
22
 
        v = conf.env
23
 
 
24
 
        # CPPFLAGS CXXDEFINES _CXXINCFLAGS _CXXDEFFLAGS
25
 
        v['CXXFLAGS_DEBUG'] = ['-g']
26
 
        v['CXXFLAGS_RELEASE'] = ['-O2']
27
 
 
28
 
        v['CXX_SRC_F']           = ''
29
 
        v['CXX_TGT_F']           = ['-c', '-o', ''] # shell hack for -MD
30
 
        v['CPPPATH_ST']          = '-I%s' # template for adding include paths
31
 
 
32
 
        # linker
33
 
        if not v['LINK_CXX']: v['LINK_CXX'] = v['CXX']
34
 
        v['CXXLNK_SRC_F']        = ''
35
 
        v['CXXLNK_TGT_F']        = ['-o', ''] # shell hack for -MD
36
 
 
37
 
        v['LIB_ST']              = '-l%s' # template for adding libs
38
 
        v['LIBPATH_ST']          = '-L%s' # template for adding libpaths
39
 
        v['STATICLIB_ST']        = '-l%s'
40
 
        v['STATICLIBPATH_ST']    = '-L%s'
41
 
        v['RPATH_ST']            = '-Wl,-rpath,%s'
42
 
        v['CXXDEFINES_ST']       = '-D%s'
43
 
 
44
 
        v['SONAME_ST']           = '-Wl,-h,%s'
45
 
        v['SHLIB_MARKER']        = '-Wl,-Bdynamic'
46
 
        v['STATICLIB_MARKER']    = '-Wl,-Bstatic'
47
 
        v['FULLSTATIC_MARKER']   = '-static'
48
 
 
49
 
        # program
50
 
        v['program_PATTERN']     = '%s'
51
 
 
52
 
        # shared library
53
 
        v['shlib_CXXFLAGS']      = ['-fPIC', '-DPIC'] # avoid using -DPIC, -fPIC aleady defines the __PIC__ macro
54
 
        v['shlib_LINKFLAGS']     = ['-shared']
55
 
        v['shlib_PATTERN']       = 'lib%s.so'
56
 
 
57
 
        # static lib
58
 
        v['staticlib_LINKFLAGS'] = ['-Wl,-Bstatic']
59
 
        v['staticlib_PATTERN']   = 'lib%s.a'
60
 
 
61
 
        # osx stuff
62
 
        v['LINKFLAGS_MACBUNDLE'] = ['-bundle', '-undefined', 'dynamic_lookup']
63
 
        v['CCFLAGS_MACBUNDLE']   = ['-fPIC']
64
 
        v['macbundle_PATTERN']   = '%s.bundle'
65
 
 
66
 
@conftest
67
 
def gxx_modifier_win32(conf):
68
 
        v = conf.env
69
 
        v['program_PATTERN']     = '%s.exe'
70
 
 
71
 
        v['shlib_PATTERN']       = '%s.dll'
72
 
        v['implib_PATTERN']      = 'lib%s.dll.a'
73
 
        v['IMPLIB_ST']           = '-Wl,--out-implib,%s'
74
 
 
75
 
        dest_arch = v['DEST_CPU']
76
 
        if dest_arch == 'x86':
77
 
                # On 32-bit x86, gcc emits a message telling the -fPIC option is ignored on this arch, so we remove that flag.
78
 
                v['shlib_CXXFLAGS'] = ['-DPIC'] # TODO this is a wrong define, we don't use -fPIC!
79
 
 
80
 
        v.append_value('shlib_CXXFLAGS', '-DDLL_EXPORT') # TODO adding nonstandard defines like this DLL_EXPORT is not a good idea
81
 
 
82
 
        # Auto-import is enabled by default even without this option,
83
 
        # but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
84
 
        # that the linker emits otherwise.
85
 
        v.append_value('LINKFLAGS', '-Wl,--enable-auto-import')
86
 
 
87
 
@conftest
88
 
def gxx_modifier_cygwin(conf):
89
 
        gxx_modifier_win32(conf)
90
 
        v = conf.env
91
 
        v['shlib_PATTERN']       = 'cyg%s.dll'
92
 
        v.append_value('shlib_LINKFLAGS', '-Wl,--enable-auto-image-base')
93
 
 
94
 
@conftest
95
 
def gxx_modifier_darwin(conf):
96
 
        v = conf.env
97
 
        v['shlib_CXXFLAGS']      = ['-fPIC', '-compatibility_version', '1', '-current_version', '1']
98
 
        v['shlib_LINKFLAGS']     = ['-dynamiclib']
99
 
        v['shlib_PATTERN']       = 'lib%s.dylib'
100
 
 
101
 
        v['staticlib_LINKFLAGS'] = []
102
 
 
103
 
        v['SHLIB_MARKER']        = ''
104
 
        v['STATICLIB_MARKER']    = ''
105
 
        v['SONAME_ST']           = ''   
106
 
 
107
 
@conftest
108
 
def gxx_modifier_aix(conf):
109
 
        v = conf.env
110
 
        v['program_LINKFLAGS']   = ['-Wl,-brtl']
111
 
 
112
 
        v['shlib_LINKFLAGS']     = ['-shared', '-Wl,-brtl,-bexpfull']
113
 
 
114
 
        v['SHLIB_MARKER']        = ''
115
 
 
116
 
@conftest
117
 
def gxx_modifier_platform(conf):
118
 
        # * set configurations specific for a platform.
119
 
        # * the destination platform is detected automatically by looking at the macros the compiler predefines,
120
 
        #   and if it's not recognised, it fallbacks to sys.platform.
121
 
        dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
122
 
        gxx_modifier_func = globals().get('gxx_modifier_' + dest_os)
123
 
        if gxx_modifier_func:
124
 
                        gxx_modifier_func(conf)
125
 
 
126
 
def detect(conf):
127
 
        conf.find_gxx()
128
 
        conf.find_cpp()
129
 
        conf.find_ar()
130
 
        conf.gxx_common_flags()
131
 
        conf.gxx_modifier_platform()
132
 
        conf.cxx_load_tools()
133
 
        conf.cxx_add_flags()
134
 
        conf.link_add_flags()
135