xref: /dpdk/examples/ethtool/ethtool-app/Makefile (revision 11e02702)
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
15*11e02702SJerin JacobPKGCONF ?= pkg-config
16*11e02702SJerin Jacob
17fa23714eSBruce Richardson# Build using pkg-config variables if possible
18*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
19fa23714eSBruce Richardson$(error "no installation of DPDK found")
20939abaf9SMarkos Chandrasendif
21bda68ab9SRemy Horton
22fa23714eSBruce Richardsonall: shared
23fa23714eSBruce Richardson.PHONY: shared static
24fa23714eSBruce Richardsonshared: build/$(APP)-shared
25fa23714eSBruce Richardson	ln -sf $(APP)-shared build/$(APP)
26fa23714eSBruce Richardsonstatic: build/$(APP)-static
27fa23714eSBruce Richardson	ln -sf $(APP)-static build/$(APP)
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
345a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static)
355a196330SBruce Richardson# check for broken pkg-config
365a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
375a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
385a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config")
395a196330SBruce Richardsonendif
405a196330SBruce Richardsonendif
415a196330SBruce Richardson
42bc8e3247SDavid MarchandCFLAGS += -DALLOW_EXPERIMENTAL_API
43bc8e3247SDavid Marchand
44fa23714eSBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
45fa23714eSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
46fa23714eSBruce Richardson
47fa23714eSBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
48fa23714eSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
49fa23714eSBruce Richardson
50fa23714eSBruce Richardsonbuild:
51fa23714eSBruce Richardson	@mkdir -p $@
52fa23714eSBruce Richardson
53fa23714eSBruce Richardson.PHONY: clean
54fa23714eSBruce Richardsonclean:
55fa23714eSBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
56fa23714eSBruce Richardson	test -d build && rmdir -p build || true
57