From 995fc898662f85c21c2b1ac6a756fff1a2c6ba54 Mon Sep 17 00:00:00 2001
From: Josh Buhler <jbuhler@control4.com>
Date: Tue, 3 Apr 2018 16:28:28 -0600
Subject: [PATCH 1/4] Fixes path used to find SDK

---
 search_sdks.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/search_sdks.sh b/search_sdks.sh
index 3ddac3af..5d9bc327 100755
--- a/search_sdks.sh
+++ b/search_sdks.sh
@@ -43,7 +43,7 @@ if [ $valid_flag -eq "0" ]; then
 
     prompt="Select SDK to use:"
 
-    loc1=( $(find /Applications/XCode.app -type d -name "MacOSX10.*.sdk") )
+    loc1=( $(find /Applications/Xcode.app -type l -name "MacOSX10.*.sdk") )
     loc2=( $(find /Developer/SDKs -maxdepth 1 -type d -name "MacOSX10.*.sdk") )
 
     options=("${loc1[@]}" "${loc2[@]}")

From 09a984a79037dd5c763ca0031763a3c4c9ebc21e Mon Sep 17 00:00:00 2001
From: Josh Buhler <jbuhler@control4.com>
Date: Tue, 3 Apr 2018 19:54:34 -0600
Subject: [PATCH 2/4] MSG_NOSIGNAL is not available on macOS

---
 direwolf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/direwolf.h b/direwolf.h
index 04f840b9..514bcc52 100644
--- a/direwolf.h
+++ b/direwolf.h
@@ -253,7 +253,7 @@ typedef pthread_mutex_t dw_mutex_t;
 // but always using send/recv makes more sense.
 // Need option to prevent a SIGPIPE signal on Linux.  (added for 1.5 beta 2)
 
-#if __WIN32__
+#if __WIN32__ || __APPLE__
 #define SOCK_SEND(s,data,size) send(s,data,size,0)
 #else
 #define SOCK_SEND(s,data,size) send(s,data,size, MSG_NOSIGNAL)

From 49ea703af1b4a1a39a4c7126e2a372cbeb117231 Mon Sep 17 00:00:00 2001
From: Josh Buhler <jbuhler@control4.com>
Date: Tue, 3 Apr 2018 19:56:02 -0600
Subject: [PATCH 3/4] Makefile tweaks

Uses the changes from pull request #71 by schuyler from the main direwolf repo
---
 Makefile.macosx | 27 +++++----------------------
 1 file changed, 5 insertions(+), 22 deletions(-)

diff --git a/Makefile.macosx b/Makefile.macosx
index 63c175da..70af2eac 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -36,27 +36,6 @@ all :  $(APPS) direwolf.conf
 
 SYS_LIBS :=
 SYS_MIN :=
-#SDK := $(shell find /Developer -maxdepth 1 -type d -name "SDKs")
-#$(info $$SDK = ${SDK})
-#ifeq (${SDK},/Developer/SDKs)
-#	SDK := $(shell find /Developer/SDKs -maxdepth 1 -type d -name "MacOSX10.8.sdk")
-#	ifeq (${SDK},/Developer/SDKs/MacOSX10.8.sdk)
-#		SYS_LIBS := -isystem /Developer/SDKs/MacOSX10.8.sdk
-#		SYS_MIN := -mmacosx-version-min=10.8
-#	else
-#		SDK := $(shell find /Developer/SDKs -maxdepth 1 -type d -name "MacOSX10.9.sdk")
-#		ifeq (${SDK},/Developer/SDKs/MacOSX10.9.sdk)
-#			SYS_LIBS := -isystem /Developer/SDKs/MacOSX10.9.sdk
-#			SYS_MIN := -mmacosx-version-min=10.9
-#		else
-#			SDK := $(shell find /Developer/SDKs -maxdepth 1 -type d -name "MacOSX10.10.sdk")
-#			ifeq (${SDK},/Developer/SDKs/MacOSX10.10.sdk)
-#				SYS_LIBS := -isystem /Developer/SDKs/MacOSX10.10.sdk
-#				SYS_MIN := -mmacosx-version-min=10.10
-#			endif
-#		endif
-#	endif
-#endif
 
 SYS_LIBS := $(shell ./search_sdks.sh)
 EXTRA_CFLAGS :=
@@ -70,8 +49,12 @@ endif
 
 # Change as required in support of the available libraries
 
-#CC := $(DARWIN_CC) -m64 $(SYS_LIBS) $(SYS_MIN)
+UNAME_M := $(shell uname -m)
+ifeq (${UNAME_M},x86_64)
+CC := $(DARWIN_CC) -m64 $(SYS_LIBS) $(SYS_MIN)
+else
 CC := $(DARWIN_CC) -m32 $(SYS_LIBS) $(SYS_MIN)
+endif
 
 # _XOPEN_SOURCE=600 and _DEFAULT_SOURCE=1 are needed for glibc >= 2.24.
 # Explanation here:  https://github.com/wb2osz/direwolf/issues/62

From b40d3fa1349b6fde75a44f490b471897a9e96f0b Mon Sep 17 00:00:00 2001
From: Josh Buhler <jbuhler@control4.com>
Date: Tue, 3 Apr 2018 19:56:45 -0600
Subject: [PATCH 4/4] ignore file tweaks

---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index 9f3c3763..3f8779da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,3 +105,5 @@ $RECYCLE.BIN/
 
 # Windows shortcuts
 *.lnk
+/use_this_sdk
+*.dSYM