BUILD: makefile: refactor support for 51DEGREES v3/v4
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.
diff --git a/Makefile b/Makefile
index bc6f59f..e7e3e1c 100644
--- 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_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 @@
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)
+51DEGREES_VER = 3
-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),)
+ 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
-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
+ 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),)