--- a/Makefile
+++ b/Makefile
@@ -285,8 +285,7 @@ endif
 API_MAJOR=$(shell echo `grep -e CS_API_MAJOR include/capstone/capstone.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}')
 VERSION_EXT =
 
-IS_APPLE := $(shell $(CC) -dM -E - < /dev/null 2> /dev/null | grep __apple_build_version__ | wc -l | tr -d " ")
-ifeq ($(IS_APPLE),1)
+ifeq ($(OS),Darwin)
 # on MacOS, do not build in Universal format by default
 MACOS_UNIVERSAL ?= no
 ifeq ($(MACOS_UNIVERSAL),yes)
@@ -295,16 +294,8 @@ LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
 endif
 EXT = dylib
 VERSION_EXT = $(API_MAJOR).$(EXT)
-$(LIBNAME)_LDFLAGS += -dynamiclib -install_name lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR)
+$(LIBNAME)_LDFLAGS += -dynamiclib -install_name $(PREFIX)/lib/lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR)
 AR_EXT = a
-# Homebrew wants to make sure its formula does not disable FORTIFY_SOURCE
-# However, this is not really necessary because 'CAPSTONE_USE_SYS_DYN_MEM=yes' by default
-ifneq ($(HOMEBREW_CAPSTONE),1)
-ifneq ($(CAPSTONE_USE_SYS_DYN_MEM),yes)
-# remove string check because OSX kernel complains about missing symbols
-CFLAGS += -D_FORTIFY_SOURCE=0
-endif
-endif
 else
 CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
 LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
