1dnl*************************************************************************** 2dnl Copyright (c) 1998-2000 Free Software Foundation, Inc. * 3dnl * 4dnl Permission is hereby granted, free of charge, to any person obtaining a * 5dnl copy of this software and associated documentation files (the * 6dnl "Software"), to deal in the Software without restriction, including * 7dnl without limitation the rights to use, copy, modify, merge, publish, * 8dnl distribute, distribute with modifications, sublicense, and/or sell * 9dnl copies of the Software, and to permit persons to whom the Software is * 10dnl furnished to do so, subject to the following conditions: * 11dnl * 12dnl The above copyright notice and this permission notice shall be included * 13dnl in all copies or substantial portions of the Software. * 14dnl * 15dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 16dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 17dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 18dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 19dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 20dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 21dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 22dnl * 23dnl Except as contained in this notice, the name(s) of the above copyright * 24dnl holders shall not be used in advertising or otherwise to promote the * 25dnl sale, use or other dealings in this Software without prior written * 26dnl authorization. * 27dnl*************************************************************************** 28dnl 29dnl Author: Thomas E. Dickey 1996,1997,1998,1999,2000 30dnl 31dnl $Id: aclocal.m4,v 1.235 2000/10/08 01:01:40 tom Exp $ 32dnl Macros used in NCURSES auto-configuration script. 33dnl 34dnl See http://dickey.his.com/autoconf/ for additional information. 35dnl 36dnl --------------------------------------------------------------------------- 37dnl --------------------------------------------------------------------------- 38dnl Construct the list of include-options for the C programs in the Ada95 39dnl binding. 40AC_DEFUN([CF_ADA_INCLUDE_DIRS], 41[ 42ACPPFLAGS="$ACPPFLAGS -I. -I../../include" 43if test "$srcdir" != "."; then 44 ACPPFLAGS="$ACPPFLAGS -I\$(srcdir)/../../include" 45fi 46if test "$GCC" != yes; then 47 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)" 48elif test "$includedir" != "/usr/include"; then 49 if test "$includedir" = '${prefix}/include' ; then 50 if test $prefix != /usr ; then 51 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)" 52 fi 53 else 54 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)" 55 fi 56fi 57AC_SUBST(ACPPFLAGS) 58])dnl 59dnl --------------------------------------------------------------------------- 60dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES' 61dnl in the sharutils 4.2 distribution. 62AC_DEFUN([CF_ANSI_CC_CHECK], 63[ 64AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) 65AC_CACHE_VAL(cf_cv_ansi_cc,[ 66cf_cv_ansi_cc=no 67cf_save_CFLAGS="$CFLAGS" 68# Don't try gcc -ansi; that turns off useful extensions and 69# breaks some systems' header files. 70# AIX -qlanglvl=ansi 71# Ultrix and OSF/1 -std1 72# HP-UX -Aa -D_HPUX_SOURCE 73# SVR4 -Xc 74# UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes) 75for cf_arg in "-DCC_HAS_PROTOS" \ 76 "" \ 77 -qlanglvl=ansi \ 78 -std1 \ 79 -Ae \ 80 "-Aa -D_HPUX_SOURCE" \ 81 -Xc 82do 83 CFLAGS="$cf_save_CFLAGS $cf_arg" 84 AC_TRY_COMPILE( 85[ 86#ifndef CC_HAS_PROTOS 87#if !defined(__STDC__) || (__STDC__ != 1) 88choke me 89#endif 90#endif 91],[ 92 int test (int i, double x); 93 struct s1 {int (*f) (int a);}; 94 struct s2 {int (*f) (double a);};], 95 [cf_cv_ansi_cc="$cf_arg"; break]) 96done 97CFLAGS="$cf_save_CFLAGS" 98]) 99AC_MSG_RESULT($cf_cv_ansi_cc) 100 101if test "$cf_cv_ansi_cc" != "no"; then 102if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then 103 CFLAGS="$CFLAGS $cf_cv_ansi_cc" 104else 105 AC_DEFINE(CC_HAS_PROTOS) 106fi 107fi 108])dnl 109dnl --------------------------------------------------------------------------- 110dnl For programs that must use an ANSI compiler, obtain compiler options that 111dnl will make it recognize prototypes. We'll do preprocessor checks in other 112dnl macros, since tools such as unproto can fake prototypes, but only part of 113dnl the preprocessor. 114AC_DEFUN([CF_ANSI_CC_REQD], 115[AC_REQUIRE([CF_ANSI_CC_CHECK]) 116if test "$cf_cv_ansi_cc" = "no"; then 117 AC_ERROR( 118[Your compiler does not appear to recognize prototypes. 119You have the following choices: 120 a. adjust your compiler options 121 b. get an up-to-date compiler 122 c. use a wrapper such as unproto]) 123fi 124])dnl 125dnl --------------------------------------------------------------------------- 126dnl Test if 'bool' is a builtin type in the configured C++ compiler. Some 127dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc 128dnl 2.6.3 does, in anticipation of the ANSI C++ standard. 129dnl 130dnl Treat the configuration-variable specially here, since we're directly 131dnl substituting its value (i.e., 1/0). 132AC_DEFUN([CF_BOOL_DECL], 133[ 134AC_MSG_CHECKING([for builtin bool type]) 135AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[ 136 AC_TRY_COMPILE([ 137#include <stdio.h> 138#include <sys/types.h> 139],[bool x = false], 140 [ifelse($1,,cf_cv_builtin_bool,[$1])=1], 141 [ifelse($1,,cf_cv_builtin_bool,[$1])=0]) 142 ]) 143if test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1 144then AC_MSG_RESULT(yes) 145else AC_MSG_RESULT(no) 146fi 147])dnl 148dnl --------------------------------------------------------------------------- 149dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type). 150dnl Don't bother looking for bool.h, since it's been deprecated. 151AC_DEFUN([CF_BOOL_SIZE], 152[ 153AC_MSG_CHECKING([for size of bool]) 154AC_CACHE_VAL(cf_cv_type_of_bool,[ 155 rm -f cf_test.out 156 AC_TRY_RUN([ 157#include <stdlib.h> 158#include <stdio.h> 159#ifdef HAVE_GXX_BUILTIN_H 160#include <g++/builtin.h> 161#elif HAVE_GPP_BUILTIN_H 162#include <gpp/builtin.h> 163#elif HAVE_BUILTIN_H 164#include <builtin.h> 165#endif 166main() 167{ 168 FILE *fp = fopen("cf_test.out", "w"); 169 if (fp != 0) { 170 bool x = true; 171 if ((bool)(-x) >= 0) 172 fputs("unsigned ", fp); 173 if (sizeof(x) == sizeof(int)) fputs("int", fp); 174 else if (sizeof(x) == sizeof(char)) fputs("char", fp); 175 else if (sizeof(x) == sizeof(short))fputs("short",fp); 176 else if (sizeof(x) == sizeof(long)) fputs("long", fp); 177 fclose(fp); 178 } 179 exit(0); 180} 181 ], 182 [cf_cv_type_of_bool=`cat cf_test.out`], 183 [cf_cv_type_of_bool=unknown], 184 [cf_cv_type_of_bool=unknown]) 185 ]) 186 rm -f cf_test.out 187AC_MSG_RESULT($cf_cv_type_of_bool) 188if test "$cf_cv_type_of_bool" = unknown ; then 189 AC_MSG_WARN(Assuming unsigned for type of bool) 190 cf_cv_type_of_bool=unsigned 191fi 192])dnl 193dnl --------------------------------------------------------------------------- 194dnl Determine the default configuration into which we'll install ncurses. This 195dnl can be overridden by the user's command-line options. There's two items to 196dnl look for: 197dnl 1. the prefix (e.g., /usr) 198dnl 2. the header files (e.g., /usr/include/ncurses) 199dnl We'll look for a previous installation of ncurses and use the same defaults. 200dnl 201dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and 202dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's 203dnl programs from a vendor's. 204AC_DEFUN([CF_CFG_DEFAULTS], 205[ 206AC_MSG_CHECKING(for prefix) 207if test "x$prefix" = "xNONE" ; then 208 case "$cf_cv_system_name" in 209 # non-vendor systems don't have a conflict 210 openbsd*|netbsd*|freebsd*|linux*) 211 prefix=/usr 212 ;; 213 *) prefix=$ac_default_prefix 214 ;; 215 esac 216fi 217AC_MSG_RESULT($prefix) 218 219if test "x$prefix" = "xNONE" ; then 220AC_MSG_CHECKING(for default include-directory) 221test -n "$verbose" && echo 1>&AC_FD_MSG 222for cf_symbol in \ 223 $includedir \ 224 $includedir/ncurses \ 225 $prefix/include \ 226 $prefix/include/ncurses \ 227 /usr/local/include \ 228 /usr/local/include/ncurses \ 229 /usr/include \ 230 /usr/include/ncurses 231do 232 cf_dir=`eval echo $cf_symbol` 233 if test -f $cf_dir/curses.h ; then 234 if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then 235 includedir="$cf_symbol" 236 test -n "$verbose" && echo $ac_n " found " 1>&AC_FD_MSG 237 break 238 fi 239 fi 240 test -n "$verbose" && echo " tested $cf_dir" 1>&AC_FD_MSG 241done 242AC_MSG_RESULT($includedir) 243fi 244])dnl 245dnl --------------------------------------------------------------------------- 246dnl Check if the terminal-capability database functions are available. If not, 247dnl ncurses has a much-reduced version. 248AC_DEFUN([CF_CGETENT],[ 249AC_MSG_CHECKING(for terminal-capability database functions) 250AC_CACHE_VAL(cf_cv_cgetent,[ 251AC_TRY_LINK([ 252#include <stdlib.h>],[ 253 char temp[128]; 254 char *buf = temp; 255 char *db_array = temp; 256 cgetent(&buf, /* int *, */ &db_array, "vt100"); 257 cgetcap(buf, "tc", '='); 258 cgetmatch(buf, "tc"); 259 ], 260 [cf_cv_cgetent=yes], 261 [cf_cv_cgetent=no]) 262]) 263AC_MSG_RESULT($cf_cv_cgetent) 264test "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT) 265])dnl 266dnl --------------------------------------------------------------------------- 267dnl Check if we're accidentally using a cache from a different machine. 268dnl Derive the system name, as a check for reusing the autoconf cache. 269dnl 270dnl If we've packaged config.guess and config.sub, run that (since it does a 271dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow 272dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM 273dnl which is useful in cross-compiles. 274AC_DEFUN([CF_CHECK_CACHE], 275[ 276if test -f $srcdir/config.guess ; then 277 ifelse([$1],,[AC_CANONICAL_HOST],[$1]) 278 system_name="$host_os" 279else 280 system_name="`(uname -s -r) 2>/dev/null`" 281 if test -z "$system_name" ; then 282 system_name="`(hostname) 2>/dev/null`" 283 fi 284fi 285test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name") 286AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"]) 287 288test -z "$system_name" && system_name="$cf_cv_system_name" 289test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name") 290 291if test ".$system_name" != ".$cf_cv_system_name" ; then 292 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)) 293 AC_ERROR("Please remove config.cache and try again.") 294fi 295])dnl 296dnl --------------------------------------------------------------------------- 297dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g., 298dnl the 'errno' variable. Define a DECL_xxx symbol if we must declare it 299dnl ourselves. 300dnl 301dnl (I would use AC_CACHE_CHECK here, but it will not work when called in a 302dnl loop from CF_SYS_ERRLIST). 303dnl 304dnl $1 = the name to check 305AC_DEFUN([CF_CHECK_ERRNO], 306[ 307AC_MSG_CHECKING(if external $1 is declared) 308AC_CACHE_VAL(cf_cv_dcl_$1,[ 309 AC_TRY_COMPILE([ 310#ifdef HAVE_STDLIB_H 311#include <stdlib.h> 312#endif 313#include <stdio.h> 314#include <sys/types.h> 315#include <errno.h> ], 316 [long x = (long) $1], 317 [eval 'cf_cv_dcl_'$1'=yes'], 318 [eval 'cf_cv_dcl_'$1'=no']) 319]) 320 321eval 'cf_result=$cf_cv_dcl_'$1 322AC_MSG_RESULT($cf_result) 323 324if test "$cf_result" = no ; then 325 eval 'cf_result=DECL_'$1 326 CF_UPPER(cf_result,$cf_result) 327 AC_DEFINE_UNQUOTED($cf_result) 328fi 329 330# It's possible (for near-UNIX clones) that the data doesn't exist 331CF_CHECK_EXTERN_DATA($1,int) 332])dnl 333dnl --------------------------------------------------------------------------- 334dnl Check for existence of external data in the current set of libraries. If 335dnl we can modify it, it's real enough. 336dnl $1 = the name to check 337dnl $2 = its type 338AC_DEFUN([CF_CHECK_EXTERN_DATA], 339[ 340AC_MSG_CHECKING(if external $1 exists) 341AC_CACHE_VAL(cf_cv_have_$1,[ 342 AC_TRY_LINK([ 343#undef $1 344extern $2 $1; 345], 346 [$1 = 2], 347 [eval 'cf_cv_have_'$1'=yes'], 348 [eval 'cf_cv_have_'$1'=no'])]) 349 350eval 'cf_result=$cf_cv_have_'$1 351AC_MSG_RESULT($cf_result) 352 353if test "$cf_result" = yes ; then 354 eval 'cf_result=HAVE_'$1 355 CF_UPPER(cf_result,$cf_result) 356 AC_DEFINE_UNQUOTED($cf_result) 357fi 358 359])dnl 360dnl --------------------------------------------------------------------------- 361dnl Check if the C++ compiler accepts duplicate parameter initialization. This 362dnl is a late feature for the standard and is not in some recent compilers 363dnl (1999/9/11). 364AC_DEFUN([CF_CPP_PARAM_INIT], 365[ 366if test "$CXX" = yes ; then 367AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[ 368 AC_LANG_CPLUSPLUS 369 AC_TRY_RUN([ 370class TEST { 371private: 372 int value; 373public: 374 TEST(int x = 1); 375 ~TEST(); 376}; 377 378TEST::TEST(int x = 1) // some compilers do not like second initializer 379{ 380 value = x; 381} 382void main() { } 383], 384 [cf_cv_cpp_param_init=yes], 385 [cf_cv_cpp_param_init=no], 386 [cf_cv_cpp_param_init=unknown]) 387]) 388fi 389test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT) 390])dnl 391dnl --------------------------------------------------------------------------- 392AC_DEFUN([CF_DIRS_TO_MAKE], 393[ 394DIRS_TO_MAKE="lib" 395for cf_item in $cf_list_models 396do 397 CF_OBJ_SUBDIR($cf_item,cf_subdir) 398 DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir" 399done 400for cf_dir in $DIRS_TO_MAKE 401do 402 test ! -d $cf_dir && mkdir $cf_dir 403done 404AC_SUBST(DIRS_TO_MAKE) 405])dnl 406dnl --------------------------------------------------------------------------- 407dnl Check if 'errno' is declared in <errno.h> 408AC_DEFUN([CF_ERRNO], 409[ 410CF_CHECK_ERRNO(errno) 411])dnl 412dnl --------------------------------------------------------------------------- 413dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between 414dnl math.h and builtin.h, only for ncurses 415AC_DEFUN([CF_ETIP_DEFINES], 416[ 417AC_MSG_CHECKING(for special defines needed for etip.h) 418cf_save_CXXFLAGS="$CXXFLAGS" 419cf_result="none" 420for cf_math in "" MATH_H 421do 422for cf_excp in "" MATH_EXCEPTION 423do 424 CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu" 425 test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}" 426 test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}" 427AC_TRY_COMPILE([ 428#include <etip.h.in> 429],[],[ 430 test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math}) 431 test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp}) 432 cf_result="$cf_math $cf_excp" 433 break 434],[]) 435done 436done 437AC_MSG_RESULT($cf_result) 438CXXFLAGS="$cf_save_CXXFLAGS" 439]) 440dnl --------------------------------------------------------------------------- 441dnl Check for memmove, or a bcopy that can handle overlapping copy. If neither 442dnl is found, add our own version of memmove to the list of objects. 443AC_DEFUN([CF_FUNC_MEMMOVE], 444[ 445AC_CHECK_FUNC(memmove,,[ 446AC_CHECK_FUNC(bcopy,[ 447 AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[ 448 AC_TRY_RUN([ 449int main() { 450 static char data[] = "abcdefghijklmnopqrstuwwxyz"; 451 char temp[40]; 452 bcopy(data, temp, sizeof(data)); 453 bcopy(temp+10, temp, 15); 454 bcopy(temp+5, temp+15, 10); 455 exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz")); 456} 457 ], 458 [cf_cv_good_bcopy=yes], 459 [cf_cv_good_bcopy=no], 460 [cf_cv_good_bcopy=unknown]) 461 ]) 462 ],[cf_cv_good_bcopy=no]) 463 if test "$cf_cv_good_bcopy" = yes ; then 464 AC_DEFINE(USE_OK_BCOPY) 465 else 466 AC_DEFINE(USE_MY_MEMMOVE) 467 fi 468])])dnl 469dnl --------------------------------------------------------------------------- 470dnl See if the poll function really works. Some platforms have poll(), but 471dnl it does not work for terminals or files. 472AC_DEFUN([CF_FUNC_POLL],[ 473AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[ 474AC_TRY_RUN([ 475#include <stdio.h> 476#ifdef HAVE_POLL_H 477#include <poll.h> 478#else 479#include <sys/poll.h> 480#endif 481int main() { 482 struct pollfd myfds; 483 int ret; 484 485 myfds.fd = 0; 486 myfds.events = POLLIN; 487 488 ret = poll(&myfds, 1, 100); 489 exit(ret != 0); 490}], 491 [cf_cv_working_poll=yes], 492 [cf_cv_working_poll=no], 493 [cf_cv_working_poll=unknown])]) 494test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL) 495])dnl 496dnl --------------------------------------------------------------------------- 497dnl Some old/broken variations define tcgetattr() only as a macro in 498dnl termio(s).h 499AC_DEFUN([CF_FUNC_TERMIOS],[ 500AC_REQUIRE([CF_STRUCT_TERMIOS]) 501AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[ 502AC_TRY_LINK([ 503#include <sys/types.h> 504#ifdef HAVE_UNISTD_H 505#include <unistd.h> 506#endif 507#ifdef HAVE_TERMIOS_H 508#include <termios.h> 509#define TTY struct termios 510#else 511#ifdef HAVE_TERMIO_H 512#include <termio.h> 513#define TTY struct termio 514#endif 515#endif 516],[ 517TTY foo; 518tcgetattr(1, &foo);], 519[cf_cv_have_tcgetattr=yes], 520[cf_cv_have_tcgetattr=no])]) 521test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR) 522])dnl 523dnl --------------------------------------------------------------------------- 524dnl Test for availability of useful gcc __attribute__ directives to quiet 525dnl compiler warnings. Though useful, not all are supported -- and contrary 526dnl to documentation, unrecognized directives cause older compilers to barf. 527AC_DEFUN([CF_GCC_ATTRIBUTES], 528[ 529if test "$GCC" = yes 530then 531cat > conftest.i <<EOF 532#ifndef GCC_PRINTF 533#define GCC_PRINTF 0 534#endif 535#ifndef GCC_SCANF 536#define GCC_SCANF 0 537#endif 538#ifndef GCC_NORETURN 539#define GCC_NORETURN /* nothing */ 540#endif 541#ifndef GCC_UNUSED 542#define GCC_UNUSED /* nothing */ 543#endif 544EOF 545if test "$GCC" = yes 546then 547 AC_CHECKING([for $CC __attribute__ directives]) 548 changequote(,)dnl 549cat > conftest.$ac_ext <<EOF 550#line __oline__ "configure" 551#include "confdefs.h" 552#include "conftest.h" 553#include "conftest.i" 554#if GCC_PRINTF 555#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) 556#else 557#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ 558#endif 559#if GCC_SCANF 560#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) 561#else 562#define GCC_SCANFLIKE(fmt,var) /*nothing*/ 563#endif 564extern void wow(char *,...) GCC_SCANFLIKE(1,2); 565extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN; 566extern void foo(void) GCC_NORETURN; 567int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; } 568EOF 569 changequote([,])dnl 570 for cf_attribute in scanf printf unused noreturn 571 do 572 CF_UPPER(CF_ATTRIBUTE,$cf_attribute) 573 cf_directive="__attribute__(($cf_attribute))" 574 echo "checking for $CC $cf_directive" 1>&AC_FD_CC 575 case $cf_attribute in 576 scanf|printf) 577 cat >conftest.h <<EOF 578#define GCC_$CF_ATTRIBUTE 1 579EOF 580 ;; 581 *) 582 cat >conftest.h <<EOF 583#define GCC_$CF_ATTRIBUTE $cf_directive 584EOF 585 ;; 586 esac 587 if AC_TRY_EVAL(ac_compile); then 588 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute) 589 cat conftest.h >>confdefs.h 590# else 591# sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h 592 fi 593 done 594else 595 fgrep define conftest.i >>confdefs.h 596fi 597rm -rf conftest* 598fi 599])dnl 600dnl --------------------------------------------------------------------------- 601dnl Check if the compiler supports useful warning options. There's a few that 602dnl we don't use, simply because they're too noisy: 603dnl 604dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x) 605dnl -Wredundant-decls (system headers make this too noisy) 606dnl -Wtraditional (combines too many unrelated messages, only a few useful) 607dnl -Wwrite-strings (too noisy, but should review occasionally) 608dnl -pedantic 609dnl 610AC_DEFUN([CF_GCC_WARNINGS], 611[ 612if test "$GCC" = yes 613then 614 changequote(,)dnl 615 cat > conftest.$ac_ext <<EOF 616#line __oline__ "configure" 617int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; } 618EOF 619 changequote([,])dnl 620 AC_CHECKING([for $CC warning options]) 621 cf_save_CFLAGS="$CFLAGS" 622 EXTRA_CFLAGS="-W -Wall" 623 cf_warn_CONST="" 624 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings" 625 for cf_opt in \ 626 Wbad-function-cast \ 627 Wcast-align \ 628 Wcast-qual \ 629 Winline \ 630 Wmissing-declarations \ 631 Wmissing-prototypes \ 632 Wnested-externs \ 633 Wpointer-arith \ 634 Wshadow \ 635 Wstrict-prototypes $cf_warn_CONST 636 do 637 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" 638 if AC_TRY_EVAL(ac_compile); then 639 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt) 640 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" 641 test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES" 642 fi 643 done 644 rm -f conftest* 645 CFLAGS="$cf_save_CFLAGS" 646fi 647AC_SUBST(EXTRA_CFLAGS) 648])dnl 649dnl --------------------------------------------------------------------------- 650dnl Verify that a test program compiles and runs with GNAT 651dnl $cf_ada_make is set to the program that compiles/links 652AC_DEFUN([CF_GNAT_TRY_RUN], 653[ 654rm -f conftest* 655cat >>conftest.ads <<CF_EOF 656$1 657CF_EOF 658cat >>conftest.adb <<CF_EOF 659$2 660CF_EOF 661if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then 662 if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then 663ifelse($3,, :,[ $3]) 664ifelse($4,,,[ else 665 $4]) 666 fi 667ifelse($4,,,[else 668 $4]) 669fi 670rm -f conftest* 671])dnl 672dnl --------------------------------------------------------------------------- 673dnl Verify Version of GNAT. 674AC_DEFUN([CF_GNAT_VERSION], 675[ 676changequote(<<, >>)dnl 677cf_cv_gnat_version=`$cf_ada_make -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\ 678 sed -e 's/[^0-9 \.]//g' | $AWK '{print $<<1>>;}'` 679case $cf_cv_gnat_version in 680 3.1[1-9]*|3.[2-9]*|[4-9].*) 681 cf_cv_prog_gnat_correct=yes 682 ;; 683 *) echo Unsupported GNAT version $cf_cv_gnat_version. Required is 3.11 or better. Disabling Ada95 binding. 684 cf_cv_prog_gnat_correct=no 685 ;; 686esac 687case $cf_cv_gnat_version in 688 3.1*|[4-9].*) 689 cf_compile_generics=generics 690 cf_generic_objects="\$(GENOBJS)" 691 ;; 692 *) cf_compile_generics= 693 cf_generic_objects= 694 ;; 695esac 696changequote([, ])dnl 697]) 698dnl --------------------------------------------------------------------------- 699dnl If we're trying to use g++, test if libg++ is installed (a rather common 700dnl problem :-). If we have the compiler but no library, we'll be able to 701dnl configure, but won't be able to build the c++ demo program. 702AC_DEFUN([CF_GPP_LIBRARY], 703[ 704cf_cxx_library=unknown 705case $cf_cv_system_name in #(vi 706os2*) #(vi 707 cf_gpp_libname=gpp 708 ;; 709*) 710 cf_gpp_libname=g++ 711 ;; 712esac 713if test "$ac_cv_prog_gxx" = yes; then 714 AC_MSG_CHECKING([for lib$cf_gpp_libname]) 715 cf_save="$LIBS" 716 LIBS="$LIBS -l$cf_gpp_libname" 717 AC_TRY_LINK([ 718#include <$cf_gpp_libname/builtin.h> 719 ], 720 [two_arg_error_handler_t foo2 = lib_error_handler], 721 [cf_cxx_library=yes 722 CXXLIBS="$CXXLIBS -l$cf_gpp_libname" 723 if test "$cf_gpp_libname" = cpp ; then 724 AC_DEFINE(HAVE_GPP_BUILTIN_H) 725 else 726 AC_DEFINE(HAVE_GXX_BUILTIN_H) 727 fi], 728 [AC_TRY_LINK([ 729#include <builtin.h> 730 ], 731 [two_arg_error_handler_t foo2 = lib_error_handler], 732 [cf_cxx_library=yes 733 CXXLIBS="$CXXLIBS -l$cf_gpp_libname" 734 AC_DEFINE(HAVE_BUILTIN_H)], 735 [cf_cxx_library=no])]) 736 LIBS="$cf_save" 737 AC_MSG_RESULT($cf_cxx_library) 738fi 739])dnl 740dnl --------------------------------------------------------------------------- 741dnl Insert text into the help-message, for readability, from AC_ARG_WITH. 742AC_DEFUN([CF_HELP_MESSAGE], 743[AC_DIVERT_HELP([$1])dnl 744])dnl 745dnl --------------------------------------------------------------------------- 746dnl Construct the list of include-options according to whether we're building 747dnl in the source directory or using '--srcdir=DIR' option. If we're building 748dnl with gcc, don't append the includedir if it happens to be /usr/include, 749dnl since that usually breaks gcc's shadow-includes. 750AC_DEFUN([CF_INCLUDE_DIRS], 751[ 752CPPFLAGS="$CPPFLAGS -I. -I../include" 753if test "$srcdir" != "."; then 754 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include" 755fi 756if test "$GCC" != yes; then 757 CPPFLAGS="$CPPFLAGS -I\$(includedir)" 758elif test "$includedir" != "/usr/include"; then 759 if test "$includedir" = '${prefix}/include' ; then 760 if test $prefix != /usr ; then 761 CPPFLAGS="$CPPFLAGS -I\$(includedir)" 762 fi 763 else 764 CPPFLAGS="$CPPFLAGS -I\$(includedir)" 765 fi 766fi 767AC_SUBST(CPPFLAGS) 768])dnl 769dnl --------------------------------------------------------------------------- 770dnl Check if we have either a function or macro for 'isascii()'. 771AC_DEFUN([CF_ISASCII], 772[ 773AC_MSG_CHECKING(for isascii) 774AC_CACHE_VAL(cf_cv_have_isascii,[ 775 AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')], 776 [cf_cv_have_isascii=yes], 777 [cf_cv_have_isascii=no]) 778])dnl 779AC_MSG_RESULT($cf_cv_have_isascii) 780test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII) 781])dnl 782dnl --------------------------------------------------------------------------- 783dnl Compute the library-prefix for the given host system 784dnl $1 = variable to set 785AC_DEFUN([CF_LIB_PREFIX], 786[ 787 case $cf_cv_system_name in 788 os2) LIB_PREFIX='' ;; 789 *) LIB_PREFIX='lib' ;; 790 esac 791ifelse($1,,,[$1=$LIB_PREFIX]) 792 AC_SUBST(LIB_PREFIX) 793])dnl 794dnl --------------------------------------------------------------------------- 795dnl Append definitions and rules for the given models to the subdirectory 796dnl Makefiles, and the recursion rule for the top-level Makefile. If the 797dnl subdirectory is a library-source directory, modify the LIBRARIES list in 798dnl the corresponding makefile to list the models that we'll generate. 799dnl 800dnl For shared libraries, make a list of symbolic links to construct when 801dnl generating each library. The convention used for Linux is the simplest 802dnl one: 803dnl lib<name>.so -> 804dnl lib<name>.so.<major> -> 805dnl lib<name>.so.<maj>.<minor> 806AC_DEFUN([CF_LIB_RULES], 807[ 808CF_LIB_PREFIX(cf_prefix) 809AC_REQUIRE([CF_SUBST_NCURSES_VERSION]) 810for cf_dir in $SRC_SUBDIRS 811do 812 if test -f $srcdir/$cf_dir/modules; then 813 814 cf_libs_to_make= 815 for cf_item in $CF_LIST_MODELS 816 do 817 CF_LIB_SUFFIX($cf_item,cf_suffix) 818 if test $cf_item = shared ; then 819 if test "$cf_cv_do_symlinks" = yes ; then 820 case "$cf_cv_shlib_version" in #(vi 821 rel) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;; #(vi 822 abi) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;; 823 esac 824 fi 825 fi 826 cf_libs_to_make="$cf_libs_to_make ../lib/${cf_prefix}${cf_dir}${cf_suffix}" 827 done 828 829 if test $cf_dir = ncurses ; then 830 case "$LIB_SUBSETS" in #(vi 831 termlib+*) #(vi 832 ;; 833 *) #(vi 834 cf_item=`echo $cf_libs_to_make |sed -e s/$LIB_NAME/$TINFO_NAME/g` 835 cf_libs_to_make="$cf_item $cf_libs_to_make" 836 ;; 837 esac 838 fi 839 840 sed -e "s@\@LIBS_TO_MAKE\@@$cf_libs_to_make@" \ 841 $cf_dir/Makefile >$cf_dir/Makefile.out 842 mv $cf_dir/Makefile.out $cf_dir/Makefile 843 844 $AWK -f $srcdir/mk-0th.awk \ 845 name=$cf_dir \ 846 $srcdir/$cf_dir/modules >>$cf_dir/Makefile 847 848 for cf_item in $CF_LIST_MODELS 849 do 850 echo 'Appending rules for '$cf_item' model ('$cf_dir')' 851 CF_UPPER(CF_ITEM,$cf_item) 852 CF_LIB_SUFFIX($cf_item,cf_suffix) 853 CF_OBJ_SUBDIR($cf_item,cf_subdir) 854 855 # These dependencies really are for development, not 856 # builds, but they are useful in porting, too. 857 cf_depend="../include/ncurses_cfg.h" 858 if test "$srcdir" = "."; then 859 cf_reldir="." 860 else 861 cf_reldir="\$(srcdir)" 862 fi 863 864 if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then 865 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h" 866 elif test -f $srcdir/$cf_dir/curses.priv.h; then 867 cf_depend="$cf_depend $cf_reldir/curses.priv.h" 868 fi 869 870 for cf_subset in $LIB_SUBSETS 871 do 872 $AWK -f $srcdir/mk-1st.awk \ 873 name=$cf_dir \ 874 traces=$LIB_TRACING \ 875 MODEL=$CF_ITEM \ 876 model=$cf_subdir \ 877 prefix=$cf_prefix \ 878 suffix=$cf_suffix \ 879 subset=$cf_subset \ 880 ShlibVer=$cf_cv_shlib_version \ 881 DoLinks=$cf_cv_do_symlinks \ 882 rmSoLocs=$cf_cv_rm_so_locs \ 883 ldconfig="$LDCONFIG" \ 884 overwrite=$WITH_OVERWRITE \ 885 depend="$cf_depend" \ 886 target="$target" \ 887 $srcdir/$cf_dir/modules >>$cf_dir/Makefile 888 test $cf_dir = ncurses && WITH_OVERWRITE=no 889 $AWK -f $srcdir/mk-2nd.awk \ 890 name=$cf_dir \ 891 traces=$LIB_TRACING \ 892 MODEL=$CF_ITEM \ 893 model=$cf_subdir \ 894 subset=$cf_subset \ 895 srcdir=$srcdir \ 896 echo=$WITH_ECHO \ 897 $srcdir/$cf_dir/modules >>$cf_dir/Makefile 898 done 899 done 900 fi 901 902 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile 903done 904 905for cf_dir in $SRC_SUBDIRS 906do 907 if test -f $cf_dir/Makefile ; then 908 case "$cf_dir" in 909 Ada95) #(vi 910 echo 'libs \' >> Makefile 911 echo 'install.libs \' >> Makefile 912 echo 'uninstall.libs ::' >> Makefile 913 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile 914 ;; 915 esac 916 fi 917 918 if test -f $srcdir/$cf_dir/modules; then 919 echo >> Makefile 920 if test -f $srcdir/$cf_dir/headers; then 921cat >> Makefile <<CF_EOF 922install.includes \\ 923uninstall.includes \\ 924CF_EOF 925 fi 926if test "$cf_dir" != "c++" ; then 927echo 'lint \' >> Makefile 928fi 929cat >> Makefile <<CF_EOF 930libs \\ 931lintlib \\ 932install.libs \\ 933uninstall.libs \\ 934install.$cf_dir \\ 935uninstall.$cf_dir :: 936 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@ 937CF_EOF 938 elif test -f $srcdir/$cf_dir/headers; then 939cat >> Makefile <<CF_EOF 940 941libs \\ 942install.libs \\ 943uninstall.libs \\ 944install.includes \\ 945uninstall.includes :: 946 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@ 947CF_EOF 948fi 949done 950 951cat >> Makefile <<CF_EOF 952 953install.data \ 954uninstall.data :: 955 cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@ 956 957install.man \ 958uninstall.man :: 959 cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@ 960 961distclean :: 962 rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h 963 rm -f headers.sh headers.sed 964 rm -rf \$(DIRS_TO_MAKE) 965CF_EOF 966 967# Special case: tack's manpage lives in its own directory. 968if test -d tack ; then 969if test -f $srcdir/$tack.h; then 970cat >> Makefile <<CF_EOF 971 972install.man \ 973uninstall.man :: 974 cd tack && \$(MAKE) \$(CF_MFLAGS) \[$]@ 975CF_EOF 976fi 977fi 978 979dnl If we're installing into a subdirectory of /usr/include, etc., we should 980dnl prepend the subdirectory's name to the "#include" paths. It won't hurt 981dnl anything, and will make it more standardized. It's awkward to decide this 982dnl at configuration because of quoting, so we'll simply make all headers 983dnl installed via a script that can do the right thing. 984 985rm -f headers.sed headers.sh 986 987dnl ( generating this script makes the makefiles a little tidier :-) 988echo creating headers.sh 989cat >headers.sh <<CF_EOF 990#! /bin/sh 991# This shell script is generated by the 'configure' script. It is invoked in a 992# subdirectory of the build tree. It generates a sed-script in the parent 993# directory that is used to adjust includes for header files that reside in a 994# subdirectory of /usr/include, etc. 995PRG="" 996while test \[$]# != 3 997do 998PRG="\$PRG \[$]1"; shift 999done 1000DST=\[$]1 1001REF=\[$]2 1002SRC=\[$]3 1003echo installing \$SRC in \$DST 1004case \$DST in 1005/*/include/*) 1006 TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$ 1007 TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$ 1008 END=\`basename \$DST\` 1009 for i in \`cat \$REF/../*/headers |fgrep -v "#"\` 1010 do 1011 NAME=\`basename \$i\` 1012 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED 1013 done 1014 rm -f \$TMPSRC 1015 sed -f \$TMPSED \$SRC > \$TMPSRC 1016 eval \$PRG \$TMPSRC \$DST/\`basename \$SRC\` 1017 rm -f \$TMPSRC \$TMPSED 1018 ;; 1019*) 1020 eval \$PRG \$SRC \$DST 1021 ;; 1022esac 1023CF_EOF 1024 1025chmod 0755 headers.sh 1026 1027for cf_dir in $SRC_SUBDIRS 1028do 1029 if test -f $srcdir/$cf_dir/headers; then 1030 cat >>$cf_dir/Makefile <<CF_EOF 1031\$(DESTDIR)\$(includedir) : 1032 \$(srcdir)/../mkinstalldirs \[$]@ 1033 1034install \\ 1035install.libs \\ 1036install.includes :: \$(AUTO_SRC) \$(DESTDIR)\$(includedir) \\ 1037CF_EOF 1038 j="" 1039 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"` 1040 do 1041 test -n "$j" && echo " $j \\" >>$cf_dir/Makefile 1042 j=$i 1043 done 1044 echo " $j" >>$cf_dir/Makefile 1045 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"` 1046 do 1047 echo " @ (cd \$(DESTDIR)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(DESTDIR)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile 1048 test $i = curses.h && echo " @ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile 1049 done 1050 1051 cat >>$cf_dir/Makefile <<CF_EOF 1052 1053uninstall \\ 1054uninstall.libs \\ 1055uninstall.includes :: 1056CF_EOF 1057 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"` 1058 do 1059 i=`basename $i` 1060 echo " -@ (cd \$(DESTDIR)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile 1061 test $i = curses.h && echo " -@ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile 1062 done 1063 fi 1064done 1065 1066])dnl 1067dnl --------------------------------------------------------------------------- 1068dnl Compute the library file-suffix from the given model name 1069dnl $1 = model name 1070dnl $2 = variable to set 1071dnl The variable $LIB_SUFFIX, if set, prepends the variable to set. 1072AC_DEFUN([CF_LIB_SUFFIX], 1073[ 1074 AC_REQUIRE([CF_SUBST_NCURSES_VERSION]) 1075 case $1 in 1076 normal) $2='.a' ;; 1077 debug) $2='_g.a' ;; 1078 profile) $2='_p.a' ;; 1079 shared) 1080 case $cf_cv_system_name in 1081 hpux*) $2='.sl' ;; 1082 *) $2='.so' ;; 1083 esac 1084 esac 1085 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}" 1086])dnl 1087dnl --------------------------------------------------------------------------- 1088dnl Compute the string to append to -library from the given model name 1089dnl $1 = model name 1090dnl $2 = variable to set 1091dnl The variable $LIB_SUFFIX, if set, prepends the variable to set. 1092AC_DEFUN([CF_LIB_TYPE], 1093[ 1094 case $1 in 1095 normal) $2='' ;; 1096 debug) $2='_g' ;; 1097 profile) $2='_p' ;; 1098 shared) $2='' ;; 1099 esac 1100 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}" 1101])dnl 1102dnl --------------------------------------------------------------------------- 1103dnl Some systems have a non-ANSI linker that doesn't pull in modules that have 1104dnl only data (i.e., no functions), for example NeXT. On those systems we'll 1105dnl have to provide wrappers for global tables to ensure they're linked 1106dnl properly. 1107AC_DEFUN([CF_LINK_DATAONLY], 1108[ 1109AC_MSG_CHECKING([if data-only library module links]) 1110AC_CACHE_VAL(cf_cv_link_dataonly,[ 1111 rm -f conftest.a 1112 changequote(,)dnl 1113 cat >conftest.$ac_ext <<EOF 1114#line __oline__ "configure" 1115int testdata[3] = { 123, 456, 789 }; 1116EOF 1117 changequote([,])dnl 1118 if AC_TRY_EVAL(ac_compile) ; then 1119 mv conftest.o data.o && \ 1120 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null 1121 fi 1122 rm -f conftest.$ac_ext data.o 1123 changequote(,)dnl 1124 cat >conftest.$ac_ext <<EOF 1125#line __oline__ "configure" 1126int testfunc() 1127{ 1128#if defined(NeXT) 1129 exit(1); /* I'm told this linker is broken */ 1130#else 1131 extern int testdata[3]; 1132 return testdata[0] == 123 1133 && testdata[1] == 456 1134 && testdata[2] == 789; 1135#endif 1136} 1137EOF 1138 changequote([,])dnl 1139 if AC_TRY_EVAL(ac_compile); then 1140 mv conftest.o func.o && \ 1141 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null 1142 fi 1143 rm -f conftest.$ac_ext func.o 1144 ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null 1145 cf_saveLIBS="$LIBS" 1146 LIBS="conftest.a $LIBS" 1147 AC_TRY_RUN([ 1148 int main() 1149 { 1150 extern int testfunc(); 1151 exit (!testfunc()); 1152 } 1153 ], 1154 [cf_cv_link_dataonly=yes], 1155 [cf_cv_link_dataonly=no], 1156 [cf_cv_link_dataonly=unknown]) 1157 LIBS="$cf_saveLIBS" 1158 ]) 1159AC_MSG_RESULT($cf_cv_link_dataonly) 1160test "$cf_cv_link_dataonly" = no && AC_DEFINE(BROKEN_LINKER) 1161])dnl 1162dnl --------------------------------------------------------------------------- 1163dnl Most Unix systems have both link and symlink, a few don't have symlink. 1164dnl A few non-Unix systems implement symlink, but not link. 1165dnl A few non-systems implement neither (or have nonfunctional versions). 1166AC_DEFUN([CF_LINK_FUNCS], 1167[ 1168AC_CHECK_FUNCS( \ 1169 remove \ 1170 unlink ) 1171 1172if test "$ac_cv_prog_cc_cross" = yes ; then 1173 AC_CHECK_FUNCS( \ 1174 link \ 1175 symlink ) 1176else 1177 AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[ 1178 cf_cv_link_funcs= 1179 for cf_func in link symlink ; do 1180 AC_TRY_RUN([ 1181#include <sys/types.h> 1182#include <sys/stat.h> 1183#ifdef HAVE_UNISTD_H 1184#include <unistd.h> 1185#endif 1186int main() 1187{ 1188 int fail = 0; 1189 char *src = "config.log"; 1190 char *dst = "conftest.chk"; 1191 struct stat src_sb; 1192 struct stat dst_sb; 1193 1194 stat(src, &src_sb); 1195 fail = ($cf_func("config.log", "conftest.chk") < 0) 1196 || (stat(dst, &dst_sb) < 0) 1197 || (dst_sb.st_mtime != src_sb.st_mtime); 1198#ifdef HAVE_UNLINK 1199 unlink(dst); 1200#else 1201 remove(dst); 1202#endif 1203 exit (fail); 1204} 1205 ],[ 1206 cf_cv_link_funcs="$cf_cv_link_funcs $cf_func" 1207 eval 'ac_cv_func_'$cf_func'=yes'],[ 1208 eval 'ac_cv_func_'$cf_func'=no'],[ 1209 eval 'ac_cv_func_'$cf_func'=error']) 1210 done 1211 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no 1212 ]) 1213 test "$ac_cv_func_link" = yes && AC_DEFINE(HAVE_LINK) 1214 test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK) 1215fi 1216])dnl 1217dnl --------------------------------------------------------------------------- 1218dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make' 1219dnl options to lower-levels. It's very useful for "make -n" -- if we have it. 1220dnl (GNU 'make' does both, something POSIX 'make', which happens to make the 1221dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-) 1222AC_DEFUN([CF_MAKEFLAGS], 1223[ 1224AC_MSG_CHECKING([for makeflags variable]) 1225AC_CACHE_VAL(cf_cv_makeflags,[ 1226 cf_cv_makeflags='' 1227 for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)' 1228 do 1229 cat >cf_makeflags.tmp <<CF_EOF 1230all : 1231 @ echo '.$cf_option' 1232CF_EOF 1233 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null` 1234 case "$cf_result" in 1235 .*k) 1236 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null` 1237 case "$cf_result" in 1238 .*CC=*) cf_cv_makeflags= 1239 ;; 1240 *) cf_cv_makeflags=$cf_option 1241 ;; 1242 esac 1243 break 1244 ;; 1245 *) echo no match "$cf_result" 1246 ;; 1247 esac 1248 done 1249 rm -f cf_makeflags.tmp]) 1250AC_MSG_RESULT($cf_cv_makeflags) 1251AC_SUBST(cf_cv_makeflags) 1252])dnl 1253dnl --------------------------------------------------------------------------- 1254dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have 1255dnl a monocase filesystem. 1256AC_DEFUN([CF_MAKE_TAGS],[ 1257AC_REQUIRE([CF_MIXEDCASE_FILENAMES]) 1258AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no) 1259 1260if test "$cf_cv_mixedcase" = yes ; then 1261 AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no) 1262else 1263 MAKE_UPPER_TAGS=no 1264fi 1265 1266if test "$MAKE_UPPER_TAGS" = yes ; then 1267 MAKE_UPPER_TAGS= 1268else 1269 MAKE_UPPER_TAGS="#" 1270fi 1271AC_SUBST(MAKE_UPPER_TAGS) 1272 1273if test "$MAKE_LOWER_TAGS" = yes ; then 1274 MAKE_LOWER_TAGS= 1275else 1276 MAKE_LOWER_TAGS="#" 1277fi 1278AC_SUBST(MAKE_LOWER_TAGS) 1279])dnl 1280dnl --------------------------------------------------------------------------- 1281dnl Option to allow user to override automatic configuration of manpage format. 1282dnl There are several special cases. 1283AC_DEFUN([CF_MANPAGE_FORMAT], 1284[ AC_MSG_CHECKING(format of man-pages) 1285 1286AC_ARG_WITH(manpage-format, 1287 [ --with-manpage-format specify manpage-format: gzip/compress/BSDI/normal and 1288 optionally formatted, e.g., gzip,formatted], 1289 [cf_manpage_form=$withval], 1290 [cf_manpage_form=unknown]) 1291 1292case ".$cf_manpage_form" in 1293.gzip|.compress|.BSDI|.normal|.formatted) # (vi 1294 ;; 1295.unknown|.) # (vi 1296 if test -z "$MANPATH" ; then 1297 MANPATH="/usr/man:/usr/share/man" 1298 fi 1299 # look for the 'date' man-page (it's most likely to be installed!) 1300 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" 1301 cf_manpage_form=unknown 1302 for cf_dir in $MANPATH; do 1303 test -z "$cf_dir" && cf_dir=/usr/man 1304changequote({{,}})dnl 1305 for cf_name in $cf_dir/*/date.[01]* $cf_dir/*/date 1306changequote([,])dnl 1307 do 1308 cf_test=`echo $cf_name | sed -e 's/*//'` 1309 if test "x$cf_test" = "x$cf_name" ; then 1310 case "$cf_name" in 1311 *.gz) cf_manpage_form=gzip;; 1312 *.Z) cf_manpage_form=compress;; 1313 *.0) cf_manpage_form=BSDI,formatted;; 1314 *) cf_manpage_form=normal;; 1315 esac 1316 break 1317 fi 1318 done 1319 if test "$cf_manpage_form" != "unknown" ; then 1320 break 1321 fi 1322 done 1323 IFS="$ac_save_ifs" 1324 ;; 1325.*) # (vi 1326 AC_MSG_WARN(Unexpected manpage-format) 1327 ;; 1328esac 1329 1330AC_MSG_RESULT($cf_manpage_form) 1331])dnl 1332dnl --------------------------------------------------------------------------- 1333dnl The Debian people have their own naming convention for manpages. This 1334dnl option lets us override the name of the file containing renaming, or 1335dnl disable it altogether. 1336AC_DEFUN([CF_MANPAGE_RENAMES], 1337[ 1338AC_MSG_CHECKING(for manpage renaming) 1339 1340AC_ARG_WITH(manpage-renames, 1341 [ --with-manpage-renames specify manpage-renaming], 1342 [cf_manpage_renames=$withval], 1343 [cf_manpage_renames=yes]) 1344 1345case ".$cf_manpage_renames" in #(vi 1346.no) #(vi 1347 ;; 1348.|.yes) 1349 # Debian 'man' program? 1350 if test -f /etc/debian_version ; then 1351 cf_manpage_renames=`cd $srcdir && pwd`/man/man_db.renames 1352 else 1353 cf_manpage_renames=no 1354 fi 1355 ;; 1356esac 1357 1358if test "$cf_manpage_renames" != no ; then 1359 if test ! -f $cf_manpage_renames ; then 1360 AC_MSG_ERROR(not a filename: $cf_manpage_renames) 1361 fi 1362 1363 test ! -d man && mkdir man 1364 1365 # Construct a sed-script to perform renaming within man-pages 1366 if test -n "$cf_manpage_renames" ; then 1367 test ! -d man && mkdir man 1368 $srcdir/man/make_sed.sh $cf_manpage_renames >man/edit_man.sed 1369 fi 1370fi 1371 1372AC_MSG_RESULT($cf_manpage_renames) 1373])dnl 1374dnl --------------------------------------------------------------------------- 1375dnl Some people expect each tool to make all aliases for manpages in the 1376dnl man-directory. This accommodates the older, less-capable implementations 1377dnl of 'man', and is optional. 1378AC_DEFUN([CF_MANPAGE_SYMLINKS], 1379[ 1380AC_MSG_CHECKING(for manpage symlinks) 1381 1382AC_ARG_WITH(manpage-symlinks, 1383 [ --with-manpage-symlinks specify manpage-symlinks], 1384 [cf_manpage_symlinks=$withval], 1385 [cf_manpage_symlinks=yes]) 1386 1387AC_MSG_RESULT($cf_manpage_symlinks) 1388])dnl 1389dnl --------------------------------------------------------------------------- 1390dnl Try to determine if the man-pages on the system are compressed, and if 1391dnl so, what format is used. Use this information to construct a script that 1392dnl will install man-pages. 1393AC_DEFUN([CF_MAN_PAGES], 1394[ 1395CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:) 1396CF_MANPAGE_FORMAT 1397CF_MANPAGE_RENAMES 1398CF_MANPAGE_SYMLINKS 1399 1400 if test "$prefix" = "NONE" ; then 1401 cf_prefix="$ac_default_prefix" 1402 else 1403 cf_prefix="$prefix" 1404 fi 1405 1406 case "$cf_manpage_form" in # (vi 1407 *formatted*) # (vi 1408 cf_subdir='$mandir/cat' 1409 cf_format=yes 1410 ;; 1411 *) 1412 cf_subdir='$mandir/man' 1413 cf_format=no 1414 ;; 1415 esac 1416 1417test ! -d man && mkdir man 1418cat >man/edit_man.sh <<CF_EOF 1419changequote({{,}})dnl 1420#! /bin/sh 1421# this script is generated by the configure-script 1422prefix="$cf_prefix" 1423datadir="$datadir" 1424TERMINFO="$TERMINFO" 1425MKDIRS="`cd $srcdir && pwd`/mkinstalldirs" 1426INSTALL="$INSTALL" 1427INSTALL_DATA="$INSTALL_DATA" 1428transform="$program_transform_name" 1429 1430TMP=\${TMPDIR-/tmp}/man\$\$ 1431trap "rm -f \$TMP" 0 1 2 5 15 1432 1433verb=\{{$}}1 1434shift 1435 1436mandir=\{{$}}1 1437shift 1438 1439srcdir=\{{$}}1 1440shift 1441 1442for i in \{{$}}* ; do 1443case \$i in #(vi 1444*.orig|*.rej) ;; #(vi 1445*.[0-9]*) 1446 section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`; 1447 if test \$verb = installing ; then 1448 if test ! -d $cf_subdir\${section} ; then 1449 \$MKDIRS $cf_subdir\$section 1450 fi 1451 fi 1452 aliases= 1453 source=\`basename \$i\` 1454 inalias=\$source 1455 test ! -f \$inalias && inalias="\$srcdir/\$inalias" 1456 if test ! -f \$inalias ; then 1457 echo .. skipped \$source 1458 continue 1459 fi 1460CF_EOF 1461if test "$cf_manpage_symlinks" = yes ; then 1462cat >>man/edit_man.sh <<CF_EOF 1463 aliases=\`sed -f \$srcdir/manlinks.sed \$inalias | sort -u\` 1464CF_EOF 1465fi 1466if test "$cf_manpage_renames" = no ; then 1467cat >>man/edit_man.sh <<CF_EOF 1468 # perform program transformations for section 1 man pages 1469 if test \$section = 1 ; then 1470 target=$cf_subdir\${section}/\`echo \$source|sed "\${transform}"\` 1471 else 1472 target=$cf_subdir\${section}/\$source 1473 fi 1474 1475 # replace variables in man page 1476CF_EOF 1477 ifelse($1,,,{{ 1478 for cf_name in $1 1479 do 1480cat >>man/edit_man.sh <<CF_EOF 1481 prog_$cf_name=\`echo $cf_name|sed "\${transform}"\` 1482CF_EOF 1483 done 1484 }}) 1485cat >>man/edit_man.sh <<CF_EOF 1486 sed -e "s,@DATADIR@,\$datadir," \\ 1487 -e "s,@TERMINFO@,\$TERMINFO," \\ 1488CF_EOF 1489 ifelse($1,,,{{ 1490 for cf_name in $1 1491 do 1492 cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` 1493cat >>man/edit_man.sh <<CF_EOF 1494 -e "s,@$cf_NAME@,\$prog_$cf_name," \\ 1495CF_EOF 1496 done 1497 }}) 1498cat >>man/edit_man.sh <<CF_EOF 1499 < \$i >\$TMP 1500CF_EOF 1501else 1502cat >>man/edit_man.sh <<CF_EOF 1503 target=\`grep "^\$source" $cf_manpage_renames | $AWK '{print \{{$}}2}'\` 1504 if test -z "\$target" ; then 1505 echo '? missing rename for '\$source 1506 target="\$source" 1507 fi 1508 target="$cf_subdir\$section/\$target" 1509 test \$verb = installing && sed -e "s,@DATADIR@,\$datadir," < \$i | sed -f edit_man.sed >\$TMP 1510CF_EOF 1511fi 1512if test $cf_format = yes ; then 1513cat >>man/edit_man.sh <<CF_EOF 1514 nroff -man \$TMP >\$TMP.out 1515 mv \$TMP.out \$TMP 1516CF_EOF 1517fi 1518case "$cf_manpage_form" in #(vi 1519*compress*) #(vi 1520cat >>man/edit_man.sh <<CF_EOF 1521 if test \$verb = installing ; then 1522 if ( compress -f \$TMP ) 1523 then 1524 mv \$TMP.Z \$TMP 1525 fi 1526 fi 1527 target="\$target.Z" 1528CF_EOF 1529 ;; 1530*gzip*) #(vi 1531cat >>man/edit_man.sh <<CF_EOF 1532 if test \$verb = installing ; then 1533 if ( gzip -f \$TMP ) 1534 then 1535 mv \$TMP.gz \$TMP 1536 fi 1537 fi 1538 target="\$target.gz" 1539CF_EOF 1540 ;; 1541*BSDI*) 1542cat >>man/edit_man.sh <<CF_EOF 1543 # BSDI installs only .0 suffixes in the cat directories 1544 target="\`echo \$target|sed -e 's/\.[1-9]\+.\?/.0/'\`" 1545CF_EOF 1546 ;; 1547esac 1548cat >>man/edit_man.sh <<CF_EOF 1549 echo \$verb \$target 1550 suffix=\`basename \$target | sed -e 's/^[^.]*//'\` 1551 if test \$verb = installing ; then 1552 \$INSTALL_DATA \$TMP \$target 1553 test -n "\$aliases" && ( 1554 cd $cf_subdir\${section} && ( 1555 target=\`basename \$target\` 1556 for cf_alias in \$aliases 1557 do 1558 if test \$section = 1 ; then 1559 cf_alias=\`echo \$cf_alias|sed "\${transform}"\` 1560 fi 1561 1562 if test -f \$cf_alias\${suffix} ; then 1563 if ( cmp -s \$target \$cf_alias\${suffix} ) 1564 then 1565 : 1566 else 1567 echo .. \$verb alias \$cf_alias\${suffix} 1568 rm -f \$cf_alias\${suffix} 1569 $LN_S \$target \$cf_alias\${suffix} 1570 fi 1571 else 1572 echo .. \$verb alias \$cf_alias\${suffix} 1573 rm -f \$cf_alias\${suffix} 1574 $LN_S \$target \$cf_alias\${suffix} 1575 fi 1576 done 1577 ) 1578 ) 1579 else 1580 rm -f \$target 1581 test -n "\$aliases" && ( 1582 cd $cf_subdir\${section} && ( 1583 for cf_alias in \$aliases 1584 do 1585 if test \$section = 1 ; then 1586 cf_alias=\`echo \$cf_alias|sed "\${transform}"\` 1587 fi 1588 1589 echo .. \$verb alias \$cf_alias\${suffix} 1590 rm -f \$cf_alias\${suffix} 1591 done 1592 ) 1593 ) 1594 fi 1595 ;; 1596esac 1597done 1598exit 0 1599CF_EOF 1600changequote([,])dnl 1601chmod 755 man/edit_man.sh 1602 1603])dnl 1604dnl --------------------------------------------------------------------------- 1605dnl Checks for libraries. At least one UNIX system, Apple Macintosh 1606dnl Rhapsody 5.5, does not have -lm. We cannot use the simpler 1607dnl AC_CHECK_LIB(m,sin), because that fails for C++. 1608AC_DEFUN([CF_MATH_LIB], 1609[ 1610AC_CACHE_CHECK(if -lm needed for math functions, 1611 cf_cv_need_libm,[ 1612 AC_TRY_LINK([ 1613 #include <stdio.h> 1614 #include <math.h> 1615 ], 1616 [double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)], 1617 [cf_cv_need_libm=no], 1618 [cf_cv_need_libm=yes])]) 1619if test "$cf_cv_need_libm" = yes 1620then 1621ifelse($1,,[ 1622 LIBS="$LIBS -lm" 1623],[$1=-lm]) 1624fi 1625]) 1626dnl --------------------------------------------------------------------------- 1627dnl Check if the file-system supports mixed-case filenames. If we're able to 1628dnl create a lowercase name and see it as uppercase, it doesn't support that. 1629AC_DEFUN([CF_MIXEDCASE_FILENAMES], 1630[ 1631AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[ 1632 rm -f conftest CONFTEST 1633 echo test >conftest 1634 if test -f CONFTEST ; then 1635 cf_cv_mixedcase=no 1636 else 1637 cf_cv_mixedcase=yes 1638 fi 1639 rm -f conftest CONFTEST 1640]) 1641test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES) 1642])dnl 1643dnl --------------------------------------------------------------------------- 1644dnl Compute the object-directory name from the given model name 1645AC_DEFUN([CF_OBJ_SUBDIR], 1646[ 1647 case $1 in 1648 normal) $2='objects' ;; 1649 debug) $2='obj_g' ;; 1650 profile) $2='obj_p' ;; 1651 shared) $2='obj_s' ;; 1652 esac 1653])dnl 1654dnl --------------------------------------------------------------------------- 1655dnl Check the argument to see that it looks like a pathname. Rewrite it if it 1656dnl begins with one of the prefix/exec_prefix variables, and then again if the 1657dnl result begins with 'NONE'. This is necessary to workaround autoconf's 1658dnl delayed evaluation of those symbols. 1659AC_DEFUN([CF_PATH_SYNTAX],[ 1660case ".[$]$1" in #(vi 1661./*) #(vi 1662 ;; 1663.[a-zA-Z]:[\\/]*) #(vi OS/2 EMX 1664 ;; 1665.\[$]{*prefix}*) #(vi 1666 eval $1="[$]$1" 1667 case ".[$]$1" in #(vi 1668 .NONE/*) 1669 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@` 1670 ;; 1671 esac 1672 ;; #(vi 1673.NONE/*) 1674 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@` 1675 ;; 1676*) 1677 AC_ERROR(expected a pathname) 1678 ;; 1679esac 1680])dnl 1681dnl --------------------------------------------------------------------------- 1682dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX. 1683AC_DEFUN([CF_PROG_EXT], 1684[ 1685AC_REQUIRE([CF_CHECK_CACHE]) 1686PROG_EXT= 1687case $cf_cv_system_name in 1688os2*) 1689 # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@ 1690 CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__" 1691 CXXFLAGS="$CXXFLAGS -Zmt -D__ST_MT_ERRNO__" 1692 LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"` 1693 PROG_EXT=".exe" 1694 ;; 1695cygwin*) 1696 PROG_EXT=".exe" 1697 ;; 1698esac 1699AC_SUBST(PROG_EXT) 1700])dnl 1701dnl --------------------------------------------------------------------------- 1702dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the 1703dnl misc/tabset install won't work properly. Usually this happens only when 1704dnl using the fallback mkinstalldirs script 1705AC_DEFUN([CF_PROG_INSTALL], 1706[AC_PROG_INSTALL 1707case $INSTALL in 1708/*) 1709 ;; 1710*) 1711changequote({{,}})dnl 1712 cf_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'` 1713 test -z "$cf_dir" && cf_dir=. 1714changequote([,])dnl 1715 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's:^.*/::'` 1716 ;; 1717esac 1718])dnl 1719dnl --------------------------------------------------------------------------- 1720dnl Attempt to determine if we've got one of the flavors of regular-expression 1721dnl code that we can support. 1722AC_DEFUN([CF_REGEX], 1723[ 1724AC_MSG_CHECKING([for regular-expression headers]) 1725AC_CACHE_VAL(cf_cv_regex,[ 1726AC_TRY_LINK([#include <sys/types.h> 1727#include <regex.h>],[ 1728 regex_t *p; 1729 int x = regcomp(p, "", 0); 1730 int y = regexec(p, "", 0, 0, 0); 1731 regfree(p); 1732 ],[cf_cv_regex="regex.h"],[ 1733 AC_TRY_LINK([#include <regexp.h>],[ 1734 char *p = compile("", "", "", 0); 1735 int x = step("", ""); 1736 ],[cf_cv_regex="regexp.h"],[ 1737 cf_save_LIBS="$LIBS" 1738 LIBS="-lgen $LIBS" 1739 AC_TRY_LINK([#include <regexpr.h>],[ 1740 char *p = compile("", "", ""); 1741 int x = step("", ""); 1742 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])]) 1743]) 1744AC_MSG_RESULT($cf_cv_regex) 1745case $cf_cv_regex in 1746 regex.h) AC_DEFINE(HAVE_REGEX_H_FUNCS) ;; 1747 regexp.h) AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;; 1748 regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;; 1749esac 1750])dnl 1751dnl --------------------------------------------------------------------------- 1752dnl Attempt to determine the appropriate CC/LD options for creating a shared 1753dnl library. 1754dnl 1755dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the 1756dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib 1757dnl We avoid compiling-in a ../lib path for the shared library since that can 1758dnl lead to unexpected results at runtime. 1759dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries 1760dnl are compiled in ../../lib 1761dnl 1762dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure 1763dnl to install symbolic links to the rel/abi versions of shared libraries. 1764dnl 1765dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi 1766dnl version when making symbolic links. 1767dnl 1768dnl Some loaders leave 'so_locations' lying around. It's nice to clean up. 1769AC_DEFUN([CF_SHARED_OPTS], 1770[ 1771 AC_REQUIRE([CF_SUBST_NCURSES_VERSION]) 1772 LOCAL_LDFLAGS= 1773 LOCAL_LDFLAGS2= 1774 LD_SHARED_OPTS= 1775 INSTALL_LIB="-m 644" 1776 1777 cf_cv_do_symlinks=no 1778 1779 AC_MSG_CHECKING(if release/abi version should be used for shared libs) 1780 AC_ARG_WITH(shlib-version, 1781 [ --with-shlib-version=X Specify rel or abi version for shared libs], 1782 [test -z "$withval" && withval=auto 1783 case $withval in #(vi 1784 yes) #(vi 1785 cf_cv_shlib_version=auto 1786 ;; 1787 rel|abi|auto|no) #(vi 1788 cf_cv_shlib_version=$withval 1789 ;; 1790 *) 1791 AC_ERROR([option value must be one of: rel, abi, auto or no]) 1792 ;; 1793 esac 1794 ],[cf_cv_shlib_version=auto]) 1795 AC_MSG_RESULT($cf_cv_shlib_version) 1796 1797 cf_cv_rm_so_locs=no 1798 1799 # Some less-capable ports of gcc support only -fpic 1800 CC_SHARED_OPTS= 1801 if test "$GCC" = yes 1802 then 1803 AC_MSG_CHECKING(which $CC option to use) 1804 cf_save_CFLAGS="$CFLAGS" 1805 for CC_SHARED_OPTS in -fPIC -fpic '' 1806 do 1807 CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS" 1808 AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[]) 1809 done 1810 AC_MSG_RESULT($CC_SHARED_OPTS) 1811 CFLAGS="$cf_save_CFLAGS" 1812 fi 1813 1814 case $cf_cv_system_name in 1815 beos*) 1816 MK_SHARED_LIB='$(CC) -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0' 1817 ;; 1818 hpux*) 1819 # (tested with gcc 2.7.2 -- I don't have c89) 1820 if test "$GCC" = yes; then 1821 LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)' 1822 else 1823 CC_SHARED_OPTS='+Z' 1824 LD_SHARED_OPTS='-Wl,+b,$(libdir)' 1825 fi 1826 MK_SHARED_LIB='$(LD) +b $(libdir) -b -o $[@]' 1827 # HP-UX shared libraries must be executable, and should be 1828 # readonly to exploit a quirk in the memory manager. 1829 INSTALL_LIB="-m 555" 1830 ;; 1831 irix*) 1832 if test "$cf_cv_ld_rpath" = yes ; then 1833 cf_ld_rpath_opt="-Wl,-rpath," 1834 EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS" 1835 fi 1836 # tested with IRIX 5.2 and 'cc'. 1837 if test "$GCC" != yes; then 1838 CC_SHARED_OPTS='-KPIC' 1839 fi 1840 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]' 1841 cf_cv_rm_so_locs=yes 1842 ;; 1843 linux*|gnu*) 1844 if test "$DFT_LWR_MODEL" = "shared" ; then 1845 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib" 1846 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS" 1847 fi 1848 if test "$cf_cv_ld_rpath" = yes ; then 1849 cf_ld_rpath_opt="-Wl,-rpath," 1850 EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS" 1851 fi 1852 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel 1853 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION),-stats,-lc -o $[@]' 1854 ;; 1855 openbsd2*) 1856 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC" 1857 MK_SHARED_LIB='$(LD) -Bshareable -soname,`basename $[@].$(ABI_VERSION)` -o $[@]' 1858 ;; 1859 openbsd*|freebsd*) 1860 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC" 1861 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]' 1862 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel 1863 ;; 1864 netbsd*) 1865 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC" 1866 test "$cf_cv_ld_rpath" = yes && cf_ld_rpath_opt="-Wl,-rpath," 1867 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then 1868 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib" 1869 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS" 1870 EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS" 1871 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]' 1872 if test "$cf_cv_shlib_version" = auto; then 1873 if test ! -f /usr/libexec/ld.elf_so; then 1874 cf_cv_shlib_version=rel 1875 fi 1876 fi 1877 else 1878 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]' 1879 fi 1880 ;; 1881 osf*|mls+*) 1882 # tested with OSF/1 V3.2 and 'cc' 1883 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't 1884 # link with shared libs). 1885 MK_SHARED_LIB='$(LD) -set_version $(REL_VERSION):$(ABI_VERSION) -expect_unresolved "*" -shared -soname `basename $[@]`' 1886 case $host_os in 1887 osf4*) 1888 MK_SHARED_LIB="${MK_SHARED_LIB} -msym" 1889 ;; 1890 esac 1891 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]' 1892 if test "$DFT_LWR_MODEL" = "shared" ; then 1893 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib" 1894 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS" 1895 fi 1896 if test "$cf_cv_ld_rpath" = yes ; then 1897 cf_ld_rpath_opt="-rpath" 1898 # EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS" 1899 fi 1900 cf_cv_rm_so_locs=yes 1901 ;; 1902 sco3.2v5*) # (also uw2* and UW7) hops 13-Apr-98 1903 # tested with osr5.0.5 1904 if test "$ac_cv_prog_gcc" != yes; then 1905 CC_SHARED_OPTS='-belf -KPIC' 1906 fi 1907 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o [$]@' 1908 if test "$cf_cv_ld_rpath" = yes ; then 1909 # only way is to set LD_RUN_PATH but no switch for it 1910 RUN_PATH=$libdir 1911 fi 1912 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel 1913 LINK_PROGS='LD_RUN_PATH=$(libdir)' 1914 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib' 1915 ;; 1916 sunos4*) 1917 # tested with SunOS 4.1.1 and gcc 2.7.0 1918 if test "$ac_cv_prog_gcc" != yes; then 1919 CC_SHARED_OPTS='-KPIC' 1920 fi 1921 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@]' 1922 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel 1923 ;; 1924 solaris2*) 1925 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2 1926 if test "$ac_cv_prog_gcc" != yes; then 1927 CC_SHARED_OPTS='-KPIC' 1928 fi 1929 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]' 1930 if test "$DFT_LWR_MODEL" = "shared" ; then 1931 LOCAL_LDFLAGS="-R `pwd`/lib:\$(libdir)" 1932 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS" 1933 fi 1934 if test "$cf_cv_ld_rpath" = yes ; then 1935 cf_ld_rpath_opt="-R" 1936 EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS" 1937 fi 1938 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel 1939 ;; 1940 sysv5uw7*|unix_sv*) 1941 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc) 1942 if test "$ac_cv_prog_gcc" != yes; then 1943 CC_SHARED_OPTS='-KPIC' 1944 fi 1945 MK_SHARED_LIB='$(LD) -d y -G -o [$]@' 1946 ;; 1947 *) 1948 CC_SHARED_OPTS='unknown' 1949 MK_SHARED_LIB='echo unknown' 1950 ;; 1951 esac 1952 1953 # This works if the last tokens in $MK_SHARED_LIB are the -o target. 1954 case "$cf_cv_shlib_version" in #(vi 1955 rel|abi) 1956 case "$MK_SHARED_LIB" in #(vi 1957 *'-o $[@]') 1958 test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes 1959 ;; 1960 *) 1961 AC_MSG_WARN(ignored --with-shlib-version) 1962 ;; 1963 esac 1964 ;; 1965 esac 1966 1967 if test -n "$cf_ld_rpath_opt" ; then 1968 AC_MSG_CHECKING(if we need a space after rpath option) 1969 cf_save_LIBS="$LIBS" 1970 LIBS="$LIBS ${cf_ld_rpath_opt}$libdir" 1971 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes) 1972 LIBS="$cf_save_LIBS" 1973 AC_MSG_RESULT($cf_rpath_space) 1974 test "$cf_rpath_space" = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt " 1975 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)" 1976 fi 1977 1978 AC_SUBST(CC_SHARED_OPTS) 1979 AC_SUBST(LD_SHARED_OPTS) 1980 AC_SUBST(MK_SHARED_LIB) 1981 AC_SUBST(LINK_PROGS) 1982 AC_SUBST(LINK_TESTS) 1983 AC_SUBST(EXTRA_LDFLAGS) 1984 AC_SUBST(LOCAL_LDFLAGS) 1985 AC_SUBST(LOCAL_LDFLAGS2) 1986 AC_SUBST(INSTALL_LIB) 1987])dnl 1988dnl --------------------------------------------------------------------------- 1989dnl Check for definitions & structures needed for window size-changing 1990dnl FIXME: check that this works with "snake" (HP-UX 10.x) 1991AC_DEFUN([CF_SIZECHANGE], 1992[ 1993AC_REQUIRE([CF_STRUCT_TERMIOS]) 1994AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[ 1995 cf_cv_sizechange=unknown 1996 cf_save_CFLAGS="$CFLAGS" 1997 1998for cf_opts in "" "NEED_PTEM_H" 1999do 2000 2001 CFLAGS="$cf_save_CFLAGS" 2002 test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts" 2003 AC_TRY_COMPILE([#include <sys/types.h> 2004#ifdef HAVE_TERMIOS_H 2005#include <termios.h> 2006#else 2007#ifdef HAVE_TERMIO_H 2008#include <termio.h> 2009#endif 2010#endif 2011#ifdef NEED_PTEM_H 2012/* This is a workaround for SCO: they neglected to define struct winsize in 2013 * termios.h -- it's only in termio.h and ptem.h 2014 */ 2015#include <sys/stream.h> 2016#include <sys/ptem.h> 2017#endif 2018#if !defined(sun) || !defined(HAVE_TERMIOS_H) 2019#include <sys/ioctl.h> 2020#endif 2021],[ 2022#ifdef TIOCGSIZE 2023 struct ttysize win; /* FIXME: what system is this? */ 2024 int y = win.ts_lines; 2025 int x = win.ts_cols; 2026#else 2027#ifdef TIOCGWINSZ 2028 struct winsize win; 2029 int y = win.ws_row; 2030 int x = win.ws_col; 2031#else 2032 no TIOCGSIZE or TIOCGWINSZ 2033#endif /* TIOCGWINSZ */ 2034#endif /* TIOCGSIZE */ 2035 ], 2036 [cf_cv_sizechange=yes], 2037 [cf_cv_sizechange=no]) 2038 2039 CFLAGS="$cf_save_CFLAGS" 2040 if test "$cf_cv_sizechange" = yes ; then 2041 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC 2042 test -n "$cf_opts" && cf_cv_sizechange="$cf_opts" 2043 break 2044 fi 2045done 2046]) 2047if test "$cf_cv_sizechange" != no ; then 2048 AC_DEFINE(HAVE_SIZECHANGE) 2049 case $cf_cv_sizechange in #(vi 2050 NEED*) 2051 AC_DEFINE_UNQUOTED($cf_cv_sizechange ) 2052 ;; 2053 esac 2054fi 2055])dnl 2056dnl --------------------------------------------------------------------------- 2057dnl For each parameter, test if the source-directory exists, and if it contains 2058dnl a 'modules' file. If so, add to the list $cf_cv_src_modules which we'll 2059dnl use in CF_LIB_RULES. 2060dnl 2061dnl This uses the configured value to make the lists SRC_SUBDIRS and 2062dnl SUB_MAKEFILES which are used in the makefile-generation scheme. 2063AC_DEFUN([CF_SRC_MODULES], 2064[ 2065AC_MSG_CHECKING(for src modules) 2066 2067# dependencies and linker-arguments for test-programs 2068TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS" 2069TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS" 2070 2071# dependencies and linker-arguments for utility-programs 2072PROG_ARGS="$TEST_ARGS" 2073 2074cf_cv_src_modules= 2075for cf_dir in $1 2076do 2077 if test -f $srcdir/$cf_dir/modules; then 2078 2079 # We may/may not have tack in the distribution, though the 2080 # makefile is. 2081 if test $cf_dir = tack ; then 2082 if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then 2083 continue 2084 fi 2085 fi 2086 2087 if test -z "$cf_cv_src_modules"; then 2088 cf_cv_src_modules=$cf_dir 2089 else 2090 cf_cv_src_modules="$cf_cv_src_modules $cf_dir" 2091 fi 2092 2093 # Make the ncurses_cfg.h file record the library interface files as 2094 # well. These are header files that are the same name as their 2095 # directory. Ncurses is the only library that does not follow 2096 # that pattern. 2097 if test $cf_dir = tack ; then 2098 continue 2099 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then 2100 CF_UPPER(cf_have_include,$cf_dir) 2101 AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H) 2102 AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include}) 2103 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS" 2104 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS" 2105 fi 2106 fi 2107done 2108AC_MSG_RESULT($cf_cv_src_modules) 2109TEST_ARGS="-L${LIB_DIR} -L\$(libdir) $TEST_ARGS" 2110AC_SUBST(TEST_DEPS) 2111AC_SUBST(TEST_ARGS) 2112 2113PROG_ARGS="-L${LIB_DIR} -L\$(libdir) $PROG_ARGS" 2114AC_SUBST(PROG_ARGS) 2115 2116SRC_SUBDIRS="man include" 2117for cf_dir in $cf_cv_src_modules 2118do 2119 SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir" 2120done 2121SRC_SUBDIRS="$SRC_SUBDIRS misc test" 2122test "$cf_with_cxx_binding" != no && SRC_SUBDIRS="$SRC_SUBDIRS c++" 2123 2124ADA_SUBDIRS= 2125if test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then 2126 SRC_SUBDIRS="$SRC_SUBDIRS Ada95" 2127 ADA_SUBDIRS="gen src samples" 2128fi 2129 2130SUB_MAKEFILES= 2131for cf_dir in $SRC_SUBDIRS 2132do 2133 SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile" 2134done 2135 2136if test -n "$ADA_SUBDIRS"; then 2137 for cf_dir in $ADA_SUBDIRS 2138 do 2139 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile" 2140 done 2141 AC_SUBST(ADA_SUBDIRS) 2142fi 2143])dnl 2144dnl --------------------------------------------------------------------------- 2145dnl Check for -lstdc++, which is GNU's standard C++ library. 2146AC_DEFUN([CF_STDCPP_LIBRARY], 2147[ 2148if test -n "$GXX" ; then 2149case $cf_cv_system_name in #(vi 2150os2*) #(vi 2151 cf_stdcpp_libname=stdcpp 2152 ;; 2153*) 2154 cf_stdcpp_libname=stdc++ 2155 ;; 2156esac 2157AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[ 2158 cf_save="$LIBS" 2159 LIBS="$LIBS -l$cf_stdcpp_libname" 2160AC_TRY_LINK([ 2161#include <strstream.h>],[ 2162char buf[80]; 2163strstreambuf foo(buf, sizeof(buf)) 2164], 2165 [cf_cv_libstdcpp=yes], 2166 [cf_cv_libstdcpp=no]) 2167 LIBS="$cf_save" 2168]) 2169test "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname" 2170fi 2171])dnl 2172dnl --------------------------------------------------------------------------- 2173dnl Remove "-g" option from the compiler options 2174AC_DEFUN([CF_STRIP_G_OPT], 2175[$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl 2176dnl --------------------------------------------------------------------------- 2177dnl Check if we need _POSIX_SOURCE defined to use struct sigaction. We'll only 2178dnl do this if we've found the sigaction function. 2179dnl 2180dnl If needed, define SVR4_ACTION. 2181AC_DEFUN([CF_STRUCT_SIGACTION],[ 2182if test "$ac_cv_func_sigaction" = yes; then 2183AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE) 2184AC_TRY_COMPILE([ 2185#include <sys/types.h> 2186#include <signal.h>], 2187 [struct sigaction act], 2188 [sigact_bad=no], 2189 [ 2190AC_TRY_COMPILE([ 2191#define _POSIX_SOURCE 2192#include <sys/types.h> 2193#include <signal.h>], 2194 [struct sigaction act], 2195 [sigact_bad=yes 2196 AC_DEFINE(SVR4_ACTION)], 2197 [sigact_bad=unknown])]) 2198AC_MSG_RESULT($sigact_bad) 2199fi 2200])dnl 2201dnl --------------------------------------------------------------------------- 2202dnl Some machines require _POSIX_SOURCE to completely define struct termios. 2203dnl If so, define SVR4_TERMIO 2204AC_DEFUN([CF_STRUCT_TERMIOS],[ 2205AC_CHECK_HEADERS( \ 2206termio.h \ 2207termios.h \ 2208unistd.h \ 2209) 2210if test "$ISC" = yes ; then 2211 AC_CHECK_HEADERS( sys/termio.h ) 2212fi 2213if test "$ac_cv_header_termios_h" = yes ; then 2214 case "$CFLAGS" in 2215 *-D_POSIX_SOURCE*) 2216 termios_bad=dunno ;; 2217 *) termios_bad=maybe ;; 2218 esac 2219 if test "$termios_bad" = maybe ; then 2220 AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE) 2221 AC_TRY_COMPILE([#include <termios.h>], 2222 [struct termios foo; int x = foo.c_iflag], 2223 termios_bad=no, [ 2224 AC_TRY_COMPILE([ 2225#define _POSIX_SOURCE 2226#include <termios.h>], 2227 [struct termios foo; int x = foo.c_iflag], 2228 termios_bad=unknown, 2229 termios_bad=yes AC_DEFINE(SVR4_TERMIO)) 2230 ]) 2231 AC_MSG_RESULT($termios_bad) 2232 fi 2233fi 2234])dnl 2235dnl --------------------------------------------------------------------------- 2236dnl Shorthand macro for substituting things that the user may override 2237dnl with an environment variable. 2238dnl 2239dnl $1 = long/descriptive name 2240dnl $2 = environment variable 2241dnl $3 = default value 2242AC_DEFUN([CF_SUBST], 2243[AC_CACHE_VAL(cf_cv_subst_$2,[ 2244AC_MSG_CHECKING(for $1 (symbol $2)) 2245test -z "[$]$2" && $2=$3 2246AC_MSG_RESULT([$]$2) 2247AC_SUBST($2) 2248cf_cv_subst_$2=[$]$2]) 2249$2=${cf_cv_subst_$2} 2250])dnl 2251dnl --------------------------------------------------------------------------- 2252dnl Get the version-number for use in shared-library naming, etc. 2253AC_DEFUN([CF_SUBST_NCURSES_VERSION], 2254[ 2255changequote(,)dnl 2256NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`" 2257NCURSES_MINOR="`egrep '^NCURSES_MINOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`" 2258NCURSES_PATCH="`egrep '^NCURSES_PATCH[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`" 2259changequote([,])dnl 2260cf_cv_abi_version=${NCURSES_MAJOR} 2261cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR} 2262dnl Show the computed version, for logging 2263AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version (`date`)) 2264dnl We need these values in the generated headers 2265AC_SUBST(NCURSES_MAJOR) 2266AC_SUBST(NCURSES_MINOR) 2267AC_SUBST(NCURSES_PATCH) 2268dnl We need these values in the generated makefiles 2269AC_SUBST(cf_cv_rel_version) 2270AC_SUBST(cf_cv_abi_version) 2271AC_SUBST(cf_cv_cc_bool_type) 2272AC_SUBST(cf_cv_builtin_bool) 2273AC_SUBST(cf_cv_type_of_bool)dnl 2274])dnl 2275dnl --------------------------------------------------------------------------- 2276dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on 2277dnl older SCO configurations. 2278AC_DEFUN([CF_SYS_TIME_SELECT], 2279[ 2280AC_MSG_CHECKING(if sys/time.h works with sys/select.h) 2281AC_CACHE_VAL(cf_cv_sys_time_select,[ 2282AC_TRY_COMPILE([ 2283#include <sys/types.h> 2284#ifdef HAVE_SYS_TIME_H 2285#include <sys/time.h> 2286#endif 2287#ifdef HAVE_SYS_SELECT_H 2288#include <sys/select.h> 2289#endif 2290],[],[cf_cv_sys_time_select=yes], 2291 [cf_cv_sys_time_select=no]) 2292 ]) 2293AC_MSG_RESULT($cf_cv_sys_time_select) 2294test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT) 2295])dnl 2296dnl --------------------------------------------------------------------------- 2297dnl Determine the type we should use for chtype (and attr_t, which is treated 2298dnl as the same thing). We want around 32 bits, so on most machines want a 2299dnl long, but on newer 64-bit machines, probably want an int. If we're using 2300dnl wide characters, we have to have a type compatible with that, as well. 2301AC_DEFUN([CF_TYPEOF_CHTYPE], 2302[ 2303AC_REQUIRE([CF_UNSIGNED_LITERALS]) 2304AC_MSG_CHECKING([for type of chtype]) 2305AC_CACHE_VAL(cf_cv_typeof_chtype,[ 2306 AC_TRY_RUN([ 2307#ifdef USE_WIDEC_SUPPORT 2308#include <stddef.h> /* we want wchar_t */ 2309#define WANT_BITS 39 2310#else 2311#define WANT_BITS 31 2312#endif 2313#include <stdio.h> 2314int main() 2315{ 2316 FILE *fp = fopen("cf_test.out", "w"); 2317 if (fp != 0) { 2318 char *result = "long"; 2319#ifdef USE_WIDEC_SUPPORT 2320 /* 2321 * If wchar_t is smaller than a long, it must be an int or a 2322 * short. We prefer not to use a short anyway. 2323 */ 2324 if (sizeof(unsigned long) > sizeof(wchar_t)) 2325 result = "int"; 2326#endif 2327 if (sizeof(unsigned long) > sizeof(unsigned int)) { 2328 int n; 2329 unsigned int x; 2330 for (n = 0; n < WANT_BITS; n++) { 2331 unsigned int y = (x >> n); 2332 if (y != 1 || x == 0) { 2333 x = 0; 2334 break; 2335 } 2336 } 2337 /* 2338 * If x is nonzero, an int is big enough for the bits 2339 * that we want. 2340 */ 2341 result = (x != 0) ? "int" : "long"; 2342 } 2343 fputs(result, fp); 2344 fclose(fp); 2345 } 2346 exit(0); 2347} 2348 ], 2349 [cf_cv_typeof_chtype=`cat cf_test.out`], 2350 [cf_cv_typeof_chtype=long], 2351 [cf_cv_typeof_chtype=long]) 2352 rm -f cf_test.out 2353 ]) 2354AC_MSG_RESULT($cf_cv_typeof_chtype) 2355 2356AC_SUBST(cf_cv_typeof_chtype) 2357AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype) 2358 2359cf_cv_1UL="1" 2360test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U" 2361test "$cf_cv_typeof_chtype" = long && cf_cv_1UL="${cf_cv_1UL}L" 2362AC_SUBST(cf_cv_1UL) 2363 2364])dnl 2365dnl --------------------------------------------------------------------------- 2366dnl 2367AC_DEFUN([CF_TYPE_SIGACTION], 2368[ 2369AC_MSG_CHECKING([for type sigaction_t]) 2370AC_CACHE_VAL(cf_cv_type_sigaction,[ 2371 AC_TRY_COMPILE([ 2372#include <signal.h>], 2373 [sigaction_t x], 2374 [cf_cv_type_sigaction=yes], 2375 [cf_cv_type_sigaction=no])]) 2376AC_MSG_RESULT($cf_cv_type_sigaction) 2377test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION) 2378])dnl 2379dnl --------------------------------------------------------------------------- 2380dnl Test if the compiler supports 'U' and 'L' suffixes. Only old compilers 2381dnl won't, but they're still there. 2382AC_DEFUN([CF_UNSIGNED_LITERALS], 2383[ 2384AC_MSG_CHECKING([if unsigned literals are legal]) 2385AC_CACHE_VAL(cf_cv_unsigned_literals,[ 2386 AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1], 2387 [cf_cv_unsigned_literals=yes], 2388 [cf_cv_unsigned_literals=no]) 2389 ]) 2390AC_MSG_RESULT($cf_cv_unsigned_literals) 2391])dnl 2392dnl --------------------------------------------------------------------------- 2393dnl Make an uppercase version of a variable 2394dnl $1=uppercase($2) 2395AC_DEFUN([CF_UPPER], 2396[ 2397changequote(,)dnl 2398$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` 2399changequote([,])dnl 2400])dnl 2401dnl --------------------------------------------------------------------------- 2402dnl Compute the shift-mask that we'll use for wide-character indices. We use 2403dnl all but the index portion of chtype for storing attributes. 2404AC_DEFUN([CF_WIDEC_SHIFT], 2405[ 2406AC_REQUIRE([CF_TYPEOF_CHTYPE]) 2407AC_MSG_CHECKING([for number of bits in chtype]) 2408AC_CACHE_VAL(cf_cv_shift_limit,[ 2409 AC_TRY_RUN([ 2410#include <stdio.h> 2411int main() 2412{ 2413 FILE *fp = fopen("cf_test.out", "w"); 2414 if (fp != 0) { 2415 int n; 2416 unsigned TYPEOF_CHTYPE x = 1L; 2417 for (n = 0; ; n++) { 2418 unsigned long y = (x >> n); 2419 if (y != 1 || x == 0) 2420 break; 2421 x <<= 1; 2422 } 2423 fprintf(fp, "%d", n); 2424 fclose(fp); 2425 } 2426 exit(0); 2427} 2428 ], 2429 [cf_cv_shift_limit=`cat cf_test.out`], 2430 [cf_cv_shift_limit=32], 2431 [cf_cv_shift_limit=32]) 2432 rm -f cf_test.out 2433 ]) 2434AC_MSG_RESULT($cf_cv_shift_limit) 2435AC_SUBST(cf_cv_shift_limit) 2436 2437AC_MSG_CHECKING([for width of character-index]) 2438AC_CACHE_VAL(cf_cv_widec_shift,[ 2439if test ".$with_widec" = ".yes" ; then 2440 cf_attrs_width=39 2441 if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null ) 2442 then 2443 cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width` 2444 else 2445 cf_cv_widec_shift=16 2446 fi 2447else 2448 cf_cv_widec_shift=8 2449fi 2450]) 2451AC_MSG_RESULT($cf_cv_widec_shift) 2452AC_SUBST(cf_cv_widec_shift) 2453])dnl 2454dnl --------------------------------------------------------------------------- 2455dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just 2456dnl defaulting to yes/no. 2457dnl 2458dnl $1 = option name 2459dnl $2 = help-text 2460dnl $3 = environment variable to set 2461dnl $4 = default value, shown in the help-message, must be a constant 2462dnl $5 = default value, if it's an expression & cannot be in the help-message 2463dnl 2464AC_DEFUN([CF_WITH_PATH], 2465[AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),, 2466ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl 2467CF_PATH_SYNTAX(withval) 2468eval $3="$withval" 2469AC_SUBST($3)dnl 2470])dnl 2471dnl --------------------------------------------------------------------------- 2472dnl Process an option specifying a list of colon-separated paths. 2473dnl 2474dnl $1 = option name 2475dnl $2 = help-text 2476dnl $3 = environment variable to set 2477dnl $4 = default value, shown in the help-message, must be a constant 2478dnl $5 = default value, if it's an expression & cannot be in the help-message 2479dnl 2480AC_DEFUN([CF_WITH_PATHLIST],[ 2481AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),, 2482ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl 2483 2484IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" 2485cf_dst_path= 2486for cf_src_path in $withval 2487do 2488 CF_PATH_SYNTAX(cf_src_path) 2489 test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:" 2490 cf_dst_path="${cf_dst_path}${cf_src_path}" 2491done 2492IFS="$ac_save_ifs" 2493 2494eval $3="$cf_dst_path" 2495AC_SUBST($3)dnl 2496])dnl 2497