요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
Building libbpf
===============
libelf and zlib are internal dependencies of libbpf and thus are required to link
against and must be installed on the system for applications to work.
pkg-config is used by default to find libelf, and the program called
can be overridden with PKG_CONFIG.
If using pkg-config at build time is not desired, it can be disabled by
setting NO_PKG_CONFIG=1 when calling make.
To build both static libbpf.a and shared libbpf.so:
.. code-block:: bash
$ cd src
$ make
To build only static libbpf.a library in directory build/ and install them
together with libbpf headers in a staging directory root/:
.. code-block:: bash
$ cd src
$ mkdir build root
$ BUILD_STATIC_ONLY=y OBJDIR=build DESTDIR=root make install
To build both static libbpf.a and shared libbpf.so against a custom libelf
dependency installed in /build/root/ and install them together with libbpf
headers in a build directory /build/root/:
.. code-block:: bash
$ cd src
$ PKG_CONFIG_PATH=/build/root/lib64/pkgconfig DESTDIR=/build/root make
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
libbpf build dependency
1-13`Building libbpf` 문서는 `(LGPL-2.1 OR BSD-2-Clause)` license를 따르며 libbpf build 방법을 설명합니다.
`libelf`와 `zlib`은 libbpf의 internal dependency입니다. Application이 동작하도록 이 library와 link해야 하므로 system에 설치되어 있어야 합니다.
기본적으로 `pkg-config`를 사용해 `libelf`를 찾으며, 호출할 program은 `PKG_CONFIG`로 override할 수 있습니다.
Build할 때 `pkg-config`를 사용하지 않으려면 `make`를 호출할 때 `NO_PKG_CONFIG=1`을 설정해 disable할 수 있습니다.
Static library만 staging directory에 install
21-29Static `libbpf.a`만 `build/` directory에 build하고 libbpf header와 함께 staging directory `root/`에 install하려면 다음 command를 사용합니다.
$ cd src
$ mkdir build root
$ BUILD_STATIC_ONLY=y OBJDIR=build DESTDIR=root make install
`BUILD_STATIC_ONLY=y`는 static-only build를 선택하고, `OBJDIR=build`는 object output directory를, `DESTDIR=root`는 staging install root를 지정합니다.
Custom libelf로 build하고 install
30-37`/build/root/`에 설치된 custom `libelf` dependency를 사용해 static `libbpf.a`와 shared `libbpf.so`를 모두 build하고 libbpf header와 함께 `/build/root/`에 install하려면 다음 command를 사용합니다.
$ cd src
$ PKG_CONFIG_PATH=/build/root/lib64/pkgconfig DESTDIR=/build/root make
`PKG_CONFIG_PATH=/build/root/lib64/pkgconfig`로 custom `libelf` metadata 위치를 지정하고 `DESTDIR=/build/root`로 install root를 지정합니다.
요약과 해설
libbpf_build.rst:1-37Libbpf는 `libelf`와 `zlib`에 link하며 기본적으로 `pkg-config`로 `libelf`를 찾습니다. `PKG_CONFIG`로 실행 program을 바꾸거나 `NO_PKG_CONFIG=1`로 검색을 끌 수 있습니다.
기본 `make`는 `libbpf.a`와 `libbpf.so`를 함께 만들고, `BUILD_STATIC_ONLY`, `OBJDIR`, `DESTDIR` 조합은 static-only staging build를 구성합니다. Custom dependency는 `PKG_CONFIG_PATH`로 선택합니다.