]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
all_errnos/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>
Tue, 16 Apr 2024 07:28:52 +0000 (09:28 +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>
configure.ac
meson.build
misc-utils/Makemodule.am
tools/all_errnos
tools/all_syscalls

index 2fff2de09d54ef0deb59f51899f05d09fe3f0395..2e6e0eed6c64e16c280ed40ff4aa42242c5fe0cd 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 21822f0bd426ea0e863edaf74d5077a09fcd385d..bc8c40471aa2f68ebdf77f48eadd24f331fd1837 100644 (file)
@@ -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')
index 7622a5d7bea26f2e8abba354ca4c4c9fec3a46db..841275eb6eb149e1bd81e13b0e423bfb4773eb49 100644 (file)
@@ -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
index 4b662aa8f326fb8cf32a58cfb3742f8715101680..137713d401219d0528bd7426d3363f7cce9673d9 100755 (executable)
@@ -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"
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"