13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 23998e2a0SBruce Richardson# Copyright(c) 2010-2014 Intel Corporation 3b82da759SHuawei Xie 40eba4adeSBruce Richardson# binary name 50eba4adeSBruce RichardsonAPP = vhost-switch 60eba4adeSBruce Richardson 70eba4adeSBruce Richardson# all source are stored in SRCS-y 80eba4adeSBruce RichardsonSRCS-y := main.c virtio_net.c 90eba4adeSBruce Richardson 1022119c45SBruce Richardson# Build using pkg-config variables if possible 114131ad5dSBruce Richardsonifeq ($(shell pkg-config --exists libdpdk && echo 0),0) 1222119c45SBruce Richardson 131842d194SBruce Richardsonall: shared 141842d194SBruce Richardson.PHONY: shared static 151842d194SBruce Richardsonshared: build/$(APP)-shared 161842d194SBruce Richardson ln -sf $(APP)-shared build/$(APP) 171842d194SBruce Richardsonstatic: build/$(APP)-static 181842d194SBruce Richardson ln -sf $(APP)-static build/$(APP) 1922119c45SBruce Richardson 201842d194SBruce RichardsonLDFLAGS += -pthread 211842d194SBruce Richardson 22*12a652a0SBruce RichardsonPKGCONF ?= pkg-config 23ca926852SBruce Richardson 24ca926852SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk) 25ca926852SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 26ca926852SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 27ca926852SBruce RichardsonLDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) 281842d194SBruce Richardson 298728ccf3SThomas MonjalonCFLAGS += -DALLOW_EXPERIMENTAL_API 308728ccf3SThomas Monjalon 311842d194SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 321842d194SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 331842d194SBruce Richardson 341842d194SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 351842d194SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 3622119c45SBruce Richardson 3722119c45SBruce Richardsonbuild: 3822119c45SBruce Richardson @mkdir -p $@ 3922119c45SBruce Richardson 4022119c45SBruce Richardson.PHONY: clean 4122119c45SBruce Richardsonclean: 421842d194SBruce Richardson rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 437e9562a1SBruce Richardson test -d build && rmdir -p build || true 4422119c45SBruce Richardson 4522119c45SBruce Richardsonelse # Build using legacy build system 4622119c45SBruce Richardson 47b82da759SHuawei Xieifeq ($(RTE_SDK),) 48b82da759SHuawei Xie$(error "Please define RTE_SDK environment variable") 49b82da759SHuawei Xieendif 50b82da759SHuawei Xie 51e9c65942SBruce Richardson# Default target, detect a build directory, by looking for a path with a .config 52e9c65942SBruce RichardsonRTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config))))) 53b82da759SHuawei Xie 54b82da759SHuawei Xieinclude $(RTE_SDK)/mk/rte.vars.mk 55b82da759SHuawei Xie 56742bde12SBruce Richardsonifneq ($(CONFIG_RTE_EXEC_ENV_LINUX),y) 57218c4e68SBruce Richardson$(info This application can only operate in a linux environment, \ 58b82da759SHuawei Xieplease change the definition of the RTE_TARGET environment variable) 59b82da759SHuawei Xieall: 60b82da759SHuawei Xieelse 61b82da759SHuawei Xie 628728ccf3SThomas MonjalonCFLAGS += -DALLOW_EXPERIMENTAL_API 63b82da759SHuawei XieCFLAGS += -O2 -D_FILE_OFFSET_BITS=64 64b82da759SHuawei XieCFLAGS += $(WERROR_FLAGS) 65b82da759SHuawei Xie 66b82da759SHuawei Xieinclude $(RTE_SDK)/mk/rte.extapp.mk 67b82da759SHuawei Xie 68b82da759SHuawei Xieendif 6922119c45SBruce Richardsonendif 70