13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson# Copyright(c) 2010-2014 Intel Corporation
3af75078fSIntel
4af75078fSIntel# binary name
5af75078fSIntelAPP = simple_mp
6af75078fSIntel
7af75078fSIntel# all source are stored in SRCS-y
8af75078fSIntelSRCS-y := main.c mp_commands.c
9af75078fSIntel
10*13abe17cSBruce Richardson# Build using pkg-config variables if possible
11*13abe17cSBruce Richardsonifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
12*13abe17cSBruce Richardson$(error "no installation of DPDK found")
13*13abe17cSBruce Richardsonendif
14af75078fSIntel
15*13abe17cSBruce Richardsonall: shared
16*13abe17cSBruce Richardson.PHONY: shared static
17*13abe17cSBruce Richardsonshared: build/$(APP)-shared
18*13abe17cSBruce Richardson	ln -sf $(APP)-shared build/$(APP)
19*13abe17cSBruce Richardsonstatic: build/$(APP)-static
20*13abe17cSBruce Richardson	ln -sf $(APP)-static build/$(APP)
21*13abe17cSBruce Richardson
22*13abe17cSBruce RichardsonPKGCONF ?= pkg-config
23*13abe17cSBruce Richardson
24*13abe17cSBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
25*13abe17cSBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
26*13abe17cSBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
27*13abe17cSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
28*13abe17cSBruce Richardson
29*13abe17cSBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
30*13abe17cSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
31*13abe17cSBruce Richardson
32*13abe17cSBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
33*13abe17cSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
34*13abe17cSBruce Richardson
35*13abe17cSBruce Richardsonbuild:
36*13abe17cSBruce Richardson	@mkdir -p $@
37*13abe17cSBruce Richardson
38*13abe17cSBruce Richardson.PHONY: clean
39*13abe17cSBruce Richardsonclean:
40*13abe17cSBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
41*13abe17cSBruce Richardson	test -d build && rmdir -p build || true
42