view configure.in @ 17:76d91e545ea8 default tip

addrsbr and dtimep fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 24 Nov 2014 14:49:25 +0900
parents bce86c4163a3
children
line wrap: on
line source

dnl ====================================================================
dnl Process this file with autoconf to produce a configure script.
dnl ====================================================================
AC_INIT(h/mh.h)

dnl default values
etcdir='${exec_prefix}/lib/mh'
slibdir=
manuals=standard
pagerpath=
SUN40=
SOLARIS=
SYS5=
SVR4=
BSD41A=
BSD42=
BSD43=
BSD44=
sharedlib=off
slflags=
ranlib=on
pop=on
popdir=
popserver=off
bboards=off
bbdelivery=off
bbhome=
APOP=APOP
DPOP=
MPOP=
POP2=
RPOP=
POPSERVICE=
NNTP=NNTP
smtp='/smtp'
ATTVIBUG=
curses=
NCURSES=
READLINE=
SYS5DIR=
NDIR=
NOIOCTLH=
UNISTD=
SHADOW=
CONTENT_LENGTH=
ZONEINFO=
TZNAME=
V7=
ALTOS=
SIGEMT=
RENAME=
VSPRINTF=
SETEUID=
SETREUID=
NFS=
NORUSERPASS=
FILBUF_ADJ=
FILE__PTR=
FCNTL=
FLOCK=
LOCKF=
LIBLOCKFILE=
MAILLOCK=
WAITINT=
SOCKETS=
BIND=
POSIX=
NTOHLSWAP=
mailspool=
mailgroup=off
DBMPWD=
SETMG=
make_mhconfig=
debug=off
JAPAN=JAPAN

dnl (tricky) autoconf cannot change a default value of "$libexecdir".  :-<
for ac_arg
do
  case "$ac_arg" in
    -libexecdir | --libexecdir | --libexecdi | --libexecd \
      | --libexec | --libexe | --libex | --libe \
      | -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* \
      | --libexec=* | --libexe=* | --libex=* | --libe=*)
      etcdir=$libexecdir
      ;;
  esac
done

dnl (tricky) patch command cannot chmod. :-<
for ac_dir in $srcdir $srcdir/.. $srcdir/../..
do
  if test -f $ac_dir/install-sh
  then
    chmod +x $ac_dir/install-sh
    chmod +x $ac_dir/configure
    chmod +x $ac_dir/config.guess
    chmod +x $ac_dir/config.sub
    break
  fi
done

dnl ====================================================================
dnl Check optional features
dnl ====================================================================
AC_ARG_ENABLE(batchmode,
[  --enable-batchmode      run conf/mhconfig automatically],
 [if test "$enableval" = yes
  then
    batchmode=yes
  else
    batchmode=no
  fi], [batchmode=no])

AC_ARG_ENABLE(sharedlib,
[  --enable-sharedlib      make shared library (DEFAULT on some OS)],
 [if test "$enableval" = yes
  then
    use_sharedlib=yes
  else
    use_sharedlib=no
  fi], [use_sharedlib=default])

AC_ARG_ENABLE(smtp,
[  --enable-smtp           use SMTP (DEFAULT)],
 [if test "$enableval" = yes
  then
    smtp='/smtp'
  else
    smtp=
  fi])

AC_ARG_ENABLE(pop,
[  --enable-pop            POP support (DEFAULT)],
 [if test "$enableval" = yes
  then
    pop=on
  else
    pop=off
    popserver=off
    bboards=off
    bbhome=
    MPOP=
    APOP=
    RPOP=
    DPOP=
    POP2=
  fi])

