summaryrefslogtreecommitdiffstats
path: root/build/external/Makefile
blob: 852766f86243c15cec2235d1d14d77a2a1b9fc08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Copyright (c) 2015 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Scripts require non-POSIX parts of bash
SHELL := /bin/bash

DL_CACHE_DIR = $(HOME)/Downloads
MAKE ?= make
MAKE_ARGS ?= -j
BUILD_DIR        ?= $(CURDIR)/_build
INSTALL_DIR      ?= $(CURDIR)/_install
PKG_VERSION ?= $(shell git describe --abbrev=0 | cut -d- -f1 | cut -dv -f2 | cut -d. -f1,2)
PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l)
JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
	$(shell grep -c ^processor /proc/cpuinfo), 2)

B := $(BUILD_DIR)
I := $(INSTALL_DIR)

ifneq ($(shell which cmake3),)
CMAKE?=cmake3
else
CMAKE?=cmake
endif

ARCH_X86_64=$(filter x86_64,$(shell uname -m))

include packages.mk
include packages/nasm.mk
include packages/ipsec-mb.mk
include packages/quicly.mk
include packages/dpdk.mk
include packages/rdma-core.mk
include packages/libbpf.mk

.PHONY: clean
clean:
	@rm -rf $(B) $(I)

.PHONY: install
install: $(if $(ARCH_X86_64), nasm-install ipsec-mb-install) dpdk-install rdma-core-install quicly-install libbpf-install

.PHONY: config
config: $(if $(ARCH_X86_64), nasm-config ipsec-mb-config) dpdk-config rdma-core-config

##############################################################################
# .deb packaging
##############################################################################

DEB_VER := $(PKG_VERSION)
DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)

.PHONY: build-deb install-deb check-deb

deb/debian/changelog: Makefile
	@echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
	@echo "" >> $@
	@echo "  * Version $(DEB_VER)" >> $@
	@echo "" >> $@
	@echo " -- VPP Dev <vpp-dev@lists.fd.io>  $(shell date -R)" >> $@

$(DEV_DEB): deb/debian/changelog
	@cd deb && dpkg-buildpackage -b -uc -us
	git clean -fdx deb

build-deb: $(DEV_DEB)

install-deb:
ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
	@make $(DEV_DEB)
	@sudo dpkg -i $(DEV_DEB)
else
	@echo "=========================================================="
	@echo " Up-to-date vpp-ext-deps package already installed"
	@echo "=========================================================="
endif

check-deb:
ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
	@echo "=========================================================="
	@echo " Out of date vpp-ext-deps package installed."
	@echo " Installed: $(INSTALLED_VER)"
	@echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
	@echo ""
	@echo " Please upgrade by invoking 'make install-ext-deps'"
	@echo " from the top level directory."
	@echo "=========================================================="
endif

##############################################################################
# .rpm packaging
##############################################################################

RPM_VER := $(PKG_VERSION)
RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-ext-deps 2> /dev/null | grep -v "not inst")

.PHONY: build-rpm install-rpm check-rpm

$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
	@rpmbuild -bb \
	  --define "_topdir $(CURDIR)/rpm" \
	  --define "_version $(RPM_VER)" \
	  --define "_release $(PKG_SUFFIX)" \
	  $(CURDIR)/rpm/vpp-ext-deps.spec
	mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
	@git clean -fdx rpm

build-rpm: $(DEV_RPM)

install-rpm:
ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
	@$(MAKE) $(DEV_RPM)
	sudo rpm -e vpp-ext-deps || true
	sudo rpm -Uih --force $(DEV_RPM)
else
	@echo "=========================================================="
	@echo " Up-to-date vpp-ext-deps package already installed"
	@echo "=========================================================="
endif

check-rpm:
ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
	@echo "=========================================================="
	@echo " Out of date vpp-ext-deps package installed."
	@echo " Installed: $(INSTALLED_RPM_VER)"
	@echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
	@echo ""
	@echo " Please upgrade by invoking 'make install-ext-deps'"
	@echo " from the top level directory."
	@echo "=========================================================="
endif

