samples/bpf: Allow building with custom CFLAGS/LDFLAGS
authorViktor Malik <vmalik@redhat.com>
Wed, 25 Oct 2023 06:19:12 +0000 (08:19 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 26 Oct 2023 13:32:12 +0000 (15:32 +0200)
commit870f09f1ba3014e2c157b14299c172b4bb716638
treeeccba13e343802ae0bef8d186d918062e1634396
parentc421c12586b3f00fb96b5c9af15c9a051a9090b1
samples/bpf: Allow building with custom CFLAGS/LDFLAGS

Currently, it is not possible to specify custom flags when building
samples/bpf. The flags are defined in TPROGS_CFLAGS/TPROGS_LDFLAGS
variables, however, when trying to override those from the make command,
compilation fails.

For example, when trying to build with PIE:

    $ make -C samples/bpf TPROGS_CFLAGS="-fpie" TPROGS_LDFLAGS="-pie"

This is because samples/bpf/Makefile updates these variables, especially
appends include paths to TPROGS_CFLAGS and these updates are overridden
by setting the variables from the make command.

This patch introduces variables TPROGS_USER_CFLAGS/TPROGS_USER_LDFLAGS
for this purpose, which can be set from the make command and their
values are propagated to TPROGS_CFLAGS/TPROGS_LDFLAGS.

Signed-off-by: Viktor Malik <vmalik@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/2d81100b830a71f0e72329cc7781edaefab75f62.1698213811.git.vmalik@redhat.com
samples/bpf/Makefile