AC_ARG_ENABLE(apop,
[  --enable-apop=AUTHFILE  APOP support (DEFAULT)],
 [case "$enableval" in
    no)
      APOP=
      ;;
    /*)
      APOP=APOP=\'\"$enableval\"\'
      pop=on
      ;;
    *)
      APOP=APOP
      pop=on
      ;;
    esac])

AC_ARG_ENABLE(rpop,
[  --enable-rpop           RPOP support],
 [if test "$enableval" = yes
  then
    RPOP=RPOP
    pop=on
  else
    RPOP=
  fi])

AC_ARG_ENABLE(dpop,
[  --enable-dpop           use DPOP],
 [if test "$enableval" = yes
  then
    pophome=`csh -c 'echo ~pop' 2> /dev/null`
    if test x"$pophome" != x
    then
      DPOP=DPOP
      pop=on
      popserver=on
    else
      AC_MSG_ERROR([At first, you must register a new user \"pop\".])
    fi
  else
    DPOP=
  fi])

AC_ARG_ENABLE(nntp,
[  --enable-nntp           NNTP support (DEFAULT)],
 [if test "$enableval" = yes
  then
    NNTP=NNTP
    bboards=off
    bbhome=
    MPOP=
  else
    NNTP=
  fi])

AC_ARG_ENABLE(bboards,
[  --enable-bboards        BBoards support],
 [if test "$enableval" = yes
  then
    bbhome=`csh -c 'echo ~bboards' 2> /dev/null`
    if test x"$bbhome" != x
    then
      pop=on
      bboards=pop
      MPOP=MPOP
      NNTP=
    else
      AC_MSG_ERROR([At first, you must register a new user \"bboards\".])
    fi
  else
    bboards=off
    bbhome=
    MPOP=
  fi])

AC_ARG_ENABLE(popserver,
[  --enable-popserver      install POP server],
 [if test "$enableval" = yes
  then
    pop=on
    popserver=on
    POP2=POP2
  else
    popserver=off
    POP2=
  fi])

AC_ARG_ENABLE(jmandir,
[  --enable-jmandir=DIR    set a directory for Japanese manual],
 [case "$enableval" in
    no)
      jmandir=
      ;;
    /*)
      jmandir="$enableval"
      ;;
    *)
      AC_MSG_ERROR(You must set DIR with --enable-jmandir=DIR option.)
      ;;
    esac], [jmandir=default])

AC_ARG_WITH(pager,
[  --with-pager=DIR        set default pager (DEFAULT: auto detect)],
 [pagerpath="$withval"])

if test "$pop" = on -a "$popserver" = off -a x"$APOP" = x
then
  APOP=APOP
fi

if test "$popserver" = on
then
  if test "$bboards" != off
  then
    bbdelivery=on
  fi
  if test x"$APOP" = xAPOP
  then
    AC_MSG_ERROR(You must set AUTHFILE with --enable-apop=AUTHFILE option.)
  fi
fi

AC_ARG_ENABLE(debug,
[  --enable-debug          debug mode (for maintainer)],
 [if test "$enableval" = yes
  then
    debug=on
  fi])

AC_ARG_ENABLE(japan,
[  --enable-japan          Japanese support (DEFAULT)],
 [if test "$enableval" = yes
  then
    JAPAN=JAPAN
  else
    JAPAN=
  fi])

dnl ====================================================================
dnl Check OS type.
dnl ====================================================================
AC_CANONICAL_HOST

dnl ====================================================================
dnl Checks for programs.
dnl ====================================================================
CC_bak="$CC"
CFLAGS_bak="$CFLAGS"
LDFLAGS_bak="$LDFLAGS"

AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
AC_PROG_AWK
AC_PROG_RANLIB

if test x"$CFLAGS_bak" = x
then
  if test "$debug" = on
  then
    CFLAGS="-g"
  else
    CFLAGS=`echo "$CFLAGS" | sed 's/-g *//'`
  fi
fi

if test x"$LDFLAGS_bak" = x -a "$debug" != on
then
  LDFLAGS="-s $LDFLAGS"
fi

case "$host_os" in
  sunos4*)
    if test "$use_sharedlib" != no
    then
      sharedlib=sun4
      if test $ac_cv_prog_gcc = yes
      then
        slflags="-fpic"
        if test x"$LDFLAGS_bak" = x
        then
          LDFLAGS="$LDFLAGS -B/usr/bin/"
        fi
      else
        slflags="-pic"
      fi
      slibdir=$libdir
    fi
    SUN40=SUN40
    SETEUID=SETEUID
    ;;
  solaris2*)
    if test "$use_sharedlib" != no
    then
      sharedlib=sys5
      if test $ac_cv_prog_gcc = yes
      then
        slflags="-fpic"
        if test x"$LDFLAGS_bak" = x
        then
          LDFLAGS="$LDFLAGS -B/usr/ccs/bin/"
        fi
      else
        slflags="-K pic"
      fi
      slibdir=$libdir
    fi
    SOLARIS=`echo "$host_os" | $AWK -F. '{printf "SOLARIS=2%02d%02d",$2,$3}'`
    SETEUID=`echo "$host_os" | $AWK -F. '$2>=3{printf "SETEUID"}'`
    ;;
  freebsd* | netbsd*)
    if test "$use_sharedlib" != no
    then
      sharedlib=fbsd
      if test -x /usr/bin/objformat
      then
	if test x`/usr/bin/objformat` = xelf
	then
	  sharedlib=gnuelf
	  make_mhconfig='CFLAGS="-O -DMHSLIB_NOMINVER"'
	fi
      fi
      echo __ELF__ | $CC -E - | grep -q __ELF__ || sharedlib=gnuelf
      slflags="-fpic"
      slibdir=$libdir
    fi
    if test x"$CFLAGS_bak" = x
    then
      CFLAGS="$CFLAGS -pipe"
    fi
    manuals=standard/gzip
    ;;
  bsdi*)
    if test x"$CC_bak" = x -a "$use_sharedlib" != no \
      -a x`echo "$host_os" | $AWK -F. '$1=="bsdi3"{printf "bsdi3"}'` = xbsdi3
    then
      CC=shlicc2
    fi
    if test x"$CFLAGS_bak" = x
    then
      CFLAGS="$CFLAGS -pipe"
    fi
    ;;
  next*)
    if test x"$LDFLAGS_bak" = x
    then
      LDFLAGS=
    fi
    # OPENSTEP's lockf is broken
    ac_cv_func_lockf=no
    ;;
  hpux*)
    if test $ac_cv_prog_gcc != yes
    then
      if test x"$CFLAGS_bak" = x
      then
	CFLAGS="+O2"
      fi
      if test x"$LDFLAGS_bak" = x
      then
	LDFLAGS="-nqs"
      fi
    fi
    # HP-UX's ruserpass is incompatible with MH
    ac_cv_func_ruserpass=no
    # HP-UX's _ruserpass is incompatible with MH
    ac_cv_func__ruserpass=no
    ;;
  irix*)
    if test x"$CFLAGS_bak" = x
    then
      if test $ac_cv_prog_gcc = yes
      then
        CFLAGS="$CFLAGS -fsigned-char"
      else
        CFLAGS="$CFLAGS -signed"
      fi
    fi
    SETREUID=SETREUID
    ;;
  osf*)
    SYS5=SYS5
    SETEUID=SETEUID
    ;;
  sysv5uw*)
    FILE__PTR=FILE__PTR
    FILBUF_ADJ=FILBUF_ADJ
    ;;
  darwin*)
    if test x"$CFLAGS_bak" = x
    then
      CFLAGS="-traditional $CFLAGS"
    fi
    if test x"$LDFLAGS_bak" = x -a "$debug" != on
    then    
      LDFLAGS="-Wl,-S"
    fi
    ;;
  linux*)
    if test "$use_sharedlib" != no
    then
      sharedlib=gnuelf
      slflags="-fpic"
      slibdir=$libdir
    fi
    if test x"$CFLAGS_bak" = x
    then
      CFLAGS="$CFLAGS -pipe"
    fi
    SYS5=SYS5
    SETREUID=SETREUID
    # Linux's ruserpass is incompatible with MH
    ac_cv_func_ruserpass=no
    ;;
