blob: f7e0854cd9f72efd4b6ee96102094a9a58453b97 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 5ac5885d35257888d0e4a9dda903405314f9fc84 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 10 Aug 2022 17:53:13 -0700
4Subject: [PATCH] configure: Add correct system headers and prototypes to tests
5
6Newer compilers e.g. clang-15+ have turned stricter towards these
7warnings and turned them into errors which results in subtle failures
8during build, therefore make the testcases use the needed headers and
9modern C
10
11Upstream-Status: Inactive-Upstream
12
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 unix/configure | 51 +++++++++++++++++++++++++++++++++++++++-----------
16 1 file changed, 40 insertions(+), 11 deletions(-)
17
18diff --git a/unix/configure b/unix/configure
19index 49579f3..8fd82dd 100755
20--- a/unix/configure
21+++ b/unix/configure
22@@ -379,14 +379,37 @@ $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
23
24 # Check for missing functions
25 # add NO_'function_name' to flags if missing
26-for func in fchmod fchown lchown nl_langinfo
27-do
28- echo Check for $func
29- echo "int main(){ $func(); return 0; }" > conftest.c
30- $CC $BFLAG $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
31- [ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
32-done
33+echo Check for fchmod
34+cat > conftest.c << _EOF_
35+#include <sys/stat.h>
36+int main(){ fchmod(0,0); return 0; }
37+_EOF_
38+$CC $BFLAG $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
39+[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_FCHMOD"
40
41+echo Check for fchown
42+cat > conftest.c << _EOF_
43+#include <unistd.h>
44+int main(){ fchown(0,0,0); return 0; }
45+_EOF_
46+$CC $BFLAG $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
47+[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_FCHOWN"
48+
49+echo Check for lchown
50+cat > conftest.c << _EOF_
51+#include <unistd.h>
52+int main(){ lchown(NULL,0,0); return 0; }
53+_EOF_
54+$CC $BFLAG $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
55+[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_LCHOWN"
56+
57+echo Check for nl_langinfo
58+cat > conftest.c << _EOF_
59+#include <langinfo.h>
60+int main(){ nl_langinfo(0); return 0; }
61+_EOF_
62+$CC $BFLAG $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
63+[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_NL_LANGINFO"
64 # Check (seriously) for a working lchmod.
65 echo 'Check for lchmod'
66 temp_file="/tmp/unzip_test_$$"
67@@ -401,14 +424,17 @@ ln -s "${temp_link}" "${temp_file}" && \
68 rm -f "${temp_file}"
69
70 echo Check for memset
71-echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
72+cat > conftest.c << _EOF_
73+#include <string.h>
74+int main(){ char k; memset(&k,0,0); return 0; }
75+_EOF_
76 $CC $CFLAGS $LDFLAGS -o conftest conftest.c >/dev/null 2>/dev/null
77 [ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DZMEM"
78
79 echo Check for errno declaration
80 cat > conftest.c << _EOF_
81 #include <errno.h>
82-main()
83+int main()
84 {
85 errno = 0;
86 return 0;
87@@ -419,6 +445,8 @@ $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
88
89 echo Check for directory libraries
90 cat > conftest.c << _EOF_
91+#include <sys/types.h>
92+#include <dirent.h>
93 int main() { return closedir(opendir(".")); }
94 _EOF_
95
96@@ -523,10 +551,11 @@ fi
97 # needed for AIX (and others ?) when mmap is used
98 echo Check for valloc
99 cat > conftest.c << _EOF_
100-main()
101+#include <stdlib.h>
102+int main()
103 {
104 #ifdef MMAP
105- valloc();
106+ valloc(0);
107 #endif
108 }
109 _EOF_
110--
1112.37.1
112