From d74fa4b9ca371e8a16882016b71a08b8e87261e4 Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Fri, 9 Oct 2015 22:48:56 +0000
Subject: [PATCH 1/3] Avoid compiling OpenGL parts when OpenGL is disabled.

---
 SConstruct                                                 |  2 ++
 engine/SConscript                                          | 14 +++++++++++++-
 .../core/gui/fifechan/base/opengl/opengl_gui_graphics.cpp  |  4 ++++
 engine/core/video/opengl/fife_opengl.h                     |  2 +-
 engine/core/video/opengl/glimage.cpp                       |  4 ++++
 engine/core/video/opengl/glimage.h                         |  2 +-
 engine/core/video/opengl/renderbackendopengl.cpp           |  4 ++++
 engine/core/video/opengl/renderbackendopengl.h             |  3 ++-
 8 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/SConstruct b/SConstruct
index 71966d8..ced3e90 100644
--- a/SConstruct
+++ b/SConstruct
@@ -198,9 +198,11 @@ else:
 
 if GetOption('disable-opengl'):
 	opengl = 0
+	env['ENABLE_OPENGL'] = False
 	extra_libs['opengl'] = False
 else:
 	opengl = 1
+	env['ENABLE_OPENGL'] = True
 	extra_libs['opengl'] = True
 
 if GetOption('disable-zip'):
diff --git a/engine/SConscript b/engine/SConscript
index e9348c3..1fe1ffa 100644
--- a/engine/SConscript
+++ b/engine/SConscript
@@ -35,6 +35,7 @@ core_path = os.path.join('engine', 'core')
 extensionpath = upath(os.path.join(opts['SRC'], 'python', 'fife', 'extensions'))
 
 local_tinyxml = env['LOCAL_TINYXML']
+opengl = env['ENABLE_OPENGL']
 fifechan = env['ENABLE_FIFECHAN']
 librocket = env['ENABLE_LIBROCKET']
 cegui = env['ENABLE_CEGUI']
@@ -46,7 +47,7 @@ if fifechan:
 #**************************************************************************
 #Compile the list of source code to be used
 #**************************************************************************
-dirfilters = ['swigwrappers', 'tinyxml', 'fifechan', 'librocket', 'cegui', 'cegui-0']
+dirfilters = ['swigwrappers', 'tinyxml', 'fifechan', 'librocket', 'cegui', 'cegui-0', 'glee']
 
 allfiles = list(src_path.walkfiles())
 allfiles_base = list()
@@ -92,6 +93,17 @@ if (local_tinyxml):
 	compilefiles = compilefiles + local_tinyxml_implfiles
 
 #**************************************************************************
+# if opengl is enabled add the local glee header/impl files to the overall
+# compile list
+#**************************************************************************
+if opengl:
+	local_glee_header_files = utils.include_by_dir(['glee'], headerfiles)
+	local_glee_impl_files = utils.include_by_dir(['glee'], implfiles)
+
+	headerfiles = headerfiles + local_glee_header_files
+	compilefiles = compilefiles + local_glee_impl_files
+
+#**************************************************************************
 #Compile the list of fifechan glue code
 #**************************************************************************
 fifechan_glue_headerfiles = utils.include_by_dir(['fifechan'], headerfiles)
diff --git a/engine/core/gui/fifechan/base/opengl/opengl_gui_graphics.cpp b/engine/core/gui/fifechan/base/opengl/opengl_gui_graphics.cpp
index f12cc4d..33ab24f 100644
--- a/engine/core/gui/fifechan/base/opengl/opengl_gui_graphics.cpp
+++ b/engine/core/gui/fifechan/base/opengl/opengl_gui_graphics.cpp
@@ -19,6 +19,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
+#ifdef HAVE_OPENGL
+
 // Standard C++ library includes
 
 // This needs to be here, before fifechan includes gl.h
@@ -168,3 +170,5 @@ namespace FIFE {
 		mColor = color;
 	}
 }
+
+#endif // HAVE_OPENGL
diff --git a/engine/core/video/opengl/fife_opengl.h b/engine/core/video/opengl/fife_opengl.h
index b4ce51a..a3bdcf0 100644
--- a/engine/core/video/opengl/fife_opengl.h
+++ b/engine/core/video/opengl/fife_opengl.h
@@ -19,7 +19,7 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
-#ifndef FIFE_UTIL_FIFEGL_H
+#if !defined(FIFE_UTIL_FIFEGL_H) && defined(HAVE_OPENGL)
 #define FIFE_UTIL_FIFEGL_H
 
 // Standard C++ library includes
diff --git a/engine/core/video/opengl/glimage.cpp b/engine/core/video/opengl/glimage.cpp
index 76c13d7..c24eeb8 100644
--- a/engine/core/video/opengl/glimage.cpp
+++ b/engine/core/video/opengl/glimage.cpp
@@ -19,6 +19,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
+#ifdef HAVE_OPENGL
+
 // Standard C++ library includes
 #include <cassert>
 #include <iostream>
@@ -588,3 +590,5 @@ namespace FIFE {
 		return m_tex_coords;
 	}
 }
+
+#endif // HAVE_OPENGL
diff --git a/engine/core/video/opengl/glimage.h b/engine/core/video/opengl/glimage.h
index 61e185a..9ab2391 100644
--- a/engine/core/video/opengl/glimage.h
+++ b/engine/core/video/opengl/glimage.h
@@ -19,7 +19,7 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
-#ifndef FIFE_VIDEO_RENDERBACKENDS_OPENGL_GLIMAGE_H
+#if !defined(FIFE_VIDEO_RENDERBACKENDS_OPENGL_GLIMAGE_H) && defined(HAVE_OPENGL)
 #define FIFE_VIDEO_RENDERBACKENDS_OPENGL_GLIMAGE_H
 
 // Standard C++ library includes
