Skip to content

Commit 6c07b5a

Browse files
committed
Respect PKG_CONFIG_PATH from the environment
If brew (or some other installation method) has put openssl in a non-traditional place, you need to add that place to `PKG_CONFIG_PATH`; but, the Makefile effectively resets it when calling anything that uses it. So: - include any existing $PKG_CONFIG_PATH in invocations - document when and how to set PKG_CONFIG_PATH Signed-off-by: Michael Bridgen <[email protected]>
1 parent d293394 commit 6c07b5a

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

DEVELOPMENT.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,40 @@ $ brew install cmake [email protected] libssh2 pkg-config
2727
$ LIBGIT2_FORCE=1 make libgit2
2828
```
2929

30+
#### openssl and pkg-config
31+
32+
You may see this message when trying to run a build:
33+
34+
```
35+
# pkg-config --cflags -- libgit2
36+
Package openssl was not found in the pkg-config search path.
37+
Perhaps you should add the directory containing `openssl.pc'
38+
to the PKG_CONFIG_PATH environment variable
39+
Package 'openssl', required by 'libgit2', not found
40+
pkg-config: exit status 1
41+
```
42+
43+
On some macOS systems `brew` will not link the pkg-config file for
44+
openssl into expected directory, because it clashes with a
45+
system-provided openssl. When installing it, or if you do
46+
47+
```console
48+
49+
Warning: Refusing to link macOS provided/shadowed software: [email protected]
50+
If you need to have [email protected] first in your PATH, run:
51+
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.profile
52+
53+
For compilers to find [email protected] you may need to set:
54+
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
55+
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
56+
57+
For pkg-config to find [email protected] you may need to set:
58+
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
59+
```
60+
61+
.. it tells you (in the last part of the message) how to add `openssl`
62+
to your `PKG_CONFIG_PATH` so it can be found.
63+
3064
### Linux
3165

3266
```console

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ ${CACHE}/imagepolicies_${REFLECTOR_VER}.yaml:
8989

9090
test: $(LIBGIT2) test-api test_deps generate fmt vet manifests api-docs ## Run tests
9191
LD_LIBRARY_PATH=$(LIBGIT2_LIB_PATH) \
92-
PKG_CONFIG_PATH=$(LIBGIT2_LIB_PATH)/pkgconfig/ \
92+
PKG_CONFIG_PATH=$(LIBGIT2_LIB_PATH)/pkgconfig/:$(PKG_CONFIG_PATH) \
9393
go test ./... -coverprofile cover.out
9494

9595
test-api: ## Run api tests
9696
cd api; go test ./... -coverprofile cover.out
9797

9898
manager: $(LIBGIT2) generate fmt vet ## Build manager binary
99-
PKG_CONFIG_PATH=$(LIBGIT2_LIB_PATH)/pkgconfig/ \
99+
PKG_CONFIG_PATH=$(LIBGIT2_LIB_PATH)/pkgconfig/:$(PKG_CONFIG_PATH) \
100100
go build -o bin/manager main.go
101101

102102
run: $(LIBGIT2) generate fmt vet manifests # Run against the configured Kubernetes cluster in ~/.kube/config
@@ -133,7 +133,7 @@ fmt: ## Run go fmt against code
133133
cd api; go fmt ./...
134134

135135
vet: $(LIBGIT2) ## Run go vet against code
136-
PKG_CONFIG_PATH=$(LIBGIT2_LIB_PATH)/pkgconfig \
136+
PKG_CONFIG_PATH=$(LIBGIT2_LIB_PATH)/pkgconfig:$(PKG_CONFIG_PATH) \
137137
go vet ./...
138138
cd api; go vet ./...
139139

0 commit comments

Comments
 (0)