Don't raise an error when trying to auto-connect master to physical outputs if the...
[ardour.git] / autowaf.py
index 8dc9efffc3693c53a71c8023163160f6bf5998e1..9078761ef837e6ffd702ce2cef017d6ade0842f5 100644 (file)
@@ -81,18 +81,8 @@ def check_header(conf, name, define='', mandatory=False):
                else:
                        conf.check(header_name=name, mandatory=mandatory)
 
-def check_tool(conf, name):
-       "Check for a tool iff it hasn't been checked for yet"
-       if type(conf.env['AUTOWAF_TOOLS']) != dict:
-               conf.env['AUTOWAF_TOOLS'] = {}
-
-       checked = conf.env['AUTOWAF_TOOLS']
-       if not name in checked:
-               conf.check_tool(name)
-               checked[name] = True
-
 def nameify(name):
-       return name.replace('/', '_').replace('++', 'PP').replace('-', '_')
+       return name.replace('/', '_').replace('++', 'PP').replace('-', '_').replace('.', '_')
 
 def check_pkg(conf, name, **args):
        if not 'mandatory' in args:
@@ -129,69 +119,166 @@ def configure(conf):
        global g_step
        if g_step > 1:
                return
-       def append_cxx_flags(val):
-               conf.env.append_value('CCFLAGS', val)
-               conf.env.append_value('CXXFLAGS', val)
+       def append_cxx_flags(vals):
+               conf.env.append_value('CCFLAGS', vals.split())
+               conf.env.append_value('CXXFLAGS', vals.split())
        conf.line_just = 43
-       check_tool(conf, 'misc')
-       check_tool(conf, 'compiler_cc')
-       check_tool(conf, 'compiler_cxx')
+       conf.check_tool('misc')
+       conf.check_tool('compiler_cc')
+       conf.check_tool('compiler_cxx')
        conf.env['BUILD_DOCS'] = Options.options.build_docs
        conf.env['DEBUG'] = Options.options.debug
+       conf.env['STRICT'] = Options.options.strict
        conf.env['PREFIX'] = os.path.abspath(os.path.expanduser(os.path.normpath(conf.env['PREFIX'])))
