fix compilation of libcanvas so that when built as a shared lib (the default), -DLIBC...
[ardour.git] / libs / canvas / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import Options
4 from waflib import TaskGen
5 import os
6
7 # Version of this package (even if built as a child)
8 MAJOR = '0'
9 MINOR = '0'
10 MICRO = '0'
11 CANVAS_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
12
13 # Library version (UNIX style major, minor, micro)
14 # major increment <=> incompatible changes
15 # minor increment <=> compatible changes (additions)
16 # micro increment <=> no interface changes
17 CANVAS_LIB_VERSION = '0.0.0'
18
19 # Variables for 'waf dist'
20 APPNAME = 'canvas'
21 VERSION = CANVAS_VERSION
22 I18N_PACKAGE = 'libcanvas'
23
24 # Mandatory variables
25 top = '.'
26 out = 'build'
27
28 path_prefix = 'libs/canvas/'
29
30 canvas_sources = [
31         'arc.cc',
32         'arrow.cc',
33         'canvas.cc',
34         'circle.cc',
35         'curve.cc',
36         'debug.cc',
37         'drag_handle.cc',
38         'item.cc',
39         'fill.cc',
40         'flag.cc',
41         'group.cc',
42         'image.cc',
43         'line.cc',
44         'line_set.cc',
45         'lookup_table.cc',
46         'outline.cc',
47         'pixbuf.cc',
48         'poly_item.cc',
49         'poly_line.cc',
50         'polygon.cc',
51         'rectangle.cc',
52         'root_group.cc',
53         'stateful_image.cc',
54         'text.cc',
55         'types.cc',
56         'utils.cc',
57         'wave_view.cc'
58 ]
59
60 def options(opt):
61     autowaf.set_options(opt)
62
63 def configure(conf):
64     conf.load ('compiler_cxx')
65     autowaf.configure(conf)
66     autowaf.build_version_files(path_prefix+'canvas/version.h', path_prefix+'version.cc',
67                                 'libcanvas', conf.env['MAJOR'], conf.env['MINOR'], 0,
68                                 'LIBCANVAS_API', 'canvas/visibility.h')
69     autowaf.check_pkg(conf, 'cairomm-1.0', uselib_store='CAIROMM', atleast_version='1.8.4')
70
71 def build(bld):
72     # Library
73     if bld.is_defined ('INTERNAL_SHARED_LIBS'):
74         obj = bld.shlib(features = 'cxx cxxshlib', source=canvas_sources)
75         obj.defines      = [ 'LIBCANVAS_DLL_EXPORTS=1' ]
76     else:
77         obj = bld.stlib(features = 'cxx cxxstlib', source=canvas_sources)
78         obj.cxxflags     = [ '-fPIC' ]
79         obj.cflags       = [ '-fPIC' ]
80
81     obj.export_includes = ['.']
82     obj.includes     = ['.']
83     obj.uselib       = 'SIGCPP CAIROMM GTKMM BOOST'
84     obj.use          = [ 'libpbd', 'libevoral', 'libardour', 'libgtkmm2ext' ]
85     obj.name         = 'libcanvas'
86     obj.target       = 'canvas'
87     obj.vnum         = CANVAS_LIB_VERSION
88     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
89     obj.defines      += [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
90     
91     if bld.env['BUILD_TESTS'] and bld.env['HAVE_CPPUNIT']:
92
93             manual_tests              = '''
94                         test/hello_world.cc
95                         test/gtk_many.cc
96                         test/gtk_scene.cc
97                         test/gtk_movement.cc
98                         test/gtk_viewport.cc
99                         test/gtk_drag.cc
100                 '''.split()
101
102             for t in manual_tests:
103                     target = t[:-3]
104                     name = t[t.find('/')+1:-3]
105                     manual_testobj = bld.new_task_gen('cxx', 'program')
106                     manual_testobj.source = t
107                     manual_testobj.includes = obj.includes + ['test', '../pbd']
108                     manual_testobj.uselib       = 'CPPUNIT SIGCPP CAIROMM GTKMM'
109                     manual_testobj.uselib_local = 'libcanvas libevoral libardour libgtkmm2ext'
110                     manual_testobj.name         = 'libcanvas-manual-test-%s' % name
111                     manual_testobj.target       = target
112                     manual_testobj.install_path = ''
113                     
114                     unit_testobj              = bld.new_task_gen('cxx', 'program')
115                     unit_testobj.source       = '''
116                         test/group.cc
117                         test/arrow.cc
118                         test/optimizing_lookup_table.cc
119                         test/polygon.cc
120                         test/types.cc
121                         test/render.cc
122                         test/xml.cc
123                         test/wave_view.cc
124                         test/item.cc
125                         test/testrunner.cpp
126                 '''.split()
127
128                     unit_testobj.includes     = obj.includes + ['test', '../pbd']
129                     unit_testobj.uselib       = 'CPPUNIT SIGCPP CAIROMM GTKMM'
130                     unit_testobj.uselib_local = 'libcanvas libevoral libardour libgtkmm2ext'
131                     unit_testobj.name         = 'libcanvas-unit-tests'
132                     unit_testobj.target       = 'run-tests'
133                     unit_testobj.install_path = ''
134                     unit_testobj.cxxflags     = ['-DPACKAGE="libcanvastest"']
135                     unit_testobj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
136                     unit_testobj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
137                     unit_testobj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
138                     
139             benchmarks = '''
140                         benchmark/items_at_point.cc
141                         benchmark/render_parts.cc
142                         benchmark/render_from_log.cc
143                         benchmark/render_whole.cc
144                 '''.split()
145
146             for t in benchmarks:
147                     target = t[:-3]
148                     name = t[t.find('/')+1:-3]
149                     manual_testobj = bld.new_task_gen('cxx', 'program')
150                     manual_testobj.source = [ t, 'benchmark/benchmark.cc' ]
151                     manual_testobj.includes = obj.includes + ['test', '../pbd']
152                     manual_testobj.uselib       = 'CPPUNIT SIGCPP CAIROMM GTKMM'
153                     manual_testobj.uselib_local = 'libcanvas libevoral libardour libgtkmm2ext'
154                     manual_testobj.name         = 'libcanvas-benchmark-%s' % name
155                     manual_testobj.target       = target
156                     manual_testobj.install_path = ''
157
158 def shutdown():
159     autowaf.shutdown()
160