make zoom focus selector a little narrower
[ardour.git] / SConstruct
index 6f4f1bdde14ecdc9e884f34929b63d4ccd33ea68..46cbfc74857736735da102979537538ad601c771 100644 (file)
@@ -16,7 +16,7 @@ import SCons.Node.FS
 SConsignFile()
 EnsureSConsVersion(0, 96)
 
-version = '2.0beta7.1'
+version = '2.0beta9'
 
 subst_dict = { }
 
@@ -42,7 +42,8 @@ opts.AddOptions(
     BoolOption('SURFACES', 'Build support for control surfaces', 0),
     BoolOption('SYSLIBS', 'USE AT YOUR OWN RISK: CANCELS ALL SUPPORT FROM ARDOUR AUTHORS: Use existing system versions of various libraries instead of internal ones', 0),
     BoolOption('VERSIONED', 'Add revision information to ardour/gtk executable name inside the build directory', 0),
-    BoolOption('VST', 'Compile with support for VST', 0)
+    BoolOption('VST', 'Compile with support for VST', 0),
+    BoolOption('TRANZPORT', 'Compile with support for Frontier Designs (if libusb is available)', 0)
 )
 
 #----------------------------------------------------------------------
@@ -231,6 +232,33 @@ def i18n (buildenv, sources, installenv):
         moname = domain + '.mo'
         installenv.Alias('install', installenv.InstallAs (os.path.join (modir, moname), lang + '.mo'))
 
+
+def fetch_svn_revision (path):
+    cmd = "svn info "
+    cmd += path
+    cmd += " | awk '/^Revision:/ { print $2}'"
+    return commands.getoutput (cmd)
+
+def create_stored_revision (target = None, source = None, env = None):
+    if os.path.exists('.svn'):    
+        rev = fetch_svn_revision ('.');
+        try:
+            text  = "#ifndef __ardour_svn_revision_h__\n"
+            text += "#define __ardour_svn_revision_h__\n"
+            text += "static const char* ardour_svn_revision = \"" + rev + "\";\n";
+            text += "#endif\n"
+            print '============> writing svn revision info to svn_revision.h\n'
+            o = file ('svn_revision.h', 'w')
+            o.write (text)
+            o.close ()
+        except IOError:
+            print "Could not open svn_revision.h for writing\n"
+            sys.exit (-1)
+    else:
+        print "You cannot use \"scons revision\" on without using a checked out"
+        print "copy of the Ardour source code repository"
+        sys.exit (-1)
+
 #
 # A generic builder for version.cc files
 #
@@ -239,14 +267,8 @@ def i18n (buildenv, sources, installenv):
 #
 
 def version_builder (target, source, env):
-    cmd = "svn info "
-    cmd += source[0].get_path()
-    cmd += " | awk '/^Revision:/ { print $2}'"
-    
-    rev = commands.getoutput (cmd)
-        
-    text  = "const char* " + env['DOMAIN'] + "_revision = \"" + rev + "\";\n"
-    text += "int " + env['DOMAIN'] + "_major_version = " + str (env['MAJOR']) + ";\n"
+
+    text  = "int " + env['DOMAIN'] + "_major_version = " + str (env['MAJOR']) + ";\n"
     text += "int " + env['DOMAIN'] + "_minor_version = " + str (env['MINOR']) + ";\n"
     text += "int " + env['DOMAIN'] + "_micro_version = " + str (env['MICRO']) + ";\n"
     
@@ -269,7 +291,7 @@ def version_builder (target, source, env):
     try:
         o = file (target[1].get_path(), 'w')
         o.write (text)
-        o.close ();
+        o.close ()
     except IOError:
         print "Could not open", target[1].get_path(), " for writing\n"
         sys.exit (-1)
@@ -357,7 +379,7 @@ env.Append (BUILDERS = {'Tarball' : tarball_bld})
 #
 
 if env['VST']:
-    sys.stdout.write ("Are you building Ardour for personal use (rather than distributiont to others)? [no]: ")
+    sys.stdout.write ("Are you building Ardour for personal use (rather than distribution to others)? [no]: ")
     answer = sys.stdin.readline ()
     answer = answer.rstrip().strip()
     if answer != "yes" and answer != "y":
@@ -367,6 +389,57 @@ if env['VST']:
         print "OK, VST support will be enabled"
 
 
