~ubuntu-branches/ubuntu/wily/xmms2/wily

« back to all changes in this revision

Viewing changes to wafadmin/Tools/suncc.py

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2008-05-29 10:14:25 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080529101425-ycw1nbd980uhvzfp
Tags: 0.4DrKosmos-4ubuntu1
* Merge from debian unstable (LP: #178477), remaining changes:
  - debian/control: Update Maintainer field
  - debian/control: add lpia to xmms2-plugin-alsa supported architectures
* This version reads AAC files (LP: #156359)

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
 
 
6
import os, sys, pproc, Object
 
7
import optparse
 
8
import Utils, Action, Params, checks, Configure
 
9
 
 
10
def setup(env):
 
11
        pass
 
12
 
 
13
def detect(conf):
 
14
        cc = None
 
15
        if conf.env['CC']:
 
16
                cc = conf.env['CC']
 
17
        elif 'CC' in os.environ:
 
18
                cc = os.environ['CC']
 
19
        if not cc: cc = conf.find_program('cc', var='CC')
 
20
        if not cc:
 
21
                return 0;
 
22
        #TODO: Has anyone a better ida to check if this is a sun cc?
 
23
        ret = os.popen("%s -flags" %cc).close()
 
24
        if ret:
 
25
                conf.check_message('suncc', '', not ret)
 
26
                return 0 #at least gcc exit with error
 
27
        conf.check_tool('checks')
 
28
 
 
29
        # load the cc builders
 
30
        conf.check_tool('cc')
 
31
 
 
32
        # sun cc requires ar for static libs
 
33
        if not conf.check_tool('ar'):
 
34
                Utils.error('suncc needs ar - not found')
 
35
                return 0
 
36
 
 
37
        v = conf.env
 
38
 
 
39
        cpp = cc
 
40
 
 
41
        v['CC']  = cc
 
42
        v['CPP'] = cpp
 
43
 
 
44
        v['CPPFLAGS']             = []
 
45
        v['CCDEFINES']            = []
 
46
        v['_CCINCFLAGS']          = []
 
47
        v['_CCDEFFLAGS']          = []
 
48
 
 
49
        v['CC_SRC_F']             = ''
 
50
        v['CC_TGT_F']             = '-c -o '
 
51
        v['CPPPATH_ST']           = '-I%s' # template for adding include paths
 
52
 
 
53
        # linker
 
54
        v['LINK_CC']              = v['CC']
 
55
        v['LIB']                  = []
 
56
 
 
57
        v['CCLNK_SRC_F']          = ''
 
58
        v['CCLNK_TGT_F']          = '-o '
 
59
 
 
60
        v['LIB_ST']               = '-l%s' # template for adding libs
 
61
        v['LIBPATH_ST']           = '-L%s' # template for adding libpaths
 
62
        v['STATICLIB_ST']         = '-l%s'
 
63
        v['STATICLIBPATH_ST']     = '-L%s'
 
64
        v['_LIBDIRFLAGS']         = ''
 
65
        v['_LIBFLAGS']            = ''
 
66
        v['CCDEFINES_ST']         = '-D%s'
 
67
 
 
68
        # linker debug levels
 
69
        v['LINKFLAGS']            = []
 
70
        v['LINKFLAGS_OPTIMIZED']  = ['-s']
 
71
        v['LINKFLAGS_RELEASE']    = ['-s']
 
72
        v['LINKFLAGS_DEBUG']      = ['-g']
 
73
        v['LINKFLAGS_ULTRADEBUG'] = ['-g3']
 
74
 
 
75
        v['SHLIB_MARKER']        = '-Bdynamic'
 
76
        v['STATICLIB_MARKER']    = '-Bstatic'
 
77
 
 
78
        # shared library
 
79
        v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
 
80
        v['shlib_LINKFLAGS']     = ['-G']
 
81
        v['shlib_obj_ext']       = ['.o']
 
82
        v['shlib_PREFIX']        = 'lib'
 
83
        v['shlib_SUFFIX']        = '.so'
 
84
 
 
85
        # plugins. We handle them exactly as shlibs
 
86
        # everywhere except on osx, where we do bundles
 
87
        v['plugin_CCFLAGS']      = v['shlib_CCFLAGS']
 
88
        v['plugin_LINKFLAGS']    = v['shlib_LINKFLAGS']
 
89
        v['plugin_obj_ext']      = v['shlib_obj_ext']
 
90
        v['plugin_PREFIX']       = v['shlib_PREFIX']
 
91
        v['plugin_SUFFIX']       = v['shlib_SUFFIX']
 
92
 
 
93
        # static lib
 
94
        v['staticlib_LINKFLAGS'] = ['-Bstatic']
 
95
        v['staticlib_obj_ext']   = ['.o']
 
96
        v['staticlib_PREFIX']    = 'lib'
 
97
        v['staticlib_SUFFIX']    = '.a'
 
98
 
 
99
        # program
 
100
        v['program_obj_ext']     = ['.o']
 
101
        v['program_SUFFIX']      = ''
 
102
 
 
103
        #test if the compiler could build a prog
 
104
        test = Configure.check_data()
 
105
        test.code = 'int main() {return 0;}\n'
 
106
        test.env = v
 
107
        test.execute = 1
 
108
        test.force_compiler="cc"
 
109
        ret = conf.run_check(test, "program")
 
110
        conf.check_message('compiler could create', 'programs', not (ret is False))
 
111
        if not ret:
 
112
                return 0
 
113
        ret = 0
 
114
        #test if the compiler could build a shlib
 
115
        lib_obj = Configure.check_data()
 
116
        lib_obj.code = "int k = 3;\n"
 
117
        lib_obj.env = v
 
118
        lib_obj.build_type = "shlib"
 
119
        lib_obj.force_compiler="cc"
 
120
        ret = conf.run_check(lib_obj)
 
121
        conf.check_message('compiler could create', 'shared libs', not (ret is False))
 
122
        if not ret:
 
123
                return 0
 
124
        ret = 0
 
125
        #test if the compiler could build a staiclib
 
126
        lib_obj = Configure.check_data()
 
127
        lib_obj.code = "int k = 3;\n"
 
128
        lib_obj.env = v
 
129
        lib_obj.build_type = "staticlib"
 
130
        lib_obj.force_compiler="cc"
 
131
        ret = conf.run_check(lib_obj)
 
132
        conf.check_message('compiler could create', 'static libs', not (ret is False))
 
133
        if not ret:
 
134
                return 0
 
135
 
 
136
        # compiler debug levels
 
137
        v['CCFLAGS'] = ['-O']
 
138
        if conf.check_flags('-O2'):
 
139
                v['CCFLAGS_OPTIMIZED'] = ['-O2']
 
140
                v['CCFLAGS_RELEASE'] = ['-O2']
 
141
        if conf.check_flags('-g -DDEBUG'):
 
142
                v['CCFLAGS_DEBUG'] = ['-g', '-DDEBUG']
 
143
        if conf.check_flags('-g3 -O0 -DDEBUG'):
 
144
                v['CCFLAGS_ULTRADEBUG'] = ['-g3', '-O0', '-DDEBUG']
 
145
 
 
146
        # see the option below
 
147
        try:
 
148
                v['CCFLAGS'] = v['CCFLAGS_'+Params.g_options.debug_level.upper()]
 
149
        except AttributeError:
 
150
                pass
 
151
 
 
152
        ron = os.environ
 
153
        def addflags(orig, dest=None):
 
154
                if not dest: dest=orig
 
155
                try: conf.env[dest] = ron[orig]
 
156
                except KeyError: pass
 
157
        addflags('CCFLAGS', 'CFLAGS')
 
158
        addflags('CPPFLAGS')
 
159
        addflags('LINKFLAGS')
 
160
 
 
161
        if not v['DESTDIR']: v['DESTDIR']=''
 
162
 
 
163
        v['program_INST_VAR'] = 'PREFIX'
 
164
        v['program_INST_DIR'] = 'bin'
 
165
        v['shlib_INST_VAR'] = 'PREFIX'
 
166
        v['shlib_INST_DIR'] = 'lib'
 
167
        v['staticlib_INST_VAR'] = 'PREFIX'
 
168
        v['staticlib_INST_DIR'] = 'lib'
 
169
 
 
170
        return 1
 
171
 
 
172
def set_options(opt):
 
173
        try:
 
174
                opt.add_option('-d', '--debug-level',
 
175
                action = 'store',
 
176
                default = '',
 
177
                help = 'Specify the debug level, does nothing if CFLAGS is set in the environment. [Allowed Values: ultradebug, debug, release, optimized]',
 
178
                dest = 'debug_level')
 
179
        except optparse.OptionConflictError:
 
180
                # the g++ tool might have added that option already
 
181
                pass
 
182