]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
all_syscalls: don't hardcode AWK invocation
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 16 Apr 2024 07:26:22 +0000 (09:26 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Thu, 18 Apr 2024 07:59:49 +0000 (09:59 +0200)
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>
(cherry picked from commit 543f991f62659b9a3ff67f9cda3456b2a5bb3f98)

configure.ac
meson.build
misc-utils/Makemodule.am
tools/all_syscalls

index c3387496ce1648763dd176091c31b35cc2f0fc96..ef85a7ade68c93247f025e250f82e2579fe018db 100644 (file)
@@ -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])
index 21751e3b0052d58020a40e13421c4f6c3ba1affb..844cde141d56c5e778b82e054176660b076dc28e 100644 (file)
@@ -895,6 +895,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(
@@ -3034,7 +3035,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')
index 0720dda0ac02b6a76b2d61c2bd84f1f6700efd10..3763fa9c266a91ae84841969ff78912bd6cd3dc9 100644 (file)
@@ -326,7 +326,7 @@ misc-utils/enosys.c: syscalls.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
index f2f91b3aefbf06701b6af23b5a9cfc90caf796ff..15984e52878f090cf1dd0cdf23864f87dfc52f89 100755 (executable)
@@ -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"