~ubuntu-branches/ubuntu/karmic/xmms2/karmic

« back to all changes in this revision

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