+#######################
+# Dependency Checking #
+#######################
+
+deps = \
+{
+       'glib-2.0'             : '2.10.1',
+       'gthread-2.0'          : '2.10.1',
+       'gtk+-2.0'             : '2.8.1',
+       'libxml-2.0'           : '2.6.0',
+       'samplerate'           : '0.1.0',
+       'raptor'               : '1.4.2',
+       'lrdf'                 : '0.4.0',
+       'jack'                 : '0.101.1',
+       'libgnomecanvas-2.0'   : '2.0'
+}
+
+def DependenciesRequiredMessage():
+       print 'You do not have the necessary dependencies required to build ardour'
+       print 'Please consult http://ardour.org/building for more information'
+
+def CheckPKGConfig(context, version):
+     context.Message( 'Checking for pkg-config version >= %s... ' %version )
+     ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
+     context.Result( ret )
+     return ret
+
+def CheckPKGVersion(context, name, version):
+     context.Message( 'Checking for %s... ' % name )
+     ret = context.TryAction('pkg-config --atleast-version=%s %s' %(version,name) )[0]
+     context.Result( ret )
+     return ret
+
+conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
+                                       'CheckPKGVersion' : CheckPKGVersion })
+
+# I think a more recent version is needed on win32
+min_pkg_config_version = '0.8.0'
+
+if not conf.CheckPKGConfig(min_pkg_config_version):
+     print 'pkg-config >= %s not found.' % min_pkg_config_version
+     Exit(1)
+
+for pkg, version in deps.iteritems():
+       if not conf.CheckPKGVersion( pkg, version ):
+               print '%s >= %s not found.' %(pkg, version)
+               DependenciesRequiredMessage()
+               Exit(1)
+
+env = conf.Finish()
+
 # ----------------------------------------------------------------------
 # Construction environment setup
 # ----------------------------------------------------------------------
@@ -518,6 +591,24 @@ else:
 env = conf.Finish()
 
 if env['SYSLIBS']:
+
+    syslibdeps = \
+    {
+        'sigc++-2.0'           : '2.0',
+        'gtkmm-2.4'            : '2.8',
+        'libgnomecanvasmm-2.6' : '2.12.0'
+    }
+
+    conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
+                    'CheckPKGVersion' : CheckPKGVersion })
+
+    for pkg, version in syslibdeps.iteritems():
+        if not conf.CheckPKGVersion( pkg, version ):
+            print '%s >= %s not found.' %(pkg, version)
+            DependenciesRequiredMessage()
+            Exit(1)
+       
+    env = conf.Finish()
     
     libraries['sigc2'] = LibraryInfo()
     libraries['sigc2'].ParseConfig('pkg-config --cflags --libs sigc++-2.0')
@@ -576,7 +667,8 @@ if env['SYSLIBS']:
     gtk_subdirs = [
 #        'libs/flowcanvas',
         'libs/gtkmm2ext',
-        'gtk2_ardour'
+        'gtk2_ardour',
+        'libs/clearlooks'
         ]
 
 else:
@@ -645,20 +737,23 @@ else:
        'libs/gtkmm2/gtk',
        'libs/libgnomecanvasmm',
 #      'libs/flowcanvas',
-    'libs/gtkmm2ext',
-    'gtk2_ardour'
+        'libs/gtkmm2ext',
+        'gtk2_ardour',
+        'libs/clearlooks'
         ]
 
 #
-# always build the LGPL control protocol lib, since we link against it ourselves
-# ditto for generic MIDI
+# * always build the LGPL control protocol lib, since we link against it from libardour
+# * ditto for generic MIDI
+# * tranzport checks whether it should build internally, but we need here so that
+#   its included in the tarball
 #
 
-surface_subdirs = [ 'libs/surfaces/control_protocol', 'libs/surfaces/generic_midi' ]
+surface_subdirs = [ 'libs/surfaces/control_protocol', 'libs/surfaces/generic_midi', 'libs/surfaces/tranzport' ]
 
 if env['SURFACES']:
     if have_libusb:
-        surface_subdirs += [ 'libs/surfaces/tranzport' ]
+        env['TRANZPORT'] = 'yes'
     if os.access ('libs/surfaces/sony9pin', os.F_OK):
         surface_subdirs += [ 'libs/surfaces/sony9pin' ]
 
@@ -931,6 +1026,9 @@ env = conf.Finish()
 
 rcbuild = env.SubstInFile ('ardour.rc','ardour.rc.in', SUBST_DICT = subst_dict)
 
+the_revision = env.Command ('frobnicatory_decoy', [], create_stored_revision)
+
+env.Alias('revision', the_revision)
 env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour_system.rc'))
 env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour.rc'))
 
@@ -940,13 +1038,8 @@ Default (rcbuild)
 
 Precious (env['DISTTREE'])
 
-#
-# note the special "cleanfirst" source name. this triggers removal
-# of the existing disttree
-#
-
 env.Distribute (env['DISTTREE'],
-                [ 'SConstruct',
+               [ 'SConstruct', 'svn_revision.h',
                   'COPYING', 'PACKAGER_README', 'README',
                   'ardour.rc.in',
                   'ardour_system.rc',
@@ -970,12 +1063,13 @@ env.Distribute (env['DISTTREE'],
                 glob.glob ('DOCUMENTATION/README*')
                 )
 
-srcdist = env.Tarball(env['TARBALL'], env['DISTTREE'])
+srcdist = env.Tarball(env['TARBALL'], [ env['DISTTREE'], the_revision ])
 env.Alias ('srctar', srcdist)
 
 #
 # don't leave the distree around
 #
+
 env.AddPreAction (env['DISTTREE'], Action ('rm -rf ' + str (File (env['DISTTREE']))))
 env.AddPostAction (srcdist, Action ('rm -rf ' + str (File (env['DISTTREE']))))