13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 2fa23714eSBruce Richardson# Copyright(c) 2015-2020 Intel Corporation 3bda68ab9SRemy Horton 4fa23714eSBruce Richardson 5*11e02702SJerin JacobPKGCONF ?= pkg-config 6*11e02702SJerin Jacob 7*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) 8fa23714eSBruce Richardson$(error "no installation of DPDK found") 9fa23714eSBruce Richardsonendif 10fa23714eSBruce Richardsonifneq ($(shell uname),Linux) 11fa23714eSBruce Richardson$(error This application can only operate in a linux environment) 12bda68ab9SRemy Hortonendif 13bda68ab9SRemy Horton 14bda68ab9SRemy Horton# library name 15fa23714eSBruce RichardsonLIB = librte_ethtool.so 16fa23714eSBruce RichardsonLIB_STATIC = librte_ethtool.a 17fa23714eSBruce RichardsonSRCS = rte_ethtool.c 18bda68ab9SRemy Horton 19bda68ab9SRemy HortonCFLAGS += -O3 20fa23714eSBruce RichardsonCFLAGS += -fPIC 2199d8ebcfSZijie PanCFLAGS += -DALLOW_EXPERIMENTAL_API 22bda68ab9SRemy Horton 23fa23714eSBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 24fa23714eSBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 25fa23714eSBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 26fa23714eSBruce RichardsonLDFLAGS += -Wl,--no-undefined $(LDFLAGS_SHARED) 27077d223eSBernard Iremonger 28fa23714eSBruce Richardson# check for ixgbe by grepping pre-processor output 29fa23714eSBruce Richardsonifneq ($(shell $(CC) $(CFLAGS) -dM -E - < /dev/null | grep IXGBE),) 307157a9dcSBruce RichardsonLDFLAGS += -lrte_net_ixgbe 31fa23714eSBruce Richardsonendif 32fa23714eSBruce Richardson 33fa23714eSBruce Richardson.PHONY: all clean static shared 34fa23714eSBruce Richardsonall shared: build/$(LIB) 35fa23714eSBruce Richardsonstatic: build/$(LIB_STATIC) 36fa23714eSBruce Richardson 37fa23714eSBruce Richardsonclean: 38fa23714eSBruce Richardson rm -f build/$(LIB) 39fa23714eSBruce Richardson test -d build && rmdir -p build || true 40fa23714eSBruce Richardson 41fa23714eSBruce Richardsonbuild: 42fa23714eSBruce Richardson @mkdir -p $@ 43fa23714eSBruce Richardson 44fa23714eSBruce Richardsonbuild/%.so: $(SRCS) Makefile $(PC_FILE) | build 45fa23714eSBruce Richardson $(CC) $(CFLAGS) -o $@ -shared $(SRCS) $(LDFLAGS) 46fa23714eSBruce Richardson 47fa23714eSBruce Richardsonbuild/%.a: $(SRCS) Makefile $(PC_FILE) | build 48fa23714eSBruce Richardson $(CC) $(CFLAGS) -c $(SRCS) -o build/$(SRCS).o 49fa23714eSBruce Richardson $(AR) -cr $@ build/*.o 50