| 1 | dnl acinclude.m4 -- Extra macros needed for GNU make. | 
|---|
| 2 | dnl | 
|---|
| 3 | dnl Automake will incorporate this into its generated aclocal.m4. | 
|---|
| 4 |  | 
|---|
| 5 | dnl --------------------------------------------------------------------------- | 
|---|
| 6 | dnl Got this from the lynx 2.8 distribution. | 
|---|
| 7 | dnl by T.E.Dickey <dickey@clark.net> | 
|---|
| 8 | dnl and Jim Spath <jspath@mail.bcpl.lib.md.us> | 
|---|
| 9 | dnl and Philippe De Muyter <phdm@macqel.be> | 
|---|
| 10 | dnl | 
|---|
| 11 | dnl Created: 1997/1/28 | 
|---|
| 12 | dnl Updated: 1997/12/23 | 
|---|
| 13 | dnl --------------------------------------------------------------------------- | 
|---|
| 14 | dnl After checking for functions in the default $LIBS, make a further check | 
|---|
| 15 | dnl for the functions that are netlib-related (these aren't always in the | 
|---|
| 16 | dnl libc, etc., and have to be handled specially because there are conflicting | 
|---|
| 17 | dnl and broken implementations. | 
|---|
| 18 | dnl Common library requirements (in order): | 
|---|
| 19 | dnl     -lresolv -lsocket -lnsl | 
|---|
| 20 | dnl     -lnsl -lsocket | 
|---|
| 21 | dnl     -lsocket | 
|---|
| 22 | dnl     -lbsd | 
|---|
| 23 | AC_DEFUN([CF_NETLIBS],[ | 
|---|
| 24 | cf_test_netlibs=no | 
|---|
| 25 | AC_MSG_CHECKING(for network libraries) | 
|---|
| 26 | AC_CACHE_VAL(cf_cv_netlibs,[ | 
|---|
| 27 | AC_MSG_RESULT(working...) | 
|---|
| 28 | cf_cv_netlibs="" | 
|---|
| 29 | cf_test_netlibs=yes | 
|---|
| 30 | AC_CHECK_FUNCS(gethostname,,[ | 
|---|
| 31 | CF_RECHECK_FUNC(gethostname,nsl,cf_cv_netlibs,[ | 
|---|
| 32 | CF_RECHECK_FUNC(gethostname,socket,cf_cv_netlibs)])]) | 
|---|
| 33 | # | 
|---|
| 34 | # FIXME:  sequent needs this library (i.e., -lsocket -linet -lnsl), but | 
|---|
| 35 | # I don't know the entrypoints - 97/7/22 TD | 
|---|
| 36 | AC_CHECK_LIB(inet,main,cf_cv_netlibs="-linet $cf_cv_netlibs") | 
|---|
| 37 | # | 
|---|
| 38 | if test "$ac_cv_func_lsocket" != no ; then | 
|---|
| 39 | AC_CHECK_FUNCS(socket,,[ | 
|---|
| 40 | CF_RECHECK_FUNC(socket,socket,cf_cv_netlibs,[ | 
|---|
| 41 | CF_RECHECK_FUNC(socket,bsd,cf_cv_netlibs)])]) | 
|---|
| 42 | fi | 
|---|
| 43 | # | 
|---|
| 44 | AC_CHECK_FUNCS(gethostbyname,,[ | 
|---|
| 45 | CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)]) | 
|---|
| 46 | # | 
|---|
| 47 | AC_CHECK_FUNCS(strcasecmp,,[ | 
|---|
| 48 | CF_RECHECK_FUNC(strcasecmp,resolv,cf_cv_netlibs)]) | 
|---|
| 49 | ]) | 
|---|
| 50 | LIBS="$LIBS $cf_cv_netlibs" | 
|---|
| 51 | test $cf_test_netlibs = no && echo "$cf_cv_netlibs" >&AC_FD_MSG | 
|---|
| 52 | ])dnl | 
|---|
| 53 | dnl --------------------------------------------------------------------------- | 
|---|
| 54 | dnl Re-check on a function to see if we can pick it up by adding a library. | 
|---|
| 55 | dnl     $1 = function to check | 
|---|
| 56 | dnl     $2 = library to check in | 
|---|
| 57 | dnl     $3 = environment to update (e.g., $LIBS) | 
|---|
| 58 | dnl     $4 = what to do if this fails | 
|---|
| 59 | dnl | 
|---|
| 60 | dnl This uses 'unset' if the shell happens to support it, but leaves the | 
|---|
| 61 | dnl configuration variable set to 'unknown' if not.  This is a little better | 
|---|
| 62 | dnl than the normal autoconf test, which gives misleading results if a test | 
|---|
| 63 | dnl for the function is made (e.g., with AC_CHECK_FUNC) after this macro is | 
|---|
| 64 | dnl used (autoconf does not distinguish between a null token and one that is | 
|---|
| 65 | dnl set to 'no'). | 
|---|
| 66 | AC_DEFUN([CF_RECHECK_FUNC],[ | 
|---|
| 67 | AC_CHECK_LIB($2,$1,[ | 
|---|
| 68 | CF_UPPER(cf_tr_func,$1) | 
|---|
| 69 | AC_DEFINE_UNQUOTED(HAVE_$cf_tr_func,1,[Define if you have function $1]) | 
|---|
| 70 | ac_cv_func_$1=yes | 
|---|
| 71 | $3="-l$2 [$]$3"],[ | 
|---|
| 72 | ac_cv_func_$1=unknown | 
|---|
| 73 | unset ac_cv_func_$1 2>/dev/null | 
|---|
| 74 | $4], | 
|---|
| 75 | [[$]$3]) | 
|---|
| 76 | ])dnl | 
|---|
| 77 | dnl --------------------------------------------------------------------------- | 
|---|
| 78 | dnl Make an uppercase version of a variable | 
|---|
| 79 | dnl $1=uppercase($2) | 
|---|
| 80 | AC_DEFUN([CF_UPPER], | 
|---|
| 81 | [ | 
|---|
| 82 | changequote(,)dnl | 
|---|
| 83 | $1=`echo $2 | tr '[a-z]' '[A-Z]'` | 
|---|
| 84 | changequote([,])dnl | 
|---|
| 85 | ])dnl | 
|---|
| 86 |  | 
|---|
| 87 |  | 
|---|
| 88 | dnl --------------------------------------------------------------------------- | 
|---|
| 89 | dnl From Paul Eggert <eggert@twinsun.com> | 
|---|
| 90 |  | 
|---|
| 91 | AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC, | 
|---|
| 92 | [AC_CACHE_CHECK([for nanoseconds field of struct stat.st_mtim], | 
|---|
| 93 | ac_cv_struct_st_mtim_nsec, | 
|---|
| 94 | [ac_save_CPPFLAGS="$CPPFLAGS" | 
|---|
| 95 | ac_cv_struct_st_mtim_nsec=no | 
|---|
| 96 | # tv_nsec -- the usual case | 
|---|
| 97 | # _tv_nsec -- Solaris 2.6, if | 
|---|
| 98 | #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1 | 
|---|
| 99 | #    && !defined __EXTENSIONS__) | 
|---|
| 100 | # st__tim.tv_nsec -- UnixWare 2.1.2 | 
|---|
| 101 | for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do | 
|---|
| 102 | CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val" | 
|---|
| 103 | AC_TRY_COMPILE([#include <sys/types.h> | 
|---|
| 104 | #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;], | 
|---|
| 105 | [ac_cv_struct_st_mtim_nsec=$ac_val; break]) | 
|---|
| 106 | done | 
|---|
| 107 | CPPFLAGS="$ac_save_CPPFLAGS"]) | 
|---|
| 108 |  | 
|---|
| 109 | if test $ac_cv_struct_st_mtim_nsec != no; then | 
|---|
| 110 | AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec, [Define if 'struct stat' contains a nanoseconds field]) | 
|---|
| 111 | fi | 
|---|
| 112 | ] | 
|---|
| 113 | ) | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 | dnl --------------------------------------------------------------------------- | 
|---|
| 117 | dnl This will be in the next version of autoconf; take this out then! | 
|---|
| 118 |  | 
|---|
| 119 | # make_FUNC_SETVBUF_REVERSED | 
|---|
| 120 | # ------------------------ | 
|---|
| 121 | AC_DEFUN([make_FUNC_SETVBUF_REVERSED], | 
|---|
| 122 | [AC_REQUIRE([AC_C_PROTOTYPES])dnl | 
|---|
| 123 | AC_CACHE_CHECK(whether setvbuf arguments are reversed, | 
|---|
| 124 | ac_cv_func_setvbuf_reversed, | 
|---|
| 125 | [ac_cv_func_setvbuf_reversed=no | 
|---|
| 126 | AC_LINK_IFELSE( | 
|---|
| 127 | [AC_LANG_PROGRAM( | 
|---|
| 128 | [[#include <stdio.h> | 
|---|
| 129 | #         if PROTOTYPES | 
|---|
| 130 | int (setvbuf) (FILE *, int, char *, size_t); | 
|---|
| 131 | #         endif]], | 
|---|
| 132 | [[char buf; return setvbuf (stdout, _IOLBF, &buf, 1);]])], | 
|---|
| 133 | [AC_LINK_IFELSE( | 
|---|
| 134 | [AC_LANG_PROGRAM( | 
|---|
| 135 | [[#include <stdio.h> | 
|---|
| 136 | #            if PROTOTYPES | 
|---|
| 137 | int (setvbuf) (FILE *, int, char *, size_t); | 
|---|
| 138 | #            endif]], | 
|---|
| 139 | [[char buf; return setvbuf (stdout, &buf, _IOLBF, 1);]])], | 
|---|
| 140 | [# It compiles and links either way, so it must not be declared | 
|---|
| 141 | # with a prototype and most likely this is a K&R C compiler. | 
|---|
| 142 | # Try running it. | 
|---|
| 143 | AC_RUN_IFELSE( | 
|---|
| 144 | [AC_LANG_PROGRAM( | 
|---|
| 145 | [[#include <stdio.h>]], | 
|---|
| 146 | [[/* This call has the arguments reversed. | 
|---|
| 147 | A reversed system may check and see that the address of buf | 
|---|
| 148 | is not _IOLBF, _IONBF, or _IOFBF, and return nonzero.  */ | 
|---|
| 149 | char buf; | 
|---|
| 150 | if (setvbuf (stdout, _IOLBF, &buf, 1) != 0) | 
|---|
| 151 | exit (1); | 
|---|
| 152 | putchar ('\r'); | 
|---|
| 153 | exit (0); /* Non-reversed systems SEGV here.  */]])], | 
|---|
| 154 | ac_cv_func_setvbuf_reversed=yes, | 
|---|
| 155 | rm -f core core.* *.core, | 
|---|
| 156 | [[: # Assume setvbuf is not reversed when cross-compiling.]])] | 
|---|
| 157 | ac_cv_func_setvbuf_reversed=yes)])]) | 
|---|
| 158 | if test $ac_cv_func_setvbuf_reversed = yes; then | 
|---|
| 159 | AC_DEFINE(SETVBUF_REVERSED, 1, | 
|---|
| 160 | [Define to 1 if the `setvbuf' function takes the buffering type as | 
|---|
| 161 | its second argument and the buffer pointer as the third, as on | 
|---|
| 162 | System V before release 3.]) | 
|---|
| 163 | fi | 
|---|
| 164 | ])# make_FUNC_SETVBUF_REVERSED | 
|---|