| [160] | 1 | # |
|---|
| 2 | # Hydrogen build script |
|---|
| 3 | # |
|---|
| 4 | |
|---|
| 5 | # vim: set filetype=python |
|---|
| 6 | # kate: syntax python |
|---|
| 7 | |
|---|
| 8 | import urllib |
|---|
| 9 | import os |
|---|
| 10 | import subprocess |
|---|
| 11 | import sys |
|---|
| [162] | 12 | import glob |
|---|
| [160] | 13 | |
|---|
| [204] | 14 | def printStatus( value ): |
|---|
| [826] | 15 | if str(value) == "1": |
|---|
| [204] | 16 | return "enabled" |
|---|
| 17 | else: |
|---|
| 18 | return "disabled" |
|---|
| 19 | |
|---|
| [162] | 20 | def recursiveDirs(root) : |
|---|
| 21 | return filter( ( lambda a : a.rfind( ".svn") == -1 ), [ a[0] for a in os.walk( root ) ] ) |
|---|
| [160] | 22 | |
|---|
| [162] | 23 | def unique( list ) : |
|---|
| 24 | return dict.fromkeys( list ).keys() |
|---|
| 25 | |
|---|
| 26 | def scanFiles(dir, accept=[ "*.cpp" ], reject=[] ) : |
|---|
| 27 | sources = [] |
|---|
| 28 | paths = recursiveDirs( dir ) |
|---|
| 29 | for path in paths: |
|---|
| 30 | for pattern in accept: |
|---|
| 31 | sources += glob.glob( path + "/" + pattern ) |
|---|
| 32 | for pattern in reject: |
|---|
| 33 | sources = filter( ( lambda a : a.rfind( pattern ) == -1 ), sources ) |
|---|
| 34 | return unique( sources ) |
|---|
| 35 | |
|---|
| 36 | def subdirsContaining( root, patterns ): |
|---|
| 37 | dirs = unique( map( os.path.dirname, scanFiles( root, patterns ) ) ) |
|---|
| 38 | dirs.sort() |
|---|
| 39 | return dirs |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| [826] | 43 | def get_platform_flags( opts ): |
|---|
| [162] | 44 | includes = [] |
|---|
| [401] | 45 | cppflags = [] |
|---|
| 46 | ldflags = [] |
|---|
| [162] | 47 | |
|---|
| [826] | 48 | env = Environment( options = opts ) |
|---|
| 49 | |
|---|
| [162] | 50 | if sys.platform == "linux2" or sys.platform == "darwin": |
|---|
| [826] | 51 | if str(env['debug']) == "1": |
|---|
| [401] | 52 | cppflags += ['-Wall', '-g2', '-ggdb', '-O0'] |
|---|
| [162] | 53 | else: |
|---|
| [401] | 54 | cppflags += ['-O3', '-fomit-frame-pointer', '-funroll-loops'] |
|---|
| [202] | 55 | #cppflags += " %s" % get_optimized_flags( target_cpu ) |
|---|
| [162] | 56 | |
|---|
| [826] | 57 | if str(env['oss']) == "1": cppflags.append('-DOSS_SUPPORT') |
|---|
| 58 | if str(env['alsa']) == "1": cppflags.append('-DALSA_SUPPORT') |
|---|
| 59 | if str(env['jack']) == "1": cppflags.append('-DJACK_SUPPORT') |
|---|
| 60 | if str(env['lash']) == "1": cppflags.append('-DLASH_SUPPORT') |
|---|
| 61 | if str(env['lrdf']) == "1": cppflags.append('-DLRDF_SUPPORT') |
|---|
| 62 | if str(env['portaudio']) == "1": cppflags.append('-DPORTAUDIO_SUPPORT') |
|---|
| 63 | if str(env['portmidi']) == "1": cppflags.append('-DPORTMIDI_SUPPORT') |
|---|
| [204] | 64 | |
|---|
| [294] | 65 | |
|---|
| [401] | 66 | cppflags.append('-DFLAC_SUPPORT') |
|---|
| 67 | cppflags.append('-DLADSPA_SUPPORT') |
|---|
| [826] | 68 | |
|---|
| [294] | 69 | |
|---|
| [826] | 70 | if str(env['lash']) == "1": includes.append( '/usr/lib/lash-1.0' ) |
|---|
| [294] | 71 | |
|---|
| [826] | 72 | if str(env['libarchive']) == "1": cppflags.append('-DLIBARCHIVE_SUPPORT') |
|---|
| [294] | 73 | |
|---|
| [162] | 74 | includes.append( './' ) |
|---|
| [196] | 75 | includes.append( 'gui/src/' ) |
|---|
| [162] | 76 | includes.append( '3rdparty/install/include' ) |
|---|
| [294] | 77 | |
|---|
| [162] | 78 | if sys.platform == 'linux2': |
|---|
| [401] | 79 | ldflags.append('-lasound') |
|---|
| [183] | 80 | |
|---|
| [162] | 81 | elif sys.platform == 'darwin': |
|---|
| 82 | pass |
|---|
| [269] | 83 | elif sys.platform == "win32": |
|---|
| 84 | includes.append( '3rdparty\install\include' ) |
|---|
| [294] | 85 | includes.append( 'build\pthreads\include' ) |
|---|
| [269] | 86 | includes.append( '3rdparty\libarchive\include' ) |
|---|
| [294] | 87 | includes.append( 'windows\timeFix' ) |
|---|
| [162] | 88 | else: |
|---|
| 89 | raise Exception( "Platform '%s' not supported" % sys.platform ) |
|---|
| 90 | |
|---|
| 91 | return (includes, cppflags, ldflags) |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | |
|---|
| [160] | 95 | def download_3rdparty_libs(): |
|---|
| 96 | print " * Downloading required 3rdparty libraries" |
|---|
| 97 | |
|---|
| 98 | curdir = os.path.abspath( os.path.curdir ) |
|---|
| [294] | 99 | |
|---|
| [269] | 100 | if sys.platform != "win32": |
|---|
| 101 | prefix = os.path.abspath( os.path.curdir ) + "/3rdparty/install" |
|---|
| 102 | else: |
|---|
| 103 | prefix = os.path.abspath( os.path.curdir ) + "\3rdparty\install" |
|---|
| [160] | 104 | |
|---|
| [294] | 105 | |
|---|
| [160] | 106 | compile_flags = "--enable-static --disable-shared" |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | if not os.path.exists( "3rdparty" ): |
|---|
| 110 | os.mkdir( "3rdparty" ) |
|---|
| 111 | |
|---|
| 112 | if not os.path.exists( "3rdparty/install" ): |
|---|
| 113 | os.mkdir( "3rdparty/install" ) |
|---|
| [294] | 114 | |
|---|
| [269] | 115 | if not os.path.exists( "3rdparty/install/lib" ): |
|---|
| 116 | os.mkdir( "3rdparty/install/lib" ) |
|---|
| [160] | 117 | |
|---|
| 118 | |
|---|
| [294] | 119 | |
|---|
| 120 | |
|---|
| [269] | 121 | if not os.path.exists( "3rdparty/libsndfile.tar.gz" ) and not os.path.exists("3rdparty/libsndfile.zip"): |
|---|
| 122 | if sys.platform != "win32": |
|---|
| 123 | print " * Downloading libsndfile.tar.gz" |
|---|
| 124 | urllib.urlretrieve("http://www.mega-nerd.com/libsndfile/libsndfile-1.0.17.tar.gz", "3rdparty/libsndfile.tar.gz") |
|---|
| 125 | else: |
|---|
| 126 | print " * Downloading libsndfile.zip" |
|---|
| 127 | urllib.urlretrieve("http://www.mega-nerd.com/libsndfile/libsndfile-1_0_17.zip", "3rdparty/libsndfile.zip") |
|---|
| [294] | 128 | |
|---|
| 129 | |
|---|
| [269] | 130 | if sys.platform != "win32": |
|---|
| 131 | #unix commands |
|---|
| 132 | if not os.path.exists( "3rdparty/install/lib/libsndfile.a" ): |
|---|
| 133 | Execute( "cd 3rdparty; tar xzf libsndfile.tar.gz" ) |
|---|
| 134 | Execute( "cd 3rdparty/libsndfile-1.0.17; ./configure --disable-flac --prefix=%s %s" % (prefix, compile_flags) ) |
|---|
| [826] | 135 | res = Execute( "cd 3rdparty/libsndfile-1.0.17; make -j2; make install" ) |
|---|
| [269] | 136 | if res != 0: |
|---|
| 137 | raise Exception( "Error compiling 3rdparty libraries" ) |
|---|
| 138 | else: |
|---|
| 139 | #windows |
|---|
| 140 | if not os.path.exists( "3rdparty\install\lib\libsndfile-1.dll" ): |
|---|
| 141 | Execute( "unzip 3rdparty\libsndfile.zip -d 3rdparty" ) |
|---|
| 142 | Execute( "copy 3rdparty\libsndfile-1_0_17\libsndfile-1.dll 3rdparty\install\lib") |
|---|
| 143 | Execute( "copy 3rdparty\libsndfile-1_0_17\sndfile.h 3rdparty\install\lib") |
|---|
| [160] | 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| [294] | 147 | |
|---|
| [160] | 148 | def get_svn_revision(): |
|---|
| 149 | p = subprocess.Popen("svnversion -n", shell=True, stdout=subprocess.PIPE) |
|---|
| 150 | return p.stdout.read() |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | |
|---|
| [826] | 154 | def get_hydrogen_lib( opts ): |
|---|
| 155 | includes, cppflags, ldflags = get_platform_flags( opts ) |
|---|
| [162] | 156 | |
|---|
| 157 | includes.append( "libs/hydrogen/include" ) |
|---|
| [202] | 158 | includes.append( "/usr/include/lash-1.0") |
|---|
| [162] | 159 | |
|---|
| [269] | 160 | #location of qt4.py |
|---|
| 161 | qt4ToolLocation="." |
|---|
| 162 | |
|---|
| [826] | 163 | env = Environment(options = opts , tools=['default','qt4'], toolpath=[qt4ToolLocation], ENV=os.environ, CPPPATH = includes, CPPFLAGS = cppflags, CCFLAGS = "", LINKFLAGS=ldflags ) |
|---|
| [162] | 164 | env.EnableQt4Modules( ['QtCore', 'QtGui'], debug=False) |
|---|
| 165 | env.CacheDir( "scons_cache" ) |
|---|
| [536] | 166 | |
|---|
| [826] | 167 | if str(env['jack']) == "1": |
|---|
| [538] | 168 | env.ParseConfig('pkg-config --modversion jack', get_jack_api_flags) |
|---|
| [162] | 169 | |
|---|
| [536] | 170 | #env.Decider is not known in older scons version |
|---|
| 171 | try: |
|---|
| 172 | env.Decider( "MD5-timestamp" ) |
|---|
| 173 | except AttributeError: |
|---|
| 174 | env.SourceSignatures('MD5') |
|---|
| 175 | |
|---|
| 176 | |
|---|
| [826] | 177 | if str(env['jack']) == "1": |
|---|
| [403] | 178 | env.ParseConfig('pkg-config --modversion jack', get_jack_midi_api_version) |
|---|
| [162] | 179 | |
|---|
| 180 | src = scanFiles( "libs/hydrogen", ['*.cpp', '*.cc', '*.c' ], [ 'moc_'] ) |
|---|
| [534] | 181 | src.append( "version.cpp" ) |
|---|
| [162] | 182 | |
|---|
| 183 | static_lib = env.StaticLibrary(target = 'hydrogen', source = src ) |
|---|
| 184 | return static_lib |
|---|
| 185 | |
|---|
| 186 | |
|---|
| [826] | 187 | def get_hydrogen_gui( lib_hydrogen , opts ): |
|---|
| 188 | includes, cppflags, ldflags = get_platform_flags( opts ) |
|---|
| [162] | 189 | |
|---|
| 190 | includes.append( "libs/hydrogen/include" ) |
|---|
| 191 | includes.append( "gui/src/UI" ) |
|---|
| [202] | 192 | includes.append( "/usr/include/lash-1.0") |
|---|
| [162] | 193 | |
|---|
| [269] | 194 | #location of qt4.py |
|---|
| 195 | qt4ToolLocation="." |
|---|
| 196 | |
|---|
| [826] | 197 | env = Environment(options = opts , tools=['default','qt4'], toolpath=[qt4ToolLocation], ENV=os.environ, CPPPATH = includes, CPPFLAGS = cppflags, CCFLAGS = "", LINKFLAGS=ldflags ) |
|---|
| [534] | 198 | |
|---|
| [204] | 199 | env.EnableQt4Modules( ['QtCore', 'QtGui','QtNetwork','QtXml'], debug=False) |
|---|
| [534] | 200 | # |
|---|
| [162] | 201 | env.CacheDir( "scons_cache" ) |
|---|
| [536] | 202 | |
|---|
| 203 | #env.Decider is not known in older scons version |
|---|
| 204 | try: |
|---|
| 205 | env.Decider( "MD5-timestamp" ) |
|---|
| 206 | except AttributeError: |
|---|
| 207 | env.SourceSignatures('MD5') |
|---|
| [162] | 208 | |
|---|
| 209 | # rcc needs a -name flag because examples use identified resource files |
|---|
| 210 | def takebasename(file): |
|---|
| 211 | return os.path.splitext(os.path.basename(file))[0] |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | directory = "gui" |
|---|
| 215 | |
|---|
| 216 | resources = [ env.Qrc( qrc, QT4_QRCFLAGS = '-name ' + takebasename( qrc ) ) for qrc in scanFiles(directory, ['*.qrc'] ) ] |
|---|
| 217 | interfaces = [ env.Uic4( uic ) for uic in scanFiles(directory, ['*.ui'] ) ] |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | src = scanFiles( directory, ['*.cpp', '*.cc', '*.c' ], [ 'moc_'] ) |
|---|
| 221 | |
|---|
| 222 | env.Append( LIBS = lib_hydrogen ) |
|---|
| 223 | env.Append( LIBS = ["sndfile"] ) |
|---|
| [294] | 224 | |
|---|
| [826] | 225 | if str(env['lrdf']) == "1": env.Append( LIBS = ["lrdf"] ) |
|---|
| 226 | if str(env['flac']) == "1": env.Append( LIBS = ["FLAC","FLAC++"] ) |
|---|
| 227 | if str(env['lash']) == "1": env.Append( LIBS = ["lash"]) |
|---|
| 228 | if str(env['jack']) == "1": |
|---|
| [401] | 229 | env.Append( LIBS = ["jack"]) |
|---|
| 230 | env.ParseConfig('pkg-config --modversion jack', get_jack_midi_api_version) |
|---|
| [826] | 231 | if str(env['alsa']) == "1": env.Append( LIBS = ["asound"]) |
|---|
| 232 | if str(env['libarchive']) == "1": env.Append( LIBS = ["archive"]) |
|---|
| [234] | 233 | else: env.Append( LIBS = ["tar"]) |
|---|
| [826] | 234 | if str(env['portaudio']) == "1": env.Append( LIBS = [ "portaudio" ] ) |
|---|
| 235 | if str(env['portmidi']) == "1": |
|---|
| [299] | 236 | env.Append( LIBS = [ "portmidi" ] ) |
|---|
| 237 | env.Append( LIBS = [ "porttime" ] ) |
|---|
| [294] | 238 | env.Append( LIBPATH = '3rdparty\libsndfile-1_0_17' ) |
|---|
| 239 | env.Append( LIBPATH = 'build\pthreads\lib' ) |
|---|
| [204] | 240 | |
|---|
| [401] | 241 | app = env.Program(target = 'hydrogen', source = src ) |
|---|
| [162] | 242 | |
|---|
| 243 | env.Alias('programs', app) |
|---|
| 244 | env.Default('programs') |
|---|
| [294] | 245 | |
|---|
| [826] | 246 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/i18n")) |
|---|
| 247 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/img")) |
|---|
| 248 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/drumkits")) |
|---|
| 249 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/demo_songs")) |
|---|
| 250 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/hydrogen.default.conf")) |
|---|
| 251 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/emptySample.wav")) |
|---|
| 252 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/click.wav")) |
|---|
| 253 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/doc")) |
|---|
| 254 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/hydrogen/data', source="./data/DefaultSong.h2song")) |
|---|
| 255 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/bin/', source="./hydrogen")) |
|---|
| 256 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/applications', source="./hydrogen.desktop")) |
|---|
| 257 | env.Alias(target="install", source=env.Install(dir= env['DESTDIR'] + env['prefix'] + '/share/pixmaps', source="./data/img/gray/h2-icon.svg")) |
|---|
| [227] | 258 | |
|---|
| [826] | 259 | |
|---|
| [162] | 260 | return app |
|---|
| 261 | |
|---|
| [538] | 262 | def get_jack_api_flags(xenv, pkg_ver): |
|---|
| 263 | (major, minor, patch) = pkg_ver.rstrip().split('.') |
|---|
| 264 | major = int(major) |
|---|
| 265 | minor = int(minor) |
|---|
| 266 | patch = int(patch) |
|---|
| 267 | rv = "" |
|---|
| 268 | if (major == 0) and (minor < 102): |
|---|
| 269 | rv = "-DJACK_NO_BBT_OFFSET" |
|---|
| 270 | if (major == 0) and (minor == 102) and (patch < 4): |
|---|
| 271 | rv = "-DJACK_NO_BBT_OFFSET" |
|---|
| 272 | xenv.MergeFlags(rv) |
|---|
| [162] | 273 | |
|---|
| [826] | 274 | opts = Options('scache.conf') |
|---|
| [294] | 275 | |
|---|
| 276 | #platform independent settings |
|---|
| [202] | 277 | opts.Add('debug', 'Set to 1 to build with debug informations', 0) |
|---|
| [294] | 278 | opts.Add('libarchive', 'Set to 1 to enable libarchive instead of libtar', 0) |
|---|
| 279 | opts.Add('prefix','Default: /usr/local',"/usr/local") |
|---|
| [826] | 280 | opts.Add('DESTDIR','Default: none',"") |
|---|
| [269] | 281 | |
|---|
| [294] | 282 | #platform dependent settings |
|---|
| [269] | 283 | if sys.platform != "win32": |
|---|
| [826] | 284 | opts.Add('oss', 'Set to 1 to enable oss',1) |
|---|
| 285 | |
|---|
| [296] | 286 | opts.Add('portmidi', 'Set to 1 to enable portmidi',0) |
|---|
| 287 | |
|---|
| 288 | opts.Add('portaudio', 'Set to 1 to enable portaudio',0) |
|---|
| 289 | |
|---|
| [269] | 290 | opts.Add('lash', 'Set to 1 to enable lash',0) |
|---|
| [294] | 291 | |
|---|
| 292 | |
|---|
| [269] | 293 | opts.Add('alsa', 'Set to 1 to enable alsa',1) |
|---|
| [294] | 294 | |
|---|
| [269] | 295 | |
|---|
| [294] | 296 | opts.Add('jack', 'Set to 1 to enable jack',1) |
|---|
| 297 | |
|---|
| 298 | |
|---|
| [826] | 299 | opts.Add('jack_midi', 'Set to 1 to enable jack MIDI',1) |
|---|
| 300 | |
|---|
| 301 | |
|---|
| [294] | 302 | opts.Add('lrdf', 'Set to 1 to enable lrdf',1) |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | opts.Add('flac', 'Set to 1 to enable flac',1) |
|---|
| [269] | 306 | else: |
|---|
| [826] | 307 | #alsa, lash,oss and jack are not available on windows |
|---|
| [296] | 308 | opts.Add('portmidi', 'Set to 1 to enable portmidi',1) |
|---|
| 309 | |
|---|
| 310 | opts.Add('portaudio', 'Set to 1 to enable portaudio',1) |
|---|
| 311 | |
|---|
| [826] | 312 | opts.Add('oss', 'Set to 1 to enable oss',0) |
|---|
| 313 | |
|---|
| [269] | 314 | opts.Add('lash', 'Set to 1 to enable lash',0) |
|---|
| [294] | 315 | |
|---|
| [269] | 316 | opts.Add('alsa', 'Set to 1 to enable alsa',0) |
|---|
| [294] | 317 | |
|---|
| [269] | 318 | opts.Add('jack', 'Set to 1 to enable jack',0) |
|---|
| 319 | |
|---|
| [826] | 320 | opts.Add('jack_midi', 'Set to 1 to enable jack MIDI',0) |
|---|
| 321 | |
|---|
| [294] | 322 | opts.Add('lrdf', 'Set to 1 to enable lrdf',0) |
|---|
| 323 | |
|---|
| 324 | opts.Add('flac', 'Set to 1 to enable flac',0) |
|---|
| [204] | 325 | |
|---|
| [401] | 326 | # JACK MIDI version detection. |
|---|
| 327 | def get_jack_midi_api_version(xenv, pkg_ver): |
|---|
| 328 | rv = "" |
|---|
| 329 | (major, minor, patch) = pkg_ver.rstrip().split('.') |
|---|
| 330 | major = int(major) |
|---|
| 331 | minor = int(minor) |
|---|
| 332 | patch = int(patch) |
|---|
| 333 | if major != 0: |
|---|
| 334 | return rv |
|---|
| 335 | if minor < 102: |
|---|
| 336 | return rv |
|---|
| 337 | rv = "-DJACK_MIDI_SUPPORT" |
|---|
| [826] | 338 | xenv['jack_midi'] = 1 |
|---|
| [401] | 339 | if (minor == 102) and (patch <= 26): |
|---|
| 340 | rv += " -DJACK_MIDI_0_102_0" |
|---|
| 341 | elif (minor < 104): |
|---|
| 342 | rv += " -DJACK_MIDI_0_102_27" |
|---|
| 343 | elif (minor == 104) and (patch == 0): |
|---|
| 344 | rv += " -DJACK_MIDI_0_102_27" |
|---|
| 345 | elif (minor >= 105): |
|---|
| 346 | rv += " -DJACK_MIDI_0_105_0" |
|---|
| 347 | xenv.MergeFlags(rv) |
|---|
| [229] | 348 | |
|---|
| [296] | 349 | |
|---|
| [826] | 350 | #get includes ( important if you compile on non-standard envorionments) |
|---|
| [204] | 351 | |
|---|
| [826] | 352 | includes, a , b = get_platform_flags( opts ) |
|---|
| [269] | 353 | |
|---|
| 354 | env = Environment(options = opts, CPPPATH = includes) |
|---|
| 355 | |
|---|
| [826] | 356 | |
|---|
| [202] | 357 | Help(opts.GenerateHelpText(env)) |
|---|
| [160] | 358 | |
|---|
| 359 | |
|---|
| [269] | 360 | platform = sys.platform |
|---|
| [202] | 361 | |
|---|
| [269] | 362 | #just download 3rd party libs if we're *not* running linux. |
|---|
| 363 | #We trust in our package managment system! |
|---|
| 364 | if platform == "darwin" or platform == "win32": |
|---|
| 365 | download_3rdparty_libs() |
|---|
| [202] | 366 | |
|---|
| [269] | 367 | |
|---|
| 368 | |
|---|
| [204] | 369 | #Check if all required libraries are installed |
|---|
| 370 | conf = Configure(env) |
|---|
| 371 | if not conf.CheckCHeader('sndfile.h'): |
|---|
| 372 | print 'libsndfile must be installed!' |
|---|
| 373 | Exit(1) |
|---|
| [202] | 374 | |
|---|
| [204] | 375 | |
|---|
| 376 | |
|---|
| 377 | # it seems that conf.CheckCHeader dislikes like the "++" in filenames |
|---|
| 378 | #if not conf.CheckCHeader('FLAC++/all.h'): |
|---|
| 379 | # print 'FLAC++ must be installed!' |
|---|
| 380 | # Exit(1) |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | # these libraries are optional (can be enabled/disabled, see 'scons -h') |
|---|
| 384 | |
|---|
| [826] | 385 | if str(env['portaudio']) == "1" and not conf.CheckCHeader('portaudio.h'): |
|---|
| [538] | 386 | print "portaudio must be installed!" |
|---|
| 387 | Exit(1) |
|---|
| 388 | |
|---|
| [826] | 389 | if str(env['portmidi']) == "1" and not conf.CheckCHeader('portmidi.h'): |
|---|
| [538] | 390 | print "portmidi must be installed!" |
|---|
| 391 | Exit(1) |
|---|
| 392 | |
|---|
| 393 | |
|---|
| [204] | 394 | #alsa: (default: enabled) |
|---|
| [826] | 395 | if str(env['alsa']) == "1" and not conf.CheckCHeader('alsa/asoundlib.h'): |
|---|
| [204] | 396 | print 'alsa must be installed!' |
|---|
| 397 | Exit(1) |
|---|
| 398 | |
|---|
| 399 | #jack: (default: enabled) |
|---|
| [826] | 400 | if str(env['jack']) == "1" and not conf.CheckCHeader('jack/jack.h'): |
|---|
| [204] | 401 | print 'jack must be installed!' |
|---|
| 402 | Exit(1) |
|---|
| 403 | |
|---|
| [401] | 404 | #jack_midi: (default: enabled if jack is) |
|---|
| [826] | 405 | if str(env['jack']) == "1" and conf.CheckCHeader('jack/midiport.h'): |
|---|
| 406 | env['jack_midi'] = 1 |
|---|
| 407 | if str(env['jack_midi']) == "1" and not conf.CheckCHeader('jack/midiport.h'): |
|---|
| 408 | print 'Your version of JACK does not have MIDI support.' |
|---|
| 409 | Exit(1) |
|---|
| [401] | 410 | |
|---|
| [204] | 411 | #lash: (default: disabled) |
|---|
| [826] | 412 | if str(env['lash']) == "1" and not os.path.isdir("/usr/include/lash-1.0"): |
|---|
| [204] | 413 | print 'liblash must be installed!' |
|---|
| 414 | Exit(1) |
|---|
| 415 | |
|---|
| [234] | 416 | #libarchive: (default: disabled) |
|---|
| [826] | 417 | if str(env['libarchive']) == "1" and not conf.CheckCHeader("archive.h"): |
|---|
| [234] | 418 | print 'libarchive must be installed!' |
|---|
| 419 | Exit(1) |
|---|
| 420 | #libtar: needed if not libarchive |
|---|
| [826] | 421 | elif not str(env['libarchive']) == "1" and not conf.CheckCHeader("zlib.h"): |
|---|
| [234] | 422 | print 'zlib devel package must be installed!' |
|---|
| 423 | Exit(1) |
|---|
| [826] | 424 | elif not str(env['libarchive']) == "1" and not conf.CheckCHeader("libtar.h"): |
|---|
| [234] | 425 | print 'libtar must be installed!' |
|---|
| 426 | Exit(1) |
|---|
| [204] | 427 | |
|---|
| [294] | 428 | #lrdf: categorizing of ladspa effects |
|---|
| [826] | 429 | if str(env['lrdf']) == "1" and not conf.CheckCHeader('lrdf.h'): |
|---|
| [294] | 430 | print 'lrdf must be installed!' |
|---|
| 431 | Exit(1) |
|---|
| [204] | 432 | |
|---|
| [294] | 433 | #flac: support for flac samples |
|---|
| [826] | 434 | if str(env['flac']) == "1" and not conf.CheckCHeader('FLAC/all.h'): |
|---|
| [294] | 435 | print 'FLAC must be installed!' |
|---|
| 436 | Exit(1) |
|---|
| [204] | 437 | |
|---|
| 438 | |
|---|
| [160] | 439 | print "" |
|---|
| 440 | print "=================================================================" |
|---|
| 441 | print " Hydrogen build script" |
|---|
| 442 | print "" |
|---|
| 443 | print " Revision: %s" % get_svn_revision() |
|---|
| [204] | 444 | print " Platform: %s" % platform |
|---|
| [202] | 445 | |
|---|
| [826] | 446 | if str(env['debug']) == "1" : |
|---|
| [160] | 447 | print " Debug build" |
|---|
| 448 | else: |
|---|
| 449 | print " Release build" |
|---|
| [202] | 450 | |
|---|
| [826] | 451 | print " Prefix: " + env['prefix'] |
|---|
| 452 | print " Destdir: " + env['DESTDIR'] |
|---|
| [160] | 453 | print "=================================================================" |
|---|
| [204] | 454 | print "Feature Overview:\n" |
|---|
| [202] | 455 | |
|---|
| [826] | 456 | print " lash: " + printStatus( env["lash"] ) |
|---|
| 457 | print " oss: " + printStatus( env["oss"] ) |
|---|
| 458 | print " alsa: " + printStatus( env["alsa"] ) |
|---|
| 459 | print " jack: " + printStatus( env["jack"] ) |
|---|
| 460 | print " jack_midi: " + printStatus( env["jack_midi"] ) |
|---|
| 461 | print "libarchive: " + printStatus( env["libarchive"] ) + (' (using libtar instead)', '')[env['libarchive']] |
|---|
| 462 | print " portaudio: " + printStatus( env["portaudio"] ) |
|---|
| 463 | print " portmidi: " + printStatus( env["portmidi"] ) |
|---|
| [202] | 464 | |
|---|
| 465 | print "\n=================================================================" |
|---|
| [160] | 466 | print "" |
|---|
| 467 | |
|---|
| [164] | 468 | # write the config.h file |
|---|
| 469 | conf = open("config.h", "w") |
|---|
| 470 | |
|---|
| 471 | conf.write( "#ifndef HYD_CONFIG_H\n" ) |
|---|
| 472 | conf.write( "#define HYD_CONFIG_H\n" ) |
|---|
| 473 | conf.write( "#include <string>\n" ) |
|---|
| [202] | 474 | |
|---|
| [238] | 475 | |
|---|
| [826] | 476 | if str(env['debug']) == "1": conf.write( "#define CONFIG_DEBUG\n" ) |
|---|
| 477 | if str(env['lash']) == "1": conf.write( "#define LASH\n" ) |
|---|
| [202] | 478 | |
|---|
| [164] | 479 | conf.write( "#ifndef QT_BEGIN_NAMESPACE\n" ) |
|---|
| 480 | conf.write( "# define QT_BEGIN_NAMESPACE\n" ) |
|---|
| 481 | conf.write( "#endif\n" ) |
|---|
| 482 | conf.write( "#ifndef QT_END_NAMESPACE\n" ) |
|---|
| 483 | conf.write( "# define QT_END_NAMESPACE\n" ) |
|---|
| 484 | conf.write( "#endif\n" ) |
|---|
| 485 | |
|---|
| [826] | 486 | conf.write( "#define CONFIG_PREFIX \"%s\"\n" % env['prefix'] ) |
|---|
| 487 | conf.write( "#define DATA_PATH \"%s/share/hydrogen/data\"\n" % env['prefix'] ) |
|---|
| [164] | 488 | |
|---|
| 489 | conf.write( "#endif\n" ) |
|---|
| 490 | |
|---|
| 491 | conf.close() |
|---|
| 492 | |
|---|
| [534] | 493 | version = open("version.cpp", "w") |
|---|
| 494 | version.write( "// autogenerated by Sconstruct script\n" ) |
|---|
| 495 | version.write( '#include "version.h"\n' ) |
|---|
| [402] | 496 | version.write( '#include "config.h"\n' ) |
|---|
| [534] | 497 | version.write( "static const std::string extra_version = \"svn%s\";\n" % get_svn_revision() ) |
|---|
| 498 | version.write( "static const std::string VERSION = \"0.9.4-\" + extra_version;\n" ) |
|---|
| 499 | version.write( "std::string get_version() { return VERSION; }\n" ) |
|---|
| [238] | 500 | version.close() |
|---|
| [160] | 501 | |
|---|
| [826] | 502 | libhyd = get_hydrogen_lib( opts ) |
|---|
| 503 | app = get_hydrogen_gui( libhyd , opts ) |
|---|
| 504 | |
|---|
| 505 | opts.Save("scache.conf",env) |
|---|