Hi,
I followed www.ipfire.org - IPFire 2.x - Building Add-ons to create lfs/libbpf as below:
include Config
SUMMARY = libbpf for bpf program open load attach
VER = 1.3.0
THISAPP = libbpf-$(VER)
DL_FILE = $(THISAPP).tar.gz
DL_FROM = $(URL_IPFIRE)
DIR_APP = $(DIR_SRC)/$(THISAPP)
TARGET = $(DIR_INFO)/$(THISAPP)
###############################################################################
# Top-level Rules
###############################################################################
objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
$(DL_FILE)_BLAKE2 = 5ee0a45cd06be482c9523ec2a9bb26cf12b89df23f515b037badda868770069d5ffb751c011222b86b1d43034a1cdd537cb263883ed0645641548adc9c9896eb
install : $(TARGET)
check : $(patsubst %,$(DIR_CHK)/%,$(objects))
download :$(patsubst %,$(DIR_DL)/%,$(objects))
b2 : $(subst %,%_BLAKE2,$(objects))
dist:
@$(PAK)
###############################################################################
# Downloading, checking, b2sum
###############################################################################
$(patsubst %,$(DIR_CHK)/%,$(objects)) :
@$(CHECK)
$(patsubst %,$(DIR_DL)/%,$(objects)) :
@$(LOAD)
$(subst %,%_BLAKE2,$(objects)) :
@$(B2SUM)
###############################################################################
# Installation Details
###############################################################################
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
@$(PREBUILD)
@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
cd $(DIR_APP)/src && make $(MAKETUNING)
cd $(DIR_APP)/src && make install
@rm -rf $(DIR_APP)
@$(POSTBUILD)
- New add-on compilation went ok, here is the _build.ipfire.log for libbpf
====================================== Installing libbpf-1.3.0 ...
Install started; saving file list to /usr/src/lsalr ...
cd /usr/src/libbpf-1.3.0/src && make -j8
make[1]: Entering directory '/usr/src/libbpf-1.3.0/src'
MKDIR staticobjs
MKDIR sharedobjs
CC staticobjs/bpf.o
CC staticobjs/btf.o
CC staticobjs/libbpf.o
...SNIP...
CC libbpf.so.1.3.0
AR libbpf.a
make[1]: Leaving directory '/usr/src/libbpf-1.3.0/src'
cd /usr/src/libbpf-1.3.0/src && make install
make[1]: Entering directory '/usr/src/libbpf-1.3.0/src'
INSTALL bpf.h libbpf.h btf.h libbpf_common.h libbpf_legacy.h bpf_helpers.h bpf_helper_defs.h bpf_tracing.h bpf_endian.h bpf_core_read.h skel_internal.h libbpf_version.h usdt.bpf.h
INSTALL ./libbpf.pc
INSTALL ./libbpf.a ./libbpf.so ./libbpf.so.1 ./libbpf.so.1.3.0
make[1]: Leaving directory '/usr/src/libbpf-1.3.0/src'
Updating linker cache...
Install done; saving file list to /usr/src/log/libbpf-1.3.0 ...
above says saving file list to /usr/src/log/libbpf-1.3.0
but log/libbpf-1.3.0 is empty
root@r210:/home/vincent/go/src/github.com/vincentmli/ipfire-2.x# pwd
/home/vincent/go/src/github.com/vincentmli/ipfire-2.x
root@r210:/home/vincent/go/src/github.com/vincentmli/ipfire-2.x# ls -l log/libbpf-1.3.0
-rw-r--r-- 1 root root 0 Feb 21 17:47 log/libbpf-1.3.0
any idea?
ah, my bad, I had a previous hack patch to add libbpf from kernel source build
diff --git a/config/rootfiles/common/x86_64/linux b/config/rootfiles/common/x86_64/linux
index 2c051a0b4..0900560a2 100644
--- a/config/rootfiles/common/x86_64/linux
+++ b/config/rootfiles/common/x86_64/linux
@@ -23700,3 +23700,8 @@ lib/modules/KVER-ipfire/modules.symbols.bin
#lib/modules/KVER-ipfire/source
sbin/gen_init_cpio
usr/sbin/bpftool
+usr/lib/libbpf.a
+usr/lib/libbpf.so.1.3.0
+usr/lib/libbpf.so
+usr/lib/libbpf.so.1
+usr/lib/pkgconfig/libbpf.pc
diff --git a/lfs/linux b/lfs/linux
index 8b6f8f283..717281cfc 100644
--- a/lfs/linux
+++ b/lfs/linux
@@ -174,6 +174,10 @@ else
cd $(DIR_APP)/tools/bpf/bpftool && sed -i -e 's/^prefix ?= \/usr\/local/prefix ?= \/usr/' Makefile
cd $(DIR_APP)/tools/bpf/bpftool && make $(MAKETUNING)
+ # Build libbpf
+ cd $(DIR_APP)/tools/lib/bpf && sed -i -e 's/^prefix ?= \/usr\/local/prefix ?= \/usr/' Makefile
+ cd $(DIR_APP)/tools/bpf/bpftool && make $(MAKETUNING)
+
# Install the kernel
cd $(DIR_APP) && cp -v arch/$(KERNEL_ARCH)/boot/$(KERNEL_TARGET) /boot/vmlinuz-$(VER)-$(VERSUFIX)
cd $(DIR_APP) && cp -v System.map /boot/System.map-$(VER)-$(VERSUFIX)
@@ -183,6 +187,9 @@ else
# Install bpftool
cd $(DIR_APP)/tools/bpf/bpftool && make install
+ # Install libbpf
+ cd $(DIR_APP)/tools/lib/bpf && make install_lib install_pkgconfig
+
ifneq "$(BUILD_PLATFORM)" "x86"
cd $(DIR_APP) && make $(MAKETUNING) dtbs
mkdir -p /boot/dtb-$(VER)-$(VERSUFIX)
that patch added libbpf.* to build/usr/lib directory already, and then this lfs/libbpf build detects libbpf.* in build/usr/lib, probably see no files diff and result in empty log/libbpf-1.3.0, I removed previous hack patch, removed build/usr/lib/libbpf.*, removed log/libbpf-1.3.0, re-build, resolved this empty log/libbpf-1.3.0 issue
I had issue with building libbpf package with above lfs libbpf with dist: @$(PAK)
, for the record, here is lfs libbpf I used to work.
diff --git a/config/rootfiles/common/libbpf b/config/rootfiles/common/libbpf
new file mode 100644
index 000000000..f77715fe2
--- /dev/null
+++ b/config/rootfiles/common/libbpf
@@ -0,0 +1,4 @@
+usr/lib/libbpf.a
+usr/lib/libbpf.so
+usr/lib/libbpf.so.1
+usr/lib/libbpf.so.1.3.0
diff --git a/lfs/libbpf b/lfs/libbpf
new file mode 100644
index 000000000..fda9ad240
--- /dev/null
+++ b/lfs/libbpf
@@ -0,0 +1,77 @@
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2007-2023 IPFire Team <info@ipfire.org> #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER = 1.3.0
+
+THISAPP = libbpf-$(VER)
+DL_FILE = $(THISAPP).tar.gz
+DL_FROM = $(URL_IPFIRE)
+DIR_APP = $(DIR_SRC)/$(THISAPP)
+TARGET = $(DIR_INFO)/$(THISAPP)
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_BLAKE2 = 5ee0a45cd06be482c9523ec2a9bb26cf12b89df23f515b037badda868770069d5ffb751c011222b86b1d43034a1cdd537cb263883ed0645641548adc9c9896eb
+
+install : $(TARGET)
+
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+
+b2 : $(subst %,%_BLAKE2,$(objects))
+
+###############################################################################
+# Downloading, checking, b2sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+ @$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+ @$(LOAD)
+
+$(subst %,%_BLAKE2,$(objects)) :
+ @$(B2SUM)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+ @$(PREBUILD)
+ @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+
+ cd $(DIR_APP)/src && make $(MAKETUNING)
+ cd $(DIR_APP)/src && make install
+ @rm -rf $(DIR_APP)
+ @$(POSTBUILD)
diff --git a/make.sh b/make.sh
index 4f9dfef79..1c3d9d6ad 100755
--- a/make.sh
+++ b/make.sh
@@ -1109,6 +1109,7 @@ buildipfire() {
lfsmake2 libcap
lfsmake2 libcap-ng
lfsmake2 libpcap
+ lfsmake2 libbpf
lfsmake2 ppp
lfsmake2 pptp
lfsmake2 unzip