]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/ncftp/ncftp/acinclude.m4
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / ncftp / ncftp / acinclude.m4
1 AC_DEFUN([wi_ARG_WITH_SOCKS5], [
2         AC_ARG_WITH(socks5,[  --with-socks5           try to find and use the SOCKS5 library],wi_want_socks5=$withval,wi_want_socks5=no)
3 ])
4 dnl
5 dnl
6 dnl
7 dnl
8 AH_TEMPLATE([SOCKS], [define if using the socks library])
9 AC_DEFUN([wi_LIB_SOCKS5], [
10         if test "$wi_want_socks5" != yes ; then
11                 ac_cv_lib_socks5_SOCKSinit=no
12         else
13                 # Look for the "SOCKS" library for use with Firewalls/Gateways.
14                 SOCKS_LIBS=''
15
16                 # First check for extra libraries that may be needed to
17                 # link against socks.  If we already checked for one or
18                 # more of these libraries, we don't want to count them
19                 # in the socks-only list.
20                 #
21                 if test "x$ac_cv_lib_db_main" = "x" ; then
22                         AC_CHECK_LIB(db,main,[SOCKS_LIBS="$SOCKS_LIBS -ldb"])
23                 fi
24                 if test "x$ac_cv_lib_isode_main" = "x" ; then
25                         AC_CHECK_LIB(isode,main,[SOCKS_LIBS="$SOCKS_LIBS -lisode"])
26                 fi
27                 if test "x$ac_cv_lib_com_err_main" = "x" ; then
28                         AC_CHECK_LIB(com_err,main,[SOCKS_LIBS="$SOCKS_LIBS -lcom_err"])
29                 fi
30                 if test "x$ac_cv_lib_crypto_main" = "x" ; then
31                         AC_CHECK_LIB(crypto,main,[SOCKS_LIBS="$SOCKS_LIBS -lcrypto"])
32                 fi
33                 if test "x$ac_cv_lib_krb5_main" = "x" ; then
34                         AC_CHECK_LIB(krb5,main,[SOCKS_LIBS="$SOCKS_LIBS -lkrb5"])
35                 fi
36                 if test "x$ac_cv_lib_gssapi_krb5_main" = "x" ; then
37                         AC_CHECK_LIB(gssapi_krb5,main,[SOCKS_LIBS="$SOCKS_LIBS -lgssapi_krb5"])
38                 fi
39
40                 AC_CHECK_LIB(socks5,SOCKSinit,[SOCKS_LIBS="$SOCKS_LIBS -lsocks5"])
41                 AC_CHECK_HEADERS(socks.h socks5p.h)
42
43                 if test "$ac_cv_lib_socks5_SOCKSinit" != yes ; then
44                         ac_cv_lib_socks5_SOCKSinit=no
45                         unset SOCKS_LIBS
46                 else
47                         AC_SUBST(SOCKS_LIBS)
48                         AC_DEFINE(SOCKS,5)
49                 fi
50         fi
51         AC_MSG_CHECKING([if SOCKS5 will be used])
52         AC_MSG_RESULT([$ac_cv_lib_socks5_SOCKSinit])
53 ])
54 dnl
55 dnl
56 dnl
57 dnl
58 AC_DEFUN([wi_ARG_ENABLE_DEBUG], [
59 # if DEBUGBUILD is yes, other macros try to set up a compilation environment
60 # with debugging symbols enabled.  Example macros which are affected are
61 # wi_CFLAGS and wi_SFLAG.
62 #
63 AC_ARG_ENABLE(debug,
64 [  --enable-debug          enable debugging symbols],
65 [
66         DEBUGBUILD=no
67         DEBUGCONFIGUREFLAG=""
68         if test "$enableval" != "no" ; then
69                 DEBUGBUILD=yes
70                 DEBUGCONFIGUREFLAG="--enable-debug"
71         fi
72 ],[
73 dnl     # Argument not specified; default is disabled.
74         DEBUGBUILD=no
75         DEBUGCONFIGUREFLAG=""
76 ])
77 ])
78 dnl
79 dnl
80 dnl
81 dnl
82 AC_DEFUN([wi_ARG_DISABLE_CCDV], [
83 AC_ARG_ENABLE(ccdv,[  --disable-ccdv          disable use of ccdv program in Makefiles],use_ccdv="$enableval",use_ccdv=yes)
84 ])
85 dnl
86 dnl
87 dnl
88 dnl
89 AC_DEFUN([wi_ARG_DISABLE_PRECOMP], [
90 AC_ARG_ENABLE(ccdv,[  --disable-precomp       disable use of precompiled header files],use_precomp="$enableval",use_precomp=yes)
91 ])
92 dnl
93 dnl
94 dnl
95 dnl
96 AH_TEMPLATE([PRAGMA_HDRSTOP], [])
97 AC_DEFUN([wi_CC_PRECOMP], [
98 AC_CACHE_CHECK([if the C compiler can use precompiled headers], [wi_cv_cc_precomp], [
99         result="no"
100         if test "${use_precomp-yes}" != no ; then
101                 wi_cv_cc_precomp_type="unknown"
102                 /bin/rm -f pchtest.h pchtest.p pchtest.c pchtest.o pchtest csetc.pch pchtest.pch pchtest.h.gch
103                 cat <<EOF > pchtest.h
104 /* pchtest.h */
105 #include <stdio.h>
106 #include <string.h>
107 #include <stdlib.h>
108 #define FOOBAR 33       /* Make sure it can compile custom headers too */
109 EOF
110                 cat <<EOF > pchtest.c
111 /* pchtest.c */
112 #include "pchtest.h"
113
114 main()
115 {
116         if (FOOBAR == 33)
117                 exit(0);
118         exit(1);
119 }
120 EOF
121                 if test "$GCC" = yes ; then
122                         #
123                         # Try gcc 3.4's built-in implementation first
124                         #
125                         echo ${CC-cc} $CPPFLAGS pchtest.h -c >&5
126                         ${CC-cc} $CPPFLAGS pchtest.h -c >&5 2>&5
127                         if test -f pchtest.h.gch ; then
128                                 #
129                                 # Good, the .gch file was created.
130                                 # Odds are we're good to go.
131                                 #
132                                 echo "Successfully compiled pchtest.h into the precompiled header file pchtest.h.gch." >&5
133                                 AC_TRY_COMPILE([#include "pchtest.h"],[if (FOOBAR == 33) exit(0)],[result="yes" ; wi_cv_cc_precomp_type="gcc_gch_files"],[result="no"])
134                         else
135                                 echo "This version of GCC did not compile pchtest.h into the precompiled header file pchtest.h.gch." >&5
136                                 #
137                                 # See if Apple's implementation works.
138                                 #
139                                 echo ${CC-cc} $CPPFLAGS -precomp pchtest.h -o pchtest.p >&5 
140                                 ${CC-cc} $CPPFLAGS -precomp pchtest.h -o pchtest.p >&5 2>&5
141                                 if test -s pchtest.p ; then
142                                         AC_TRY_COMPILE([#include "pchtest.h"],[if (FOOBAR == 33) exit(0)],[result="yes" ; wi_cv_cc_precomp_type="gcc_dash_precomp"],[result="no"])
143                                 fi
144                         fi
145                 elif test "${result}_${SYS-aix}_${GCC}" = "no_aix_no" ; then
146                         #
147                         # AIX xlc
148                         #
149                         echo ${CC-cc} $CPPFLAGS -qusepcomp -qgenpcomp pchtest.c -o pchtest >&5
150                         ${CC-cc} $CPPFLAGS -qusepcomp -qgenpcomp pchtest.c -o pchtest >&5 2>&5
151                         if test -s pchtest ; then
152                                 result="yes"
153                                 wi_cv_cc_precomp_type="xlc"
154                                 wi_CFLAGS_TO_ADD_LATER="$wi_CFLAGS_TO_ADD_LATER -qusepcomp -qgenpcomp"
155                         fi
156                 else
157                         #
158                         # IRIX, Compaq C
159                         #
160                         cat <<EOF > pchtest.c
161 #include "pchtest.h"
162 #pragma hdrstop
163 #include <stdarg.h>
164
165 main() { exit(0); }
166 EOF
167                         for pchflags in "-pch -no_pch_messages" "-pch" "-LANG:pch"
168                         do
169                                 /bin/rm -f pchtest.pch
170                                 echo ${CC-cc} $CPPFLAGS $pchflags pchtest.c -o pchtest >&5
171                                 ${CC-cc} $CPPFLAGS $pchflags pchtest.c -o pchtest >&5 2>&5
172                                 if test -f pchtest.pch ; then
173                                         result="yes"
174                                         wi_cv_cc_precomp_type="ccc"
175                                         wi_CFLAGS_TO_ADD_LATER="$wi_CFLAGS_TO_ADD_LATER $pchflags"
176                                         AC_DEFINE(PRAGMA_HDRSTOP)
177                                         break
178                                 fi
179                         done
180                         unset pchflags
181                 fi
182                 /bin/rm -f pchtest.h pchtest.p pchtest.c pchtest.o pchtest csetc.pch pchtest.pch pchtest.h.gch
183         fi
184         wi_cv_cc_precomp="$result"
185 ])
186 ])
187 dnl
188 dnl
189 dnl
190 dnl
191 AC_DEFUN([wi_TEST_DASH_L], [
192 AC_CACHE_CHECK([if shell can test for symlinks], [wi_cv_shell_test_symlinks], [
193 wi_cv_shell_test_symlinks="no"
194 wi_cv_test_L="false"
195 wi_cv_test_not_L=":"
196 /bin/rm -f config.lnk
197 if test ! -f "config.lnk" ; then
198         /bin/ln -s /bin/ln config.lnk
199         if test -f "config.lnk" ; then
200                 ( if test -L config.lnk ; then /bin/rm -f config.lnk ; fi ) 2>/dev/null
201                 if test ! -f "config.lnk" ; then
202                         wi_cv_shell_test_symlinks="yes"
203                         wi_cv_test_L='test -L'
204                         wi_cv_test_not_L='test ! -L'
205                 else
206                         ( if test -h config.lnk ; then /bin/rm -f config.lnk ; fi ) 2>/dev/null
207                         if test ! -f "config.lnk" ; then
208                                 wi_cv_shell_test_symlinks="yes"
209                                 wi_cv_test_L='test -h'
210                                 wi_cv_test_not_L='test ! -h'
211                         fi
212                 fi
213         fi
214         /bin/rm -f config.lnk
215 fi
216 ])
217 test_L="$wi_cv_test_L"
218 test_not_L="$wi_cv_test_not_L"
219 ])
220 dnl
221 dnl
222 dnl
223 dnl
224 AC_DEFUN([wi_EXTRA_IDIR], [
225 incdir="$1"
226 if test -r $incdir ; then
227         case "$CPPFLAGS" in
228                 *${incdir}*)
229                         # echo "   + already had $incdir" 1>&6
230                         ;;
231                 *)
232                         if test "$CPPFLAGS" = "" ; then
233                                 CPPFLAGS="-I$incdir"
234                         else
235                                 CPPFLAGS="$CPPFLAGS -I$incdir"
236                         fi
237                         echo "   + found $incdir" 1>&6
238                         ;;
239         esac
240 fi
241 ])
242 dnl
243 dnl
244 dnl
245 dnl
246 AC_DEFUN([wi_EXTRA_LDIR], [
247 libdir="$1"
248 if test -r $libdir ; then
249         case "$LDFLAGS" in
250                 *${libdir}*)
251                         # echo "   + already had $libdir" 1>&6
252                         ;;
253                 *)
254                         if test "$LDFLAGS" = "" ; then
255                                 LDFLAGS="-L$libdir"
256                         else
257                                 LDFLAGS="$LDFLAGS -L$libdir"
258                         fi
259                         echo "   + found $libdir" 1>&6
260                         ;;
261         esac
262 fi
263 ])
264 dnl
265 dnl
266 dnl
267 dnl
268 AC_DEFUN([wi_GNU_LD], [
269 AC_MSG_CHECKING([for GNU ld])
270 wi_cv_prog_ld="ld"
271 result="no"
272 x=`ld --version 2>/dev/null | fgrep GNU`
273 if test "$x" != "" ; then
274         wi_cv_prog_ld="gld"
275         result="yes"
276 fi
277 AC_MSG_RESULT($result)
278 ])
279 dnl
280 dnl
281 dnl
282 dnl
283 AC_DEFUN([wi_LD_READONLY_TEXT], [
284 if test "$SYS$wi_cv_prog_ld" = "linuxgld" ; then
285         LDFLAGS="$LDFLAGS -Xlinker -n"
286 fi
287 ])
288 dnl
289 dnl
290 dnl
291 dnl
292 AC_DEFUN([wi_FUNC_STRSIGNAL], [
293         case "$OS" in
294                 aix4.3*)
295                         # It didn't appear until several ML packs
296                         # into 4.3.3
297                         #
298                         ;;
299                 *)
300                         AC_CHECK_FUNCS(strsignal)
301                         ;;
302         esac
303 ])
304 dnl
305 dnl
306 dnl
307 dnl
308 AC_DEFUN([wi_FUNC_GETCWD], [
309 if test "${SYS}" = sunos ; then
310         # Use getwd on SunOS -- getcwd does a "popen("/bin/pwd")" -- aaaccck.
311         #
312         AC_CHECK_FUNCS(getwd)
313 else
314         AC_CHECK_FUNCS(getcwd getwd)
315 fi
316 if test "$ac_cv_func_getcwd" = no && test "$ac_cv_func_getwd" = no ; then
317 AC_WARN(This system does not have either getwd or getcwd?)
318 AC_WARN(I find that a little hard to believe.)
319 AC_WARN(You may want to try -DHAVE_GETWD anyway.)
320 AC_WARN([
321 This could also mean that your compiler isn't working])
322 AC_WARN(with this configure script.  Check the ./config.log)
323 AC_WARN(and look for anomalies.)
324 fi
325 ])
326 dnl
327 dnl
328 dnl
329 dnl
330 AC_DEFUN([wi_EXTRA_SYSV_SUNOS_DIRS], [
331 if test "${SYS-sunos}" = sunos ; then
332         AC_MSG_CHECKING([for System V compatibility directories])
333         AC_MSG_RESULT([])
334         wi_EXTRA_IDIR("/usr/5include")
335         wi_EXTRA_LDIR("/usr/5lib")
336 fi
337 ])
338 dnl
339 dnl
340 dnl If you want to also look for include and lib subdirectories in the
341 dnl $HOME tree, you supply "yes" as the first argument to this macro.
342 dnl
343 dnl If you want to look for subdirectories in include/lib directories,
344 dnl you pass the names in argument 3, otherwise pass a dash.
345 dnl
346 AC_DEFUN([wi_EXTRA_DIRS], [
347 AC_MSG_CHECKING([for extra include and lib directories])
348 AC_MSG_RESULT([])
349 ifelse([$1], yes, [dnl
350 b1=`cd .. ; pwd`
351 b2=`cd ../.. ; pwd`
352 exdirs="$HOME $j $b1 $b2 $prefix $2"
353 if test -x "$HOME/bin/OS" ; then
354         b3=`$HOME/bin/OS`
355         b3="$HOME/$b3"
356         if test -d "$b3" ; then
357                 exdirs="$b3 $exdirs"
358         fi
359 fi
360 ],[dnl
361 exdirs="$prefix $2"
362 ])
363 subexdirs="$3"
364 if test "$subexdirs" = "" ; then
365         subexdirs="-"
366 fi
367 for subexdir in $subexdirs ; do
368 if test "$subexdir" = "-" ; then
369         subexdir=""
370 else
371         subexdir="/$subexdir"
372 fi
373 for exdir in $exdirs ; do
374         case "$exdir" in
375                 "/usr"|"/"|"//")
376                         if test "$exdir" = "//" ; then exdir="/" ; fi
377                         if test "$subexdir" != ""; then
378                                 incdir="${exdir}/include${subexdir}"
379                                 wi_EXTRA_IDIR($incdir)
380
381                                 libdir="${exdir}/lib${subexdir}"
382                                 wi_EXTRA_LDIR($libdir)
383                         fi
384                         ;;
385                 *)
386                         if test "$subexdir" = ""; then
387                                 incdir="${exdir}/include${subexdir}"
388                                 wi_EXTRA_IDIR($incdir)
389
390                                 libdir="${exdir}/lib${subexdir}"
391                                 wi_EXTRA_LDIR($libdir)
392                         fi
393                         ;;
394         esac
395 done
396 done
397 ])
398 dnl
399 dnl
400 dnl
401 AC_DEFUN([wi_HPUX_CFLAGS],
402 [AC_MSG_CHECKING(if HP-UX ansi C compiler flags are needed)
403 AC_REQUIRE([AC_PROG_CC])
404 AC_REQUIRE([wi_OS_VAR])
405 ac_cv_hpux_flags=no
406 if test "$os" = hp-ux ; then
407         if test "$GCC" = yes ; then
408                 if test "$CFLAGS" != "" ; then
409                         # Shouldn't be in there.
410 changequote(<<, >>)dnl
411                         CFLAGS=`echo "$CFLAGS" | sed 's/-A[ae]//g'`
412 changequote([, ])dnl
413                         case "$CFLAGS" in
414                                 *_HPUX_SOURCE*)
415                                         ;;
416                                 *)
417                                         # This is required for the extended
418                                         # namespace.
419                                         #
420                                         CFLAGS="-D_HPUX_SOURCE $CFLAGS"
421                                         ;;
422                         esac
423                 fi
424         else
425                 # If you're not using gcc, then you better have a cc/c89
426                 # that is usable.  If you have the barebones compiler, it
427                 # won't work.  The good compiler uses -Aa for the ANSI
428                 # compatible stuff.
429 changequote(<<, >>)dnl
430                 x=`echo "$CFLAGS" | grep 'A[ae]' 2>/dev/null`
431 changequote([, ])dnl
432                 if test "$x" = "" ; then
433                         CFLAGS="$CFLAGS -Ae"
434                 fi
435         fi
436         ac_cv_hpux_flags=yes
437 fi
438 AC_MSG_RESULT($ac_cv_hpux_flags)
439 ])
440 dnl
441 dnl
442 dnl
443 AC_DEFUN([wi_OS_DEFAULT_CFLAGS], [
444 AC_MSG_CHECKING(if we should customize your CFLAGS environment variable)
445 wi_replace_O_with_g="no"
446 case "$wi_orig_CFLAGS" in
447         "")
448                 wi_replace_O_with_g="no"
449                 ;;
450         "-g -O2")
451                 wi_replace_O_with_g="no"
452                 ;;
453         "-g -O")
454                 wi_replace_O_with_g="no"
455                 ;;
456         "-O2 -g")
457                 wi_replace_O_with_g="no"
458                 ;;
459         "-O -g")
460                 wi_replace_O_with_g="no"
461                 ;;
462         -g)
463                 wi_replace_O_with_g="yes"
464                 ;;
465 esac
466
467 #
468 # See if your CFLAGS environment variable wasn't set or exported,
469 # or if you are using a conservative default.  If so, we will
470 # add some additional flags for better performance, warning reporting,
471 # etc.
472 #
473 # Note we are now checking the current value of CFLAGS, which may have
474 # been changed by configure.
475 #
476 wi_os_default_cflags="no"
477 case "$CFLAGS" in
478         "")
479                 wi_os_default_cflags="yes"
480                 ;;
481         "-g -O2")
482                 wi_os_default_cflags="yes"
483                 ;;
484         "-g -O")
485                 wi_os_default_cflags="yes"
486                 ;;
487         "-O2 -g")
488                 wi_os_default_cflags="yes"
489                 ;;
490         "-O -g")
491                 wi_os_default_cflags="yes"
492                 ;;
493         -g)
494                 wi_os_default_cflags="yes"
495                 ;;
496         -O)
497                 wi_os_default_cflags="yes"
498                 ;;
499         -O2)
500                 wi_os_default_cflags="yes"
501                 ;;
502 esac
503
504 if test "$wi_os_default_cflags" = yes ; then
505         if test "$GCC" = yes ; then
506                 #
507                 # gcc
508                 #
509                 wi_gcc_optimizer_flags=''
510                 case "$wi_cv_gcc_version" in
511                         2.7.*|2.8.*|2.9*)
512                                 wi_os_default_cflags="-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wbad-function-cast -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wmissing-declarations -Winline"
513                                 ;;
514                         3.*)
515                                 wi_os_default_cflags="-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wbad-function-cast -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wmissing-declarations -Winline -Wmissing-format-attribute -Wformat-security"
516                                 wi_gcc_optimizer_flags='-Wdisabled-optimization'
517                                 ;;
518                         *)
519                                 wi_os_default_cflags="-W -Wall"
520                                 ;;
521                 esac
522                 if test "$wi_replace_O_with_g" = yes ; then
523                         wi_os_default_cflags="-g $wi_os_default_cflags"
524                 else
525                         wi_os_default_cflags="-O2 $wi_os_default_cflags"
526                         if test "$wi_gcc_optimizer_flags" != "" ; then
527                                 wi_os_default_cflags="$wi_os_default_cflags $wi_gcc_optimizer_flags"
528                         fi
529                 fi
530                 case "$OS" in
531                         hpux*)
532                                 wi_os_default_cflags="-D_HPUX_SOURCE $wi_os_default_cflags"
533                                 ;;
534                         bsdos*)
535                                 wi_os_default_cflags=`echo "$wi_os_default_cflags" | sed 's/\ -Wcast-qual//g'`          # avoid va_start() problem
536                                 wi_os_default_cflags=`echo "$wi_os_default_cflags" | sed 's/\ -Wredundant-decls//g'`
537                                 ;;
538                         openbsd*|unixware*|openunix*)
539                                 wi_os_default_cflags=`echo "$wi_os_default_cflags" | sed 's/\ -Wredundant-decls//g'`
540                                 ;;
541                 esac
542         else
543                 #
544                 # regular cc
545                 #
546                 case "${wi_replace_O_with_g}_${OS}" in
547                         no_aix*)
548                                 wi_os_default_cflags="-O -qinfo=cmp:cnd:dcl:eff:gen:ini:par:pro:rea:use -qlonglong -qro -qroconst -qlanglvl=extended -qsrcmsg -qmaxmem=20480 -qsuppress=1506-469:1506-409"
549                                 ;;
550                         yes_aix*)
551                                 wi_os_default_cflags="-g -qinfo=cmp:cnd:dcl:eff:gen:ini:par:pro:rea:use -qlonglong -qro -qroconst -qlanglvl=extended -qsrcmsg -qmaxmem=20480 -qsuppress=1506-469:1506-409"
552                                 ;;
553                         no_irix[2345]*|no_irix6.[01234]*)
554                                 wi_os_default_cflags="-O2 -xansi -fullwarn -use_readonly_const -G0 -rdata_shared"
555                                 ;;
556                         yes_irix[2345]*|yes_irix6.[01234]*)
557                                 wi_os_default_cflags="-g -xansi -fullwarn -use_readonly_const -G0 -rdata_shared"
558                                 ;;
559                         no_irix*)
560                                 wi_os_default_cflags="-O2 -IPA -xansi -fullwarn -use_readonly_const -G0 -rdata_shared -woff 1174"
561                                 ;;
562                         yes_irix*)
563                                 wi_os_default_cflags="-g -xansi -fullwarn -use_readonly_const -G0 -rdata_shared -woff 1174"
564                                 ;;
565                         no_digitalunix*)
566                                 wi_os_default_cflags="-O4 -std1 -portable -readonly_strings"
567                                 ;;
568                         yes_digitalunix*)
569                                 wi_os_default_cflags="-g -std1 -portable -readonly_strings"
570                                 ;;
571                         no_hpux*)
572                                 wi_os_default_cflags="-Ae +O2 +Ovolatile +Olibcalls +ESlit +w1 +DAportable"
573                                 ;;
574                         yes_hpux*)
575                                 wi_os_default_cflags="-Ae -g +w1 +DAportable"
576                                 ;;
577                         no_solaris*)
578                                 if test "$wi_cv_sunwspro_cc_version2" -ge 530 ; then
579                                         wi_os_default_cflags="-xipo -xO5 -xc99 -xbuiltin -xstrconst -dalign -Qn -errtags=yes -erroff=E_END_OF_LOOP_CODE_NOT_REACHED -mc"
580                                 else
581                                         wi_os_default_cflags="-xO4 -xstrconst -dalign -Qn"
582                                 fi
583                                 ;;
584                         yes_solaris*)
585                                 if test "$wi_cv_sunwspro_cc_version2" -ge 530 ; then
586                                         wi_os_default_cflags="-g -xc99 -xstrconst -dalign -Qn -errtags=yes -erroff=E_END_OF_LOOP_CODE_NOT_REACHED"
587                                 else
588                                         wi_os_default_cflags="-g -xstrconst -dalign -Qn"
589                                 fi
590                                 ;;
591                         no_tru64*)
592                                 wi_os_default_cflags="-O4 -tune host -std1 -readonly_strings -portable -warnprotos -msg_enable level6 -msg_disable longlongtype,hexoctunsign,unusedincl,unnecincl,nestincl,unusedtop,unknownmacro,ignorecallval,strctpadding,truncintasn,truncintcast,trunclongcast,ansialiascast,conststocls,unrefsdecl,subscrbounds2"
593                                 ;;
594                         yes_tru64*)
595                                 wi_os_default_cflags="-g -std1 -readonly_strings -portable -warnprotos -msg_enable level6 -msg_disable longlongtype,hexoctunsign,unusedincl,unnecincl,nestincl,unusedtop,unknownmacro,ignorecallval,strctpadding,truncintasn,truncintcast,trunclongcast,ansialiascast,conststocls,unrefsdecl,subscrbounds2"
596                                 ;;
597                         no_unixware*|no_openunix*)
598                                 wi_os_default_cflags='-O -K inline -K host -Q n'
599                                 ;;
600                         yes_unixware*|yes_openunix*)
601                                 wi_os_default_cflags='-g -K host -Q n'
602                                 ;;
603                         *)
604                                 wi_os_default_cflags="no"
605                                 ;;
606                 esac
607         fi
608 fi
609 if test "$wi_os_default_cflags" != "no" ; then
610         CFLAGS="$wi_os_default_cflags"
611 fi
612 AC_MSG_RESULT($wi_os_default_cflags)
613 ])
614 dnl
615 dnl
616 dnl
617 AC_DEFUN([wi_SFLAG], [AC_REQUIRE([AC_PROG_CC])
618 STRIP="strip"
619 if test "$SFLAG" = "" ; then
620         SFLAG="-s"
621         case "$OS" in
622                 macosx*)
623                         SFLAG='-Wl,-x'
624                         ;;
625         esac
626 fi
627 #
628 # Was it ./configure --enable-debug ?
629 #
630 if test "$DEBUGBUILD" = yes ; then
631         SFLAG=""
632         STRIP=":"
633 fi
634 case "$CFLAGS" in
635         "-g"|"-g "*|*" -g"|*" -g "*|*"-g"[0-9]*)
636                 # SFLAG="# $SFLAG"
637                 SFLAG=""
638                 STRIP=":"
639                 ;;
640 esac
641 STRIPFLAG="$SFLAG"
642 ])
643 dnl
644 dnl
645 dnl
646 AC_DEFUN([wi_PROG_SUN_WORKSHOP_CC_VERSION], [
647 AC_REQUIRE([AC_PROG_CC])
648 if test "${SYS}_${GCC}" != solaris_no ; then
649         wi_cv_cc_is_sunwspro_cc="no"
650         wi_cv_sunwspro_cc_version="0"
651         wi_cv_sunwspro_cc_version2="0"
652 else
653         AC_CACHE_CHECK([if the C compiler is Sun WorkShop C],[wi_cv_cc_is_sunwspro_cc], [
654 changequote(<<, >>)dnl
655 #
656 # cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
657 # usage: cc [ options] files.  Use 'cc -flags' for details
658 #
659 # cc: WorkShop Compilers 4.2 30 Oct 1996 C 4.2
660 # usage: cc [ options] files.  Use 'cc -flags' for details
661 #
662                 wi_cv_sunwspro_cc_version=`$CC -V 2>&1 | sed -n '/WorkShop.*C\ [1-9]/{s/^.*C/C/;s/^C\ \([^\ ]*\).*/\1/;p;q;}'`
663                 case "$wi_cv_sunwspro_cc_version" in
664                         [1-9]*)
665                                 wi_cv_cc_is_sunwspro_cc="yes"
666                                 ver1=`echo "$wi_cv_sunwspro_cc_version" | cut -d. -f1`
667                                 ver2=`echo "$wi_cv_sunwspro_cc_version" | cut -d. -f2`
668                                 ver3=0
669                                 wi_cv_sunwspro_cc_version2=`expr "$ver1" '*' 100 + "$ver2" "*" 10 + "$ver3"`
670                                 unset ver1 ver2 ver3
671                                 ;;
672                         *)
673                                 wi_cv_cc_is_sunwspro_cc="no"
674                                 wi_cv_sunwspro_cc_version="0"
675                                 wi_cv_sunwspro_cc_version2="0"
676                                 ;;
677                 esac
678 changequote([, ])dnl
679         ])
680         if test "$wi_cv_cc_is_sunwspro_cc" = yes ; then
681                 AC_MSG_CHECKING([output of "cc -V" to determine version of Sun WorkShop C])
682                 AC_MSG_RESULT("version $wi_cv_sunwspro_cc_version")
683         fi
684 fi
685 ])
686 dnl
687 dnl
688 dnl
689 AC_DEFUN([wi_PROG_GCC_VERSION], [
690 AC_REQUIRE([AC_PROG_CC])
691 if test "$GCC" = yes ; then
692         AC_CACHE_CHECK([the version of GCC],[wi_cv_gcc_version], [
693 changequote(<<, >>)dnl
694         wi_cv_gcc_version=`$CC -v 2>&1 | sed -n '/gcc version/{s/^.*gcc version//;s/^[^1-9]*//;s/\ .*//;p;q;}'`
695 changequote([, ])dnl
696 ])
697 else
698         wi_cv_gcc_version="0"
699 fi
700 ])
701 dnl
702 dnl
703 dnl
704 AC_DEFUN([wi_REQUEST_NO_Y2K_WARNINGS], [
705         wi_request_no_y2k_warnings=yes
706 ])
707 dnl
708 dnl
709 dnl
710 AC_DEFUN([wi_CFLAGS_NO_Y2K_WARNINGS], [
711 AC_REQUIRE([AC_PROG_CC])
712 if test "x$wi_request_no_y2k_warnings" = xyes ; then
713 case "${wi_cv_gcc_version-0}" in
714 changequote(<<, >>)dnl
715         0|1.*|2.[012345678].*)
716 changequote([, ])dnl
717                 ;;
718         *)
719                 case "$CFLAGS" in
720                         *-Wno-format-y2k*)
721                                 ;;
722                         *)
723                                 oldCFLAGS="$CFLAGS"
724                                 CFLAGS="$CFLAGS -Wno-format-y2k"
725                                 #
726                                 # Now check if this version of GCC
727                                 # accepts this flag...
728                                 #
729                                 AC_TRY_COMPILE([],[int junk;],[],[CFLAGS="$oldCFLAGS"])
730                                 unset oldCFLAGS
731                                 ;;
732                 esac
733                 ;;
734 esac
735 fi
736 ])
737 dnl
738 dnl
739 dnl
740 AC_DEFUN([wi_CFLAGS], [AC_REQUIRE([AC_PROG_CC])
741         wi_PROG_GCC_VERSION
742         AC_REQUIRE_CPP()
743         wi_PROG_SUN_WORKSHOP_CC_VERSION
744         wi_OS_DEFAULT_CFLAGS
745         wi_CFLAGS_NO_Y2K_WARNINGS
746 changequote(<<, >>)dnl
747         add_O0="no"
748         if [ "$NOOPTCFLAGS" = "" ] ; then
749                 NOOPTCFLAGS=`echo "$CFLAGS" | sed 's/[-+]O[0-9A-Za-z]*//g;s/-xO[0-9]//g;s/-Wc,-O3//g;s/-IPA//g;s/-xipo//g;s/\ \ */ /g;s/^\ *//;s/\ *$//;'`
750                 if [ "$GCC" = "yes" ] ; then
751                         add_O0="yes"
752                 else
753                         case "$CC" in
754                                 ccc|*/ccc)
755                                         # Compaq CC
756                                         add_O0="yes"
757                                         ;;
758                         esac
759                 fi
760         fi
761         if [ "$DEBUGCFLAGS" = "" ] ; then
762                 DEBUGCFLAGS="-g $NOOPTCFLAGS"
763         fi
764         if [ "$add_O0" = yes ] ; then
765                 NOOPTCFLAGS="-O0 $NOOPTCFLAGS"
766         fi
767 changequote([, ])dnl
768         #
769         # Was it ./configure --enable-debug ?
770         #
771         AC_MSG_CHECKING([if this is a debug build])
772         if test "$DEBUGBUILD" = yes ; then
773                 AC_MSG_RESULT(yes)
774                 CFLAGS="$DEBUGCFLAGS"
775         else
776                 AC_MSG_RESULT(no)
777         fi
778         AC_MSG_CHECKING([NOOPTCFLAGS])
779         AC_MSG_RESULT($NOOPTCFLAGS)
780         AC_MSG_CHECKING([DEBUGCFLAGS])
781         AC_MSG_RESULT($DEBUGCFLAGS)
782         AC_MSG_CHECKING([CFLAGS])
783         AC_MSG_RESULT($CFLAGS)
784 ])
785 dnl
786 dnl
787 dnl
788 AC_DEFUN([wi_HPUX_GCC___STDC_EXT__], [
789 AC_MSG_CHECKING([if -D__STDC_EXT__ is needed with GCC on HP-UX])
790 AC_TRY_RUN([
791 #include <stdio.h>
792  
793 main()
794 {
795 #ifdef __STDC_EXT__
796         if (__STDC_EXT__ == 0)
797                 exit(1);                /* have __STDC_EXT__=0 */
798         exit(0);                        /* have __STDC_EXT__=1 */
799 #else
800         exit(1);                        /* do not have __STDC_EXT__ */
801 #endif
802 }],[
803         # action if true
804         #
805         # Already have it defined.
806         #
807         AC_MSG_RESULT(no)
808 ],[
809         # action if false
810         #
811         # Not defined -- we need to define it then.
812         # This is required for the extended
813         # namespace symbols for Large Files.
814         #
815         CFLAGS="-D__STDC_EXT__ $CFLAGS"
816         AC_MSG_RESULT(yes)
817 ],[
818         # action if cross-compiling, guess
819         CFLAGS="-D__STDC_EXT__ $CFLAGS"
820         AC_MSG_RESULT(yes)
821 ])
822 ])
823 dnl
824 dnl
825 dnl
826 AC_DEFUN([wi_ENV_VAR_MESSAGES], [
827 AC_MSG_CHECKING([if you set and exported the environment variable CC])
828 if test "x$CC" = x ; then
829         AC_MSG_RESULT([no (you may want to do that since configure scripts look for gcc first)])
830 else
831         AC_MSG_RESULT($CC)
832 fi
833 AC_MSG_CHECKING([for environment variable CFLAGS])
834 if test "x$CFLAGS" = x ; then
835         AC_MSG_RESULT([no (we will choose a default set for you)])
836 else
837         AC_MSG_RESULT($CFLAGS)
838 fi
839 AC_MSG_CHECKING([for environment variable CPPFLAGS])
840 AC_MSG_RESULT(${CPPFLAGS-no})
841 AC_MSG_CHECKING([for environment variable LDFLAGS])
842 AC_MSG_RESULT(${LDFLAGS-no})
843 AC_MSG_CHECKING([for environment variable LIBS])
844 AC_MSG_RESULT(${LIBS-no})
845 ])
846 dnl
847 dnl
848 dnl
849 AC_DEFUN([wi_CFLAGS_LFS64], [AC_REQUIRE([AC_PROG_CC])
850 AC_REQUIRE([wi_OS_VAR])
851 wi_CFLAGS
852 if test "os_${os}_gcc_${GCC}" = os_hp-ux_gcc_yes ; then
853         wi_HPUX_GCC___STDC_EXT__
854 fi
855 case "$CFLAGS" in
856         *-D_LARGEFILE64_SOURCE*)
857                 ;;
858         *)
859                 CFLAGS="-D_LARGEFILE64_SOURCE $CFLAGS"
860                 DEBUGCFLAGS="-D_LARGEFILE64_SOURCE $DEBUGCFLAGS"
861                 NOOPTCFLAGS="-D_LARGEFILE64_SOURCE $NOOPTCFLAGS"
862                 ;;
863 esac
864 AC_MSG_CHECKING([if we should add to CFLAGS for LFS64 support])
865 AC_MSG_RESULT($CFLAGS)
866 ])
867 dnl
868 dnl
869 dnl
870 AC_DEFUN([wi_CFLAGS_REENTRANT], [AC_REQUIRE([AC_PROG_CC])
871 case "$CFLAGS" in
872         *-D_REENTRANT*)
873                 ;;
874         *)
875                 CFLAGS="-D_REENTRANT $CFLAGS"
876                 ;;
877 esac
878 AC_MSG_CHECKING([if we should add -D_REENTRANT to CFLAGS])
879 AC_MSG_RESULT($CFLAGS)
880 ])
881 dnl
882 dnl
883 dnl
884 AC_DEFUN([wi_PROTOTYPES], [
885 AC_MSG_CHECKING(if the compiler supports function prototypes)
886 AC_TRY_COMPILE(,[extern void exit(int status);],[wi_cv_prototypes=yes
887 AC_DEFINE(PROTOTYPES)],wi_cv_prototypes=no)
888 AC_MSG_RESULT($wi_cv_prototypes)
889 ])
890 dnl
891 dnl
892 dnl
893
894 AH_TEMPLATE([tv_sec_t], [type of the tv_sec field of struct timeval])
895 AH_TEMPLATE([tv_usec_t], [type of the tv_usec field of struct timeval])
896 AC_DEFUN([wi_STRUCT_TIMEVAL_FIELD_TYPES], [
897 wi_struct_timeval_field_checks="cached"
898 AC_CACHE_CHECK([what type the tv_sec field of struct timeval is],[wi_cv_struct_timeval_tv_sec], [
899 wi_struct_timeval_field_checks="uncached"
900 wi_PREREQ_UNISTD_H([$0])
901 AC_TRY_RUN([
902         /* program */
903 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
904 #       define _ALL_SOURCE 1
905 #endif
906 #ifdef HAVE_UNISTD_H
907 #       include <unistd.h>
908 #endif
909 #include <sys/types.h>
910 #include <sys/time.h>
911 #include <stdio.h>
912 #include <stdlib.h>
913 #include <string.h>
914
915 static void
916 neg(void *dst0, size_t siz)
917 {
918         unsigned char *dst = (unsigned char *) dst0;
919         unsigned char *dlim;
920
921         dlim = dst + siz;
922         while (dst < dlim)
923                 *dst++ = (unsigned char) 0xEE;
924 }
925
926 int
927 main(int argc, char **argv)
928 {
929         FILE *fp;
930         const char *typ;
931         struct timeval tv;
932 #define x tv.tv_sec
933
934         memset(&tv, 0, sizeof(tv));
935         fp = stdout;
936         if (argc == 1) {
937                 fp = fopen("conftest.out", "w");
938                 if (fp == NULL) {
939                         perror("could not write to ./conftest.out");
940                         exit(1);
941                 }
942         }
943
944         neg(&x, sizeof(x));
945 #ifdef HAVE_LONG_LONG
946         if (sizeof(x) == sizeof(long long)) {
947                 typ = "long long";
948         } else
949 #endif
950         if (sizeof(x) == sizeof(long)) {
951                 typ = "long";
952         } else {
953                 typ = "int";
954         }
955         (void) fprintf(fp, "%s%s\n", (x > 0) ? "unsigned " : "", typ);
956 #undef x
957
958 #define x tv.tv_usec
959         neg(&x, sizeof(x));
960 #ifdef HAVE_LONG_LONG
961         if (sizeof(x) == sizeof(long long)) {
962                 typ = "long long";
963         } else
964 #endif
965         if (sizeof(x) == sizeof(long)) {
966                 typ = "long";
967         } else {
968                 typ = "int";
969         }
970         (void) fprintf(fp, "%s%s\n", (x > 0) ? "unsigned " : "", typ);
971 #undef x
972
973         if (fp != stdout)
974                 (void) fclose(fp);
975         exit(0);
976 }
977 ],[
978         # action if true
979         if test -f conftest.out ; then
980                 wi_cv_struct_timeval_tv_sec="`sed -n '1,1p' conftest.out`"
981                 wi_cv_struct_timeval_tv_usec="`sed -n '2,2p' conftest.out`"
982         fi
983 ],[
984         # action if false
985         wi_cv_struct_timeval_tv_sec="long"
986         wi_cv_struct_timeval_tv_usec="long"
987 ],[
988         # action if cross compiling
989         wi_cv_struct_timeval_tv_sec="long"
990         wi_cv_struct_timeval_tv_usec="long"
991 ])
992         /bin/rm -f conftest.out
993 ])
994 if test "$wi_struct_timeval_field_checks" = "uncached" ; then
995         AC_MSG_CHECKING([what type the tv_usec field of struct timeval is])
996         AC_MSG_RESULT([$wi_cv_struct_timeval_tv_usec])
997 else
998         AC_CACHE_CHECK([what type the tv_usec field of struct timeval is],[wi_cv_struct_timeval_tv_usec], [:])
999 fi
1000 AC_DEFINE_UNQUOTED(tv_sec_t, $wi_cv_struct_timeval_tv_sec)
1001 AC_DEFINE_UNQUOTED(tv_usec_t, $wi_cv_struct_timeval_tv_usec)
1002 ])
1003 dnl
1004 dnl
1005 dnl
1006 AH_TEMPLATE([main_void_return_t], [type that main() should return])
1007 AC_DEFUN([wi_VOID_MAIN_RETURN_TYPE], [
1008 AC_CACHE_CHECK([what type main() should return],[wi_cv_main_void_return_t], [
1009 wi_cv_main_void_return_t="int"
1010 case "${GCC}_${SYS}" in
1011         no_irix*|no_hpux)
1012                 wi_cv_main_void_return_t="void"
1013                 ;;
1014 esac
1015 ])
1016 AC_DEFINE_UNQUOTED(main_void_return_t, $wi_cv_main_void_return_t)
1017 ])
1018 dnl
1019 dnl
1020 dnl
1021 AH_TEMPLATE([INSECURE_CHOWN], [define if chown can be used to subvert security])
1022 AC_DEFUN([wi_INSECURE_CHOWN], [
1023 wi_PREREQ_UNISTD_H([$0])
1024 AC_MSG_CHECKING(if chown can be used to subvert security)
1025 AC_TRY_RUN([
1026 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
1027 #       define _ALL_SOURCE 1
1028 #endif
1029 #ifdef HAVE_UNISTD_H
1030 #       include <unistd.h>
1031 #endif
1032 #include <sys/types.h>
1033 #include <sys/stat.h>
1034 #include <stdio.h>
1035  
1036 main()
1037 {
1038         int result;
1039         char fn[64];
1040         FILE *fp;
1041         struct stat st;
1042
1043         setuid(1);      /* if you're root, try set to someone else. */
1044         sprintf(fn, "/tmp/fu%06ld", (long) getpid());
1045         unlink(fn);
1046         fp = fopen(fn, "w");
1047         if (fp == NULL)
1048                 exit(1);        /* assume the worst */
1049         fprintf(fp, "%s\n", "hello world");
1050         fclose(fp);
1051
1052         result = chown(fn, 0, 0);
1053         if (stat(fn, &st) < 0) {
1054                 unlink(fn);
1055                 exit((result == 0) ? 0 : 1);
1056         }
1057         unlink(fn);
1058
1059         /* exit(0) if the insecure chown to uid 0 succeeded. */
1060         exit((st.st_uid == 0) ? 0 : 1);
1061 }],[
1062         # action if true
1063         wi_cv_insecure_chown=yes
1064         AC_DEFINE(INSECURE_CHOWN)
1065 ],[
1066         # action if false
1067         wi_cv_insecure_chown=no
1068 ],[
1069         # action if cross-compiling, guess
1070         wi_cv_insecure_chown=no
1071 ])
1072
1073 AC_MSG_RESULT($wi_cv_insecure_chown)
1074 ])
1075 dnl
1076 dnl
1077 dnl
1078 AC_DEFUN([wi_PREREQ_UNISTD_H], [
1079         if test "x$ac_cv_header_unistd_h" = x ; then
1080                 AC_MSG_ERROR([Script needs to check for <unistd.h> before calling [$1].])
1081         fi
1082 ])
1083
1084 AH_TEMPLATE([NEED_GETOPT_H], [define if we need to include <getopt.h> for the getopt() global variables])
1085 AH_TEMPLATE([NEED_GETOPT_EXTERN_DECLS], [define if we need extern declarations for the getopt() global variables])
1086 AC_DEFUN([wi_GETOPT], [
1087 AC_CACHE_CHECK([how to access getopt() global variables], [wi_cv_getopt_decl], [
1088 wi_PREREQ_UNISTD_H([$0])
1089 AC_TRY_COMPILE([
1090 /* includes */
1091 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
1092 #       define _ALL_SOURCE 1
1093 #endif
1094 #ifdef HAVE_UNISTD_H
1095 #       include <unistd.h>
1096 #endif
1097 #include <stdio.h>
1098 #include <stdlib.h>
1099 ],[
1100         optind = (optarg == 0) ? 66 : 99;
1101 ],[wi_cv_getopt_decl="automatic"],[wi_cv_getopt_decl="unknown"])
1102 if test "$wi_cv_getopt_decl" = unknown ; then
1103 AC_TRY_COMPILE([
1104 /* includes */
1105 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
1106 #       define _ALL_SOURCE 1
1107 #endif
1108 #ifdef HAVE_UNISTD_H
1109 #       include <unistd.h>
1110 #endif
1111 #include <stdio.h>
1112 #include <stdlib.h>
1113 #include <getopt.h>
1114 ],[
1115         optind = (optarg == 0) ? 66 : 99;
1116 ],[wi_cv_getopt_decl="getopt.h"],[wi_cv_getopt_decl="manual"])
1117 fi
1118 ])
1119 if test "$wi_cv_getopt_decl" = "getopt.h" ; then
1120         AC_DEFINE(NEED_GETOPT_H)
1121 elif test "$wi_cv_getopt_decl" = "manual" ; then
1122         AC_DEFINE(NEED_GETOPT_EXTERN_DECLS)
1123 fi
1124 ])
1125 dnl
1126 dnl
1127 dnl
1128 AC_DEFUN([wi_LIB_SNPRINTF], [
1129 if test "$ac_cv_func_snprintf" = "no" ; then
1130         AC_CHECK_LIB(snprintf,snprintf)
1131         if test "$ac_cv_lib_snprintf_snprintf" = yes ; then
1132                 unset ac_cv_func_snprintf ac_cv_func_vsnprintf
1133                 AC_CHECK_HEADERS(snprintf.h)
1134                 AC_CHECK_FUNCS(snprintf vsnprintf)
1135         fi
1136 fi
1137 ])
1138 dnl
1139 dnl
1140 dnl
1141 AH_TEMPLATE([SNPRINTF_TERMINATES], [define if snprintf works correctly])
1142 AC_DEFUN([wi_SNPRINTF_TERMINATES], [
1143 if test "$ac_cv_func_snprintf" != "no" ; then
1144 AC_MSG_CHECKING(if snprintf works correctly)
1145         if test "$ac_cv_func_snprintf" = "no" ; then
1146                 AC_CHECK_LIB(snprintf,snprintf)
1147         fi
1148 wi_PREREQ_UNISTD_H([$0])
1149 AC_TRY_RUN([
1150         /* program */
1151 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
1152 #       define _ALL_SOURCE 1
1153 #endif
1154 #ifdef HAVE_UNISTD_H
1155 #       include <unistd.h>
1156 #endif
1157 #include <stdio.h>
1158 #include <string.h>
1159 #ifdef HAVE_STRINGS_H
1160 #include <strings.h>
1161 #endif
1162 #include <stdlib.h>
1163  
1164 main()
1165 {
1166         char s[16];
1167         int i, result;
1168
1169         for (i=0; i<(int)(sizeof(s)/sizeof(char)); i++)
1170                 s[i] = 'x';
1171         result = (int) snprintf(s + 1, 10, "%s %s!", "hello", "world");
1172         if (s[10] != '\0')
1173                 exit(1);        /* did not force termination! */
1174         if (s[11] != 'x')
1175                 exit(2);        /* overflow! */
1176         if (s[0] != 'x')
1177                 exit(3);        /* underflow! */
1178         exit(0);
1179 }
1180 ],[
1181         # action if true
1182         wi_cv_snprintf_terminates=yes
1183         AC_DEFINE(SNPRINTF_TERMINATES)
1184         x="yes";
1185 ],[
1186         # action if false
1187         wi_cv_snprintf_terminates=no
1188         x="no";
1189 ],[
1190         # action if cross compiling
1191         wi_cv_snprintf_terminates=no
1192         x="unknown";
1193 ])
1194 AC_MSG_RESULT($x)
1195 fi
1196 ])
1197 dnl
1198 dnl
1199 dnl
1200 AC_DEFUN([wi_SNPRINTF], [
1201 wi_SPRINTF_RETVAL
1202 dnl Uncache these -- config.cache doesn't cache it right for this case.
1203 unset ac_cv_func_snprintf
1204 unset ac_cv_func_vsnprintf
1205
1206 AC_CHECK_FUNCS(snprintf vsnprintf)
1207 wi_SNPRINTF_TERMINATES
1208 wi_LIB_SNPRINTF
1209 ])
1210 dnl
1211 dnl
1212 dnl
1213
1214 AH_TEMPLATE([HAVE_HPSECURITY_H], [define if we have hpsecurity.h])
1215 AC_DEFUN([wi_HEADER_HPSECURITY_H], [
1216 AC_MSG_CHECKING(for hpsecurity.h)
1217 wi_cv_header_hpsecurity_h=no
1218 if test -f /usr/include/hpsecurity.h ; then
1219         wi_cv_header_hpsecurity_h=yes
1220         AC_DEFINE(HAVE_HPSECURITY_H)
1221 fi
1222 AC_MSG_RESULT($wi_cv_header_hpsecurity_h)
1223 ])
1224 dnl
1225 dnl
1226 dnl
1227 AH_TEMPLATE([CAN_USE_SYS_SELECT_H], [define if we can use sys/select.h])
1228 AC_DEFUN([wi_HEADER_SYS_SELECT_H], [
1229 wi_PREREQ_UNISTD_H([$0])
1230 # See if <sys/select.h> is includable after <sys/time.h>
1231 if test "$ac_cv_header_sys_time_h" = no ; then
1232         wi_chk_headers="sys/time.h sys/select.h"
1233 else
1234         wi_chk_headers="sys/time.h"
1235 fi
1236 AC_CHECK_HEADERS($wi_chk_headers)
1237 if test "$ac_cv_header_sys_select_h" = yes ; then
1238         AC_MSG_CHECKING([if <sys/select.h> is compatible with <sys/time.h>])
1239         selecth=yes
1240         if test "$ac_cv_header_sys_time_h" = yes ; then
1241                 AC_TRY_COMPILE([
1242 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
1243 #       define _ALL_SOURCE 1
1244 #endif
1245 #ifdef HAVE_UNISTD_H
1246 #       include <unistd.h>
1247 #endif
1248 #include <sys/types.h>
1249 #include <sys/time.h>
1250 #include <sys/select.h>],[
1251                 fd_set a;
1252                 struct timeval tmval;
1253
1254                 tmval.tv_sec = 0;],selecth=yes,selecth=no)
1255         fi
1256         if test "$selecth" = yes ; then
1257                 AC_DEFINE(CAN_USE_SYS_SELECT_H)
1258         fi
1259         AC_MSG_RESULT($selecth)
1260 fi
1261 ])
1262 dnl
1263 dnl
1264 dnl
1265 AC_DEFUN([wi_LIB_44BSD], [
1266 AC_CHECK_FUNC(strerror,[a=yes],[a=no])
1267 if test "$a" = no ; then
1268         # Not in libc, try lib44bsd.
1269         AC_CHECK_LIB(44bsd,strerror)
1270 fi
1271 ])
1272 dnl
1273 dnl
1274 dnl
1275 AH_TEMPLATE([HAVE_UNIX_DOMAIN_SOCKETS], [define if UNIX domain sockets are available])
1276 AC_DEFUN([wi_UNIX_DOMAIN_SOCKETS], [
1277 if test "x$want_unix_domain_sockets" != xno ; then
1278         wi_PREREQ_UNISTD_H([$0])
1279         AC_CHECK_HEADERS(sys/un.h)
1280         AC_CACHE_CHECK([for UNIX domain sockets], [wi_cv_unix_domain_sockets], [
1281         AC_TRY_RUN([
1282 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
1283 #       define _ALL_SOURCE 1
1284 #endif
1285 #ifdef HAVE_UNISTD_H
1286 #       include <unistd.h>
1287 #endif
1288 #include <sys/types.h>
1289 #include <sys/socket.h>
1290 #ifdef HAVE_SYS_UN_H
1291 #include <sys/un.h>
1292 #endif
1293  
1294 main()
1295 {
1296         int sfd;
1297
1298         sfd = socket(AF_UNIX, SOCK_STREAM, 0);
1299         if (sfd < 0)
1300                 exit(1);                /* do not have UNIX domain sockets */
1301         close(sfd);
1302         exit(0);                        /* do have UNIX domain sockets */
1303 }],[
1304         # action if true
1305         wi_cv_unix_domain_sockets=yes
1306 ],[
1307         # action if false
1308         wi_cv_unix_domain_sockets=no
1309 ],[
1310         # action if cross-compiling, guess
1311         wi_cv_unix_domain_sockets=yes
1312 ])
1313 ])
1314         if test "x$wi_cv_unix_domain_sockets" = xyes ; then
1315                 AC_DEFINE(HAVE_UNIX_DOMAIN_SOCKETS)
1316         fi
1317         wi_SOCKADDR_UN_SUN_LEN
1318 fi
1319 ])
1320 dnl
1321 dnl
1322 dnl
1323 AC_DEFUN([wi_LIB_NSL], [
1324 dnl Note: Check for socket lib first, then nsl.
1325
1326 case "$OS" in
1327         hpux1[123456789]*)
1328                 # HP-UX 11 uses NSL for YP services
1329                 AC_CHECK_LIB(nsl,getpwent)
1330                 ;;
1331
1332         *)
1333                 AC_CHECK_FUNC(gethostbyname,[a=yes],[a=no])
1334                 if test "$a" = no ; then
1335                         # Not in libc, try libnsl.
1336                         AC_CHECK_LIB(nsl,gethostbyname)
1337                 fi
1338                 ;;
1339 esac
1340
1341 ])
1342 dnl
1343 dnl
1344 dnl
1345 AC_DEFUN([wi_LIB_SOCKET], [
1346 AC_CHECK_FUNC(socket,[a=yes],[a=no])
1347 if test "$a" = no ; then
1348         # Not in libc, try libsocket.
1349         AC_CHECK_LIB(socket,socket)
1350 fi
1351 ])
1352 dnl
1353 dnl
1354 dnl
1355 AC_DEFUN([wi_LIB_RESOLV], [
1356 # See if we could access two well-known sites without help of any special
1357 # libraries, like resolv.
1358 dnl
1359 dnl AC_MSG_WARN([the following check may take several minutes if networking is not up.  You may want to bring it up now and restart configure, otherwise please be patient.])
1360 dnl
1361 AC_CACHE_CHECK([if we need to look for -lresolv], [wi_cv_look_for_resolv], [
1362 wi_PREREQ_UNISTD_H([$0])
1363 AC_TRY_RUN([
1364 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
1365 #       define _ALL_SOURCE 1
1366 #endif
1367 #ifdef HAVE_UNISTD_H
1368 #       include <unistd.h>
1369 #endif
1370 #include <sys/types.h>
1371 #include <sys/socket.h>
1372 #include <netinet/in.h>
1373 #include <netdb.h>
1374  
1375 main()
1376 {
1377         struct hostent *hp1, *hp2;
1378
1379         hp1 = gethostbyname("ftp.ncftp.com");
1380         if (hp1 == (struct hostent *) 0) {
1381                 hp2 = gethostbyname("www.ibm.com");
1382                 if (hp2 == (struct hostent *) 0)
1383                         exit(1);
1384         }
1385         exit(0);
1386 }],wi_cv_look_for_resolv=no,wi_cv_look_for_resolv=yes,wi_cv_look_for_resolv=yes)
1387 ])
1388
1389 if test "$wi_cv_look_for_resolv" = yes ; then
1390 AC_CHECK_LIB(resolv,main)
1391 else
1392         ac_cv_lib_resolv=no
1393 fi
1394 ])
1395 dnl
1396 dnl
1397 dnl
1398 AC_DEFUN([wi_LIB_TCP_WRAPPERS], [
1399 wi_PREREQ_UNISTD_H([$0])
1400 AC_MSG_CHECKING([for tcp wrappers library (libwrap)])
1401
1402 AC_TRY_LINK([
1403         /* includes */
1404 #ifdef HAVE_UNISTD_H
1405 #       include <unistd.h>
1406 #endif
1407 #include <sys/types.h>
1408 #include <stdio.h>
1409
1410 /* These are needed if libwrap.a was compiled with
1411  * PROCESS_OPTIONS defined.
1412  */
1413 int allow_severity = 1; /* arbitrary for this test */
1414 int deny_severity = 2;  /* arbitrary for this test */
1415
1416 ],[
1417         /* function-body */
1418         exit((allow_severity == deny_severity) ? 1 : 0);
1419 ],[
1420 dnl     ...Don't bother defining this symbol...
1421 dnl     ...Check for tcpd.h instead...
1422 dnl     AC_DEFINE(HAVE_LIBWRAP)
1423 dnl
1424 dnl     ...Don't modify LIBS, instead set WRAPLIB...
1425 dnl     LIBS="-lwrap  $LIBS"
1426 dnl
1427         WRAPLIB="-lwrap"
1428         wi_cv_lib_wrap_hosts_access=yes
1429 ],[
1430         WRAPLIB=""
1431         wi_cv_lib_wrap_hosts_access=no
1432 ])
1433 AC_MSG_RESULT($wi_cv_lib_wrap_hosts_access)
1434 ])
1435 dnl
1436 dnl
1437 dnl
1438 AC_DEFUN([wi_NET_LIBS], [
1439 # Mostly for SunOS 4 -- needs to come first because other libs depend on it
1440 wi_LIB_44BSD
1441
1442 wi_LIB_SOCKET
1443
1444 if test "$SYS" = unixware ; then
1445         case "$OS" in
1446                 unixware2*)
1447                         # So far, only UnixWare needs this.
1448                         AC_CHECK_LIB(gen,syslog)
1449
1450                         if test -f /usr/ucblib/libucb.a ; then
1451                                 LDFLAGS="$LDFLAGS -L/usr/ucblib"
1452                                 LIBS="$LIBS -lucb"
1453                         fi
1454                         if test -f /usr/include/unistd.h ; then
1455                                 ac_cv_header_unistd_h=yes
1456                         fi
1457
1458                         # UnixWare 2 needs both lsocket and lnsl, and configure
1459                         # script won't detect this condition properly because 
1460                         # the libraries are interdependent.
1461                         #
1462                         LIBS="$LIBS -lsocket -lnsl"
1463
1464                         # Now look for socket()
1465                         #
1466                         # AC_CHECK_FUNC(socket,[a=yes],[a=no])
1467                         #
1468                         AC_CHECK_FUNC(socket,[a=yes],[a=no])
1469                         ;;
1470                 *)
1471                         ;;
1472         esac
1473 fi
1474
1475 dnl AC_CHECK_LIB(inet,main)
1476
1477 wi_LIB_NSL
1478 wi_LIB_RESOLV
1479
1480 if test "$SYS" = dynixptx ; then
1481         LIBS="$LIBS -lsocket -lnsl"
1482 fi
1483
1484 ])
1485 dnl
1486 dnl
1487 dnl
1488 dnl
1489 AH_TEMPLATE([UNAME], [uname -a output])
1490 AC_DEFUN([wi_DEFINE_UNAME], [
1491 # Get first 127 chars of all uname information.  Some folks have
1492 # way too much stuff there, so grab only the first 127.
1493 unam=`uname -a 2>/dev/null | cut -c1-127 | sed 's-"-\\"-g'`
1494 if test "$unam" != "" ; then
1495         AC_DEFINE_UNQUOTED(UNAME, "$unam")
1496 fi
1497 ])
1498 dnl
1499 dnl
1500 dnl
1501 AH_TEMPLATE([HAVE_SIGSETJMP], [define if we have sigsetjmp and siglongjmp])
1502 AC_DEFUN([wi_FUNC_SIGSETJMP], [
1503 wi_PREREQ_UNISTD_H([$0])
1504 AC_CACHE_CHECK([for sigsetjmp and siglongjmp], [wi_cv_func_sigsetjmp], [
1505
1506 AC_TRY_LINK([
1507         /* includes */
1508 #ifdef HAVE_UNISTD_H
1509 #       include <unistd.h>
1510 #endif
1511 #include <sys/types.h>
1512 #include <stdio.h>
1513 #include <signal.h>
1514 #include <setjmp.h>
1515 ],[
1516         /* function-body */
1517         sigjmp_buf sjb;
1518
1519         if (sigsetjmp(sjb, 1) != 0)
1520                 siglongjmp(sjb, 1);     /* bogus code, of course. */
1521         exit(0);
1522 ],[
1523         wi_cv_func_sigsetjmp=yes
1524 ],[
1525         wi_cv_func_sigsetjmp=no
1526 ])
1527 ])
1528 if test "$wi_cv_func_sigsetjmp" = yes ; then
1529         AC_DEFINE(HAVE_SIGSETJMP)
1530 fi
1531 ])
1532 dnl
1533 dnl
1534 dnl
1535 AH_TEMPLATE([HAVE_UTMP_UT_NAME], [define if struct utmp has the ut_name field])
1536 AC_DEFUN([wi_UTMP_UT_NAME], [
1537 AC_MSG_CHECKING([for ut_name field in struct utmp])
1538 AC_TRY_LINK([
1539         /* includes */
1540 #include <unistd.h>
1541 #include <sys/types.h>
1542 #include <utmp.h>
1543 ],[
1544 struct utmp u;
1545
1546 u.ut_name[0] = '\0';
1547 exit(((int) &u.ut_name) & 0xff);        /* bogus code, of course. */
1548 ],[
1549         wi_cv_utmp_ut_name=yes
1550         AC_DEFINE(HAVE_UTMP_UT_NAME)
1551 ],[
1552         wi_cv_utmp_ut_name=no
1553 ])
1554 AC_MSG_RESULT($wi_cv_utmp_ut_name)
1555 ])
1556 dnl
1557 dnl
1558 dnl
1559 AH_TEMPLATE([HAVE_UTMPX_UT_SYSLEN], [define if struct utmpx has the ut_syslen field])
1560 AC_DEFUN([wi_UTMPX_UT_SYSLEN], [
1561 AC_MSG_CHECKING([for ut_syslen field in struct utmpx])
1562 AC_TRY_LINK([
1563         /* includes */
1564 #include <unistd.h>
1565 #include <sys/types.h>
1566 #include <utmpx.h>
1567 ],[
1568 struct utmpx u;
1569
1570 u.ut_syslen = 0;
1571 exit(((int) &u.ut_syslen) & 0xff);      /* bogus code, of course. */
1572 ],[
1573         wi_cv_utmpx_ut_syslen=yes
1574         AC_DEFINE(HAVE_UTMPX_UT_SYSLEN)
1575 ],[
1576         wi_cv_utmpx_ut_syslen=no
1577 ])
1578 AC_MSG_RESULT($wi_cv_utmpx_ut_syslen)
1579 ])
1580 dnl
1581 dnl
1582 dnl
1583 AH_TEMPLATE([HAVE_UTMP_UT_USER], [define if struct utmp has the ut_user field])
1584 AC_DEFUN([wi_UTMP_UT_USER], [
1585 AC_MSG_CHECKING([for ut_user field in struct utmp])
1586 AC_TRY_LINK([
1587         /* includes */
1588 #include <unistd.h>
1589 #include <sys/types.h>
1590 #include <utmp.h>
1591 ],[
1592 struct utmp u;
1593
1594 u.ut_user[0] = '\0';
1595 exit(((int) &u.ut_user) & 0xff);        /* bogus code, of course. */
1596 ],[
1597         wi_cv_utmp_ut_user=yes
1598         AC_DEFINE(HAVE_UTMP_UT_USER)
1599 ],[
1600         wi_cv_utmp_ut_user=no
1601 ])
1602 AC_MSG_RESULT($wi_cv_utmp_ut_user)
1603 ])
1604 dnl
1605 dnl
1606 dnl
1607 AH_TEMPLATE([HAVE_UTMP_UT_PID], [define if struct utmp has the ut_pid field])
1608 AC_DEFUN([wi_UTMP_UT_PID], [
1609 AC_MSG_CHECKING([for ut_pid field in struct utmp])
1610 AC_TRY_LINK([
1611         /* includes */
1612 #include <unistd.h>
1613 #include <sys/types.h>
1614 #include <utmp.h>
1615 ],[
1616 struct utmp u;
1617
1618 u.ut_pid = 1;
1619 exit(((int) &u.ut_pid) & 0xff); /* bogus code, of course. */
1620 ],[
1621         wi_cv_utmp_ut_pid=yes
1622         AC_DEFINE(HAVE_UTMP_UT_PID)
1623 ],[
1624         wi_cv_utmp_ut_pid=no
1625 ])
1626 AC_MSG_RESULT($wi_cv_utmp_ut_pid)
1627 ])
1628
1629 dnl
1630 dnl
1631 dnl
1632 AH_TEMPLATE([HAVE_UTMP_UT_TIME], [define if struct utmp has the ut_time field])
1633 AC_DEFUN([wi_UTMP_UT_TIME], [
1634 AC_MSG_CHECKING([for ut_time field in struct utmp])
1635 AC_TRY_LINK([
1636         /* includes */
1637 #include <unistd.h>
1638 #include <sys/types.h>
1639 #include <utmp.h>
1640 ],[
1641 struct utmp u;
1642
1643 u.ut_time = 1;
1644 exit(((int) &u.ut_time) & 0xff);        /* bogus code, of course. */
1645 ],[
1646         wi_cv_utmp_ut_time=yes
1647         AC_DEFINE(HAVE_UTMP_UT_TIME)
1648 ],[
1649         wi_cv_utmp_ut_time=no
1650 ])
1651 AC_MSG_RESULT($wi_cv_utmp_ut_time)
1652 ])
1653 dnl
1654 dnl
1655 dnl
1656 AH_TEMPLATE([HAVE_UTMP_UT_HOST], [define if struct utmp has the ut_host field])
1657 AC_DEFUN([wi_UTMP_UT_HOST], [
1658 AC_MSG_CHECKING([for ut_host field in struct utmp])
1659 AC_TRY_LINK([
1660         /* includes */
1661 #include <unistd.h>
1662 #include <sys/types.h>
1663 #include <utmp.h>
1664 ],[
1665 struct utmp u;
1666
1667 u.ut_host[0] = '\0';
1668 exit(((int) &u.ut_host) & 0xff);        /* bogus code, of course. */
1669 ],[
1670         wi_cv_utmp_ut_host=yes
1671         AC_DEFINE(HAVE_UTMP_UT_HOST)
1672 ],[
1673         wi_cv_utmp_ut_host=no
1674 ])
1675 AC_MSG_RESULT($wi_cv_utmp_ut_host)
1676 ])
1677 dnl
1678 dnl
1679 dnl
1680 dnl
1681 AH_TEMPLATE([HAVE_STRUCT_STAT64], [define if we have struct stat64])
1682 AC_DEFUN([wi_STRUCT_STAT64], [
1683 AC_MSG_CHECKING([for struct stat64])
1684 AC_TRY_LINK([
1685         /* includes */
1686 #include <unistd.h>
1687 #include <sys/types.h>
1688 #include <sys/stat.h>
1689 ],[
1690 struct stat64 st;
1691
1692 st.st_size = 0;
1693 exit(((int) &st.st_size) & 0xff);       /* bogus code, of course. */
1694 ],[
1695         wi_cv_struct_stat64=yes
1696         AC_DEFINE(HAVE_STRUCT_STAT64)
1697 ],[
1698         wi_cv_struct_stat64=no
1699 ])
1700 AC_MSG_RESULT($wi_cv_struct_stat64)
1701 ])
1702 dnl
1703 dnl
1704 dnl
1705 AH_TEMPLATE([HAVE_STRUCT_CMSGDHR], [define if we have struct cmsghdr])
1706 AC_DEFUN([wi_STRUCT_CMSGHDR], [
1707 AC_CACHE_CHECK([for struct cmsghdr],[wi_cv_struct_cmsghdr], [
1708 AC_TRY_LINK([
1709         /* includes */
1710 #include <unistd.h>
1711 #include <sys/types.h>
1712 #include <sys/uio.h>
1713 #include <sys/socket.h>
1714 #include <sys/un.h>
1715 ],[
1716 struct cmsghdr cm;
1717
1718 cm.cmsg_len = 0;
1719 cm.cmsg_level = 0;
1720 cm.cmsg_type = 0;
1721 exit(((int) &cm.cmsg_type) & 0xff);     /* bogus code, of course. */
1722 ],[
1723         wi_cv_struct_cmsghdr=yes
1724 ],[
1725         wi_cv_struct_cmsghdr=no
1726 ])
1727 ])
1728 if test "$wi_cv_struct_cmsghdr" = yes ; then
1729         AC_DEFINE(HAVE_STRUCT_CMSGDHR)
1730 fi
1731 ])
1732 dnl
1733 dnl
1734 dnl
1735 AH_TEMPLATE([HAVE_MSGHDR_CONTROL], [define if struct msghdr has the msg_control field])
1736 AC_DEFUN([wi_MSGHDR_CONTROL], [
1737 AC_CACHE_CHECK([for msg_control field in struct msghdr],[wi_cv_msghdr_control], [
1738 AC_TRY_LINK([
1739         /* includes */
1740 #include <unistd.h>
1741 #include <sys/types.h>
1742 #include <sys/uio.h>
1743 #include <sys/socket.h>
1744 #include <sys/un.h>
1745 ],[
1746 struct msghdr m;
1747
1748 m.msg_control = &m;
1749 m.msg_controllen = sizeof(m);
1750 exit(((int) &m.msg_control) & 0xff);    /* bogus code, of course. */
1751 ],[
1752         wi_cv_msghdr_control=yes
1753 ],[
1754         wi_cv_msghdr_control=no
1755 ])
1756 ])
1757 if test "$wi_cv_msghdr_control" = yes ; then
1758         AC_DEFINE(HAVE_MSGHDR_CONTROL)
1759 fi
1760 ])
1761 dnl
1762 dnl
1763 dnl
1764 AH_TEMPLATE([HAVE_MSGHDR_ACCRIGHTS], [define if struct msghdr has the msg_accrights field])
1765 AC_DEFUN([wi_MSGHDR_ACCRIGHTS], [
1766 AC_CACHE_CHECK([for msg_accrights field in struct msghdr], [wi_cv_msghdr_accrights], [
1767 AC_TRY_LINK([
1768         /* includes */
1769 #include <unistd.h>
1770 #include <sys/types.h>
1771 #include <sys/uio.h>
1772 #include <sys/socket.h>
1773 #include <sys/un.h>
1774 ],[
1775 struct msghdr m;
1776
1777 m.msg_accrights = &m;
1778 m.msg_accrightslen = sizeof(m);
1779 exit(((int) &m.msg_accrights) & 0xff);  /* bogus code, of course. */
1780 ],[
1781         wi_cv_msghdr_accrights=yes
1782 ],[
1783         wi_cv_msghdr_accrights=no
1784 ])
1785 ])
1786 if test "$wi_cv_msghdr_accrights" = yes ; then
1787         AC_DEFINE(HAVE_MSGHDR_ACCRIGHTS)
1788 fi
1789 ])
1790 dnl
1791 dnl
1792 dnl
1793 AH_TEMPLATE([HAVE_PR_PASSWD_FG_OLDCRYPT], [define if struct pr_passwd has the fg_oldcrypt field])
1794 AC_DEFUN([wi_PR_PASSWD_FG_OLDCRYPT], [
1795 AC_MSG_CHECKING([for fg_oldcrypt field in struct pr_passwd])
1796 AC_TRY_LINK([
1797         /* includes */
1798 #include <unistd.h>
1799 #include <sys/types.h>
1800 #include <sys/stat.h>
1801 #include <stdio.h>
1802 #include <string.h>
1803 #include <stdlib.h>
1804 #include <pwd.h>
1805 #include <grp.h>
1806 #include <errno.h>
1807
1808 #if defined(HAVE_USERPW_H) && defined(HAVE_GETUSERPW)   /* AIX */
1809 #       include <userpw.h>
1810 #elif defined(HAVE_PWDADJ_H) && defined(HAVE_GETPWANAM) /* SunOS */
1811 #       include <sys/label.h>
1812 #       ifdef HAVE_SYS_AUDIT_H
1813 #               include <sys/audit.h>
1814 #       endif
1815 #       include <pwdadj.h>
1816 #elif defined(HAVE_GETESPWNAM) /* Digital UNIX 4 */
1817 #       ifdef HAVE_SYS_SECDEFINES_H
1818 #               include <sys/secdefines.h>
1819 #       endif
1820 #       ifdef HAVE_SYS_SECURITY_H
1821 #               include <sys/security.h>
1822 #       endif
1823 #       ifdef HAVE_SYS_AUDIT_H
1824 #               include <sys/audit.h>
1825 #       endif
1826 #       ifdef HAVE_KRB_H
1827 #               include <krb.h>
1828 #       endif
1829 #       ifdef HAVE_PROT_H
1830 #               include <prot.h>
1831 #       endif
1832 #elif defined(HAVE_GETPRPWNAM) /* SCO Open Server V, Digital UNIX 3, HP-UX 10 */
1833 #       ifdef HAVE_SYS_SECDEFINES_H
1834 #               include <sys/secdefines.h>
1835 #       endif
1836 #       ifdef HAVE_SYS_SECURITY_H
1837 #               include <sys/security.h>
1838 #       endif
1839 #       ifdef HAVE_SYS_AUDIT_H
1840 #               include <sys/audit.h>
1841 #       endif
1842 #       ifdef HAVE_HPSECURITY_H
1843 #               include <hpsecurity.h>
1844 #       endif
1845 #       ifdef HAVE_KRB_H
1846 #               include <krb.h>
1847 #       endif
1848 #       ifdef HAVE_PROT_H
1849 #               include <prot.h>
1850 #       endif
1851 #endif
1852 ],[
1853         struct pr_passwd xu;
1854         memset(&xu, 0, sizeof(xu));
1855         if (xu.uflg.fg_oldcrypt != 0)
1856                 xu.uflg.fg_oldcrypt++;  /* bogus code, of course */
1857         exit(0);
1858 ],[
1859         wi_cv_pr_passwd_fg_oldcrypt=yes
1860         AC_DEFINE(HAVE_PR_PASSWD_FG_OLDCRYPT)
1861 ],[
1862         wi_cv_pr_passwd_fg_oldcrypt=no
1863 ])
1864 AC_MSG_RESULT($wi_cv_pr_passwd_fg_oldcrypt)
1865 ])
1866 dnl
1867 dnl
1868 dnl
1869 AH_TEMPLATE([HAVE_SOCKADDR_UN_SUN_LEN], [define if struct sockaddr_un has the sun_len field])
1870 AC_DEFUN([wi_SOCKADDR_UN_SUN_LEN], [
1871 AC_CACHE_CHECK([for sun_len field in struct sockaddr_un], [wi_cv_sockaddr_un_sun_len], [
1872 AC_TRY_LINK([
1873         /* includes */
1874 #include <unistd.h>
1875 #include <sys/types.h>
1876 #include <sys/uio.h>
1877 #include <sys/socket.h>
1878 #include <sys/un.h>
1879 ],[
1880 struct sockaddr_un uaddr;
1881
1882 uaddr.sun_len = strlen("/tmp/test.sock");
1883 exit(((int) uaddr.sun_len);     /* bogus code, of course. */
1884 ],[
1885         wi_cv_sockaddr_un_sun_len=yes
1886 ],[
1887         wi_cv_sockaddr_un_sun_len=no
1888 ])
1889 ])
1890 if test "$wi_cv_sockaddr_un_sun_len" = yes ; then
1891         AC_DEFINE(HAVE_SOCKADDR_UN_SUN_LEN)
1892 fi
1893 ])
1894 dnl
1895 dnl
1896 dnl
1897 AH_TEMPLATE([HAVE_STATFS_F_BAVAIL], [define if struct statfs has the f_bavail field])
1898 AC_DEFUN([wi_STATFS_F_BAVAIL], [
1899 AC_MSG_CHECKING([for f_bavail field in struct statfs])
1900 AC_TRY_LINK([
1901         /* includes */
1902 #include <unistd.h>
1903 #include <sys/types.h>
1904 #ifdef HAVE_SYS_STATFS_H
1905 #       include <sys/statfs.h>
1906 #elif defined(HAVE_SYS_VFS_H)
1907 #       include <sys/vfs.h>
1908 #endif
1909 ],[
1910 struct statfs st;
1911
1912 st.f_bavail = 1;
1913 exit((int) st.f_bavail);        /* bogus code, of course. */
1914 ],[
1915         wi_cv_statfs_f_bavail=yes
1916         AC_DEFINE(HAVE_STATFS_F_BAVAIL)
1917 ],[
1918         wi_cv_statfs_f_bavail=no
1919 ])
1920 AC_MSG_RESULT($wi_cv_statfs_f_bavail)
1921 ])
1922 dnl
1923 dnl
1924 dnl
1925 AH_TEMPLATE([HAVE_STATVFS_F_FRSIZE], [define if struct statvfs has the f_frsize field])
1926 AC_DEFUN([wi_STATVFS_F_FRSIZE], [
1927 AC_MSG_CHECKING([for f_frsize field in struct statvfs])
1928 AC_TRY_LINK([
1929         /* includes */
1930 #include <unistd.h>
1931 #include <sys/types.h>
1932 #include <sys/statvfs.h>
1933 ],[
1934 struct statvfs st;
1935
1936 st.f_frsize = 1;
1937 exit((int) st.f_frsize);        /* bogus code, of course. */
1938 ],[
1939         wi_cv_statfs_f_frsize=yes
1940         AC_DEFINE(HAVE_STATVFS_F_FRSIZE)
1941 ],[
1942         wi_cv_statfs_f_frsize=no
1943 ])
1944 AC_MSG_RESULT($wi_cv_statfs_f_frsize)
1945 ])
1946 dnl
1947 dnl
1948 dnl
1949 AH_TEMPLATE([SPRINTF_RETURNS_PTR], [define if sprintf returns a pointer to the data])
1950 AC_DEFUN([wi_SPRINTF_RETVAL], [
1951 AC_MSG_CHECKING([what sprintf() returns])
1952 AC_TRY_RUN([
1953         /* program */
1954 #include <stdio.h>
1955 #include <string.h>
1956  
1957 main()
1958 {
1959         int result;
1960         char s[8];
1961
1962         result = (int) sprintf(s, "%d", 22);
1963         if (result == 2)
1964                 exit(0);
1965         exit(1);
1966
1967 }
1968 ],[
1969         # action if true
1970         wi_cv_sprintf_returns_ptr=no
1971         x="length of data written";
1972 ],[
1973         # action if false
1974         wi_cv_sprintf_returns_ptr=yes
1975         AC_DEFINE(SPRINTF_RETURNS_PTR)
1976         x="pointer to data";
1977 ],[
1978         # action if cross compiling
1979         wi_cv_sprintf_returns_ptr=no
1980         x="unknown";
1981 ])
1982 AC_MSG_RESULT($x)
1983 ])
1984 dnl
1985 dnl
1986 dnl
1987 AC_DEFUN([wi_LIB_CRYPT], [
1988 AC_MSG_CHECKING([which library has usable crypt() function])
1989 ac_save_LIBS="$LIBS"
1990 crypt_lib=NONE
1991
1992 for lib in "c" "crypt" "descrypt" "des"
1993 do
1994
1995 if test "$lib" = "c" ; then
1996         LIBS="$ac_save_LIBS"
1997 else
1998         LIBS="$ac_save_LIBS -l${lib}"
1999 fi
2000
2001 wi_PREREQ_UNISTD_H([$0])
2002 AC_TRY_RUN([
2003         /* program */
2004 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
2005 #       define _ALL_SOURCE 1
2006 #endif
2007 #ifdef HAVE_UNISTD_H
2008 #       include <unistd.h>
2009 #endif
2010 #include <stdio.h>
2011 #include <string.h>
2012
2013 extern char *crypt(const char *key, const char *salt);
2014
2015 main()
2016 {
2017         char cleartext[256];
2018         char *cp;
2019
2020         memset(cleartext, 0, sizeof(cleartext));
2021         strcpy(cleartext, "password");
2022
2023         cp = crypt(cleartext, "xx");
2024         if ((cp != NULL) && (strcmp(cp, "xxj31ZMTZzkVA") == 0)) {
2025                 /* printf("PASS\n"); */
2026                 exit(0);
2027         }
2028         /* printf("FAIL\n"); */
2029         exit(1);
2030 }
2031 ],[
2032         # action if true
2033         crypt_lib="$lib"
2034 ],[
2035         # action if false
2036         :
2037 ],[
2038         # action if cross compiling
2039         :
2040 ])
2041
2042
2043 if test "$crypt_lib" != NONE ; then
2044         break
2045 fi
2046
2047 done
2048
2049
2050 LIBS="$ac_save_LIBS"
2051
2052 if test "$crypt_lib" = NONE ; then
2053         crypt_lib=c
2054         AC_MSG_RESULT([none?])
2055 else
2056         AC_MSG_RESULT([lib${crypt_lib}])
2057 fi
2058 if test "$crypt_lib" != c ; then
2059         AC_CHECK_LIB(${lib},crypt)
2060 fi
2061 ])
2062 dnl
2063 dnl
2064 dnl
2065 AC_DEFUN([wi_TEST], [
2066 changequote(<^, ^>)dnl
2067 changequote([, ])dnl
2068 ])
2069 dnl
2070 dnl
2071 dnl
2072 AH_TEMPLATE([HAVE__RES_DEFDNAME], [define if _res global variable is usable])
2073 AC_DEFUN([wi__RES_DEFDNAME], [
2074 AC_MSG_CHECKING([for useable _res global variable])
2075 AC_TRY_LINK([
2076         /* includes */
2077 #include <unistd.h>
2078 #include <sys/types.h>
2079 #include <sys/stat.h>
2080 #include <sys/socket.h>
2081 #include <arpa/inet.h>
2082 #include <netinet/in.h>
2083 #ifdef HAVE_ARPA_NAMESER_H
2084 #       include <arpa/nameser.h>
2085 #endif
2086 #ifdef HAVE_RESOLV_H
2087 #       include <resolv.h>
2088 #endif
2089 ],[
2090         /* function-body */
2091         int len;
2092
2093         res_init();
2094         len = (int) strlen(_res.defdname);
2095 ],[
2096         wi_cv__res_defdname=yes
2097         AC_DEFINE(HAVE__RES_DEFDNAME)
2098 ],[
2099         wi_cv__res_defdname=no
2100 ])
2101 AC_MSG_RESULT($wi_cv__res_defdname)
2102 ])
2103 dnl
2104 dnl
2105 dnl
2106 dnl
2107 AH_TEMPLATE([sig_atomic_t], [type to use for sig_atomic_t])
2108 AC_DEFUN([wi_TYPE_SIG_ATOMIC_T], [
2109 wi_PREREQ_UNISTD_H([$0])
2110 AC_MSG_CHECKING([for sig_atomic_t])
2111 AC_TRY_LINK([
2112         /* includes */
2113 #ifdef HAVE_UNISTD_H
2114 #include <unistd.h>
2115 #endif
2116 #include <sys/types.h>
2117 #include <sys/signal.h>
2118 #include <signal.h>     /* MG: for IRIX */
2119 #if STDC_HEADERS
2120 #include <stdlib.h>
2121 #include <stddef.h>
2122 #endif
2123 ],[
2124         /* function-body */
2125         sig_atomic_t sample;
2126
2127         sample = (sig_atomic_t) getpid();       /* bogus code, of course */
2128         exit((sample > 0) ? 0 : 1);
2129 ],[
2130         ac_cv_type_sig_atomic_t=yes
2131 ],[
2132         ac_cv_type_sig_atomic_t=no
2133 ])
2134 AC_MSG_RESULT($ac_cv_type_sig_atomic_t)
2135 if test $ac_cv_type_sig_atomic_t = no ; then
2136         AC_DEFINE(sig_atomic_t, int)
2137 fi
2138 ])
2139 dnl
2140 dnl
2141 dnl
2142 dnl
2143 AC_DEFUN([wi_LIB_READLINE], [
2144 AC_MSG_CHECKING([for GNU Readline library, version 2.0 or newer])
2145
2146 wi_cv_lib_readline=no
2147 wi_cv_lib_readline_result=no
2148 ac_save_LIBS="$LIBS"
2149 # Note: $LIBCURSES is permitted to be empty.
2150 for LIBREADLINE in "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses"
2151 do
2152         LIBS="$ac_save_LIBS $LIBREADLINE"
2153         AC_TRY_RUN([
2154         /* program */
2155 #include <stdio.h>
2156 #include <stdlib.h>
2157  
2158 main(int argc, char **argv)
2159 {
2160         /* Note:  don't actually call readline, since it may block;
2161          * We just want to see if it (dynamic) linked in okay.
2162          */
2163         if (argc == 0)  /* never true */
2164                 readline(0);
2165         exit(0);
2166 }
2167 ],[
2168         # action if true
2169         wi_cv_lib_readline=yes
2170 ],[
2171         # action if false
2172         wi_cv_lib_readline=no
2173 ],[
2174         # action if cross compiling
2175         wi_cv_lib_readline=no
2176 ])
2177
2178         if test "$wi_cv_lib_readline" = yes ; then break ; fi
2179 done
2180
2181 # Now try it again, to be sure it is recent enough.
2182 # rl_function_of_keyseq appeared in version 2.0
2183 #
2184 dnl AC_CHECK_FUNC(rl_function_of_keyseq, [wi_cv_lib_readline=yes],[
2185 dnl     wi_cv_lib_readline=no;wi_cv_lib_readline_result="no (it is present but too old to use)"
2186 dnl ])
2187         AC_TRY_LINK([
2188                 /* includes */
2189         ],[
2190                 /* function-body */
2191                 readline(0);
2192                 rl_function_of_keyseq(0);
2193         ],[
2194                 wi_cv_lib_readline=yes
2195         ],[
2196                 wi_cv_lib_readline=no
2197                 wi_cv_lib_readline_result="no (it is present but too old to use)"
2198         ])
2199
2200 if test "$wi_cv_lib_readline" = no ; then
2201         LIBREADLINE=""
2202         # restore LIBS
2203         LIBS="$ac_save_LIBS"
2204 else
2205         /bin/rm -f readline.ver
2206         touch readline.ver
2207
2208         AC_TRY_RUN([
2209         /* program */
2210 #include <unistd.h>
2211 #include <sys/types.h>
2212 #include <stdio.h>
2213
2214 extern char *rl_library_version;
2215
2216 main()
2217 {
2218         FILE *fp;
2219         double d;
2220
2221         sscanf(rl_library_version, "%lf", &d);
2222         fp = fopen("readline.ver", "w");
2223         if (fp == NULL) exit(1);
2224         if (fprintf(fp, "%s\n", rl_library_version) < 0) exit(1);
2225         if (fprintf(fp, "%03d\n", (int) (d * 100.0)) < 0) exit(1);
2226         if (fclose(fp) < 0) exit(1);
2227         exit(0);
2228 }
2229         ],[
2230                 # action if true
2231                 rl_library_version=`sed -n 1,1p readline.ver 2>/dev/null`
2232                 rlver=`sed -n 2,2p readline.ver 2>/dev/null`
2233                 /bin/rm -f readline.ver
2234         ],[
2235                 # action if false
2236                 rl_library_version=''
2237                 rlver=''
2238                 /bin/rm -f readline.ver
2239         ],[
2240                 # action if cross compiling
2241                 rl_library_version=''
2242                 rlver=''
2243                 /bin/rm -f readline.ver
2244         ])
2245
2246         case "$rlver" in
2247                 ???)
2248                         wi_cv_lib_readline_result="yes, installed version is $rl_library_version"
2249                         ;;
2250                 *)
2251                         # Test using current LIBS.
2252                         AC_TRY_LINK([
2253                                 /* includes */
2254                                 extern int rl_completion_append_character;
2255                         ],[
2256                                 /* function-body */
2257                                 readline(0);
2258                                 rl_completion_append_character = 0;
2259                         ],[
2260                                 rlver="210"
2261                         ],[
2262                                 rlver="200"
2263                         ])
2264
2265                         if test "$rlver" = "210" ; then
2266                                 wi_cv_lib_readline_result="yes, version 2.1 or higher"
2267                         else
2268                                 wi_cv_lib_readline_result="yes, version 2.0"
2269                         fi
2270                         ;;
2271         esac
2272
2273         wi_cv_lib_readline=yes
2274         # restore LIBS
2275         LIBS="$ac_save_LIBS"
2276 fi
2277 AC_MSG_RESULT($wi_cv_lib_readline_result)
2278 AC_SUBST(LIBREADLINE)
2279
2280 if test "$wi_cv_lib_readline" = yes ; then
2281         # Now verify that all the headers are installed.
2282         #
2283         AC_REQUIRE_CPP()
2284         unset ac_cv_header_readline_chardefs_h
2285         unset ac_cv_header_readline_history_h
2286         unset ac_cv_header_readline_keymaps_h
2287         unset ac_cv_header_readline_readline_h
2288         unset ac_cv_header_readline_tilde_h
2289         AC_CHECK_HEADERS([readline/chardefs.h readline/history.h readline/keymaps.h readline/readline.h readline/tilde.h])
2290
2291         for xxwi in \
2292                 "$ac_cv_header_readline_chardefs_h" \
2293                 "$ac_cv_header_readline_history_h" \
2294                 "$ac_cv_header_readline_keymaps_h" \
2295                 "$ac_cv_header_readline_readline_h" \
2296                 "$ac_cv_header_readline_tilde_h" 
2297         do
2298                 if test "$xxwi" = no ; then
2299                         break
2300                 fi
2301         done
2302
2303         if test "$xxwi" = no ; then
2304                 AC_MSG_WARN([GNU Readline headers are not installed or could not be found -- GNU Readline will not be used.])
2305                 wi_cv_lib_readline=no
2306                 wi_cv_lib_readline_result="no (headers not installed)"
2307         else
2308                 AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, $rlver)
2309         fi
2310 fi
2311 ])
2312 dnl
2313 dnl
2314 dnl
2315 AH_TEMPLATE([HAVE_LONG_LONG], [define if we have the long long type])
2316 AH_TEMPLATE([PRINTF_LONG_LONG], [define if printf supports long long])
2317 AH_TEMPLATE([SCANF_LONG_LONG], [define if scanf supports long long])
2318 AH_TEMPLATE([PRINTF_ULONG_LONG], [define if printf supports unsigned long long])
2319 AH_TEMPLATE([SCANF_ULONG_LONG], [define if scanf supports unsigned long long])
2320 AH_TEMPLATE([PRINTF_LONG_LONG_QD], [define if using %qd for long long in printf])
2321 AH_TEMPLATE([SCANF_LONG_LONG_QD], [define if using %qd for long long in scanf])
2322 AH_TEMPLATE([PRINTF_LONG_LONG_LLD], [define if using %lld for long long in printf])
2323 AH_TEMPLATE([SCANF_LONG_LONG_LLD], [define if using %lld for long long in scanf])
2324 AC_DEFUN([wi_USE_LONG_LONG], [
2325 wi_PREREQ_UNISTD_H([$0])
2326 AC_MSG_CHECKING([for 64-bit integral type: long long])
2327 LONGEST_INT="long"
2328 AC_TRY_RUN([
2329         /* program */
2330 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
2331 #       define _ALL_SOURCE 1
2332 #endif
2333 #ifdef HAVE_UNISTD_H
2334 #       include <unistd.h>
2335 #endif
2336 #include <sys/types.h>
2337 #include <stdio.h>
2338
2339 long long hugeNumvar = 1;
2340
2341 main()
2342 {
2343         long long hugeNumtoo = 2;
2344
2345         if (hugeNumtoo > hugeNumvar)
2346                 hugeNumvar++;
2347         if (sizeof(hugeNumvar) < 8)
2348                 exit(1);
2349         exit(0);
2350 }
2351
2352 ],[
2353         # action if true
2354         wi_cv_type_long_long=yes
2355         LONGEST_INT="long long"
2356 ],[
2357         # action if false
2358         wi_cv_type_long_long=no
2359 ],[
2360         # action if cross compiling
2361         wi_cv_type_long_long=no
2362 ])
2363 AC_MSG_RESULT($wi_cv_type_long_long)
2364
2365 if test "$wi_cv_type_long_long" = yes ; then
2366         
2367 AC_MSG_CHECKING([how to print a 64-bit integral type])
2368 wi_cv_printf_long_long=fail
2369
2370 AC_TRY_RUN([
2371         /* program */
2372 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
2373 #       define _ALL_SOURCE 1
2374 #endif
2375 #ifdef HAVE_UNISTD_H
2376 #       include <unistd.h>
2377 #endif
2378 #include <sys/types.h>
2379 #include <stdio.h>
2380 #include <string.h>
2381 #include <stdlib.h>
2382
2383 main()
2384 {
2385         char s[80];
2386         long long hugeNum;
2387
2388         hugeNum = (long long) 1000000000;
2389         hugeNum = hugeNum * (long long) 99;
2390         hugeNum = hugeNum + (long long) 1;
2391
2392         (void) sprintf(s, "%lld", hugeNum);
2393         exit((strcmp(s, "99000000001") == 0) ? 0 : 1);
2394 }
2395 ],[
2396         # action if true
2397         wi_cv_printf_long_long="%lld"
2398 ],[
2399         # action if false
2400         :
2401 ],[
2402         # action if cross compiling
2403         :
2404 ])
2405
2406
2407 if test "$wi_cv_printf_long_long" = fail ; then
2408
2409 AC_TRY_RUN([
2410         /* program */
2411 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
2412 #       define _ALL_SOURCE 1
2413 #endif
2414 #ifdef HAVE_UNISTD_H
2415 #       include <unistd.h>
2416 #endif
2417 #include <sys/types.h>
2418 #include <stdio.h>
2419 #include <string.h>
2420 #include <stdlib.h>
2421
2422 main()
2423 {
2424         char s[80];
2425         long long hugeNum;
2426
2427         hugeNum = (long long) 1000000000;
2428         hugeNum = hugeNum * (long long) 99;
2429         hugeNum = hugeNum + (long long) 1;
2430
2431         (void) sprintf(s, "%qd", hugeNum);
2432         exit((strcmp(s, "99000000001") == 0) ? 0 : 1);
2433 }
2434 ],[
2435         # action if true
2436         wi_cv_printf_long_long="%qd"
2437 ],[
2438         # action if false
2439         :
2440 ],[
2441         # action if cross compiling
2442         :
2443 ])
2444 fi
2445
2446 if test "$wi_cv_printf_long_long" = fail ; then
2447         wi_cv_printf_long_long_msg_result='cannot print'
2448 else
2449         wi_cv_printf_long_long_msg_result="$wi_cv_printf_long_long"
2450 fi
2451
2452 AC_MSG_RESULT($wi_cv_printf_long_long_msg_result)
2453
2454         
2455 AC_MSG_CHECKING([how to scan a 64-bit integral type])
2456 wi_cv_scanf_long_long=fail
2457
2458 AC_TRY_RUN([
2459         /* program */
2460 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
2461 #       define _ALL_SOURCE 1
2462 #endif
2463 #ifdef HAVE_UNISTD_H
2464 #       include <unistd.h>
2465 #endif
2466 #include <sys/types.h>
2467 #include <stdio.h>
2468 #include <string.h>
2469 #include <stdlib.h>
2470
2471 main()
2472 {
2473         long long hugeNum, justAsHugeNum;
2474
2475         hugeNum = (long long) 1000000000;
2476         hugeNum = hugeNum * (long long) 99;
2477         hugeNum = hugeNum + (long long) 1;
2478
2479         justAsHugeNum = (long long) 0;
2480         --justAsHugeNum;
2481         sscanf("99000000001", "%lld", &justAsHugeNum);
2482         if (memcmp(&hugeNum, &justAsHugeNum, sizeof(hugeNum)) == 0)
2483                 exit(0);
2484         exit(1);
2485 }
2486 ],[
2487         # action if true
2488         wi_cv_scanf_long_long="%lld"
2489 ],[
2490         # action if false
2491         :
2492 ],[
2493         # action if cross compiling
2494         :
2495 ])
2496
2497
2498 if test "$wi_cv_scanf_long_long" = fail ; then
2499
2500 AC_TRY_RUN([
2501         /* program */
2502 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
2503 #       define _ALL_SOURCE 1
2504 #endif
2505 #ifdef HAVE_UNISTD_H
2506 #       include <unistd.h>
2507 #endif
2508 #include <sys/types.h>
2509 #include <stdio.h>
2510 #include <string.h>
2511 #include <stdlib.h>
2512
2513 main()
2514 {
2515         long long hugeNum, justAsHugeNum;
2516
2517         hugeNum = (long long) 1000000000;
2518         hugeNum = hugeNum * (long long) 99;
2519         hugeNum = hugeNum + (long long) 1;
2520
2521         justAsHugeNum = (long long) 0;
2522         --justAsHugeNum;
2523         sscanf("99000000001", "%qd", &justAsHugeNum);
2524         if (memcmp(&hugeNum, &justAsHugeNum, sizeof(hugeNum)) == 0)
2525                 exit(0);
2526         exit(1);
2527 }
2528 ],[
2529         # action if true
2530         wi_cv_scanf_long_long="%qd"
2531 ],[
2532         # action if false
2533         :
2534 ],[
2535         # action if cross compiling
2536         :
2537 ])
2538 fi
2539
2540 if test "$wi_cv_scanf_long_long" = fail ; then
2541         wi_cv_scanf_long_long_msg_result='cannot scan'
2542 else
2543         wi_cv_scanf_long_long_msg_result="$wi_cv_scanf_long_long"
2544 fi
2545
2546 AC_MSG_RESULT($wi_cv_scanf_long_long_msg_result)
2547
2548 fi
2549
2550 AC_MSG_CHECKING([if everything was available to use the 64-bit integral type])
2551
2552 if test "$wi_cv_type_long_long" = no ; then
2553         wi_cv_use_long_long_msg_result="no (long long type not available)"
2554         wi_cv_use_long_long="no"
2555         wi_cv_scanf_long_long="fail"
2556         wi_cv_prihtf_long_long="fail"
2557         LONGEST_INT="long"
2558 elif test "$wi_cv_printf_long_long" = fail ; then
2559         wi_cv_use_long_long_msg_result="no (libc printf() does not support them)"
2560         wi_cv_use_long_long="no"
2561         wi_cv_scanf_long_long="fail"
2562         wi_cv_prihtf_long_long="fail"
2563         LONGEST_INT="long"
2564 elif test "$wi_cv_scanf_long_long" = fail ; then
2565         wi_cv_use_long_long_msg_result="no (libc scanf() does not support them)"
2566         wi_cv_use_long_long="no"
2567         wi_cv_scanf_long_long="fail"
2568         wi_cv_prihtf_long_long="fail"
2569         LONGEST_INT="long"
2570 else
2571         AC_DEFINE(HAVE_LONG_LONG)
2572         if test "$wi_cv_printf_long_long$wi_cv_scanf_long_long" = "%lld%qd" ; then
2573                 # FreeBSD 3.2 has %lld and %qd, but we want to
2574                 # run on 3.1 and 3.0.
2575                 #
2576                 wi_cv_printf_long_long="%qd"
2577         fi
2578         wi_cv_printf_ulong_long=`echo "$wi_cv_printf_long_long" | sed 's/d$/u/;'`
2579         wi_cv_scanf_ulong_long=`echo "$wi_cv_scanf_long_long" | sed 's/d$/u/;'`
2580         AC_DEFINE_UNQUOTED(PRINTF_LONG_LONG, "$wi_cv_printf_long_long")
2581         AC_DEFINE_UNQUOTED(SCANF_LONG_LONG , "$wi_cv_scanf_long_long")
2582         AC_DEFINE_UNQUOTED(PRINTF_ULONG_LONG, "$wi_cv_printf_ulong_long")
2583         AC_DEFINE_UNQUOTED(SCANF_ULONG_LONG , "$wi_cv_scanf_ulong_long")
2584         if test "$wi_cv_printf_long_long" = "%qd" ; then
2585                 AC_DEFINE(PRINTF_LONG_LONG_QD)
2586         else
2587                 AC_DEFINE(PRINTF_LONG_LONG_LLD)
2588         fi
2589         if test "$wi_cv_scanf_long_long" = "%qd" ; then
2590                 AC_DEFINE(SCANF_LONG_LONG_QD)
2591         else
2592                 AC_DEFINE(SCANF_LONG_LONG_LLD)
2593         fi
2594         wi_cv_use_long_long="yes"
2595         wi_cv_use_long_long_msg_result="yes"
2596 fi
2597 AC_MSG_RESULT($wi_cv_use_long_long_msg_result)
2598 ])
2599 dnl
2600 dnl
2601 dnl
2602 AC_DEFUN([wi_REMOVE_UNKNOWN_PREPROCESSING_DIRECTIVES_FROM_FILE], [
2603 AC_REQUIRE([wi_TEST_DASH_L])
2604 h_file="$1"
2605 if test -f "$h_file" && $test_not_L "$h_file" ; then
2606         h_tmp=`echo "$h_file" | sed 's/\.h/.tmp/;'`
2607
2608 changequote(<<, >>)dnl
2609         remove_cpp_warning=yes
2610         if [ "$SYS" = linux ] ; then
2611                 #
2612                 # We need to retain #warning on Linux
2613                 #
2614                 remove_cpp_warning=no
2615         fi
2616         if [ "$GCC" = yes ] ; then
2617                 #
2618                 # GCC accepts #warning
2619                 #
2620                 remove_cpp_warning=no
2621         fi
2622
2623         if [ "$remove_cpp_warning" = yes ] ; then
2624                 #
2625                 # Remove "#warning", since compiler will complain about it
2626                 # not being recognized.
2627                 #
2628                 sed 's/^\([\ \  ]*#[\ \ ]*warning.*\)/\/* \1 *\//;' "$h_file" > "$h_tmp"
2629                 cmp -s "$h_file" "$h_tmp"
2630                 if test $? -ne 0 ; then 
2631                         mv "$h_tmp" "$h_file"
2632                         chmod a+r "$h_file"
2633                 fi
2634                 /bin/rm -f "$h_tmp"
2635                 unset h_tmp longest_int_subst
2636         fi
2637 changequote([, ])dnl
2638 fi
2639 unset h_file remove_cpp_warning
2640 ])
2641 dnl
2642 dnl
2643 dnl
2644 AC_DEFUN([wi_SUBST_LONGEST_INT_HEADER], [
2645 AC_REQUIRE([wi_TEST_DASH_L])
2646 h_file="$1"
2647 if test -f "$h_file" && $test_not_L "$h_file" ; then
2648         h_tmp=`echo "$h_file" | sed 's/\.h/.tmp/;'`
2649 dnl
2650 dnl LONGEST_INT should most often be "long long" if wi_USE_LONG_LONG has been run
2651 dnl
2652         longest_int_subst="${LONGEST_INT-long}"
2653 dnl
2654         if sed 's/^#define longest_int.*/#define longest_int '"$longest_int_subst"'/;s/^#define longest_uint.*/#define longest_uint unsigned '"$longest_int_subst"'/;' "$h_file" > "$h_tmp" ; then
2655                 cmp -s "$h_file" "$h_tmp"
2656                 if test $? -ne 0 ; then 
2657                         mv "$h_tmp" "$h_file"
2658                         chmod a+r "$h_file"
2659                 fi
2660         fi
2661         /bin/rm -f "$h_tmp"
2662         unset h_tmp longest_int_subst
2663 fi
2664 unset h_file
2665 ])
2666 dnl
2667 dnl
2668 dnl
2669 AC_DEFUN([wi_SUBST_STAT_HEADER], [
2670 AC_REQUIRE([wi_TEST_DASH_L])
2671 h_file="$1"
2672 if test -f "$h_file" && $test_not_L "$h_file" ; then
2673         h_tmp=`echo "$h_file" | sed 's/\.h/.tmp/;'`
2674 dnl
2675 dnl wi_cv_struct_stat64=yes
2676 dnl
2677         if test "x$wi_cv_struct_stat64" = xyes ; then
2678                 if sed 's/^#define Stat .*/#define Stat stat64/;s/^#define Lstat .*/#define Lstat lstat64/;s/^#define Fstat .*/#define Fstat fstat64/;' "$h_file" > "$h_tmp" ; then
2679                         cmp -s "$h_file" "$h_tmp"
2680                         if test $? -ne 0 ; then 
2681                                 mv "$h_tmp" "$h_file"
2682                                 chmod a+r "$h_file"
2683                         fi
2684                 fi
2685         else
2686                 if sed 's/^#define Stat .*/#define Stat stat/;s/^#define Lstat .*/#define Lstat lstat/;s/^#define Fstat .*/#define Fstat fstat/;' "$h_file" > "$h_tmp" ; then
2687                         cmp -s "$h_file" "$h_tmp"
2688                         if test $? -ne 0 ; then 
2689                                 mv "$h_tmp" "$h_file"
2690                                 chmod a+r "$h_file"
2691                         fi
2692                 fi
2693         fi
2694         /bin/rm -f "$h_tmp"
2695         unset h_tmp longest_int_subst
2696 fi
2697 unset h_file
2698 ])
2699 dnl
2700 dnl
2701 dnl
2702 dnl
2703 AC_DEFUN([wi_MANDIR], [
2704 if test "x$mandir" = 'x${prefix}/man' ; then
2705         # Mandir is at default value -- try to see
2706         # if $prefix/share/man would be better.
2707         #
2708
2709         # $prefix is probably set to NONE.
2710         #
2711         p=`cd / ; cd $prefix 2>/dev/null ; pwd`
2712         if test "x$p" = "x/" ; then
2713                 p="/usr/local"
2714         fi
2715         if test -d "$p/share/man" ; then
2716                 mandir="$p/share/man"
2717         fi
2718 fi
2719 ])
2720 dnl
2721 dnl
2722 dnl
2723 dnl
2724 AC_DEFUN([wi_BEAUTIFY_ENVIRONMENT_VARIABLES], [
2725 changequote(<<, >>)dnl
2726 LIBS=`echo "$LIBS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
2727 LDFLAGS=`echo "$LDFLAGS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
2728 CPPFLAGS=`echo "$CPPFLAGS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
2729 CFLAGS=`echo "$CFLAGS $wi_CFLAGS_TO_ADD_LATER" | sed 's/^ *//;s/ *$//;s/  */ /g'`
2730 DEFS=`echo "$DEFS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
2731 changequote([, ])dnl
2732 ])
2733 dnl
2734 dnl
2735 dnl
2736 dnl
2737 AC_DEFUN([wi_PATH_PWD], [
2738 AC_PATH_PROG(wi_PWD, "pwd", "pwd")
2739 ])
2740 dnl
2741 dnl
2742 dnl
2743 dnl
2744 AC_DEFUN([wi_BASENAME], [
2745 $1=`echo "[$]$1" | sed -n '
2746 s-//*-/-g
2747 s-/*$--
2748 s-^/$--
2749 s-^.*/--
2750 p
2751 q'`dnl
2752 ])
2753 dnl
2754 dnl
2755 dnl
2756 dnl
2757 AC_DEFUN([wi_DIRNAME], [
2758 changequote({{, }})dnl
2759 $1=`echo "{{$}}$1" | sed -n '
2760 s-//*-/-g
2761 s-/*$--
2762 /^\/\/*[^/]*$/{
2763         c\\
2764 /
2765         p
2766         q
2767 }
2768 /^[^/]*$/{
2769         c\\
2770 .
2771         p
2772         q
2773 }
2774 /./{
2775         s-/[^/]*$--
2776         p
2777         q
2778 }'`dnl
2779 changequote([, ])dnl
2780 ])
2781 dnl
2782 dnl
2783 dnl
2784 dnl
2785 AC_DEFUN([wi_RESOLVE_PATH], [
2786 AC_REQUIRE([wi_PATH_PWD])
2787 wi_path="$1"
2788 if test -d "$wi_path" ; then
2789         wi_resolved_path=`cd "$wi_path" ; $wi_PWD 2>/dev/null`
2790 elif test ! -f "$wi_path" ; then
2791         wi_resolved_path="$wi_path"
2792 else
2793         wi_parent_dir="$wi_path"
2794         wi_file_name="$wi_path"
2795         wi_DIRNAME(wi_parent_dir)
2796         wi_BASENAME(wi_file_name)
2797         wi_resolved_path=`cd "$wi_parent_dir" ; $wi_PWD 2>/dev/null`
2798         if test "x$wi_resolved_path" != x ; then
2799                 wi_resolved_path="$wi_resolved_path/$wi_file_name"
2800         fi
2801         unset wi_parent_dir wi_file_name
2802 fi
2803 if test "x$wi_resolved_path" = x ; then
2804         $2="[$]$1"
2805 else
2806         $2="$wi_resolved_path"
2807 fi
2808 unset wi_resolved_path wi_path
2809 ])
2810 dnl
2811 dnl
2812 dnl
2813 dnl
2814 AC_DEFUN([wi_PATH_MKTEMP], [
2815 AC_PATH_PROG(MKTEMP, "mktemp", "")
2816 ])
2817 dnl
2818 dnl
2819 dnl
2820 dnl
2821 AC_DEFUN([wi_PATH_PERL], [
2822 AC_PATH_PROG(PERL, "perl", "perl")
2823 ])
2824 dnl
2825 dnl
2826 dnl
2827 dnl
2828 AC_DEFUN([wi_PROG_PERL], [
2829 AC_REQUIRE([wi_PATH_PERL])
2830 if test "x$PERL" != "x" ; then
2831         AC_DEFINE_UNQUOTED(PERL, "$PERL")
2832 fi
2833 AC_SUBST(PERL)
2834 ])
2835 dnl
2836 dnl
2837 dnl
2838 dnl
2839 AC_DEFUN([wi_CREATE_AC_TMPDIR], [
2840 AC_REQUIRE([wi_PATH_MKTEMP])
2841 changequote({{, }})dnl
2842 wi_tmpdir=""
2843 if [ "x$MKTEMP" != "x" ] ; then
2844         # Ignore error from mktemp, since some old versions of Linux
2845         # print an error about not supporting -d.
2846         #
2847         wi_tmpdir=`"$MKTEMP" -d /tmp/configure.XXXXXXXXXX 2>/dev/null`
2848         if [ $? -ne 0 ] ; then
2849                 wi_tmpdir=""
2850         fi
2851 fi
2852 if [ "x$wi_tmpdir" = "x" ] ; then
2853         for wi_tmpdir in . $TMPDIR $TEMPDIR /tmp ABORT
2854         do
2855                 if [ "$wi_tmpdir" = ABORT ] ; then
2856                         echo "Cannot create temporary directory."
2857                         exit 1
2858                 fi
2859                 wi_tmpdir="$wi_tmpdir/config_tmp.$$"
2860                 if [ -d "$wi_tmpdir" ] || [ -f "$wi_tmpdir" ] ; then
2861                         echo "Will not create temporary directory."
2862                         exit 1
2863                 fi
2864                 mkdir "$wi_tmpdir"
2865                 if [ $? -eq 0 ] && [ -d "$wi_tmpdir" ] ; then break ;  fi
2866         done
2867 fi
2868 changequote([, ])dnl
2869
2870 # Use the temporary directory here...
2871 $1
2872 # Done using the temporary directory here.
2873
2874 /bin/rm -r "$wi_tmpdir"
2875 unset wi_tmpdir
2876 ])
2877 dnl
2878 dnl
2879 dnl
2880 dnl
2881 AH_TEMPLATE([SELECT_TYPE_ARG1], [define this to the type of the first parameter to select()])
2882 AH_TEMPLATE([SELECT_TYPE_ARG234], [define this to the type of parameters 2, 3, and 4 to select()])
2883 AH_TEMPLATE([SELECT_TYPE_ARG5], [define this to the type of the fifth parameter to select()])
2884 AC_DEFUN([wi_FUNC_SELECT_ARGTYPES],
2885 [
2886 wi_PREREQ_UNISTD_H([$0])
2887 AC_MSG_CHECKING([types of arguments for select()])
2888  AC_CACHE_VAL(ac_cv_func_select_arg234,dnl
2889  [AC_CACHE_VAL(ac_cv_func_select_arg1,dnl
2890   [AC_CACHE_VAL(ac_cv_func_select_arg5,dnl
2891    [for ac_cv_func_select_arg234 in 'fd_set *' 'int *' 'void *'; do
2892      for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
2893       for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
2894        AC_TRY_COMPILE(dnl
2895 [#if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)      /* MG */
2896 #       define _ALL_SOURCE 1    /* MG */
2897 #endif
2898 #ifdef HAVE_UNISTD_H    /* MG */
2899 #include <unistd.h>
2900 #endif                  /* MG */
2901 #include <sys/types.h>  /* MG: always incl */
2902 #include <sys/time.h>   /* MG: always incl */
2903 #ifdef HAVE_SYS_SELECT_H
2904 #include <sys/select.h>
2905 #endif
2906 #include <sys/socket.h> /* MG: always incl */
2907 extern select ($ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5);],,dnl
2908         [ac_not_found=no ; break 3],ac_not_found=yes)
2909       done
2910      done
2911     done
2912    ])dnl AC_CACHE_VAL
2913   ])dnl AC_CACHE_VAL
2914  ])dnl AC_CACHE_VAL
2915  if test "$ac_not_found" = yes; then
2916   ac_cv_func_select_arg1=int 
2917   ac_cv_func_select_arg234='int *' 
2918   ac_cv_func_select_arg5='struct timeval *'
2919  fi
2920  AC_MSG_RESULT([$ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5])
2921  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1,$ac_cv_func_select_arg1)
2922  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234,($ac_cv_func_select_arg234))
2923  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5,($ac_cv_func_select_arg5))
2924 ])
2925 dnl
2926 dnl
2927 dnl
2928 dnl
2929 AC_DEFUN([wi_CREATE_PRPP_SCRIPT], [
2930 changequote({{, }})dnl
2931 cat << 'EOF' > "{{$1}}"
2932 #!/usr/bin/perl -w
2933 #
2934 # prpp.pl
2935 #
2936 # Feed the output of your CPP to this to print a list of function prototypes.
2937
2938 #use strict;
2939
2940 my ($c) = "";
2941 my ($unputc) = "";
2942 my ($line) = "";
2943 my ($lines) = "";
2944 my ($cline) = "";
2945 my ($skipping) = 0;
2946 my ($numclines) = 0;
2947
2948 MAINLOOP: while (1) {
2949         if ($unputc ne "") {
2950                 $c = $unputc;
2951                 $unputc = "";
2952         } else {
2953                 last unless (read(STDIN, $c, 1) == 1);
2954         }
2955         if ($c eq "{") {
2956                 $skipping++;
2957         } elsif ($c eq "}") {
2958                 --$skipping;
2959                 $unputc = ";";
2960         } elsif ($skipping) {
2961                 next MAINLOOP;
2962         } elsif ($c eq ";") {
2963                 if ($line =~ m/^\s*(\S.*\S)\s*$/s) {
2964                         $lines .= {{$}}1;
2965                         $line = "";
2966                 }
2967                 if ($lines =~ m/^\s*(extern\s*)?(\S.*\S)\s*$/s) {
2968                         $cline = {{$}}2;
2969                         $cline =~ s/\s+/\ /g;
2970                         if ($cline =~ /^typedef/) {
2971                                 $cline = "";
2972                         } elsif ($cline =~ /\(.*\)$/) {
2973                                 # found a proto
2974                                 print $cline, ";\n";
2975                                 $numclines++;
2976                         } else {
2977                                 $cline = "";
2978                         }
2979                 }
2980                 $lines = "";
2981                 $line = "";
2982         } elsif ($c eq "\n") {
2983                 if ($line =~ m/^\s*(\S.*\S)\s*$/s) {
2984                         $lines .= {{$}}1 . " ";
2985                         $line = "";
2986                 }
2987         } elsif (($c eq "#") && ($line eq "")) {
2988                 # Looks like a preprocessor line, kill it
2989                 {
2990                         last MAINLOOP if (read(STDIN, $c, 1) != 1);
2991                         last if ($c eq "\n");
2992                         redo;
2993                 }
2994         } elsif ($c =~ /^\s$/) {
2995                 $line .= " " if ($line ne "");
2996         } elsif (! $skipping) {
2997                 $line .= $c;
2998         }
2999 }
3000 exit(($numclines == 0) ? 1 : 0);
3001 EOF
3002 chmod 755 "{{$1}}"
3003 changequote([, ])dnl
3004 ])
3005 dnl
3006 dnl
3007 dnl
3008 dnl
3009 AH_TEMPLATE([write_return_t], [return type from write])
3010 AH_TEMPLATE([write_size_t], [size parameter to write])
3011 AH_TEMPLATE([read_return_t], [return type from read])
3012 AH_TEMPLATE([read_size_t], [size parameter to read])
3013 AH_TEMPLATE([send_return_t], [return type from send])
3014 AH_TEMPLATE([send_size_t], [size parameter to send])
3015 AH_TEMPLATE([recv_return_t], [return type from recv])
3016 AH_TEMPLATE([recv_size_t], [size parameter to recv])
3017 AH_TEMPLATE([sockaddr_size_t], [size parameter to connect])
3018 AH_TEMPLATE([sockopt_size_t], [size parameter to setsockopt])
3019 AH_TEMPLATE([listen_backlog_t], [backlog parameter to write])
3020 AH_TEMPLATE([alarm_time_t], [seconds parameter to alarm])
3021 AH_TEMPLATE([gethost_addrptr_t], [address parameter to gethostbyaddr])
3022 AH_TEMPLATE([gethostname_size_t], [size parameter to gethostname])
3023 AC_DEFUN([wi_UNISTD_FUNC_PARAM_TYPES], [
3024 AC_REQUIRE([AC_PROG_CPP])
3025 AC_REQUIRE([wi_PATH_PERL])
3026 AC_REQUIRE([AC_TYPE_SIZE_T])
3027 AC_REQUIRE([wi_PATH_MKTEMP])
3028 wi_PREREQ_UNISTD_H([$0])
3029 AC_CACHE_CHECK([for return type from write], [wi_cv_write_return_t], [
3030 used_cache_for_wi_unistd_fpt="no"
3031 wi_CREATE_AC_TMPDIR([
3032 wi_CREATE_PRPP_SCRIPT([$wi_tmpdir/prpp.pl])
3033
3034 changequote({{, }})dnl
3035 cat << 'EOF' > "$wi_tmpdir/unistd.c"
3036 #include <confdefs.h>
3037
3038 #include <unistd.h>
3039 #include <sys/types.h>
3040 #include <sys/socket.h>
3041 #include <netinet/in.h>
3042 #include <arpa/inet.h>
3043 #include <netdb.h>
3044
3045 main()
3046 {
3047         exit(0);
3048 }
3049 EOF
3050
3051 cat << 'EOF' > "$wi_tmpdir/sed.sh"
3052 #!/bin/sh
3053
3054 if [ {{$}}# -eq 0 ] ; then exit 1 ; fi
3055 x="{{$}}1"
3056
3057 sed -n 's/extern//;s/static//;
3058                 /[\ \*]'"$x"'\ *(/{
3059                         s/^.*'"$x"'\ *(/(/
3060                         s/)\ *[;,].*$/)/
3061                         /ssize_t/{
3062                                 c\
3063 ssize_t
3064                         }
3065                         /size_t/{
3066                                 c\
3067 size_t
3068                         }
3069                         /socklen_t/{
3070                                 c\
3071 socklen_t
3072                         }
3073                         /unsigned int/{
3074                                 c\
3075 unsigned int
3076                         }
3077                         /unsigned long/{
3078                                 c\
3079 unsigned long
3080                         }
3081                         /long/{
3082                                 c\
3083 long
3084                         }
3085                         q
3086 }' | sed 's/int int/int/g'
3087 EOF
3088 chmod 755 "$wi_tmpdir/sed.sh"
3089
3090
3091 cat << 'EOF' > "$wi_tmpdir/sed2.sh"
3092 #!/bin/sh
3093
3094 if [ {{$}}# -eq 0 ] ; then exit 1 ; fi
3095 x="{{$}}1"
3096
3097 sed -n 's/extern//;s/static//;
3098                 /[\ \*]'"$x"'\ *(/{
3099                         s/^.*'"$x"'\ *(/(/
3100                         s/)\ *[;,].*$/)/
3101                         /const char/{
3102                                 c\
3103 const char *
3104                         }
3105                         /char/{
3106                                 c\
3107 char *
3108                         }
3109                         /const/{
3110                                 c\
3111 const void
3112                         }
3113                         q
3114 }'
3115 EOF
3116 chmod 755 "$wi_tmpdir/sed2.sh"
3117
3118 $CPP "-I${srcdir-.}" "$wi_tmpdir/unistd.c" > "$wi_tmpdir/unistd.i"
3119 if [ -s "$wi_tmpdir/unistd.i" ] ; then
3120         "$PERL" "$wi_tmpdir/prpp.pl" < "$wi_tmpdir/unistd.i" > "$wi_tmpdir/protos.h"
3121 fi
3122 if [ -f "$wi_tmpdir/protos.h" ] ; then
3123         #
3124         # Check the return type of write()
3125         #
3126         x="write"
3127         wi_cv_write_return_t=`sed -n 's/extern//;s/static//;
3128                 s/__attribute__((__cdecl__))//;
3129                 /[\ \*]'"$x"'\ *(/{
3130                         s/'"$x"'\ *(.*//
3131                         s/^\ *//
3132                         s/\ *$//
3133                         p;q
3134                 }' "$wi_tmpdir/protos.h"`
3135         #
3136         # Check what type write() expects for the size parameter
3137         #
3138         x="write"
3139         wi_cv_write_size_t=`/bin/sh "$wi_tmpdir/sed.sh" "$x" < "$wi_tmpdir/protos.h"`
3140         #
3141         # Check the return type of send()
3142         #
3143         x="send"
3144         wi_cv_send_return_t=`sed -n 's/extern//;s/static//;
3145                 s/__attribute__((__cdecl__))//;
3146                 /[\ \*]'"$x"'\ *(/{
3147                         s/'"$x"'\ *(.*//
3148                         s/^\ *//
3149                         s/\ *$//
3150                         p;q
3151                 }' "$wi_tmpdir/protos.h"`
3152         #
3153         # Check what type send() expects for the size parameter
3154         # Tru64 is one example where send() differs from write()  :-(
3155         #
3156         x="send"
3157         wi_cv_send_size_t=`/bin/sh "$wi_tmpdir/sed.sh" "$x" < "$wi_tmpdir/protos.h"`
3158         #
3159         # Check what type connect() expects for the size parameter
3160         #
3161         x="connect"
3162         wi_cv_sockaddr_size_t=`/bin/sh "$wi_tmpdir/sed.sh" "$x" < "$wi_tmpdir/protos.h"`
3163         #
3164         # Check what type setsockopt() expects for the size parameter
3165         #
3166         x="setsockopt"
3167         wi_cv_sockopt_size_t=`/bin/sh "$wi_tmpdir/sed.sh" "$x" < "$wi_tmpdir/protos.h"`
3168         #
3169         # Check what type listen() expects for the backlog parameter
3170         #
3171         x="listen"
3172         wi_cv_listen_backlog_t=`/bin/sh "$wi_tmpdir/sed.sh" "$x" < "$wi_tmpdir/protos.h"`
3173         #
3174         # Check what type alarm() expects for the seconds parameter
3175         #
3176         x="alarm"
3177         wi_cv_alarm_time_t=`/bin/sh "$wi_tmpdir/sed.sh" "$x" < "$wi_tmpdir/protos.h"`
3178         #
3179         # Check what type gethostbyaddr() expects for the addr parameter
3180         #
3181         x="gethostbyaddr"
3182         wi_cv_gethost_addrptr_t=`/bin/sh "$wi_tmpdir/sed2.sh" "$x" < "$wi_tmpdir/protos.h"`
3183         #
3184         # Check what type gethostname() expects for the size parameter
3185         #
3186         x="gethostname"
3187         wi_cv_gethostname_size_t=`/bin/sh "$wi_tmpdir/sed.sh" "$x" < "$wi_tmpdir/protos.h"`
3188 fi
3189 if [ "x$wi_cv_write_return_t" = "x" ] ; then
3190         wi_cv_write_return_t="int"
3191 fi
3192 if [ "x$wi_cv_write_size_t" = "x" ] ; then
3193         wi_cv_write_size_t="int"
3194 fi
3195 if [ "x$wi_cv_send_return_t" = "x" ] ; then
3196         wi_cv_send_return_t="int"
3197 fi
3198 if [ "x$wi_cv_send_size_t" = "x" ] ; then
3199         wi_cv_send_size_t="int"
3200 fi
3201 if [ "x$wi_cv_sockaddr_size_t" = "x" ] ; then
3202         wi_cv_sockaddr_size_t="int"
3203 fi
3204 if [ "x$wi_cv_sockopt_size_t" = "x" ] ; then
3205         wi_cv_sockopt_size_t="int"
3206 fi
3207 if [ "x$wi_cv_listen_backlog_t" = "x" ] ; then
3208         wi_cv_listen_backlog_t="int"
3209 fi
3210 if [ "x$wi_cv_alarm_time_t" = "x" ] ; then
3211         wi_cv_alarm_time_t="int"
3212 fi
3213 if [ "x$wi_cv_gethost_addrptr_t" = "x" ] ; then
3214         wi_cv_gethost_addrptr_t="struct in_addr *"
3215 fi
3216 if [ "$wi_cv_gethost_addrptr_t" = "const void" ] ; then
3217         wi_cv_gethost_addrptr_t="const struct in_addr *"
3218 fi
3219 if [ "x$wi_cv_gethostname_size_t" = "x" ] ; then
3220         wi_cv_gethostname_size_t="int"
3221 fi
3222 changequote([, ])dnl
3223 ])
3224 ])
3225 if test "x$used_cache_for_wi_unistd_fpt" = "xno" ; then
3226         AC_MSG_CHECKING([for size parameter to write])
3227         AC_MSG_RESULT([$wi_cv_write_size_t])
3228         AC_MSG_CHECKING([for return type from send])
3229         AC_MSG_RESULT([$wi_cv_send_return_t])
3230         AC_MSG_CHECKING([for size parameter to send])
3231         AC_MSG_RESULT([$wi_cv_send_size_t])
3232         AC_MSG_CHECKING([for size parameter to connect])
3233         AC_MSG_RESULT([$wi_cv_sockaddr_size_t])
3234         AC_MSG_CHECKING([for size parameter to setsockopt])
3235         AC_MSG_RESULT([$wi_cv_sockopt_size_t])
3236         AC_MSG_CHECKING([for backlog parameter to listen])
3237         AC_MSG_RESULT([$wi_cv_listen_backlog_t])
3238         AC_MSG_CHECKING([for seconds parameter to alarm])
3239         AC_MSG_RESULT([$wi_cv_alarm_time_t])
3240         AC_MSG_CHECKING([for address parameter to gethostbyaddr])
3241         AC_MSG_RESULT([$wi_cv_gethost_addrptr_t])
3242         AC_MSG_CHECKING([for size parameter to gethostname])
3243         AC_MSG_RESULT([$wi_cv_gethostname_size_t])
3244 else
3245         AC_CACHE_CHECK([for size parameter to write],[wi_cv_write_size_t],[:])
3246         AC_CACHE_CHECK([for return type from send],[wi_cv_send_return_t],[:])
3247         AC_CACHE_CHECK([for size parameter to send],[wi_cv_send_size_t],[:])
3248         AC_CACHE_CHECK([for size parameter to connect],[wi_cv_sockaddr_size_t],[:])
3249         AC_CACHE_CHECK([for size parameter to setsockopt],[wi_cv_sockopt_size_t],[:])
3250         AC_CACHE_CHECK([for backlog parameter to listen],[wi_cv_listen_backlog_t],[:])
3251         AC_CACHE_CHECK([for seconds parameter to alarm],[wi_cv_alarm_time_t],[:])
3252         AC_CACHE_CHECK([for address parameter to gethostbyaddr],[wi_cv_gethost_addrptr_t],[:])
3253         AC_CACHE_CHECK([for size parameter to gethostname],[wi_cv_gethostname_size_t],[:])
3254 fi
3255 unset used_cache_for_wi_unistd_fpt
3256 AC_DEFINE_UNQUOTED(write_return_t, $wi_cv_write_return_t)
3257 AC_DEFINE_UNQUOTED(write_size_t, $wi_cv_write_size_t)
3258 AC_DEFINE_UNQUOTED(read_return_t, $wi_cv_write_return_t)
3259 AC_DEFINE_UNQUOTED(read_size_t, $wi_cv_write_size_t)
3260 AC_DEFINE_UNQUOTED(send_return_t, $wi_cv_send_return_t)
3261 AC_DEFINE_UNQUOTED(send_size_t, $wi_cv_send_size_t)
3262 AC_DEFINE_UNQUOTED(recv_return_t, $wi_cv_send_return_t)
3263 AC_DEFINE_UNQUOTED(recv_size_t, $wi_cv_send_size_t)
3264 AC_DEFINE_UNQUOTED(sockaddr_size_t, $wi_cv_sockaddr_size_t)
3265 AC_DEFINE_UNQUOTED(sockopt_size_t, $wi_cv_sockopt_size_t)
3266 AC_DEFINE_UNQUOTED(listen_backlog_t, $wi_cv_listen_backlog_t)
3267 AC_DEFINE_UNQUOTED(alarm_time_t, $wi_cv_alarm_time_t)
3268 AC_DEFINE_UNQUOTED(gethost_addrptr_t, $wi_cv_gethost_addrptr_t)
3269 AC_DEFINE_UNQUOTED(gethostname_size_t, $wi_cv_gethostname_size_t)
3270 ])
3271 dnl
3272 dnl
3273 dnl
3274 dnl
3275 AC_DEFUN([wi_PATH_GNU_TAR_OR_TAR], [
3276 AC_PATH_PROG(TAR, "gtar", "")
3277 if test "x$TAR" = "x" ; then
3278         unset TAR
3279         unset ac_cv_path_TAR
3280         AC_PATH_PROG(TAR, "tar", "")
3281 fi
3282 ])
3283 dnl
3284 dnl
3285 dnl
3286 dnl
3287 AH_TEMPLATE([TAR], [define to the tar command being used])
3288 AC_DEFUN([wi_PROG_TAR], [
3289 AC_REQUIRE([wi_PATH_GNU_TAR_OR_TAR])
3290 if test "x$TAR" != "x" ; then
3291         AC_DEFINE_UNQUOTED(TAR, "$TAR")
3292 fi
3293 AC_SUBST(TAR)
3294 ])
3295 dnl
3296 dnl
3297 dnl
3298 dnl
3299 AC_DEFUN([wi_CREATE_TAR_FILES], [
3300 AC_REQUIRE([wi_PATH_GNU_TAR_OR_TAR])
3301 AC_MSG_CHECKING([how to create TAR files])
3302 changequote(<<, >>)dnl
3303 x=""
3304 if [ -x /usr/bin/what ] ; then
3305         x=`/usr/bin/what "$TAR" 2>&1 | sed -n 's/.*pax.*/pax/g;/pax/p'`
3306 elif [ -x /bin/what ] ; then
3307         x=`/bin/what "$TAR" 2>&1 | sed -n 's/.*pax.*/pax/g;/pax/p'`
3308 fi
3309 if [ "x$x" != "xpax" ] ; then
3310         # The junk above is because Mac OS X Server's tar freaks out
3311         # and does not exit if you do "tar --help".
3312         #
3313         x=`"$TAR" --help 2>&1 | sed -n 's/.*owner=NAME.*/owner=NAME/g;/owner=NAME/p'`
3314 fi
3315 case "$x" in
3316         *owner=NAME*)
3317                 TARFLAGS="-c --owner=root --group=bin --verbose -f"
3318                 ;;
3319         *)
3320                 TARFLAGS="cvf"
3321                 ;;
3322 esac
3323 changequote([, ])dnl
3324 AC_SUBST(TARFLAGS)
3325 AC_MSG_RESULT([$TAR $TARFLAGS])
3326 ])
3327 dnl
3328 dnl
3329 dnl
3330 dnl
3331 AC_DEFUN([wi_PROG_CCDV_NO_CREATE], [
3332 if test "x$use_ccdv" = "xno" ; then
3333         AC_MSG_CHECKING([for ccdv])
3334         AC_MSG_RESULT([(disabled)])
3335 else
3336         AC_PATH_PROG(CCDV, "CCDV", "")
3337         CCDV="$wi_cv_path_ccdv"
3338         if test "x$CCDV" != x ; then
3339                 CCDV="@$CCDV "  # trailing space needed
3340         fi
3341 AC_SUBST(CCDV)
3342 fi
3343 ])
3344 dnl
3345 dnl
3346 dnl
3347 dnl
3348 AC_DEFUN([wi_PROG_CCDV], [
3349 if test "x$use_ccdv" = "xno" ; then
3350         AC_MSG_CHECKING([for ccdv])
3351         AC_MSG_RESULT([(disabled)])
3352 else
3353 unset wi_cv_path_ccdv   # can't use cache if it was a temp prog last time
3354 wi_used_cache_path_ccdv="yes"
3355 AC_CACHE_CHECK([for ccdv], [wi_cv_path_ccdv], [
3356 wi_used_cache_path_ccdv="no"
3357 for CCDV in /usr/bin/ccdv /usr/local/bin/ccdv /usr/ccs/bin/ccdv NONE
3358 do
3359         if test "$CCDV" = NONE ; then CCDV="" ; break ; fi
3360         $CCDV >/dev/null 2>&1
3361         if test $? -eq 96 ; then
3362                 break
3363         fi
3364 done
3365 if test "x$CCDV" = "x" ; then
3366         changequote({{, }})dnl
3367         cat > ccdv.c << 'EOF'
3368 /* ccdv.c
3369  *
3370  * Copyright (C) 2002-2003, by Mike Gleason, NcFTP Software.
3371  * All Rights Reserved.
3372  *
3373  * Licensed under the GNU Public License.
3374  */
3375 #include <unistd.h>
3376 #include <sys/types.h>
3377 #include <sys/time.h>
3378 #include <sys/wait.h>
3379 #include <fcntl.h>
3380 #include <stdio.h>
3381 #include <string.h>
3382 #include <stdlib.h>
3383 #include <errno.h>
3384
3385 #define SETCOLOR_SUCCESS        (gANSIEscapes ? "\033\1331;32m" : "")
3386 #define SETCOLOR_FAILURE        (gANSIEscapes ? "\033\1331;31m" : "")
3387 #define SETCOLOR_WARNING        (gANSIEscapes ? "\033\1331;33m" : "")
3388 #define SETCOLOR_NORMAL         (gANSIEscapes ? "\033\1330;39m" : "")
3389
3390 #define TEXT_BLOCK_SIZE 8192
3391 #define INDENT 2
3392
3393 #define TERMS "vt100:vt102:vt220:vt320:xterm:xterm-color:ansi:linux:scoterm:scoansi:dtterm:cons25:cygwin:screen"
3394
3395 size_t gNBufUsed = 0, gNBufAllocated = 0;
3396 char *gBuf = NULL;
3397 int gCCPID;
3398 char gAction[64] = "";
3399 char gTarget[64] = "";
3400 char gAr[32] = "";
3401 char gArLibraryTarget[64] = "";
3402 int gDumpCmdArgs = 0;
3403 char gArgsStr[800];
3404 int gColumns = 80;
3405 int gANSIEscapes = 0;
3406 int gExitStatus = 95;
3407
3408 static void
3409 DumpFormattedOutput(void)
3410 {
3411         char *cp;
3412         char spaces[8 + 1] = "        ";
3413         char *saved;
3414         int curcol;
3415         int i;
3416
3417         curcol = 0;
3418         saved = NULL;
3419         for (cp = gBuf + ((gDumpCmdArgs == 0) ? strlen(gArgsStr) : 0); ; cp++) {
3420                 if (*cp == '\0') {
3421                         if (saved != NULL) {
3422                                 cp = saved;
3423                                 saved = NULL;
3424                         } else break;
3425                 }
3426                 if (*cp == '\r')
3427                         continue;
3428                 if (*cp == '\t') {
3429                         saved = cp + 1;
3430                         cp = spaces + 8 - (8 - ((curcol - INDENT - 1) % 8));
3431                 }
3432                 if (curcol == 0) {
3433                         for (i = INDENT; --i >= 0; )
3434                                 putchar(' ');
3435                         curcol = INDENT;
3436                 }
3437                 putchar(*cp);
3438                 if (++curcol == (gColumns - 1)) {
3439                         putchar('\n');
3440                         curcol = 0;
3441                 } else if (*cp == '\n')
3442                         curcol = 0;
3443         }
3444         free(gBuf);
3445 }       /* DumpFormattedOutput */
3446
3447
3448
3449 /* Difftime(), only for timeval structures.  */
3450 static void TimeValSubtract(struct timeval *tdiff, struct timeval *t1, struct timeval *t0)
3451 {
3452         tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
3453         tdiff->tv_usec = t1->tv_usec - t0->tv_usec;
3454         if (tdiff->tv_usec < 0) {
3455                 tdiff->tv_sec--;
3456                 tdiff->tv_usec += 1000000;
3457         }
3458 }       /* TimeValSubtract */
3459
3460
3461
3462 static void
3463 Wait(void)
3464 {
3465         int pid2, status;
3466
3467         do {
3468                 status = 0;
3469                 pid2 = (int) waitpid(gCCPID, &status, 0);
3470         } while (((pid2 >= 0) && (! WIFEXITED(status))) || ((pid2 < 0) && (errno == EINTR)));
3471         if (WIFEXITED(status))
3472                 gExitStatus = WEXITSTATUS(status);
3473 }       /* Wait */
3474
3475
3476
3477 static int
3478 SlurpProgress(int fd)
3479 {
3480         char s1[71];
3481         char *newbuf;
3482         int nready;
3483         size_t ntoread;
3484         ssize_t nread;
3485         struct timeval now, tnext, tleft;
3486         fd_set ss;
3487         fd_set ss2;
3488         const char *trail = "/-\\|", *trailcp;
3489
3490         trailcp = trail;
3491         snprintf(s1, sizeof(s1), "%s%s%s... ", gAction, gTarget[0] ? " " : "", gTarget);
3492         printf("\r%-70s%-9s", s1, "");
3493         fflush(stdout);
3494
3495         gettimeofday(&now, NULL);
3496         tnext = now;
3497         tnext.tv_sec++;
3498         tleft.tv_sec = 1;
3499         tleft.tv_usec = 0;
3500         FD_ZERO(&ss2);
3501         FD_SET(fd, &ss2);
3502         for(;;) {
3503                 if (gNBufUsed == (gNBufAllocated - 1)) {
3504                         if ((newbuf = (char *) realloc(gBuf, gNBufAllocated + TEXT_BLOCK_SIZE)) == NULL) {
3505                                 perror("ccdv: realloc");
3506                                 return (-1);
3507                         }
3508                         gNBufAllocated += TEXT_BLOCK_SIZE;
3509                         gBuf = newbuf;
3510                 }
3511                 for (;;) {
3512                         ss = ss2;
3513                         nready = select(fd + 1, &ss, NULL, NULL, &tleft);
3514                         if (nready == 1)
3515                                 break;
3516                         if (nready < 0) {
3517                                 if (errno != EINTR) {
3518                                         perror("ccdv: select");
3519                                         return (-1);
3520                                 }
3521                                 continue;
3522                         }
3523                         gettimeofday(&now, NULL);
3524                         if ((now.tv_sec > tnext.tv_sec) || ((now.tv_sec == tnext.tv_sec) && (now.tv_usec >= tnext.tv_usec))) {
3525                                 tnext = now;
3526                                 tnext.tv_sec++;
3527                                 tleft.tv_sec = 1;
3528                                 tleft.tv_usec = 0;
3529                                 printf("\r%-71s%c%-7s", s1, *trailcp, "");
3530                                 fflush(stdout);
3531                                 if (*++trailcp == '\0')
3532                                         trailcp = trail;
3533                         } else {
3534                                 TimeValSubtract(&tleft, &tnext, &now);
3535                         }
3536                 }
3537                 ntoread = (gNBufAllocated - gNBufUsed - 1);
3538                 nread = read(fd, gBuf + gNBufUsed, ntoread);
3539                 if (nread < 0) {
3540                         if (errno == EINTR)
3541                                 continue;
3542                         perror("ccdv: read");
3543                         return (-1);
3544                 } else if (nread == 0) {
3545                         break;
3546                 }
3547                 gNBufUsed += nread;
3548                 gBuf[gNBufUsed] = '\0';
3549         }
3550         snprintf(s1, sizeof(s1), "%s%s%s: ", gAction, gTarget[0] ? " " : "", gTarget);
3551         Wait();
3552         if (gExitStatus == 0) {
3553                 printf("\r%-70s", s1);
3554                 printf("[%s%s%s]", ((gNBufUsed - strlen(gArgsStr)) < 4) ? SETCOLOR_SUCCESS : SETCOLOR_WARNING, "OK", SETCOLOR_NORMAL);
3555                 printf("%-5s\n", " ");
3556         } else {
3557                 printf("\r%-70s", s1);
3558                 printf("[%s%s%s]", SETCOLOR_FAILURE, "ERROR", SETCOLOR_NORMAL);
3559                 printf("%-2s\n", " ");
3560                 gDumpCmdArgs = 1;       /* print cmd when there are errors */
3561         }
3562         fflush(stdout);
3563         return (0);
3564 }       /* SlurpProgress */
3565
3566
3567
3568 static int
3569 SlurpAll(int fd)
3570 {
3571         char *newbuf;
3572         size_t ntoread;
3573         ssize_t nread;
3574
3575         printf("%s%s%s.\n", gAction, gTarget[0] ? " " : "", gTarget);
3576         fflush(stdout);
3577
3578         for(;;) {
3579                 if (gNBufUsed == (gNBufAllocated - 1)) {
3580                         if ((newbuf = (char *) realloc(gBuf, gNBufAllocated + TEXT_BLOCK_SIZE)) == NULL) {
3581                                 perror("ccdv: realloc");
3582                                 return (-1);
3583                         }
3584                         gNBufAllocated += TEXT_BLOCK_SIZE;
3585                         gBuf = newbuf;
3586                 }
3587                 ntoread = (gNBufAllocated - gNBufUsed - 1);
3588                 nread = read(fd, gBuf + gNBufUsed, ntoread);
3589                 if (nread < 0) {
3590                         if (errno == EINTR)
3591                                 continue;
3592                         perror("ccdv: read");
3593                         return (-1);
3594                 } else if (nread == 0) {
3595                         break;
3596                 }
3597                 gNBufUsed += nread;
3598                 gBuf[gNBufUsed] = '\0';
3599         }
3600         Wait();
3601         gDumpCmdArgs = (gExitStatus != 0);      /* print cmd when there are errors */
3602         return (0);
3603 }       /* SlurpAll */
3604
3605
3606
3607 static const char *
3608 Basename(const char *path)
3609 {
3610         const char *cp;
3611         cp = strrchr(path, '/');
3612         if (cp == NULL)
3613                 return (path);
3614         return (cp + 1);
3615 }       /* Basename */
3616
3617
3618
3619 static const char *
3620 Extension(const char *path)
3621 {
3622         const char *cp = path;
3623         cp = strrchr(path, '.');
3624         if (cp == NULL)
3625                 return ("");
3626         return (cp);
3627 }       /* Extension */
3628
3629
3630
3631 static void
3632 Usage(void)
3633 {
3634         fprintf(stderr, "Usage: ccdv /path/to/cc CFLAGS...\n\n");
3635         fprintf(stderr, "I wrote this to reduce the deluge Make output to make finding actual problems\n");
3636         fprintf(stderr, "easier.  It is intended to be invoked from Makefiles, like this.  Instead of:\n\n");
3637         fprintf(stderr, "\t.c.o:\n");
3638         fprintf(stderr, "\t\t$(CC) $(CFLAGS) $(DEFS) $(CPPFLAGS) $< -c\n");
3639         fprintf(stderr, "\nRewrite your rule so it looks like:\n\n");
3640         fprintf(stderr, "\t.c.o:\n");
3641         fprintf(stderr, "\t\t@ccdv $(CC) $(CFLAGS) $(DEFS) $(CPPFLAGS) $< -c\n\n");
3642         fprintf(stderr, "ccdv 1.1.0 is Free under the GNU Public License.  Enjoy!\n");
3643         fprintf(stderr, "  -- Mike Gleason, NcFTP Software <http://www.ncftp.com>\n");
3644         exit(96);
3645 }       /* Usage */
3646
3647
3648
3649 int
3650 main(int argc, char **argv)
3651 {
3652         int pipe1[2];
3653         int devnull;
3654         char emerg[256];
3655         int fd;
3656         int nread;
3657         int i;
3658         int cc = 0, pch = 0;
3659         const char *quote;
3660
3661         if (argc < 2)
3662                 Usage();
3663
3664         snprintf(gAction, sizeof(gAction), "Running %s", Basename(argv[1]));
3665         memset(gArgsStr, 0, sizeof(gArgsStr));
3666         for (i = 1; i < argc; i++) {
3667                 quote = (strchr(argv[i], ' ') != NULL) ? "\"" : "";
3668                 snprintf(gArgsStr + strlen(gArgsStr), sizeof(gArgsStr) - strlen(gArgsStr), "%s%s%s%s%s", (i == 1) ? "" : " ", quote, argv[i], quote, (i == (argc - 1)) ? "\n" : "");
3669                 if ((strcmp(argv[i], "-o") == 0) && ((i + 1) < argc)) {
3670                         if (strcasecmp(Extension(argv[i + 1]), ".o") != 0) {
3671                                 strcpy(gAction, "Linking");
3672                                 snprintf(gTarget, sizeof(gTarget), "%s", Basename(argv[i + 1]));
3673                         }
3674                 } else if (strchr("-+/", (int) argv[i][0]) != NULL) {
3675                         continue;
3676                 } else if (strncasecmp(Extension(argv[i]), ".c", 2) == 0) {
3677                         cc++;
3678                         snprintf(gTarget, sizeof(gTarget), "%s", Basename(argv[i]));
3679                 } else if ((strncasecmp(Extension(argv[i]), ".h", 2) == 0) && (cc == 0)) {
3680                         pch++;
3681                         snprintf(gTarget, sizeof(gTarget), "%s", Basename(argv[i]));
3682                 } else if ((i == 1) && (strcmp(Basename(argv[i]), "ar") == 0)) {
3683                         snprintf(gAr, sizeof(gAr), "%s", Basename(argv[i]));
3684                 } else if ((gArLibraryTarget[0] == '\0') && (strcasecmp(Extension(argv[i]), ".a") == 0)) {
3685                         snprintf(gArLibraryTarget, sizeof(gArLibraryTarget), "%s", Basename(argv[i]));
3686                 }
3687         }
3688         if ((gAr[0] != '\0') && (gArLibraryTarget[0] != '\0')) {
3689                 strcpy(gAction, "Creating library");
3690                 snprintf(gTarget, sizeof(gTarget), "%s", gArLibraryTarget);
3691         } else if (pch > 0) {
3692                 strcpy(gAction, "Precompiling");
3693         } else if (cc > 0) {
3694                 strcpy(gAction, "Compiling");
3695         }
3696
3697         if (pipe(pipe1) < 0) {
3698                 perror("ccdv: pipe");
3699                 exit(97);
3700         }
3701
3702         (void) close(0);
3703         devnull = open("/dev/null", O_RDWR, 00666);
3704         if ((devnull != 0) && (dup2(devnull, 0) == 0))
3705                 close(devnull);
3706
3707         gCCPID = (int) fork();
3708         if (gCCPID < 0) {
3709                 (void) close(pipe1[0]);
3710                 (void) close(pipe1[1]);
3711                 perror("ccdv: fork");
3712                 exit(98);
3713         } else if (gCCPID == 0) {
3714                 /* Child */
3715                 (void) close(pipe1[0]);         /* close read end */
3716                 if (pipe1[1] != 1) {            /* use write end on stdout */
3717                         (void) dup2(pipe1[1], 1);
3718                         (void) close(pipe1[1]);
3719                 }
3720                 (void) dup2(1, 2);              /* use write end on stderr */
3721                 execvp(argv[1], argv + 1);
3722                 perror(argv[1]);
3723                 exit(99);
3724         }
3725
3726         /* parent */
3727         (void) close(pipe1[1]);         /* close write end */
3728         fd = pipe1[0];                  /* use read end */
3729
3730         gColumns = (getenv("COLUMNS") != NULL) ? atoi(getenv("COLUMNS")) : 80;
3731         gANSIEscapes = (getenv("TERM") != NULL) && (strstr(TERMS, getenv("TERM")) != NULL);
3732         gBuf = (char *) malloc(TEXT_BLOCK_SIZE);
3733         if (gBuf == NULL) 
3734                 goto panic;
3735         gNBufUsed = 0;
3736         gNBufAllocated = TEXT_BLOCK_SIZE;
3737         if (strlen(gArgsStr) < (gNBufAllocated - 1)) {
3738                 strcpy(gBuf, gArgsStr);
3739                 gNBufUsed = strlen(gArgsStr);
3740         }
3741
3742         if (isatty(1)) {
3743                 if (SlurpProgress(fd) < 0)
3744                         goto panic;
3745         } else {
3746                 if (SlurpAll(fd) < 0)
3747                         goto panic;
3748         }
3749         DumpFormattedOutput();
3750         exit(gExitStatus);
3751
3752 panic:
3753         gDumpCmdArgs = 1;       /* print cmd when there are errors */
3754         DumpFormattedOutput();
3755         while ((nread = read(fd, emerg, (size_t) sizeof(emerg))) > 0)
3756                 (void) write(2, emerg, (size_t) nread);
3757         Wait();
3758         exit(gExitStatus);
3759 }       /* main */
3760 /* eof ccdv.c */
3761 EOF
3762         changequote([, ])dnl
3763         ${CC-cc} $DEFS $CPPFLAGS $CFLAGS "ccdv.c" -o "ccdv" >/dev/null 2>&1
3764         /bin/rm -f ccdv.c ccdv.o ccdv.c.gz.uu ccdv.c.gz
3765         strip ./ccdv >/dev/null 2>&1
3766         ./ccdv >/dev/null 2>&1
3767         if test $? -eq 96 ; then
3768                 CCDV="./ccdv"
3769         else
3770                 /bin/rm -f ccdv
3771         fi
3772 fi
3773 if test "x$CCDV" != x ; then
3774         wi_RESOLVE_PATH([$CCDV], [CCDV])
3775         wi_cv_path_ccdv="$CCDV"
3776         CCDV="@$CCDV "  # trailing space needed
3777 else
3778         wi_cv_path_ccdv=""
3779 fi
3780 ])
3781 if test "$wi_used_cache_path_ccdv" = yes ; then
3782         CCDV="$wi_cv_path_ccdv"
3783         if test "x$CCDV" != x ; then
3784                 CCDV="@$CCDV "  # trailing space needed
3785         fi
3786 fi
3787 AC_SUBST(CCDV)
3788 fi
3789 ])
3790 dnl
3791 dnl
3792 dnl
3793 dnl
3794 AC_DEFUN([wi_HEADER_CURSES], [
3795 AC_MSG_CHECKING([for curses library headers])
3796 if test "$wi_cv_ncurses" != "no" ; then
3797         AC_CHECK_HEADERS(ncurses.h curses.h termios.h termio.h sgtty.h sys/ioctl.h)
3798 else
3799         AC_CHECK_HEADERS(curses.h termios.h termio.h sgtty.h sys/ioctl.h)
3800 fi
3801 dnl needed for Solaris 7
3802 if test "$ac_cv_header_curses_h" = no ; then
3803         if test -f /usr/include/curses.h ; then
3804                 AC_DEFINE(HAVE_CURSES_H)
3805                 ac_cv_header_curses_h=yes
3806         fi
3807 fi
3808 ])
3809 dnl
3810 dnl
3811 dnl
3812 dnl
3813 AH_TEMPLATE([HAVE_LIBCURSES], [define if linking against libcurses])
3814 AH_TEMPLATE([HAVE_LIBNCURSES], [define if linking against libncurses])
3815 AC_DEFUN([wi_LIB_CURSES], [
3816 wi_HEADER_CURSES
3817 AC_MSG_CHECKING([for curses library])
3818
3819 wi_cv_lib_curses=no
3820 wi_cv_lib_curses_result=no
3821 ac_save_LIBS="$LIBS"
3822 for LIBCURSES in "-lncurses" "-lcurses" "-lcurses -ltermcap" "-ltermcap -lcurses"
3823 do
3824         if test "x$LIBCURSES-$wi_cv_ncurses" = "x-lncurses-no" ; then
3825                 # This should never work
3826                 LIBCURSES="-lkdfjkdjfs"
3827         fi
3828         LIBS="$ac_save_LIBS $LIBCURSES"
3829         AC_TRY_RUN([
3830         /* program */
3831 #include <stdio.h>
3832 #include <stdlib.h>
3833
3834 #ifdef HAVE_NCURSES_H
3835 #       include <ncurses.h>
3836 #else
3837 #       include <curses.h>
3838 #endif
3839
3840  
3841 main(int argc, char **argv)
3842 {
3843         /* Note:  don't actually call curses, since it may block;
3844          * We just want to see if it (dynamic) linked in okay.
3845          */
3846         if (argc == 4)
3847                 initscr();
3848         exit(0);
3849 }
3850 ],[
3851         # action if true
3852         wi_cv_lib_curses=yes
3853         wi_cv_lib_curses_result="yes"
3854 ],[
3855         # action if false
3856         wi_cv_lib_curses=no
3857 ],[
3858         # action if cross compiling
3859         wi_cv_lib_curses=no
3860 ])
3861
3862         if test "$wi_cv_lib_curses" = yes ; then break ; fi
3863 done
3864
3865 # restore LIBS
3866 LIBS="$ac_save_LIBS"
3867
3868 if test "$wi_cv_lib_curses_result" != "no" ; then
3869         case "$LIBCURSES" in
3870                 "-lncurses")
3871                         AC_DEFINE(HAVE_LIBNCURSES)
3872                         ;;
3873                 "-lcurses")
3874                         AC_DEFINE(HAVE_LIBCURSES)
3875                         ;;
3876                 "-lcurses -ltermcap")
3877                         AC_DEFINE(HAVE_LIBCURSES)
3878                         ;;
3879                 "-ltermcap -lcurses")
3880                         AC_DEFINE(HAVE_LIBCURSES)
3881                         ;;
3882         esac
3883 else
3884         LIBCURSES=''
3885 fi
3886
3887 AC_SUBST(LIBCURSES)
3888 AC_MSG_RESULT([$wi_cv_lib_curses_result])
3889 ])
3890 dnl
3891 dnl
3892 dnl
3893 dnl
3894 AH_TEMPLATE([waddstr_str_t], [string parameter to waddstr])
3895 AH_TEMPLATE([WADDSTR_TYPE_ARG1_CONST], [define if first parameter to waddstr is const char *])
3896 AC_DEFUN([wi_CURSES_FUNC_PARAM_TYPES], [
3897 AC_REQUIRE([AC_PROG_CPP])
3898 AC_REQUIRE([wi_PATH_PERL])
3899 AC_REQUIRE([wi_PATH_MKTEMP])
3900 wi_PREREQ_UNISTD_H([$0])
3901 AC_CACHE_CHECK([string parameter to waddstr], [wi_cv_waddstr_str_t], [
3902 used_cache_for_wi_curses_fpt="no"
3903 wi_CREATE_AC_TMPDIR([
3904 wi_CREATE_PRPP_SCRIPT([$wi_tmpdir/prpp.pl])
3905
3906 changequote({{, }})dnl
3907 cat << 'EOF' > "$wi_tmpdir/curses.c"
3908 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
3909 #       define _ALL_SOURCE 1
3910 #endif
3911 #include <confdefs.h>
3912 #ifdef HAVE_UNISTD_H
3913 #       include <unistd.h>
3914 #endif
3915 #include <sys/types.h>
3916 #include <stdio.h>
3917 #include <string.h>
3918 #include <stdlib.h>
3919
3920 #ifdef HAVE_NCURSES_H
3921 #       include <ncurses.h>
3922 #else
3923 #       include <curses.h>
3924 #endif
3925
3926 main()
3927 {
3928         exit(0);
3929 }
3930 EOF
3931
3932 cat << 'EOF' > "$wi_tmpdir/sed2.sh"
3933 #!/bin/sh
3934
3935 if [ {{$}}# -eq 0 ] ; then exit 1 ; fi
3936 x="{{$}}1"
3937
3938 sed -n 's/extern//;s/static//;
3939                 /[\ \*]'"$x"'\ *(/{
3940                         s/^.*'"$x"'\ *(/(/
3941                         s/)\ *[;,].*$/)/
3942                         /const char/{
3943                                 c\
3944 const char *
3945                         }
3946                         /char/{
3947                                 c\
3948 char *
3949                         }
3950                         /const/{
3951                                 c\
3952 const void
3953                         }
3954                         q
3955 }'
3956 EOF
3957 chmod 755 "$wi_tmpdir/sed2.sh"
3958
3959 $CPP "-I${srcdir-.}" "$wi_tmpdir/curses.c" > "$wi_tmpdir/curses.i"
3960 if [ -s "$wi_tmpdir/curses.i" ] ; then
3961         "$PERL" "$wi_tmpdir/prpp.pl" < "$wi_tmpdir/curses.i" > "$wi_tmpdir/protos.h"
3962 fi
3963 if [ -f "$wi_tmpdir/protos.h" ] ; then
3964         #
3965         # Check what type waddstr() expects for the string parameter
3966         #
3967         x="waddstr"
3968         wi_cv_waddstr_str_t=`/bin/sh "$wi_tmpdir/sed2.sh" "$x" < "$wi_tmpdir/protos.h"`
3969 fi
3970 if [ "x$wi_cv_waddstr_str_t" = "x" ] ; then
3971         wi_cv_waddstr_str_t="const char *"
3972 fi
3973 changequote([, ])dnl
3974 ])
3975 ])
3976 dnl if test "x$used_cache_for_wi_curses_fpt" = "xno" ; then
3977 dnl     AC_MSG_CHECKING([string parameter to waddstr])
3978 dnl     AC_MSG_RESULT([$wi_cv_waddstr_str_t])
3979 dnl else
3980 dnl     AC_CACHE_CHECK([string parameter to waddstr],[wi_cv_waddstr_str_t],[:])
3981 dnl fi
3982 unset used_cache_for_wi_curses_fpt
3983 AC_DEFINE_UNQUOTED(waddstr_str_t, $wi_cv_waddstr_str_t)
3984 if test "$wi_cv_waddstr_str_t" = "const char *" ; then
3985         AC_DEFINE(WADDSTR_TYPE_ARG1_CONST)
3986 fi
3987 ])
3988 dnl
3989 dnl
3990 dnl
3991 dnl
3992 AH_TEMPLATE([HAVE_BEEP], [define if curses library has beep() functionality])
3993 AH_TEMPLATE([HAVE__MAXX], [define if curses structure has maxx or _maxx field])
3994 AH_TEMPLATE([HAVE_GETCURX], [define if curses library has getcurx() functionality])
3995 AH_TEMPLATE([HAVE_GETYX], [define if curses library has getyx() functionality])
3996 AH_TEMPLATE([HAVE_GETMAXX], [define if curses library has getmaxx() functionality])
3997 AH_TEMPLATE([HAVE_GETMAXYX], [define if curses library has getmaxyx() functionality])
3998 AH_TEMPLATE([HAVE_GETBEGX], [define if curses library has getbegx() functionality])
3999 AH_TEMPLATE([HAVE_GETBEGYX], [define if curses library has getbegyx() functionality])
4000 AH_TEMPLATE([HAVE_TOUCHWIN], [define if curses library has touchwin() functionality])
4001 AC_DEFUN([wi_CURSES_FEATURES], [
4002 if test "$wi_cv_lib_curses" = "yes" ; then
4003 wi_PREREQ_UNISTD_H([$0])
4004         # Then $LIBCURSES is a list of curses and support libraries.
4005         ac_save_LIBS="$LIBS";
4006         LIBS="$LIBS $LIBCURSES";
4007
4008 wi_CURSES_FUNC_PARAM_TYPES
4009
4010         # maxx or _maxx
4011         AC_MSG_CHECKING([whether curses structure has maxx or _maxx field])
4012         AC_TRY_COMPILE([
4013         /* includes */
4014 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
4015 #       define _ALL_SOURCE 1
4016 #endif
4017 #ifdef HAVE_UNISTD_H
4018 #       include <unistd.h>
4019 #endif
4020 #include <sys/types.h>
4021 #include <stdio.h>
4022 #include <string.h>
4023 #include <stdlib.h>
4024
4025 #ifdef HAVE_NCURSES_H
4026 #       include <ncurses.h>
4027 #else
4028 #       include <curses.h>
4029 #endif
4030 ],[
4031                 WINDOW *w;
4032         
4033                 w = newwin(10, 10, 1, 1);
4034                 w->maxx = 0;
4035 ],[
4036 AC_MSG_RESULT([maxx])
4037 ],[
4038 AC_DEFINE(HAVE__MAXX)
4039 AC_MSG_RESULT([_maxx])
4040 ])
4041
4042         if test "${SYS-hpux}" = hpux ; then
4043         AC_CHECK_FUNCS(__getcurx __getcury __getmaxx __getmaxy __getbegx __getbegy)
4044         fi
4045
4046         # getcurx
4047         AC_MSG_CHECKING([for getcurx() functionality in curses library])
4048         AC_TRY_LINK([
4049         /* includes */
4050 #ifdef HAVE_UNISTD_H
4051 #       include <unistd.h>
4052 #endif
4053 #include <sys/types.h>
4054 #include <stdio.h>
4055 #include <string.h>
4056 #include <stdlib.h>
4057
4058 #ifdef HAVE_NCURSES_H
4059 #       include <ncurses.h>
4060 #else
4061 #       include <curses.h>
4062 #endif
4063
4064 ],[
4065         /* function-body */
4066         WINDOW *junk = 0;
4067         int mx = 0;
4068
4069         mx = getcurx(junk);
4070         exit(0);
4071 ],[
4072         AC_DEFINE(HAVE_GETCURX)
4073         AC_MSG_RESULT([yes])
4074 ],[
4075         AC_MSG_RESULT([no])
4076 ])
4077
4078         # getyx
4079         AC_MSG_CHECKING([for getyx() functionality in curses library])
4080         AC_TRY_LINK([
4081         /* includes */
4082 #ifdef HAVE_UNISTD_H
4083 #       include <unistd.h>
4084 #endif
4085 #include <sys/types.h>
4086 #include <stdio.h>
4087 #include <string.h>
4088 #include <stdlib.h>
4089
4090 #ifdef HAVE_NCURSES_H
4091 #       include <ncurses.h>
4092 #else
4093 #       include <curses.h>
4094 #endif
4095
4096 ],[
4097         /* function-body */
4098         WINDOW *junk = 0;
4099         int mx = 0, my = 0;
4100
4101         getyx(junk, my, mx);
4102         exit(0);
4103 ],[
4104         AC_DEFINE(HAVE_GETYX)
4105         AC_MSG_RESULT([yes])
4106 ],[
4107         AC_MSG_RESULT([no])
4108 ])
4109
4110         # getmaxx
4111         AC_MSG_CHECKING([for getmaxx() functionality in curses library])
4112         AC_TRY_LINK([
4113         /* includes */
4114 #ifdef HAVE_UNISTD_H
4115 #       include <unistd.h>
4116 #endif
4117 #include <sys/types.h>
4118 #include <stdio.h>
4119 #include <string.h>
4120 #include <stdlib.h>
4121
4122 #ifdef HAVE_NCURSES_H
4123 #       include <ncurses.h>
4124 #else
4125 #       include <curses.h>
4126 #endif
4127 ],[
4128         /* function-body */
4129         WINDOW *junk = 0;
4130         int mx = 0;
4131
4132         mx = getmaxx(junk);
4133         exit(0);
4134 ],[
4135         AC_DEFINE(HAVE_GETMAXX)
4136         AC_MSG_RESULT([yes])
4137 ],[
4138         AC_MSG_RESULT([no])
4139 ])
4140
4141         # getmaxyx
4142         AC_MSG_CHECKING([for getmaxyx() functionality in curses library])
4143         AC_TRY_LINK([
4144         /* includes */
4145 #ifdef HAVE_UNISTD_H
4146 #       include <unistd.h>
4147 #endif
4148 #include <sys/types.h>
4149 #include <stdio.h>
4150 #include <string.h>
4151 #include <stdlib.h>
4152
4153 #ifdef HAVE_NCURSES_H
4154 #       include <ncurses.h>
4155 #else
4156 #       include <curses.h>
4157 #endif
4158 ],[
4159         /* function-body */
4160         WINDOW *junk = 0;
4161         int mx = 0, my = 0;
4162
4163         getmaxyx(junk, my, mx);
4164         exit(my < 0 ? my : 0);
4165 ],[
4166         AC_DEFINE(HAVE_GETMAXYX)
4167         AC_MSG_RESULT([yes])
4168 ],[
4169         AC_MSG_RESULT([no])
4170 ])
4171
4172         # getbegx
4173         AC_MSG_CHECKING([for getbegx() functionality in curses library])
4174         AC_TRY_LINK([
4175         /* includes */
4176 #ifdef HAVE_UNISTD_H
4177 #       include <unistd.h>
4178 #endif
4179 #include <sys/types.h>
4180 #include <stdio.h>
4181 #include <string.h>
4182 #include <stdlib.h>
4183
4184 #ifdef HAVE_NCURSES_H
4185 #       include <ncurses.h>
4186 #else
4187 #       include <curses.h>
4188 #endif
4189
4190 ],[
4191         /* function-body */
4192         WINDOW *junk = 0;
4193         int mx = 0;
4194
4195         mx = getbegx(junk);
4196         exit(0);
4197 ],[
4198         AC_DEFINE(HAVE_GETBEGX)
4199         AC_MSG_RESULT([yes])
4200 ],[
4201         AC_MSG_RESULT([no])
4202 ])
4203
4204         # getbegyx
4205         AC_MSG_CHECKING([for getbegyx() functionality in curses library])
4206         AC_TRY_LINK([
4207         /* includes */
4208 #ifdef HAVE_UNISTD_H
4209 #       include <unistd.h>
4210 #endif
4211 #include <sys/types.h>
4212 #include <stdio.h>
4213 #include <string.h>
4214 #include <stdlib.h>
4215
4216 #ifdef HAVE_NCURSES_H
4217 #       include <ncurses.h>
4218 #else
4219 #       include <curses.h>
4220 #endif
4221 ],[
4222         /* function-body */
4223         WINDOW *junk = 0;
4224         int mx = 0, my = 0;
4225
4226         getbegyx(junk, my, mx);
4227         exit(my < 0 ? my : 0);
4228 ],[
4229         AC_DEFINE(HAVE_GETBEGYX)
4230         AC_MSG_RESULT([yes])
4231 ],[
4232         AC_MSG_RESULT([no])
4233 ])
4234
4235         # touchwin
4236         AC_MSG_CHECKING([for touchwin() functionality in curses library])
4237         AC_TRY_LINK([
4238         /* includes */
4239 #ifdef HAVE_UNISTD_H
4240 #       include <unistd.h>
4241 #endif
4242 #include <sys/types.h>
4243 #include <stdio.h>
4244 #include <string.h>
4245 #include <stdlib.h>
4246
4247 #ifdef HAVE_NCURSES_H
4248 #       include <ncurses.h>
4249 #else
4250 #       include <curses.h>
4251 #endif
4252 ],[
4253         /* function-body */
4254         WINDOW *junk = 0;
4255         touchwin(junk);
4256         exit(0);
4257 ],[
4258         AC_DEFINE(HAVE_TOUCHWIN)
4259         AC_MSG_RESULT([yes])
4260 ],[
4261         AC_MSG_RESULT([no])
4262 ])
4263
4264         # beep
4265         AC_MSG_CHECKING([for beep() functionality in curses library])
4266         AC_TRY_LINK([
4267         /* includes */
4268 #ifdef HAVE_UNISTD_H
4269 #       include <unistd.h>
4270 #endif
4271 #include <sys/types.h>
4272 #include <stdio.h>
4273 #include <string.h>
4274 #include <stdlib.h>
4275
4276 #ifdef HAVE_NCURSES_H
4277 #       include <ncurses.h>
4278 #else
4279 #       include <curses.h>
4280 #endif
4281 ],[
4282         /* function-body */
4283         beep();
4284         exit(getpid() & 1);
4285 ],[
4286         AC_DEFINE(HAVE_BEEP)
4287         AC_MSG_RESULT([yes])
4288 ],[
4289         AC_MSG_RESULT([no])
4290 ])
4291
4292         AC_CHECK_FUNCS(keypad nodelay curs_set doupdate wnoutrefresh)
4293
4294         LIBS="$ac_save_LIBS";
4295 fi
4296 ])
4297 dnl
4298 dnl
4299 dnl
4300 AC_DEFUN([wi_SHADOW_FUNCS], [
4301 AC_CHECK_FUNCS(md5_crypt md5crypt bcrypt getspnam crypt_set_format)
4302
4303 if test "$ac_cv_func_getspnam" = no ; then
4304         unset ac_cv_func_getspnam
4305         AC_CHECK_LIB(gen,getspnam)
4306         if test "$ac_cv_lib_gen_getspnam" = yes ; then
4307                 AC_CHECK_FUNCS(getspnam)
4308         fi
4309 elif test "$ac_cv_func_getspnam" = yes ; then
4310         # Special hack to be sure UnixWare 7.1 uses -lgen for getspnam.
4311         # The reason we do this is so that the binary can be used on
4312         # SCO 5.0.6 with the UDK compatibility libraries installed,
4313         # For some reason, on UW7.1 getspnam is in the standard library and
4314         # libgen, but on SCO/UDK it is only in libgen.
4315         #
4316         case "$OS" in
4317                 unixware2*)
4318                         ;;
4319                 unixware*)
4320                         AC_CHECK_LIB(gen,getspnam)
4321                         ;;
4322         esac
4323 fi
4324
4325 # AIX
4326 #
4327 case "$SYS" in
4328         "aix"|"")
4329                 AC_CHECK_FUNCS(getuserpw)
4330                 ;;
4331         *)
4332                 ;;
4333 esac
4334
4335 # C2: SCO Open Server 5; Digital UNIX
4336 AC_CHECK_FUNCS(set_auth_parameters bigcrypt)
4337
4338 # C2: Digital UNIX 3.2, 4.0; SCO Open Server 5; HP-UX 11
4339 AC_CHECK_FUNCS(getprpwnam)
4340
4341 # Digital UNIX 4.0
4342 AC_CHECK_FUNCS(getespwnam get_num_crypts get_crypt_name)
4343
4344 # Digital Unix 4.0
4345 AC_CHECK_FUNCS(dispcrypt)
4346
4347 # SunOS
4348 AC_CHECK_FUNCS(getpwanam)
4349 ])
4350 dnl
4351 dnl
4352 dnl
4353 AC_DEFUN([wi_SHADOW_HEADERS], [
4354 AC_CHECK_HEADERS(shadow.h crypt.h)
4355
4356 # AIX
4357 AC_CHECK_HEADERS(userpw.h)
4358
4359 # SunOS
4360 AC_CHECK_HEADERS(pwdadj.h)
4361
4362 # HP-UX
4363 #
4364 # Bug in header on these version 10 which cause is it not
4365 # to get detected.
4366 #
4367 wi_HEADER_HPSECURITY_H
4368
4369 # SCO Open Server, Digital UNIX
4370 AC_CHECK_HEADERS(sys/security.h sys/audit.h krb.h prot.h)
4371
4372 # Digital UNIX
4373 AC_CHECK_HEADERS(sys/secdefines.h)
4374
4375 # Digital UNIX
4376 wi_PR_PASSWD_FG_OLDCRYPT
4377 ])
4378 dnl
4379 dnl
4380 dnl
4381 AC_DEFUN([wi_SHADOW_LIBS], [
4382 check_for_libcrypt=yes
4383
4384 # AIX security library is libs.a
4385 AC_CHECK_LIB(s,getuserpw)
4386 if test "$ac_cv_lib_s" = yes ; then
4387         check_for_libcrypt=no
4388 elif test "$ac_cv_lib_s_getuserpw" = yes ; then
4389         check_for_libcrypt=no
4390 fi
4391
4392 # SCO OpenServer 5 stuff for shadow password
4393 AC_CHECK_LIB(x,nap)
4394 AC_CHECK_LIB(prot,getprpwnam)
4395
4396 # Digital UNIX
4397 AC_CHECK_LIB(security,endprpwent)
4398
4399 # HP-UX
4400 AC_CHECK_LIB(sec,getprpwnam)
4401
4402 if test "$ac_cv_lib_sec_getprpwnam" = no ; then
4403         # DYNIX/ptx
4404         AC_CHECK_LIB(sec,getspnam)
4405 fi
4406
4407 if test "$check_for_libcrypt" = yes ; then
4408         wi_LIB_CRYPT
4409 fi
4410 AC_CHECK_FUNCS(crypt)
4411 ])
4412 dnl
4413 dnl
4414 dnl
4415 AC_DEFUN([wi_OS_VAR], [
4416 #
4417 # Take note if the user is or is not exporting a CFLAGS env var.
4418 #
4419 wi_orig_CFLAGS="$CFLAGS"
4420 wi_CFLAGS_TO_ADD_LATER=""
4421 changequote(!@, @!)dnl
4422 if [ -x "$HOME/bin/OS" ] ; then
4423         HOME_OS=`$HOME/bin/OS`
4424         HOME_OS="$HOME/$HOME_OS"
4425 fi
4426 host=`uname -n 2>/dev/null | tr '[A-Z]' '[a-z]'`
4427 os=`uname -s 2>/dev/null | tr '[A-Z]' '[a-z]'`
4428 if [ "$os" = "TvoPT" ] ; then os="sunos" ; fi
4429 dnl work around inability to use $1
4430 os_v=`uname -v 2>/dev/null | sed 's/^[^0-9.]*//;s/[^0-9.].*$//;' | awk '-F[-/: ]' '{n = 1; print $n; }'`
4431 os_r=`uname -r 2>/dev/null | sed 's/^[^0-9.]*//;s/[^0-9.].*$//;' | awk '-F[-/: ]' '{n = 1; print $n; }'`
4432 os_r1=`echo "${os_r}" | cut -c1`
4433 arch=`uname -m 2>/dev/null | tr '[A-Z]' '[a-z]'`
4434 archp=`uname -p 2>/dev/null | tr '[A-Z]' '[a-z]'`
4435 OS=''
4436 SYS=''
4437 NDEFS=''
4438
4439 # Special case a few systems where if your CFLAGS appear
4440 # to want to generate for 32 bit, use that mode rather
4441 # than 64 bit.
4442 #
4443 case "$os,$CFLAGS" in
4444         irix64,*-n32*)
4445                 os=irix
4446                 # then go to regular "irix" instead of "irix64" below.
4447                 ;;
4448 esac
4449
4450 case "$os" in
4451         osf1)
4452                 case "$os_r" in
4453                         3*|4*)
4454                                 OS="digitalunix${os_r}-$arch"
4455                                 SYS=digitalunix
4456                                 NDEFS="$NDEFS -DDIGITAL_UNIX=$os_r1"
4457                                 ;;
4458                         *)
4459                                 OS="tru64unix${os_r}-$arch"
4460                                 SYS=tru64unix
4461                                 NDEFS="$NDEFS -DTRU64UNIX=$os_r1"
4462                                 ;;
4463                 esac
4464                 ;;
4465         aix)
4466                 os_lev=`/usr/bin/oslevel 2>/dev/null`
4467                 if [ "$os_lev" = "" ] ; then
4468                         if [ "$os_r" = "" ] ; then os_r=0 ; fi
4469                         OS="aix${os_v}.${os_r}"
4470                         os_int=`expr $os_v$os_r '*' 10`
4471                 else
4472                         os_v=`echo "$os_lev" | cut -d. -f1-3`
4473                         os_v1=`echo "$os_v" | cut -d. -f1`
4474                         os_v2=`echo "$os_v" | cut -d. -f2`
4475                         if [ "$os_v2" = "" ] ; then os_v2=0 ; fi
4476                         os_v3=`echo "$os_v" | cut -d. -f3`
4477                         if [ "$os_v3" = "" ] ; then os_v3=0 ; fi
4478                         os_int=`expr "$os_v1" '*' 100 + "$os_v2" '*' 10 + "$os_v3"`
4479                         OS="aix${os_v}"
4480                 fi
4481                 SYS=aix
4482                 NDEFS="$NDEFS -DAIX=${os_int}"
4483                 ;;
4484         irix)
4485                 OS="irix${os_r}"
4486                 SYS=irix
4487                 NDEFS="$NDEFS -DIRIX=$os_r1"
4488                 ;;
4489         irix64)
4490                 OS="irix64_${os_r}"
4491                 SYS=irix64
4492                 NDEFS="$NDEFS -DIRIX=$os_r1 -DIRIX64=$os_r1"
4493                 ;;
4494         hp-ux)
4495                 os_r=`echo "${os_r}" | cut -d. -f2-`
4496                 os_r1=`echo "$os_r" | cut -d. -f1`
4497                 os_r2=`echo "${os_r}" | cut -d. -f2`
4498                 os_int=`expr "$os_r1" '*' 100 + "$os_r2"`
4499                 OS="hpux${os_r}"
4500                 SYS=hpux
4501                 NDEFS="$NDEFS -DHPUX=$os_int"
4502                 ;;
4503         freebsd)
4504                 OS="freebsd${os_r}-$arch"
4505                 os_r1=`echo "$os_r" | cut -d. -f1`
4506                 os_r2=`echo "$os_r" | cut -d. -f2`
4507                 if [ "$os_r2" = "" ] ; then os_r2=0 ; fi
4508                 os_r3=`echo "$os_r" | cut -d. -f3`
4509                 if [ "$os_r3" = "" ] ; then os_r3=0 ; fi
4510                 os_int=`expr "$os_r1" '*' 100 + "$os_r2" '*' 10 + "$os_r3"`
4511                 SYS=freebsd
4512                 NDEFS="$NDEFS -DFREEBSD=$os_int"
4513                 ;;
4514         netbsd)
4515                 OS="netbsd${os_r}-$arch"
4516                 os_r1=`echo "$os_r" | cut -d. -f1`
4517                 os_r2=`echo "$os_r" | cut -d. -f2`
4518                 if [ "$os_r2" = "" ] ; then os_r2=0 ; fi
4519                 os_r3=`echo "$os_r" | cut -d. -f3`
4520                 if [ "$os_r3" = "" ] ; then os_r3=0 ; fi
4521                 os_int=`expr "$os_r1" '*' 100 + "$os_r2" '*' 10 + "$os_r3"`
4522                 NDEFS="$NDEFS -DNETBSD=$os_int"
4523                 SYS=netbsd
4524                 ;;
4525         openbsd)
4526                 OS="openbsd${os_r}-$arch"
4527                 os_r1=`echo "$os_r" | cut -d. -f1`
4528                 os_r2=`echo "$os_r" | cut -d. -f2`
4529                 if [ "$os_r2" = "" ] ; then os_r2=0 ; fi
4530                 os_r3=`echo "$os_r" | cut -d. -f3`
4531                 if [ "$os_r3" = "" ] ; then os_r3=0 ; fi
4532                 os_int=`expr "$os_r1" '*' 100 + "$os_r2" '*' 10 + "$os_r3"`
4533                 SYS=openbsd
4534                 NDEFS="$NDEFS -DOPENBSD=$os_int"
4535                 ;;
4536         sco*)
4537                 OS=scosv
4538                 SYS=sco
4539                 os_v1=`echo "$os_v" | cut -d. -f1`
4540                 case "$os_v1" in
4541                         [1-9])
4542                                 os_v2=`echo "$os_v" | cut -d. -f2`
4543                                 if [ "$os_v2" = "" ] ; then os_v2=0 ; fi
4544                                 os_v3=`echo "$os_v" | cut -d. -f3`
4545                                 if [ "$os_v3" = "" ] ; then os_v3=0 ; fi
4546                                 os_int=`expr "$os_v1" '*' 100 + "$os_v2" '*' 10 + "$os_v3"`
4547                                 NDEFS="$NDEFS -DSCO=$os_int"
4548                                 ;;
4549                         *)
4550                                 NDEFS="$NDEFS -DSCO=1"
4551                                 ;;
4552                 esac
4553                 ;;
4554         dynix*)
4555                 OS="dynixptx${os_v}"
4556                 SYS=dynixptx
4557                 os_v1=`echo "$os_v" | cut -d. -f1`
4558                 os_v2=`echo "$os_v" | cut -d. -f2`
4559                 os_v3=`echo "$os_v" | cut -d. -f3`
4560                 if [ "$os_v3" = "" ] ; then os_v3=0 ; fi
4561                 os_int=`expr "$os_v1" '*' 100 + "$os_v2" '*' 10 + "$os_v3"`
4562                 NDEFS="$NDEFS -DDYNIX=$os_int"
4563                 ;;
4564         linux)
4565                 case "$arch" in
4566                         *86)
4567                                 arch=x86
4568                                 ;;
4569                 esac
4570
4571                 libc=""
4572                 os_r1=`echo "$os_r" | cut -d. -f1`
4573                 os_r2=`echo "$os_r" | cut -d. -f2`
4574                 os_r3=`echo "$os_r" | cut -d- -f1 | cut -d. -f3`
4575                 os_int=`expr "$os_r1" '*' 10000 + "$os_r2" '*' 1000 + "$os_r3"`
4576                 NDEFS="$NDEFS -DLINUX=$os_int"
4577
4578                 vertest="./vertest.$$"
4579                 /bin/rm -f "$vertest" "$vertest.c"
4580                 cat <<EOF > "$vertest.c"
4581 #include <stdio.h>
4582 #include <gnu/libc-version.h>
4583
4584 main()
4585 {
4586         const char *ver = gnu_get_libc_version();
4587         const char *rel = gnu_get_libc_release();
4588
4589         fprintf(stdout, "glibc%s\n", ver);
4590         exit(0);
4591 }
4592 EOF
4593                 echo $ac_n "checking version of C library""... $ac_c" 1>&6
4594                 echo "configure:: checking version of C library" >&5
4595                 ${CC-cc} $DEFS $CPPFLAGS $CFLAGS "$vertest.c" -o "$vertest" >/dev/null 2>&1
4596                 if [ -x "$vertest" ] ; then libc=`$vertest` ; fi
4597                 /bin/rm -f "$vertest" "$vertest.c"
4598
4599                 case "$libc" in
4600                         glibc*)
4601                                 echo "$libc" 1>&6
4602                                 glibc_r=`echo "$libc" | sed 's/glibc//'`
4603                                 glibc_r1=`echo "$glibc_r" | cut -d. -f1`
4604                                 glibc_r2=`echo "$glibc_r" | cut -d. -f2`
4605                                 glibc_r3=`echo "$glibc_r" | cut -d- -f1 | cut -d. -f3`
4606                                 glibc_int=`expr "$glibc_r1" '*' 10000 + "$glibc_r2" '*' 1000 + "$glibc_r3"`
4607                                 NDEFS="$NDEFS -DLINUX_GLIBC=$glibc_int"
4608                                 libc="glibc${glibc_r1}.${glibc_r2}"
4609                                 OS="linux-$arch"
4610                                 ;;
4611                         *)
4612                                 if test -f /lib/libc-2.2.2.so ; then
4613                                         NDEFS="$NDEFS -DLINUX_GLIBC=22002"
4614                                         libc="glibc2.2"
4615                                         OS="linux-$arch"
4616                                 elif test -f /lib/libc-2.2.1.so ; then
4617                                         NDEFS="$NDEFS -DLINUX_GLIBC=22001"
4618                                         libc="glibc2.2"
4619                                         OS="linux-$arch"
4620                                 elif test -f /lib/libc-2.2.0.so ; then
4621                                         NDEFS="$NDEFS -DLINUX_GLIBC=22000"
4622                                         libc="glibc2.1"
4623                                         OS="linux-$arch"
4624                                 elif test -f /lib/libc-2.1.3.so ; then
4625                                         NDEFS="$NDEFS -DLINUX_GLIBC=21003"
4626                                         libc="glibc2.1"
4627                                         OS="linux-$arch"
4628                                 elif test -f /lib/libc-2.1.2.so ; then
4629                                         NDEFS="$NDEFS -DLINUX_GLIBC=21002"
4630                                         libc="glibc2.1"
4631                                         OS="linux-$arch"
4632                                 elif test -f /lib/libc-2.1.1.so ; then
4633                                         NDEFS="$NDEFS -DLINUX_GLIBC=21001"
4634                                         libc="glibc2.1"
4635                                         OS="linux-$arch"
4636                                 elif test -f /lib/libc.so.6 ; then
4637                                         NDEFS="$NDEFS -DLINUX_GLIBC=20000"
4638                                         libc="glibc2.0"
4639                                         OS="linux-$arch"
4640                                 elif test -f /lib/libc.so.6.1 ; then
4641                                         NDEFS="$NDEFS -DLINUX_GLIBC=20001"
4642                                         libc="glibc2.0"
4643                                         OS="linux-$arch"
4644                                 else
4645                                         NDEFS="$NDEFS -DLINUX_LIBC=5"
4646                                         libc="libc5"
4647                                         OS="linux-$arch"
4648                                 fi
4649                                 echo "$libc" 1>&6
4650                                 ;;
4651                 esac
4652                 SYS=linux
4653                 ;;
4654         bsd/os)
4655                 OS="bsdos${os_r}"
4656                 SYS=bsdos
4657                 NDEFS="$NDEFS -DBSDOS=$os_r1"
4658                 ;;
4659         ultrix)
4660                 OS="ultrix-$arch"
4661                 SYS=ultrix
4662                 NDEFS="$NDEFS -DULTRIX"
4663                 ;;
4664         unixware)
4665                 OS="unixware${os_v}"
4666                 SYS=unixware
4667                 os_v1=`echo "$os_v" | cut -d. -f1`
4668                 case "$os_v1" in
4669                         [1-9])
4670                                 os_v2=`echo "$os_v" | cut -d. -f2`
4671                                 os_v3=`echo "$os_v" | cut -d. -f3`
4672                                 if [ "$os_v3" = "" ] ; then os_v3=0 ; fi
4673                                 os_int=`expr "$os_v1" '*' 100 + "$os_v2" '*' 10 + "$os_v3"`
4674                                 NDEFS="$NDEFS -DUNIXWARE=$os_int"
4675                                 ;;
4676                         *)
4677                                 NDEFS="$NDEFS -DUNIXWARE=1"
4678                                 ;;
4679                 esac
4680                 ;;
4681         openunix)
4682                 OS="openunix${os_v}"
4683                 SYS=openunix
4684                 os_v1=`echo "$os_v" | cut -d. -f1`
4685                 os_v2=`echo "$os_v" | cut -d. -f2`
4686                 os_v3=`echo "$os_v" | cut -d. -f3`
4687                 if [ "$os_v3" = "" ] ; then os_v3=0 ; fi
4688                 os_int=`expr "$os_v1" '*' 100 + "$os_v2" '*' 10 + "$os_v3"`
4689                 NDEFS="$NDEFS -DOPENUNIX=$os_int -DUNIXWARE=$os_int"
4690                 ;;
4691         macos*|darwin|rhapsody)
4692                 OS="macosx"
4693                 SYS="macosx"
4694                 os_v=`perl -e '{open(F, "< /System/Library/CoreServices/SystemVersion.plist") or exit(2); my ($doc) = ""; my ($line); while (defined($line = <F>)) { $doc .= $line; } close(F); $doc =~ s/\s+//gs; if ($doc =~ /<key>ProductVersion<\/key><string>([^<]+)<\/string>/) { print $1, "\n"; exit(0); } exit(1); }' 2>/dev/null`
4695                 if [ "$os_v" = "" ] && [ -x "$HOME/bin/macosver" ] ; then
4696                         os_v=`"$HOME/bin/macosver" 2>/dev/null`
4697                 fi
4698                 if [ "$os_v" = "" ] ; then
4699                         cat > "$HOME/macosver.c" <<EOF
4700 /*
4701 <?xml version="1.0" encoding="UTF-8"?>
4702 <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
4703 <plist version="0.9">
4704 <dict>
4705         <key>ProductBuildVersion</key>
4706         <string>5S66</string>
4707         <key>ProductName</key>
4708         <string>Mac OS X</string>
4709         <key>ProductVersion</key>
4710         <string>10.1.5</string>
4711 </dict>
4712 </plist>
4713 */
4714
4715 #include <stdio.h>
4716 #include <string.h>
4717 #include <stdlib.h>
4718 #include <ctype.h>
4719
4720 main()
4721 {
4722         char line[256], *cp, *cp2; 
4723         FILE *fp;
4724
4725         fp = fopen("/System/Library/CoreServices/SystemVersion.plist", "r");
4726
4727         if (fp != NULL) {
4728                 memset(line, 0, sizeof(line));
4729                 while (fgets(line, sizeof(line) - 1, fp) != NULL) {
4730                         cp = strstr(line, "<key>ProductVersion</key>");
4731                         if (cp != NULL) {
4732                                 memset(line, 0, sizeof(line));
4733                                 if (fgets(line, sizeof(line) - 2, fp) != NULL) {
4734                                         for (cp = line; ((*cp != '\0') && (! isdigit(*cp))); ) cp++;
4735                                         for (cp2 = cp; ((*cp2 != '\0') && (! isspace(*cp2)) && (*cp2 != '<') && (*cp2 != '>')); ) cp2++;
4736                                         cp2[0] = '\0';
4737                                         fclose(fp);
4738                                         fprintf(stdout, "%s\n", cp);
4739                                         exit(0);
4740                                 }
4741                         }
4742                 }
4743         }
4744         fclose(fp);
4745         exit(1);
4746 }
4747 EOF
4748                         ${CC-cc} "$HOME/macosver.c" -o "$HOME/macosver" > /dev/null 2>&1
4749                         os_v=`"$HOME/macosver" 2>/dev/null`
4750                         /bin/mv "$HOME/macosver" "$HOME/bin/macosver" 2>/dev/null
4751                         /bin/rm -f "$HOME/macosver.c" "$HOME/macosver"
4752                 fi
4753                 if [ "$os_v" != "" ] ; then
4754                         OS="macosx${os_v}"
4755                         os_v1=`echo "$os_v" | cut -d. -f1`
4756                         os_v2=`echo "$os_v" | cut -d. -f2`
4757                         os_v3=`echo "$os_v" | cut -d. -f3`
4758                         if [ "$os_v3" = "" ] ; then os_v3=0 ; fi
4759                         os_int=`expr "$os_v1" '*' 1000 + "$os_v2" '*' 100 + "$os_v3"`
4760                         NDEFS="$NDEFS -DMACOSX=$os_int"
4761                 else
4762                         NDEFS="$NDEFS -DMACOSX"
4763                 fi
4764                 ;;
4765         sunos)
4766                 if [ "$arch" = "" ] ; then arch="sparc" ; fi
4767                 if [ "$archp" = "" ] ; then archp="$arch" ; fi
4768                 case "$os_r" in
4769                         5.[789]*|5.1[0-9][0-9]*)
4770                                 os_r1=`echo "$os_r" | cut -d. -f2`
4771                                 os_r2=`echo "$os_r" | cut -d. -f3`
4772                                 if [ "$os_r2" = "" ] ; then os_r2=0 ; fi
4773                                 os_r3=`echo "$os_r" | cut -d. -f4`
4774                                 if [ "$os_r3" = "" ] ; then os_r3=0 ; fi
4775                                 os_int=`expr "$os_r1" '*' 100 + "$os_r2" '*' 10 + "$os_r3"`
4776                                 os_r=`echo "$os_r" | cut -c3-`
4777                                 OS="solaris${os_r}-$archp"
4778                                 NDEFS="$NDEFS -DSOLARIS=$os_int"
4779                                 SYS=solaris
4780                                 ;;
4781                         5.[023456]*|5.1)
4782                                 os_r=`echo "$os_r" | sed 's/^5/2/;'`
4783                                 os_r1=`echo "$os_r" | cut -d. -f1`
4784                                 os_r2=`echo "$os_r" | cut -d. -f2`
4785                                 if [ "$os_r2" = "" ] ; then os_r2=0 ; fi
4786                                 os_r3=`echo "$os_r" | cut -d. -f3`
4787                                 if [ "$os_r3" = "" ] ; then os_r3=0 ; fi
4788                                 os_int=`expr "$os_r1" '*' 100 + "$os_r2" '*' 10 + "$os_r3"`
4789                                 OS="solaris${os_r}-$archp"
4790                                 NDEFS="$NDEFS -DSOLARIS=$os_int"
4791                                 SYS=solaris
4792                                 ;;
4793                         4.*)
4794                                 OS="sunos${os_r}-sparc"
4795                                 NDEFS="$NDEFS -DSUNOS=\\\"$os_r\\\""
4796                                 SYS=sunos
4797                                 ;;
4798                         *)
4799                                 os_r1=`echo "$os_r" | cut -d. -f1`
4800                                 if [ "$os_r1" = "" ] ; then os_r1=0 ; fi
4801                                 os_r2=`echo "$os_r" | cut -d. -f2`
4802                                 if [ "$os_r2" = "" ] ; then os_r2=0 ; fi
4803                                 os_r3=`echo "$os_r" | cut -d. -f3`
4804                                 if [ "$os_r3" = "" ] ; then os_r3=0 ; fi
4805                                 os_int=`expr "$os_r1" '*' 100 + "$os_r2" '*' 10 + "$os_r3"`
4806                                 OS="solaris${os_r}-$archp"
4807                                 NDEFS="$NDEFS -DSOLARIS=$os_int"
4808                                 SYS=solaris
4809                                 ;;
4810                 esac
4811                 ;;
4812         *)
4813                 OS="$os"
4814                 SYS="$os"
4815
4816                 if grep Novell /usr/include/sys/types.h ; then
4817                         OS="unixware${os_v}"
4818                         SYS="unixware"
4819                 fi
4820                 ;;
4821 esac
4822
4823 if [ "x$wi_cv_OS" != "x" ] && [ "$wi_cv_OS" != "$OS" ] ; then
4824 changequote([, ])
4825         AC_MSG_ERROR([Your config.cache file is invalid.  It was created on $wi_cv_OS, but this machine is running $OS.  Remove the config.cache file if you wish to continue.])
4826 fi
4827 wi_cv_OS="$OS"
4828
4829 AC_SUBST(NDEFS)
4830 AC_SUBST(OS)
4831 AC_SUBST(host)
4832 AC_SUBST(SYS)
4833 AC_SUBST(HOME_OS)
4834 ])
4835 dnl
4836 dnl
4837 dnl
4838 AC_DEFUN([wi_SIZEOF_STRUCT_STAT], [
4839 AC_MSG_CHECKING(size of struct stat)
4840 wi_PREREQ_UNISTD_H([$0])
4841 AC_TRY_RUN([
4842         /* program */
4843 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
4844 #       define _ALL_SOURCE 1
4845 #endif
4846 #ifdef HAVE_UNISTD_H
4847 #       include <unistd.h>
4848 #endif
4849 #include <sys/types.h>
4850 #include <sys/stat.h>
4851 #include <stdio.h>
4852 #include <stdlib.h>
4853  
4854 main()
4855 {
4856         struct stat x;
4857         FILE *fp;
4858
4859         fp = fopen("conftest.out", "w");
4860         if (fp != NULL) {
4861                 fprintf(fp, "%u\n", (unsigned int) sizeof(x));
4862                 fclose(fp);
4863                 exit(0);        /* OK */
4864         }
4865         exit(1);                /* Not OK */
4866 }
4867 ],[
4868         # action if true
4869         x=`cat conftest.out`
4870         case "$x" in
4871 changequote(<<, >>)dnl
4872                 [0-9]*)
4873 changequote([, ])dnl
4874                         AC_DEFINE_UNQUOTED(SIZEOF_STRUCT_STAT, $x)
4875                         ac_cv_sizeof_struct_stat="$x"
4876                         ;;
4877                 *)
4878                         x="failed"
4879                         ;;
4880         esac
4881         /bin/rm -f conftest.out
4882 ],[
4883         # action if false
4884         x="failed";
4885         /bin/rm -f conftest.out
4886 ],[
4887         # action if cross compiling
4888         x="unknown";
4889         /bin/rm -f conftest.out
4890 ])
4891 AC_MSG_RESULT($x)
4892 ])
4893 dnl
4894 dnl
4895 dnl
4896 AC_DEFUN([wi_SIZEOF_STRUCT_STAT64], [
4897 AC_MSG_CHECKING(size of struct stat64)
4898 wi_PREREQ_UNISTD_H([$0])
4899 AC_TRY_RUN([
4900         /* program */
4901 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
4902 #       define _ALL_SOURCE 1
4903 #endif
4904 #ifdef HAVE_UNISTD_H
4905 #       include <unistd.h>
4906 #endif
4907 #include <sys/types.h>
4908 #include <sys/stat.h>
4909 #include <stdio.h>
4910 #include <stdlib.h>
4911  
4912 main()
4913 {
4914         struct stat64 x;
4915         FILE *fp;
4916
4917         fp = fopen("conftest.out", "w");
4918         if (fp != NULL) {
4919                 fprintf(fp, "%u\n", (unsigned int) sizeof(x));
4920                 fclose(fp);
4921                 exit(0);        /* OK */
4922         }
4923         exit(1);                /* Not OK */
4924 }
4925 ],[
4926         # action if true
4927         x=`cat conftest.out`
4928         case "$x" in
4929 changequote(<<, >>)dnl
4930                 [0-9]*)
4931 changequote([, ])dnl
4932                         AC_DEFINE_UNQUOTED(SIZEOF_STRUCT_STAT64, $x)
4933                         ac_cv_sizeof_struct_stat64="$x"
4934                         ;;
4935                 *)
4936                         x="failed"
4937                         ;;
4938         esac
4939         /bin/rm -f conftest.out
4940 ],[
4941         # action if false
4942         x="failed";
4943         /bin/rm -f conftest.out
4944 ],[
4945         # action if cross compiling
4946         x="unknown";
4947         /bin/rm -f conftest.out
4948 ])
4949 AC_MSG_RESULT($x)
4950 ])