xref: /dpdk/examples/multi_process/hotplug_mp/Makefile (revision 43f062ac3a926e53993b52a3d4333f2de2c6a706)
105f1d684SQi Zhang# SPDX-License-Identifier: BSD-3-Clause
213abe17cSBruce Richardson# Copyright(c) 2010-2014 Intel Corporation
305f1d684SQi Zhang
405f1d684SQi Zhang# binary name
505f1d684SQi ZhangAPP = hotplug_mp
605f1d684SQi Zhang
705f1d684SQi Zhang# all source are stored in SRCS-y
805f1d684SQi ZhangSRCS-y := main.c commands.c
9*43f062acSBruce RichardsonSRC-DEPS := build/commands.h
1005f1d684SQi Zhang
1111e02702SJerin JacobPKGCONF ?= pkg-config
1211e02702SJerin Jacob
1313abe17cSBruce Richardson# Build using pkg-config variables if possible
1411e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
1513abe17cSBruce Richardson$(error "no installation of DPDK found")
1613abe17cSBruce Richardsonendif
1705f1d684SQi Zhang
1813abe17cSBruce Richardsonall: shared
1913abe17cSBruce Richardson.PHONY: shared static
2013abe17cSBruce Richardsonshared: build/$(APP)-shared
2113abe17cSBruce Richardson	ln -sf $(APP)-shared build/$(APP)
2213abe17cSBruce Richardsonstatic: build/$(APP)-static
2313abe17cSBruce Richardson	ln -sf $(APP)-static build/$(APP)
2413abe17cSBruce Richardson
2513abe17cSBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
26*43f062acSBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) -I build/
2713abe17cSBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
2813abe17cSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
2913abe17cSBruce Richardson
30*43f062acSBruce Richardsonbuild/commands.h: commands.list Makefile
31*43f062acSBruce Richardson	dpdk-cmdline-gen.py -o $@ --context-name=main_ctx $<
32*43f062acSBruce Richardson
335a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static)
345a196330SBruce Richardson# check for broken pkg-config
355a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
365a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
375a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config")
385a196330SBruce Richardsonendif
395a196330SBruce Richardsonendif
405a196330SBruce Richardson
41bc8e3247SDavid MarchandCFLAGS += -DALLOW_EXPERIMENTAL_API
42bc8e3247SDavid Marchand
43*43f062acSBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(SRC-DEPS)
4413abe17cSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
4513abe17cSBruce Richardson
46*43f062acSBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build  $(SRC-DEPS)
4713abe17cSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
4813abe17cSBruce Richardson
4913abe17cSBruce Richardsonbuild:
5013abe17cSBruce Richardson	@mkdir -p $@
5113abe17cSBruce Richardson
5213abe17cSBruce Richardson.PHONY: clean
5313abe17cSBruce Richardsonclean:
54*43f062acSBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared build/*.h
5513abe17cSBruce Richardson	test -d build && rmdir -p build || true
56