which: update 2.21 -> 2.23, build with meson

This (and 2.22) is a first release in many years. Rather than try
to use upstream's absurdly overblown, incompatible build system
(see below), I added a small-ish meson file. This means:

- drop tweaks and dependency on cwautomacros as that is no longer used

- drop patch as configure.ac has been rewritten, and the recipe is using meson anyway

- drop --disable-iberty for the same reason

In this realease, cwautomacros has been replaced by an equally custom, weird set
of macros, written by 'which' maintainer: https://github.com/CarloWood/cwm4

- one effect of that is that autoreconf isn't happy with which's configure.ac and won't run;
one is supposed to use a custom script instead: https://github.com/CarloWood/cwm4/blob/master/scripts/bootstrap.sh

- alas, that script is not shipped in tarballs; the maintainer wants
everyone to trust their 200k configure script (hello xz backdoor)

- building from git (where the script exists) is not impossible,
but that has no version tags

All this 'special handling' for what, exactly? Five .c files to produce one
single-function executable, and one manpage. Wich should all be in coreutils
to begin with. GNU's attachment to autotools defies reason.

(From OE-Core rev: 600545a0ef313e7df5a0f25eba17b73b0f410489)

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexander Kanavin
2025-09-25 12:53:39 +02:00
committed by Richard Purdie
parent 702c515a75
commit cf0cf92200
4 changed files with 113 additions and 38 deletions

View File

@@ -1,19 +0,0 @@
Update autoconf prologue to use "foreign" strictness.
Upstream-Status: Pending
Signed-off-by: Ross Burton <ross.burton@intel.com>
diff --git a/configure.ac b/configure.ac
index d974461..a20dfa8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT([which], [2.21])
AC_CONFIG_SRCDIR(which.c)
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([foreign])
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE

View File

@@ -1,4 +1,4 @@
From 16a1647fc26953fab659de5f55d4c0defdfb894f Mon Sep 17 00:00:00 2001
From 83d2ed3fd203868a8f287d2ebedc7c304c74fbb4 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 22 Mar 2025 17:56:19 -0700
Subject: [PATCH] getopt: Fix signature of getenv function
@@ -13,27 +13,32 @@ Upstream-Status: Submitted [https://lists.gnu.org/archive/html/which-bugs/2025-0
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
getopt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
getopt.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/getopt.c b/getopt.c
index 9ac2ed6..b1aa322 100644
--- a/getopt.c
+++ b/getopt.c
@@ -209,7 +209,7 @@ static char *posixly_correct;
@@ -205,7 +205,7 @@ static char *posixly_correct;
/* Avoid depending on library functions or files
whose names are inconsistent. */
-char *getenv ();
-char *getenv();
+char *getenv (const char*);
static char *
my_index (str, chr)
static char *my_index(str, chr) const char *str;
int chr;
diff --git a/getopt.h b/getopt.h
index f080053..e04e3ca 100644
--- a/getopt.h
+++ b/getopt.h
@@ -103,7 +103,7 @@ struct option
@@ -102,7 +102,7 @@ struct option {
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
extern int getopt(int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
-extern int getopt();
+extern int getopt (int, char * const [], const char *);
#endif /* __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long(int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind);
extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, const struct option *longopts,

View File

@@ -0,0 +1,92 @@
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#
project('which', 'c', version: '2.23')
add_project_arguments('-DHAVE_CONFIG_H', language : 'c')
src = ['bash.c','getopt1.c','getopt.c','tilde.c','which.c']
executable('which', src, install: true)
install_man('which.1')
conf_data = configuration_data()
conf_data.set('GETGROUPS_T', 'gid_t')
compiler = meson.get_compiler('c')
if compiler.has_function('strchr')
conf_data.set('HAVE_STRCHR', 1)
endif
if compiler.has_function('memcpy')
conf_data.set('HAVE_MEMCPY', 1)
endif
if compiler.has_function('getopt_long')
conf_data.set('HAVE_GETOPT_LONG', 1)
endif
if compiler.has_function('getcwd')
conf_data.set('HAVE_GETCWD', 1)
endif
if compiler.has_function('getwd')
conf_data.set('HAVE_GETWD', 1)
endif
if compiler.has_function('sysconf')
conf_data.set('HAVE_SYSCONF', 1)
endif
if compiler.has_function('getgroups')
conf_data.set('HAVE_GETGROUPS', 1)
endif
if compiler.has_function('eaccess')
conf_data.set('HAVE_EACCESS', 1)
endif
if compiler.has_function('getpwent')
conf_data.set('HAVE_GETPWENT', 1)
endif
if compiler.has_function('getpwnam')
conf_data.set('HAVE_GETPWNAM', 1)
endif
if compiler.has_function('getpwuid')
conf_data.set('HAVE_GETPWUID', 1)
conf_data.set('HAVE_GETPW_DECLS', 1)
endif
if compiler.has_header('unistd.h')
conf_data.set('HAVE_UNISTD_H', 1)
endif
if compiler.has_header('string.h')
conf_data.set('HAVE_STRING_H', 1)
endif
if compiler.has_header('stdlib.h')
conf_data.set('HAVE_STDLIB_H', 1)
endif
if compiler.has_header('memory.h')
conf_data.set('HAVE_MEMORY_H', 1)
endif
if compiler.has_header('pwd.h')
conf_data.set('HAVE_PWD_H', 1)
endif
if compiler.has_header('strings.h')
conf_data.set('HAVE_STRINGS_H', 1)
endif
if compiler.has_header('inttypes.h')
conf_data.set('HAVE_INTTYPES_H', 1)
endif
if compiler.has_header('stdio.h')
conf_data.set('HAVE_STDIO_H', 1)
endif
if compiler.has_header('stdint.h')
conf_data.set('HAVE_STDINT_H', 1)
endif
if compiler.has_header('sys/stat.h')
conf_data.set('HAVE_SYS_STAT_H', 1)
endif
if compiler.has_header('sys/types.h')
conf_data.set('HAVE_SYS_TYPES_H', 1)
endif
conf_data.set('NEED_XMALLOC', 1)
conf_data.set('STDC_HEADERS', 1)
conf_data.set('VERSION', '"' + meson.project_version() + '"')
configure_file(output: 'config.h', configuration: conf_data)

View File

@@ -9,21 +9,18 @@ HOMEPAGE = "https://carlowood.github.io/which/"
LICENSE = "GPL-3.0-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504\
file://which.c;beginline=1;endline=17;md5=a9963693af2272e7a8df6f231164e7a2"
DEPENDS = "cwautomacros-native"
inherit autotools texinfo update-alternatives
EXTRA_OECONF = "--disable-iberty"
inherit meson update-alternatives
SRC_URI = "${GNU_MIRROR}/which/which-${PV}.tar.gz \
file://automake.patch \
file://meson.build \
file://0001-getopt-Fix-signature-of-getenv-function.patch \
"
SRC_URI[sha256sum] = "f4a245b94124b377d8b49646bf421f9155d36aa7614b6ebf83705d3ffc76eaad"
SRC_URI[sha256sum] = "a2c558226fc4d9e4ce331bd2fd3c3f17f955115d2c00e447618a4ef9978a2a73"
do_configure:prepend() {
sed -i -e 's%@ACLOCAL_CWFLAGS@%-I ${STAGING_DIR_NATIVE}/usr/share/cwautomacros/m4%g' ${S}/Makefile.am ${S}/tilde/Makefile.am
cp ${UNPACKDIR}/meson.build ${S}
}
ALTERNATIVE:${PN} = "which"