zip: Make configure checks to be more robust

Newer compilers are strict and have turned some warnings into hard
errors which results in subtle configure check failures. Therefore fix
these tests and also enable largefile support via cflags when its
desired

(From OE-Core rev: 64e575a62ac2606e8f1037e712de66dff8156b46)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Khem Raj
2022-08-10 22:54:30 -07:00
committed by Richard Purdie
parent e2bc510623
commit 537c61b2ca
3 changed files with 171 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
From 8810f2643c9372a8083272dc1fc157427646d961 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 10 Aug 2022 17:16:23 -0700
Subject: [PATCH 1/2] configure: Specify correct function signatures and
declarations
Include needed system headers in configure tests, this is needed because
newer compilers are getting stricter about the C99 specs and turning
-Wimplicit-function-declaration into hard error e.g. clang-15+
Upstream-Status: Inactive-Upstream
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
unix/configure | 79 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 66 insertions(+), 13 deletions(-)
diff --git a/unix/configure b/unix/configure
index 1d9a9bb..f2b3d02 100644
--- a/unix/configure
+++ b/unix/configure
@@ -513,21 +513,70 @@ $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
# Check for missing functions
# add NO_'function_name' to flags if missing
-for func in rmdir strchr strrchr rename mktemp mktime mkstemp
-do
- echo Check for $func
- echo "int main(){ $func(); return 0; }" > conftest.c
- $CC $CFLAGS $LDFLAGS $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null
- [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
-done
+echo Check for rmdir
+cat > conftest.c << _EOF_
+#include <unistd.h>
+int main(){ rmdir(NULL); return 0; }
+_EOF_
+$CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_RMDIR"
+
+echo Check for strchr
+cat > conftest.c << _EOF_
+#include <string.h>
+int main(){ strchr(NULL,0); return 0; }
+_EOF_
+$CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_STRCHR"
+echo Check for strrchr
+cat > conftest.c << _EOF_
+#include <string.h>
+int main(){ strrchr(NULL,0); return 0; }
+_EOF_
+$CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_STRRCHR"
+
+echo Check for rename
+cat > conftest.c << _EOF_
+#include <stdio.h>
+int main(){ rename(NULL,NULL); return 0; }
+_EOF_
+$CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_RENAME"
+
+echo Check for mktemp
+cat > conftest.c << _EOF_
+#include <stdlib.h>
+int main(){ mktemp(NULL); return 0; }
+_EOF_
+$CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_MKTEMP"
+
+echo Check for mktime
+cat > conftest.c << _EOF_
+#include <time.h>
+int main(){ mktime(NULL); return 0; }
+_EOF_
+$CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_MKTIME"
+
+echo Check for mkstemp
+cat > conftest.c << _EOF_
+#include <stdlib.h>
+int main(){ return mkstemp(NULL); }
+_EOF_
+$CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_MKSTEMP"
echo Check for memset
-echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
+cat > conftest.c << _EOF_
+#include <string.h>
+int main(){ char k; memset(&k,0,0); return 0; }
+_EOF_
$CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM"
-
echo Check for memmove
cat > conftest.c << _EOF_
#include <string.h>
@@ -548,7 +597,7 @@ $CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
echo Check for errno declaration
cat > conftest.c << _EOF_
#include <errno.h>
-main()
+int main()
{
errno = 0;
return 0;
@@ -625,14 +674,18 @@ CFLAGS="${CFLAGS} ${OPT}"
echo Check for valloc
cat > conftest.c << _EOF_
-main()
+#include <stdlib.h>
+int main()
{
#ifdef MMAP
- valloc();
+ valloc(0);
#endif
+ return 0;
}
_EOF_
-$CC ${CFLAGS} -c conftest.c > /dev/null 2>/dev/null
+#$CC ${CFLAGS} -c conftest.c > /dev/null 2>/dev/null
+$CC ${CFLAGS} -c conftest.c
+echo "==========================================="
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_VALLOC"
--
2.37.1

View File

@@ -0,0 +1,35 @@
From 76f5bf3546d826dcbc03acbefcf0b10b972bf136 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 10 Aug 2022 17:19:38 -0700
Subject: [PATCH 2/2] unix.c: Do not redefine DIR as FILE
DIR is already provided on Linux via
/usr/include/dirent.h system header
Upstream-Status: Inactive-Upstream
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
unix/unix.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/unix/unix.c b/unix/unix.c
index ba87614..6e6f4d2 100644
--- a/unix/unix.c
+++ b/unix/unix.c
@@ -61,13 +61,11 @@ local time_t label_utim = 0;
/* Local functions */
local char *readd OF((DIR *));
-
#ifdef NO_DIR /* for AT&T 3B1 */
#include <sys/dir.h>
#ifndef dirent
# define dirent direct
#endif
-typedef FILE DIR;
/*
** Apparently originally by Rich Salz.
** Cleaned up and modified by James W. Birdsall.
--
2.37.1

View File

@@ -17,6 +17,8 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/infozip/Zip%203.x%20%28latest%29/3.0/zip30.tar.
file://0001-configure-use-correct-CPP.patch \
file://0002-configure-support-PIC-code-build.patch \
file://0001-configure-Use-CFLAGS-and-LDFLAGS-when-doing-link-tes.patch \
file://0001-configure-Specify-correct-function-signatures-and-de.patch \
file://0002-unix.c-Do-not-redefine-DIR-as-FILE.patch \
"
UPSTREAM_VERSION_UNKNOWN = "1"