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