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 1122119c45SBruce Richardson$(shell pkg-config --exists libdpdk) 1222119c45SBruce Richardsonifeq ($(.SHELLSTATUS),0) 1322119c45SBruce Richardson 141842d194SBruce Richardsonall: shared 151842d194SBruce Richardson.PHONY: shared static 161842d194SBruce Richardsonshared: build/$(APP)-shared 171842d194SBruce Richardson ln -sf $(APP)-shared build/$(APP) 181842d194SBruce Richardsonstatic: build/$(APP)-static 191842d194SBruce Richardson ln -sf $(APP)-static build/$(APP) 2022119c45SBruce Richardson 211842d194SBruce RichardsonLDFLAGS += -pthread 221842d194SBruce Richardson 231842d194SBruce RichardsonPC_FILE := $(shell pkg-config --path libdpdk) 241842d194SBruce RichardsonCFLAGS += -O3 $(shell pkg-config --cflags libdpdk) 251842d194SBruce RichardsonLDFLAGS_SHARED = $(shell pkg-config --libs libdpdk) 261842d194SBruce RichardsonLDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk) 271842d194SBruce Richardson 288728ccf3SThomas MonjalonCFLAGS += -DALLOW_EXPERIMENTAL_API 298728ccf3SThomas Monjalon 301842d194SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 311842d194SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 321842d194SBruce Richardson 331842d194SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 341842d194SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 3522119c45SBruce Richardson 3622119c45SBruce Richardsonbuild: 3722119c45SBruce Richardson @mkdir -p $@ 3822119c45SBruce Richardson 3922119c45SBruce Richardson.PHONY: clean 4022119c45SBruce Richardsonclean: 411842d194SBruce Richardson rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 4222119c45SBruce Richardson rmdir --ignore-fail-on-non-empty build 4322119c45SBruce Richardson 4422119c45SBruce Richardsonelse # Build using legacy build system 4522119c45SBruce Richardson 46b82da759SHuawei Xieifeq ($(RTE_SDK),) 47b82da759SHuawei Xie$(error "Please define RTE_SDK environment variable") 48b82da759SHuawei Xieendif 49b82da759SHuawei Xie 5098a7ea33SJerin Jacob# Default target, can be overridden by command line or environment 51*218c4e68SBruce RichardsonRTE_TARGET ?= x86_64-native-linux-gcc 52b82da759SHuawei Xie 53b82da759SHuawei Xieinclude $(RTE_SDK)/mk/rte.vars.mk 54b82da759SHuawei Xie 55742bde12SBruce Richardsonifneq ($(CONFIG_RTE_EXEC_ENV_LINUX),y) 56*218c4e68SBruce Richardson$(info This application can only operate in a linux environment, \ 57b82da759SHuawei Xieplease change the definition of the RTE_TARGET environment variable) 58b82da759SHuawei Xieall: 59b82da759SHuawei Xieelse 60b82da759SHuawei Xie 618728ccf3SThomas MonjalonCFLAGS += -DALLOW_EXPERIMENTAL_API 62b82da759SHuawei XieCFLAGS += -O2 -D_FILE_OFFSET_BITS=64 63b82da759SHuawei XieCFLAGS += $(WERROR_FLAGS) 64b82da759SHuawei Xie 65b82da759SHuawei Xieinclude $(RTE_SDK)/mk/rte.extapp.mk 66b82da759SHuawei Xie 67b82da759SHuawei Xieendif 6822119c45SBruce Richardsonendif 69