logo

utils-extra

Collection of extra tools for Unixes git clone https://anongit.hacktivis.me/git/utils-extra.git/
commit: ee07ab9d0f2a8609f97a3924bb500bc0dac79455
parent f26e1283cd330feb184dcb00d5c94c688ea021a0
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 20 Aug 2025 16:56:39 +0200

configure: add check_header and maybe_filter

Diffstat:

Mconfigure27+++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/configure b/configure @@ -2,6 +2,8 @@ # SPDX-FileCopyrightText: 2017-2023 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> # SPDX-License-Identifier: MPL-2.0 +target_filter="" + usage() { cat <<END Usage: [variables] configure [variables] @@ -46,13 +48,22 @@ or_die() { is_ok || exit 1 } +maybe_filter() { + if test "$#" -gt 0 + then + exec grep -v -F "$@" + else + cat + fi +} + gen_targets() { printf 'EXE = ' - printf '%s\n ' cmd/*.c | sed -e 's;.c$;;' | tr -d '\n' + printf '%s\n ' cmd/*.c | maybe_filter ${target_filter} | sed -e 's;.c$;;' | tr -d '\n' echo printf 'MAN1 = ' - printf '%s\n ' cmd/*.1 sh-man/*.1 | tr -d '\n' + printf '%s\n ' cmd/*.1 sh-man/*.1 | maybe_filter ${target_filter} | tr -d '\n' echo } @@ -68,6 +79,18 @@ check_cmd() { command -v "$cmd" >/dev/null ; is_ok } +check_header() { + header="$1" + + set -- $CC -E -x c - + + printf 'Checking <%s> header (printf "#include <%s>" | %s) ...' "$header" "$header" "$*" + + printf '#include <%s>\n' "$header" | $@ >/dev/null + + is_ok +} + ## User configuration # defaults