New playlist dialog "New" button active from the start and playlist name
[ardour.git] / SConstruct
index fcc5382e92b6b2080018952aa6c29396a921f758..776d2a6241de24c593bce3d607e6b4041f589fc2 100644 (file)
@@ -9,13 +9,14 @@ import errno
 import time
 import platform
 import string
+import commands
 from sets import Set
 import SCons.Node.FS
 
 SConsignFile()
 EnsureSConsVersion(0, 96)
 
-version = '2.0beta2'
+version = '2.0beta9'
 
 subst_dict = { }
 
@@ -25,7 +26,8 @@ subst_dict = { }
 
 opts = Options('scache.conf')
 opts.AddOptions(
-  ('ARCH', 'Set architecture-specific compilation flags by hand (all flags as 1 argument)',''),
+    ('ARCH', 'Set architecture-specific compilation flags by hand (all flags as 1 argument)',''),
+    BoolOption('AUDIOUNITS', 'Compile with Apple\'s AudioUnit library. (experimental)', 0),
     BoolOption('COREAUDIO', 'Compile with Apple\'s CoreAudio library', 0),
     BoolOption('DEBUG', 'Set to build with debugging information and no optimizations', 0),
     PathOption('DESTDIR', 'Set the intermediate install "prefix"', '/'),
@@ -39,8 +41,9 @@ opts.AddOptions(
     PathOption('PREFIX', 'Set the install "prefix"', '/usr/local'),
     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 version information to ardour/gtk executable name inside the build directory', 0),
-    BoolOption('VST', 'Compile with support for VST', 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('TRANZPORT', 'Compile with support for Frontier Designs (if libusb is available)', 0)
 )
 
 #----------------------------------------------------------------------
@@ -229,41 +232,71 @@ 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
 #
 # note: requires that DOMAIN, MAJOR, MINOR, MICRO are set in the construction environment
 # note: assumes one source files, the header that declares the version variables
 #
+
 def version_builder (target, source, env):
-   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"
-   
-   try:
-      o = file (target[0].get_path(), 'w')
-      o.write (text)
-      o.close ()
-   except IOError:
-      print "Could not open", target[0].get_path(), " for writing\n"
-      sys.exit (-1)
-   
-   text  = "#ifndef __" + env['DOMAIN'] + "_version_h__\n"
-   text += "#define __" + env['DOMAIN'] + "_version_h__\n"
-   text += "extern int " + env['DOMAIN'] + "_major_version;\n"
-   text += "extern int " + env['DOMAIN'] + "_minor_version;\n"
-   text += "extern int " + env['DOMAIN'] + "_micro_version;\n"
-   text += "#endif /* __" + env['DOMAIN'] + "_version_h__ */\n"
-   
-   try:
-      o = file (target[1].get_path(), 'w')
-      o.write (text)
-      o.close ();
-   except IOError:
-      print "Could not open", target[1].get_path(), " for writing\n"
-      sys.exit (-1)
-   
-   return None
+
+    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"
+    
+    try:
+        o = file (target[0].get_path(), 'w')
+        o.write (text)
+        o.close ()
+    except IOError:
+        print "Could not open", target[0].get_path(), " for writing\n"
+        sys.exit (-1)
+
+    text  = "#ifndef __" + env['DOMAIN'] + "_version_h__\n"
+    text += "#define __" + env['DOMAIN'] + "_version_h__\n"
+    text += "extern const char* " + env['DOMAIN'] + "_revision;\n"
+    text += "extern int " + env['DOMAIN'] + "_major_version;\n"
+    text += "extern int " + env['DOMAIN'] + "_minor_version;\n"
+    text += "extern int " + env['DOMAIN'] + "_micro_version;\n"
+    text += "#endif /* __" + env['DOMAIN'] + "_version_h__ */\n"
+    
+    try:
+        o = file (target[1].get_path(), 'w')
+        o.write (text)
+        o.close ()
+    except IOError:
+        print "Could not open", target[1].get_path(), " for writing\n"
+        sys.exit (-1)
+        
+    return None
 
 version_bld = Builder (action = version_builder)
 env.Append (BUILDERS = {'VersionBuild' : version_bld})
@@ -277,32 +310,18 @@ env.Append (BUILDERS = {'VersionBuild' : version_bld})
 #
 
 def versioned_builder(target,source,env):
-    # build ID is composed of a representation of the date of the last CVS transaction
-    # for this (SConscript) file
+    w, r = os.popen2( "svn info | awk '/^Revision:/ { print $2}'")
     
-    try:
-        o = file (source[0].get_dir().get_path() +  '/CVS/Entries', "r")
-    except IOError:
-        print "Could not CVS/Entries for reading"
+    last_revision = r.readline().strip()
+    w.close()
+    r.close()
+    if last_revision == "":
+        print "No SVN info found - versioned executable cannot be built"
         return -1
     
-    last_date = ""
-    lines = o.readlines()
-    for line in lines:
-        if line[0:12] == '/SConscript/':
-            parts = line.split ("/")
-            last_date = parts[3]
-            break
-    o.close ()
-    
-    if last_date == "":
-        print "No SConscript CVS update info found - versioned executable cannot be built"
-        return -1
-    
-    tag = time.strftime ('%Y%M%d%H%m', time.strptime (last_date))
-    print "The current build ID is " + tag
+    print "The current build ID is " + last_revision
     
-    tagged_executable = source[0].get_path() + '-' + tag
+    tagged_executable = source[0].get_path() + '-' + last_revision
     
     if os.path.exists (tagged_executable):
         print "Replacing existing executable with the same build tag."
@@ -360,12 +379,12 @@ 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":
-        print 'You cannot build Ardour with VST support for distribution to others.\nIt is a violation of several different licenses. VST support disabled.'
-        env['VST'] = 0;
+        print 'You cannot build Ardour with VST support for distribution to others.\nIt is a violation of several different licenses. Build with VST=false.'
+        sys.exit (-1);
     else:
         print "OK, VST support will be enabled"
 
@@ -457,6 +476,16 @@ libraries['flac'] = conf.Finish ()
 # or if that fails...
 #libraries['flac']    = LibraryInfo (LIBS='FLAC')
 
+# boost (we don't link against boost, just use some header files)
+
+libraries['boost'] = LibraryInfo ()
+conf = Configure (libraries['boost'])
+if conf.CheckHeader ('boost/shared_ptr.hpp', language='CXX') == False:
+        print "Boost header files do not appear to be installed."
+        sys.exit (1)
+    
+libraries['boost'] = conf.Finish ()
+
 #
 # Check for liblo
 
@@ -487,8 +516,6 @@ else:
 
 libraries['dmalloc'] = conf.Finish ()
 
-#
-
 #
 # Audio/MIDI library (needed for MIDI, since audio is all handled via JACK)
 #
@@ -507,7 +534,7 @@ elif conf.CheckCHeader('/System/Library/Frameworks/CoreMIDI.framework/Headers/Co
     subst_dict['%MIDITAG%'] = "ardour"
     subst_dict['%MIDITYPE%'] = "coremidi"
 else:
-    print "It appears you don't have the required MIDI libraries installed."
+    print "It appears you don't have the required MIDI libraries installed. For Linux this means you are missing the development package for ALSA libraries."
     sys.exit (1)
 
 env = conf.Finish()
@@ -533,7 +560,7 @@ if env['SYSLIBS']:
 # cannot use system one for the time being
 #
     
-    libraries['sndfile'] = LibraryInfo(LIBS='libsndfile',
+    libraries['sndfile-ardour'] = LibraryInfo(LIBS='libsndfile-ardour',
                                     LIBPATH='#libs/libsndfile',
                                     CPPPATH=['#libs/libsndfile', '#libs/libsndfile/src'])
 
@@ -542,7 +569,7 @@ if env['SYSLIBS']:
 
 #    libraries['flowcanvas'] = LibraryInfo(LIBS='flowcanvas', LIBPATH='#/libs/flowcanvas', CPPPATH='#libs/flowcanvas')
     libraries['soundtouch'] = LibraryInfo()
-    libraries['soundtouch'].ParseConfig ('pkg-config --cflags --libs libSoundTouch')
+    libraries['soundtouch'].ParseConfig ('pkg-config --cflags --libs soundtouch-1.0')
 
     libraries['appleutility'] = LibraryInfo(LIBS='libappleutility',
                                             LIBPATH='#libs/appleutility',
@@ -556,19 +583,23 @@ if env['SYSLIBS']:
         'libs/libsndfile',
         'libs/pbd',
         'libs/midi++2',
-        'libs/ardour'
+        'libs/ardour',
+    # these are unconditionally included but have
+    # tests internally to avoid compilation etc
+    # if VST is not set
+        'libs/fst',
+        'vst',
+    # this is unconditionally included but has
+    # tests internally to avoid compilation etc
+    # if COREAUDIO is not set
+        'libs/appleutility'
         ]
     
-    if env['VST']:
-        subdirs = ['libs/fst'] + subdirs + ['vst']
-
-    if env['COREAUDIO']:
-        subdirs = subdirs + ['libs/appleutility']
-    
     gtk_subdirs = [
 #        'libs/flowcanvas',
         'libs/gtkmm2ext',
-        'gtk2_ardour'
+        'gtk2_ardour',
+        'libs/clearlooks'
         ]
 
 else:
@@ -597,7 +628,7 @@ else:
     libraries['soundtouch'] = LibraryInfo(LIBS='soundtouch',
                                           LIBPATH='#libs/soundtouch',
                                           CPPPATH=['#libs', '#libs/soundtouch'])
-    libraries['sndfile'] = LibraryInfo(LIBS='libsndfile',
+    libraries['sndfile-ardour'] = LibraryInfo(LIBS='libsndfile-ardour',
                                     LIBPATH='#libs/libsndfile',
                                     CPPPATH=['#libs/libsndfile', '#libs/libsndfile/src'])
 #    libraries['libglademm'] = LibraryInfo(LIBS='libglademm',
@@ -617,15 +648,18 @@ else:
         'libs/libsndfile',
         'libs/pbd',
         'libs/midi++2',
-        'libs/ardour'
+        'libs/ardour',
+    # these are unconditionally included but have
+    # tests internally to avoid compilation etc
+    # if VST is not set
+        'libs/fst',
+        'vst',
+    # this is unconditionally included but has
+    # tests internally to avoid compilation etc
+    # if COREAUDIO is not set
+        'libs/appleutility'
         ]
     
-    if env['VST']:
-        subdirs = ['libs/fst'] + subdirs + ['vst']
-
-    if env['COREAUDIO']:
-        subdirs = subdirs + ['libs/appleutility']
-    
     gtk_subdirs = [
        'libs/glibmm2',
        'libs/gtkmm2/pango',
@@ -634,20 +668,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' ]
 
@@ -671,9 +708,15 @@ if os.environ.has_key('DISTCC_HOSTS'):
     env['ENV']['HOME'] = os.environ['HOME']
 
 final_prefix = '$PREFIX'
-install_prefix = '$DESTDIR/$PREFIX'
 
-subst_dict['INSTALL_PREFIX'] = install_prefix;
+if env['DESTDIR'] :
+    install_prefix = '$DESTDIR/$PREFIX'
+else:
+    install_prefix = env['PREFIX']
+
+subst_dict['%INSTALL_PREFIX%'] = install_prefix;
+subst_dict['%FINAL_PREFIX%'] = final_prefix;
+subst_dict['%PREFIX%'] = final_prefix;
 
 if env['PREFIX'] == '/usr':
     final_config_prefix = '/etc'
@@ -682,15 +725,14 @@ else:
 
 config_prefix = '$DESTDIR' + final_config_prefix
 
-
 # SCons should really do this for us
 
 conf = Configure (env)
 
-have_cxx = conf.TryAction (Action (env['CXX'] + ' --version'))
+have_cxx = conf.TryAction (Action (str(env['CXX']) + ' --version'))
 if have_cxx[0] != 1:
     print "This system has no functional C++ compiler. You cannot build Ardour from source without one."
-    exit (1)
+    sys.exit (1)
 else:
     print "Congratulations, you have a functioning C++ compiler."
 
@@ -915,6 +957,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'))
 
@@ -924,17 +969,22 @@ 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',
-                  'tools/config.guess'
+                  'tools/config.guess',
+                  'icons/icon/ardour_icon_mac_mask.png',
+                  'icons/icon/ardour_icon_mac.png',
+                  'icons/icon/ardour_icon_tango_16px_blue.png',
+                  'icons/icon/ardour_icon_tango_16px_red.png',
+                  'icons/icon/ardour_icon_tango_22px_blue.png',
+                  'icons/icon/ardour_icon_tango_22px_red.png',
+                  'icons/icon/ardour_icon_tango_32px_blue.png',
+                  'icons/icon/ardour_icon_tango_32px_red.png',
+                  'icons/icon/ardour_icon_tango_48px_blue.png',
+                  'icons/icon/ardour_icon_tango_48px_red.png'
                   ] +
                 glob.glob ('DOCUMENTATION/AUTHORS*') +
                 glob.glob ('DOCUMENTATION/CONTRIBUTORS*') +
@@ -944,11 +994,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']))))