Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | From 4e102de2e6204c1d8e8be00bb5ffd4587e70350c Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 15 Aug 2022 10:35:53 -0700 |
| 4 | Subject: [PATCH] configure: Add needed system headers in checks |
| 5 | |
| 6 | Newer compilers throw warnings when a funciton is used with implicit |
| 7 | declaration and enabling -Werror can silently fail these tests and |
| 8 | result in wrong configure results. Therefore add the needed headers in |
| 9 | the AC_TRY_LINK macros |
| 10 | |
| 11 | * configure.ac: Add missing system headers in AC_TRY_LINK. |
| 12 | |
| 13 | Upstream-Status: Submitted [https://lists.gnu.org/archive/html/screen-devel/2022-08/msg00000.html] |
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 15 | --- |
| 16 | configure.ac | 57 +++++++++++++++++++++++++++++++++++++++------------- |
| 17 | 1 file changed, 43 insertions(+), 14 deletions(-) |
| 18 | |
| 19 | diff --git a/configure.ac b/configure.ac |
| 20 | index c0f02df..d308079 100644 |
| 21 | --- a/configure.ac |
| 22 | +++ b/configure.ac |
| 23 | @@ -233,6 +233,7 @@ AC_CHECKING(BSD job jontrol) |
| 24 | AC_TRY_LINK( |
| 25 | [#include <sys/types.h> |
| 26 | #include <sys/ioctl.h> |
| 27 | +#include <unistd.h> |
| 28 | ], [ |
| 29 | #ifdef POSIX |
| 30 | tcsetpgrp(0, 0); |
| 31 | @@ -250,12 +251,16 @@ dnl |
| 32 | dnl **** setresuid(), setreuid(), seteuid() **** |
| 33 | dnl |
| 34 | AC_CHECKING(setresuid) |
| 35 | -AC_TRY_LINK(,[ |
| 36 | -setresuid(0, 0, 0); |
| 37 | +AC_TRY_LINK([ |
| 38 | +#include <unistd.h> |
| 39 | +],[ |
| 40 | +return setresuid(0, 0, 0); |
| 41 | ], AC_DEFINE(HAVE_SETRESUID)) |
| 42 | AC_CHECKING(setreuid) |
| 43 | -AC_TRY_LINK(,[ |
| 44 | -setreuid(0, 0); |
| 45 | +AC_TRY_LINK([ |
| 46 | +#include <unistd.h> |
| 47 | +],[ |
| 48 | +return setreuid(0, 0); |
| 49 | ], AC_DEFINE(HAVE_SETREUID)) |
| 50 | dnl |
| 51 | dnl seteuid() check: |
| 52 | @@ -274,7 +279,9 @@ seteuid(0); |
| 53 | |
| 54 | dnl execvpe |
| 55 | AC_CHECKING(execvpe) |
| 56 | -AC_TRY_LINK(,[ |
| 57 | +AC_TRY_LINK([ |
| 58 | + #include <unistd.h> |
| 59 | +],[ |
| 60 | execvpe(0, 0, 0); |
| 61 | ], AC_DEFINE(HAVE_EXECVPE) |
| 62 | CFLAGS="$CFLAGS -D_GNU_SOURCE") |
| 63 | @@ -284,10 +291,18 @@ dnl **** select() **** |
| 64 | dnl |
| 65 | |
| 66 | AC_CHECKING(select) |
| 67 | -AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, |
| 68 | +AC_TRY_LINK([ |
| 69 | + #include <sys/select.h> |
| 70 | +],[ |
| 71 | + select(0, 0, 0, 0, 0); |
| 72 | +],, |
| 73 | LIBS="$LIBS -lnet -lnsl" |
| 74 | AC_CHECKING(select with $LIBS) |
| 75 | -AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, |
| 76 | +AC_TRY_LINK([ |
| 77 | + #include <sys/select.h> |
| 78 | +],[ |
| 79 | + select(0, 0, 0, 0, 0); |
| 80 | +],, |
| 81 | AC_MSG_ERROR(!!! no select - no screen)) |
| 82 | ) |
| 83 | dnl |
| 84 | @@ -624,11 +639,19 @@ dnl |
| 85 | dnl **** termcap or terminfo **** |
| 86 | dnl |
| 87 | AC_CHECKING(for tgetent) |
| 88 | -AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, |
| 89 | +AC_TRY_LINK([ |
| 90 | + #include <curses.h> |
| 91 | + #include <term.h> |
| 92 | +],[ |
| 93 | + tgetent((char *)0, (char *)0); |
| 94 | +],, |
| 95 | olibs="$LIBS" |
| 96 | LIBS="-lcurses $olibs" |
| 97 | AC_CHECKING(libcurses) |
| 98 | -AC_TRY_LINK(,[ |
| 99 | +AC_TRY_LINK([ |
| 100 | + #include <curses.h> |
| 101 | + #include <term.h> |
| 102 | +],[ |
| 103 | #ifdef __hpux |
| 104 | __sorry_hpux_libcurses_is_totally_broken_in_10_10(); |
| 105 | #else |
| 106 | @@ -871,7 +894,7 @@ test -f /usr/lib/libutil.a && LIBS="$LIBS -lutil" |
| 107 | fi |
| 108 | |
| 109 | AC_CHECKING(getloadavg) |
| 110 | -AC_TRY_LINK(,[getloadavg((double *)0, 0);], |
| 111 | +AC_TRY_LINK([#include <stdlib.h>],[getloadavg((double *)0, 0);], |
| 112 | AC_DEFINE(LOADAV_GETLOADAVG) load=1, |
| 113 | if test "$cross_compiling" = no && test -f /usr/lib/libkvm.a ; then |
| 114 | olibs="$LIBS" |
| 115 | @@ -1109,10 +1132,10 @@ AC_CHECKING(IRIX sun library) |
| 116 | AC_TRY_LINK(,,,LIBS="$oldlibs") |
| 117 | |
| 118 | AC_CHECKING(syslog) |
| 119 | -AC_TRY_LINK(,[closelog();], , [oldlibs="$LIBS" |
| 120 | +AC_TRY_LINK([#include <syslog.h>],[closelog();], , [oldlibs="$LIBS" |
| 121 | LIBS="$LIBS -lbsd" |
| 122 | AC_CHECKING(syslog in libbsd.a) |
| 123 | -AC_TRY_LINK(, [closelog();], AC_NOTE(- found.), [LIBS="$oldlibs" |
| 124 | +AC_TRY_LINK([#include <syslog.h>], [closelog();], AC_NOTE(- found.), [LIBS="$oldlibs" |
| 125 | AC_NOTE(- bad news: syslog missing.) AC_DEFINE(NOSYSLOG)])]) |
| 126 | |
| 127 | AC_EGREP_CPP(YES_IS_DEFINED, |
| 128 | @@ -1149,7 +1172,7 @@ AC_CHECKING(getspnam) |
| 129 | AC_TRY_LINK([#include <shadow.h>], [getspnam("x");],AC_DEFINE(SHADOWPW)) |
| 130 | |
| 131 | AC_CHECKING(getttyent) |
| 132 | -AC_TRY_LINK(,[getttyent();], AC_DEFINE(GETTTYENT)) |
| 133 | +AC_TRY_LINK([#include <ttyent.h>],[getttyent();], AC_DEFINE(GETTTYENT)) |
| 134 | |
| 135 | AC_CHECKING(fdwalk) |
| 136 | AC_TRY_LINK([#include <stdlib.h>], [fdwalk(NULL, NULL);],AC_DEFINE(HAVE_FDWALK)) |
| 137 | @@ -1204,7 +1227,13 @@ main() { |
| 138 | AC_SYS_LONG_FILE_NAMES |
| 139 | |
| 140 | AC_MSG_CHECKING(for vsprintf) |
| 141 | -AC_TRY_LINK([#include <stdarg.h>],[va_list valist; vsprintf(0,0,valist);], AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no)) |
| 142 | +AC_TRY_LINK([ |
| 143 | + #include <stdarg.h> |
| 144 | + #include <stdio.h> |
| 145 | +],[ |
| 146 | + va_list valist; |
| 147 | + vsprintf(0,0,valist); |
| 148 | +], AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no)) |
| 149 | |
| 150 | AC_HEADER_DIRENT |
| 151 | |