aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas@t-8ch.de>2024-04-16 09:26:22 +0200
committerThomas Weißschuh <thomas@t-8ch.de>2024-04-16 09:28:52 +0200
commit543f991f62659b9a3ff67f9cda3456b2a5bb3f98 (patch)
tree699ff573e1d8a9ad262472a4aef1b96d212c1430
parent4d5441ec53337edae2b9f7deef0e21d700c06b4d (diff)
downloadutil-linux-543f991f62659b9a3ff67f9cda3456b2a5bb3f98.tar.gz
all_errnos/all_syscalls: don't hardcode AWK invocation
Use the buildsystem to find a usable awk implementation and use that. Reported-by: Firas Khalil Khana <firasuke@gmail.com> Link: https://github.com/util-linux/util-linux/pull/2949 Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> https://lore.kernel.org/util-linux/31ccace2e5912ffc428e065cd66764088c625c4d.camel@physik.fu-berlin.de/ Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
-rw-r--r--configure.ac1
-rw-r--r--meson.build7
-rw-r--r--misc-utils/Makemodule.am4
-rwxr-xr-xtools/all_errnos4
-rwxr-xr-xtools/all_syscalls4
5 files changed, 14 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index 2fff2de09d..2e6e0eed6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,6 +132,7 @@ AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_MKDIR_P
AC_PROG_YACC
+AC_PROG_AWK
# Don't use autotools integrated LEX/YACC support for libsmartcols
AC_PATH_PROG([FLEX], [flex])
diff --git a/meson.build b/meson.build
index 21822f0bd4..bc8c40471a 100644
--- a/meson.build
+++ b/meson.build
@@ -896,6 +896,7 @@ conf.set('USE_TTY_GROUP', have ? 1 : false)
bison = find_program('bison')
flex = find_program('flex')
+awk = find_program('gawk', 'mawk', 'nawk', 'awk')
build_hwclock = not get_option('build-hwclock').disabled()
bison_gen = generator(
@@ -2768,7 +2769,8 @@ endif
errnos_h = custom_target('errnos.h',
input : 'tools/all_errnos',
output : 'errnos.h',
- command : ['tools/all_errnos', cc.cmd_array(), get_option('c_args')],
+ command : ['tools/all_errnos', awk.full_path(),
+ cc.cmd_array(), get_option('c_args')],
)
opt = not get_option('build-lsfd').require(lib_rt.found()).disabled()
@@ -3085,7 +3087,8 @@ endif
syscalls_h = custom_target('syscalls.h',
input : 'tools/all_syscalls',
output : 'syscalls.h',
- command : ['tools/all_syscalls', cc.cmd_array(), get_option('c_args')],
+ command : ['tools/all_syscalls', awk.full_path(),
+ cc.cmd_array(), get_option('c_args')],
)
if cc.compiles(fs.read('include/audit-arch.h'), name : 'has AUDIT_ARCH_NATIVE')
diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am
index 7622a5d7be..841275eb6e 100644
--- a/misc-utils/Makemodule.am
+++ b/misc-utils/Makemodule.am
@@ -1,6 +1,6 @@
errnos.h: $(top_srcdir)/tools/all_errnos
@echo ' GEN $@'
- @$(top_srcdir)/tools/all_errnos $(CC) $(CFLAGS)
+ @$(top_srcdir)/tools/all_errnos "$(AWK)" $(CC) $(CFLAGS)
-include errnos.h.deps
CLEANFILES += errnos.h errnos.h.deps
@@ -338,7 +338,7 @@ misc-utils/enosys.c: syscalls.h errnos.h
syscalls.h: $(top_srcdir)/tools/all_syscalls
@echo ' GEN $@'
- @$(top_srcdir)/tools/all_syscalls $(CC) $(CFLAGS)
+ @$(top_srcdir)/tools/all_syscalls "$(AWK)" $(CC) $(CFLAGS)
-include syscalls.h.deps
CLEANFILES += syscalls.h syscalls.h.deps
diff --git a/tools/all_errnos b/tools/all_errnos
index 4b662aa8f3..137713d401 100755
--- a/tools/all_errnos
+++ b/tools/all_errnos
@@ -5,6 +5,8 @@
set -e
set -o pipefail
+AWK="$1"
+shift
OUTPUT=errnos.h
ERRNO_INCLUDES="
#include <sys/errno.h>
@@ -13,6 +15,6 @@ ERRNO_INCLUDES="
trap 'rm -f $OUTPUT $OUTPUT.deps' ERR
"$@" -MD -MF "$OUTPUT.deps" <<< "$ERRNO_INCLUDES" -dM -E - \
- | gawk 'match($0, /^#[ \t]*define[ \t]*E([^ ]+)/, res) { print "UL_ERRNO(\"E" res[1] "\", E" res[1] ")" }' \
+ | "$AWK" 'match($0, /^#[ \t]*define[ \t]*E([^ ]+)/, res) { print "UL_ERRNO(\"E" res[1] "\", E" res[1] ")" }' \
| sort \
> "$OUTPUT"
diff --git a/tools/all_syscalls b/tools/all_syscalls
index f2f91b3aef..15984e5287 100755
--- a/tools/all_syscalls
+++ b/tools/all_syscalls
@@ -3,6 +3,8 @@
set -e
set -o pipefail
+AWK="$1"
+shift
OUTPUT=syscalls.h
SYSCALL_INCLUDES="
#include <sys/syscall.h>
@@ -11,6 +13,6 @@ SYSCALL_INCLUDES="
trap 'rm -f $OUTPUT $OUTPUT.deps' ERR
"$@" -MD -MF "$OUTPUT.deps" <<< "$SYSCALL_INCLUDES" -dM -E - \
- | gawk 'match($0, /^#define __NR_([^ ]+)/, res) { print "UL_SYSCALL(\"" res[1] "\", __NR_" res[1] ")" }' \
+ | "$AWK" 'match($0, /^#define __NR_([^ ]+)/, res) { print "UL_SYSCALL(\"" res[1] "\", __NR_" res[1] ")" }' \
| sort \
> "$OUTPUT"