Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Detect Darwin OS and try to determine lib paths
Browse files Browse the repository at this point in the history
This tries to automatically determine the location of `openssl@1.1` and
`libssh2` if installed on MacOS using the brew package manager, or
provides a warning with an install / configuration suggestion.

Signed-off-by: Hidde Beydals <hello@hidde.co>
  • Loading branch information
hiddeco committed Sep 30, 2021
1 parent 73a09a4 commit acc0269
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions hack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@ else
LIBGIT2_DOWNLOAD_URL ?= https://github.com/libgit2/libgit2/archive/$(LIBGIT2_REVISION).tar.gz
endif

OS_FLAGS :=
# Detect Darwin (MacOS) to help the user a bit configuring OpenSSL,
# or at least in pointing out what steps should be taken if it can't
# magically figure it out by itself. Because we too, are nice people.
ifeq ($(shell uname -s),Darwin)
HAS_BREW := $(shell brew --version 2>/dev/null)
ifdef HAS_BREW
HAS_OPENSSL := $(shell brew --prefix openssl@1.1)
ifdef HAS_OPENSSL
OS_FLAGS += "-DOPENSSL_ROOT_DIR=$(HAS_OPENSSL)
else
$(warning "Failed to detect openssl@1.1 installation with brew. It can be installed with 'brew install openssl@1.1',")
$(warning "or an alternative location can be provided using 'FLAGS=-DOPENSSL_ROOT_DIR:PATH=<path> make'.")
endif
HAS_LIBSSH2 := $(shell brew --prefix libssh2)
ifdef HAS_LIBSSH2
OS_FLAGS += "-DLIBSSH2_INCLUDE_DIR:PATH=$(HAS_LIBSSH2)/include"
else
$(warning "Failed to detect libssh2 installation with brew. It can be installed with 'brew install libssh2',"
$(warning "or an alternative location can be provided using 'FLAGS=-DLIBSSH2_INCLUDE_DIR:PATH=<path> make'.")
endif
endif
endif

$(INSTALL_LIBDIR)/libgit2.so.$(LIBGIT2_VERSION):
set -e; \
SETUP_LIBGIT2_TMP_DIR=$$(mktemp -d) \
Expand All @@ -38,6 +62,7 @@ $(INSTALL_LIBDIR)/libgit2.so.$(LIBGIT2_VERSION):
-DREGEX_BACKEND:STRING=builtin \
-DUSE_HTTPS:STRING=$(USE_HTTPS) \
-DUSE_SSH:BOOL=$(USE_SSH) \
$(OS_FLAGS) \
$(FLAGS) \
&& cmake --build $$SETUP_LIBGIT2_TMP_DIR/build --target install \
&& rm -rf $$SETUP_LIBGIT2_TMP_DIR
Expand Down

0 comments on commit acc0269

Please sign in to comment.