【Intel DPDK】Makefile编写在应用中添加新的程序代码

1、如下SRCS-y := main.c 如果此时有多个文件时如果一个一个写会非常麻烦。

include $(RTE_SDK)/mk/DPDK.vars.mk

# binary name
APP = l2fwd
# all source are stored in SRCS-y
SRCS-y := main.c
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)

include $(RTE_SDK)/mk/DPDK.extapp.mk

2、将上面的Makefile修改为如下内容:

ifeq ($(RTE_SDK),)

$(error "Please define RTE_SDK environment variable")
endif

# Default target, can be overriden by command line or environment
RTE_TARGET ?= x86_64-default-linuxapp-gcc

include $(RTE_SDK)/mk/rte.vars.mk

L2_SRC = $(RTE_SDK)/examples/l2fwd
# binary name
APP = l2fwd

# all source are stored in SRCS-y
#注意此处必须写绝对路径,否则无法获取.c文件。
SRCS-y := $(wildcard $(L2_SRC)/*.c)
##

#此处可修改为不优化-O0 支持gdb调试
CFLAGS += -O0 -ggdb -w
CFLAGS += $(WERROR_FLAGS)

#要链接的库文件名,此库文件为其它依赖代码编译的库文件,存放到lib目录
LDFLAGS += -lrte_other
# this application needs libraries first
DEPDIRS-y += lib

include $(RTE_SDK)/mk/rte.extapp.mk



你可能感兴趣的:(【Intel DPDK】Makefile编写在应用中添加新的程序代码)