pkgsrc on Mac OS X

From Wikistix

Xcode

First, you will need Xcode installed, including the command-line tools, else you'll likely get the following error:

bash$ bmake replace
ERROR: This package has set PKG_FAIL_REASON:
ERROR: No suitable Xcode SDK or Command Line Tools installed.
*** Error code 1

Install the command-line tools:

bash$ xcode-select --install
xcode-select: note: install requested for command line developer tools

If you still get the above error, run the following from pkgsrc which may provide information (as it did here):

bash$ /usr/bin/xcrun --sdk macosx$(sw_vers -productVersion) --show-sdk-path
xcodebuild: error: SDK "macosx10.15.3" cannot be located.
xcodebuild: error: SDK "macosx10.15.3" cannot be located.
xcrun: error: unable to lookup item 'Path' in SDK 'macosx10.15.3'

Further, it appeared the default wasn't installed correctly?

bash$ xcrun --show-sdk-version
xcodebuild: error: SDK "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" cannot be located.
xcrun: error: unable to lookup item 'SDKVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk'
bash$ ls -l /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
total 24
-rw-r--r--  1 root  wheel   127 Oct 18 09:40 Entitlements.plist
drwxr-xr-x  3 root  wheel    96 Aug 30  2019 Library
-rw-r--r--  1 root  wheel  3651 Oct 18 09:40 SDKSettings.json
-rw-r--r--  1 root  wheel  3115 Oct 18 09:40 SDKSettings.plist
drwxr-xr-x  4 root  wheel   128 Aug 30  2019 System
drwxr-xr-x  7 root  wheel   224 Aug 30  2019 usr

"Fixed" by manually adding to mk.conf:

OSX_SDK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

See Also