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