xref: /dpdk/examples/ethtool/ethtool-app/Makefile (revision fa23714e)
13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
2*fa23714eSBruce 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
10*fa23714eSBruce RichardsonCFLAGS += -I../lib
11*fa23714eSBruce RichardsonLDFLAGS += -L../lib/build
12*fa23714eSBruce RichardsonLDFLAGS_STATIC = -l:librte_ethtool.a
13*fa23714eSBruce RichardsonLDFLAGS_SHARED = -lrte_ethtool
14bda68ab9SRemy Horton
15*fa23714eSBruce Richardson# Build using pkg-config variables if possible
16*fa23714eSBruce Richardsonifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
17*fa23714eSBruce Richardson$(error "no installation of DPDK found")
18939abaf9SMarkos Chandrasendif
19bda68ab9SRemy Horton
20*fa23714eSBruce Richardsonall: shared
21*fa23714eSBruce Richardson.PHONY: shared static
22*fa23714eSBruce Richardsonshared: build/$(APP)-shared
23*fa23714eSBruce Richardson	ln -sf $(APP)-shared build/$(APP)
24*fa23714eSBruce Richardsonstatic: build/$(APP)-static
25*fa23714eSBruce Richardson	ln -sf $(APP)-static build/$(APP)
26*fa23714eSBruce Richardson
27*fa23714eSBruce RichardsonPKGCONF ?= pkg-config
28*fa23714eSBruce Richardson
29*fa23714eSBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
30*fa23714eSBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
31*fa23714eSBruce RichardsonLDFLAGS_SHARED += $(shell $(PKGCONF) --libs libdpdk)
32*fa23714eSBruce RichardsonLDFLAGS_STATIC += $(shell $(PKGCONF) --static --libs libdpdk)
33*fa23714eSBruce Richardson
34*fa23714eSBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
35*fa23714eSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
36*fa23714eSBruce Richardson
37*fa23714eSBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
38*fa23714eSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
39*fa23714eSBruce Richardson
40*fa23714eSBruce Richardsonbuild:
41*fa23714eSBruce Richardson	@mkdir -p $@
42*fa23714eSBruce Richardson
43*fa23714eSBruce Richardson.PHONY: clean
44*fa23714eSBruce Richardsonclean:
45*fa23714eSBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
46*fa23714eSBruce Richardson	test -d build && rmdir -p build || true
47