Attempt to strip stupid FLAC include.
[ardour.git] / wscript
1 #!/usr/bin/env python
2 import autowaf
3 import Options
4 import os
5 import commands
6
7 # Variables for 'waf dist'
8 VERSION = '3.0pre0'
9 APPNAME = 'ardour'
10
11 # Mandatory variables
12 srcdir = '.'
13 blddir = 'build'
14
15 children = [
16         'libs/pbd',
17         'libs/midi++2',
18         'libs/evoral',
19         'libs/vamp-sdk',
20         'libs/vamp-plugins',
21         'libs/taglib',
22         'libs/rubberband',
23         'libs/surfaces',
24         'libs/ardour',
25         'libs/gtkmm2ext',
26         'gtk2_ardour'
27 ]
28
29
30 # Version stuff
31
32 def fetch_svn_revision (path):
33         cmd = "LANG= svn info " + path + " | awk '/^Revision:/ { print $2}'"
34         return commands.getoutput(cmd)
35
36 def fetch_git_revision (path):
37         cmd = "LANG= git log --abbrev HEAD^..HEAD " + path
38         output = commands.getoutput(cmd).splitlines()
39         rev = output[0].replace ("commit", "git")[0:10]
40         for line in output:
41                 try:
42                         if "git-svn-id" in line:
43                                 line = line.split('@')[1].split(' ')
44                                 rev = line[0]
45                 except:
46                         pass
47         return rev
48
49 def create_stored_revision():
50         rev = ""
51         if os.path.exists('.svn'):
52                 rev = fetch_svn_revision('.');
53         elif os.path.exists('.git'):
54                 rev = fetch_git_revision('.');
55         elif os.path.exists('libs/ardour/svn_revision.cc'):
56                 print "Using packaged svn revision"
57                 return
58         else:
59                 print "Missing libs/ardour/svn_revision.cc.  Blame the packager."
60                 sys.exit(-1)
61
62         try:
63                 text =  '#include <ardour/svn_revision.h>\n'
64                 text += 'namespace ARDOUR { extern const char* svn_revision = \"' + rev + '\"; }\n'
65                 print 'Writing svn revision info to libs/ardour/svn_revision.cc'
66                 o = file('libs/ardour/svn_revision.cc', 'w')
67                 o.write(text)
68                 o.close()
69         except IOError:
70                 print 'Could not open libs/ardour/svn_revision.cc for writing\n'
71                 sys.exit(-1)
72
73
74 # Waf stages
75
76 def set_options(opt):
77         autowaf.set_options(opt)
78         opt.add_option('--arch', type='string', dest='arch',
79                         help='Architecture-specific compiler flags')
80         opt.add_option('--aubio', action='store_true', default=True, dest='aubio',
81                         help="Use Paul Brossier's aubio library for feature detection (if available)")
82         opt.add_option('--audiounits', action='store_true', default=False, dest='audiounits',
83                         help='Compile with Apple\'s AudioUnit library. (experimental)')
84         opt.add_option('--coreaudio', action='store_true', default=False, dest='coreaudio',
85                         help='Compile with Apple\'s CoreAudio library')
86         opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
87                         help='Build runtime checked assembler code')
88         opt.add_option('--freedesktop', action='store_true', default=False, dest='freedesktop',
89                         help='Install MIME type, icons and .desktop file as per freedesktop.org standards')
90         opt.add_option('--freesound', action='store_true', default=False, dest='freesound',
91                         help='Include Freesound database lookup')
92         opt.add_option('--gtkosx', action='store_true', default=False, dest='gtkosx',
93                         help='Compile for use with GTK-OSX, not GTK-X11')
94         opt.add_option('--lv2', action='store_true', default=False, dest='lv2',
95                         help='Compile with support for LV2 (if slv2 is available)')
96         opt.add_option('--nls', action='store_true', default=True, dest='nls',
97                         help='Set to turn on i18n support')
98         opt.add_option('--surfaces', action='store_true', default=True, dest='surfaces',
99                         help='Build support for control surfaces')
100         opt.add_option('--syslibs', action='store_true', default=True, dest='syslibs',
101                         help='Use existing system versions of various libraries instead of internal ones')
102         opt.add_option('--tranzport', action='store_true', default=True, dest='tranzport',
103                         help='Compile with support for Frontier Designs (if libusb is available)')
104         opt.add_option('--universal', action='store_true', default=False, dest='universal',
105                         help='Compile as universal binary.  Requires that external libraries are universal.')
106         opt.add_option('--versioned', action='store_true', default=False, dest='versioned',
107                         help='Add revision information to executable name inside the build directory')
108         opt.add_option('--vst', action='store_true', default=False, dest='vst',
109                         help='Compile with support for VST')
110         opt.add_option('--wiimote', action='store_true', default=False, dest='wiimote',
111                         help='Build the wiimote control surface')
112         opt.add_option('--windows-key', type='string', dest='windows_key',
113                         help='Set X Modifier (Mod1,Mod2,Mod3,Mod4,Mod5) for "Windows" key [Default: Mod4]')
114         for i in children:
115                 opt.sub_options(i)
116         
117 def sub_config_and_use(conf, name, has_objects = True):
118         conf.sub_config(name)
119         autowaf.set_local_lib(conf, name, has_objects)
120
121 def configure(conf):
122         create_stored_revision()
123         autowaf.set_recursive()
124         autowaf.configure(conf)
125         autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2')
126         autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.14.0')
127         for i in children:
128                 sub_config_and_use(conf, i)
129         
130         print conf.env['CCFLAGS']
131         print conf.env['CXXFLAGS']
132
133         # Fix utterly braindead FLAC include path
134         for prefix in [ '/usr/include', '/usr/local/include' ]:
135                 for flags in [ conf.env['CCFLAGS'], conf.env['CXXFLAGS'] ]:
136                         for i in flags:
137                                 if i == '-I' + prefix + '/FLAC':
138                                         print '*** STRIPPED IDIOTIC FLAC INCLUDE PATH'
139                                         flags.remove(i)
140
141         print conf.env['CCFLAGS']
142         print conf.env['CXXFLAGS']
143
144         autowaf.print_summary(conf)
145         opts = Options.options
146         autowaf.display_header('Ardour Configuration')
147         autowaf.display_msg(conf, 'Architecture flags', opts.arch)
148         autowaf.display_msg(conf, 'Aubio', bool(conf.env['HAVE_AUBIO']))
149         autowaf.display_msg(conf, 'AudioUnits', opts.audiounits)
150         autowaf.display_msg(conf, 'CoreAudio', opts.coreaudio)
151         autowaf.display_msg(conf, 'FPU Optimization', opts.fpu_optimization)
152         autowaf.display_msg(conf, 'Freedesktop Files', opts.freedesktop)
153         autowaf.display_msg(conf, 'Freesound', opts.freesound)
154         autowaf.display_msg(conf, 'GtkOSX', opts.gtkosx)
155         autowaf.display_msg(conf, 'LV2 Support', bool(conf.env['HAVE_SLV2']))
156         autowaf.display_msg(conf, 'Translation', opts.nls)
157         autowaf.display_msg(conf, 'Surfaces', opts.surfaces)
158         autowaf.display_msg(conf, 'System Libraries', opts.syslibs)
159         autowaf.display_msg(conf, 'Tranzport', opts.tranzport)
160         autowaf.display_msg(conf, 'Universal Binary', opts.universal)
161         autowaf.display_msg(conf, 'Versioned Binary', opts.versioned)
162         autowaf.display_msg(conf, 'VST Support', opts.vst)
163         autowaf.display_msg(conf, 'Wiimote Support', opts.wiimote)
164         autowaf.display_msg(conf, 'Windows Key', opts.windows_key)
165
166 def build(bld):
167         autowaf.set_recursive()
168         for i in children:
169                 bld.add_subdirs(i)
170
171 def shutdown():
172         autowaf.shutdown()
173