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
905f1d684SQi Zhang
1013abe17cSBruce Richardson# Build using pkg-config variables if possible
1113abe17cSBruce Richardsonifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
1213abe17cSBruce Richardson$(error "no installation of DPDK found")
1313abe17cSBruce Richardsonendif
1405f1d684SQi Zhang
1513abe17cSBruce Richardsonall: shared
1613abe17cSBruce Richardson.PHONY: shared static
1713abe17cSBruce Richardsonshared: build/$(APP)-shared
1813abe17cSBruce Richardson	ln -sf $(APP)-shared build/$(APP)
1913abe17cSBruce Richardsonstatic: build/$(APP)-static
2013abe17cSBruce Richardson	ln -sf $(APP)-static build/$(APP)
2113abe17cSBruce Richardson
2213abe17cSBruce RichardsonPKGCONF ?= pkg-config
2313abe17cSBruce Richardson
2413abe17cSBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
2513abe17cSBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
2613abe17cSBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
2713abe17cSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
2813abe17cSBruce Richardson
29*bc8e3247SDavid MarchandCFLAGS += -DALLOW_EXPERIMENTAL_API
30*bc8e3247SDavid Marchand
3113abe17cSBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
3213abe17cSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
3313abe17cSBruce Richardson
3413abe17cSBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
3513abe17cSBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
3613abe17cSBruce Richardson
3713abe17cSBruce Richardsonbuild:
3813abe17cSBruce Richardson	@mkdir -p $@
3913abe17cSBruce Richardson
4013abe17cSBruce Richardson.PHONY: clean
4113abe17cSBruce Richardsonclean:
4213abe17cSBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
4313abe17cSBruce Richardson	test -d build && rmdir -p build || true
44