xref: /dpdk/examples/ip_pipeline/Makefile (revision 11e02702)
13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
2fbc74e66SJasvinder Singh# Copyright(c) 2010-2018 Intel Corporation
377a33467SCristian Dumitrescu
40eba4adeSBruce Richardson# binary name
50eba4adeSBruce RichardsonAPP = ip_pipeline
60eba4adeSBruce Richardson
70eba4adeSBruce Richardson# all source are stored in SRCS-y
871937434SJasvinder SinghSRCS-y := action.c
971937434SJasvinder SinghSRCS-y += cli.c
104bbf8e30SJasvinder SinghSRCS-y += conn.c
119a408cc8SJasvinder SinghSRCS-y += kni.c
12133c2c65SJasvinder SinghSRCS-y += link.c
134bbf8e30SJasvinder SinghSRCS-y += main.c
146bfe74f8SJasvinder SinghSRCS-y += mempool.c
150eba4adeSBruce RichardsonSRCS-y += parser.c
16d75c371eSJasvinder SinghSRCS-y += pipeline.c
178245472cSJasvinder SinghSRCS-y += swq.c
182f74ae28SJasvinder SinghSRCS-y += tap.c
19c0b668e0SJasvinder SinghSRCS-y += thread.c
2025961ff3SJasvinder SinghSRCS-y += tmgr.c
21bd9b67a1SFan ZhangSRCS-y += cryptodev.c
220eba4adeSBruce Richardson
23*11e02702SJerin JacobPKGCONF ?= pkg-config
24*11e02702SJerin Jacob
2522119c45SBruce Richardson# Build using pkg-config variables if possible
26*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
27fda34680SCiara Power$(error "no installation of DPDK found")
28fda34680SCiara Powerendif
2922119c45SBruce Richardson
301842d194SBruce Richardsonall: shared
311842d194SBruce Richardson.PHONY: shared static
321842d194SBruce Richardsonshared: build/$(APP)-shared
331842d194SBruce Richardson	ln -sf $(APP)-shared build/$(APP)
341842d194SBruce Richardsonstatic: build/$(APP)-static
351842d194SBruce Richardson	ln -sf $(APP)-static build/$(APP)
361842d194SBruce Richardson
3769b1bb49SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
38ca926852SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
39ca926852SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
408549295dSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
4122119c45SBruce Richardson
425a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static)
435a196330SBruce Richardson# check for broken pkg-config
445a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
455a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
465a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config")
475a196330SBruce Richardsonendif
485a196330SBruce Richardsonendif
495a196330SBruce Richardson
50570e6810SCristian DumitrescuCFLAGS += -I. -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE
5122119c45SBruce Richardson
5222119c45SBruce RichardsonOBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
5322119c45SBruce Richardson
5422119c45SBruce Richardsonbuild/%.o: %.c Makefile $(PC_FILE) | build
5522119c45SBruce Richardson	$(CC) $(CFLAGS) -c $< -o $@
5622119c45SBruce Richardson
571842d194SBruce Richardsonbuild/$(APP)-shared: $(OBJS)
581842d194SBruce Richardson	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
591842d194SBruce Richardson
601842d194SBruce Richardsonbuild/$(APP)-static: $(OBJS)
611842d194SBruce Richardson	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
6222119c45SBruce Richardson
6322119c45SBruce Richardsonbuild:
6422119c45SBruce Richardson	@mkdir -p $@
6522119c45SBruce Richardson
6622119c45SBruce Richardson.PHONY: clean
6722119c45SBruce Richardsonclean:
681842d194SBruce Richardson	rm -f build/$(APP)* build/*.o
697e9562a1SBruce Richardson	test -d build && rmdir -p build || true
70