Index: src/configobject.cpp
===================================================================
--- src/configobject.cpp	(revision 2114)
+++ src/configobject.cpp	(working copy)
@@ -629,7 +629,7 @@
     // On Windows and Mac it is always (and only) app dir.
     //
     QString qConfigPath;
-#ifdef __LINUX__
+#ifdef __UNIX__
     // On Linux, check if the path is stored in the configuration database.
     if (getValueString(ConfigKey("[Config]","Path")).length()>0 && QDir(getValueString(ConfigKey("[Config]","Path"))).exists())
         qConfigPath = getValueString(ConfigKey("[Config]","Path"));
Index: src/SConscript
===================================================================
--- src/SConscript	(revision 2114)
+++ src/SConscript	(working copy)
@@ -47,23 +47,23 @@
 
 #Checks for OGG/Vorbis on all three platforms
 def CheckOggVorbis():
-	#Check for Ogg and Vorbis on Linux, OS X, and Win32
-	if not conf.CheckLib('vorbisfile'):
-		print 'Did not find libvorbisfile.a, libvorbisfile.lib, or the libvorbisfile development headers, exiting!'
+	#these libraries must be checked in this order, because of their dependency tree
+ 	if not conf.CheckLib('ogg'):
+		print 'Did not find libogg.a, libogg.lib, or the libogg development headers, exiting!'
 		Exit(1)
 
 	if not conf.CheckLib('vorbis'):
 		print 'Did not find libvorbis.a, libvorbis.lib, or the libvorbisfile development headers, exiting!'
 		Exit(1)
 
-	if not conf.CheckLib('ogg'):
-		print 'Did not find libogg.a, libogg.lib, or the libogg development headers, exiting!'
+	if not conf.CheckLib('vorbisfile'):
+		print 'Did not find libvorbisfile.a, libvorbisfile.lib, or the libvorbisfile development headers, exiting!'
 		Exit(1)
 
-# This function is here for historical reasons. It used to be easiest to build
-# Mixxx on OS X using the Vorbis and OGG "frameworks", and so this function
-# used to have some OS X-specific stuff in it. If you're building on OS X now
-# though, just install libvorbis and libogg from source.
+	# This function is here for historical reasons. It used to be easiest to build
+	# Mixxx on OS X using the Vorbis and OGG "frameworks", and so this function
+	# used to have some OS X-specific stuff in it. If you're building on OS X now
+	# though, just install libvorbis and libogg from source.
 
 	return
 
@@ -106,7 +106,7 @@
 		print "Not working FFMPEG support... enabled"
 	else:
 		print "Not working FFMPEG support... disabled"
-	return	
+	return
 
 
 # Checks for pkg-config on Linux
@@ -166,6 +166,16 @@
 	env[argflag] = flags
 	return flags
 
+def generic_QT_libs():
+	env.Append(LIBS = 'Qt3Support');
+	env.Append(LIBS = 'QtXml');
+	env.Append(LIBS = 'QtGui');
+	env.Append(LIBS = 'QtCore');
+	env.Append(LIBS = 'QtOpenGL');
+	env.Append(LIBS = 'QtNetwork');
+	env.Append(LIBS = 'QtSql');
+
+
 ###### MAIN LINE ######
 #######################
 #Get the platform/OS that we're building on:
@@ -178,17 +188,19 @@
 elif sys.platform == 'darwin':
 	print 'Platform: OS X'
 	platform = 'osx'
+elif sys.platform == 'openbsd4':
+	print 'Platform: OpenBSD'
+	platform = 'bsd' #so, claiming every BSD is like OpenBSD is probably going to bite us, but whatever it works for the meantime
 else:
 	print 'Platform: Unknown (assuming Linux-like)'
 	platform = 'linux'
 
 #Figure out what the QT path is
