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