]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: make all OpenSSL variants use the same settings
authorWilly Tarreau <w@1wt.eu>
Thu, 22 Dec 2022 13:39:54 +0000 (14:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Dec 2022 15:53:35 +0000 (16:53 +0100)
It's getting complicated to configure includes and lib dirs for
OpenSSL API variants such as WolfSSL, because some settings are
common and others are specific but carry a prefix that doesn't
match the USE_* rule scheme.

This patch simplifies everything by considering that all SSL libs
will use SSL_INC, SSL_LIB, SSL_CFLAGS and SSL_LDFLAGS. That's much
more convenient. This works thanks to the settings collector which
explicitly checks the SSL_* settings. When USE_OPENSSL_WOLFSSL is
set, then USE_OPENSSL is implied, so that there's no need to
duplicate maintenance effort.

Makefile
include/make/options.mk

index 802263cbce7678b5f9a2938a81e7dee9ed84d369..a5ddc70d0e11a3d4e27a20683953223d94ff48f9 100644 (file)
--- a/Makefile
+++ b/Makefile
 #                                                               pcre2-config)
 #   SSL_LIB        : force the lib path to libssl/libcrypto
 #   SSL_INC        : force the include path to libssl/libcrypto
-#   WOLFSSL_INC    : force the include path to wolfSSL
-#   WOLFSSL_LIB    : force the lib path to wolfSSL
 #   LUA_LIB        : force the lib path to lua
 #   LUA_INC        : force the include path to lua
 #   LUA_LIB_NAME   : force the lib name (or automatically evaluated, by order of
@@ -558,24 +556,29 @@ ifneq ($(USE_CPU_AFFINITY),)
   OPTIONS_OBJS   += src/cpuset.o
 endif
 
+# OpenSSL is packaged in various forms and with various dependencies.
+# In general -lssl is enough, but on some platforms, -lcrypto may be needed,
+# reason why it's added by default. Some even need -lz, then you'll need to
+# pass it in the "ADDLIB" variable if needed. If your SSL libraries are not
+# in the usual path, use SSL_INC=/path/to/inc and SSL_LIB=/path/to/lib.
+
+# This is for the WolfSSL variant of the OpenSSL API. Setting it implies
+# OPENSSL so it's not necessary to set the latter.
+ifneq ($(USE_OPENSSL_WOLFSSL),)
+  SSL_CFLAGS      := $(if $(SSL_INC),-I$(SSL_INC) -I$(SSL_INC)/wolfssl)
+  SSL_LDFLAGS     := $(if $(SSL_LIB),-L$(SSL_LIB)) -lwolfssl
+  # always automatically set USE_OPENSSL
+  USE_OPENSSL     := $(if $(USE_OPENSSL),$(USE_OPENSSL),implicit)
+endif
+
+# This is for any variant of the OpenSSL API. By default it uses OpenSSL.
 ifneq ($(USE_OPENSSL),)
-  # OpenSSL is packaged in various forms and with various dependencies.
-  # In general -lssl is enough, but on some platforms, -lcrypto may be needed,
-  # reason why it's added by default. Some even need -lz, then you'll need to
-  # pass it in the "ADDLIB" variable if needed. If your SSL libraries are not
-  # in the usual path, use SSL_INC=/path/to/inc and SSL_LIB=/path/to/lib.
+  # only preset these for the regular openssl
   ifeq ($(USE_OPENSSL_WOLFSSL),)
-    OPENSSL_CFLAGS   = $(if $(SSL_INC),-I$(SSL_INC))
-    OPENSSL_LDFLAGS  = $(if $(SSL_LIB),-L$(SSL_LIB)) -lssl -lcrypto
+    SSL_CFLAGS    := $(if $(SSL_INC),-I$(SSL_INC))
+    SSL_LDFLAGS   := $(if $(SSL_LIB),-L$(SSL_LIB)) -lssl -lcrypto
   endif
-  OPTIONS_OBJS  += src/ssl_sock.o src/ssl_ckch.o src/ssl_sample.o src/ssl_crtlist.o src/cfgparse-ssl.o src/ssl_utils.o src/jwt.o src/ssl_ocsp.o
-endif
-
-ifneq ($(USE_OPENSSL_WOLFSSL),)
-  WOLFSSL_CFLAGS    = $(if $(WOLFSSL_INC),-I$(WOLFSSL_INC) -I$(WOLFSSL_INC)/wolfssl)
-  WOLFSSL_LDFLAGS   = $(if $(WOLFSSL_LIB),-L$(WOLFSSL_LIB)) -lwolfssl
-  OPTIONS_CFLAGS   += $(WOLFSSL_CFLAGS)
-  OPTIONS_LDFLAGS  += $(WOLFSSL_LDFLAGS)
+  OPTIONS_OBJS += src/ssl_sock.o src/ssl_ckch.o src/ssl_sample.o src/ssl_crtlist.o src/cfgparse-ssl.o src/ssl_utils.o src/jwt.o src/ssl_ocsp.o
 endif
 
 ifneq ($(USE_ENGINE),)
index 9e96f875cea68587046a66124ad1ea0e33e43a5f..3a58813ce8724912c01a95881b45915f1d3f003c 100644 (file)
@@ -36,7 +36,7 @@ disabled_opts   = $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt
 reset_opt_vars = $(foreach name,INC LIB CFLAGS LDFLAGS SRC,$(eval $(1)_$(name)=))
 
 # preset all variables for all supported build options among use_opts
-reset_opts_vars = $(foreach opt,$(patsubst USE_%,%,$(use_opts)) SSL WOLFSSL,$(call reset_opt_vars,$(opt)))
+reset_opts_vars = $(foreach opt,$(patsubst USE_%,%,$(use_opts)) SSL,$(call reset_opt_vars,$(opt)))
 
 # append $(1)_{C,LD}FLAGS into OPTIONS_{C,LD}FLAGS if not empty
 define collect_opt_flags =