1b77f6600SCristian Dumitrescu# SPDX-License-Identifier: BSD-3-Clause 2b77f6600SCristian Dumitrescu# Copyright(c) 2020 Intel Corporation 3b77f6600SCristian Dumitrescu 4b77f6600SCristian Dumitrescu# binary name 5b77f6600SCristian DumitrescuAPP = pipeline 6b77f6600SCristian Dumitrescu 7b77f6600SCristian Dumitrescu# all source are stored in SRCS-y 85074e1d5SCristian DumitrescuSRCS-y += cli.c 95f657a7fSCristian DumitrescuSRCS-y += conn.c 10b77f6600SCristian DumitrescuSRCS-y += main.c 11b77f6600SCristian DumitrescuSRCS-y += obj.c 12b77f6600SCristian DumitrescuSRCS-y += thread.c 13b77f6600SCristian Dumitrescu 14*11e02702SJerin JacobPKGCONF ?= pkg-config 15*11e02702SJerin Jacob 16b77f6600SCristian Dumitrescu# Build using pkg-config variables if possible 17*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) 18b77f6600SCristian Dumitrescu$(error "no installation of DPDK found") 19b77f6600SCristian Dumitrescuendif 20b77f6600SCristian Dumitrescu 21b77f6600SCristian Dumitrescuall: shared 22b77f6600SCristian Dumitrescu.PHONY: shared static 23b77f6600SCristian Dumitrescushared: build/$(APP)-shared 24b77f6600SCristian Dumitrescu ln -sf $(APP)-shared build/$(APP) 25b77f6600SCristian Dumitrescustatic: build/$(APP)-static 26b77f6600SCristian Dumitrescu ln -sf $(APP)-static build/$(APP) 27b77f6600SCristian Dumitrescu 28b77f6600SCristian DumitrescuPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 29b77f6600SCristian DumitrescuCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 30b77f6600SCristian DumitrescuLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 31b77f6600SCristian DumitrescuLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 32b77f6600SCristian Dumitrescu 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 41b77f6600SCristian DumitrescuCFLAGS += -I. -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE 42b77f6600SCristian Dumitrescu 43b77f6600SCristian DumitrescuOBJS := $(patsubst %.c,build/%.o,$(SRCS-y)) 44b77f6600SCristian Dumitrescu 45b77f6600SCristian Dumitrescubuild/%.o: %.c Makefile $(PC_FILE) | build 46b77f6600SCristian Dumitrescu $(CC) $(CFLAGS) -c $< -o $@ 47b77f6600SCristian Dumitrescu 48b77f6600SCristian Dumitrescubuild/$(APP)-shared: $(OBJS) 49b77f6600SCristian Dumitrescu $(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 50b77f6600SCristian Dumitrescu 51b77f6600SCristian Dumitrescubuild/$(APP)-static: $(OBJS) 52b77f6600SCristian Dumitrescu $(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 53b77f6600SCristian Dumitrescu 54b77f6600SCristian Dumitrescubuild: 55b77f6600SCristian Dumitrescu @mkdir -p $@ 56b77f6600SCristian Dumitrescu 57b77f6600SCristian Dumitrescu.PHONY: clean 58b77f6600SCristian Dumitrescuclean: 59b77f6600SCristian Dumitrescu rm -f build/$(APP)* build/*.o 60b77f6600SCristian Dumitrescu test -d build && rmdir -p build || true 61