13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 2fa23714eSBruce Richardson# Copyright(c) 2010-2020 Intel Corporation 3bda68ab9SRemy Horton 4bda68ab9SRemy Horton# binary name 5bda68ab9SRemy HortonAPP = ethtool 6bda68ab9SRemy Horton 7bda68ab9SRemy Horton# all source are stored in SRCS-y 8bda68ab9SRemy HortonSRCS-y := main.c ethapp.c 9bda68ab9SRemy Horton 10fa23714eSBruce RichardsonCFLAGS += -I../lib 11fa23714eSBruce RichardsonLDFLAGS += -L../lib/build 12fa23714eSBruce RichardsonLDFLAGS_STATIC = -l:librte_ethtool.a 13fa23714eSBruce RichardsonLDFLAGS_SHARED = -lrte_ethtool 14bda68ab9SRemy Horton 15fa23714eSBruce Richardson# Build using pkg-config variables if possible 16fa23714eSBruce Richardsonifneq ($(shell pkg-config --exists libdpdk && echo 0),0) 17fa23714eSBruce Richardson$(error "no installation of DPDK found") 18939abaf9SMarkos Chandrasendif 19bda68ab9SRemy Horton 20fa23714eSBruce Richardsonall: shared 21fa23714eSBruce Richardson.PHONY: shared static 22fa23714eSBruce Richardsonshared: build/$(APP)-shared 23fa23714eSBruce Richardson ln -sf $(APP)-shared build/$(APP) 24fa23714eSBruce Richardsonstatic: build/$(APP)-static 25fa23714eSBruce Richardson ln -sf $(APP)-static build/$(APP) 26fa23714eSBruce Richardson 27fa23714eSBruce RichardsonPKGCONF ?= pkg-config 28fa23714eSBruce Richardson 29fa23714eSBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 30fa23714eSBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 31fa23714eSBruce RichardsonLDFLAGS_SHARED += $(shell $(PKGCONF) --libs libdpdk) 32fa23714eSBruce RichardsonLDFLAGS_STATIC += $(shell $(PKGCONF) --static --libs libdpdk) 33fa23714eSBruce Richardson 34*bc8e3247SDavid MarchandCFLAGS += -DALLOW_EXPERIMENTAL_API 35*bc8e3247SDavid Marchand 36fa23714eSBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 37fa23714eSBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 38fa23714eSBruce Richardson 39fa23714eSBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 40fa23714eSBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 41fa23714eSBruce Richardson 42fa23714eSBruce Richardsonbuild: 43fa23714eSBruce Richardson @mkdir -p $@ 44fa23714eSBruce Richardson 45fa23714eSBruce Richardson.PHONY: clean 46fa23714eSBruce Richardsonclean: 47fa23714eSBruce Richardson rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 48fa23714eSBruce Richardson test -d build && rmdir -p build || true 49