diff mbox series

Improved usability of the Makefile in libbpf

Message ID 20221129074235.116969-1-liuxin350@huawei.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series Improved usability of the Makefile in libbpf | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-21 fail Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 fail Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-36 fail Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-38 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-37 success Logs for test_verifier on x86_64 with gcc

Commit Message

Xin Liu Nov. 29, 2022, 7:42 a.m. UTC
Current libbpf Makefile does not contain the help command, which
is inconvenient to use. A help command is provided to list the
commands supported by libbpf make and the functions of the commands.

Signed-off-by: Xin Liu <liuxin350@huawei.com>
---
 tools/lib/bpf/Makefile | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

Comments

Andrii Nakryiko Dec. 1, 2022, 12:42 a.m. UTC | #1
On Mon, Nov 28, 2022 at 11:42 PM Xin Liu <liuxin350@huawei.com> wrote:
>
> Current libbpf Makefile does not contain the help command, which
> is inconvenient to use. A help command is provided to list the
> commands supported by libbpf make and the functions of the commands.
>
> Signed-off-by: Xin Liu <liuxin350@huawei.com>
> ---
>  tools/lib/bpf/Makefile | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
>
> diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
> index 4c904ef0b47e..c86e05df4711 100644
> --- a/tools/lib/bpf/Makefile
> +++ b/tools/lib/bpf/Makefile
> @@ -286,3 +286,37 @@ tags:
>
>  # Delete partially updated (corrupted) files on error
>  .DELETE_ON_ERROR:
> +
> +help:
> +       @echo 'Default targets:'
> +       @echo '  all               - Run all_cmd'
> +       @echo '  all_cmd           - Build library and pkgconfig, check abi and version info'
> +       @echo ''
> +       @echo 'Cleaning targets:'
> +       @echo '  clean             - Remove all generated files'
> +       @echo ''
> +       @echo 'Build targets:'
> +       @echo '  libbpf.so         - Build the dynamic library'
> +       @echo '  libbpf.a          - Build the static library'
> +       @echo '  libbpf.pc         - Build the pkgconfig file'
> +       @echo ''
> +       @echo 'Install targets:'
> +       @echo '  install           - Install all headers, library and pkgconfig file to'
> +       @echo '                      DESTDIR(default: /) with prefix(default: /usr/local)'
> +       @echo '  install_lib       - Install only library'
> +       @echo '  install_headers   - Install only headers'
> +       @echo '  install_pkgconfig - Install only pkgconfig file'
> +       @echo ''
> +       @echo 'Other generic targets:'
> +       @echo '  cscope            - Generate cscope index'
> +       @echo '  tags              - Generate tags file for editors'
> +       @echo '  check             - Check abi and version info'
> +       @echo '  check_abi         - Check versioned symbols'
> +       @echo '  check_version     - Check whether the libbpf version defined in libbpf_version.h'
> +       @echo '                      is the same as that defined in libbpf.map'
> +       @echo ''
> +       @echo '  make V=0|1             [targets] 0 => quiet build (default), 1 => verbose build'
> +       @echo '  make DESTDIR=/root     [install targets] use DESTDIR for installing'
> +       @echo '                                           into a different root directory'
> +       @echo '  make prefix=/path      [install targets] use prefix for installing'
> +       @echo '                                           into a user defined prefix path'


I'm a bit hesitant about adding all this. Most of those targets are
not intended to be used directly, only "all", "clean", and "install"
are supposed to be used by end-users (maybe also "install_headers").
And those seems to be pretty typical and straightforward targets.

I actually didn't even know about `make help`, but I checked perf's
`make help` and it's way more succinct, let's try modeling it here?

Also, please use [PATCH bpf-next] (with v2 in between them) for next
submission to point that this is meant for bpf-next tree.


> --
> 2.33.0
>
Xin Liu Dec. 2, 2022, 2:13 a.m. UTC | #2
On Wed, 30 Nov 2022 at 00:42:09 AM Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
> On Mon, Nov 28, 2022 at 11:42 PM Xin Liu <liuxin350@huawei.com> wrote:
> >
> > Current libbpf Makefile does not contain the help command, which
> > is inconvenient to use. A help command is provided to list the
> > commands supported by libbpf make and the functions of the commands.
> ...
> > +       @echo '  make prefix=/path      [install targets] use prefix for installing'
> > +       @echo '                                           into a user defined prefix path'
> 
> 
> I'm a bit hesitant about adding all this. Most of those targets are
> not intended to be used directly, only "all", "clean", and "install"
> are supposed to be used by end-users (maybe also "install_headers").
> And those seems to be pretty typical and straightforward targets.
> 
> I actually didn't even know about `make help`, but I checked perf's
> `make help` and it's way more succinct, let's try modeling it here?
> 
> Also, please use [PATCH bpf-next] (with v2 in between them) for next
> submission to point that this is meant for bpf-next tree.

Thanks to andrii's reply, I'll try to simplify the help command.

The original purpose of adding this is that when I use libbpf, libbpf installs
the file in /usr/local by default, and I didn't read the makefile carefully
before, so I need to open the makefile to read the code. Determine which
parameter is used to define the path that I want to customize. The makefile
of the kernel provides a make help instruction, which is much more convenient
to use.
diff mbox series

Patch

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 4c904ef0b47e..c86e05df4711 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -286,3 +286,37 @@  tags:
 
 # Delete partially updated (corrupted) files on error
 .DELETE_ON_ERROR:
+
+help:
+	@echo 'Default targets:'
+	@echo '  all               - Run all_cmd'
+	@echo '  all_cmd           - Build library and pkgconfig, check abi and version info'
+	@echo ''
+	@echo 'Cleaning targets:'
+	@echo '  clean             - Remove all generated files'
+	@echo ''
+	@echo 'Build targets:'
+	@echo '  libbpf.so         - Build the dynamic library'
+	@echo '  libbpf.a          - Build the static library'
+	@echo '  libbpf.pc         - Build the pkgconfig file'
+	@echo ''
+	@echo 'Install targets:'
+	@echo '  install           - Install all headers, library and pkgconfig file to'
+	@echo '                      DESTDIR(default: /) with prefix(default: /usr/local)'
+	@echo '  install_lib       - Install only library'
+	@echo '  install_headers   - Install only headers'
+	@echo '  install_pkgconfig - Install only pkgconfig file'
+	@echo ''
+	@echo 'Other generic targets:'
+	@echo '  cscope            - Generate cscope index'
+	@echo '  tags              - Generate tags file for editors'
+	@echo '  check             - Check abi and version info'
+	@echo '  check_abi         - Check versioned symbols'
+	@echo '  check_version     - Check whether the libbpf version defined in libbpf_version.h'
+	@echo '                      is the same as that defined in libbpf.map'
+	@echo ''
+	@echo '  make V=0|1             [targets] 0 => quiet build (default), 1 => verbose build'
+	@echo '  make DESTDIR=/root     [install targets] use DESTDIR for installing'
+	@echo '                                           into a different root directory'
+	@echo '  make prefix=/path      [install targets] use prefix for installing'
+	@echo '                                           into a user defined prefix path'