1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
From: Helmut Grohne <helmut@subdivi.de>
Subject: make cross compilation work
This patch essentially replaces most AC_TRY_RUN with something "better".
Dependening on the use case that may be AC_TRY_COMPILE, AC_COMPUTE_INT or even
AC_CHECK_TYPE. Uses beyond cross compilation:
* Significant simplification of the code.
* Some checks become cacheable.
Index: expect-5.45/configure.in
===================================================================
--- expect-5.45.orig/configure.in
+++ expect-5.45/configure.in
@@ -467,47 +467,32 @@
# and if so that WNOHANG is not defined. The only place I've
# seen this is ISC.
AC_MSG_CHECKING([if WNOHANG requires _POSIX_SOURCE])
-AC_TRY_RUN([
+AC_TRY_COMPILE([
#include <sys/wait.h>
-main() {
+],[
#ifndef WNOHANG
- return 0;
-#else
- return 1;
+#error WNOHANG missing
#endif
-}],
- AC_MSG_RESULT(yes)
- AC_DEFINE(WNOHANG_REQUIRES_POSIX_SOURCE)
-,
+],
AC_MSG_RESULT(no)
,
- AC_MSG_ERROR([Expect can't be cross compiled])
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(WNOHANG_REQUIRES_POSIX_SOURCE)
)
AC_MSG_CHECKING([if any value exists for WNOHANG])
rm -rf wnohang
-AC_TRY_RUN([
+AC_COMPUTE_INT(WNOHANG_BACKUP_VALUE, WNOHANG, [
#include <stdio.h>
#include <sys/wait.h>
-main() {
-#ifdef WNOHANG
- FILE *fp = fopen("wnohang","w");
- fprintf(fp,"%d",WNOHANG);
- fclose(fp);
- return 0;
-#else
- return 1;
-#endif
-}],
- AC_MSG_RESULT(yes)
- AC_DEFINE_UNQUOTED(WNOHANG_BACKUP_VALUE, `cat wnohang`)
- rm -f wnohang
-,
- AC_MSG_RESULT(no)
+],[WNOHANG_BACKUP_VALUE=no])
+if "$WNOHANG_BACKUP_VALUE" = "no"; then
AC_DEFINE(WNOHANG_BACKUP_VALUE, 1)
-,
- AC_MSG_ERROR([Expect can't be cross compiled])
-)
+ AC_MSG_RESULT(no)
+else
+ AC_DEFINE_UNQUOTED(WNOHANG_BACKUP_VALUE, [$WNOHANG_BACKUP_VALUE])
+ AC_MSG_RESULT(yes)
+fi
#
# check how signals work
@@ -711,22 +696,12 @@
fi
# first check for the pure bsd
-AC_MSG_CHECKING([for struct sgttyb])
-AC_TRY_RUN([
-#include <sgtty.h>
-main()
-{
- struct sgttyb tmp;
- exit(0);
-}],
- AC_MSG_RESULT(yes)
+AC_CHECK_TYPE([struct sgttyb],[
AC_DEFINE(HAVE_SGTTYB)
PTY_TYPE=sgttyb
-,
- AC_MSG_RESULT(no)
-,
- AC_MSG_ERROR([Expect can't be cross compiled])
-)
+],[],[
+#include <sgtty.h>
+])
# mach systems have include files for unimplemented features
# so avoid doing following test on those systems
@@ -736,109 +711,77 @@
# note that if we detect termio.h (only), we still set PTY_TYPE=termios
# since that just controls which of pty_XXXX.c file is use and
# pty_termios.c is set up to handle pty_termio.
- AC_MSG_CHECKING([for struct termio])
- AC_TRY_RUN([#include <termio.h>
- main()
- {
- struct termio tmp;
- exit(0);
- }],
+ AC_CHECK_TYPE([struct termio],[
AC_DEFINE(HAVE_TERMIO)
PTY_TYPE=termios
- AC_MSG_RESULT(yes)
-,
- AC_MSG_RESULT(no)
-,
- AC_MSG_ERROR([Expect can't be cross compiled])
-)
+],[],[
+#include <termio.h>
+])
# now check for the new style ttys (not yet posix)
- AC_MSG_CHECKING([for struct termios])
- AC_TRY_RUN([
+ AC_CHECK_TYPE([struct termios],[
+ AC_DEFINE(HAVE_TERMIOS)
+ PTY_TYPE=termios
+ ],[],[
/* including termios.h on Solaris 5.6 fails unless inttypes.h included */
# ifdef HAVE_INTTYPES_H
# include <inttypes.h>
# endif
# include <termios.h>
- main()
- {
- struct termios tmp;
- exit(0);
- }],
- AC_DEFINE(HAVE_TERMIOS)
- PTY_TYPE=termios
- AC_MSG_RESULT(yes)
- ,
- AC_MSG_RESULT(no)
- ,
- AC_MSG_ERROR([Expect can't be cross compiled])
- )
+ ])
fi
AC_MSG_CHECKING([if TCGETS or TCGETA in termios.h])
-AC_TRY_RUN([
+AC_TRY_COMPILE([
/* including termios.h on Solaris 5.6 fails unless inttypes.h included */
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <termios.h>
-main() {
+],[
#if defined(TCGETS) || defined(TCGETA)
- return 0;
#else
- return 1;
+#error missing
#endif
-}],
+],[
AC_DEFINE(HAVE_TCGETS_OR_TCGETA_IN_TERMIOS_H)
AC_MSG_RESULT(yes)
-,
+],[
AC_MSG_RESULT(no)
-,
- AC_MSG_ERROR([Expect can't be cross compiled])
-)
+])
AC_MSG_CHECKING([if TIOCGWINSZ in termios.h])
-AC_TRY_RUN([
+AC_TRY_COMPILE([
/* including termios.h on Solaris 5.6 fails unless inttypes.h included */
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <termios.h>
-main() {
-#ifdef TIOCGWINSZ
- return 0;
-#else
- return 1;
+],[
+#ifndef TIOCGWINSZ
+#error missing
#endif
-}],
+],[
AC_DEFINE(HAVE_TIOCGWINSZ_IN_TERMIOS_H)
AC_MSG_RESULT(yes)
-,
+],[
AC_MSG_RESULT(no)
-,
- AC_MSG_ERROR([Expect can't be cross compiled])
-)
+])
# finally check for Cray style ttys
AC_MSG_CHECKING([for Cray-style ptys])
SETUID=":"
-AC_TRY_RUN([
-main(){
-#ifdef CRAY
- return 0;
-#else
- return 1;
+AC_TRY_COMPILE([],[
+#ifndef CRAY
+#error missing
#endif
-}
-],
+],[
PTY_TYPE=unicos
SETUID="chmod u+s"
AC_MSG_RESULT(yes)
-,
+],[
AC_MSG_RESULT(no)
-,
- AC_MSG_ERROR([Expect can't be cross compiled])
-)
+])
#
# Check for select and/or poll. If both exist, we prefer select.
@@ -875,21 +818,16 @@
# check for timezones
#
AC_MSG_CHECKING([for SV-style timezone])
-AC_TRY_RUN([
+AC_TRY_COMPILE([
extern char *tzname[2];
extern int daylight;
-main()
-{
+],[
int *x = &daylight;
char **y = tzname;
-
- exit(0);
-}],
+],
AC_DEFINE(HAVE_SV_TIMEZONE)
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
-,
- AC_MSG_ERROR([Expect can't be cross compiled])
)
|