13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 23998e2a0SBruce Richardson# Copyright(c) 2010-2014 Intel Corporation 3af75078fSIntel 4af75078fSIntel# binary name 5af75078fSIntelAPP = mp_server 6af75078fSIntel 7af75078fSIntel# all source are stored in SRCS-y 8af75078fSIntelSRCS-y := main.c init.c args.c 9af75078fSIntel 1013abe17cSBruce RichardsonCFLAGS += -I../shared 11af75078fSIntel 12*11e02702SJerin JacobPKGCONF ?= pkg-config 13*11e02702SJerin Jacob 1413abe17cSBruce Richardson# Build using pkg-config variables if possible 15*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) 1613abe17cSBruce Richardson$(error "no installation of DPDK found") 1713abe17cSBruce Richardsonendif 18af75078fSIntel 1913abe17cSBruce Richardsonall: shared 2013abe17cSBruce Richardson.PHONY: shared static 2113abe17cSBruce Richardsonshared: build/$(APP)-shared 2213abe17cSBruce Richardson ln -sf $(APP)-shared build/$(APP) 2313abe17cSBruce Richardsonstatic: build/$(APP)-static 2413abe17cSBruce Richardson ln -sf $(APP)-static build/$(APP) 25af75078fSIntel 2613abe17cSBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 2713abe17cSBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 2813abe17cSBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 2913abe17cSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 3013abe17cSBruce Richardson 315a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 325a196330SBruce Richardson# check for broken pkg-config 335a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 345a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 355a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 365a196330SBruce Richardsonendif 375a196330SBruce Richardsonendif 385a196330SBruce Richardson 39bc8e3247SDavid MarchandCFLAGS += -DALLOW_EXPERIMENTAL_API 40bc8e3247SDavid Marchand 4113abe17cSBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 4213abe17cSBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 4313abe17cSBruce Richardson 4413abe17cSBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 4513abe17cSBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 4613abe17cSBruce Richardson 4713abe17cSBruce Richardsonbuild: 4813abe17cSBruce Richardson @mkdir -p $@ 4913abe17cSBruce Richardson 5013abe17cSBruce Richardson.PHONY: clean 5113abe17cSBruce Richardsonclean: 5213abe17cSBruce Richardson rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 5313abe17cSBruce Richardson test -d build && rmdir -p build || true 54