We need to escape the # for old versions of make(1). However, new
versions of grep(1) diagnose if it receives an escaped #. To keep both
make(1) and grep(1) happy in both their old and new versions, we need to
take advantage of # not being a comment in bash(1) when not preceeded by
a space, and also of \# being translated into # by bash(1).
alx@debian:~$ echo ''\#
#
alx@debian:~$ echo ''#
#
Fixes: 76f12e3fd3ea (2025-02-10; "share/mk/: Escape '#' in regexes")
Reported-by: Sergei Trofimovich <slyich@gmail.com>
Cc: Florian Weimer <fw@deneb.enyo.de>
Cc: Boris Pigin <boris.pigin@gmail.com>
Suggested-by: Jakub Wilk <jwilk@jwilk.net>
References: <
20250227162800.36exbwmqky6d7z4t@jwilk.net>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
CPP_HAS_ALREADY_D_FORTIFY_SOURCE := \
$(shell \
$(CPP) -dM - -Wno-error </dev/null \
- | $(GREP) '\#define _FORTIFY_SOURCE ' >/dev/null \
+ | $(GREP) ''\#'define _FORTIFY_SOURCE ' >/dev/null \
&& $(ECHO) yes \
|| $(ECHO) no; \
)
BIN_sh := $(shell $(FIND) $(SRCBINDIR) -type f \
- | $(XARGS) $(GREP) -l '^\#!/bin/\(sh\|bash\)\>' \
+ | $(XARGS) $(GREP) -l '^'\#'!/bin/\(sh\|bash\)\>' \
| $(SORT))