##############################################################################
# ebuild support
##############################################################################

.PHONY: ebuild-build ebuild-install

ebuild-build:
ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
	@echo "=========================================================="
	@echo "Building vpp-ext-deps from source. Consider installing"
	@echo "development package by invoking 'make install-ext-deps'"
	@echo "from the top level directory"
	@echo "=========================================================="
	make config
else
ifneq ($(INSTALLED_VER),)
	make check-deb
endif
ifneq ($(INSTALLED_RPM_VER),)
	make check-rpm
endif
endif

ebuild-install:
ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
	make install
endif
class="o">*args, demo_struct1_t **); demo_struct1_t *demo1; demo_struct2_t *demo2; /* Allocate data structures in process private memory */ demo1 = clib_mem_alloc (sizeof (*demo1)); demo2 = clib_mem_alloc (sizeof (*demo2)); demo1->demo2 = demo2; /* retrieve data from shared memory checkpoint */ unserialize_cstring (sm, (char **) &demo1->name); unserialize_cstring (sm, (char **) &demo2->string1); unserialize_cstring (sm, (char **) &demo2->string2); *result = demo1; } void serialize_demo1 (serialize_main_t * sm, va_list * args) { demo_struct1_t *demo1 = va_arg (*args, demo_struct1_t *); demo_struct2_t *demo2 = demo1->demo2; serialize_cstring (sm, (char *) demo1->name); serialize_cstring (sm, (char *) demo2->string1); serialize_cstring (sm, (char *) demo2->string2); } /* Serialize / unserialize variant */ clib_error_t * persist_serialize (persist_main_t * pm) { u8 *checkpoint; serialize_main_t sm; demo_struct2_t *demo2; demo_struct1_t *demo1; time_t starttime = time (0); char *datestring = ctime (&starttime); /* Get back the root pointer */ checkpoint = svmdb_local_get_vec_variable (pm->c, "demo1_checkpoint", sizeof (u8)); /* It doesnt exist create our data structures */ if (checkpoint == 0) { /* Allocate data structures in process-private memory */ demo1 = clib_mem_alloc (sizeof (*demo2)); vec_validate (demo1, 0); demo2 = clib_mem_alloc (sizeof (*demo2)); demo1->demo2 = demo2; demo1->name = format (0, "My name is Ishmael%c", 0); demo2->string1 = format (0, "Here is string1%c", 0); demo2->string2 = format (0, "Born at %s%c", datestring, 0); /* Create checkpoint */ serialize_open_vector (&sm, checkpoint); serialize (&sm, serialize_demo1, demo1); checkpoint = serialize_close_vector (&sm); /* Copy checkpoint into shared memory */ svmdb_local_set_vec_variable (pm->c, "demo1_checkpoint", checkpoint, sizeof (u8)); /* Toss the process-private-memory original.. */ vec_free (checkpoint); } else { /* Open the checkpoint */ unserialize_open_data (&sm, checkpoint, vec_len (checkpoint)); unserialize (&sm, unserialize_demo1, &demo1); /* Toss the process-private-memory checkpoint copy */ vec_free (checkpoint); /* Off we go... */ demo2 = demo1->demo2; fformat (stdout, "name: %s\n", demo1->name); fformat (stdout, "demo2 location: %llx\n", demo2); fformat (stdout, "string1: %s\n", demo2->string1); fformat (stdout, "string2: %s\n", demo2->string2); } return 0; } int main (int argc, char **argv) { unformat_input_t _input, *input = &_input; persist_main_t *pm = &persist_main; clib_error_t *error = 0; /* Make a 4mb database arena, chroot so it's truly private */ pm->c = svmdb_map_chroot_size ("/ptest", 4 << 20); ASSERT (pm->c); unformat_init_command_line (input, argv); while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "malloc")) error = persist_malloc (pm); else if (unformat (input, "serialize")) error = persist_serialize (pm); else { error = clib_error_return (0, "Unknown flavor '%U'", format_unformat_error, input); break; } } svmdb_unmap (pm->c); if (error) { clib_error_report (error); exit (1); } return 0; } /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */