]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: refactor support for 51DEGREES v3/v4
authorWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2022 17:54:36 +0000 (18:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Dec 2022 15:53:35 +0000 (16:53 +0100)
In order to simplify maintenance and long-term evolutions, now the
feature remains enabled by setting USE_51DEGREES=1 and the version
is set in 51DEGREES_VER (3 or 4 are supported only). The default
version remains 3. All 51DEGREES flags are shared between both
versions and only use the "51DEGREES_" prefix.

The related CFLAGS and LDFLAGS can now be overridden using
51DEGREES_CFLAGS and 51DEGREES_LDFLAGS, both of which are automatically
collected into the respective OPTIONS_*. The USE_51DEGREES_V4 option is
now removed, and the doc was updated.

Makefile
doc/51Degrees-device-detection.txt
doc/configuration.txt

index bc6f59f087151fc6140538ec6e11c39d169b3899..e7e3e1c47d15443ec8098e4831260d0af17c965f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,6 @@
 #   USE_PROMEX           : enable the Prometheus exporter
 #   USE_DEVICEATLAS      : enable DeviceAtlas api.
 #   USE_51DEGREES        : enable third party device detection library from 51Degrees
-#   USE_51DEGREES_V4     : enable use of 51Degrees V4 engine with Hash algorithm
 #   USE_WURFL            : enable WURFL detection library from Scientiamobile
 #   USE_SYSTEMD          : enable sd_notify() support.
 #   USE_OBSOLETE_LINKER  : use when the linker fails to emit __start_init/__stop_init
@@ -304,7 +303,7 @@ use_opts = USE_EPOLL USE_KQUEUE USE_NETFILTER                                 \
            USE_GETADDRINFO USE_OPENSSL USE_OPENSSL_WOLFSSL USE_LUA            \
            USE_ACCEPT4 USE_CLOSEFROM USE_ZLIB USE_SLZ USE_CPU_AFFINITY        \
            USE_TFO USE_NS USE_DL USE_RT USE_LIBATOMIC USE_MATH                \
-           USE_DEVICEATLAS USE_51DEGREES USE_51DEGREES_V4                     \
+           USE_DEVICEATLAS USE_51DEGREES                                      \
            USE_WURFL USE_SYSTEMD USE_OBSOLETE_LINKER USE_PRCTL USE_PROCCTL    \
            USE_THREAD_DUMP USE_EVPORTS USE_OT USE_QUIC USE_PROMEX             \
            USE_MEMORY_PROFILING USE_SHM_OPEN
@@ -662,39 +661,43 @@ ifneq ($(USE_DEVICEATLAS),)
 endif
 
 # Use 51DEGREES_SRC and possibly 51DEGREES_INC and 51DEGREES_LIB to force path
-# to 51degrees v3/v4 headers and libraries if needed.
+# to 51degrees v3/v4 headers and libraries if needed. Note that the SRC/INC/
+# LIB/CFLAGS/LDFLAGS variables names all use 51DEGREES as the prefix,
+# regardless of the version since they are mutually exclusive. The version
+# (51DEGREES_VER) must be either 3 or 4, and defaults to 3 if not set.
 51DEGREES_INC = $(51DEGREES_SRC)
 51DEGREES_LIB = $(51DEGREES_SRC)
-
-ifneq ($(USE_51DEGREES_V4),)  # v4 here
-  ifneq ($(USE_51DEGREES),)
-    $(error cannot compile both 51Degrees V3 and V4 engine support)
-  endif
-  _51DEGREES_SRC   = $(shell find $(51DEGREES_LIB) -maxdepth 2 -name '*.c')
-  OPTIONS_OBJS    += $(_51DEGREES_SRC:%.c=%.o)
-  OPTIONS_CFLAGS  += -DUSE_51DEGREES_V4
-  ifeq ($(USE_THREAD),)
-    OPTIONS_CFLAGS  += -DFIFTYONEDEGREES_NO_THREADING -DFIFTYONE_DEGREES_NO_THREADING
-  endif
-  OPTIONS_OBJS    += addons/51degrees/51d.o
-  OPTIONS_CFLAGS  += $(if $(51DEGREES_INC),-I$(51DEGREES_INC))
-  OPTIONS_LDFLAGS += $(if $(51DEGREES_LIB),-L$(51DEGREES_LIB))
-  USE_ATOMIC       = implicit
-  USE_MATH         = implicit
-endif # USE_51DEGREES_V4
-
-ifneq ($(USE_51DEGREES),) # v3 here
-  OPTIONS_OBJS    += $(51DEGREES_LIB)/../cityhash/city.o
-  OPTIONS_OBJS    += $(51DEGREES_LIB)/51Degrees.o
-  ifeq ($(USE_THREAD),)
-    OPTIONS_CFLAGS  += -DFIFTYONEDEGREES_NO_THREADING
+51DEGREES_VER = 3
+
+ifneq ($(USE_51DEGREES),)
+  ifeq ($(51DEGREES_VER),4)  # v4 here
+    _51DEGREES_SRC      = $(shell find $(51DEGREES_LIB) -maxdepth 2 -name '*.c')
+    OPTIONS_OBJS       += $(_51DEGREES_SRC:%.c=%.o)
+    51DEGREES_CFLAGS   += -DUSE_51DEGREES_V4
+    ifeq ($(USE_THREAD),)
+      51DEGREES_CFLAGS += -DFIFTYONEDEGREES_NO_THREADING -DFIFTYONE_DEGREES_NO_THREADING
+    endif
+    USE_ATOMIC          = implicit
+  endif # 51DEGREES_VER==4
+
+  ifeq ($(51DEGREES_VER),3)  # v3 here
+    OPTIONS_OBJS       += $(51DEGREES_LIB)/../cityhash/city.o
+    OPTIONS_OBJS       += $(51DEGREES_LIB)/51Degrees.o
+    ifeq ($(USE_THREAD),)
+      51DEGREES_CFLAGS += -DFIFTYONEDEGREES_NO_THREADING
+    else
+      OPTIONS_OBJS     += $(51DEGREES_LIB)/../threading.o
+    endif
   else
-    OPTIONS_OBJS    += $(51DEGREES_LIB)/../threading.o
-  endif
-  OPTIONS_OBJS    += addons/51degrees/51d.o
-  OPTIONS_CFLAGS  += $(if $(51DEGREES_INC),-I$(51DEGREES_INC))
-  OPTIONS_LDFLAGS += $(if $(51DEGREES_LIB),-L$(51DEGREES_LIB))
-  USE_MATH         = implicit
+    ifneq ($(51DEGREES_VER),4)
+      $(error 51Degrees version (51DEGREES_VER) must be either 3 or 4)
+    endif
+  endif # 51DEGREES_VER==3
+
+  OPTIONS_OBJS        += addons/51degrees/51d.o
+  51DEGREES_CFLAGS    += $(if $(51DEGREES_INC),-I$(51DEGREES_INC))
+  51DEGREES_LDFLAGS   += $(if $(51DEGREES_LIB),-L$(51DEGREES_LIB))
+  USE_MATH             = implicit
 endif # USE_51DEGREES
 
 ifneq ($(USE_WURFL),)
index b3d3421f66e880dccb30bb30f23783d6f1a6c1f2..2fa64e377f1790980a079104b9089f80a38484d6 100644 (file)
@@ -30,11 +30,11 @@ official git repository :
 
       git clone --recurse-submodules https://github.com/51Degrees/device-detection-cxx.git
 
-then run 'make' with USE_51DEGREES or USE_51DEGREES_V4 (if using 51Degrees
-version 4), and 51DEGREES_SRC set. Both 51DEGREES_INC and 51DEGREES_LIB may
-additionally be used to force specific different paths for .o and .h, but
-will default to 51DEGREES_SRC. Make sure to replace '51D_REPO_PATH' with
-the path to the 51Degrees repository.
+then run 'make' with USE_51DEGREES, optionally 51DEGREES_VER=4 (if using
+51Degrees version 4), and 51DEGREES_SRC set. Both 51DEGREES_INC and
+51DEGREES_LIB may additionally be used to force specific different paths for
+.o and .h, but will default to 51DEGREES_SRC. Make sure to replace
+'51D_REPO_PATH' with the path to the 51Degrees repository.
 
 51Degrees provide 4 different detection algorithms:
 
@@ -55,7 +55,7 @@ To use the 51Degrees Trie algorithm use the following command line.
 
 To build with the 51Degrees Device Detection V4 use the following command line.
 
-    $ make TARGET=<target> USE_51DEGREES_V4=1 51DEGREES_SRC='51D_REPO_PATH'/src
+    $ make TARGET=<target> USE_51DEGREES=1 51DEGREES_VER=4 51DEGREES_SRC='51D_REPO_PATH'/src
 
 A data file containing information about devices, browsers, operating systems
 and their associated signatures is then needed. 51Degrees provide a free
@@ -77,7 +77,7 @@ Hash algorithm, build with:
 or
     $ make TARGET=<target> USE_51DEGREES=1 51DEGREES_SRC=addons/51degrees/dummy/trie
 or
-    $ make TARGET=<target> USE_51DEGREES_V4=1 51DEGREES_SRC=addons/51degrees/dummy/v4hash
+    $ make TARGET=<target> USE_51DEGREES=1 51DEGREES_VER=4 51DEGREES_SRC=addons/51degrees/dummy/v4hash
 
 respectively.
 
index f08e58c675bb58a755e6c11bdd6d5f3a9baf82a5..93f78cb8e9ceb8c08596e83ee9148b75a28e4db9 100644 (file)
@@ -1176,7 +1176,7 @@ The following keywords are supported in the "global" section :
   file should be unzipped and accessible by HAProxy with relevant permissions.
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES or USE_51DEGREES_V4.
+  compiled with USE_51DEGREES.
 
 51degrees-property-name-list [<string> ...]
   A list of 51Degrees property names to be load from the dataset. A full list
@@ -1184,14 +1184,14 @@ The following keywords are supported in the "global" section :
   https://51degrees.com/resources/property-dictionary
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES or USE_51DEGREES_V4.
+  compiled with USE_51DEGREES.
 
 51degrees-property-separator <char>
   A char that will be appended to every property value in a response header
   containing 51Degrees results. If not set that will be set as ','.
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES or USE_51DEGREES_V4.
+  compiled with USE_51DEGREES.
 
 51degrees-cache-size <number>
   Sets the size of the 51Degrees converter cache to <number> entries. This
@@ -1199,40 +1199,40 @@ The following keywords are supported in the "global" section :
   By default, this cache is disabled.
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES or USE_51DEGREES_V4.
+  compiled with USE_51DEGREES.
 
 51degrees-use-performance-graph { on | off }
   Enables ('on') or disables ('off') the use of the performance graph in
   the detection process. The default value depends on 51Degrees library.
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES_V4.
+  compiled with USE_51DEGREES and 51DEGREES_VER=4.
 
 51degrees-use-predictive-graph { on | off }
   Enables ('on') or disables ('off') the use of the predictive graph in
   the detection process. The default value depends on 51Degrees library.
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES_V4.
+  compiled with USE_51DEGREES and 51DEGREES_VER=4.
 
 51degrees-drift <number>
   Sets the drift value that a detection can allow.
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES_V4.
+  compiled with USE_51DEGREES and 51DEGREES_VER=4.
 
 51degrees-difference <number>
   Sets the difference value that a detection can allow.
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES_V4.
+  compiled with USE_51DEGREES and 51DEGREES_VER=4.
 
 51degrees-allow-unmatched { on | off }
   Enables ('on') or disables ('off') the use of unmatched nodes in the
   detection process. The default value depends on 51Degrees library.
 
   Please note that this option is only available when HAProxy has been
-  compiled with USE_51DEGREES_V4.
+  compiled with USE_51DEGREES and 51DEGREES_VER=4.
 
 ca-base <dir>
   Assigns a default directory to fetch SSL CA certificates and CRLs from when a