File: configure.in

package info (click to toggle)
less 332-4
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 956 kB
  • ctags: 1,145
  • sloc: ansic: 13,030; sh: 185; makefile: 116; awk: 7
file content (199 lines) | stat: -rw-r--r-- 6,425 bytes parent folder | download | duplicates (2)
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
dnl Process this file with autoconf to produce a configure script.
AC_INIT(forwback.c)
AC_CONFIG_HEADER(defines.h)

dnl Checks for programs.
AC_PROG_CC
AC_ISC_POSIX
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL

dnl Checks for libraries.
AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
dnl Regular expressions (regcmp) are in -lgen on Solaris 2,
dnl and in -lintl on SCO Unix.
AC_CHECK_LIB(gen, regcmp)
AC_CHECK_LIB(intl, regcmp)
AC_CHECK_LIB(PW, regcmp)

dnl Checks for terminal libraries
dnl Solaris has curses & termcap, but they need libucb
dnl which is broken, so we use termlib.

AC_MSG_CHECKING(for working terminal libraries)
TERMLIBS=
if test $have_ncurses = yes; then
  TERMLIBS="$TERMLIBS -lncurses"
  dnl Don't use -ltermcap with -lncurses (Linux doesn't like it).
else
  if test $have_curses = yes; then
    TERMLIBS="$TERMLIBS -lcurses"
  fi
  if test $have_termcap = yes; then
    TERMLIBS="$TERMLIBS -ltermcap"
  fi
fi

SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
AC_TRY_LINK(, [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
  [termok=yes], [termok=no])
if test $termok = yes; then
  AC_MSG_RESULT(using $TERMLIBS)
else
  LIBS="$SAVE_LIBS"
  if test $have_termlib = yes; then
    LIBS="$LIBS -ltermlib"
    AC_MSG_RESULT(using -ltermlib)
  else
    AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
    exit 1
  fi
fi

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(ctype.h errno.h fcntl.h limits.h stdio.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h)

dnl Checks for identifiers.
AC_TYPE_OFF_T
AC_MSG_CHECKING(for void)
AC_TRY_COMPILE(, [void *foo = 0;], 
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for const)
AC_TRY_COMPILE(, [const int foo = 0;], 
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for time_t)
AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])

dnl Checks for functions and external variables.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(memcpy popen _setjmp sigsetmask stat strchr system)

dnl Some systems have termios.h but not the corresponding functions.
AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))

AC_MSG_CHECKING(for fileno)
AC_TRY_LINK([
#if HAVE_STDIO_H
#include <stdio.h>
#endif], [static int x; x = fileno(stdin);],
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for strerror)
AC_TRY_LINK([
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#endif], [static char *x; x = strerror(0);],
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for sys_errlist)
AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], 
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])

have_errno=no
AC_MSG_CHECKING(for errno)
AC_TRY_LINK([
#if HAVE_ERRNO_H
#include <errno.h>
#endif], [static int x; x = errno;], 
  [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
if test $have_errno = no; then
AC_TRY_LINK([
#if HAVE_ERRNO_H
#include <errno.h>
#endif], [extern int errno; static int x; x = errno;], 
  [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
  [AC_MSG_RESULT(no)])
fi

AC_MSG_CHECKING(for locale)
AC_TRY_LINK([#include <locale.h>
#include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for ctype functions)
AC_TRY_LINK([
#if HAVE_CTYPE_H
#include <ctype.h>
#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])

dnl Checks for external variable ospeed in the termcap library.
have_ospeed=no
AC_MSG_CHECKING(termcap for ospeed)
AC_TRY_LINK([
#include <sys/types.h>
#if HAVE_TERMIOS_H
#include <termios.h>
#endif
#if HAVE_TERMCAP_H
#include <termcap.h>
#endif], [ospeed = 0;],
[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
if test $have_ospeed = no; then
AC_TRY_LINK(, [extern short ospeed; ospeed = 0;], 
  [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
  [AC_MSG_RESULT(no)])
fi

dnl Checks for regular expression functions.
have_regex=no
have_posix_regex=unknown
AC_MSG_CHECKING(for regcomp)
dnl Some versions of Solaris have a regcomp() function, but it doesn't work!
dnl So we run a test program.  If we're cross-compiling, do it the old way.
AC_TRY_RUN([
#include <sys/types.h>
#include <regex.h>
main() { regex_t r; regmatch_t rm;
if (regcomp(&r, "abc", 0)) exit(1);
if (regexec(&r, "xabcy", 1, &rm, 0)) exit(1);
exit(0); }],
  have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
if test $have_posix_regex = yes; then
  AC_MSG_RESULT(using POSIX regcomp)
  AC_DEFINE(HAVE_POSIX_REGCOMP)
  have_regex=yes
elif test $have_posix_regex = unknown; then
  AC_TRY_LINK([
#include <sys/types.h>
#include <regex.h>],
  [regex_t *r; regfree(r);],
  AC_MSG_RESULT(using POSIX regcomp)
  AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
else
  AC_MSG_RESULT(no)
fi
if test $have_regex = no; then
AC_CHECK_FUNC(regcmp, 
AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
fi
if test $have_regex = no; then
AC_TRY_LINK([
#include "regexp.h"], [regcomp("");],
AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
fi
if test $have_regex = no && test -f ${srcdir}/regex.c; then
AC_MSG_RESULT(using POSIX regcomp -- local source); AC_DEFINE(HAVE_POSIX_REGCOMP) REGEX_O='regex.$(O)' AC_SUBST(REGEX_O) have_regex=yes
fi
if test $have_regex = no && test -f ${srcdir}/regexp.c; then
AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
fi
if test $have_regex = no; then
AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
fi
if test $have_regex = no; then
AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
fi

AC_OUTPUT(Makefile)