[dpdk-dev] [PATCH 6/6] examples: enable linking examples both static and shared

Bruce Richardson bruce.richardson at intel.com
Tue Dec 12 17:59:40 CET 2017


Since the DPDK build now includes both static and shared libraries, we need
a new way to enable building the examples using either method from the one
installation. To do this, we add in a default "shared" target, and a
separate "static" target which links in the DPDK static libraries. In both
cases, the final application name is symlinked to the last-built static or
shared target, with both binaries able to co-exist in the build directory.

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 examples/bond/Makefile                     | 21 ++++++++++++++++-----
 examples/cmdline/Makefile                  | 21 ++++++++++++++++-----
 examples/distributor/Makefile              | 21 ++++++++++++++++-----
 examples/eventdev_pipeline_sw_pmd/Makefile | 21 ++++++++++++++++-----
 examples/exception_path/Makefile           | 21 ++++++++++++++++-----
 examples/flow_classify/Makefile            | 21 ++++++++++++++++-----
 examples/flow_filtering/Makefile           | 21 ++++++++++++++++-----
 examples/helloworld/Makefile               | 21 ++++++++++++++++-----
 examples/ip_fragmentation/Makefile         | 21 ++++++++++++++++-----
 examples/ip_pipeline/Makefile              | 21 ++++++++++++++++-----
 examples/ip_reassembly/Makefile            | 21 ++++++++++++++++-----
 examples/ipsec-secgw/Makefile              | 21 ++++++++++++++++-----
 examples/ipv4_multicast/Makefile           | 21 ++++++++++++++++-----
 examples/kni/Makefile                      | 21 ++++++++++++++++-----
 examples/l2fwd-cat/Makefile                | 21 ++++++++++++++++-----
 examples/l2fwd-crypto/Makefile             | 21 ++++++++++++++++-----
 examples/l2fwd-jobstats/Makefile           | 21 ++++++++++++++++-----
 examples/l2fwd-keepalive/Makefile          | 21 ++++++++++++++++-----
 examples/l2fwd/Makefile                    | 21 ++++++++++++++++-----
 examples/l3fwd-acl/Makefile                | 21 ++++++++++++++++-----
 examples/l3fwd-power/Makefile              | 21 ++++++++++++++++-----
 examples/l3fwd-vf/Makefile                 | 21 ++++++++++++++++-----
 examples/l3fwd/Makefile                    | 21 ++++++++++++++++-----
 examples/link_status_interrupt/Makefile    | 21 ++++++++++++++++-----
 examples/load_balancer/Makefile            | 21 ++++++++++++++++-----
 examples/packet_ordering/Makefile          | 21 ++++++++++++++++-----
 examples/ptpclient/Makefile                | 21 ++++++++++++++++-----
 examples/qos_meter/Makefile                | 21 ++++++++++++++++-----
 examples/qos_sched/Makefile                | 21 ++++++++++++++++-----
 examples/rxtx_callbacks/Makefile           | 21 ++++++++++++++++-----
 examples/service_cores/Makefile            | 21 ++++++++++++++++-----
 examples/skeleton/Makefile                 | 21 ++++++++++++++++-----
 examples/tep_termination/Makefile          | 21 ++++++++++++++++-----
 examples/timer/Makefile                    | 21 ++++++++++++++++-----
 examples/vhost/Makefile                    | 21 ++++++++++++++++-----
 examples/vhost_scsi/Makefile               | 21 ++++++++++++++++-----
 examples/vmdq/Makefile                     | 21 ++++++++++++++++-----
 examples/vmdq_dcb/Makefile                 | 21 ++++++++++++++++-----
 38 files changed, 608 insertions(+), 190 deletions(-)

