From 85eb44ac95b6697a416512d74a85eb4ad1bd128a Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Mon, 4 Sep 2023 17:41:52 +0000 Subject: [PATCH] lib(ekmfweb|kmipclient): use `pkg-config` instead of `(curl|xml2)-config` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `pkg-config` is mandatory for compiling s390-tools anyway therefore let's replace `curl-config` and `xml2-config` calls whenever possible. In addition, `pkg-config` has the advantage that cross-compilation is supported. While at it, use `pkg-config` for libcrypto, json-c, and libssl as well. Reviewed-by: Ingo Franzki Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- libekmfweb/Makefile | 8 ++++---- libkmipclient/Makefile | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libekmfweb/Makefile b/libekmfweb/Makefile index 3d32c873..26c87a69 100644 --- a/libekmfweb/Makefile +++ b/libekmfweb/Makefile @@ -55,7 +55,7 @@ check-dep-libekmfweb: detect-openssl-version.dep "detect-openssl-version.dep", \ "openssl-devel version >= 1.1.1", \ "HAVE_OPENSSL=0", \ - -I. -lcrypto -DOPENSSL_SUPPRESS_DEPRECATED) + -I. `$(PKG_CONFIG) --cflags --libs libcrypto` -DOPENSSL_SUPPRESS_DEPRECATED) $(call check_dep, \ "libekmfweb", \ "json-c/json.h", \ @@ -66,7 +66,7 @@ check-dep-libekmfweb: detect-openssl-version.dep "curl/curl.h", \ "libcurl-devel", \ "HAVE_LIBCURL=0" \ - `$(CURL_CONFIG) --cflags` `$(CURL_CONFIG) --libs`) + `$(PKG_CONFIG) --cflags --libs libcurl`) $(CURL_CONFIG) --ssl-backends | grep OpenSSL >/dev/null 2>&1 || { echo "Error: libcurl is not built with the OpenSSL backend"; exit 1; } touch check-dep-libekmfweb @@ -85,8 +85,8 @@ ekmfweb.o: check-dep-libekmfweb ekmfweb.c utilities.h cca.h $(rootdir)include/ek utilities.o: check-dep-libekmfweb utilities.c utilities.h $(rootdir)include/ekmfweb/ekmfweb.h cca.o: check-dep-libekmfweb cca.c cca.h utilities.h $(rootdir)include/ekmfweb/ekmfweb.h -libekmfweb.so.$(VERSION): ALL_CFLAGS += -fPIC `$(CURL_CONFIG) --cflags` -libekmfweb.so.$(VERSION): LDLIBS = -ljson-c -lcrypto -lssl `$(CURL_CONFIG) --libs` -ldl +libekmfweb.so.$(VERSION): ALL_CFLAGS += -fPIC `$(PKG_CONFIG) --cflags json-c libcurl libcrypto libssl` +libekmfweb.so.$(VERSION): LDLIBS = `$(PKG_CONFIG) --libs json-c libcurl libcrypto libssl` -ldl libekmfweb.so.$(VERSION): ALL_LDFLAGS += -shared -Wl,--version-script=libekmfweb.map \ -Wl,-z,defs,-Bsymbolic -Wl,-soname,libekmfweb.so.$(VERM) libekmfweb.so.$(VERSION): ekmfweb.o utilities.o cca.o $(libs) diff --git a/libkmipclient/Makefile b/libkmipclient/Makefile index 7f1b04db..b0175a5d 100644 --- a/libkmipclient/Makefile +++ b/libkmipclient/Makefile @@ -51,7 +51,6 @@ detect-openssl-version.dep: mv $(TMPFILE) $@ CURL_CONFIG ?= curl-config -XML2_CONFIG ?= xml2-config check-dep-libkmipclient: detect-openssl-version.dep $(call check_dep, \ @@ -59,7 +58,7 @@ check-dep-libkmipclient: detect-openssl-version.dep "detect-openssl-version.dep", \ "openssl-devel version >= 1.1.1", \ "HAVE_OPENSSL=0", \ - -I. -lcrypto -DOPENSSL_SUPPRESS_DEPRECATED) + -I. `$(PKG_CONFIG) --cflags --libs libcrypto` -DOPENSSL_SUPPRESS_DEPRECATED) $(call check_dep, \ "libkmipclient", \ "json-c/json.h", \ @@ -70,13 +69,13 @@ check-dep-libkmipclient: detect-openssl-version.dep "libxml/tree.h", \ "libxml2-devel", \ "HAVE_LIBXML2=0", \ - `$(XML2_CONFIG) --cflags` `$(XML2_CONFIG) --libs`) + `$(PKG_CONFIG) --cflags --libs libxml-2.0`) $(call check_dep, \ "libkmipclient", \ "curl/curl.h", \ "libcurl-devel", \ "HAVE_LIBCURL=0" \ - `$(CURL_CONFIG) --cflags` `$(CURL_CONFIG) --libs`) + `$(PKG_CONFIG) --cflags --libs libcurl`) $(CURL_CONFIG) --ssl-backends | grep OpenSSL >/dev/null 2>&1 || { echo "Error: libcurl is not built with the OpenSSL backend"; exit 1; } touch check-dep-libkmipclient @@ -107,8 +106,8 @@ tls.o: check-dep-libkmipclient tls.c kmip.h utils.h $(rootdir)include/kmipclient names.o: check-dep-libkmipclient names.c names.h utils.h $(rootdir)include/kmipclient/kmipclient.h utils.o: check-dep-libkmipclient utils.c names.h utils.h $(rootdir)include/kmipclient/kmipclient.h -libkmipclient.so.$(VERSION): ALL_CFLAGS += -fPIC `$(XML2_CONFIG) --cflags` `$(CURL_CONFIG) --cflags` -libkmipclient.so.$(VERSION): LDLIBS = -ljson-c -lcrypto -lssl `$(XML2_CONFIG) --libs` `$(CURL_CONFIG) --libs` +libkmipclient.so.$(VERSION): ALL_CFLAGS += -fPIC `$(PKG_CONFIG) --cflags json-c libcrypto libssl libxml-2.0 libcurl` +libkmipclient.so.$(VERSION): LDLIBS = `$(PKG_CONFIG) --libs json-c libcrypto libssl libxml-2.0 libcurl` libkmipclient.so.$(VERSION): ALL_LDFLAGS += -shared -Wl,--version-script=libkmipclient.map \ -Wl,-z,defs,-Bsymbolic -Wl,-soname,libkmipclient.so.$(VERM) libkmipclient.so.$(VERSION): kmip.o request.o response.o attribute.o key.o ttlv.o json.o \