-if platform == 'linux':
-	default_qtdir = '/usr/share/qt4'
-elif platform == 'osx':
-	default_qtdir = '/usr/local/Trolltech/Qt-4.3.2/'
-elif platform == 'win32':
-	default_qtdir = 'C:\\qt\\4.3.0'
+#XXX this map should probably be moved to the top of the file
+default_qtdir = {'linux': '/usr/share/qt4',
+		'osx': '/usr/local/Trolltech/Qt-4.3.2/',
+		'win32': 'C:\\qt\\4.3.0',
+		'bsd': '/usr/local/lib/qt4'}[platform]
 
 #Read the qtdir flag, if it was set explicitly
 flags_qtdir = ARGUMENTS.get('qtdir', default_qtdir)
@@ -206,7 +218,7 @@
 #Set up our environment, tell SCONS to use it's QT tools, and set some enviroment variables for it.
 #The ENV = os.environ part pulls in your existing environment variables. This is useful for awkward Linux setups
 #and on Windows where all the paths are set in the shell.
-if platform == 'linux' or platform == 'osx':
+if platform in ('linux','bsd', 'osx'):
 	env = Environment(tools=['default','qt4', 'msvs'], toolpath=['../', './'], QTDIR=flags_qtdir, QT_LIB='', ENV = os.environ)
  	os.environ['PKG_CONFIG_PATH']=flags_qtdir+'lib/pkgconfig'  #Set the PKG_CONFIG_PATH explicitly, handles multiple QT 4.x installations
 elif platform == 'win32':
@@ -317,19 +329,24 @@
 
 #Set up the library path on Windows:
 if platform == 'win32':
-	env.Append(CPPPATH='../../../mixxx-winlib') #If you add more directories, separate them with a semicolon (;)
-	env.Append(LIBPATH='../../../mixxx-winlib')
+	env.Append(CPPPATH=['../../../mixxx-winlib'])
+	env.Append(LIBPATH=['../../../mixxx-winlib'])
 	env.Append(LINKFLAGS = ['/nodefaultlib:libc.lib', '/nodefaultlib:libcd.lib', '/subsystem:windows', '/entry:mainCRTStartup'])
+elif platform == 'bsd':
+	env.Append(LIBS=['pthread', 'ossaudio']) #system libs that we assume exist (XXX should we CheckLib() these?)
+	env.Append(CPPPATH=['/usr/include', '/usr/local/include', '/usr/X11R6/include']) #XXX not complete
+	env.Append(LIBPATH=['/usr/lib/', '/usr/local/lib', '/usr/X11R6/lib']) #XXX not complete
 
 #Check for dependencies if we're not doing a clean...
 
 if not env.GetOption('clean') and not SCons.Util.containsAny(os.sys.argv, ['-h', '--help']):
 	conf = Configure(env, custom_tests = { 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG })
 	
+
+
 #TODO: Add all of the other configure checks as custom_tests properly.
 	
 # On Posix default SCons.LIBPREFIX = 'lib', on Windows default SCons.LIBPREFIX = ''
-
 	if not conf.CheckLibWithHeader('portaudio', 'portaudio.h', 'C'):
 		print 'Did not find libportaudio.a, portaudio.lib, or the PortAudio-v19 development header files - exiting!'
 		Exit(1)
@@ -341,14 +358,11 @@
 	if not conf.CheckLib(['id3tag','libid3tag-release']):
 		print 'Did not find libid3tag.a, libid3tag.lib, or the libid3tag development header files - exiting!'
 		Exit(1)
-
-	#Check for Ogg and Vorbis
+	
 	CheckOggVorbis()
 
-	#Check for OpenGL (it's messy to do it for all three platforms)
 	CheckOpenGL()
 	
-	#Check if FFMPEG was enabled
 	CheckFFMPEG(conf, sources)
 
 	#Check for LADSPA header, if it was passed as a flag
@@ -359,7 +373,7 @@
 			Exit(1)
 
 	#Platform-specific checks for Linux and Win32...
