dnl dnl $XFree86: xc/programs/xterm/aclocal.m4,v 3.1.2.8 1999/07/28 13:37:53 hohndel Exp $ dnl dnl --------------------------------------------------------------------------- dnl dnl Copyright 1997,1998,1999 by Thomas E. Dickey dnl dnl All Rights Reserved dnl dnl Permission to use, copy, modify, and distribute this software and its dnl documentation for any purpose and without fee is hereby granted, dnl provided that the above copyright notice appear in all copies and that dnl both that copyright notice and this permission notice appear in dnl supporting documentation, and that the name of the above listed dnl copyright holder(s) not be used in advertising or publicity pertaining dnl to distribution of the software without specific, written prior dnl permission. dnl dnl THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD dnl TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY dnl AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE dnl LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. dnl dnl --------------------------------------------------------------------------- dnl --------------------------------------------------------------------------- dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES' dnl in the sharutils 4.2 distribution. AC_DEFUN([CF_ANSI_CC_CHECK], [ AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) AC_CACHE_VAL(cf_cv_ansi_cc,[ cf_cv_ansi_cc=no cf_save_CFLAGS="$CFLAGS" # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE # SVR4 -Xc # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes) for cf_arg in "-DCC_HAS_PROTOS" \ "" \ -qlanglvl=ansi \ -std1 \ "-Aa -D_HPUX_SOURCE +e" \ "-Aa -D_HPUX_SOURCE" \ -Xc do CFLAGS="$cf_save_CFLAGS $cf_arg" AC_TRY_COMPILE( [ #ifndef CC_HAS_PROTOS #if !defined(__STDC__) || (__STDC__ != 1) choke me #endif #endif ],[ int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);};], [cf_cv_ansi_cc="$cf_arg"; break]) done CFLAGS="$cf_save_CFLAGS" ]) AC_MSG_RESULT($cf_cv_ansi_cc) if test "$cf_cv_ansi_cc" != "no"; then if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then CFLAGS="$CFLAGS $cf_cv_ansi_cc" else AC_DEFINE(CC_HAS_PROTOS) fi fi ])dnl dnl --------------------------------------------------------------------------- dnl Allow user to disable a normally-on option. AC_DEFUN([CF_ARG_DISABLE], [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl dnl --------------------------------------------------------------------------- dnl Allow user to enable a normally-off option. AC_DEFUN([CF_ARG_ENABLE], [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl dnl --------------------------------------------------------------------------- dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus dnl values. dnl dnl Parameters: dnl $1 = option name dnl $2 = help-string dnl $3 = action to perform if option is not default dnl $4 = action if perform if option is default dnl $5 = default option value (either 'yes' or 'no') AC_DEFUN([CF_ARG_OPTION], [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes) if test "$enableval" != "$5" ; then ifelse($3,,[ :]dnl ,[ $3]) ifelse($4,,,[ else $4]) fi],[enableval=$5 ifelse($4,,,[ $4 ])dnl ])])dnl dnl --------------------------------------------------------------------------- dnl Check if we're accidentally using a cache from a different machine. dnl Derive the system name, as a check for reusing the autoconf cache. dnl dnl If we've packaged config.guess and config.sub, run that (since it does a dnl better job than uname). AC_DEFUN([CF_CHECK_CACHE], [ if test -f $srcdir/config.guess ; then AC_CANONICAL_HOST system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name") AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"]) test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name") if test ".$system_name" != ".$cf_cv_system_name" ; then AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)) AC_ERROR("Please remove config.cache and try again.") fi ])dnl dnl --------------------------------------------------------------------------- dnl Check for data that is usually declared in or dnl $1 = the name to check AC_DEFUN([CF_CHECK_ERRNO], [ AC_MSG_CHECKING([declaration of $1]) AC_CACHE_VAL(cf_cv_dcl_$1,[ AC_TRY_COMPILE([ #if HAVE_STDLIB_H #include #endif #include #include #include ], [long x = (long) $1], [eval 'cf_cv_dcl_'$1'=yes'], [eval 'cf_cv_dcl_'$1'=no]')]) eval 'cf_result=$cf_cv_dcl_'$1 AC_MSG_RESULT($cf_result) # It's possible (for near-UNIX clones) that the data doesn't exist AC_CACHE_VAL(cf_cv_have_$1,[ if test $cf_result = no ; then eval 'cf_result=DECL_'$1 CF_UPPER(cf_result,$cf_result) AC_DEFINE_UNQUOTED($cf_result) AC_MSG_CHECKING([existence of $1]) AC_TRY_LINK([ #undef $1 extern long $1; ], [$1 = 2], [eval 'cf_cv_have_'$1'=yes'], [eval 'cf_cv_have_'$1'=no']) eval 'cf_result=$cf_cv_have_'$1 AC_MSG_RESULT($cf_result) else eval 'cf_cv_have_'$1'=yes' fi ]) eval 'cf_result=HAVE_'$1 CF_UPPER(cf_result,$cf_result) eval 'test $cf_cv_have_'$1' = yes && AC_DEFINE_UNQUOTED($cf_result)' ])dnl dnl --------------------------------------------------------------------------- dnl You can always use "make -n" to see the actual options, but it's hard to dnl pick out/analyze warning messages when the compile-line is long. dnl dnl Sets: dnl ECHO_LD - symbol to prefix "cc -o" lines dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o) dnl SHOW_CC - symbol to put before explicit "cc -c" lines dnl ECHO_CC - symbol to put before any "cc" line dnl AC_DEFUN([CF_DISABLE_ECHO],[ AC_MSG_CHECKING(if you want to see long compiling messages) CF_ARG_DISABLE(echo, [ --disable-echo test: display "compiling" commands], [ ECHO_LD='@echo linking [$]@;' RULE_CC=' @echo compiling [$]<' SHOW_CC=' @echo compiling [$]@' ECHO_CC='@' ],[ ECHO_LD='' RULE_CC='# compiling' SHOW_CC='# compiling' ECHO_CC='' ]) AC_MSG_RESULT($enableval) AC_SUBST(ECHO_LD) AC_SUBST(RULE_CC) AC_SUBST(SHOW_CC) AC_SUBST(ECHO_CC) ])dnl dnl --------------------------------------------------------------------------- dnl Check if 'errno' is declared in AC_DEFUN([CF_ERRNO], [ CF_CHECK_ERRNO(errno) ])dnl dnl --------------------------------------------------------------------------- dnl Check for memmove, or a bcopy that can handle overlapping copy. If neither dnl is found, add our own version of memmove to the list of objects. AC_DEFUN([CF_FUNC_MEMMOVE], [ AC_CHECK_FUNC(memmove,,[ AC_CHECK_FUNC(bcopy,[ AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[ AC_TRY_RUN([ int main() { static char data[] = "abcdefghijklmnopqrstuwwxyz"; char temp[40]; bcopy(data, temp, sizeof(data)); bcopy(temp+10, temp, 15); bcopy(temp+5, temp+15, 10); exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz")); } ], [cf_cv_good_bcopy=yes], [cf_cv_good_bcopy=no], [cf_cv_good_bcopy=unknown]) ]) ],[cf_cv_good_bcopy=no]) if test $cf_cv_good_bcopy = yes ; then AC_DEFINE(USE_OK_BCOPY) else AC_DEFINE(USE_MY_MEMMOVE) fi ])])dnl dnl --------------------------------------------------------------------------- dnl Check for tgetent function in termcap library. If we cannot find this, dnl we'll use the $LINES and $COLUMNS environment variables to pass screen dnl size information to subprocesses. (We cannot use terminfo's compatibility dnl function, since it cannot provide the termcap-format data). AC_DEFUN([CF_FUNC_TGETENT], [ AC_CACHE_CHECK(for full tgetent function,cf_cv_lib_tgetent,[ cf_save_LIBS="$LIBS" cf_cv_lib_tgetent=no cf_TERMLIB="termcap termlib ncurses curses" for cf_termlib in '' $cf_TERMLIB ; do LIBS="$cf_save_LIBS" test -n "$cf_termlib" && LIBS="$LIBS -l$cf_termlib" AC_TRY_RUN([ /* terminfo implementations ignore the buffer argument, making it useless for * the xterm application, which uses this information to make a new TERMCAP * environment variable. */ int main() { char buffer[1024]; buffer[0] = 0; tgetent(buffer, "vt100"); exit(buffer[0] == 0); }], [echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC if test -n "$cf_termlib" ; then cf_cv_lib_tgetent="-l$cf_termlib" else cf_cv_lib_tgetent=yes fi break], [echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC], [echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC]) done LIBS="$cf_save_LIBS" ]) # If we found a working tgetent(), set LIBS and check for termcap.h. # (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should # not have side effects other than setting the cache variable, because # they are not executed when a cached value exists.) if test "$cf_cv_lib_tgetent" != no ; then test "$cf_cv_lib_tgetent" != yes && LIBS="$LIBS $cf_cv_lib_tgetent" AC_CHECK_HEADERS(termcap.h) else # If we didn't find a tgetent() that supports the buffer # argument, look again to see whether we can find even # a crippled one. A crippled tgetent() is still useful to # validate values for the TERM environment variable given to # child processes. AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[ cf_cv_lib_part_tgetent=no for cf_termlib in $cf_TERMLIB ; do LIBS="$cf_save_LIBS -l$cf_termlib" AC_TRY_LINK([],[tgetent(0, 0)], [echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC cf_cv_lib_part_tgetent="-l$cf_termlib" break]) done LIBS="$cf_save_LIBS" ]) if test "$cf_cv_lib_part_tgetent" != no ; then LIBS="$LIBS $cf_cv_lib_part_tgetent" AC_CHECK_HEADERS(termcap.h) # If this is linking against ncurses, we'll trigger the # ifdef in resize.c that turns the termcap stuff back off. AC_DEFINE(USE_TERMINFO) fi fi ])dnl dnl --------------------------------------------------------------------------- dnl Test for availability of useful gcc __attribute__ directives to quiet dnl compiler warnings. Though useful, not all are supported -- and contrary dnl to documentation, unrecognized directives cause older compilers to barf. AC_DEFUN([CF_GCC_ATTRIBUTES], [ if test -n "$GCC" then cat > conftest.i < conftest.$ac_ext <&AC_FD_CC case $cf_attribute in scanf|printf) cat >conftest.h <conftest.h <>confdefs.h # else # sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h fi done else fgrep define conftest.i >>confdefs.h fi rm -rf conftest* fi ])dnl dnl --------------------------------------------------------------------------- dnl Check if the compiler supports useful warning options. There's a few that dnl we don't use, simply because they're too noisy: dnl dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x) dnl -Wredundant-decls (system headers make this too noisy) dnl -Wtraditional (combines too many unrelated messages, only a few useful) dnl -Wwrite-strings (too noisy, but should review occasionally) dnl -pedantic dnl AC_DEFUN([CF_GCC_WARNINGS], [ if test -n "$GCC" then changequote(,)dnl cat > conftest.$ac_ext <./Imakefile test -f $cf_makefile && cat $cf_makefile >>./Imakefile cat >> ./Imakefile <<'CF_EOF' findstddefs: @echo 'IMAKE_CFLAGS="${ALLDEFINES} ifelse($1,,,$1)"' @echo 'IMAKE_LOADFLAGS="${EXTRA_LOAD_FLAGS} ifelse($2,,,$2)"' CF_EOF if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile) then CF_VERBOSE(Using $IMAKE) else # sometimes imake doesn't have the config path compiled in. Find it. cf_config= for cf_libpath in $X_LIBS $LIBS ; do case $cf_libpath in # (vi -L*) cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'` cf_libpath=$cf_libpath/X11/config if test -d $cf_libpath ; then cf_config=$cf_libpath break fi ;; esac done if test -z "$cf_config" ; then AC_WARN(Could not find imake config-directory) else cf_imake_opts="$cf_imake_opts -I$cf_config" if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC) then CF_VERBOSE(Using $IMAKE $cf_config) else AC_WARN(Cannot run $IMAKE) fi fi fi # GNU make sometimes prints "make[1]: Entering...", which # would confuse us. eval `make findstddefs 2>/dev/null | grep -v make` cd .. rm -rf conftestdir # We use $(ALLDEFINES) rather than $(STD_DEFINES) because the former # declares XTFUNCPROTO there. However, some vendors (e.g., SGI) have # modified it to support site.cf, adding a kludge for the /usr/include # directory. Try to filter that out, otherwise gcc won't find its # headers. if test -n "$GCC" ; then if test -n "$IMAKE_CFLAGS" ; then cf_nostdinc="" cf_std_incl="" cf_cpp_opts="" for cf_opt in $IMAKE_CFLAGS do case "$cf_opt" in -nostdinc) #(vi cf_nostdinc="$cf_opt" ;; -I/usr/include) #(vi cf_std_incl="$cf_opt" ;; *) #(vi cf_cpp_opts="$cf_cpp_opts $cf_opt" ;; esac done if test -z "$cf_nostdinc" ; then IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl" elif test -z "$cf_std_incl" ; then IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc" else CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\") IMAKE_CFLAGS="$cf_cpp_opts" fi fi fi fi AC_SUBST(IMAKE_CFLAGS) AC_SUBST(IMAKE_LOADFLAGS) ])dnl dnl --------------------------------------------------------------------------- dnl On both Ultrix and CLIX, I find size_t defined in AC_DEFUN([CF_SIZE_T], [ AC_MSG_CHECKING(for size_t in or ) AC_CACHE_VAL(cf_cv_type_size_t,[ AC_TRY_COMPILE([ #include #if STDC_HEADERS #include #include #endif #include ], [size_t x], [cf_cv_type_size_t=yes], [cf_cv_type_size_t=no]) ]) AC_MSG_RESULT($cf_cv_type_size_t) test $cf_cv_type_size_t = no && AC_DEFINE(size_t, unsigned) ])dnl dnl --------------------------------------------------------------------------- dnl Check for the declaration of fd_set. Some platforms declare it in dnl , and some in , which requires AC_DEFUN([CF_TYPE_FD_SET], [ AC_MSG_CHECKING(for declaration of fd_set) AC_CACHE_VAL(cf_cv_type_fd_set,[ AC_TRY_COMPILE([ #include ], [fd_set x], [cf_cv_type_fd_set=sys/types.h], [AC_TRY_COMPILE([ #include #include ], [fd_set x], [cf_cv_type_fd_set=sys/select.h], [cf_cv_type_fd_set=unknown])])]) AC_MSG_RESULT($cf_cv_type_fd_set) if test $cf_cv_type_fd_set = sys/select.h ; then AC_DEFINE(USE_SYS_SELECT_H) fi ]) dnl --------------------------------------------------------------------------- dnl Make an uppercase version of a variable dnl $1=uppercase($2) AC_DEFUN([CF_UPPER], [ changequote(,)dnl $1=`echo $2 | tr '[a-z]' '[A-Z]'` changequote([,])dnl ])dnl dnl --------------------------------------------------------------------------- dnl Use AC_VERBOSE w/o the warnings AC_DEFUN([CF_VERBOSE], [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG ])dnl dnl --------------------------------------------------------------------------- dnl Check if xterm is installed setuid, assume we want to do the same on a dnl new install AC_DEFUN([CF_XTERM_MODE],[ AC_PATH_PROG(XTERM_PATH,xterm) XTERM_MODE=755 AC_MSG_CHECKING(for presumed installation-mode) if test -f "$XTERM_PATH" ; then ls -Ll $XTERM_PATH >conftest.out read cf_mode cf_rest