[make-initrd] [PATCH v1 10/11] feature/procacct: Make procacct optional
Alexey Gladkov
gladkov.alexey at gmail.com
Thu Jun 15 20:59:19 MSK 2023
Signed-off-by: Alexey Gladkov <gladkov.alexey at gmail.com>
---
Makefile.in | 10 +++++++
configure.ac | 36 +++++++++++++++++++++++++
features/debug-procacct/src/Makefile.mk | 7 ++---
3 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 45053fa0..c26a3f44 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -90,8 +90,15 @@ HAVE_LIBINIPARSER := @HAVE_LIBINIPARSER@
HAVE_LIBINIPARSER_LIBS := @HAVE_LIBINIPARSER_LIBS@
HAVE_LIBINIPARSER_CFLAGS := @HAVE_LIBINIPARSER_CFLAGS@
+HAVE_LIBBPF := @HAVE_LIBBPF@
+HAVE_LIBBPF_LIBS := @HAVE_LIBBPF_LIBS@
+HAVE_LIBBPF_CFLAGS := @HAVE_LIBBPF_CFLAGS@
+
USE_FEATURE_BOOTLOADER = @USE_FEATURE_BOOTLOADER@
+USE_FEATURE_PROCACCT = @USE_FEATURE_PROCACCT@
+CLANG ?= @CLANG@
+LLVM_STRIP ?= @LLVM_STRIP@
YACC := @YACC@
LEX := @LEX@
@@ -108,6 +115,9 @@ SKIP_FEATURES =
ifeq ($(USE_FEATURE_BOOTLOADER),no)
SKIP_FEATURES += bootloader
endif
+ifeq ($(USE_FEATURE_PROCACCT),no)
+SKIP_FEATURES += debug-procacct
+endif
all: build
diff --git a/configure.ac b/configure.ac
index 9633a2ba..db2575e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -314,6 +314,41 @@ if test "x$with_feature_bootloader" != xno; then
fi
fi
+AC_ARG_WITH([feature-procacct],
+ [AS_HELP_STRING([--with-feature-procacct],
+ [build procacct feature (default: auto)])],
+ [],
+ [: m4_divert_text([DEFAULTS], [with_feature_procacct=auto])])
+
+USE_FEATURE_PROCACCT=no
+HAVE_LIBBPF=no
+
+if test "x$with_feature_procacct" != xno; then
+ PKG_CHECK_MODULES(HAVE_LIBBPF, libbpf, [HAVE_LIBBPF=yes], [HAVE_LIBBPF=no]);
+ AC_PATH_PROGS([with_clang], [clang])
+ AC_PATH_PROGS([with_llvm_strip], [llvm-strip])
+
+ if test "x$with_feature_procacct" != xauto; then
+ AS_IF([test "x$HAVE_LIBBPF" != xyes],
+ [AC_MSG_ERROR([libbpf was not found: https://github.com/libbpf/libbpf])])
+ AS_IF([! test -x "$with_clang"],
+ [AC_MSG_ERROR([required utility not found: clang])])
+ fi
+
+ if test "x-$HAVE_LIBBPF" = x-yes && test -x "$with_clang"; then
+ USE_FEATURE_PROCACCT=yes
+ fi
+
+ if ! test -x "$with_llvm_strip"; then
+ with_llvm_strip=/bin/true
+ fi
+
+ AC_SUBST([HAVE_LIBBPF])
+ AC_SUBST([CLANG], [$with_clang])
+ AC_SUBST([LLVM_STRIP], [$with_llvm_strip])
+fi
+
+
AC_SUBST([HAVE_GZIP])
AC_SUBST([HAVE_BZIP2])
AC_SUBST([HAVE_LZMA])
@@ -326,6 +361,7 @@ AC_SUBST([HAVE_LIBINIPARSER])
AC_SUBST([HAVE_LIBINIPARSER_LIBS])
AC_SUBST([HAVE_LIBINIPARSER_CFLAGS])
AC_SUBST([USE_FEATURE_BOOTLOADER])
+AC_SUBST([USE_FEATURE_PROCACCT])
AC_SUBST([MKLOCAL])
AC_SUBST([YACC])
AC_SUBST([LEX])
diff --git a/features/debug-procacct/src/Makefile.mk b/features/debug-procacct/src/Makefile.mk
index 505d8288..43589b1a 100644
--- a/features/debug-procacct/src/Makefile.mk
+++ b/features/debug-procacct/src/Makefile.mk
@@ -1,16 +1,13 @@
procacct_DEST = $(dest_data_bindir)/procacct
procacct_SRCS = $(FEATURESDIR)/debug-procacct/src/procacct.c
-procacct_CFLAGS = -D_GNU_SOURCE -Idatasrc/libinitramfs -DPROCACCT_BPF_FILE=\"/bin/procacct-bpf.o\"
-procacct_LIBS = -L$(dest_data_libdir) -linitramfs -lbpf
+procacct_CFLAGS = -D_GNU_SOURCE -Idatasrc/libinitramfs $(HAVE_LIBBPF_CFLAGS) -DPROCACCT_BPF_FILE=\"/bin/procacct-bpf.o\"
+procacct_LIBS = -L$(dest_data_libdir) -linitramfs $(HAVE_LIBBPF_LIBS)
PROGS += procacct
procacct_bpf_DEST = $(dest_data_bindir)/procacct-bpf.o
procacct_bpf_SRCS = $(FEATURESDIR)/debug-procacct/src/procacct-bpf.c
-CLANG ?= clang-15
-LLVM_STRIP = llvm-strip
-
$(dest_data_bindir)/procacct-bpf.o: $(procacct_bpf_SRCS)
$(Q)mkdir -p -- $(dir $@)
$(call quiet_cmd,BPF,$@,$(CLANG)) -target bpf -g -O2 -Wall -Wextra -o $@ -c $<
--
2.33.8
More information about the Make-initrd
mailing list