esac

if test "$ac_cv_prog_RANLIB" = ":"
then
  ranlib=off
fi

dnl Look for `write'
tmppath=/usr/bin:/bin:$PATH
AC_PATH_PROG(write, write, no, [$tmppath]) 

dnl Look for UCB mail
tmppath=/usr/bin:/bin:/usr/ucb:/usr/bsd:$PATH
AC_PATH_PROGS(ucbmail, Mail mailx mail, no, [$tmppath]) 

dnl Look for ps
tmppath=/usr/bin:/bin:/usr/sbin:/sbin:/usr/etc:/etc:$PATH
AC_PATH_PROG(ps, ps, no, [$tmppath]) 

dnl Look for `chown'
tmppath=/usr/bin:/bin:/usr/sbin:/sbin:/usr/etc:/etc:$PATH
AC_PATH_PROG(chown, chown, /etc/chown, [$tmppath]) 
chownpath="$ac_cv_path_chown"

dnl Look for `sendmail'
tmppath=/usr/lib:/usr/sbin:/usr/etc:/usr/ucblib:/usr/bin
AC_PATH_PROG(sendmail, sendmail, /usr/lib/sendmail, [$tmppath])
sendmailpath="$ac_cv_path_sendmail"

dnl Look for pager
if test x"$pagerpath" = x
then
  tmppath=$PATH:/usr/bin:/bin:/usr/ucb:/usr/bsd
  AC_PATH_PROGS(pager, jless less more, /usr/ucb/more, [$tmppath])
  pagerpath="$ac_cv_path_pager"
fi

dnl Check for broken vi
AC_CACHE_CHECK(for broken vi, ac_cv_prog_vi_bug,
 [ac_cv_prog_vi_bug=no
  echo 'r /nonexist-file
r /nonexist-file
q' | ex > /dev/null 2>&1
  if test $? = 2
  then
    echo 'r /nonexist-file
r /nonexist-file
r /nonexist-file
q' | ex > /dev/null 2>&1
    if test $? = 3
    then
      ac_cv_prog_vi_bug=yes
    fi
  fi])
if test "$ac_cv_prog_vi_bug" = yes
then
  ATTVIBUG=ATTVIBUG
fi

dnl ====================================================================
dnl Checks for libraries.
dnl ====================================================================
dnl Checks for network libraries (nsl, socket)
AC_CHECK_FUNC(gethostbyname, ,
  AC_CHECK_LIB(nsl, gethostbyname, ,
    AC_CHECK_LIB(resolv, gethostbyname)))
AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))

dnl Checks for crypt & dbm libraries
if test "$popserver" = on
then
  AC_CHECK_FUNC(crypt, , AC_CHECK_LIB(crypt, crypt))
  if test x"$APOP" != x
  then
    AC_CHECK_FUNC(dbm_open, ,
      AC_CHECK_LIB(gdbm, dbm_open, ,
        AC_CHECK_LIB(ndbm, dbm_open, ,
          AC_CHECK_LIB(dbm, dbm_open))))
    AC_TRY_LINK([#include <ndbm.h>
#ifdef DBM_SUFFIX
#undef dbm_pagfno
#define dbm_pagfno dbm_dirfno
#endif], [dbm_pagfno((DBM *)0)], ,
      LIBS="-lgdbm $LIBS"
      AC_TRY_LINK([#include <ndbm.h>
#ifdef DBM_SUFFIX
#undef dbm_pagfno
#define dbm_pagfno dbm_dirfno
#endif], [dbm_pagfno((DBM *)0)], ,
     [echo ""
      echo "You have no DBM library.  Give up APOP server."
      echo "  Use --disable-apop or --disable-popserver option."
      exit 0]))
  fi
fi

dnl Checks for maillock
LIBS_bak="$LIBS"
AC_CHECK_LIB(mail, maillock,
  LIBS="$LIBS -lmail"
  AC_TRY_LINK([#include <maillock.h>],
    [if (maillock("root", 5) == L_SUCCESS) mailunlock();],
    [MAILLOCK=MAILLOCK]))
if test x"$MAILLOCK" = x
then
  LIBS="$LIBS_bak"
fi

dnl Checks for library lockfile
LIBS_bak="$LIBS"
AC_CHECK_LIB(lockfile, lockfile_create,
  LIBS="$LIBS -llockfile"
  AC_TRY_LINK([#include <lockfile.h>],
    [if (lockfile_create("root.lock", 5, 0) == 0) lockfile_remove("root.lock");],
    [LIBLOCKFILE=LIBLOCKFILE]))
if test x"$LIBLOCKFILE" = x
then
  LIBS="$LIBS_bak"
fi

dnl Checks for terminal libraries
LIBS_bak="$LIBS"
CFLAGS_tmp="$CFLAGS"
test -d /usr/include/ncurses && CFLAGS="$CFLAGS -I/usr/include/ncurses"
AC_CHECK_HEADERS(ncurses.h)
if test "$ac_cv_header_ncurses_h" = yes
then
  cursesheader="ncurses.h"
else
  cursesheader="curses.h"
fi
AC_CACHE_CHECK(whether curses.h is ncurses, ac_cv_lib_ncurses,
  AC_TRY_COMPILE([#include <$cursesheader>
#ifndef NCURSES_VERSION
  This line will cause a parse error: "curses.h is not ncurses"
#endif], [WINDOW *w; w->_line->text;],
 [ac_cv_lib_ncurses=yes], [ac_cv_lib_ncurses=no]))
if test "$ac_cv_lib_ncurses" = yes
then
  if test "$cursesheader" = ncurses.h
  then
    NCURSES=NCURSES
  fi
  curseslib="-lncurses"
else
  curseslib="-lcurses"
  CFLAGS="$CFLAGS_tmp"
fi

AC_CACHE_CHECK(for tgetnum in $curseslib, ac_cv_lib_curses_tgetnum,
  LIBS="$LIBS_bak $curseslib"
  AC_TRY_LINK( , tgetnum(), [ac_cv_lib_curses_tgetnum=yes],
    [ac_cv_lib_curses_tgetnum=no]))
if test "$ac_cv_lib_curses_tgetnum" = yes
then
  curses="$curseslib"
else
  AC_CACHE_CHECK(for tgetnum in $curseslib -ltermlib,
    ac_cv_lib_curses_termlib_tgetnum,
    LIBS="$LIBS_bak $curseslib -ltermlib"
    AC_TRY_LINK( , tgetnum(), [ac_cv_lib_curses_termlib_tgetnum=yes],
      [ac_cv_lib_curses_termlib_tgetnum=no]))
  if test "$ac_cv_lib_curses_termlib_tgetnum" = yes
  then
    curses="$curseslib -ltermlib"
  else
    AC_CACHE_CHECK(for tgetnum in $curseslib -ltermcap,
      ac_cv_lib_curses_termcap_tgetnum,
      LIBS="$LIBS_bak $curseslib -ltermcap"
      AC_TRY_LINK( , tgetnum(), [ac_cv_lib_curses_termcap_tgetnum=yes],
        [ac_cv_lib_curses_termcap_tgetnum=no]))
    if test "$ac_cv_lib_curses_termcap_tgetnum" = yes
    then
      curses="$curseslib -ltermcap";
    else
      AC_CHECK_LIB(termlib, tgetnum, [curses="-ltermlib"],
        AC_CHECK_LIB(termcap, tgetnum, [curses="-ltermcap"]))
    fi
  fi
fi

dnl Check for readline library
LIBS="$LIBS_bak -lreadline $curses"
AC_CACHE_CHECK(for readline, ac_cv_lib_readline,
  AC_TRY_LINK([#include <stdio.h>
#include <readline/readline.h>], [CPPFunction x; readline("");],
 [ac_cv_lib_readline=yes], [ac_cv_lib_readline=no]))
if test "$ac_cv_lib_readline" = yes
then
  READLINE=READLINE
fi
LIBS="$LIBS_bak"

dnl ====================================================================
dnl Checks for header files.
dnl ====================================================================
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h ndbm.h shadow.h strings.h \
    sys/ioctl.h sys/param.h unistd.h)

if test "$ac_header_dirent" = dirent.h
then
  SYS5DIR=SYS5DIR
elif test "$ac_header_dirent" = ndir.h 
then
  NDIR=NDIR
fi

if test "$ac_cv_header_sys_ioctl_h" != yes
then
  NOIOCTLH=NOIOCTLH
fi

if test "$ac_cv_header_unistd_h" = yes
then
  UNISTD=UNISTD
fi

if test "$ac_cv_header_shadow_h" = yes
then
  SHADOW=SHADOW
fi

dnl ====================================================================
dnl Checks for typedefs, structures, and compiler characteristics.
dnl ====================================================================
AC_C_CONST
AC_STRUCT_ST_BLKSIZE
AC_DECL_SYS_SIGLIST
AC_HEADER_TIME
AC_STRUCT_TM

AC_TRY_COMPILE([#include <$ac_cv_struct_tm>
struct tm *localtime();],
[struct tm *tm;
tm->tm_gmtoff;], [ZONEINFO=ZONEINFO])

AC_TRY_LINK([#include <$ac_cv_struct_tm>],
[extern char *tzname[];
tzset();
tzname[0];], [TZNAME=TZNAME])

ac_compile_bak="$ac_compile"
ac_compile="$ac_compile ; ld -x -r conftest.o"
rm -f a.out
AC_CACHE_CHECK(for old load, ac_cv_sys_oldload,
  ac_cv_sys_oldload=none
  AC_TRY_COMPILE([#include <stdio.h>], [printf("Hello\n");],
   [if test -f a.out
    then
      rm -f a.out
      ac_cv_sys_oldload=off
    fi],
   [if test "$CC" = cc
    then
      ac_compile="$ac_compile_bak ; cc -s -o conftest.o"
      AC_TRY_COMPILE([#include <stdio.h>], [printf("Hello\n");],
        [ac_cv_sys_oldload=on])
    fi])
  [case "$host_os" in
    hpux10.* | osf3.*)
      ac_cv_sys_oldload=none
      ;;
  esac])
oldload="$ac_cv_sys_oldload"
ac_compile="$ac_compile_bak"

dnl ====================================================================
dnl Checks for library functions.
dnl ====================================================================
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(bcopy fcntl flock getdtablesize lockf rename rindex \
    ruserpass _ruserpass seteuid setreuid sigblock vsprintf)

AC_CACHE_CHECK(for 4.4BSD, ac_cv_sys_bsd44,
  ac_cv_sys_bsd44=no
  AC_TRY_COMPILE(
[#include <sys/param.h>
#if !defined(BSD) || (BSD < 199306)
  This line will cause a parse error: "not BSD44"
#endif], ,
   [ac_cv_sys_bsd44=yes]))
if test "$ac_cv_sys_bsd44" = yes
then
  BSD44=BSD44
  BSD43=BSD43
  BSD42=BSD42
  SETEUID=SETEUID
fi

if test "$ac_cv_func_seteuid" != yes
then
  SETEUID=
fi
if test "$ac_cv_func_setreuid" != yes
then
  SETREUID=
fi
if test x"$SETEUID" = xSETEUID -a x"$SETREUID" = xSETREUID
then
  SETREUID=
fi
if test x"$RPOP" = x
then
  SETEUID=
  SETREUID=
fi

AC_CACHE_CHECK(for SVR4, ac_cv_sys_svr4,
  ac_cv_sys_svr4=no
  AC_TRY_COMPILE(
[#if !defined(__svr4__) && !defined(__svr4) && !defined(SVR4)
  This line will cause a parse error: "not SVR4"
#endif], ,
 [ac_cv_sys_svr4=yes],
 [if test -f /etc/saf/_sactab
  then
    ac_cv_sys_svr4=yes
  fi]))
if test "$ac_cv_sys_svr4" = yes
then
  SVR4=SVR4
  SYS5=SYS5
  CONTENT_LENGTH=CONTENT_LENGTH
fi

dnl The idea from perl Configure script.
AC_MSG_CHECKING([either SYS5, BSD or V7])
ac_sys5_bsd_v7=unknown
if test `echo abc | tr a-z A-Z` = Abc
then
  if test "$ac_cv_header_strings_h" != yes \
    -o "$ac_cv_func_bcopy" != yes -o "$ac_cv_func_rindex" != yes
  then
    SYS5=SYS5
  fi
else
  AC_TRY_COMPILE([#include <signal.h>],
[kill(0, SIGTSTP);],
 [if test x"$SYS5" = x
  then
    AC_TRY_COMPILE([#include <syslog.h>],
     [openlog("MH", LOG_PID, LOG_DAEMON);],
     [if test -g "$ac_cv_path_write"
      then
        BSD42=BSD42
        BSD43=BSD43
      fi])
  fi],
 [ac_sys5_bsd_v7=V7
  V7="V7 void=int"
  case "$host_os" in
    xenix*)
      ALTOS=ALTOS
      ;;
  esac])
fi

AC_TRY_COMPILE(
[#if !defined(__svr3__) && !defined(__svr3) && !defined(SVR3)
  This line will cause a parse error: "not SVR3"
#endif], ,
[SYS5=SYS5])

if $ac_cv_path_ps -eaf > /dev/null 2>&1
then
  sys5_ps=yes
else
  sys5_ps=no
fi
if $ac_cv_path_ps -axu > /dev/null 2>&1
then
  bsd_ps=yes
else
  bsd_ps=no
fi

if test x"$BSD42" = x -a x"$V7" = x -a "$sys5_ps" = yes -a "$bsd_ps" = no
then
    SYS5=SYS5
fi
if test x"$SYS5" = x -a x"$V7" = x -a "$sys5_ps" = no -a "$bsd_ps" = yes
then
  if test "$ac_cv_func_getdtablesize" = yes -a "$ac_cv_func_sigblock" = yes \
      -a "$ac_cv_func_flock" = yes
  then
    BSD42=BSD42
  elif test "$ac_cv_func_bcopy" != yes
  then
    BSD41A=BSD41A
  fi
fi

if test x"$BSD42" = x -a x"$BSD41A" = x -a x"$V7" = x
then
  if test x"$ZONEINFO" = x -a x"$TZNAME" = xTZNAME
  then
    SYS5=SYS5
  fi
  if test -d /usr/lib/terminfo -o -d /usr/share/lib/terminfo
  then
    SYS5=SYS5
  fi
fi

if test x"$BSD41A" = xBSD41A -o x"$BSD42" = xBSD42
then
  ac_sys5_bsd_v7=BSD
fi
if test x"$SYS5" = xSYS5
then
  ac_sys5_bsd_v7=SYS5
fi
AC_MSG_RESULT($ac_sys5_bsd_v7)

AC_TRY_COMPILE([#include <signal.h>], [kill(0, SIGEMT);], ,
  AC_TRY_COMPILE([#include <signal.h>], [kill(0, SIGUSR1);],
    [SIGEMT="SIGEMT=SIGUSR1"]))

typesignal="$ac_cv_type_signal"

if test "$ac_cv_func_vsprintf" = yes
then
  VSPRINTF=VSPRINTF
fi

if test "$ac_cv_func_ruserpass" != yes
then
  if test "$ac_cv_func__ruserpass" = yes
  then
    NFS=NFS
  else
    NORUSERPASS=NORUSERPASS
  fi
fi

if test "$ac_cv_func_lockf" = yes -a x"$BSD44" = x
then
  LOCKF=LOCKF
elif test "$ac_cv_func_flock" = yes
then
  if test x"$BSD42" = x
  then
    FLOCK=FLOCK
  fi
else
  FCNTL=FCNTL
fi

AC_CACHE_CHECK(for return type of sprintf, ac_cv_type_sprintf,
AC_TRY_COMPILE([#include <sys/types.h>
#include <stdio.h>
int sprintf();], , [ac_cv_type_sprintf="int"], [ac_cv_type_sprintf="char *"]))
typesprintf="$ac_cv_type_sprintf"

if test x"$BSD42" = xBSD42 -a x"$TZNAME" = xTZNAME
then
  TZNAME=
fi

if test x"$BSD42" = xBSD42
then
  AC_TRY_COMPILE([#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
  This line will cause a parse error: "not used union wait"
#endif
#include <sys/wait.h>
wait(union wait *);], , , [WAITINT=WAITINT])
else
  test "$ac_cv_func_rename" = yes && RENAME=RENAME
  AC_CACHE_CHECK(for BSD socket support, ac_cv_sys_socket,
    AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>], [struct sockaddr_in in_socket;
socket(AF_INET, SOCK_STREAM, 0);],
   [ac_cv_sys_socket=yes], [ac_cv_sys_socket=no]))
  if test "$ac_cv_sys_socket" = yes
  then
    SOCKETS=SOCKETS
  fi
fi

AC_CACHE_CHECK(for BIND support, ac_cv_sys_bind,
  AC_EGREP_CPP(yes,
[#include <resolv.h>
#if defined(__RES) || defined(_PATH_RESCONF) || defined(RES_DEFAULT)
  yes
#endif],
 [ac_cv_sys_bind=yes], [ac_cv_sys_bind=no]))
if test "$ac_cv_sys_bind" = yes
then
  BIND=BIND
fi

AC_TRY_COMPILE([#include <termios.h>
#ifndef HAVE_SYS_WAIT_H
  This line will cause a parse error: "not POSIX"
#endif], [tcflush(0, TCOFLUSH);],
[POSIX=POSIX])

AC_CACHE_CHECK(for need ntohl macro, ac_cv_func_ntohl,
  AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
#ifdef _BIG_ENDIAN
  This line will cause a parse error: "no need ntohl() for BIG_ENDIAN"
#endif
#if BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN && BYTE_ORDER == BIG_ENDIAN
  This line will cause a parse error: "no need ntohl() for BIG_ENDIAN"
#endif],
[long x;
ntohl(x);],
   [ac_cv_func_ntohl=yes], [ac_cv_func_ntohl=no]))
if test "$ac_cv_func_ntohl" = yes
then
  NTOHLSWAP=NTOHLSWAP
fi

dnl ====================================================================
dnl Checks for system services.
dnl ====================================================================
dnl Check for support network password database (YP/NIS).
AC_CACHE_CHECK(for support network password database, ac_cv_sys_dbmpwd,
 [ac_cv_sys_dbmpwd=no
  if test -d /var/yp -o -d /usr/etc/yp -o -d /var/nis \
    -o -x /usr/sbin/ypbind -o -x /usr/etc/ypbind
  then
    ac_cv_sys_dbmpwd=yes
  fi])
if test "$ac_cv_sys_dbmpwd" = yes
then
  DBMPWD=DBMPWD
fi

dnl Find mail spool.
AC_CACHE_CHECK(where mail spool is located, ac_cv_path_mailspool,
 [ac_cv_path_mailspool=
  for spool in /var/mail /var/spool/mail /usr/mail /usr/spool/mail
  do
    if test -d $spool
    then
      ac_cv_path_mailspool=$spool
      break
    fi
  done])
mailspool="$ac_cv_path_mailspool"

dnl Check for mailgroup
AC_CACHE_CHECK(whether mail spool is opened for special group,
  ac_cv_group_mail,
 [ls_opt="-lLd"
  if test `ls $ls_opt $mailspool | $AWK '{print NF}'` -lt 9
  then
    ls_opt="-lLgd"
  fi
  ac_cv_group_mail=`ls $ls_opt $mailspool | \
    $AWK 'BEGIN{group="no"}
	  /drwxrwxr-x/ || /drwxrwxr-t/{group=$4}
	  END{print group}'`
  if test ! -g $ac_cv_path_ucbmail -a x"$MAILLOCK" = x -a x"$LIBLOCKFILE" = x
  then
    ac_cv_group_mail=no
  fi])
