[dpdk-dev] [RFCv2 40/40] examples: allow basic sample app build using pkg-config

Bruce Richardson bruce.richardson at intel.com
Mon Aug 14 11:52:08 CEST 2017


Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 examples/helloworld/Makefile | 13 +++++++++++++
 examples/l2fwd/Makefile      | 13 +++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile
index c83ec01e8..270f02f91 100644
--- a/examples/helloworld/Makefile
+++ b/examples/helloworld/Makefile
@@ -29,6 +29,17 @@
 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+ifeq ($(shell pkg-config --exists DPDK || echo 1),)
+# we have pkg-config install DPDK
+
+CFLAGS += $(shell pkg-config --cflags DPDK)
+LDFLAGS += $(shell pkg-config --libs DPDK)
+
+helloworld: main.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
+
+else # legacy build system
+
 ifeq ($(RTE_SDK),)
 $(error "Please define RTE_SDK environment variable")
 endif
@@ -48,3 +59,5 @@ CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
 include $(RTE_SDK)/mk/rte.extapp.mk
+
+endif
diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile
index 8896ab452..d631c7d35 100644
--- a/examples/l2fwd/Makefile
+++ b/examples/l2fwd/Makefile
@@ -29,6 +29,17 @@
 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+ifeq ($(shell pkg-config --exists DPDK || echo 1),)
+# we have pkg-config install DPDK
+
+CFLAGS += $(shell pkg-config --cflags DPDK)
+LDFLAGS += $(shell pkg-config --libs DPDK)
+
+l2fwd: main.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
+
+else # legacy build system
+
 ifeq ($(RTE_SDK),)
 $(error "Please define RTE_SDK environment variable")
 endif
@@ -48,3 +59,5 @@ CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
 include $(RTE_SDK)/mk/rte.extapp.mk
+
+endif
-- 
2.13.4



More information about the dev mailing list