Skip to content

Comments

Add macOS (arm64) support via Homebrew + Apple frameworks#40

Open
ps-spb wants to merge 1 commit intoJackOfMostTrades:masterfrom
ps-spb:feature/macos-support
Open

Add macOS (arm64) support via Homebrew + Apple frameworks#40
ps-spb wants to merge 1 commit intoJackOfMostTrades:masterfrom
ps-spb:feature/macos-support

Conversation

@ps-spb
Copy link

@ps-spb ps-spb commented May 7, 2025

This PR adds support for building aws-kms-pkcs11 on macOS (arm64), including:

  • Conditional linking against macOS frameworks (Security, CoreFoundation, etc.)
  • Homebrew-based detection of openssl@3 and json-c
  • Darwin-safe removal of --start-group/--end-group
  • Verified building with vcpkg-installed AWS SDK C++ (kms, acm-pca)

I'm aware theres another PR - this seemed a simpler approach. Mandating a user installs via brew doesn't seem too onerous, rather than trying to account for all the edge cases.

@hongkongkiwi
Copy link
Contributor

Seems better than mine! I'd be happy if this gets merged!

OPENSSL_PREFIX := $(shell brew --prefix openssl@3 2>/dev/null)
ifneq ($(OPENSSL_PREFIX),)
OPENSSL_INC := -I$(OPENSSL_PREFIX)/include
OPENSSL_LIB := -L$(OPENSSL_PREFIX)/lib
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this append to LIBS rather than being a separate var? (Seems like it might just simplify the commands below)

JSONC_PREFIX := $(shell brew --prefix json-c 2>/dev/null)
ifneq ($(JSONC_PREFIX),)
JSON_C_INC := -I$(JSONC_PREFIX)/include -I$(JSONC_PREFIX)/include/json-c
JSON_C_LIB := -L$(JSONC_PREFIX)/lib
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about this going into LIBS?

certificates_test: certificates.cpp certificates_test.cpp
g++ -g -fPIC -Wall -I$(AWS_SDK_PATH)/include $(PKCS11_INC) $(JSON_C_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 \
debug.cpp util.cpp certificates.cpp certificates_test.cpp -o certificates_test $(STATIC_LIBS) $(LIBS) -lcrypto -ljson-c -lcurl -lz
g++ -g -fPIC -Wall -I$(AWS_SDK_PATH)/include $(OSX_FRAMEWORKS) $(OPENSSL_INC) $(JSON_C_INC) $(PKCS11_INC) $(JSON_C_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like JSON_C_INC is on here twice now.


aws_kms_pkcs11_test: aws_kms_pkcs11_test.c aws_kms_pkcs11.so
g++ -g -fPIC -Wall -I$(AWS_SDK_PATH)/include $(PKCS11_INC) $(JSON_C_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 \
g++ -g -fPIC -Wall -I$(AWS_SDK_PATH)/include $(OSX_FRAMEWORKS) $(OPENSSL_INC) $(JSON_C_INC) $(PKCS11_INC) $(JSON_C_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON_C_INC repeated

aws_kms_pkcs11.so: aws_kms_pkcs11.cpp unsupported.cpp aws_kms_slot.cpp debug.cpp util.cpp attributes.cpp certificates.cpp
g++ -shared -fPIC -Wall -I$(AWS_SDK_PATH)/include $(PKCS11_INC) $(JSON_C_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 $(SRC) \
-o aws_kms_pkcs11.so $(STATIC_LIBS) $(LIBS) -lcrypto -ljson-c -lcurl -lz
g++ -shared -fPIC -Wall -I$(AWS_SDK_PATH)/include $(OSX_FRAMEWORKS) $(OPENSSL_INC) $(JSON_C_INC) $(PKCS11_INC) $(JSON_C_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 $(SRC) \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON_C_INC repeated

@JackOfMostTrades
Copy link
Owner

Thanks! This PR looks great! Just a couple of small things to clean up in the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants