-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MacOS specific compilation options #31
Open
hongkongkiwi
wants to merge
1
commit into
JackOfMostTrades:master
Choose a base branch
from
hongkongkiwi:compile_macos
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.idea/ | ||
*.iml | ||
*.so | ||
*.dylib | ||
aws_kms_pkcs11_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Detect OS | ||
UNAME_S := $(shell uname -s) | ||
|
||
# Try to locate the AWS SDK if not specified with AWS_SDK_PATH | ||
MACHINE := $(shell gcc -dumpmachine) | ||
ifeq ($(AWS_SDK_PATH),) | ||
|
@@ -28,9 +31,9 @@ endif | |
# dynamic libs, or both. | ||
# | ||
# Let's try to intuit this unless specified, with a bias towards static libs | ||
# if available, as they SDK versions tend to have ABI compatilbility issues | ||
# if available, as they SDK versions tend to have ABI compatibility issues | ||
# | ||
# Use these variables to override the mechanisms for those two sets: | ||
# Use these variables to override the mechanisms for those two sets: | ||
# | ||
# AWS_SDK_STATIC = y : Force use of static libraries for both C and C++ | ||
# AWS_SDK_STATIC = n : Force use of dynamic libraries for both C and C++ | ||
|
@@ -57,17 +60,17 @@ ifndef AWS_SDK_C_STATIC | |
else ifneq ($(wildcard ${AWS_SDK_LIB_PATH}/libaws-c-common.so),) | ||
AWS_SDK_C_STATIC := n | ||
else | ||
$(error Cannot find either static or dynamic SDK C libraries) | ||
$(error Cannot find either static or dynamic SDK C libraries) | ||
endif | ||
endif | ||
|
||
ifndef AWS_SDK_CPP_STATIC | ||
ifneq ($(wildcard ${AWS_SDK_LIB_PATH}/libaws-cpp-sdk-kms.a),) | ||
AWS_SDK_CPP_STATIC := y | ||
AWS_SDK_CPP_STATIC := y | ||
else ifneq ($(wildcard ${AWS_SDK_LIB_PATH}/libaws-cpp-sdk-core.so),) | ||
AWS_SDK_CPP_STATIC := n | ||
AWS_SDK_CPP_STATIC := n | ||
else | ||
$(error Cannot find either static or dynamic SDK C++ libraries) | ||
$(error Cannot find either static or dynamic SDK C++ libraries) | ||
endif | ||
endif | ||
|
||
|
@@ -111,6 +114,29 @@ ifeq ($(JSON_C_INC),) | |
endif | ||
endif | ||
|
||
# Try to locate the json-c libraries if location not specified with JSON_C_LIB | ||
ifeq ($(JSON_C_LIB),) | ||
JSON_C_LIB := $(shell pkg-config --libs json-c 2>/dev/null) | ||
ifeq ($(JSON_C_LIB),) | ||
$(error json-c libraries not found, specify JSON_C_LIB) | ||
endif | ||
endif | ||
|
||
# Try to locate OpenSSL if not specified with OPENSSL_INC and OPENSSL_LIB | ||
ifeq ($(OPENSSL_INC),) | ||
OPENSSL_INC := $(shell pkg-config --cflags openssl 2>/dev/null) | ||
ifeq ($(OPENSSL_INC),) | ||
$(error OpenSSL not found, please specify OPENSSL_INC) | ||
endif | ||
endif | ||
|
||
ifeq ($(OPENSSL_LIB),) | ||
OPENSSL_LIB := $(shell pkg-config --libs openssl 2>/dev/null) | ||
ifeq ($(OPENSSL_LIB),) | ||
$(error OpenSSL libraries not found, please specify OPENSSL_LIB) | ||
endif | ||
endif | ||
|
||
ifdef AWS_SDK_USE_SYSTEM_PROXY | ||
ifeq ($(AWS_SDK_USE_SYSTEM_PROXY),y) | ||
PROXY_CFLAGS := -DAWS_SDK_USE_SYSTEM_PROXY=1 | ||
|
@@ -124,6 +150,7 @@ endif | |
# Build library link list | ||
STATIC_LIBS := | ||
LIBS := | ||
|
||
ifeq ($(AWS_SDK_CPP_STATIC),y) | ||
$(info Using C++ SDK static libraries) | ||
STATIC_LIBS += $(AWS_SDK_LIB_PATH)/libaws-cpp-sdk-kms.a | ||
|
@@ -136,11 +163,14 @@ else ifeq ($(AWS_SDK_CPP_STATIC),n) | |
LIBS += $(AWS_SDK_LIB_PATH)/libaws-cpp-sdk-kms.so | ||
LIBS += $(AWS_SDK_LIB_PATH)/libaws-cpp-sdk-acm-pca.so | ||
else | ||
$(error Unrecognized value for AWS_SDK_CPP_STATIC, use y or n) | ||
$(error Unrecognized value for AWS_SDK_CPP_STATIC, use y or n) | ||
endif | ||
|
||
ifeq ($(AWS_SDK_C_STATIC),y) | ||
$(info Using C SDK static libraries) | ||
STATIC_LIBS += -Wl,--start-group | ||
ifeq ($(UNAME_S),Linux) | ||
STATIC_LIBS += -Wl,--start-group | ||
endif | ||
STATIC_LIBS += $(AWS_SDK_LIB_PATH)/libaws-checksums.a | ||
STATIC_LIBS += $(AWS_SDK_LIB_PATH)/libaws-c-common.a | ||
STATIC_LIBS += $(AWS_SDK_LIB_PATH)/libaws-c-event-stream.a | ||
|
@@ -153,39 +183,50 @@ ifeq ($(AWS_SDK_C_STATIC),y) | |
STATIC_LIBS += $(AWS_SDK_LIB_PATH)/libaws-c-s3.a | ||
STATIC_LIBS += $(AWS_SDK_LIB_PATH)/libaws-c-sdkutils.a | ||
STATIC_LIBS += $(AWS_SDK_LIB_PATH)/libs2n.a | ||
STATIC_LIBS += -Wl,--end-group | ||
ifeq ($(UNAME_S),Linux) | ||
STATIC_LIBS += -Wl,--end-group | ||
endif | ||
else ifeq ($(AWS_SDK_C_STATIC),n) | ||
$(info Using C SDK dynamic libraries) | ||
LIBS += $(AWS_SDK_LIB_PATH)/libaws-checksums.so | ||
LIBS += $(AWS_SDK_LIB_PATH)/libaws-c-common.so | ||
LIBS += $(AWS_SDK_LIB_PATH)/libaws-c-event-stream.so | ||
else | ||
$(error Unrecognized value for AWS_SDK_C_STATIC, use y or n) | ||
$(error Unrecognized value for AWS_SDK_C_STATIC, use y or n) | ||
endif | ||
|
||
# Source files | ||
SRC = attributes.cpp aws_kms_pkcs11.cpp certificates.cpp unsupported.cpp debug.cpp aws_kms_slot.cpp | ||
|
||
all: aws_kms_pkcs11.so | ||
# Additional frameworks for macOS | ||
ifeq ($(UNAME_S),Darwin) | ||
MACOSX_FRAMEWORKS := -framework CoreFoundation -framework Security | ||
endif | ||
|
||
all: aws_kms_pkcs11.so aws_kms_pkcs11.dylib | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if it makes sense to target the dylib on Linux systems (and vice-versa)? Can/should |
||
|
||
clean: | ||
rm -f aws_kms_pkcs11.so aws_kms_pkcs11_test aws_kms_client_test | ||
rm -f aws_kms_pkcs11.so aws_kms_pkcs11.dylib aws_kms_pkcs11_test aws_kms_client_test | ||
|
||
test: aws_kms_pkcs11_test certificates_test | ||
./certificates_test | ||
AWS_KMS_PKCS11_DEBUG=1 ./aws_kms_pkcs11_test | ||
|
||
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 certificates.cpp certificates_test.cpp -o certificates_test $(STATIC_LIBS) $(LIBS) -lcrypto -ljson-c -lcurl | ||
g++ -g -fPIC -Wall -I$(AWS_SDK_PATH)/include $(PKCS11_INC) $(JSON_C_INC) $(OPENSSL_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 \ | ||
debug.cpp certificates.cpp certificates_test.cpp -o certificates_test $(STATIC_LIBS) $(LIBS) $(OPENSSL_LIB) $(JSON_C_LIB) -lcurl $(MACOSX_FRAMEWORKS) -lz | ||
|
||
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 \ | ||
aws_kms_pkcs11_test.c -o aws_kms_pkcs11_test -ldl | ||
g++ -g -fPIC -Wall -I$(AWS_SDK_PATH)/include $(PKCS11_INC) $(JSON_C_INC) $(OPENSSL_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 \ | ||
aws_kms_pkcs11_test.c -o aws_kms_pkcs11_test -ldl $(OPENSSL_LIB) $(JSON_C_LIB) $(MACOSX_FRAMEWORKS) -lz | ||
|
||
aws_kms_pkcs11.so: aws_kms_pkcs11.cpp unsupported.cpp aws_kms_slot.cpp debug.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 | ||
g++ -shared -fPIC -Wall -I$(AWS_SDK_PATH)/include $(PKCS11_INC) $(JSON_C_INC) $(OPENSSL_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 $(SRC) \ | ||
-o aws_kms_pkcs11.so $(STATIC_LIBS) $(LIBS) $(OPENSSL_LIB) $(JSON_C_LIB) -lcurl $(MACOSX_FRAMEWORKS) -lz | ||
|
||
aws_kms_pkcs11.dylib: aws_kms_pkcs11.cpp unsupported.cpp aws_kms_slot.cpp debug.cpp attributes.cpp certificates.cpp | ||
g++ -dynamiclib -fPIC -Wall -I$(AWS_SDK_PATH)/include $(PKCS11_INC) $(JSON_C_INC) $(OPENSSL_INC) $(PROXY_CFLAGS) -fno-exceptions -std=c++17 $(SRC) \ | ||
-o aws_kms_pkcs11.dylib $(STATIC_LIBS) $(LIBS) $(OPENSSL_LIB) $(JSON_C_LIB) -lcurl $(MACOSX_FRAMEWORKS) -lz | ||
|
||
install: aws_kms_pkcs11.so | ||
cp aws_kms_pkcs11.so $(PKCS11_MOD_PATH)/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg-config --cflags openssl
will actually be empty on an Ubuntu system (this is why CI is failing) because header files are in the standard include path. If themake
will fail if pkg-config has non-zero exit code then you can probably skip this check? A stack overflow post leads me to thinkifneq ($(.SHELLSTATUS),0)
might be the right alternative here.