1ea9382dcSThomas Monjalon# SPDX-License-Identifier: BSD-3-Clause 2ea9382dcSThomas Monjalon# Copyright 2017 Mellanox Technologies, Ltd 34a3ef59aSOri Kam 40eba4adeSBruce RichardsonAPP = flow 50eba4adeSBruce Richardson 60eba4adeSBruce RichardsonSRCS-y := main.c 70eba4adeSBruce Richardson 8*11e02702SJerin JacobPKGCONF ?= pkg-config 9*11e02702SJerin Jacob 1022119c45SBruce Richardson# Build using pkg-config variables if possible 11*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) 12fda34680SCiara Power$(error "no installation of DPDK found") 13fda34680SCiara Powerendif 1422119c45SBruce Richardson 151842d194SBruce Richardsonall: shared 161842d194SBruce Richardson.PHONY: shared static 171842d194SBruce Richardsonshared: build/$(APP)-shared 181842d194SBruce Richardson ln -sf $(APP)-shared build/$(APP) 191842d194SBruce Richardsonstatic: build/$(APP)-static 201842d194SBruce Richardson ln -sf $(APP)-static build/$(APP) 2122119c45SBruce Richardson 2269b1bb49SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 23ca926852SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 24ca926852SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 258549295dSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 261842d194SBruce Richardson 275a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 285a196330SBruce Richardson# check for broken pkg-config 295a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 305a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 315a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 325a196330SBruce Richardsonendif 335a196330SBruce Richardsonendif 345a196330SBruce Richardson 35bc8e3247SDavid MarchandCFLAGS += -DALLOW_EXPERIMENTAL_API 36bc8e3247SDavid Marchand 371842d194SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 381842d194SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 391842d194SBruce Richardson 401842d194SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 411842d194SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 4222119c45SBruce Richardson 4322119c45SBruce Richardsonbuild: 4422119c45SBruce Richardson @mkdir -p $@ 4522119c45SBruce Richardson 4622119c45SBruce Richardson.PHONY: clean 4722119c45SBruce Richardsonclean: 481842d194SBruce Richardson rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 497e9562a1SBruce Richardson test -d build && rmdir -p build || true 50