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 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
|
dnl Locate ncurses or curses library
AC_DEFUN([LE_PATH_CURSES_DIRECT],
[
ncurses_h=no
for ac_dir in \
/usr/local/include/ncursesw\
/usr/local/include/ncurses\
/usr/local/include \
/usr/include/ncursesw \
/usr/include/ncurses \
/usr/include \
; \
do
if test -r "$ac_dir/curses.h"; then
no_curses=
ac_curses_includes=$ac_dir
if grep NCURSES_VERSION $ac_curses_includes/curses.h >/dev/null; then
ac_with_ncurses=yes
curses_direct_test_library=ncurses
else
ac_with_ncurses=no
curses_direct_test_library=curses
fi
break
fi
done
if test -z "$ac_curses_includes" -o "$ac_with_ncurses" = no ; then
for ac_dir in \
/usr/local/include \
/usr/include \
; \
do
if test -r "$ac_dir/ncurses.h"; then
no_curses=
ac_curses_includes=$ac_dir
ac_with_ncurses=yes
ncurses_h=yes
curses_direct_test_library=ncurses
break
fi
done
fi
# First see if replacing the include by lib works.
for ac_dir0 in `echo "$ac_curses_includes" | sed -e 's:include:lib:' -e 's:/ncurses$::'` \
/usr/lib \
/usr/local/lib \
; \
do
for ac_dir in ${ac_dir0}64 ${ac_dir0}; do
for ac_extension in so a sl; do
if test -r $ac_dir/lib${curses_direct_test_library}w.$ac_extension; then
use_libcursesw=yes
no_curses= ac_curses_libraries=$ac_dir
break 2
fi
if test -r $ac_dir/lib${curses_direct_test_library}.$ac_extension; then
no_curses= ac_curses_libraries=$ac_dir
break 2
fi
done
done
done
])
AC_DEFUN([LE_PATH_CURSES],
[AC_REQUIRE_CPP()dnl
curses_includes=NONE
curses_libraries=NONE
with_ncurses=NONE
ncurses_h=NONE
AC_MSG_CHECKING(for Curses)
dnl AC_ARG_WITH(curses, [ --with-curses enable Curses tests])
if test "x$with_curses" = xno; then
no_curses=yes
else
if test "x$curses_includes" != xNONE && test "x$curses_libraries" != xNONE \
&& test x$with_ncurses != xNONE && test x$ncurses_h != xNONE
then
no_curses=
else
AC_CACHE_VAL(ac_cv_path_curses,
[# One or both of these vars are not set, and there is no cached value.
no_curses=yes
LE_PATH_CURSES_DIRECT
if test "$no_curses" = yes; then
ac_cv_path_curses="no_curses=yes"
else
ac_cv_path_curses="no_curses= ac_curses_includes=$ac_curses_includes ac_curses_libraries=$ac_curses_libraries ac_with_ncurses=$ac_with_ncurses ncurses_h=$ncurses_h use_libcursesw=$use_libcursesw"
fi])dnl
fi
eval "$ac_cv_path_curses"
fi # with_curses != no
if test "$no_curses" = yes; then
AC_MSG_RESULT(no)
else
test "x$curses_includes" = xNONE && curses_includes=$ac_curses_includes
test "x$curses_libraries" = xNONE && curses_libraries=$ac_curses_libraries
test "x$with_ncurses" = xNONE && with_ncurses=$ac_with_ncurses
ac_cv_path_curses="no_curses= ac_curses_includes=$curses_includes ac_curses_libraries=$curses_libraries ac_with_ncurses=$with_ncurses"
if test x$ac_with_ncurses = xyes
then
AC_MSG_RESULT([Ncurses, libraries $curses_libraries, headers $curses_includes])
else
AC_MSG_RESULT([libraries $curses_libraries, headers $curses_includes])
fi
if test x$ncurses_h = xyes; then
AC_DEFINE([USE_NCURSES_H], 1, [define if ncurses.h instead of curses.h should be used])
fi
fi
])
# check if mytinfo is required for ncurses usage
AC_DEFUN([LE_MYTINFO_CHECK],
[
AC_CACHE_CHECK(whether mytinfo is required, ac_cv_need_mytinfo,
[
old_LIBS="$LIBS"
old_CFLAGS="$CFLAGS"
LIBS="$LIBS $CURSES_LIBS"
CFLAGS="$CFLAGS $CURSES_INCLUDES"
AC_TRY_LINK([
#ifdef USE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#endif],[initscr();reset_prog_mode();refresh();endwin();],[ac_cv_need_mytinfo=no],
[
LIBS="$LIBS -lmytinfo"
AC_TRY_LINK([
#ifdef USE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#endif],[initscr();reset_prog_mode();refresh();endwin();],[ac_cv_need_mytinfo=yes],
[AC_MSG_ERROR(cannot make curses work)])
])
LIBS="$old_LIBS"
CFLAGS="$old_CFLAGS"
])
if test x$ac_cv_need_mytinfo = xyes; then
CURSES_LIBS="$CURSES_LIBS -lmytinfo"
fi
])
AC_DEFUN([LE_CURSES_MOUSE],
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING(if curses provides mouse routines)
AC_CACHE_VAL(ac_cv_curses_mouse,
[
old_LIBS="$LIBS"
old_CFLAGS="$CFLAGS"
LIBS="$LIBS $CURSES_LIBS"
CFLAGS="$CFLAGS $CURSES_INCLUDES"
AC_TRY_LINK([
#ifdef USE_NCURSES_H
# include <ncurses.h>
#else
# include <curses.h>
#endif
],
[
MEVENT mev;
mousemask(ALL_MOUSE_EVENTS,0);
getmouse(&mev);
ungetmouse(&mev);
],
[ac_cv_curses_mouse=yes],
[ac_cv_curses_mouse=no])
LIBS="$old_LIBS"
CFLAGS="$old_CFLAGS"
])
AC_MSG_RESULT($ac_cv_curses_mouse)
if test x$ac_cv_curses_mouse = xyes; then
AC_DEFINE([WITH_MOUSE], 1, [define if curses provides mouse interface])
fi
AC_LANG_RESTORE
])
AC_DEFUN([LE_NCURSES_BUGS],
[
if test x$ac_with_ncurses = xyes; then
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING(if ncurses has correct CXX_TYPE_OF_BOOL)
AC_CACHE_VAL(ac_cv_ncurses_correct_bool,
[
old_LIBS="$LIBS"
old_CFLAGS="$CFLAGS"
LIBS="$LIBS $CURSES_LIBS"
CFLAGS="$CFLAGS $CURSES_INCLUDES"
AC_TRY_RUN([
#ifdef USE_NCURSES_H
# include <ncurses.h>
#else
# include <curses.h>
#endif
int main()
{
#ifdef CXX_TYPE_OF_BOOL
return sizeof(CXX_TYPE_OF_BOOL)==sizeof(bool)?0:1;
#else
return 0;
#endif
}
],
[ac_cv_ncurses_correct_bool=yes],
[ac_cv_ncurses_correct_bool=no],
[ac_cv_ncurses_correct_bool=yes])
LIBS="$old_LIBS"
CFLAGS="$old_CFLAGS"
])
AC_MSG_RESULT($ac_cv_ncurses_correct_bool)
if test x$ac_cv_ncurses_correct_bool = xno; then
AC_MSG_ERROR(ncurses misconfigured - wrong CXX_TYPE_OF_BOOL)
fi
AC_LANG_RESTORE
fi
])
dnl determine curses' bool actual type
AC_DEFUN([LE_CURSES_BOOL],
[
AC_MSG_CHECKING(whether curses defines bool type in C++)
AC_CACHE_VAL(ac_cv_curses_bool_defined,
[
old_LIBS="$LIBS"
old_CXXFLAGS="$CXXFLAGS"
LIBS="$LIBS $CURSES_LIBS"
CXXFLAGS="$CXXFLAGS $CURSES_INCLUDES"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([
#define bool LE_CURSES_BOOL
#ifdef USE_NCURSES_H
# include <ncurses.h>
#else
# include <curses.h>
#endif
],
[LE_CURSES_BOOL var=0;],
[ac_cv_curses_bool_defined=yes],
[ac_cv_curses_bool_defined=no])
AC_LANG_RESTORE
LIBS="$old_LIBS"
CXXFLAGS="$old_CXXFLAGS"
])
AC_MSG_RESULT($ac_cv_curses_bool_defined)
if test "$ac_cv_curses_bool_defined" = no; then
AC_MSG_CHECKING(for curses bool type)
AC_CACHE_VAL(ac_cv_curses_bool,
[
old_LIBS="$LIBS"
old_CFLAGS="$CFLAGS"
LIBS="$LIBS $CURSES_LIBS"
CFLAGS="$CFLAGS $CURSES_INCLUDES"
AC_TRY_RUN([
#ifdef USE_NCURSES_H
# include <ncurses.h>
#else
# include <curses.h>
#endif
int main()
{
FILE *fp = fopen("cf_test.out", "w");
if (fp != 0) {
bool x = TRUE;
if ((-x) >= 0)
fputs("unsigned ", fp);
if (sizeof(x) == sizeof(int)) fputs("int", fp);
else if (sizeof(x) == sizeof(char)) fputs("char", fp);
else if (sizeof(x) == sizeof(short))fputs("short",fp);
else if (sizeof(x) == sizeof(long)) fputs("long", fp);
else fputs("unknown",fp);
fclose(fp);
}
return(0);
}
],
[ac_cv_curses_bool="`cat cf_test.out`"
case "$ac_cv_curses_bool" in
*unknown*) ac_cv_curses_bool=unknown;;
esac
],
[ac_cv_curses_bool=unknown]
[ac_cv_curses_bool=unknown])
rm -f cf_test.out
LIBS="$old_LIBS"
CFLAGS="$old_CFLAGS"
])
AC_MSG_RESULT($ac_cv_curses_bool)
if test "x$ac_cv_curses_bool" != xunknown; then
AC_DEFINE_UNQUOTED([LE_CURSES_BOOL_TYPE],$ac_cv_curses_bool,[define to the type used as curses internal bool type])
fi
fi
])
AC_DEFUN([LE_CURSES_WIDECHAR],
[
AC_MSG_CHECKING(whether curses supports cchar_t)
AC_CACHE_VAL(ac_cv_curses_widechar,
[
old_CFLAGS="$CFLAGS"
old_LIBS="$LIBS"
CFLAGS="$CFLAGS $CURSES_INCLUDES"
LIBS="$LIBS $CURSES_LIBS"
AC_TRY_LINK([
#define _XOPEN_SOURCE_EXTENDED
#ifdef USE_NCURSES_H
# include <ncurses.h>
#else
# include <curses.h>
#endif],
[cchar_t c;mvadd_wchnstr(0,0,&c,1);],
[ac_cv_curses_widechar=yes],
[ac_cv_curses_widechar=no])
CFLAGS="$old_CFLAGS"
LIBS="$old_LIBS"
])
AC_MSG_RESULT($ac_cv_curses_widechar)
if test x$ac_cv_curses_widechar = xyes; then
AC_DEFINE([USE_MULTIBYTE_CHARS], 1, [Define to enable multibyte support])
fi
])
dnl check if c++ compiler can use dynamic initializers for static variables
AC_DEFUN([CXX_DYNAMIC_INITIALIZERS],
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING(if c++ compiler can handle dynamic initializers)
AC_TRY_RUN(
[
int f() { return 1; }
int a=f();
int main()
{
return(1-a);
}
],
[cxx_dynamic_init=yes],
[cxx_dynamic_init=no],
[cxx_dynamic_init=yes])
AC_MSG_RESULT($cxx_dynamic_init)
if test x$cxx_dynamic_init = xno; then
AC_MSG_ERROR(C++ compiler cannot handle dynamic initializers of static objects)
fi
AC_LANG_RESTORE
])
AC_DEFUN([LE_CHECK_REGEX_BUGS],[
AC_CACHE_CHECK([for good GNU regex in libc], le_cv_good_gnu_regex,
le_cv_good_gnu_regex=yes
AC_TRY_RUN([
#include <stdio.h>
#include <string.h>
#include <regex.h>
int main()
{
struct re_pattern_buffer rexp_c;
struct re_registers regs;
char *rexp;
char *buf;
int bs;
/* check for completely broken re_search_2 in redhat-6.0(?) */
memset(&rexp_c,0,sizeof(rexp_c));
memset(®s,0,sizeof(regs));
rexp="b";
buf="123abc";
bs=strlen(buf);
re_compile_pattern(rexp,strlen(rexp),&rexp_c);
if(re_search_2(&rexp_c,buf,bs,"",0,0,bs,0,bs)!=4)
return 1;
/* check for a segfault in default redhat-8.0 glibc (2.2.93-5) */
memset(&rexp_c,0,sizeof(rexp_c));
memset(®s,0,sizeof(regs));
rexp="/\\\\*([[^*]]|\\\\*[[^/]])*\\\\*/";
buf="/*a\\nb\\nc*/\\n";
bs=strlen(buf);
re_syntax_options=RE_NO_BK_VBAR|RE_NO_BK_PARENS;
re_compile_pattern(rexp,strlen(rexp),&rexp_c);
re_search_2(&rexp_c,buf,bs,"",0,0,bs,®s,bs);
return 0;
}
], , le_cv_good_gnu_regex=no)
)
if test x$le_cv_good_gnu_regex = xno; then
am_cv_gnu_regex=no
fi
])
# AM_WITH_REGEX
# -------------
#
# The idea is to distribute rx.[hc] and regex.[hc] together, for a
# while. The WITH_REGEX symbol is used to decide which of regex.h or
# rx.h should be included in the application. If `./configure
# --with-regex' is given (the default), the package will use gawk's
# regex. If `./configure --without-regex', a check is made to see if
# rx is already installed, as with newer Linux'es. If not found, the
# package will use the rx from the distribution. If found, the
# package will use the system's rx which, on Linux at least, will
# result in a smaller executable file.
#
# FIXME: This macro seems quite obsolete now since rx doesn't seem to
# be maintained, while regex is.
AC_DEFUN([AM_WITH_REGEX],
[AC_LIBSOURCES([rx.h, rx.c, regex.c, regex.h])dnl
AC_MSG_CHECKING([which of GNU rx or gawk's regex is wanted])
AC_ARG_WITH(regex,
[ --without-regex use GNU rx in lieu of gawk's regex for matching],
[test "$withval" = yes && am_with_regex=1],
[am_with_regex=1])
if test -n "$am_with_regex"; then
AC_MSG_RESULT(regex)
AC_DEFINE([WITH_REGEX], 1, [Define if using GNU regex])
AC_CACHE_CHECK([for GNU regex in libc], am_cv_gnu_regex,
[AC_TRY_LINK([],
[extern int re_max_failures; re_max_failures = 1],
[am_cv_gnu_regex=yes],
[am_cv_gnu_regex=no])])
if test $am_cv_gnu_regex = no; then
AC_LIBOBJ([regex])
fi
else
AC_MSG_RESULT(rx)
AC_CHECK_FUNC(re_rx_search, , [AC_LIBOBJ([rx])])
fi
])
|