+
+# SCons should really do this for us
+
+conf = env.Configure ()
+
+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."
+ sys.exit (1)
+else:
+ print "Congratulations, you have a functioning C++ compiler."
+
+env = conf.Finish()
+
+
+#
+# Compiler flags and other system-dependent stuff
+#
+
+opt_flags = []
+if env['GPROFILE'] == 1:
+ debug_flags = [ '-O0', '-g', '-pg' ]
+else:
+ debug_flags = [ '-O0', '-g' ]
+
+# guess at the platform, used to define compiler flags
+
+config_guess = os.popen("tools/config.guess").read()[:-1]
+
+config_cpu = 0
+config_arch = 1
+config_kernel = 2
+config_os = 3
+config = config_guess.split ("-")
+
+print "system triple: " + config_guess
+
+# Autodetect
+if env['DIST_TARGET'] == 'auto':
+ if config[config_arch] == 'apple':
+ # The [.] matches to the dot after the major version, "." would match any character
+ if re.search ("darwin[0-7][.]", config[config_kernel]) != None:
+ env['DIST_TARGET'] = 'panther'
+ if re.search ("darwin8[.]", config[config_kernel]) != None:
+ env['DIST_TARGET'] = 'tiger'
+ else:
+ env['DIST_TARGET'] = 'leopard'
+ else:
+ if re.search ("x86_64", config[config_cpu]) != None:
+ env['DIST_TARGET'] = 'x86_64'
+ elif re.search("i[0-5]86", config[config_cpu]) != None:
+ env['DIST_TARGET'] = 'i386'
+ elif re.search("powerpc", config[config_cpu]) != None:
+ env['DIST_TARGET'] = 'powerpc'
+ else:
+ env['DIST_TARGET'] = 'i686'
+ print "\n*******************************"
+ print "detected DIST_TARGET = " + env['DIST_TARGET']
+ print "*******************************\n"
+
+
+if config[config_cpu] == 'powerpc' and env['DIST_TARGET'] != 'none':
+ #
+ # Apple/PowerPC optimization options
+ #
+ # -mcpu=7450 does not reliably work with gcc 3.*
+ #
+ if env['DIST_TARGET'] == 'panther' or env['DIST_TARGET'] == 'tiger':
+ if config[config_arch] == 'apple':
+ ## opt_flags.extend ([ "-mcpu=7450", "-faltivec"])
+ # to support g3s but still have some optimization for above
+ opt_flags.extend ([ "-mcpu=G3", "-mtune=7450"])
+ else:
+ opt_flags.extend ([ "-mcpu=7400", "-maltivec", "-mabi=altivec"])
+ else:
+ opt_flags.extend([ "-mcpu=750", "-mmultiple" ])
+ opt_flags.extend (["-mhard-float", "-mpowerpc-gfxopt"])
+ opt_flags.extend (["-Os"])
+
+elif ((re.search ("i[0-9]86", config[config_cpu]) != None) or (re.search ("x86_64", config[config_cpu]) != None)) and env['DIST_TARGET'] != 'none':
+
+ build_host_supports_sse = 0
+
+ #
+ # ARCH_X86 means anything in the x86 family from i386 to x86_64
+ # USE_X86_64_ASM is used to distingush 32 and 64 bit assembler
+ #
+
+ if (re.search ("(i[0-9]86|x86_64)", config[config_cpu]) != None):
+ debug_flags.append ("-DARCH_X86")
+ opt_flags.append ("-DARCH_X86")
+
+ if config[config_kernel] == 'linux' :
+
+ if env['DIST_TARGET'] != 'i386':
+
+ flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
+ x86_flags = flag_line.split (": ")[1:][0].split ()
+
+ if "mmx" in x86_flags:
+ opt_flags.append ("-mmmx")
+ if "sse" in x86_flags:
+ build_host_supports_sse = 1
+ if "3dnow" in x86_flags:
+ opt_flags.append ("-m3dnow")
+
+ if config[config_cpu] == "i586":
+ opt_flags.append ("-march=i586")
+ elif config[config_cpu] == "i686":
+ opt_flags.append ("-march=i686")
+
+ if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) and build_host_supports_sse:
+ opt_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
+ debug_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
+# end of processor-specific section
+
+# optimization section
+if env['FPU_OPTIMIZATION']:
+ if env['DIST_TARGET'] == 'tiger' or env['DIST_TARGET'] == 'leopard':
+ opt_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
+ debug_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
+ libraries['core'].Append(LINKFLAGS= '-framework Accelerate')
+ elif env['DIST_TARGET'] == 'i686' or env['DIST_TARGET'] == 'x86_64':
+ opt_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
+ debug_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
+ if env['DIST_TARGET'] == 'x86_64':
+ opt_flags.append ("-DUSE_X86_64_ASM")
+ debug_flags.append ("-DUSE_X86_64_ASM")
+ if build_host_supports_sse != 1:
+ print "\nWarning: you are building Ardour with SSE support even though your system does not support these instructions. (This may not be an error, especially if you are a package maintainer)"
+# end optimization section
+
+# handle x86/x86_64 libdir properly
+
+if env['DIST_TARGET'] == 'x86_64':
+ env['LIBDIR']='lib64'
+else:
+ env['LIBDIR']='lib'
+
+#
+# no VST on x86_64
+#
+
+if env['DIST_TARGET'] == 'x86_64' and env['VST']:
+ print "\n\n=================================================="
+ print "You cannot use VST plugins with a 64 bit host. Please run scons with VST=0"
+ print "\nIt is theoretically possible to build a 32 bit host on a 64 bit system."
+ print "However, this is tricky and not recommended for beginners."
+ sys.exit (-1)
+
+#
+# a single way to test if we're on OS X
+#
+
+if env['DIST_TARGET'] in ['panther', 'tiger', 'leopard' ]:
+ env['IS_OSX'] = 1
+ # force tiger or later, to avoid issues on PPC which defaults
+ # back to 10.1 if we don't tell it otherwise.
+ env.Append (CCFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040")
+
+ if env['DIST_TARGET'] == 'leopard':
+ # need this to really build against the 10.4 SDK when building on leopard
+ # ideally this would be configurable, but lets just do that later when we need it
+ env.Append(CCFLAGS="-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
+ env.Append(LINKFLAGS="-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
+
+else:
+ env['IS_OSX'] = 0
+
+#
+# save off guessed arch element in an env
+#
+env.Append(CONFIG_ARCH=config[config_arch])
+
+
+#
+# ARCH="..." overrides all
+#
+
+if env['ARCH'] != '':
+ opt_flags = env['ARCH'].split()
+
+#
+# prepend boiler plate optimization flags
+#
+
+opt_flags[:0] = [
+ "-O3",
+ "-fomit-frame-pointer",
+ "-ffast-math",
+ "-fstrength-reduce",
+ "-pipe"
+ ]
+
+if env['DEBUG'] == 1:
+ env.Append(CCFLAGS=" ".join (debug_flags))
+ env.Append(LINKFLAGS=" ".join (debug_flags))
+else:
+ env.Append(CCFLAGS=" ".join (opt_flags))
+ env.Append(LINKFLAGS=" ".join (opt_flags))
+
+if env['STL_DEBUG'] == 1:
+ env.Append(CXXFLAGS="-D_GLIBCXX_DEBUG")
+
+if env['UNIVERSAL'] == 1:
+ env.Append(CCFLAGS="-arch i386 -arch ppc")
+ env.Append(LINKFLAGS="-arch i386 -arch ppc")
+
+
+#
+# warnings flags
+#
+
+env.Append(CCFLAGS="-Wall")
+env.Append(CXXFLAGS="-Woverloaded-virtual")
+
+if env['EXTRA_WARN']:
+ env.Append(CCFLAGS="-Wextra -pedantic -ansi")
+ env.Append(CXXFLAGS="-ansi")
+# env.Append(CFLAGS="-iso")
+
+#
+# fix scons nitpickiness on APPLE
+#
+
+
+def prep_libcheck(topenv, libinfo):
+ if topenv['IS_OSX']:
+ #
+ # rationale: GTK-Quartz uses jhbuild and installs to ~/gtk/inst by default.
+ # All libraries needed should be built against this location
+
+ if topenv['GTKOSX']:
+ GTKROOT = os.path.expanduser ('~/gtk/inst')
+ libinfo.Append(CPPPATH= GTKROOT + "/include", LIBPATH= GTKROOT + "/lib")
+ libinfo.Append(CXXFLAGS="-I" + GTKROOT + "/include", LINKFLAGS="-L" + GTKROOT + "/lib")
+
+
+
+prep_libcheck(env, env)
+
+#
+# these are part of the Ardour source tree because they are C++
+#
+
+libraries['vamp'] = LibraryInfo (LIBS='vampsdk',
+ LIBPATH='#libs/vamp-sdk',
+ CPPPATH='#libs/vamp-sdk')
+libraries['vamphost'] = LibraryInfo (LIBS='vamphostsdk',
+ LIBPATH='#libs/vamp-sdk',
+ CPPPATH='#libs/vamp-sdk')
+
+env['RUBBERBAND'] = False
+
+conf = Configure (env)
+
+if conf.CheckHeader ('fftw3.h'):
+ env['RUBBERBAND'] = True
+ libraries['rubberband'] = LibraryInfo (LIBS='rubberband',
+ LIBPATH='#libs/rubberband',
+ CPPPATH='#libs/rubberband',
+ CCFLAGS='-DUSE_RUBBERBAND')
+else:
+ print ""
+ print "-------------------------------------------------------------------------"
+ print "You do not have the FFTW single-precision development package installed."
+ print "This prevents Ardour from using the Rubberband library for timestretching"
+ print "and pitchshifting. It will fall back on SoundTouch for timestretch, and "
+ print "pitchshifting will not be available."
+ print "-------------------------------------------------------------------------"
+ print ""
+
+conf.Finish()
+