+       
+       if sys.platform == 'darwin':
+               #
+               #       Define OSX as a uselib to use when compiling
+               #       on Darwin to add all applicable flags at once
+               #
+               conf.env.append_value('CXXFLAGS_OSX', "-mmacosx-version-min=10.4")
+               conf.env.append_value('CCFLAGS_OSX', "-mmacosx-version-min=10.4")
+               conf.env.append_value('CXXFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
+               conf.env.append_value('CCFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
+               conf.env.append_value('LINKFLAGS_OSX', "-mmacosx-version-min=10.4")
+               conf.env.append_value('LINKFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
+               
+               conf.env.append_value('LINKFLAGS_OSX', "-sysroot /Developer/SDKs/MacOSX10.4u.sdk")
+               conf.env.append_value('LINKFLAGS_OSX', "-F/System/Library/Frameworks")
+
+               conf.env.append_value('CXXFLAGS_OSX', "-msse")
+               conf.env.append_value('CCFLAGS_OSX', "-msse")
+               conf.env.append_value('CXXFLAGS_OSX', "-msse2")
+               conf.env.append_value('CCFLAGS_OSX', "-msse2")
+               #
+               #       TODO: The previous sse flags NEED to be based
+               #       off processor type.  Need to add in a check
+               #       for that.
+               #
+               
+               conf.env.append_value('LINKFLAGS_OSX', ['-undefined', 'suppress'])
+               conf.env.append_value('LINKFLAGS_OSX', "-flat_namespace")
+               #
+               #       The previous 2 flags avoid circular dependencies
+               #       between libardour and libardour_cp on OS X.
+               #       ld reported -undefined suppress as an unknown option
+               #       in one of the tests ran, removing it for the moment
+               #
+               conf.env.append_value('CXXFLAGS_OSX', "-F/System/Library/Frameworks")
+               conf.env.append_value('CCFLAGS_OSX', "-F/System/Library/Frameworks")
+
+
+       if Options.options.gtkosx:
+               #
+               #       Define Include Paths for GTKOSX
+               #
+               conf.env.append_value('CPPPATH_GTKOSX', "/usr/include/")
+               conf.env.append_value('CPPPATH_GTKOSX', "/usr/include/c++/4.0.0")
+               conf.env.append_value('CPPPATH_GTKOSX', "/usr/include/c++/4.0.0/i686-apple-darwin8/")
+               #
+               #       TODO: Fix the above include path, it needs to be
+               #       defined based off what is read in the configuration
+               #       stage about the machine(PPC, X86, X86_64, etc.)
+               #
+               conf.env.append_value('CPPPATH_GTKOSX', "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/")
+               #
+               #       TODO: Likewise this needs to be defined not only
+               #       based off the machine characteristics, but also
+               #       based off the version of GCC being used.
+               #
+               conf.env.append_value('CPPPATH_GTKOSX', "/System/Library/Frameworks/")
+               conf.env.append_value('CXXFLAGS_GTKOSX', '-DTOP_MENUBAR')
+               conf.env.append_value('CXXFLAGS_GTKOSX', '-DGTKOSX')
+               conf.env.append_value('LINKFLAGS_GTKOSX', "-framework AppKit")
+               conf.env.append_value('LINKFLAGS_GTKOSX', "-Xlinker -headerpad")
+               conf.env.append_value('LINKFLAGS_GTKOSX', "-Xlinker 2048")
+               conf.env.append_value('CPPPATH_GTKOSX', "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/")
+               #
+               #       I had a note the previous was for MacTypes.h
+               #
+       
+       if Options.options.coreaudio:
+          #conf.env.append_value('LINKFLAGS_COREAUDIO', "-framework CoreAudioKit")
+          #conf.env.append_value('LINKFLAGS_COREAUDIO', "-framework AudioToolbox")
+          #conf.env.append_value('LINKFLAGS_COREAUDIO', "-framework CoreServices")
+          conf.check_cc (header_name = '/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h',
+                                         define_name = 'HAVE_COREAUDIO', linkflags = ['-framework', 'CoreAudio'])
+          conf.check_cxx (header_name = '/System/Library/Frameworks/AudioToolbox.framework/Headers/ExtendedAudioFile.h',
+                                         linkflags = [ '-framework', 'AudioToolbox' ])
+          conf.check_cc (header_name = '/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h',
+                                         linkflags = ['-framework', 'CoreFoundation'])
+          conf.check_cc (header_name = '/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h',
+                                         linkflags = ['-framework', 'CoreServices'])
+          #
+          #    TODO: For some reason the above doesn't seem to be correctly adding the
+          #    the link flags, so we will add them manually.
+          #
+          conf.env.append_value('LINKFLAGS_COREAUDIO', ['-framework', 'CoreServices'])
+          conf.env.append_value('LINKFLAGS_COREAUDIO', ['-framework', 'CoreFoundation'])
+          conf.env.append_value('LINKFLAGS_COREAUDIO', ['-framework', 'AudioToolbox'])
+          conf.env.append_value('LINKFLAGS_COREAUDIO', ['-framework', 'CoreAudio'])
+
+       if Options.options.audiounits:
+          #conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DHAVE_AUDIOUNITS")
+          conf.env.append_value('LINKFLAGS_AUDIOUNITS', "-framework AudioToolbox")
+          conf.env.append_value('LINKFLAGS_AUDIOUNITS', "-framework CoreServices")
+          conf.check_cc (header_name = '/System/Library/Frameworks/AudioUnit.framework/Headers/AudioUnit.h',
+                                         define_name = 'HAVE_AUDIOUNITS', linkflags = [ '-framework', 'AudioUnit' ])
+       
+
        if Options.options.bundle:
                conf.env['BUNDLE'] = True
                conf.define('BUNDLE', 1)
                conf.env['BINDIR'] = conf.env['PREFIX']
-               conf.env['INCLUDEDIR'] = conf.env['PREFIX'] + '/Headers/'
-               conf.env['LIBDIR'] = conf.env['PREFIX'] + '/Libraries/'
-               conf.env['DATADIR'] = conf.env['PREFIX'] + '/Resources/'
-               conf.env['HTMLDIR'] = conf.env['PREFIX'] + '/Resources/Documentation/'
-               conf.env['MANDIR'] = conf.env['PREFIX'] + '/Resources/Man/'
-               conf.env['LV2DIR'] = conf.env['PREFIX'] + '/PlugIns/'
+               conf.env['INCLUDEDIR'] = os.path.join(conf.env['PREFIX'], 'Headers')
+               conf.env['LIBDIR'] = os.path.join(conf.env['PREFIX'], 'Libraries')
+               conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'Resources')
+               conf.env['HTMLDIR'] = os.path.join(conf.env['PREFIX'], 'Resources/Documentation')
+               conf.env['MANDIR'] = os.path.join(conf.env['PREFIX'], 'Resources/Man')
+               conf.env['LV2DIR'] = os.path.join(conf.env['PREFIX'], 'PlugIns')
        else:
                conf.env['BUNDLE'] = False
                if Options.options.bindir:
                        conf.env['BINDIR'] = Options.options.bindir
                else:
-                       conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin/'
+                       conf.env['BINDIR'] = os.path.join(conf.env['PREFIX'], 'bin')
                if Options.options.includedir:
                        conf.env['INCLUDEDIR'] = Options.options.includedir
                else:
-                       conf.env['INCLUDEDIR'] = conf.env['PREFIX'] + '/include/'
+                       conf.env['INCLUDEDIR'] = os.path.join(conf.env['PREFIX'], 'include')
                if Options.options.libdir:
                        conf.env['LIBDIR'] = Options.options.libdir
                else:
-                       conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib/'
+                       conf.env['LIBDIR'] = os.path.join(conf.env['PREFIX'], 'lib')
                if Options.options.datadir:
                        conf.env['DATADIR'] = Options.options.datadir
                else:
-                       conf.env['DATADIR'] = conf.env['PREFIX'] + '/share/'
+                       conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'share')
                if Options.options.configdir:
                        conf.env['CONFIGDIR'] = Options.options.configdir
                else:
-                       conf.env['CONFIGDIR'] = conf.env['PREFIX'] + '/etc/'
+                       conf.env['CONFIGDIR'] = os.path.join(conf.env['PREFIX'], 'etc')
                if Options.options.htmldir:
                        conf.env['HTMLDIR'] = Options.options.htmldir
                else:
-                       conf.env['HTMLDIR'] = conf.env['DATADIR'] + 'doc/' + Utils.g_module.APPNAME + '/'
+                       conf.env['HTMLDIR'] = os.path.join(conf.env['DATADIR'], 'doc', Utils.g_module.APPNAME)
                if Options.options.mandir:
                        conf.env['MANDIR'] = Options.options.mandir
                else:
-                       conf.env['MANDIR'] = conf.env['DATADIR'] + 'man/'
+                       conf.env['MANDIR'] = os.path.join(conf.env['DATADIR'], 'man')
                if Options.options.lv2dir:
                        conf.env['LV2DIR'] = Options.options.lv2dir
                else:
                        if Options.options.lv2_user:
                                if sys.platform == "darwin":
-                                       conf.env['LV2DIR'] = os.getenv('HOME') + '/Library/Audio/Plug-Ins/LV2'
+                                       conf.env['LV2DIR'] = os.path.join(os.getenv('HOME'), 'Library/Audio/Plug-Ins/LV2')
                                else:
-                                       conf.env['LV2DIR'] = os.getenv('HOME') + '/.lv2'
+                                       conf.env['LV2DIR'] = os.path.join(os.getenv('HOME'), '.lv2')
                        else:
                                if sys.platform == "darwin":
                                        conf.env['LV2DIR'] = '/Library/Audio/Plug-Ins/LV2'
                                else:
-                                       conf.env['LV2DIR'] = conf.env['LIBDIR'] + 'lv2/'
+                                       conf.env['LV2DIR'] = os.path.join(conf.env['LIBDIR'], 'lv2')
                
        conf.env['BINDIRNAME'] = chop_prefix(conf, 'BINDIR')
        conf.env['LIBDIRNAME'] = chop_prefix(conf, 'LIBDIR')
@@ -200,13 +287,15 @@ def configure(conf):
        conf.env['LV2DIRNAME'] = chop_prefix(conf, 'LV2DIR')
        
        if Options.options.debug:
-               conf.env['CCFLAGS'] = '-O0 -g -std=c99'
-               conf.env['CXXFLAGS'] = '-O0 -g -ansi'
+               conf.env['CCFLAGS'] = [ '-O0', '-g' ]
+               conf.env['CXXFLAGS'] = [ '-O0',  '-g' ]
+       else:
+               append_cxx_flags('-DNDEBUG')
        if Options.options.strict:
-               conf.env['CCFLAGS'] = '-O0 -g -std=c99 -pedantic'
+               conf.env.append_value('CCFLAGS', [ '-std=c99', '-pedantic' ])
+               conf.env.append_value('CXXFLAGS', [ '-ansi', '-Woverloaded-virtual'])
                append_cxx_flags('-Wall -Wextra -Wno-unused-parameter')
-               conf.env.append_value('CXXFLAGS', '-Woverloaded-virtual')
-       append_cxx_flags('-fPIC -DPIC')
+       append_cxx_flags('-fPIC -DPIC -fshow-column')
        g_step = 2
        
 def set_local_lib(conf, name, has_objects):
@@ -233,10 +322,10 @@ def use_lib(bld, obj, libs):
                                obj.uselib_local = 'lib' + l.lower() + ' '
                
                if in_headers or in_libs:
-                       inc_flag = '-iquote ' + abssrcdir + '/' + l.lower()
+                       inc_flag = '-iquote ' + os.path.join(abssrcdir, l.lower())
                        for f in ['CCFLAGS', 'CXXFLAGS']:
                                if not inc_flag in bld.env[f]:
-                                       bld.env.prepend_value(f, inc_flag)
+                                       bld.env.append_value(f, inc_flag)
                else:
                        if hasattr(obj, 'uselib'):
                                obj.uselib += ' ' + l
@@ -266,6 +355,7 @@ def print_summary(conf):
        display_header('Global configuration')
        display_msg(conf, "Install prefix", conf.env['PREFIX'])
        display_msg(conf, "Debuggable build", str(conf.env['DEBUG']))
+       display_msg(conf, "Strict compiler flags", str(conf.env['STRICT']))
        display_msg(conf, "Build documentation", str(conf.env['BUILD_DOCS']))
        print
        g_step = 3
@@ -320,11 +410,11 @@ def build_dox(bld, name, version, srcdir, blddir):
        obj.source = 'doc/reference.doxygen.in'
        obj.target = 'doc/reference.doxygen'
        if is_child():
-               src_dir = srcdir + '/' + name.lower()
-               doc_dir = blddir + '/default/' + name.lower() + '/doc'
+               src_dir = os.path.join(srcdir, name.lower())
+               doc_dir = os.path.join(blddir, 'default', name.lower(), 'doc')
        else:
                src_dir = srcdir
-               doc_dir = blddir + '/default/doc'
+               doc_dir = os.path.join(blddir, 'default', 'doc')
        obj.dict = {
                name + '_VERSION' : version,
                name + '_SRCDIR'  : os.path.abspath(src_dir),
@@ -332,6 +422,7 @@ def build_dox(bld, name, version, srcdir, blddir):
        }
        obj.install_path = ''
        out1 = bld.new_task_gen('command-output')
+       out1.dependencies = [obj]
        out1.stdout = '/doc/doxygen.out'
        out1.stdin = '/doc/reference.doxygen' # whatever..
        out1.command = 'doxygen'