-	if platform == 'linux' or platform == 'win32':
+	if platform in ('linux','bsd', 'win32'):
 		#Check for libsndfile
 		#if not conf.CheckLibWithHeader(['sndfile', 'libsndfile'], 'sndfile.h', 'C'):
 		if not conf.CheckLib(['sndfile', 'libsndfile']):
@@ -372,6 +386,9 @@
 			# "libsndfile",
 			# source=["soundsourcesndfile.cpp", "trackinfoobject.cpp"])
 
+	if platform == 'bsd': #BAH I say. why can't we just live in harmony?
+		generic_QT_libs() 
+
 	#Platform-specific checks for Linux...
 	if platform == 'linux':
 		#Check for g++ (yeah, SCONS is a bit dumb here)
@@ -450,13 +467,7 @@
 		else:
 			env.Append(LIBPATH=flags_qtdir + '/lib/')
 			env.Append(CPPPATH=flags_qtdir + '/include/')
-			env.Append(LIBS = 'Qt3Support');
-			env.Append(LIBS = 'QtXml');
-			env.Append(LIBS = 'QtGui');
-			env.Append(LIBS = 'QtCore');
-			env.Append(LIBS = 'QtOpenGL');
-			env.Append(LIBS = 'QtNetwork');
-			env.Append(LIBS = 'QtSql');
+			generic_QT_libs()
 			
 			
 		#Check for CoreMIDI
@@ -474,6 +485,9 @@
 if platform == 'linux':
 	env.Append(CXXFLAGS = '-D__UNIX__ -D__LINUX__ -DBPMSCHEME_FILE=\\".mixxxbpmscheme.xml\\" -DSETTINGS_FILE=\\".mixxx.cfg\\" -DTRACK_FILE=\\".mixxxtrack.xml\\"')
 	env.Append(CXXFLAGS = '-DUNIX_SHARE_PATH=\\"' + ARGUMENTS.get('prefix', '/usr/local') + '/share/mixxx\\"')
+if platform == 'bsd':
+	env.Append(CXXFLAGS = '-D__UNIX__ -D__BSD__ -DBPMSCHEME_FILE=\\".mixxxbpmscheme.xml\\" -DSETTINGS_FILE=\\".mixxx.cfg\\" -DTRACK_FILE=\\".mixxxtrack.xml\\"')
+	env.Append(CXXFLAGS = '-DUNIX_SHARE_PATH=\\"' + ARGUMENTS.get('prefix', '/usr/local') + '/share/mixxx\\"')
 elif platform == 'osx':
 	env.Append(CXXFLAGS = '-D__MACX__ -DBPMSCHEME_FILE=\\".mixxxbpmscheme.xml\\" -DSETTINGS_FILE=\\".mixxx.cfg\\" -DTRACK_FILE=\\".mixxxtrack.xml\\"')
 elif platform == 'win32':
@@ -579,15 +593,14 @@
 #fidlib (for EQs)
 env.Append(CPPPATH='../../lib/fidlib-0.9.9/')
 sources += Split("""../../lib/fidlib-0.9.9/fidlib.c """)
-#Platform-specific compile/link flags needed for fidlib
-if platform == 'linux' or platform == 'osx':
-	env.Append(CCFLAGS = '-DT_LINUX')
-elif platform == 'win32':
+#Platform-specific compile/link flags needed for fidlib (bastard)
+if platform == 'win32':
 	env.Append(CCFLAGS = '-DT_MSVC')
 	env.Append(CXXFLAGS = '-DT_MSVC')
 	env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT.lib', '/nodefaultlib:LIBCMTD.lib'])
+else:
+	env.Append(CCFLAGS = '-DT_LINUX')
 
-
 #Parse command-line build flags
 build_flags = ""
 
@@ -908,7 +921,7 @@
 if int(flags_script):
 	dll_files += Split("""$QTDIR/lib/QtScript4.dll""")
 
