On Fri, 2020-10-23 at 21:07 -0700, Eric Biggers wrote: > On Thu, Oct 22, 2020 at 06:59:33PM +0100, luca.boccassi@xxxxxxxxx wrote: > > From: Luca Boccassi <luca.boccassi@xxxxxxxxxxxxx> > > > > 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@xxxxxxxxxxxxx> > > --- > > Makefile | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/Makefile b/Makefile > > index 3fc1bec..122c0a2 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -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) > > There should be a way to prevent pkg-config from being used if someone wants to > link to a local copy of libcrypto. One might expect setting PKGCONF to an empty > string to work, and it kind of does, but then the shell command executes > "libcrypto", which is strange. How about quoting "$(PKGCONF)" so that the shell > command is guaranteed to fail as expected in that case? > > - Eric Sure, done in v2. -- Kind regards, Luca Boccassi