xref: /dpdk/examples/ipsec-secgw/Makefile (revision ca926852)
13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson# Copyright(c) 2016 Intel Corporation
3d299106eSSergio Gonzalez Monroy
40eba4adeSBruce RichardsonAPP = ipsec-secgw
50eba4adeSBruce Richardson
60eba4adeSBruce Richardson#
70eba4adeSBruce Richardson# all source are stored in SRCS-y
80eba4adeSBruce Richardson#
90eba4adeSBruce RichardsonSRCS-y += parser.c
100eba4adeSBruce RichardsonSRCS-y += ipsec.c
110eba4adeSBruce RichardsonSRCS-y += esp.c
120eba4adeSBruce RichardsonSRCS-y += sp4.c
130eba4adeSBruce RichardsonSRCS-y += sp6.c
140eba4adeSBruce RichardsonSRCS-y += sa.c
150eba4adeSBruce RichardsonSRCS-y += rt.c
163e5f4625SKonstantin AnanyevSRCS-y += ipsec_process.c
170eba4adeSBruce RichardsonSRCS-y += ipsec-secgw.c
180eba4adeSBruce Richardson
1922119c45SBruce RichardsonCFLAGS += -gdwarf-2
2022119c45SBruce Richardson
2122119c45SBruce Richardson# Build using pkg-config variables if possible
2222119c45SBruce Richardson$(shell pkg-config --exists libdpdk)
2322119c45SBruce Richardsonifeq ($(.SHELLSTATUS),0)
2422119c45SBruce Richardson
251842d194SBruce Richardsonall: shared
261842d194SBruce Richardson.PHONY: shared static
271842d194SBruce Richardsonshared: build/$(APP)-shared
281842d194SBruce Richardson	ln -sf $(APP)-shared build/$(APP)
291842d194SBruce Richardsonstatic: build/$(APP)-static
301842d194SBruce Richardson	ln -sf $(APP)-static build/$(APP)
311842d194SBruce Richardson
32*ca926852SBruce RichardsonPKGCONF=pkg-config --define-prefix
33*ca926852SBruce Richardson
34*ca926852SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk)
35*ca926852SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
36*ca926852SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
37*ca926852SBruce RichardsonLDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
3822119c45SBruce Richardson
3922119c45SBruce RichardsonCFLAGS += -DALLOW_EXPERIMENTAL_API
4022119c45SBruce Richardson
411842d194SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
421842d194SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
431842d194SBruce Richardson
441842d194SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
451842d194SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
4622119c45SBruce Richardson
4722119c45SBruce Richardsonbuild:
4822119c45SBruce Richardson	@mkdir -p $@
4922119c45SBruce Richardson
5022119c45SBruce Richardson.PHONY: clean
5122119c45SBruce Richardsonclean:
521842d194SBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
537e9562a1SBruce Richardson	test -d build && rmdir -p build || true
5422119c45SBruce Richardson
5522119c45SBruce Richardsonelse
5622119c45SBruce Richardson
57d299106eSSergio Gonzalez Monroyifeq ($(RTE_SDK),)
58d299106eSSergio Gonzalez Monroy$(error "Please define RTE_SDK environment variable")
59d299106eSSergio Gonzalez Monroyendif
60d299106eSSergio Gonzalez Monroy
61e9c65942SBruce Richardson# Default target, detect a build directory, by looking for a path with a .config
62e9c65942SBruce RichardsonRTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config)))))
63d299106eSSergio Gonzalez Monroy
64d299106eSSergio Gonzalez Monroyinclude $(RTE_SDK)/mk/rte.vars.mk
65d299106eSSergio Gonzalez Monroy
661b028d5eSRadu Nicolauifneq ($(MAKECMDGOALS),clean)
675a032a71SKonstantin Ananyevifneq ($(CONFIG_RTE_LIBRTE_IPSEC),y)
685a032a71SKonstantin Ananyev$(error "RTE_LIBRTE_IPSEC is required to build ipsec-secgw")
691b028d5eSRadu Nicolauendif
701b028d5eSRadu Nicolauendif
711b028d5eSRadu Nicolau
72a6ec3159SNeil HormanCFLAGS += -DALLOW_EXPERIMENTAL_API
73d299106eSSergio Gonzalez MonroyCFLAGS += -O3 -gdwarf-2
74d299106eSSergio Gonzalez MonroyCFLAGS += $(WERROR_FLAGS)
759cd3ddfbSDaniel Mrzyglodifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
769cd3ddfbSDaniel MrzyglodCFLAGS_sa.o += -diag-disable=vec
779cd3ddfbSDaniel Mrzyglodendif
789cd3ddfbSDaniel Mrzyglod
79973d3d82SSergio Gonzalez Monroyifeq ($(DEBUG),1)
80906257e9SSergio Gonzalez MonroyCFLAGS += -DIPSEC_DEBUG -fstack-protector-all -O0
81973d3d82SSergio Gonzalez Monroyendif
82d299106eSSergio Gonzalez Monroy
83d299106eSSergio Gonzalez Monroyinclude $(RTE_SDK)/mk/rte.extapp.mk
8422119c45SBruce Richardson
8522119c45SBruce Richardsonendif
86