- ifndef SRCROOT
- SRCROOT=$(shell /bin/pwd)
- endif
- ifndef OBJROOT
- OBJROOT=$(SRCROOT)/BUILD/obj
- endif
- ifndef DSTROOT
- DSTROOT=$(SRCROOT)/BUILD/dst
- endif
-
- ifndef ARCH
- ARCH=i386 x86_64 ppc ppc64
- endif
-
- ifdef ARCH
- MY_ARCH = $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
- endif
+CFLAGS += -mmacosx-version-min=$(SDKVERSION)
+LIBFLAGS += -mmacosx-version-min=$(SDKVERSION)
+Product ?= MacOSX
+endif
+
+CC := xcrun -sdk $(SDKROOT) cc
+HOSTCC := cc
+
+SRCROOT?=$(shell /bin/pwd)
+OBJROOT?=$(SRCROOT)/BUILD/obj
+DSTROOT?=$(SRCROOT)/BUILD/dst
+SYMROOT?=$(SRCROOT)/BUILD/sym
+
+SRCSUBPATH := $(SRCROOT)
+OBJSUBPATH := $(OBJROOT)
+
+ifdef RC_ARCHS
+ ARCH:=$(RC_ARCHS)
+else
+ ifeq "$(Product)" "MacOSX"
+ ARCH:=i386 x86_64
+ else ifeq "$(Product)" "iPhoneOS"
+ ARCH:=armv7s armv7
+ else ifeq "$(Product)" "AppleTV"
+ ARCH:=i386
+endif
+endif
+
+MY_ARCH := $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
+ARCH_32 := $(filter-out %64, $(ARCH))
+ARCH_32_FLAGS := $(patsubst %, -arch %, $(ARCH_32))
+ARCH_64 := $(filter %64, $(ARCH))
+ARCH_64_FLAGS := $(patsubst %, -arch %, $(ARCH_64))
+
+CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS) -Wno-deprecated-declarations
+
+LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/
+
+# The current implementation of the content protection test requires IOKit.
+ifeq "$(Product)" "iPhoneOS"
+LIBFLAGS += -framework IOKit
+endif
+
+MY_OBJECTS := $(OBJSUBPATH)/main.o $(OBJSUBPATH)/memory_tests.o $(OBJSUBPATH)/misc.o \
+ $(OBJSUBPATH)/sema_tests.o $(OBJSUBPATH)/shared_memory_tests.o \
+ $(OBJSUBPATH)/socket_tests.o $(OBJSUBPATH)/tests.o \
+ $(OBJSUBPATH)/xattr_tests.o $(OBJSUBPATH)/kqueue_tests.o \
+ $(OBJSUBPATH)/machvm_tests.o $(OBJSUBPATH)/commpage_tests.o \
+ $(OBJSUBPATH)/atomic_fifo_queue_test.o $(OBJSUBPATH)/sched_tests.o \
+ $(OBJSUBPATH)/pipes_tests.o