Not all versions of pkg-config in distros have support for the
--define-prefix flag [1], causing errors when building examples manually or
with test-meson-builds.sh script [2].
For the former case, we need to remove the hard-coded use of the flag in
the Makefiles.
For the latter case, the flag is necessary for builds to succeed, so we
skip the tests when it's not present, passing it as part of the pkg-config
command if it is supported.
[1]
CentOS Linux release 7.7.1908 (Core)
pkg-config version 0.27.1
[2]
## Building cmdline
Unknown option --define-prefix
gmake: Entering directory
`...ild-x86-default/install-root/usr/local/share/dpdk/examples/cmdline'
rm -f build/cmdline build/cmdline-static build/cmdline-shared
test -d build && rmdir -p build || true
Unknown option --define-prefix
Unknown option --define-prefix
gcc -O3 main.c commands.c parse_obj_list.c -o build/cmdline-shared
main.c:14:28: fatal error: cmdline_rdline.h: No such file or directory
Fixes:
ca9268529d2b ("examples: support relocated DPDK install")
Fixes:
7f80a2102bbb ("devtools: test pkg-config file")
Cc: stable@dpdk.org
Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
pc_file=$(find $DESTDIR -name libdpdk.pc)
export PKG_CONFIG_PATH=$(dirname $pc_file):$PKG_CONFIG_PATH
-for example in cmdline helloworld l2fwd l3fwd skeleton timer; do
- echo "## Building $example"
- $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean all
-done
+# if pkg-config defines the necessary flags, test building some examples
+if pkg-config --define-prefix libdpdk >/dev/null 2>&1; then
+ export PKGCONF="pkg-config --define-prefix"
+ for example in cmdline helloworld l2fwd l3fwd skeleton timer; do
+ echo "## Building $example"
+ $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean all
+ done
+fi
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
LDFLAGS += -lrte_pmd_bond
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
-LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
-LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+PKGCONF ?= pkg-config
+
+PC_FILE := $(shell $(PKGCONF) --path libdpdk)
+CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
LDFLAGS += -pthread -lrt
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
+PKGCONF ?= pkg-config
+
CFLAGS += -D_FILE_OFFSET_BITS=64
LDFLAGS += -pthread
-PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
-LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
-LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+PC_FILE := $(shell $(PKGCONF) --path libdpdk)
+CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
LDFLAGS += -pthread
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
LDFLAGS += -pthread
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
+PKGCONF ?= pkg-config
+
LDFLAGS += -pthread
-PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
-LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
-LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+PC_FILE := $(shell $(PKGCONF) --path libdpdk)
+CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
CFLAGS += -DALLOW_EXPERIMENTAL_API
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
-PKGCONF=pkg-config --define-prefix
+PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)