BUILD: makefile: support PCRE[2]_CFLAGS and PCRE[2]_LDFLAGS
The CFLAGS and LDFLAGS appended by USE_PCRE/USE_PCRE2 can now be
overridden using PCRE_CFLAGS/PCRE2_CFLAGS and PCRE_LDFLAGS/PCRE2_LDFLAGS.
Its worth noting that PCRE2_LDFLAGS did already exist and was preset from
the pkgconfig output then complemented with -lpcre2-posix, and only then
the -L and optional -Wl,-Bstatic were appended when adding them to the
resulting global LDFLAGS. A search on the net did not reveal any use of
PCRE2_LDFLAGS in any public build scripts, and for consistency sake it's
important to make sure that we can now finally override the -L settings
like we're able to do with every other build option. Thus the meaning of
this variable changed to include all the related ldflags (-L and -Wl).
These flags are now automatically collected into OPTIONS_*.
diff --git a/Makefile b/Makefile
index c5c15ec..bc6f59f 100644
--- a/Makefile
+++ b/Makefile
@@ -737,14 +737,11 @@
PCRE_LIB := $(PCREDIR)/lib
endif
+ PCRE_CFLAGS := $(if $(PCRE_INC),-I$(PCRE_INC))
ifeq ($(USE_STATIC_PCRE),)
- # dynamic PCRE
- OPTIONS_CFLAGS += $(if $(PCRE_INC),-I$(PCRE_INC))
- OPTIONS_LDFLAGS += $(if $(PCRE_LIB),-L$(PCRE_LIB)) -lpcreposix -lpcre
+ PCRE_LDFLAGS := $(if $(PCRE_LIB),-L$(PCRE_LIB)) -lpcreposix -lpcre
else
- # static PCRE
- OPTIONS_CFLAGS += $(if $(PCRE_INC),-I$(PCRE_INC))
- OPTIONS_LDFLAGS += $(if $(PCRE_LIB),-L$(PCRE_LIB)) -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
+ PCRE_LDFLAGS := $(if $(PCRE_LIB),-L$(PCRE_LIB)) -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
endif
endif # USE_PCRE
@@ -769,6 +766,7 @@
endif
endif
+ PCRE2_CFLAGS := -DPCRE2_CODE_UNIT_WIDTH=$(PCRE2_WIDTH) $(if $(PCRE2_INC), -I$(PCRE2_INC))
PCRE2_LDFLAGS := $(shell $(PCRE2_CONFIG) --libs$(PCRE2_WIDTH) 2>/dev/null || echo -L/usr/local/lib -lpcre2-$(PCRE2_WIDTH))
ifeq ($(PCRE2_LDFLAGS),)
@@ -779,9 +777,6 @@
endif
endif
- OPTIONS_CFLAGS += -DPCRE2_CODE_UNIT_WIDTH=$(PCRE2_WIDTH)
- OPTIONS_CFLAGS += $(if $(PCRE2_INC), -I$(PCRE2_INC))
-
ifneq ($(USE_STATIC_PCRE2),)
PCRE2_LDFLAGS := $(if $(PCRE2_LIB),-L$(PCRE2_LIB)) -Wl,-Bstatic -L$(PCRE2_LIB) $(PCRE2_LDFLAGS) -Wl,-Bdynamic
else