diff --git a/examples/bond/Makefile b/examples/bond/Makefile
index 47e9adc77..6dc4d8279 100644
--- a/examples/bond/Makefile
+++ b/examples/bond/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/cmdline/Makefile b/examples/cmdline/Makefile
index a9b61c508..8c2edabfe 100644
--- a/examples/cmdline/Makefile
+++ b/examples/cmdline/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c commands.c parse_obj_list.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/distributor/Makefile b/examples/distributor/Makefile
index 96b250407..aa82e564e 100644
--- a/examples/distributor/Makefile
+++ b/examples/distributor/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/eventdev_pipeline_sw_pmd/Makefile b/examples/eventdev_pipeline_sw_pmd/Makefile
index 18fd35a55..9a8ac64f9 100644
--- a/examples/eventdev_pipeline_sw_pmd/Makefile
+++ b/examples/eventdev_pipeline_sw_pmd/Makefile
@@ -38,19 +38,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/exception_path/Makefile b/examples/exception_path/Makefile
index 60bcf63fa..c0af595cc 100644
--- a/examples/exception_path/Makefile
+++ b/examples/exception_path/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/flow_classify/Makefile b/examples/flow_classify/Makefile
index 4a08165ae..da9ad8034 100644
--- a/examples/flow_classify/Makefile
+++ b/examples/flow_classify/Makefile
@@ -39,19 +39,30 @@ SRCS-y := flow_classify.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/flow_filtering/Makefile b/examples/flow_filtering/Makefile
index ba15651ab..01bb4cd81 100644
--- a/examples/flow_filtering/Makefile
+++ b/examples/flow_filtering/Makefile
@@ -38,19 +38,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile
index e5378f118..4b5be6056 100644
--- a/examples/helloworld/Makefile
+++ b/examples/helloworld/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/ip_fragmentation/Makefile b/examples/ip_fragmentation/Makefile
index b879ed694..6c183be5e 100644
--- a/examples/ip_fragmentation/Makefile
+++ b/examples/ip_fragmentation/Makefile
@@ -40,19 +40,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 0d36ff223..a69d18bd4 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -62,9 +62,17 @@ SRCS-y += pipeline_routing.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
 
 VPATH += pipeline
 CFLAGS += -I. -I./pipeline/
@@ -74,15 +82,18 @@ OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
 build/%.o: %.c Makefile $(PC_FILE) | build
 	$(CC) $(CFLAGS) -c $< -o $@
 
