aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2020-10-26 11:15:05 +0000
committerEric Biggers <ebiggers@google.com>2020-10-26 10:18:48 -0700
commita06a9eba5c80983c55499943730e28567888c092 (patch)
treeb2edcdfc48801bc75e29d2e8e11b337dcc68177e
parent3967abf40918991b7e5cc486c7b1d9f1340316a1 (diff)
downloadfsverity-utils-a06a9eba5c80983c55499943730e28567888c092.tar.gz
Use pkg-config to get libcrypto build flags
Especially when cross-compiling or other such cases, it might be necessary to pass additional compiler flags. This is commonly done via pkg-config, so use it if available, and fall back to the hardcoded -lcrypto if not. Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> Link: https://lore.kernel.org/r/20201026111506.3215328-1-luca.boccassi@gmail.com [EB: updated comment at top of file] Signed-off-by: Eric Biggers <ebiggers@google.com>
-rw-r--r--Makefile6
1 files changed, 4 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2a2e067..06dec2f 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@
# Define DESTDIR to override the installation destination directory
# (default: empty string)
#
-# You can also specify custom CC, CFLAGS, CPPFLAGS, and/or LDFLAGS.
+# You can also specify custom CC, CFLAGS, CPPFLAGS, LDFLAGS, and/or PKGCONF.
#
##############################################################################
@@ -58,6 +58,7 @@ BINDIR ?= $(PREFIX)/bin
INCDIR ?= $(PREFIX)/include
LIBDIR ?= $(PREFIX)/lib
DESTDIR ?=
+PKGCONF ?= pkg-config
# Rebuild if a user-specified setting that affects the build changed.
.build-config: FORCE
@@ -69,7 +70,8 @@ DESTDIR ?=
DEFAULT_TARGETS :=
COMMON_HEADERS := $(wildcard common/*.h)
-LDLIBS := -lcrypto
+LDLIBS := $(shell "$(PKGCONF)" libcrypto --libs 2>/dev/null || echo -lcrypto)
+CFLAGS += $(shell "$(PKGCONF)" libcrypto --cflags 2>/dev/null || echo)
# If we are dynamically linking, when running tests we need to override
# LD_LIBRARY_PATH as no RPATH is set