1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2010-2020 Intel Corporation 3 4# binary name 5APP = lthread_pthread_shim 6 7# all source are stored in SRCS-y 8SRCS-y := main.c pthread_shim.c 9 10include ../common/common.mk 11 12CFLAGS += -DALLOW_EXPERIMENTAL_API 13CFLAGS += -D_GNU_SOURCE 14LDFLAGS += "-Wl,--copy-dt-needed-entries" 15 16# Build using pkg-config variables if possible 17ifneq ($(shell pkg-config --exists libdpdk && echo 0),0) 18$(error "no installation of DPDK found") 19endif 20 21all: shared 22.PHONY: shared static 23shared: build/$(APP)-shared 24 ln -sf $(APP)-shared build/$(APP) 25static: build/$(APP)-static 26 ln -sf $(APP)-static build/$(APP) 27 28LDFLAGS += -lpthread 29 30PKGCONF ?= pkg-config 31 32PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 33CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 34LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 35LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 36 37build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 38 $(CC) $(CFLAGS) $(filter %.c,$^) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 39 40build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 41 $(CC) $(CFLAGS) $(filter %.c,$^) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 42 43# workaround for a gcc bug with noreturn attribute 44# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 45ifeq ($(shell gcc -dumpversion),-gt 0) 46CFLAGS_main.o += -Wno-return-type 47endif 48 49build: 50 @mkdir -p $@ 51 52.PHONY: clean 53clean: 54 rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 55 test -d build && rmdir -p build || true 56