From: Alexey Gladkov <gladkov.alexey@gmail.com>
To: make-initrd@lists.altlinux.org
Subject: [make-initrd] [PATCH v1 10/11] feature/procacct: Make procacct optional
Date: Thu, 15 Jun 2023 19:59:19 +0200
Message-ID: <acf54e38f90f1429975b3e0c183cf31fc70764a1.1686851829.git.gladkov.alexey@gmail.com> (raw)
In-Reply-To: <cover.1686851829.git.gladkov.alexey@gmail.com>
Signed-off-by: Alexey Gladkov <gladkov.alexey@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
next prev parent reply other threads:[~2023-06-15 17:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 17:59 [make-initrd] [PATCH v1 00/11] Add accounting feature Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 01/11] feature/procacct: New feature to debug initramfs Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 02/11] feature/procacct: Use epoll Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 03/11] feature/procacct: Use default rcvbufsz Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 04/11] feature/procacct: Track more values Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 05/11] feature/procacct: Use msgtemplate instead of custom struct Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 06/11] feature/procacct: Use nonblocking per-call Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 07/11] feature/procacct: Add bpf helper Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 08/11] feature/procacct: Add accounting report Alexey Gladkov
2023-06-15 17:59 ` [make-initrd] [PATCH v1 09/11] feature/procacct: Wait until procacct is initialized Alexey Gladkov
2023-06-15 17:59 ` Alexey Gladkov [this message]
2023-06-15 17:59 ` [make-initrd] [PATCH v1 11/11] feature/procacct: Add to testing Alexey Gladkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=acf54e38f90f1429975b3e0c183cf31fc70764a1.1686851829.git.gladkov.alexey@gmail.com \
--to=gladkov.alexey@gmail.com \
--cc=make-initrd@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Make-initrd development discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/make-initrd/0 make-initrd/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 make-initrd make-initrd/ http://lore.altlinux.org/make-initrd \
make-initrd@lists.altlinux.org make-initrd@lists.altlinux.ru make-initrd@lists.altlinux.com
public-inbox-index make-initrd
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.make-initrd
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git