BUILD: improve the makefile's support for libpcre

Currently when cross-compiling, it's generally necessary to force
PCREDIR which the Makefile automatically appends /include and /lib to.
Unfortunately on most 64-bit linux distros, the lib path is instead
/lib64, which is really annoying to fix in the makefile.

So now we're computing PCRE_INC and PCRE_LIB from PCREDIR and using
these ones instead. If one wants to force paths individually, it is
possible to set them instead of setting PCREDIR. The old behaviour
of not passing anything to the compiler when PCREDIR is forced to blank
is conserved.
This commit is contained in:
Willy Tarreau 2013-02-13 12:39:06 +01:00
parent ea3e73b931
commit 39793095d7

View File

@ -64,6 +64,8 @@
# DLMALLOC_SRC : build with dlmalloc, indicate the location of dlmalloc.c. # DLMALLOC_SRC : build with dlmalloc, indicate the location of dlmalloc.c.
# DLMALLOC_THRES : should match PAGE_SIZE on every platform (default: 4096). # DLMALLOC_THRES : should match PAGE_SIZE on every platform (default: 4096).
# PCREDIR : force the path to libpcre. # PCREDIR : force the path to libpcre.
# PCRE_LIB : force the lib path to libpcre (defaults to $PCREDIR/lib).
# PCRE_INC : force the include path to libpcre ($PCREDIR/inc)
# IGNOREGIT : ignore GIT commit versions if set. # IGNOREGIT : ignore GIT commit versions if set.
# VERSION : force haproxy version reporting. # VERSION : force haproxy version reporting.
# SUBVERS : add a sub-version (eg: platform, model, ...). # SUBVERS : add a sub-version (eg: platform, model, ...).
@ -519,30 +521,32 @@ endif
endif endif
endif endif
ifneq ($(USE_PCRE),) ifneq ($(USE_PCRE)$(USE_STATIC_PCRE),)
# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is # PCREDIR is used to automatically construct the PCRE_INC and PCRE_LIB paths,
# automatically detected but can be forced if required. Forcing it to an empty # by appending /include and /lib respectively. If your system does not use the
# string will result in search only in the default paths. # same sub-directories, simply force these variables instead of PCREDIR. It is
ifeq ($(PCREDIR),) # automatically detected but can be forced if required (for cross-compiling).
# Forcing PCREDIR to an empty string will let the compiler use the default
# locations.
PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local) PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
endif ifneq ($(PCREDIR),)
ifeq ($(USE_STATIC_PCRE),) PCRE_INC := $(PCREDIR)/include
OPTIONS_CFLAGS += -DUSE_PCRE $(if $(PCREDIR),-I$(PCREDIR)/include) PCRE_LIB := $(PCREDIR)/lib
OPTIONS_LDFLAGS += $(if $(PCREDIR),-L$(PCREDIR)/lib) -lpcreposix -lpcre
endif
BUILD_OPTIONS += $(call ignore_implicit,USE_PCRE)
endif endif
ifneq ($(USE_STATIC_PCRE),) ifeq ($(USE_STATIC_PCRE),)
# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is # dynamic PCRE
# automatically detected but can be forced if required. OPTIONS_CFLAGS += -DUSE_PCRE $(if $(PCRE_INC),-I$(PCRE_INC))
ifeq ($(PCREDIR),) OPTIONS_LDFLAGS += $(if $(PCRE_LIB),-L$(PCRE_LIB)) -lpcreposix -lpcre
PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local) BUILD_OPTIONS += $(call ignore_implicit,USE_PCRE)
endif else
OPTIONS_CFLAGS += -DUSE_PCRE $(if $(PCREDIR),-I$(PCREDIR)/include) # static PCRE
OPTIONS_LDFLAGS += $(if $(PCREDIR),-L$(PCREDIR)/lib) -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic OPTIONS_CFLAGS += -DUSE_PCRE $(if $(PCRE_INC),-I$(PCRE_INC))
OPTIONS_LDFLAGS += $(if $(PCRE_LIB),-L$(PCRE_LIB)) -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
BUILD_OPTIONS += $(call ignore_implicit,USE_STATIC_PCRE) BUILD_OPTIONS += $(call ignore_implicit,USE_STATIC_PCRE)
endif endif
endif
# This one can be changed to look for ebtree files in an external directory # This one can be changed to look for ebtree files in an external directory
EBTREE_DIR := ebtree EBTREE_DIR := ebtree