if test "$ac_cv_group_mail" = no
then
  mailgroup=off
else
  mailgroup="$ac_cv_group_mail"
  SETMG=SETMG
fi

if test "$pop" != off
then
  if test "$popserver" = off
  then
    pop=client
  else
    popdir=$sbindir
  fi
  POPSERVICE=`grep 110/tcp /etc/services 2> /dev/null | $AWK 'NR==1{print $1}'`
  if test x"$POPSERVICE" != x
  then
    POPSERVICE=POPSERVICE=\'\"$POPSERVICE\"\'
  else
    POPSERVICE=POPSERVICE=\'\"pop\"\'
  fi
fi

if test "$use_sharedlib" = yes
then
    if test x"$SVR4" = xSVR4 -a $ac_cv_prog_gcc = yes
    then
      sharedlib=sys5
      slflags="-fpic"
      slibdir=$libdir
    fi
fi  

dnl ====================================================================
dnl Now output file.
dnl ====================================================================
dnl expand variable
if test x"$prefix" = xNONE
then
  prefix=$ac_default_prefix
fi

if test x"$exec_prefix" = xNONE
then
  exec_prefix='${prefix}'
fi

bindir=`eval echo $bindir`
bindir=`eval echo $bindir`
popdir=`eval echo $popdir`
popdir=`eval echo $popdir`
etcdir=`eval echo $etcdir`
etcdir=`eval echo $etcdir`
mandir=`eval echo $mandir`
mandir=`eval echo $mandir`
slibdir=`eval echo $slibdir`
slibdir=`eval echo $slibdir`

