blob: aa72832afe155056db0f9a2781a664c2f4a96966 [file] [log] [blame]
Benoît Ganne4a76d6f2020-06-12 08:47:34 +02001# 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
14LIBBPF_DEBUG?=n
15
16libbpf_version := 0.1.0
17libbpf_tarball := v$(libbpf_version).tar.gz
18libbpf_tarball_md5sum_0.1.0 := 00b991a6e2d28d797a56ab1575ed40e1
19libbpf_tarball_md5sum := $(libbpf_tarball_md5sum_$(libbpf_version))
20libbpf_tarball_strip_dirs := 1
21libbpf_url := https://github.com/libbpf/libbpf/archive/$(libbpf_tarball)
22
23LIBBPF_CFLAGS:=-g -Werror -Wall -fPIC -fvisibility=hidden
24ifeq ($(LIBBPF_DEBUG),y)
25 LIBBPF_CFLAGS+= -O0
26else
27 LIBBPF_CFLAGS+= -O2
28endif
29
Benoît Ganne24b51072020-10-08 14:08:47 +020030# check for libelf, zlib and kernel if_xdp.h presence
31LIBBPF_DEPS_CHECK:="\#include <linux/if_xdp.h>\\n\#include <gelf.h>\\n\#include <zlib.h>\\nint main(void){return 0;}"
32LIBBPF_DEPS_CHECK:=$(shell echo -e $(LIBBPF_DEPS_CHECK) | $(CC) -xc -lelf -lz -o /dev/null - > /dev/null 2>&1)
33LIBBPF_DEPS_CHECK:=$(.SHELLSTATUS)
Benoît Ganne4a76d6f2020-06-12 08:47:34 +020034
35define libbpf_config_cmds
36 @true
37endef
38
39define libbpf_build_cmds__
40 BUILD_STATIC_ONLY=y OBJDIR='$(libbpf_build_dir)' PREFIX='' DESTDIR='$(libbpf_install_dir)' CFLAGS='$(LIBBPF_CFLAGS)' make -C '$(libbpf_src_dir)/src' $(1) > $(2)
41endef
42
43define libbpf_build_cmds
44 $(call libbpf_build_cmds__,,$(libbpf_build_log))
45endef
46
47define libbpf_install_cmds
48 $(call libbpf_build_cmds__,install,$(libbpf_install_log))
49endef
50
Benoît Ganne24b51072020-10-08 14:08:47 +020051ifneq ($(LIBBPF_DEPS_CHECK),0)
52 $(warning "Missing libbpf dependencies. libbpf will be skipped.")
Benoît Ganne4a76d6f2020-06-12 08:47:34 +020053libbpf-install:
54 @true
55else
56 $(eval $(call package,libbpf))
57endif