# uncomment the following to force 32-bit compilation
# FORCE_M32=-m32

### combine the two updates below (1.4.1.0)
ifneq ($(shell sw_vers -productVersion | egrep '^(10\.(6|7|8|9|10|11|12|13|14|15)(\.[0-9]+)|1[123456789])?'),)
SDK=$(shell xcrun --show-sdk-path)
###
### update 1 (@mitchblank PR #158): fix for MacOS 11 / Big Sur
# ifneq ($(shell sw_vers -productVersion | egrep '^(10\.(6|7|8|9|10|11|12|13|14|15)(\.[0-9]+)|1[123456789])?'),)
# SDK=$(shell xcodebuild -sdk macosx -version | grep '^Path:' | sed 's/Path: \(.*\)/\1/')
### update 2 (@rnkn PR #164): remove need to use xcodebuild (only available with XCode installed)
# ifneq ($(shell sw_vers -productVersion | egrep '10\.(6|7|8|9|10|11|12|13|14|15)(\.[0-9]+)?'),)
# SDK=$(shell xcrun --show-sdk-path)
###

ISYSROOT=-isysroot $(SDK)
LINK_EXTRAS=-F/System/Library/PrivateFrameworks \
    -weak_framework MultitouchSupport
else
ISYSROOT=-isysroot /Developer/SDKs/MacOSX10.4u.sdk
LINK_EXTRAS=
endif

# ifneq ($(shell which clang),)
# force clang if available (for OS X 10.4 compatibility)
# CC=clang
# CXX=clang++
# LD=clang++
# endif

CFLAGS+= -D__MACOSX_CORE__ $(FORCE_M32) $(ISYSROOT)
CFLAGSDEPEND+= -D__MACOSX_CORE__ $(FORCE_M32) $(ISYSROOT)

FRAMEWORKS+= CoreAudio CoreMIDI CoreFoundation IOKit Carbon AppKit Foundation
LDFLAGS+= $(FORCE_M32) $(ISYSROOT) $(addprefix -framework ,$(FRAMEWORKS)) \
    $(LINK_EXTRAS) -lc++ -lm

SF_CSRCS+= util_sndfile.c


# this is to link properly on leopard...
MACOSX_DEPLOYMENT_TARGET=10.9
export MACOSX_DEPLOYMENT_TARGET
# option 2, add this to the gcc flags: -mmacosx-version-min=10.4

#-----------------------------------------------------------------------------
# by default, ChucK uses a pre-configured libsndfile...
# uncomment the next 3 lines to use libsndfile on your system
#-----------------------------------------------------------------------------
#FLAGS+= -D__CK_SNDFILE_NATIVE__
#LIBS+= -lsndfile
#SF_OBJ=