-build/$(APP): $(OBJS)
-	$(CC) $(OBJS) -o $@ $(LDFLAGS)
+build/$(APP)-shared: $(OBJS)
+	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
+
+build/$(APP)-static: $(OBJS)
+	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP) build/*.o
+	rm -f build/$(APP)* build/*.o
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/ip_reassembly/Makefile b/examples/ip_reassembly/Makefile
index f20f89744..650bede8c 100644
--- a/examples/ip_reassembly/Makefile
+++ b/examples/ip_reassembly/Makefile
@@ -40,19 +40,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/ipsec-secgw/Makefile b/examples/ipsec-secgw/Makefile
index a299e45ce..e0e93e2ec 100644
--- a/examples/ipsec-secgw/Makefile
+++ b/examples/ipsec-secgw/Makefile
@@ -49,19 +49,30 @@ CFLAGS += -gdwarf-2
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/ipv4_multicast/Makefile b/examples/ipv4_multicast/Makefile
index 5278c15ef..e33c7fc2f 100644
--- a/examples/ipv4_multicast/Makefile
+++ b/examples/ipv4_multicast/Makefile
@@ -40,19 +40,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/kni/Makefile b/examples/kni/Makefile
index 63d57472c..fc6b89bf6 100644
--- a/examples/kni/Makefile
+++ b/examples/kni/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile
index 308a4e078..6182dbde0 100644
--- a/examples/l2fwd-cat/Makefile
+++ b/examples/l2fwd-cat/Makefile
@@ -39,22 +39,33 @@ SRCS-y := l2fwd-cat.c cat.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
 
 CFLAGS += -D_GNU_SOURCE
 LDFLAGS += -lpqos
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
+
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l2fwd-crypto/Makefile b/examples/l2fwd-crypto/Makefile
index afa32b010..bc9f65987 100644
--- a/examples/l2fwd-crypto/Makefile
+++ b/examples/l2fwd-crypto/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l2fwd-jobstats/Makefile b/examples/l2fwd-jobstats/Makefile
index 315daf691..779d3c652 100644
--- a/examples/l2fwd-jobstats/Makefile
+++ b/examples/l2fwd-jobstats/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l2fwd-keepalive/Makefile b/examples/l2fwd-keepalive/Makefile
index a4daeeb04..b5dbf41c1 100644
--- a/examples/l2fwd-keepalive/Makefile
+++ b/examples/l2fwd-keepalive/Makefile
@@ -40,19 +40,30 @@ LDFLAGS += -lrt
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile
index 55a67d636..3cc347830 100644
--- a/examples/l2fwd/Makefile
+++ b/examples/l2fwd/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l3fwd-acl/Makefile b/examples/l3fwd-acl/Makefile
index afd7421ff..78f6df7e5 100644
--- a/examples/l3fwd-acl/Makefile
+++ b/examples/l3fwd-acl/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l3fwd-power/Makefile b/examples/l3fwd-power/Makefile
index c17e66db3..c0cddcb5c 100644
--- a/examples/l3fwd-power/Makefile
+++ b/examples/l3fwd-power/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l3fwd-vf/Makefile b/examples/l3fwd-vf/Makefile
index f3b324db0..d7aae9e10 100644
--- a/examples/l3fwd-vf/Makefile
+++ b/examples/l3fwd-vf/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile
index 41abfe7f6..a1f505ac4 100644
--- a/examples/l3fwd/Makefile
+++ b/examples/l3fwd/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/link_status_interrupt/Makefile b/examples/link_status_interrupt/Makefile
index 0e36eac0c..8ed14f120 100644
--- a/examples/link_status_interrupt/Makefile
+++ b/examples/link_status_interrupt/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/load_balancer/Makefile b/examples/load_balancer/Makefile
index 458e712de..d767b4302 100644
--- a/examples/load_balancer/Makefile
+++ b/examples/load_balancer/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c config.c init.c runtime.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/packet_ordering/Makefile b/examples/packet_ordering/Makefile
index a9b4eb016..78e26fad0 100644
--- a/examples/packet_ordering/Makefile
+++ b/examples/packet_ordering/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/ptpclient/Makefile b/examples/ptpclient/Makefile
index 7ed57d9fc..bf5d2991e 100644
--- a/examples/ptpclient/Makefile
+++ b/examples/ptpclient/Makefile
@@ -39,19 +39,30 @@ SRCS-y := ptpclient.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/qos_meter/Makefile b/examples/qos_meter/Makefile
index 34879e105..01c7804ca 100644
--- a/examples/qos_meter/Makefile
+++ b/examples/qos_meter/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c rte_policer.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/qos_sched/Makefile b/examples/qos_sched/Makefile
index f33c5b61d..f082e06fd 100644
--- a/examples/qos_sched/Makefile
+++ b/examples/qos_sched/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c args.c init.c app_thread.c cfg_file.c cmdline.c stats.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/rxtx_callbacks/Makefile b/examples/rxtx_callbacks/Makefile
index 40989fdd5..88f17f63f 100644
--- a/examples/rxtx_callbacks/Makefile
+++ b/examples/rxtx_callbacks/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/service_cores/Makefile b/examples/service_cores/Makefile
index aada19497..09cbc49ed 100644
--- a/examples/service_cores/Makefile
+++ b/examples/service_cores/Makefile
@@ -38,19 +38,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else
diff --git a/examples/skeleton/Makefile b/examples/skeleton/Makefile
index ff13e7888..e8a621b07 100644
--- a/examples/skeleton/Makefile
+++ b/examples/skeleton/Makefile
@@ -39,19 +39,30 @@ SRCS-y := basicfwd.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/tep_termination/Makefile b/examples/tep_termination/Makefile
index 52149a4b0..0354733fe 100644
--- a/examples/tep_termination/Makefile
+++ b/examples/tep_termination/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c vxlan_setup.c vxlan.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/timer/Makefile b/examples/timer/Makefile
index dc1fb74ce..716a2780e 100644
--- a/examples/timer/Makefile
+++ b/examples/timer/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index de0c8d872..562e56e19 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c virtio_net.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/vhost_scsi/Makefile b/examples/vhost_scsi/Makefile
index 29b654da6..593ca8962 100644
--- a/examples/vhost_scsi/Makefile
+++ b/examples/vhost_scsi/Makefile
@@ -41,19 +41,30 @@ CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/vmdq/Makefile b/examples/vmdq/Makefile
index bd2aae34c..0a0eae714 100644
--- a/examples/vmdq/Makefile
+++ b/examples/vmdq/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
diff --git a/examples/vmdq_dcb/Makefile b/examples/vmdq_dcb/Makefile
index d75498c45..1cd2ec1ea 100644
--- a/examples/vmdq_dcb/Makefile
+++ b/examples/vmdq_dcb/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
 
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+	ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+	ln -sf $(APP)-static build/$(APP)
+
 PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs 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)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
-	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
 
 build:
 	@mkdir -p $@
 
 .PHONY: clean
 clean:
-	rm -f build/$(APP)
+	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
 	rmdir --ignore-fail-on-non-empty build
 
 else # Build using legacy build system
-- 
2.14.3



More information about the dev mailing list