From: Jordan Williams <jordan@jwillikers.com>
To: selinux@vger.kernel.org
Cc: jordan@jwillikers.com
Subject: [PATCH] libselinux/src/Makefile: fix reallocarray strlcpy detection
Date: Fri, 1 Mar 2024 10:32:02 -0600 [thread overview]
Message-ID: <d5120a64-04f3-444d-aaf8-3cfc6c1d9953@jwillikers.com> (raw)
Pass CFLAGS and LDFLAGS when checking for realocarray and strlcpy.
This brings things inline with the fixes for libsepol/src/Makefile.
This better supports cross-compiling scenarios.
There, flags like -sysroot need to included when running these checks.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index d3b981fc..3a9b5300 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -104,13 +104,13 @@ override CFLAGS += -I../include -D_GNU_SOURCE
$(DISABLE_FLAGS) $(PCRE_CFLAGS)
# check for strlcpy(3) availability
H := \#
-ifeq (yes,$(shell printf '${H}include <string.h>\nint
main(void){char*d,*s;strlcpy(d, s, 0);return 0;}' | $(CC) -x c -o
/dev/null - >/dev/null 2>&1 && echo yes))
+ifeq (yes,$(shell printf '${H}include <string.h>\nint
main(void){char*d,*s;strlcpy(d, s, 0);return 0;}' | $(CC) $(CFLAGS)
$(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
override CFLAGS += -DHAVE_STRLCPY
endif
# check for reallocarray(3) availability
H := \#
-ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint
main(void){reallocarray(NULL, 0, 0);return 0;}' | $(CC) -x c -o
/dev/null - >/dev/null 2>&1 && echo yes))
+ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint
main(void){reallocarray(NULL, 0, 0);return 0;}' | $(CC) $(CFLAGS)
$(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
override CFLAGS += -DHAVE_REALLOCARRAY
endif
--
2.44.0
next reply other threads:[~2024-03-01 16:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 16:32 Jordan Williams [this message]
2024-03-13 22:52 ` [PATCH] libselinux/src/Makefile: fix reallocarray strlcpy detection James Carter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d5120a64-04f3-444d-aaf8-3cfc6c1d9953@jwillikers.com \
--to=jordan@jwillikers.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).