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

Message ID 20170814095208.166496-41-bruce.richardson@intel.com (mailing list archive)
State RFC, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Bruce Richardson Aug. 14, 2017, 9:52 a.m. UTC
  Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 examples/helloworld/Makefile | 13 +++++++++++++
 examples/l2fwd/Makefile      | 13 +++++++++++++
 2 files changed, 26 insertions(+)
  

Patch

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