dnl Find Japanese manual directory
dnl We must do it after expanding "$mandir"
if test x"$jmandir" = xdefault
then
  AC_CACHE_CHECK(where Japanese manual directory is located, ac_cv_path_jman,
   [ac_cv_path_jman=no
    for manlang in ja ja_JP ja_JP.EUC ja_JP.eucJP ja_JP.ujis japan japanese
    do
      if test -d $mandir/$manlang
      then
        ac_cv_path_jman="$mandir/$manlang"
        break
      fi
    done])
  if test "$ac_cv_path_jman" = no
  then
    jmandir=
  else
    jmandir="$ac_cv_path_jman"
  fi
fi

dnl We must do it after expanding "$slibdir"
if test "$sharedlib" != off -a "$sharedlib" != fbsd
then
  if test "$sharedlib" = gnuelf
  then
    LDFLAGS="$LDFLAGS -Xlinker -rpath -Xlinker $slibdir"
  elif test x"$SOLARIS" != x
  then
    LDFLAGS="$LDFLAGS -R$slibdir"
  elif test x"$SUN40" = xSUN40
  then
    if test "$slibdir" != "/usr/lib" -a "$slibdir" != "/usr/local/lib"
    then
      LDFLAGS="$LDFLAGS -L$slibdir"
    fi
  fi