-if platform == 'linux':
+if platform in ('linux', 'bsd'):
 	flags_prefix = ARGUMENTS.get('prefix', '/usr/local')
 	if not os.path.exists(flags_prefix):
 		print "Error: Prefix path does not exist!"
@@ -952,7 +965,7 @@
 			#Delete(unix_share_path + "/mixxx/skins")
 			#print "Copying skins..."
 			#env.Command(unix_share_path + "/mixxx/skins", skin_files, Copy("$TARGET", "$SOURCE"), source_scanner = DirScanner)
-			#Copy(unix_share_path + "/.ixxx/skins", skin_files)
+			#Copy(unix_share_path + "/mixxx/skins", skin_files)
 			#Delete(unix_bin_path + "mixxx")
 			
 			#Delete(unix_share_path + "/mixxx/midi")
Index: src/joysticklinux.h
===================================================================
--- src/joysticklinux.h	(revision 2114)
+++ src/joysticklinux.h	(working copy)
@@ -15,6 +15,7 @@
  *                                                                         *
  ***************************************************************************/
 
+#ifdef __LINUX__
 #ifndef JOYSTICKLINUX_H
 #define JOYSTICKLINUX_H
 
@@ -47,3 +48,4 @@
 };
 
 #endif
+#endif
Index: src/soundsourceproxy.cpp
===================================================================
--- src/soundsourceproxy.cpp	(revision 2114)
+++ src/soundsourceproxy.cpp	(working copy)
@@ -47,10 +47,14 @@
     else
 #ifdef __SNDFILE__
         m_pSoundSource = new SoundSourceSndFile(qFilename);
-#endif
+#else
 #ifdef __AUDIOFILE__
         m_pSoundSource = new SoundSourceAudioFile(qFilename);
+#else
+#error "Neither __SNDFILE__ nor __AUDIOFILE__ is defined"
 #endif
+
+#endif
 }
 
 SoundSourceProxy::SoundSourceProxy(TrackInfoObject * pTrack) : SoundSource(pTrack->getLocation())
Index: src/rtthread.cpp
===================================================================
--- src/rtthread.cpp	(revision 2114)
+++ src/rtthread.cpp	(working copy)
@@ -22,7 +22,9 @@
 #include <string.h>
 #include <qobject.h>
 #include <QDebug>
+#include <pthread.h>
 
+
 #ifdef __MACX__
 int get_bus_speed()
 {
@@ -63,7 +65,18 @@
     if (theError != KERN_SUCCESS)
         qDebug() << "Can't do thread_policy_set";
 #endif
-#ifdef __UNIX__
+#ifdef __BSD__
+    //Appearently setting thread priorities is a bad thing on OpenBSD, causing the app to starve all the other apps.
+    //we'll see...
+    struct sched_param schp;
+    memset(&schp, 0, sizeof(schp));
+#define PTHREAD_MAX_PRIORITY 99 //this is appearently necessary? um.. this is in the manpages but not in the headers. tsk tsk OpenBSD
+    schp.sched_priority = PTHREAD_MAX_PRIORITY;
+
+    if (pthread_setschedparam(pthread_self(), SCHED_RR, &schp) != 0)
+       qDebug() << "Not possible to give audio producer thread high prioriy.";
+#endif
+#ifdef __LINUX__
 #ifndef __MACX__
     // Try to set realtime priority on the current executing thread. This should be used in time-critical
     // producer threads.
@@ -77,7 +90,7 @@
     schp.sched_priority = ((sched_get_priority_max(SCHED_RR))); //sched_get_priority_min(SCHED_RR)) / 2)-1;
 
     if (sched_setscheduler(0, SCHED_RR, &schp) != 0)
-        qDebug() << "Not possible to give audio producer thread high prioriy.";
+       qDebug() << "Not possible to give audio producer thread high prioriy.";
 #endif
 #endif
 #ifdef __WIN__
