cmake: pass linker flags, use devtoolset on centos 7
[vpp.git] / build-data / packages / vpp.mk
1 # Copyright (c) 2015 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 vpp_source = src
15 ifneq ($(vpp_uses_cmake),yes)
16
17 ifeq ($($(PLATFORM)_dpdk_shared_lib),yes)
18 vpp_configure_args = --enable-dpdk-shared
19 else
20 vpp_configure_args =
21 endif
22
23 # Platform dependent configure flags
24 vpp_configure_args += $(vpp_configure_args_$(PLATFORM))
25
26
27 vpp_CPPFLAGS =
28 vpp_LDFLAGS =
29
30 ifneq ($($(PLATFORM)_uses_dpdk),no)
31 ifeq ($($(PLATFORM)_uses_external_dpdk),yes)
32 vpp_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir)
33 vpp_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir)
34 else
35 vpp_configure_depend += dpdk-install
36 vpp_CPPFLAGS += $(call installed_includes_fn, dpdk)/dpdk
37 vpp_LDFLAGS += $(call installed_libs_fn, dpdk)
38 vpp_CPPFLAGS += -I/usr/include/dpdk
39 endif
40 ifeq ($($(PLATFORM)_uses_dpdk_mlx5_pmd),yes)
41 vpp_configure_args += --with-dpdk-mlx5-pmd
42 endif
43 ifeq ($($(PLATFORM)_uses_dpdk_mlx4_pmd),yes)
44 vpp_configure_args += --with-dpdk-mlx4-pmd
45 endif
46 else
47 vpp_configure_args += --disable-dpdk-plugin
48 endif
49
50 ifeq ($($(PLATFORM)_enable_tests),yes)
51 vpp_configure_args += --enable-tests
52 endif
53
54 else
55 ifneq ($(shell which cmake3),)
56 CMAKE?=cmake3
57 else
58 CMAKE?=cmake
59 endif
60
61 vpp_cmake_args ?=
62 vpp_cmake_args += -DCMAKE_INSTALL_PREFIX:PATH=$(PACKAGE_INSTALL_DIR)
63 vpp_cmake_args += -DCMAKE_C_FLAGS="$($(TAG)_TAG_CFLAGS)"
64 vpp_cmake_args += -DCMAKE_LINKER_FLAGS="$($(TAG)_TAG_LDFLAGS)"
65 vpp_cmake_args += -DDPDK_INCLUDE_DIR_HINT="$(PACKAGE_INSTALL_DIR)/../dpdk/include"
66 vpp_cmake_args += -DDPDK_LIB_DIR_HINT="$(PACKAGE_INSTALL_DIR)/../dpdk/lib"
67
68 # Use devtoolset on centos 7
69 ifneq ($(wildcard /opt/rh/devtoolset-7/enable),)
70 vpp_cmake_args += -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin"
71 endif
72
73 vpp_configure_depend += dpdk-install
74 vpp_configure = \
75   cd $(PACKAGE_BUILD_DIR) && \
76   $(CMAKE) -G Ninja $(vpp_cmake_args) $(call find_source_fn,$(PACKAGE_SOURCE))
77 #vpp_make_args = --no-print-directory
78 vpp_build = $(CMAKE) --build $(PACKAGE_BUILD_DIR)
79 vpp_install = $(CMAKE) --build $(PACKAGE_BUILD_DIR) -- install | grep -v 'Set runtime path'
80 endif