--- SConstruct.orig	2009-07-20 17:55:10.000000000 +0200
+++ SConstruct	2009-09-15 12:54:21.000000000 +0200
@@ -48,7 +48,7 @@
     BoolOption('FPU_OPTIMIZATION', 'Build runtime checked assembler code', 1),
     BoolOption('LIBLO', 'Compile with support for liblo library', 1),
     BoolOption('NLS', 'Set to turn on i18n support', 1),
-    PathOption('PREFIX', 'Set the install "prefix"', '/usr/local'),
+    PathOption('PREFIX', 'Set the install "prefix"', '/usr/local', PathOption.PathIsDirCreate),
     BoolOption('SURFACES', 'Build support for control surfaces', 1),
     BoolOption('WIIMOTE', 'Build the wiimote control surface', 0),
     ('LIBDIR', 'Set librarydir (typically lib or lib64)', 'lib'),
@@ -679,9 +679,9 @@
     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':
+elif ((re.search ("i[0-9]86", env['DIST_TARGET']) != None) or (re.search ("x86_64", env['DIST_TARGET']) != None)):
     
-    build_host_supports_sse = 0
+    build_host_supports_sse = 1
     
     #
     # ARCH_X86 means anything in the x86 family from i386 to x86_64
@@ -740,12 +740,7 @@
             print "\nWarning: you are building Ardour with SSE support even though your system does not support these instructions. (This may not be anerror, 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'
+env['LIBDIR']='lib'
 
 #
 # no VST on x86_64
@@ -794,13 +789,7 @@
 # prepend boiler plate optimization flags
 #
 
-opt_flags[:0] = [
-    "-O3",
-    "-fomit-frame-pointer",
-    "-ffast-math",
-    "-fstrength-reduce",
-    "-pipe"
-    ]
+opt_flags[:0] = [ "%%CFLAGS%%" ];
 
 if env['DEBUG'] == 1:
     env.Append(CCFLAGS=" ".join (debug_flags))
@@ -889,6 +878,7 @@
 
 libraries['usb'] = LibraryInfo ()
 prep_libcheck(env, libraries['usb'])
+libraries['usb'].Append(CCFLAGS="-I/usr/local/include", LINKFLAGS="-L/usr/local/lib")
 
 conf = Configure (libraries['usb'])
 if conf.CheckLib ('usb', 'usb_interrupt_write'):
@@ -961,6 +951,7 @@
 if env['LIBLO']:
     libraries['lo'] = LibraryInfo ()
     prep_libcheck(env, libraries['lo'])
+    libraries['lo'].Append(CCFLAGS="-I/usr/local/include", LINKFLAGS="-L/usr/local/lib")
 
     conf = Configure (libraries['lo'])
     if conf.CheckLib ('lo', 'lo_server_new') == False:
@@ -974,6 +965,7 @@
 
 libraries['dmalloc'] = LibraryInfo ()
 prep_libcheck(env, libraries['dmalloc'])
+libraries['dmalloc'].Append(CCFLAGS="-I/usr/local/include", LINKFLAGS="-L/usr/local/lib")
 
 #
 # look for the threaded version
@@ -1031,8 +1023,10 @@
     subst_dict['%MIDITAG%'] = "ardour"
     subst_dict['%MIDITYPE%'] = "coremidi"
 else:
-    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)
+    libraries['sysmidi'] = LibraryInfo ()
+    env['SYSMIDI'] = 'none'
+    subst_dict['%MIDITAG%'] = "none"
+    subst_dict['%MIDITYPE%'] = "none"
 
 env = conf.Finish()
 
@@ -1091,7 +1085,7 @@
 
 #    libraries['flowcanvas'] = LibraryInfo(LIBS='flowcanvas', LIBPATH='#/libs/flowcanvas', CPPPATH='#libs/flowcanvas')
     libraries['soundtouch'] = LibraryInfo()
-    libraries['soundtouch'].ParseConfig ('pkg-config --cflags --libs soundtouch-1.0')
+    libraries['soundtouch'].ParseConfig ('pkg-config --cflags --libs soundtouch-1.4')
     # Comment the previous line and uncomment this for old versions of Debian:
     #libraries['soundtouch'].ParseConfig ('pkg-config --cflags --libs libSoundTouch')
 
@@ -1321,8 +1315,8 @@
     subst_dict['%JACK_INPUT%'] = "coreaudio:Built-in Audio:in"
     subst_dict['%JACK_OUTPUT%'] = "coreaudio:Built-in Audio:out"
 else:
-    subst_dict['%JACK_INPUT%'] = "alsa_pcm:playback_"
-    subst_dict['%JACK_OUTPUT%'] = "alsa_pcm:capture_"
+    subst_dict['%JACK_INPUT%'] = "oss:playback_"
+    subst_dict['%JACK_OUTPUT%'] = "oss:capture_"
 
 # posix_memalign available
 if not conf.CheckFunc('posix_memalign'):
