--- Makefile.orig	2017-04-14 23:02:41.000000000 -0500
+++ Makefile	2017-11-26 09:18:38.000000000 -0600
@@ -11,23 +11,10 @@
 # TOOLCHAIN = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
 # SDKROOT   = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
 
-ifeq ($(shell test -e /usr/lib/libffi.dylib && echo yes), yes)
-	# Use the libffi that ships with OS X.
-	FFI_LIB = -L/usr/lib -lffi
-	FFI_INCLUDE = -I/usr/include/ffi
-else
-	# Use the libffi that is distributed with Nu.
-	FFI_LIB = -L./libffi -lffi
-	FFI_INCLUDE = -I./libffi/include
-endif
-
-ifeq ($(shell test -e $(SDKROOT)/SDKs/MacOSX10.7.sdk && echo yes), yes)
-        LION_CFLAGS = -isysroot $(SDKROOT)/SDKs/MacOSX10.7.sdk
-else
-        LION_CFLAGS =
-endif
+FFI_LIB := $(shell pkg-config libffi --libs)
+FFI_INCLUDE := $(shell pkg-config libffi --cflags)
 
-INCLUDES = $(FFI_INCLUDE) -I./include
+INCLUDES = -I./include $(FFI_INCLUDE)
 
 ifeq ($(shell test -d $(PREFIX)/include && echo yes), yes)
 	INCLUDES += -I$(PREFIX)/include
@@ -48,7 +35,7 @@
 GCC_FILES = $(OBJC_FILES) $(C_FILES)
 GCC_OBJS = $(patsubst %.m, %.o, $(OBJC_FILES)) $(patsubst %.c, %.o, $(C_FILES))
 
-CC = clang
+CC ?= clang
 CFLAGS = -g -O0 -Wall -DMININUSH
 MFLAGS = -fobjc-exceptions 
 #MFLAGS += `gnustep-config --debug-flags` 
@@ -57,12 +44,7 @@
 CFLAGS += -I/usr/include/GNUstep 
 
 ifeq ($(SYSTEM), Darwin)
-	# as of around 10.7.3, clang becomes part of OS X
-	CC = /usr/bin/clang
-	ifneq ($(shell test -e $(CC) && echo yes), yes)
-		CC = $(TOOLCHAIN)/usr/bin/clang
-	endif
-	CFLAGS += -DMACOSX -DDARWIN $(LION_CFLAGS)  
+	CFLAGS += -DMACOSX -DDARWIN @SDK@
 else
 #	CFLAGS += -DLINUX
 	MFLAGS += $(shell gnustep-config --debug-flags)
