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

« back to all changes in this revision

Viewing changes to tools/wafadmin/Tools/gcc.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-2008 (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_gcc(conf):
14
 
        cc = conf.find_program(['gcc', 'cc'], var='CC', mandatory=True)
15
 
        cc = conf.cmd_to_list(cc)
16
 
        ccroot.get_cc_version(conf, cc, gcc=True)
17
 
        conf.env.CC_NAME = 'gcc'
18
 
        conf.env.CC      = cc
19
 
 
20
 
@conftest
21
 
def gcc_common_flags(conf):
22
 
        v = conf.env
23
 
 
24
 
        # CPPFLAGS CCDEFINES _CCINCFLAGS _CCDEFFLAGS
25
 
 
26
 
        v['CCFLAGS_DEBUG'] = ['-g']
27
 
 
28
 
        v['CCFLAGS_RELEASE'] = ['-O2']
29
 
 
30
 
        v['CC_SRC_F']            = ''
31
 
        v['CC_TGT_F']            = ['-c', '-o', ''] # shell hack for -MD
32
 
        v['CPPPATH_ST']          = '-I%s' # template for adding include paths
33
 
 
34
 
        # linker
35
 
        if not v['LINK_CC']: v['LINK_CC'] = v['CC']
36
 
        v['CCLNK_SRC_F']         = ''
37
 
        v['CCLNK_TGT_F']         = ['-o', ''] # shell hack for -MD
38
 
 
39
 
        v['LIB_ST']              = '-l%s' # template for adding libs
40
 
        v['LIBPATH_ST']          = '-L%s' # template for adding libpaths
41
 
        v['STATICLIB_ST']        = '-l%s'
42
 
        v['STATICLIBPATH_ST']    = '-L%s'
43
 
        v['RPATH_ST']            = '-Wl,-rpath,%s'
44
 
        v['CCDEFINES_ST']        = '-D%s'
45
 
 
46
 
        v['SONAME_ST']           = '-Wl,-h,%s'
47
 
        v['SHLIB_MARKER']        = '-Wl,-Bdynamic'
48
 
        v['STATICLIB_MARKER']    = '-Wl,-Bstatic'
49
 
        v['FULLSTATIC_MARKER']   = '-static'
50
 
 
51
 
        # program
52
 
        v['program_PATTERN']     = '%s'
53
 
 
54
 
        # shared library
55
 
        v['shlib_CCFLAGS']       = ['-fPIC', '-DPIC'] # avoid using -DPIC, -fPIC aleady defines the __PIC__ macro
56
 
        v['shlib_LINKFLAGS']     = ['-shared']
57
 
        v['shlib_PATTERN']       = 'lib%s.so'
58
 
 
59
 
        # static lib
60
 
        v['staticlib_LINKFLAGS'] = ['-Wl,-Bstatic']
61
 
        v['staticlib_PATTERN']   = 'lib%s.a'
62
 
 
63
 
        # osx stuff
64
 
        v['LINKFLAGS_MACBUNDLE'] = ['-bundle', '-undefined', 'dynamic_lookup']
65
 
        v['CCFLAGS_MACBUNDLE']   = ['-fPIC']
66
 
        v['macbundle_PATTERN']   = '%s.bundle'
67
 
 
68
 
@conftest
69
 
def gcc_modifier_win32(conf):
70
 
        v = conf.env
71
 
        v['program_PATTERN']     = '%s.exe'
72
 
 
73
 
        v['shlib_PATTERN']       = '%s.dll'
74
 
        v['implib_PATTERN']      = 'lib%s.dll.a'
75
 
        v['IMPLIB_ST']           = '-Wl,--out-implib,%s'
76
 
 
77
 
        dest_arch = v['DEST_CPU']
78
 
        if dest_arch == 'x86':
79
 
                # On 32-bit x86, gcc emits a message telling the -fPIC option is ignored on this arch, so we remove that flag.
80
 
                v['shlib_CCFLAGS'] = ['-DPIC'] # TODO this is a wrong define, we don't use -fPIC!
81
 
 
82
 
        v.append_value('shlib_CCFLAGS', '-DDLL_EXPORT') # TODO adding nonstandard defines like this DLL_EXPORT is not a good idea
83
 
 
84
 
        # Auto-import is enabled by default even without this option,
85
 
        # but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
86
 
        # that the linker emits otherwise.
87
 
        v.append_value('LINKFLAGS', '-Wl,--enable-auto-import')
88
 
 
89
 
@conftest
90
 
def gcc_modifier_cygwin(conf):
91
 
        gcc_modifier_win32(conf)
92
 
        v = conf.env
93
 
        v['shlib_PATTERN']       = 'cyg%s.dll'
94
 
        v.append_value('shlib_LINKFLAGS', '-Wl,--enable-auto-image-base')
95
 
 
96
 
@conftest
97
 
def gcc_modifier_darwin(conf):
98
 
        v = conf.env
99
 
        v['shlib_CCFLAGS']       = ['-fPIC', '-compatibility_version', '1', '-current_version', '1']
100
 
        v['shlib_LINKFLAGS']     = ['-dynamiclib']
101
 
        v['shlib_PATTERN']       = 'lib%s.dylib'
102
 
 
103
 
        v['staticlib_LINKFLAGS'] = []
104
 
 
105
 
        v['SHLIB_MARKER']        = ''
106
 
        v['STATICLIB_MARKER']    = ''
107
 
        v['SONAME_ST']           = ''
108
 
 
109
 
@conftest
110
 
def gcc_modifier_aix(conf):
111
 
        v = conf.env
112
 
        v['program_LINKFLAGS']   = ['-Wl,-brtl']
113
 
 
114
 
        v['shlib_LINKFLAGS']     = ['-shared','-Wl,-brtl,-bexpfull']
115
 
 
116
 
        v['SHLIB_MARKER']        = ''
117
 
 
118
 
@conftest
119
 
def gcc_modifier_platform(conf):
120
 
        # * set configurations specific for a platform.
121
 
        # * the destination platform is detected automatically by looking at the macros the compiler predefines,
122
 
        #   and if it's not recognised, it fallbacks to sys.platform.
123
 
        dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
124
 
        gcc_modifier_func = globals().get('gcc_modifier_' + dest_os)
125
 
        if gcc_modifier_func:
126
 
                        gcc_modifier_func(conf)
127
 
 
128
 
def detect(conf):
129
 
        conf.find_gcc()
130
 
        conf.find_cpp()
131
 
        conf.find_ar()
132
 
        conf.gcc_common_flags()
133
 
        conf.gcc_modifier_platform()
134
 
        conf.cc_load_tools()
135
 
        conf.cc_add_flags()
136
 
        conf.link_add_flags()
137