diff --git a/engine/core/video/opengl/renderbackendopengl.cpp b/engine/core/video/opengl/renderbackendopengl.cpp
index fbabc17..d470880 100644
--- a/engine/core/video/opengl/renderbackendopengl.cpp
+++ b/engine/core/video/opengl/renderbackendopengl.cpp
@@ -19,6 +19,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
+#ifdef HAVE_OPENGL
+
 // Standard C++ library includes
 
 // Platform specific includes
@@ -2310,3 +2312,5 @@ namespace FIFE {
 		glPopMatrix();
 	}
 }
+
+#endif // HAVE_OPENGL
diff --git a/engine/core/video/opengl/renderbackendopengl.h b/engine/core/video/opengl/renderbackendopengl.h
index f12c4d5..ef92eb0 100644
--- a/engine/core/video/opengl/renderbackendopengl.h
+++ b/engine/core/video/opengl/renderbackendopengl.h
@@ -19,7 +19,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
-#ifndef FIFE_VIDEO_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_H
+#if !defined(FIFE_VIDEO_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_H) \
+	&& defined(HAVE_OPENGL)
 #define FIFE_VIDEO_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_H
 
 // Standard C++ library includes
-- 
2.2.2


From 02790672ac0464e8b0585ad637b84182ee416573 Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Sat, 10 Oct 2015 17:08:37 +0000
Subject: [PATCH 2/3] Fix build with "--disable-githash" option set.

---
 SConstruct | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/SConstruct b/SConstruct
index ced3e90..a3b1a1e 100644
--- a/SConstruct
+++ b/SConstruct
@@ -441,6 +441,8 @@ opts['FIFE_VERSION'] = utils.get_fife_version(os.path.join(opts['SRC'], 'core'))
 
 if get_githash:
 	opts['FIFE_GIT_HASH'] = utils.get_fife_git_hash(os.getcwd())
+else:
+	opts['FIFE_GIT_HASH'] = ''
 
 if debug:
 	opts['LIBPATH'] = os.path.join(os.getcwd(), 'build', 'engine', 'debug')
-- 
2.2.2


From 4eeac1dbedfa9ee1fdf9168b80699e1c8377b616 Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Fri, 9 Oct 2015 22:51:23 +0000
Subject: [PATCH 3/3] Initial Haiku port.

---
 build/haiku1-config.py                             | 52 ++++++++++++++++++++++
 engine/core/audio/fife_openal.h                    |  2 +-
 .../core/loaders/native/audio/sounddecoder_ogg.h   |  2 +-
 3 files changed, 54 insertions(+), 2 deletions(-)
 create mode 100644 build/haiku1-config.py

diff --git a/build/haiku1-config.py b/build/haiku1-config.py
new file mode 100644
index 0000000..8afb550
--- /dev/null
+++ b/build/haiku1-config.py
@@ -0,0 +1,52 @@
+import os
+import subprocess
+import sys
+
+
+def initEnvironment(env):
+	env.AppendUnique(CPPDEFINES = ['TIXML_USE_STL'])
+	env.Append(CXXFLAGS = ['-Wl,--no-undefined'])
+	env.Append(LIBS = ['ogg', 'vorbis'])
+	env.Tool('swig')
+	return env
+
+def addExtras(env, opengl):
+	if opengl:
+		env.Append(LIBS = ['stdc++', 'GL'])
+	return env
+
+def getRequiredHeaders(opengl):
+	return None
+
+def getRequiredLibs(reqLibs):
+	libs = [
+			('boost_system', ''),
+			('boost_filesystem', 'boost/filesystem.hpp'),
+			('boost_regex', 'boost/regex.hpp'),
+			('openal', 'AL/al.h'),
+			('png', 'png.h'),
+			('python', 'Python.h'),
+			('sdl', 'SDL.h'),
+			('SDL_ttf', 'SDL_ttf.h'),
+			('SDL_image', 'SDL_image.h'),
+			('vorbisfile', 'vorbis/vorbisfile.h') ]
+
+	opengl = reqLibs['opengl']
+	fifechan = reqLibs['fifechan']
+
+	if fifechan:
+		libs.append(('fifechan', 'fifechan.hpp'))
+		libs.append(('fifechan_sdl', ''))
+		if opengl:
+			libs.append(('fifechan_opengl', ''))
+
+	return libs
+
+def createFifechanEnv(standard_env):
+	fifechan_lib_env = standard_env.Clone(LIBS = ['python2.7', 'fifechan'])
+	return fifechan_lib_env
+
+def getOptionalLibs(opengl):
+	return None
+
+# vim: ft=python:
diff --git a/engine/core/audio/fife_openal.h b/engine/core/audio/fife_openal.h
index db198b6..1a9cb08 100644
--- a/engine/core/audio/fife_openal.h
+++ b/engine/core/audio/fife_openal.h
@@ -26,7 +26,7 @@
 
 // Platform specific includes
 // Linux
-#if defined( __unix__ )
+#if defined( __unix__ ) || defined( __HAIKU__ )
 #include <AL/al.h>
 #include <AL/alc.h>
 #endif
diff --git a/engine/core/loaders/native/audio/sounddecoder_ogg.h b/engine/core/loaders/native/audio/sounddecoder_ogg.h
index 0e2d4fa..0f79cea 100644
--- a/engine/core/loaders/native/audio/sounddecoder_ogg.h
+++ b/engine/core/loaders/native/audio/sounddecoder_ogg.h
@@ -27,7 +27,7 @@
 // Platform specific includes
 
 // 3rd party library includes
-#include <vorbisfile.h>
+#include <vorbis/vorbisfile.h>
 #include <boost/scoped_ptr.hpp>
 
 // FIFE includes
-- 
2.2.2

