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