From 0109fb42955d4250870d93c2b35e8a1db9aed934 Mon Sep 17 00:00:00 2001
From: Rob Messick <robmessick@gmail.com>
Date: Sun, 23 Feb 2014 12:15:14 -0800
Subject: [PATCH 1/4] alloca() lives in stdlib.h on FreeBSD

---
 platform/x11/platform_config.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h
index d14f3e3f9ab..21703969cc1 100644
--- a/platform/x11/platform_config.h
+++ b/platform/x11/platform_config.h
@@ -26,7 +26,13 @@
 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
+#ifdef __linux__
 #include <alloca.h>
+#endif
+#ifdef __FreeBSD__
+#include <stdlib.h>
+#endif
+
 #define GLES2_INCLUDE_H "gl_context/glew.h"
 #define GLES1_INCLUDE_H "gl_context/glew.h"
 

From fd03693df1a7e86ce6fef7f077398deb91e81e95 Mon Sep 17 00:00:00 2001
From: Rob Messick <robmessick@gmail.com>
Date: Sun, 23 Feb 2014 12:20:27 -0800
Subject: [PATCH 2/4] Only include linux/joystick.h on linux

---
 platform/x11/os_x11.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index d95818b4a17..2d536f23110 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -45,7 +45,10 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+
+#ifdef __linux__
 #include <linux/joystick.h>
+#endif
 
 //stupid linux.h
 #ifdef KEY_TAB
@@ -1031,7 +1034,6 @@ void OS_X11::close_joystick(int p_id) {
 };
 
 void OS_X11::probe_joystick(int p_id) {
-
 	if (p_id == -1) {
 
 		for (int i=0; i<JOYSTICKS_MAX; i++) {
@@ -1073,7 +1075,6 @@ void OS_X11::move_window_to_foreground() {
 }
 
 void OS_X11::process_joysticks() {
-
 	int bytes;
 	js_event events[32];
 	InputEvent ievent;

From 026566f87222d4ef0f80f7d9f50373ff98310f2a Mon Sep 17 00:00:00 2001
From: Rob Messick <robmessick@gmail.com>
Date: Sun, 23 Feb 2014 12:21:31 -0800
Subject: [PATCH 3/4] ifdef out body of probe_joystick and process_joysticks on
 freebsd until a working implementation is completed

---
 platform/x11/os_x11.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 2d536f23110..a09575bad50 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1034,6 +1034,7 @@ void OS_X11::close_joystick(int p_id) {
 };
 
 void OS_X11::probe_joystick(int p_id) {
+	#ifndef __FreeBSD__
 	if (p_id == -1) {
 
 		for (int i=0; i<JOYSTICKS_MAX; i++) {
@@ -1067,6 +1068,7 @@ void OS_X11::probe_joystick(int p_id) {
 
 		++i;
 	};
+	#endif
 };
 
 void OS_X11::move_window_to_foreground() {
@@ -1075,6 +1077,7 @@ void OS_X11::move_window_to_foreground() {
 }
 
 void OS_X11::process_joysticks() {
+	#ifndef __FreeBSD__
 	int bytes;
 	js_event events[32];
 	InputEvent ievent;
@@ -1173,6 +1176,7 @@ void OS_X11::process_joysticks() {
 			};
 		};
 	};
+	#endif
 };
 
 void OS_X11::set_cursor_shape(CursorShape p_shape) {

From b7386de590871a82bb576951176c0a00210ae761 Mon Sep 17 00:00:00 2001
From: Rob Messick <robmessick@gmail.com>
Date: Sun, 23 Feb 2014 12:42:34 -0800
Subject: [PATCH 4/4] Unused comparison causes error on clang. Suspect this was
 a typo.

---
 script/gdscript/gd_script.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/script/gdscript/gd_script.cpp b/script/gdscript/gd_script.cpp
index 5679e1e066b..8f2da43e968 100644
--- a/script/gdscript/gd_script.cpp
+++ b/script/gdscript/gd_script.cpp
@@ -1416,7 +1416,7 @@ Error GDScript::reload() {
 	String basedir=path;
 
 	if (basedir=="")
-		basedir==get_path();
+		basedir=get_path();
 
 	if (basedir!="")
 		basedir=basedir.get_base_dir();