af_xdp: AF_XDP input plugin
[vpp.git] / build / external / packages / libbpf.mk
1 # Copyright (c) 2018 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 LIBBPF_DEBUG?=n
15
16 libbpf_version             := 0.1.0
17 libbpf_tarball             := v$(libbpf_version).tar.gz
18 libbpf_tarball_md5sum_0.1.0 := 00b991a6e2d28d797a56ab1575ed40e1
19 libbpf_tarball_md5sum      := $(libbpf_tarball_md5sum_$(libbpf_version))
20 libbpf_tarball_strip_dirs  := 1
21 libbpf_url                 := https://github.com/libbpf/libbpf/archive/$(libbpf_tarball)
22
23 LIBBPF_CFLAGS:=-g -Werror -Wall -fPIC -fvisibility=hidden
24 ifeq ($(LIBBPF_DEBUG),y)
25   LIBBPF_CFLAGS+= -O0
26 else
27   LIBBPF_CFLAGS+= -O2
28 endif
29
30 IF_XDP:=$(shell echo "\#include <linux/if_xdp.h>" | $(CC) -E -xc - > /dev/null 2>&1)
31 IF_XDP:=$(.SHELLSTATUS)
32
33 define  libbpf_config_cmds
34         @true
35 endef
36
37 define  libbpf_build_cmds__
38         BUILD_STATIC_ONLY=y OBJDIR='$(libbpf_build_dir)' PREFIX='' DESTDIR='$(libbpf_install_dir)' CFLAGS='$(LIBBPF_CFLAGS)' make -C '$(libbpf_src_dir)/src' $(1) > $(2)
39 endef
40
41 define  libbpf_build_cmds
42         $(call libbpf_build_cmds__,,$(libbpf_build_log))
43 endef
44
45 define  libbpf_install_cmds
46         $(call libbpf_build_cmds__,install,$(libbpf_install_log))
47 endef
48
49 ifneq ($(IF_XDP),0)
50   $(warning "linux/if_xdp.h was not found on this system. libbpf will be skipped.")
51 libbpf-install:
52         @true
53 else
54   $(eval $(call package,libbpf))
55 endif