fi

AC_SUBST(SUN40) AC_SUBST(SOLARIS) AC_SUBST(sharedlib) AC_SUBST(slflags)
AC_SUBST(ranlib) AC_SUBST(ATTVIBUG) AC_SUBST(jmandir) AC_SUBST(manuals)
AC_SUBST(chownpath) AC_SUBST(sendmailpath) AC_SUBST(pagerpath)
AC_SUBST(pop) AC_SUBST(popdir) AC_SUBST(APOP) AC_SUBST(DPOP) AC_SUBST(MPOP)
AC_SUBST(POP2) AC_SUBST(RPOP) AC_SUBST(POPSERVICE) AC_SUBST(smtp)
AC_SUBST(NNTP) AC_SUBST(bboards) AC_SUBST(bbdelivery) AC_SUBST(bbhome)
AC_SUBST(oldload) AC_SUBST(etcdir) AC_SUBST(slibdir) AC_SUBST(READLINE)
AC_SUBST(curses) AC_SUBST(NCURSES) AC_SUBST(SYS5DIR) AC_SUBST(NDIR)
AC_SUBST(NOIOCTLH) AC_SUBST(UNISTD) AC_SUBST(SHADOW)
AC_SUBST(BSD41A) AC_SUBST(BSD42) AC_SUBST(BSD43) AC_SUBST(BSD44)
AC_SUBST(SYS5) AC_SUBST(SVR4) AC_SUBST(CONTENT_LENGTH)
AC_SUBST(V7) AC_SUBST(ALTOS) AC_SUBST(ZONEINFO) AC_SUBST(TZNAME)
AC_SUBST(typesignal) AC_SUBST(typesprintf) AC_SUBST(NFS) AC_SUBST(NORUSERPASS)
AC_SUBST(SIGEMT) AC_SUBST(RENAME) AC_SUBST(VSPRINTF) AC_SUBST(WAITINT)
AC_SUBST(FCNTL) AC_SUBST(FLOCK) AC_SUBST(LOCKF)
AC_SUBST(MAILLOCK) AC_SUBST(LIBLOCKFILE)
AC_SUBST(FILBUF_ADJ) AC_SUBST(FILE__PTR)
AC_SUBST(SETEUID) AC_SUBST(SETREUID) AC_SUBST(debug)
AC_SUBST(SOCKETS) AC_SUBST(BIND) AC_SUBST(POSIX) AC_SUBST(NTOHLSWAP)
AC_SUBST(mailspool) AC_SUBST(mailgroup) AC_SUBST(DBMPWD) AC_SUBST(SETMG)
AC_SUBST(JAPAN)

AC_OUTPUT(conf/MH)

dnl ====================================================================
dnl auto make mhconfig
dnl ====================================================================
echo ""

[if test "$batchmode" != yes
then
  echo "Use a shell escape to check conf/MH now, if you want."
  echo ""
  echo $ac_n "Continue make mhconfig (y/n)? [Y]$ac_c"
  read ans
  test x"$ans" = x && ans=y
  case "$ans" in
    y* | Y*)
      ;;
    *)
      exit 0
      ;;
  esac
fi]

cd $ac_aux_dir/conf
make_mhconfig="make CC=\"$CC\" $make_mhconfig"
if test x"$SYS5" = xSYS5
then
  make_mhconfig="$make_mhconfig MFLAGS='CC=\"$CC\"' sys5"
fi
eval $make_mhconfig || AC_MSG_ERROR(some errors occured at making mhconfig)
echo ""
./mhconfig MH || AC_MSG_ERROR(some errors occured at running mhconfig)
cd ..
make clean
exit 0