"Fossies" - the Fresh Open Source Software Archive

Member "hylafax-7.0.2/configure" (5 Dec 2019, 140745 Bytes) of package /linux/misc/hylafax-7.0.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "configure": 7.0.1_vs_7.0.2.

    1 #!/bin/sh
    2 #   $Id: configure 1082 2012-01-31 00:58:35Z faxguy $
    3 #
    4 # HylaFAX Facsimile Software
    5 #
    6 # Copyright (c) 1988-1996 Sam Leffler
    7 # Copyright (c) 1991-1996 Silicon Graphics, Inc.
    8 # HylaFAX is a trademark of Silicon Graphics
    9 # 
   10 # Permission to use, copy, modify, distribute, and sell this software and 
   11 # its documentation for any purpose is hereby granted without fee, provided
   12 # that (i) the above copyright notices and this permission notice appear in
   13 # all copies of the software and related documentation, and (ii) the names of
   14 # Sam Leffler and Silicon Graphics may not be used in any advertising or
   15 # publicity relating to the software without the specific, prior written
   16 # permission of Sam Leffler and Silicon Graphics.
   17 # 
   18 # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
   19 # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
   20 # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
   21 # 
   22 # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
   23 # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
   24 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
   25 # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
   26 # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
   27 # OF THIS SOFTWARE.
   28 #
   29 
   30 # Configuration script for HylaFAX (tm) (aka FlexFAX)
   31 
   32 #
   33 # Shell script to setup machine-dependent files in
   34 # preparation for building HylaFax source.
   35 #
   36 
   37 #
   38 # Setup general configuration parameters.
   39 #
   40 DIR_BIN=/usr/local/bin
   41 DIR_SBIN=/usr/local/sbin
   42 DIR_LIBDATA=/usr/local/lib/fax
   43 DIR_LIB=/usr/local/lib
   44 DIR_LIBEXEC=$DIR_SBIN
   45 DIR_SPOOL=/var/spool/hylafax
   46 DIR_CGI=/var/httpd/cgi-bin
   47 PATH_DPSRIP=$DIR_LIBEXEC/ps2fax
   48 PATH_IMPRIP=/usr/lib/print/psrip
   49 CGIPATH=/cgi-bin
   50 DEFVRES=98
   51 PAGESIZE="North American Letter"
   52 FAXUID=uucp
   53 FAXGID=
   54 SYSUID=bin
   55 SYSGID=
   56 DSO=auto
   57 GETTY=auto
   58 PS=auto
   59 SYSVINIT=auto
   60 FAXQ_SERVER=yes         # init script starts faxq
   61 HFAXD_SERVER=yes        # init script starts hfaxd
   62 HFAXD_SNPP_SERVER=no        # don't start paging protocol
   63 SGI2FAX=auto
   64 PORT=auto
   65 LIBMALLOC=auto
   66 LOCKS=auto
   67 DPS=no
   68 GS=no
   69 IMP=no
   70 UTMP=auto
   71 OPTIMIZER="-O"
   72 LIBTIFF="-ltiff"
   73 TIFFINC=
   74 TIFFBIN=
   75 LIBZ=-lz
   76 ZLIBINC=
   77 REGEX=auto
   78 LIBREGEX=
   79 REGEXINC=
   80 FAXD=
   81 LIBFAXSERVER='libfaxserver.${DSO}'
   82 LIBUTIL='${UTIL}/libfaxutil.${DSO}'
   83 CONFIG_OSFCNH=auto
   84 MANNUM4_5=4F
   85 MANNUM1_8=1M
   86 INSTALLROOT=/
   87 
   88 # SVR4 packaging stuff
   89 PKG_ARCH=               # ARCH variable in pkginfo file
   90 PKG_EMAIL=someone@somehost.somedomain   # EMAIL variable in pkginfo file
   91 PKG_VENDOR="Your Name Here"     # VENDOR variable in pkginfo file
   92 
   93 : ${MAKE=make}              # make to use
   94 # screws up the test of `-f -'
   95 unset MAKEFLAGS
   96 RM="rm -f"
   97 
   98 #
   99 # Note VARX parameters cannot contain more that 100 entries as it
  100 # breaks HP's sed
  101 #
  102 VAR1="ANSICPP
  103 ANSICXXPP
  104 AR
  105 AROPTS
  106 AWK
  107 BIN     DIR_BIN
  108 CAT
  109 CGIDIR      DIR_CGI
  110 CGIPATH
  111 CHGRP
  112 CHMOD
  113 CHOWN
  114 CC
  115 CCOMPILER
  116 CMP
  117 COL
  118 CP
  119 CXX
  120 CXXCOMPILER
  121 CXXFILE
  122 DATE
  123 DEFPAGESIZE
  124 DEFVRES
  125 DIST_ALPHA
  126 DIST_MAJOR
  127 DIST_MINOR
  128 DIST_TYPE
  129 DPS
  130 DPSRIP      PATH_DPSRIP
  131 DSO
  132 DSOSUF
  133 DSODELAY
  134 DSOOPTS
  135 ECHO
  136 ENCODING
  137 ENVOPTS
  138 FAXD
  139 FAXGID
  140 FAXUID
  141 FAXQ_SERVER
  142 FILECMD
  143 FILLORDER
  144 FONTMAP
  145 FONTPATH    PATH_AFM
  146 FUSER
  147 GCOPTS
  148 GCXXOPTS
  149 GENDIST
  150 GETTY
  151 GREP
  152 GS
  153 GSRIP       PATH_GSRIP
  154 HFAXD_SERVER
  155 HFAXD_SNPP_SERVER
  156 IMP
  157 IMPRIP      PATH_IMPRIP
  158 INSTALL
  159 INSTALLROOT
  160 LIBDATA     DIR_LIBDATA
  161 LIBDIR      DIR_LIB
  162 LIBEXEC     DIR_LIBEXEC
  163 LIBFAXSERVER
  164 LIBPORT
  165 LIBREGEX
  166 LIBTIFF
  167 LIBUTIL
  168 LIBZ
  169 LLDOPTS
  170 LN
  171 LN_S
  172 HAVE_PAM
  173 PAMLIBS
  174 HAVE_JBIG
  175 HAVE_JBIGTIFF
  176 LIBJBIG
  177 HAVE_JPEG
  178 LIBJPEG
  179 HAVE_SSL
  180 HAVE_FLEXSSL
  181 SSL
  182 HAVE_LCMS
  183 HAVE_LCMS2
  184 LIBLCMS
  185 HAVE_LDAP
  186 LDAPLIBS"
  187 
  188 VAR2="MACHDEPLIBS
  189 MAKECXXOVERRIDE
  190 MAKEDEPINCLUDE
  191 MAKEDSOINCLUDE
  192 MAKEINCLUDE
  193 MAKELQUOTE
  194 MAKERQUOTE
  195 MAN
  196 MANDIR DIR_MAN
  197 MANAPPS
  198 MANCAPPNAME
  199 MANCFILENAME
  200 MANCVT
  201 MANFILES
  202 MANNUM4_5
  203 MANNUM1_8
  204 MANSAPPNAME
  205 MANSCHEME
  206 MANSFILENAME
  207 MANSYS
  208 MIMENCODE
  209 MKDEPCOPTS
  210 MKDEPCXXOPTS
  211 MKDEPEND
  212 MKDIR
  213 MKFIFO
  214 MV
  215 MV_F
  216 NOCLOBBER_OFF
  217 NOCLOBBER_ON
  218 OPTIMIZER
  219 OPENSSL
  220 PAGESIZE
  221 PATHGETTY   PATH_GETTY
  222 PATHVGETTY  PATH_VGETTY
  223 PATHEGETTY  PATH_EGETTY
  224 PCL6CMD
  225 PKG_ARCH
  226 PKG_EMAIL
  227 PKG_VENDOR
  228 PORT
  229 PORTFUNCS
  230 PROTOTYPES
  231 PSPACKAGE   PS
  232 PWDCMD
  233 RANLIB
  234 REGEX
  235 REGEXINC
  236 RM      RMCMD
  237 SBIN        DIR_SBIN
  238 SCRIPT_SH
  239 SED
  240 SENDMAIL    PATH_SENDMAIL
  241 SETMAKE
  242 SGI2FAX
  243 SHDLIBC
  244 SORT
  245 SPOOL       DIR_SPOOL
  246 SRCDIR
  247 STRIP
  248 SYSGID
  249 SYSUID
  250 SYSVINIT
  251 SYSVINITDIR DIR_SYSVINIT
  252 SYSVINITSTARTDIR    DIR_SYSVINITSTART
  253 SYSVINITSTARTNAME   NAME_SYSVINITSTART
  254 SYSVINITSTOPDIR DIR_SYSVINITSTOP
  255 SYSVINITSTOPNAME    NAME_SYSVINITSTOP
  256 TARGET
  257 TIFF2PDF
  258 TIFFBIN
  259 TIFFINC
  260 TTYCMD
  261 UTMP
  262 UUCP_LOCKDIR    DIR_LOCKS
  263 UUCP_LOCKTYPE   LOCKS
  264 UUENCODE
  265 VERSION
  266 WARNING
  267 ZLIBINC"
  268 
  269 dumpvars()
  270 {
  271     (for i do echo "$i"; done) |
  272     while read a b; do eval c=\$${b:-$a}; echo "/@$a@/s;;$c;g"; done
  273 }
  274 dumpvals()
  275 {
  276     (echo "$VAR1"; echo "$VAR2") |
  277     while read a b; do eval c=\$${b:-$a}; echo "${b:-$a}='$c'"; done
  278 }
  279 
  280 #
  281 # We expect the PATH to point to trusted programs.  However,
  282 # because we appear to need it, we add to the PATH to help
  283 # some systems along.
  284 #
  285 PATH=$PATH:/bin:/usr/bin:/etc
  286 test -d /usr/ccs/bin && PATH=$PATH:/usr/ccs/bin     # SVR4/Solaris2
  287 test -d /usr/sbin && PATH=$PATH:/usr/sbin       # SGI and others
  288 test -d /usr/bsd && PATH=$PATH:/usr/bsd         # SGI
  289 test -d /usr/ucb && PATH=$PATH:/usr/ucb         # Sun and others
  290 test -d /usr/contrib/bin && PATH=$PATH:/usr/contrib/bin # BSDi
  291 test -d /usr/5bin && PATH=/usr/5bin:$PATH:/usr/etc  # Sun and others
  292 test -d /usr/local/bin && PATH=$PATH:/usr/local/bin # for GNU stuff
  293 test -d /opt/freeware/bin && PATH=$PATH:/opt/freeware/bin   # for GNU stuff on AIX
  294 
  295 POSIXLY_CORRECT=1; export POSIXLY_CORRECT       # disable GNU extensions
  296 
  297 LC_ALL=C; export LC_ALL                 # set a common language
  298 
  299 #
  300 # Error diagnostics that should go to the terminal are
  301 # done with this interface (or cat).
  302 #
  303 bitch()
  304 {
  305     echo "$@" 1>&2
  306 }
  307 
  308 die()
  309 {
  310     kill -1 $$              # use kill so trap handler is called
  311 }
  312 
  313 #
  314 # This is the preferred interface for
  315 # configure to terminate abnormally.
  316 #
  317 boom()
  318 {
  319     bitch ""
  320     bitch "Unrecoverable error!  Once you've corrected the problem rerun this script."
  321     die
  322 }
  323 
  324 usage()
  325 {
  326     cat<<'EOF'
  327 Usage: configure [options] [host]
  328 Options: [defaults in brackets after descriptions]
  329   --help                  print this message
  330   --quiet                 do not print `Using ...' messages
  331   --nointeractive         do not prompt for input [INTERACTIVE=no]
  332   --verbose       opposite of --quiet
  333   --version               print the version of autoconf that created configure
  334   --target=TARGET         configure for TARGET [TARGET=HOST]
  335   --srcdir=DIR            find the sources in DIR [configure dir or ..]
  336   --disable-pam           disable all PAM support
  337   --disable-jbig          disable all JBIG support
  338   --disable-lcms          disable all Little CMS support
  339   --disable-jpeg          disable all JPEG library support
  340   --disable-ldap          disable all LDAP support
  341   --with-PARAM[=ARG]      set configuration PARAM [ARG=yes]
  342 EOF
  343 }
  344 
  345 QUIET=no
  346 INTERACTIVE=${INTERACTIVE:="yes"}
  347 SITE=
  348 TARGET=
  349 RELEASE=
  350 SRCDIR=
  351 WITHARGS=no
  352 #
  353 # Crack command line arguments.  We purposely
  354 # use syntax and options that are compatible
  355 # with GNU autoconf.
  356 #
  357 ac_prev=
  358 for ac_option
  359 do
  360     if [ -n "$ac_prev" ]; then      # assign the argument to previous option
  361     eval "$ac_prev=\$ac_option"
  362     ac_prev=
  363     continue
  364     fi
  365     case "$ac_option" in        # collect optional argument
  366     -*=*)   ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'`;;
  367     *)      ac_optarg=;;
  368     esac
  369     case "$ac_option" in
  370     -with-*|--with-*)
  371     ac_with=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
  372     # Reject names that are not valid shell variable names.
  373     if [ -n "`echo $ac_with| sed 's/[-_a-zA-Z0-9]//g'`" ]; then
  374         bitch "configure: $ac_with: invalid parameter name."
  375         die
  376     fi
  377     ac_with=`echo $ac_with| sed 's/-/_/g'`
  378     case "$ac_option" in
  379     *=*)    ;;
  380     *)  ac_optarg=yes;;
  381     esac
  382     eval "${ac_with}='$ac_optarg'"
  383     WITHARGS=yes
  384     ;;
  385     -quiet|--quiet)     QUIET=yes;;
  386     -nointeractive|--nointeractive) INTERACTIVE=no;;
  387     -verbose|--verbose)     QUIET=no;;
  388     -site|--site)       ac_prev=SITE;;
  389     -site=*|--site=*)       SITE="$ac_optarg";;
  390     -srcdir|--srcdir)       ac_prev=SRCDIR;;
  391     -srcdir=*|--srcdir=*)   SRCDIR="$ac_optarg";;
  392     -target|--target)       ac_prev=TARGET;;
  393     -target=*|--target=*)   TARGET="$ac_optarg" ;;
  394     -disable-pam|--disable-pam) DISABLE_PAM="yes" ;;
  395     -disable-ldap|--disable-ldap) DISABLE_LDAP="yes" ;;
  396     -disable-jbig|--disable-jbig) DISABLE_JBIG="yes" ;;
  397     -disable-lcms|--disable-lcms) DISABLE_LCMS="yes" ;;
  398     -disable-jpeg|--disable-jpeg) DISABLE_JPEG="yes" ;;
  399     -version|--version)
  400     echo "This is HylaFAX configure $Revision: 1082 $"
  401     exit 0
  402     ;;
  403     -help|--help)       usage; exit 0;;
  404     -*)
  405     bitch "configure: $ac_option: invalid option; use -help for usage."
  406     die
  407     ;;
  408     *)
  409     if [ x"$TARGET" != x ]; then
  410         bitch "configure: Can only configure for one target at a time."
  411         kill -1 $$
  412     fi
  413     TARGET="$ac_option"
  414     ;;
  415     esac
  416 done
  417 
  418 if [ -n "$ac_prev" ]; then
  419     bitch "configure: missing argument to --`echo $ac_prev | sed 's/_/-/g'`"
  420     die
  421 fi
  422 
  423 #
  424 # Our GCOPTS and GCXXOPTS are equivalent in usage to the more-traditional
  425 # CFLAGS and CXXFLAGS.  So if GCOPTS and GCXXOPTS are unset, then apply
  426 # CFLAGS and CXXFLAGS to them.
  427 #
  428 if [ -z "$GCOPTS" ]; then GCOPTS=$CFLAGS; fi
  429 if [ -z "$GCXXOPTS" ]; then GCXXOPTS=$CXXFLAGS; fi
  430 
  431 #
  432 # Locate source directory by looking for the VERSION file.
  433 # The directory must either be specified through the
  434 # environment or be located in the current directory or a
  435 # parent of the current directory.
  436 #
  437 test "$SRCDIR" || {
  438     configure=$0
  439     # NB: don't use dirname since it may not exist
  440     SRCDIR=`echo $configure | sed 's;/[^/][^/]*$;;'`
  441     if [ @"$SRCDIR" = @"$configure" ]; then
  442         SRCDIR=.
  443     fi
  444     while [ ! -r $SRCDIR/VERSION ]; do
  445     # strip last directory from pathname
  446     newdir=`echo $SRCDIR | sed 's;/[^/]*$;;'`
  447     if [ -z "$newdir" ] || [ "$newdir" = $SRCDIR ]; then
  448         break;
  449     fi
  450     SRCDIR=$newdir
  451     done
  452 }
  453 if [ ! -r $SRCDIR/VERSION ]; then
  454     bitch "Can not locate sources in $SRCDIR; the file $SRCDIR/VERSION"
  455     bitch "does not exist or is unreadable."
  456     boom
  457 fi
  458 SRCDIR=`echo "$SRCDIR" | sed 's;\([^/]\)/*$;\1;'`
  459 
  460 #
  461 # Descriptor usage:
  462 # 1: ???
  463 # 2: messages that should be seen even if we're in the background.
  464 # 3: [stdout from test runs]
  465 # 4: verbose-style messages (Using ...)
  466 # 5: compiler stderr when running tests
  467 #
  468 if [ $QUIET = yes ]; then
  469     exec 4>/dev/null            # chuck messages
  470 else
  471     exec 4>&1               # messages go to stdout
  472 fi
  473 $RM ./config.log
  474 exec 5>./config.log         # compiler messages and the like
  475 
  476 DATE=`date -u -r CHANGES`
  477 
  478 eval `cat $SRCDIR/VERSION | sed 's/\([0-9][0-9]*\)\.\([0-9][0-9]*\)\(.*\)/DIST_MAJOR=\1; DIST_MINOR=\2; DIST_TYPE=\3/'`
  479 DIST_ALPHA=`awk '{print $3}' $SRCDIR/dist/hylafax.alpha`
  480 VERSION="${DIST_MAJOR}.${DIST_MINOR}${DIST_TYPE}"
  481 if [ "$DIST_TYPE" = beta ]; then
  482     VERSION="${VERSION}${DIST_ALPHA}"
  483 fi
  484 
  485 Note()
  486 {
  487     echo "$@" 1>&4
  488 }
  489 
  490 capture()
  491 {
  492     (eval "set -x; $*") >&5 2>&1
  493     return
  494 }
  495 captureX()
  496 {
  497     (eval "set -x; $*") 2>&5
  498     return
  499 }
  500 
  501 date >&5
  502 cat 1>&5 <<'EOF'
  503 
  504 This file contains information that was captured from running the configure
  505 script.  Lines that begin with a "+" are command lines echoed by the
  506 shell.  Other lines are the output of commands; usually the contents of
  507 test case files or the output from compilers.  If configure does the
  508 wrong thing, use the information captured here to aid in debugging.
  509 
  510 EOF
  511 
  512 Note ""
  513 Note "Configuring HylaFAX (tm) (aka FlexFAX) $VERSION."
  514 Note ""
  515 Note "If configure does the wrong thing, check the file config.log for"
  516 Note "information that may help you understand what went wrong."
  517 Note ""
  518 
  519 # test for broken expr (Tru64 UNIX)
  520 x="00"
  521 match=`expr "$x" : "\([0-9]*\)"`
  522 if [ "$match" != "$x" ]; then
  523     bitch "Your expr is broken. It strips leading zeroes"
  524     bitch "This may cause problems with configure, faxsetup, & faxaddmodem"
  525     bitch "Perhaps there is an environment variable you can set"
  526     bitch "to get the desired behavior."
  527 fi
  528 
  529 #
  530 # Read site and local configuration parameters.
  531 #
  532 CONFIG_FILES=
  533 if [ -f $SITE/config.site ]; then
  534     Note "Reading site-wide parameters from $SITE/config.site."
  535     . $SITE/config.site
  536     capture . $SITE/config.site
  537     CONFIG_FILES=$SITE/config.site
  538 elif [ -f $SRCDIR/config.site ]; then
  539     Note "Reading site-wide parameters from $SRCDIR/config.site."
  540     . $SRCDIR/config.site
  541     capture . $SRCDIR/config.site
  542     CONFIG_FILES=$SRCDIR/config.site
  543 fi
  544 if [ -f config.local ]; then
  545     Note "Reading local parameters from config.local."
  546     . ./config.local
  547     capture . ./config.local
  548     CONFIG_FILES="$CONFIG_FILES config.local"
  549 elif [ -f $SRCDIR/config.local ]; then
  550     Note "Reading local parameters from $SRCDIR/config.local."
  551     . $SRCDIR/config.local
  552     capture . $SRCDIR/config.local
  553     CONFIG_FILES="$CONFIG_FILES $SRCDIR/config.local"
  554 fi
  555 #
  556 # Flush cached values if something was specified on the
  557 # command line or if the contents of a config parameter
  558 # file was changed more recently.
  559 #
  560 REASON=
  561 if [ $WITHARGS = yes ]; then 
  562     REASON="of command line parameters"
  563 elif [ "$CONFIG_FILES" ]; then
  564     REASON=`find $CONFIG_FILES -newer config.cache -print 2>/dev/null`
  565     test "$REASON" && REASON="$REASON has been updated"
  566 fi
  567 if [ "$REASON" ] && [ -f config.cache ]; then
  568    Note "Flushing cached parameters because $REASON."
  569    Note ""
  570    rm -f config.cache
  571 fi
  572 if [ -f config.cache ]; then
  573     Note "Reading cached parameters from config.cache."
  574     Note ""
  575     ODATE="$DATE"; OVERSION="$VERSION"
  576     OPORTFUNCS="$PORTFUNCS"; OMACHDEPLIBS="$MACHDEPLIBS"
  577     OTIFFINC="$TIFFINC"; OLIBTIFF="$LIBTIFF"
  578     OZLIBINC="$ZLIBINC"; OLIBZ="$LIBZ"
  579     OREGEXINC="$REGEXINC"; OLIBREGEX="$LIBREGEX"
  580     . ./config.cache
  581     capture . ./config.cache
  582     # NB: these are calculated each time from scratch
  583     DATE="$ODATE"; VERSION="$OVERSION"
  584     MACHDEPLIBS="$OMACHDEPLIBS"; PORTFUNCS="$OPORTFUNCS"
  585     # NB: these are relativized each time so beware of cached value
  586     TIFFINC="$OTIFFINC"; LIBTIFF="$OLIBTIFF"
  587     ZLIBINC="$OZLIBINC"; LIBZ="$OLIBZ"
  588     REGEXINC="$OREGEXINC"; LIBREGEX="$OLIBREGEX"
  589 fi
  590 
  591 identifyTarget()
  592 {
  593     random=`date | awk '{print $4}' | sed -e 's/.*://'` 2>/dev/null
  594     case "$random" in
  595     *0) Note "Wow, you've got a $1 system!";;
  596     *1) Note "Hmm, looks like a $1 system.";;
  597     *2) Note "Oh no, not another $1 system...";;
  598     *3) Note "Well I'll be, a $1 system.";;
  599     *4) Note "Fee, fie, foe, this smells like a $1 system.";;
  600     *5) Note "Gosh, aren't you lucky to have a $1 system!";;
  601     *6) Note "YOW!!  Did something bad happen or am I on a $1 system?";;
  602     *7) Note "Do they really still make $1 systems?!";;
  603     *8) Note "I'm always happy to encounter another $1 system.";;
  604     *9) Note "Here we are again, this time on a $1 system.";;
  605     esac
  606 }
  607 
  608 #
  609 # If no target is specified, try to deduce the system.
  610 # We use the GNU scripts for guessing and canonicalizing
  611 # the system identification, if available.
  612 #
  613 if [ -z "$TARGET" ]; then
  614     test -f $SRCDIR/config.guess && TARGET=`sh $SRCDIR/config.guess` 2>/dev/null
  615     if [ -z "$TARGET" ]; then
  616     bitch "Sorry, no target was specified on the command line and I don't seem to"
  617     bitch "have the GNU config.guess script that is used to deduce your system type."
  618     boom
  619     fi
  620     identifyTarget $TARGET
  621 elif [ -f $SRCDIR/config.sub ]; then
  622     TARGET=`sh $SRCDIR/config.sub "$TARGET"`
  623 else
  624     Note "WARNING, the GNU config.sub script does not seem to be present.  This"
  625     Note "         script is used to canonicalize your target specification; not"
  626     Note "         having it may cause problems later on..."
  627 fi
  628 echo "TARGET: $TARGET" >&5
  629 RELEASE=`(uname -r) 2>/dev/null` || RELEASE=unknown
  630 echo "RELEASE: $RELEASE" >&5
  631 
  632 #
  633 # Find the full pathname of a file
  634 # using the specified test operation.
  635 #
  636 findThing()
  637 {
  638     t="$1"; app=$2; path=$3;
  639     case $app in
  640     /*) eval $t $app && { echo $app; return; };;
  641     esac
  642     IFS=:
  643     for i in $path; do
  644     eval $t $i/$app && { echo $i/$app; return 0; }
  645     done
  646     return 1
  647 }
  648 
  649 #
  650 # Find the full pathname of a plain file.
  651 #
  652 findFile()
  653 {
  654     findThing "test -f" $1 $2
  655 }
  656 
  657 #
  658 # Find the full pathname of an executable.
  659 #
  660 findApp()
  661 {
  662     t="$1"; app=$1; path=$2;
  663     case $app in
  664     /*) eval test -x $app && test ! -d $app && { echo $app; return; };;
  665     esac
  666     IFS=:
  667     for i in $path; do
  668     eval  test -x $i/$app && test ! -d $i/$app && { echo $i/$app; return 0; }
  669     done
  670     return 1
  671 }
  672 
  673 #
  674 # Find the full pathname of an executable;
  675 # supply a default if nothing is found.
  676 #
  677 findAppDef()
  678 {
  679     app=$1; path=$2; def=$3
  680     case $app in
  681     /*) test -x $app && { echo $app; return; };;
  682     esac
  683     IFS=:
  684     for i in $path; do
  685     test -x $i/$app && { echo $i/$app; return; }
  686     done
  687     echo $def
  688 }
  689 
  690 #
  691 # Fixup a list of potentially relative pathnames so
  692 # that they work when used in a subdirectory.  The
  693 # string sent to stdout has no extraneous spaces so
  694 # it can be used, for example, in building pathnames.
  695 #
  696 # NB: There's an extra echo done here so we get a
  697 #     \n-terminated string passed to sed.
  698 #
  699 relativize()
  700 {
  701     echo `(for i do
  702     case "$i" in
  703     -Wl*)           echo "$i" ;;
  704     /*|-l*|-l[$]{DEPTH}/*)  echo "$i" ;;
  705     -L|-L/*|-L[$]{DEPTH}/*) echo "$i" ;;
  706     -I|-I/*|-I[$]{DEPTH}/*) echo "$i" ;;
  707     -R|-R/*|-R[$]{DEPTH}/*) echo "$i" ;;
  708     [$][{]DEPTH[}]/*) echo "$i" ;;
  709     -L*)        echo "$i" | sed 's;^-L;-L../;' ;;
  710     -R*)        echo "$i" | sed 's;^-R;-R../;' ;;
  711     -I*)        echo "$i" | sed 's;^-I;-I../;' ;;
  712     *)      echo "../$i" ;;
  713     esac
  714     done) | tr '\012' ' '` | \
  715     sed -e 's;/[.]/;/;g' -e 's;[ ][ ]*$;;' -e 's;/[.]$;;'
  716 }
  717 
  718 #
  719 # Locate a C and C++ compiler and verify they work and
  720 # satisfy our needs (using assorted heuristics).
  721 #
  722 JUNK="
  723     a.out
  724     conffifo
  725     confsed1
  726     confsed2
  727     conftestmmap
  728     confx confy
  729     confMakefile
  730     conf.db
  731     core
  732     dummy
  733     dummy.C
  734     dummy.a
  735     dummy.c
  736     dummy.o
  737     foo
  738     m.c
  739     so_locations
  740     t.c
  741     t.c++
  742     t.o
  743     t
  744     xMakedepend
  745     xdefs
  746     xgnu.c
  747     xmakeinc
  748     xport.h
  749     xtermios.h
  750 "
  751 trap "$RM \$JUNK; exit 1" 1 2 15
  752 
  753 $RM $JUNK
  754 
  755 #
  756 # Before we go too far, check some features required by the software
  757 #
  758 
  759 if [ -z "$MKFIFO" ]; then
  760     MKFIFO=`findApp mkfifo $PATH`
  761     if [ "$MKFIFO" ]; then
  762     mkfifo()
  763     {
  764         $MKFIFO $1
  765     }
  766     else
  767     MKFIFO=`findApp mknod /sbin:$PATH`
  768     if [ -z "$MKFIFO" ]; then
  769         cat <<EOF
  770 No support for creating a FIFO special file.
  771 
  772 There does not appear to be a way to create a FIFO special file.
  773 No mkfifo program or mknod program was located in the expected
  774 locations.  One of these programs is required for proper operation
  775 of this software.  If these programs are located in a non-standard
  776 location then you can setup the MKFIFO configuration parameter to
  777 reflect the appropriate location.  Otherwise you may need to install
  778 additional software on your system to support FIFO special files
  779 before you can configure the building of this software.
  780 EOF
  781         boom
  782     fi
  783     mkfifo()
  784     {
  785         $MKFIFO $1 p
  786     }
  787     fi
  788 fi
  789 
  790 cat>xgnu.c<<EOF
  791 #ifdef __GNUC__
  792 yes;
  793 #endif
  794 EOF
  795 
  796 #
  797 # Check if the specified compiler is from GNU 
  798 #
  799 isGNU()
  800 {
  801     capture "cat xgnu.c; ($1 -E xgnu.c 2>&5 | egrep yes)"
  802 }
  803 
  804 checkGCCVersion()
  805 {
  806     app=$1; shift
  807     eval `$app -v 2>&1 | \
  808     sed -n -e '/[Vv]ersion/s/[^(]* [a-z\-]*\([0-9]*\)\.\([0-9]*\).\([0-9]*\).*/GCCdist=\1;GCCmajor=\2;GCCminor=\3/p'`
  809     GCCversion="${GCCdist}.${GCCmajor}.${GCCminor}"; export GCCversion
  810     if [ ${GCCdist} -gt $1 ]; then
  811         return 0
  812     fi
  813     if [ ${GCCdist} -eq $1 ]; then
  814         if [ ${GCCmajor} -gt $2 ]; then
  815             return 0
  816         fi
  817         if [ ${GCCmajor} -eq $2 ] && [ ${GCCminor} -ge $3 ]; then
  818             return 0
  819         fi
  820     fi
  821     return 1
  822 }
  823 
  824 #
  825 # NB: use ANSI C prototype to weed out non-ANSI compilers.
  826 #
  827 cat>dummy.c<<EOF
  828 #include <stdlib.h>
  829 int main(int argc, char* argv[]) { exit(0); }
  830 EOF
  831 
  832 checkCompiler()
  833 {
  834     compiler=$1
  835     if isGNU $compiler; then
  836     ISGCC=yes
  837     else
  838     ISGCC=no
  839     fi
  840     #
  841     # Guess special options needed to get an
  842     # ANSI C compiler and/or similar.  Must
  843     # be combined with above checks so we only
  844     # select an ANSI C compiler.
  845     #
  846     if [ -z "${ENVOPTS:-}" ]; then
  847     case $ISGCC-$TARGET in
  848     no-*-hpux11*)   C_ANSI="-Aa -D_HPUX_SOURCE -Dhpux -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED";;
  849     yes-*-hpux11*)  C_ANSI="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED";;
  850     no-*-hp*)   C_ANSI="-Aa -D_HPUX_SOURCE -Dhpux";;
  851     no-*-sco3.2v5.*)    C_ANSI="-Dsco -Dsco5 -b elf";;
  852     yes-*-sco3.2v5.*)   C_ANSI="-Dsco -Dsco5 -m486";;
  853     *-*-sco*)       C_ANSI="-Dsco";;
  854     *-isc*)     C_ANSI="-posix -D_SYSV3 -DISC";;
  855     yes-*-solaris*) C_ANSI="-L/usr/local/lib -R/usr/local/lib";;
  856     esac
  857     else
  858     C_ANSI="$ENVOPTS"
  859     fi
  860     $RM dummy dummy.o
  861     capture $compiler -o dummy ${C_ANSI} dummy.c && {
  862     CC=$compiler;
  863     test -z "${CCOMPILER:-}" && CCOMPILER=`findApp $compiler $PATH`
  864     test -z "${ENVOPTS:-}"   && ENVOPTS="${C_ANSI:-}"
  865     return 0
  866     }
  867     return 1
  868 }
  869 
  870 CCtested=
  871 capture cat dummy.c
  872 if [ -z "${CC:-}" ]; then
  873     CCOMPILER=
  874     for i in gcc cc ncc dcc xlc c89 gcc2 acc; do
  875     CCtested="$CCtested $i"
  876     checkCompiler $i && break
  877     done
  878 else
  879     CCtested="$CCtested $CC"
  880     checkCompiler $CC
  881 fi
  882 if [ -z "$CCOMPILER" ]; then
  883     cat<<EOF
  884 
  885 Cannot locate a working ANSI C compiler.
  886 
  887 We attempted to compile the following test program:
  888 
  889 ----------------------------------------------------------
  890 EOF
  891     cat dummy.c
  892     cat<<EOF
  893 ----------------------------------------------------------
  894 
  895 with these compilers:
  896 
  897     $CCtested
  898 
  899 but none of them were successful.
  900 
  901 If your compiler is in a non-standard location, you can specify its
  902 location in several ways:
  903 
  904     o set the environment variable CC
  905     o create a config.local or config.site file that includes a
  906       definition for CC
  907     o supply it on the command line using -with-CC=<pathname>
  908 
  909 If command line options are required for ANSI C compilation, set the
  910 ENVOPTS parameter to these options in a similar way (either through
  911 an environment variable or config.local/config.site) and then rerun
  912 this script.
  913 EOF
  914     boom
  915 fi
  916 Note "Using $CCOMPILER for a C compiler (set CC to override)."
  917 
  918 test "$ENVOPTS" && {
  919     Note "Using $ENVOPTS to get the appropriate compilation environment."
  920 }
  921 
  922 CheckForGandO()
  923 {
  924     f=$1
  925     if test -s $f; then
  926     capture egrep -i \"error\|warning\" $f || return 1
  927     fi
  928     return 0
  929 }
  930 
  931 if [ -z "$GCOPTS" ]; then
  932     capture $CCOMPILER $ENVOPTS -g -c dummy.c && {
  933     Note "Looks like $CCOMPILER supports the -g option."
  934     # NB: cannot use captureX here 'cuz we lose stderr
  935     if $CCOMPILER $ENVOPTS $GCOPTS -c -g -O dummy.c >t 2>&1 && CheckForGandO t; then
  936         GCOPTS="$GCOPTS -g"
  937     else
  938         Note "... but not together with the -O option, not using it."
  939     fi
  940     }
  941 fi
  942 if [ "$GCOPTS" ]; then
  943     Note "Using \"$GCOPTS\" for C compiler options."
  944 fi
  945 
  946 # 
  947 # Figure out if there is an ANSI C-preprocessor and,
  948 # if __ANSI_CPP__ is not automatically set, configure
  949 # it to be set.
  950 #
  951 cat>dummy.c<<EOF
  952 #define ansiIDENT(a) a
  953 #define ansiCAT(a,b) a##b
  954 A=ansiCAT(ANSI,CPP);
  955 EOF
  956 capture cat dummy.c
  957 if capture "$CCOMPILER $ENVOPTS -E dummy.c | grep ANSICPP"; then
  958     Note "Looks like $CCOMPILER has an ANSI C preprocessor."
  959     cat>dummy.c<<EOF
  960 #ifdef __ANSI_CPP__
  961 yes
  962 #else
  963 no
  964 #endif
  965 EOF
  966     capture cat dummy.c
  967     if capture "$CCOMPILER $ENVOPTS -E dummy.c | grep no"; then
  968     ANSICPP='-D__ANSI_CPP__'
  969     Note "... but __ANSI_CPP__ is not automatically defined, will compensate."
  970     fi
  971 else
  972     Note "Looks like $CCOMPILER has a non-ANSI C preprocessor, will try to compensate."
  973 fi
  974 
  975 #
  976 # Figure out if the C compiler supports a -M option for generating
  977 # Make dependency information.
  978 #
  979 cat>dummy.c<<EOF
  980 #include <stdlib.h>
  981 int main(int argc, char* argv[]) { exit(0); }
  982 EOF
  983 capture cat dummy.c
  984 if capture "$CCOMPILER -c -M $MKDEPCOPTS dummy.c | grep '^dummy.o[  ]*:[    ]*dummy.c'"; then
  985     Note "Looks like $CCOMPILER supports the -M option for generating make dependencies."
  986     MKDEPEND='\${SHELL} \${PORT}/mkdepend'
  987 else
  988     Note "Looks like $CCOMPILER does not support the -M option for generating"
  989     Note "make dependencies; will disable automatic make dependency building."
  990     MKDEPEND=":"
  991 fi
  992 
  993 cat>dummy.C<<EOF
  994 class foo {
  995 public:
  996     struct bar {
  997     int a;
  998     bar();
  999     };
 1000     foo();
 1001 };
 1002 foo::bar::bar() { a = 0; }
 1003 foo::foo() { bar x; }
 1004 int main() { foo t; return 0; }
 1005 EOF
 1006 
 1007 checkCompiler()
 1008 {
 1009     compiler=$1
 1010     if isGNU $compiler; then
 1011     ISGXX=yes
 1012     checkGCCVersion $compiler 2 6 1 || return 1
 1013     else
 1014     ISGXX=no
 1015     fi
 1016     $RM dummy dummy.o
 1017     capture $compiler -o dummy dummy.C && {
 1018     CXX=$compiler;
 1019     test -z "${CXXCOMPILER:-}" && CXXCOMPILER=`findApp $compiler $PATH`
 1020     return 0
 1021     }
 1022     return 1
 1023 }
 1024 
 1025 CCtested=; ISGXX=no
 1026 capture cat dummy.C
 1027 if [ -z "${CXX:-}" ]; then
 1028     CXXCOMPILER=
 1029     CXXCOMPILERS="g++ gcc CC NCC DCC gcc2 xlC"
 1030     for i in $CXXCOMPILERS; do
 1031         CCtested="$CCtested $i"
 1032         checkCompiler $i && break
 1033     done
 1034 else
 1035     CCtested="$CCtested $CXX"
 1036     checkCompiler $CXX
 1037 fi
 1038 if [ -z "$CXXCOMPILER" ]; then
 1039     cat<<EOF
 1040 
 1041 Cannot locate a suitable C++ compiler.
 1042 
 1043 We attempted to compile the following test program:
 1044 
 1045 ----------------------------------------------------------
 1046 EOF
 1047     cat dummy.C
 1048     cat<<EOF
 1049 ----------------------------------------------------------
 1050 
 1051 with these compilers:
 1052 
 1053     $CCtested
 1054 
 1055 but none of them were successful.
 1056 
 1057 To build this software you need a C++ compiler that supports a
 1058 reasonably modern version of C++.  In particular the compiler must
 1059 support nested types and process temporary variables according to the
 1060 ANSI Reference Manual (the ARM).
 1061 
 1062 If such a compiler is in a non-standard location, you can specify its
 1063 location in several ways:
 1064 
 1065     o set the environment variable CXX
 1066     o create a config.local or config.site file that includes a
 1067       definition for CXX
 1068     o supply it on the command line using -with-CXX=<pathname>
 1069 
 1070 If you are trying to use GNU gcc, but you do not have version 2.6.1
 1071 or newer, then you must update your compiler (and probably libg++ as
 1072 well) before you can compile this software.  Consult the documentation
 1073 for information about obtaining an up-to-date version of gcc.
 1074 EOF
 1075     boom
 1076 fi
 1077 Note "Using $CXXCOMPILER for a C++ compiler (set CXX to override)."
 1078 
 1079 if [ -z "$GCXXOPTS" ]; then
 1080     case $CXX-$TARGET in
 1081     *CC-*-irix*)        # cfront-based or cfront-compatible
 1082     GCXXOPTS='+a1 +w +p'
 1083     ;;
 1084     *xlC-*-aix*)
 1085     GCXXOPTS='-qlanglvl=compat -I/usr/lpp/xlC/include -I/usr/include'
 1086     ;;
 1087     *CC-*-sco3.2v5.*)       # cfront-based or cfront-compatible
 1088     GCXXOPTS='+a1 +p'
 1089     ;;
 1090     *)
 1091     GCXXOPTS=
 1092     ;;
 1093     esac
 1094     capture $CXXCOMPILER $ENVOPTS -c -g dummy.C && {
 1095     Note "Looks like $CXXCOMPILER supports the -g option."
 1096     # NB: cannot use captureX here 'cuz we lose stderr
 1097     if $CXXCOMPILER $ENVOPTS -c -g -O dummy.C >t 2>&1 && CheckForGandO t; then
 1098         GCXXOPTS="$GCXXOPTS -g"
 1099     else
 1100         Note "... but not together with the -O option, not using it."
 1101     fi
 1102     }
 1103 fi
 1104 if [ "$GCXXOPTS" ]; then
 1105     Note "Using \"$GCXXOPTS\" for C++ compiler options."
 1106 fi
 1107 
 1108 # 
 1109 # Figure out if there is an ANSI preprocessor for the C++
 1110 # compiler and, if __ANSI_CPP__ is not automatically set,
 1111 # configure it to be set.
 1112 #
 1113 cat>dummy.C<<EOF
 1114 #define ansiIDENT(a) a
 1115 #define ansiCAT(a,b) a##b
 1116 A=ansiCAT(ANSI,CPP);
 1117 EOF
 1118 capture cat dummy.C
 1119 if capture "$CXXCOMPILER $ENVOPTS -E dummy.C | grep ANSICPP"; then
 1120     Note "Looks like $CXXCOMPILER has an ANSI C preprocessor."
 1121     cat>dummy.C<<EOF
 1122 #ifdef __ANSI_CPP__
 1123 yes
 1124 #else
 1125 no
 1126 #endif
 1127 EOF
 1128     if capture "$CXXCOMPILER $ENVOPTS -E dummy.C | grep no"; then
 1129     ANSICXXPP='-D__ANSI_CPP__'
 1130     Note "... but __ANSI_CPP__ is not automatically defined, will compensate."
 1131     fi
 1132 else
 1133     Note "Looks like $CXXCOMPILER has a non-ANSI C++ preprocessor, will try to compensate."
 1134 fi
 1135 
 1136 #
 1137 # Some pre-processors (e.g. SunPRO prior to version 3.0.1)
 1138 # leave comments in a file when invoked with the -E option. 
 1139 # This messes up the default scheme used below to check for
 1140 # function declarations.  Consequently we check for this
 1141 # behaviour here and try to work around the problem with
 1142 # some sed hackery.
 1143 #
 1144 cat>dummy.C<<EOF
 1145 /* this comment should be stripped */
 1146 something else just in case
 1147 and another line also
 1148 EOF
 1149 capture cat dummy.C
 1150 if capture "$CXXCOMPILER $ENVOPTS -E dummy.C | grep comment"; then
 1151     Note "WARNING, \"$CXX -E\" does not strip comments, will try to compensate."
 1152     Note "         Beware that this may not work and you may need to edit port.h"
 1153     Note "         to remove extraneous function declarations."
 1154     stripComments()
 1155     {
 1156     sed -e '/\/\*/,/\*\//d' -e 's;//.*$;;'
 1157     }
 1158 else
 1159     stripComments()
 1160     {
 1161     cat
 1162     }
 1163 fi
 1164 
 1165 #
 1166 # Check to see if the C++ compiler has an inbuilt 'bool' type
 1167 #
 1168 cat>dummy.C<<EOF
 1169 int main()
 1170 {
 1171     bool success = false;
 1172     return 0;
 1173 }
 1174 EOF
 1175 capture cat dummy.C
 1176 if capture "$CXXCOMPILER $ENVOPTS dummy.C"; then
 1177     CONFIG_NEEDBOOL=no
 1178 else
 1179     Note "Looks like will need to define the 'bool' type."
 1180     CONFIG_NEEDBOOL=yes
 1181 fi
 1182 
 1183 #
 1184 # Verify that $MAKE is accessible
 1185 #
 1186 PATHMAKE=`findApp ${MAKE} $PATH`
 1187 if [ "$PATHMAKE" ]; then
 1188     Note "Using $PATHMAKE to configure the software."
 1189 else
 1190     cat<<EOF
 1191 No $MAKE located in the search path.
 1192 
 1193 There was no $MAKE program in the search path used by this script.
 1194 If $MAKE is in a non-standard location, then set the MAKE environment
 1195 variable to the pathname of the appropriate program or change your
 1196 shell search path to include the directory where the program is located.
 1197 EOF
 1198     boom
 1199 fi
 1200 
 1201 #
 1202 # Deduce the include syntax supported by make.
 1203 #
 1204 CheckForMakeIncludeSyntax()
 1205 {
 1206     cat>confMakefile<<EOF
 1207 $1
 1208 all:
 1209 EOF
 1210     capture "cat confMakefile; ${MAKE} -f confMakefile"
 1211 }
 1212 if [ -z "$MAKEINCLUDE" ] || [ -z "$MAKELQUOTE" ] || [ -z "$MAKERQUOTE" ]; then
 1213     INC=xmakeinc
 1214     $RM $INC; echo "" >$INC
 1215     if CheckForMakeIncludeSyntax "include $INC"; then
 1216     MAKEINCLUDE="include"
 1217     MAKELQUOTE=
 1218     MAKERQUOTE=
 1219     elif CheckForMakeIncludeSyntax ".include <$INC>"; then
 1220     MAKEINCLUDE=".include"
 1221     MAKELQUOTE="<"
 1222     MAKERQUOTE=">"
 1223     elif CheckForMakeIncludeSyntax "#include \"$INC\""; then
 1224     MAKEINCLUDE="#include"
 1225     MAKELQUOTE='"'
 1226     MAKERQUOTE='"'
 1227     else
 1228     cat 1>&2 <<EOF
 1229 $MAKE does not support a known include syntax.
 1230 
 1231 The make program configured for use in building this software does not
 1232 support a known syntax for including other files in a Makefile.  The
 1233 Makefiles distributed with this software depend on the ability to include
 1234 other files and will not work without this functionaliy.  The following
 1235 syntaxes are understood and configure automatically selects one for use
 1236 if $MAKE looks to support it:
 1237 
 1238 include file
 1239 .include <file>
 1240 #include "file"
 1241 
 1242 If $MAKE does support including files then you should use a different
 1243 program to build this software; consult the documentation for help in
 1244 locating a suitable make program.  Otherwise if $MAKE supports include
 1245 files, but using a different syntax, then you can setup the MAKEINCLUDE,
 1246 MAKELQUOTE, and MAKERQUOTE configuration parameters to define the
 1247 appropriate syntax.
 1248 EOF
 1249     boom
 1250     fi
 1251 fi
 1252 Note "Using \"${MAKEINCLUDE} ${MAKELQUOTE}file${MAKERQUOTE}\" syntax for Makefiles."
 1253 
 1254 if [ -z "$MAKEDEPINCLUDE" ]; then
 1255     if [ "$MKDEPEND" != ":" ]; then
 1256     $RM xMakedepend
 1257     if CheckForMakeIncludeSyntax "sinclude xMakedepend"; then
 1258         Note "Looks like $MAKE supports \"sinclude\" for conditional includes."
 1259         MAKEDEPINCLUDE="sinclude"
 1260     else
 1261         MAKEDEPINCLUDE="$MAKEINCLUDE"
 1262     fi
 1263     else
 1264     MAKEDEPINCLUDE='#'
 1265     fi
 1266 fi
 1267 
 1268 #
 1269 # Check whether or not $MAKE automatically sets MAKE
 1270 # in the Makefiles.  If not, we add an explicit define
 1271 # for places where recursive calls are made.
 1272 #
 1273 if [ -z "$SETMAKE" ]; then
 1274     cat>confMakefile<<EOF
 1275 all:
 1276     @echo M="${MAKE}"
 1277 EOF
 1278     M=; eval `$MAKE -f confMakefile` >&5 2>&1
 1279     if [ "$M" ]; then
 1280     SETMAKE=
 1281     else
 1282     Note "Looks like $MAKE does not setup MAKE in Makefiles, will compensate."
 1283     SETMAKE="MAKE   = ${MAKE}"
 1284     fi
 1285 fi
 1286 
 1287 if [ -z "$MAKECXXOVERRIDE" ]; then
 1288     case $ISGXX-$TARGET in
 1289     no-*-solaris*|no-*-sunos*)          # SunPRO C++ compiler
 1290     #
 1291     # Yech, the SunPro C++ compiler < v5 has no option to force a source
 1292     # file w/ a .c++ suffix to be treated as C++ source code; instead one
 1293     # must specify file.c++=.C.  We patch the Makefiles with explicit
 1294     # construction rules to do this...
 1295     #
 1296     if [ "`$CXX -V 2>&1 | sed 'q' | sed 's/.* C++ \([^ .]*\).*/\1/g'`" -lt "5" ]; then
 1297         MAKECXXOVERRIDE="=.C";
 1298     fi
 1299     ;;
 1300     esac
 1301 fi
 1302 if [ -z "$CXXFILE" ]; then
 1303     case $CXX-$TARGET in
 1304     xlC-*-aix*)     CXXFILE="-+";;
 1305     gcc-*)      CXXFILE="-x c++";;
 1306     *-*darwin*)     CXXFILE="-x c++";;
 1307     CC-*-sco3.2v5.*)    CXXFILE="+.c++";;
 1308     esac
 1309 fi
 1310 
 1311 test "$AR" || AR=`findApp ar $PATH`
 1312 if [ -z "$AR" ]; then
 1313     Note "WARNING, could not locate a suitable ar command; using a default."
 1314     AR=ar
 1315 fi
 1316 test "$AROPTS" || AROPTS=rc
 1317 test "$RANLIB" || RANLIB=`findApp ranlib $PATH`
 1318 if [ -z "$RANLIB" ]; then
 1319     Note "WARNING, no ranlib, assuming it's not needed."
 1320     RANLIB=":"
 1321     $RM dummy.a
 1322     if capture $AR rcs dummy.a; then
 1323        AROPTS=crs
 1324        Note "Looks like ar has an s option to build symbol tables."
 1325     fi
 1326 fi
 1327 
 1328 cat>dummy.C<<EOF
 1329 #include <new>
 1330 struct foo {
 1331     int x;
 1332     foo();
 1333     ~foo();
 1334 };
 1335 foo::foo() {}
 1336 foo::~foo() {}
 1337 int main()
 1338 {
 1339     foo* ptr = 0;
 1340     foo* a = new(ptr) foo;
 1341     a->x = 0;
 1342     delete a;
 1343     return 0;
 1344 }
 1345 EOF
 1346 
 1347 #
 1348 # Look for appropriate C++ runtime support library.
 1349 #
 1350 CXXRUNTIME=
 1351 capture cat dummy.C
 1352 capture $CXXCOMPILER $ENVOPTS -o dummy dummy.C || {
 1353     #
 1354     # Compiler does not provide it automatically, check known libraries.
 1355     #
 1356     if [ "$ISGXX" = yes ]; then
 1357     capture $CXXCOMPILER $ENVOPTS -o dummy dummy.C -lg++ && \
 1358         { CXXRUNTIME="-lg++"; }
 1359     else
 1360     capture $CXXCOMPILER $ENVOPTS -o dummy dummy.C -lC && \
 1361         { CXXRUNTIME="-lC"; }
 1362     fi
 1363 }
 1364 test "$CXXRUNTIME" && {
 1365     Note "Using explicit $CXXRUNTIME reference for C++ runtime support."
 1366 }
 1367 
 1368 #
 1369 # XXX we should deduce the shell bugs that require us to use
 1370 # bash and ksh instead of sh on certain platforms (notably the
 1371 # BSD-crowd: Linux, BSDI, FreeBSD, NetBSD) but they are very
 1372 # hard to isolate.  We choose bash over ksh over sh; though
 1373 # this may be iffy (ksh appears to be just as busted some places).
 1374 #
 1375 test "$SCRIPT_SH" || SCRIPT_SH=`findApp bash $PATH`
 1376 test "$SCRIPT_SH" || SCRIPT_SH=`findApp ksh $PATH`
 1377 test "$SCRIPT_SH" || SCRIPT_SH=`findApp sh $PATH`
 1378 if [ -z "$SCRIPT_SH" ]; then
 1379     Note ""
 1380     Note "WARNING, could not locate a suitable shell for processing the command"
 1381     Note "         scripts included in this distribution; using a default value"
 1382     Note "         /bin/sh."
 1383     Note ""
 1384     SCRIPT_SH=/bin/sh
 1385 else
 1386     Note "Using $SCRIPT_SH to process command scripts."
 1387 # Security stuff
 1388     case $SCRIPT_SH in
 1389     */sh)   ;;
 1390     */ksh)  NOCLOBBER_ON='"set -o noclobber"'
 1391         NOCLOBBER_OFF='"set +o noclobber"' ;;
 1392     */bash) NOCLOBBER_ON='"set -o noclobber"'
 1393         NOCLOBBER_OFF='"set +o noclobber"' ;;
 1394     esac
 1395 fi
 1396 
 1397 makeDefs()
 1398 {
 1399     WARNING="Warning, this file was automatically created by the HylaFAX configure script"
 1400     $RM confsed1; dumpvars "$VAR1" | sort>confsed1
 1401     $RM confsed2; dumpvars "$VAR2" | sort>confsed2
 1402     unset POSIXLY_CORRECT
 1403     $RM xdefs; sed -f confsed1 $SRCDIR/defs.in | sed -f confsed2 >$1
 1404     POSIXLY_CORRECT=1 ; export POSIXLY_CORRECT
 1405 }
 1406 
 1407 # NB: save original values for use in checks below
 1408 OTIFFINC="${TIFFINC}"; x="`relativize ${TIFFINC}`"; TIFFINC="$x"
 1409 OZLIBINC="${ZLIBINC}"; x="`relativize ${ZLIBINC}`"; ZLIBINC="$x"
 1410 OREGEXINC="${REGEXINC}"; x="`relativize ${REGEXINC}`"; REGEXINC="$x"
 1411 makeDefs xdefs
 1412 
 1413 #
 1414 # runMake target rules ...
 1415 #
 1416 runMakeX()
 1417 {
 1418     target="$1"; shift
 1419     $RM $target
 1420     (echo DEPTH=.; echo SRCDIR=.; cat xdefs;
 1421        for i in "$@"; do
 1422       echo "$i";
 1423        done
 1424     )>confMakefile
 1425     captureX ${MAKE} -f confMakefile $target
 1426     return
 1427 }
 1428 runMake()
 1429 {
 1430     runMakeX "$@" >&5
 1431     return
 1432 }
 1433 
 1434 #
 1435 # Verify everything is setup for the C++ runtime environment.
 1436 #
 1437 CheckForCXXRuntime()
 1438 {
 1439 cat>t.c++<<EOF
 1440 #include <iostream>
 1441 int main(){ std::cout << "Hello World!" << std::endl; return 0;}
 1442 EOF
 1443     runMake t "t:; \${C++F} \${C++FILE} t.c++${MAKECXXOVERRIDE}"
 1444 }
 1445 CheckForCXXRuntime || {
 1446     cat 1>&2 <<EOF
 1447 
 1448 Missing C++ runtime support for $CXX ($CXXCOMPILER).
 1449 
 1450 Compilation of the following test program failed:
 1451 
 1452 ----------------------------------------------------------
 1453 EOF
 1454     cat t.c++ 1>&2
 1455     cat 1>&2 <<EOF
 1456 ----------------------------------------------------------
 1457 
 1458 Usually this is because you do not have a standard C++ library
 1459 installed on your system or you have installed it in a non-standard
 1460 location.  If you do not have a C++ library installed, then you must
 1461 install it.  If it is installed in a non-standard location, then you
 1462 should configure the compiler so that it will automatically be found.
 1463 
 1464 (For recent gcc releases this is libstdc++, for older gcc - libg++)
 1465 EOF
 1466     boom
 1467 }
 1468 
 1469 #
 1470 # Verify C++ built executables properly handle global
 1471 # static variables with constructors.
 1472 #
 1473 CheckForCXXGlobalConstructors()
 1474 {
 1475 cat>t.c++<<EOF
 1476 class foo {
 1477 private:
 1478     int a;
 1479 public:
 1480     foo() { a = -1; }
 1481     int isInitialized() { return a == -1; }
 1482 };
 1483 static foo instanceOfFoo;
 1484 int main() { return instanceOfFoo.isInitialized() ? 0 : 1; }
 1485 EOF
 1486     runMake t "t:; \${C++F} \${C++FILE} t.c++${MAKECXXOVERRIDE}" && ./a.out
 1487 }
 1488 CheckForCXXGlobalConstructors || {
 1489     cat 1>&2 <<EOF
 1490 
 1491 Broken C++ handling of global constructors ($CXX/$CXXCOMPILER).
 1492 
 1493 Compilation or execution of the following test program failed:
 1494 
 1495 ----------------------------------------------------------
 1496 EOF
 1497     cat t.c++ 1>&2
 1498     cat 1>&2 <<EOF
 1499 ----------------------------------------------------------
 1500 
 1501 This program tests whether or not the C++ compilation support properly
 1502 handles global static variables with constructors.  A working C++
 1503 compilation environment is expected to arrange that global variables
 1504 that have a constructor function (foo::foo() above) be called prior to
 1505 the start of main().  HylaFAX will not operate properly if the C++
 1506 compilation environment does not correctly implement this.
 1507 
 1508 EOF
 1509     if [ $ISGXX = yes ]; then
 1510     if expr $CXX : '.*g++.*' >/dev/null 2>&1; then
 1511         cat 1>&2 <<EOF
 1512 When using GNU gcc this can sometimes happen if gcc is improperly
 1513 configured; consult your local GNU guru/support person for help with
 1514 this problem.
 1515 
 1516 EOF
 1517     else
 1518         cat 1>&2 <<EOF
 1519 When using GNU gcc to compile C++ programs this can sometimes happen
 1520 when g++ is not used to link executables.  You might try setting
 1521 CXX to "g++" (or similar) in a config.local file or on the command
 1522 line.  Otherwise you should consult your local GNU guru/support person
 1523 for help with this problem.
 1524 
 1525 EOF
 1526     fi
 1527     fi
 1528     boom
 1529 }
 1530 
 1531 #
 1532 # Look for a library using a known (unique) function.
 1533 #
 1534 CheckForLibrary()
 1535 {
 1536     f=$1; shift
 1537     libs="$@";
 1538     cat>t.c<<EOF
 1539 extern int $f();
 1540 int t(void) { $f(); return 0; }
 1541 int main(int argc, char *argv[]){ t(); return 0; }
 1542 EOF
 1543     capture cat t.c
 1544     runMake t "t:; \${CCF} t.c $libs"
 1545 }
 1546 
 1547 #
 1548 # Look for a library using a known (unique) function.
 1549 #
 1550 CheckForLibraryWithArgs()
 1551 {
 1552     l=$1; shift
 1553     f=$1; shift
 1554     a=$1; shift
 1555     libs="$@";
 1556     cat>t.c<<EOF
 1557 #include <$l>
 1558 int t(void) { $f($a); return 0; }
 1559 int main(int argc, char *argv[]){ t(); return 0; }
 1560 EOF
 1561     capture cat t.c
 1562     runMake t "t:; \${CCF} t.c $libs"
 1563 }
 1564 
 1565 #
 1566 # Look for an include file.
 1567 #
 1568 CheckForIncludeFile()
 1569 {
 1570     (for i do
 1571     echo "#include \"$i\""
 1572      done)>t.c++
 1573     capture cat t.c++
 1574     runMake t "t:; \${C++F} \${C++FILE} -E t.c++${MAKECXXOVERRIDE}"
 1575 }
 1576 
 1577 #
 1578 # Look for a #define in system include files.
 1579 #
 1580 AddDefine()
 1581 {
 1582    echo '#ifndef' $1
 1583    echo '#define' "$2"
 1584    echo '#endif'
 1585    Note '... add #define for' "$1"
 1586 }
 1587 CheckForDefine()
 1588 {
 1589     def=$1; shift
 1590     (for i do
 1591     echo "#include \"$i\""
 1592      done
 1593      for i in "#ifdef $def" "FOUND" "#endif"; do
 1594     echo "$i"
 1595      done
 1596     )>t.c
 1597     capture cat t.c
 1598     runMakeX t 't:; ${CCF} -E t.c' | grep FOUND >&5
 1599 }
 1600 CheckDefine()
 1601 {
 1602     def=$1; shift
 1603     decl=$1; shift
 1604     CheckForDefine "$def" "$@" || AddDefine "$def" "$decl"
 1605 }
 1606 
 1607 if [ "$REGEX" = "auto" ]; then
 1608     Note "Checking for regular expression library support"
 1609     CheckForLibrary regexec "" &&
 1610         CheckForIncludeFile regex.h &&
 1611             CheckForDefine REG_STARTEND regex.h && {
 1612                 REGEX=no
 1613             }
 1614     if [ "$REGEX" = "no" ]; then
 1615         LIBREGEX=''
 1616         REGEXINC=''
 1617         Note "... found. Using system regular expression support."
 1618     else
 1619         REGEX=yes
 1620         LIBREGEX='-L${DEPTH}/regex -lregex'
 1621         REGEXINC='-I${DEPTH}/${TOPSRCDIR}/regex'
 1622         Note "... not found. Using built-in regular expression support."
 1623     fi
 1624 fi
 1625 if [ "$SGI2FAX" = auto ]; then
 1626     if CheckForLibrary iopen -limage && CheckForIncludeFile gl/image.h; then
 1627     Note "Looks like there is support for SGI RGB images, configuring sgi2fax."
 1628     SGI2FAX=yes
 1629     else
 1630     SGI2FAX=no
 1631     fi
 1632 fi
 1633 if [ "$LIBMALLOC" = auto ]; then
 1634     if CheckForLibrary mallopt -lmalloc; then
 1635     Note "Looks like -lmalloc is here, using it for memory allocation."
 1636     LIBMALLOC=yes
 1637     else
 1638     LIBMALLOC=no
 1639     fi
 1640 fi
 1641 if [ "$LIBSUN" = auto ]; then
 1642     if CheckForLibrary getpwnam -lsun; then
 1643     Note "Looks like -lsun is here, using it for NIS passwd & group stuff."
 1644     LIBSUN=yes
 1645     else
 1646     LIBSUN=no
 1647     fi
 1648 fi
 1649 
 1650 #
 1651 # PAM libraries are slightly different.  So we run some tests to try to
 1652 # distinguish between them.
 1653 #
 1654 CheckPAMType()
 1655 {
 1656     Note "... checking PAM library version"
 1657     cat>t.c++<<EOF
 1658 #include "security/pam_appl.h"
 1659 int
 1660 pamconv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata)
 1661 {
 1662     return(0);
 1663 }
 1664 int main()
 1665 {
 1666     struct pam_conv conv = { pamconv };
 1667 }
 1668 EOF
 1669     if runMake t "t:; \${C++F} $PAMLIBS \${C++FILE} t.c++${MAKECXXOVERRIDE}"; then
 1670     echo '#define STRUCT_PAM_MESSAGE const struct pam_message'
 1671     else
 1672     echo '#define STRUCT_PAM_MESSAGE struct pam_message'
 1673     fi
 1674     case $TARGET in
 1675     *-hpux11*)  echo '#define PAM_MSG_VERSION';;
 1676     *-aix)      echo '#define PAM_MSG_VERSION 1';;
 1677     esac
 1678 }
 1679 
 1680 HAVE_PAM="/*#define HAVE_PAM 1*/"
 1681 PAMLIBS=""
 1682 if [ "$DISABLE_PAM" != "yes" ]; then
 1683     Note "Checking for PAM (Pluggable Authentication Module) support"
 1684     CheckForLibrary pam_authenticate -lpam &&
 1685         CheckForIncludeFile security/pam_appl.h && {
 1686             HAVE_PAM="#define HAVE_PAM 1"
 1687             PAMLIBS="-lpam"
 1688         }
 1689     if [ "x$PAMLIBS" = "x" ]; then
 1690         Note "... not found. Disabling PAM support"
 1691         else
 1692         Note "... found. Enabling PAM support"
 1693     fi
 1694 else
 1695     Note "Disabling PAM support"
 1696 fi
 1697 HAVE_SSL="/*#define HAVE_SSL 1*/"
 1698 HAVE_FLEXSSL="/*#define HAVE_FLEXSSL 1*/"
 1699 SSL=""
 1700 FLEXSSL=""
 1701 if [ "$DISABLE_SSL" != "yes" ]; then
 1702     Note "Checking for OpenSSL library support"
 1703     CheckForLibrary TLSv1_2_method -lssl -lcrypto &&
 1704         CheckForIncludeFile openssl/ssl.h && {
 1705             HAVE_SSL="#define HAVE_SSL 1"
 1706             SSL="-lssl -lcrypto"
 1707         }
 1708     if [ "x$SSL" = "x" ]; then
 1709         Note "... not found. Disabling OpenSSL library support"
 1710     else
 1711         Note "... found. Enabling OpenSSL library support"
 1712         Note "Checking for version-flexible OpenSSL library support"
 1713         CheckForLibrary TLS_method -lssl -lcrypto &&
 1714             CheckForIncludeFile openssl/ssl.h && {
 1715                 HAVE_FLEXSSL="#define HAVE_FLEXSSL 1"
 1716                 FLEXSSL=yes
 1717             }
 1718         if [ "x$FLEXSSL" = "x" ]; then
 1719             Note "... found. Enabling OpenSSL library support (not version-flexible)."
 1720         else
 1721             Note "... found. Enabling version-flexible OpenSSL library support."
 1722         fi
 1723     fi
 1724 else
 1725     Note "Disabling OpenSSL library support"
 1726 fi
 1727 HAVE_JBIG="/*#define HAVE_JBIG 1*/"
 1728 LIBJBIG=""
 1729 if [ "$DISABLE_JBIG" != "yes" ]; then
 1730     Note "Checking for JBIG library support"
 1731     CheckForLibrary jbg_enc_init -ljbig &&
 1732         CheckForIncludeFile jbig.h && {
 1733             HAVE_JBIG="#define HAVE_JBIG 1"
 1734             LIBJBIG="-ljbig"
 1735         }
 1736     if [ "x$LIBJBIG" = "x" ]; then
 1737         Note "... not found. Disabling JBIG support"
 1738     else
 1739         Note "... found. Enabling JBIG support"
 1740     fi
 1741 else
 1742     Note "Disabling JBIG support"
 1743 fi
 1744 HAVE_JPEG="/*#define HAVE_JPEG 1*/"
 1745 LIBJPEG=""
 1746 if [ "$DISABLE_JPEG" != "yes" ]; then
 1747     Note "Checking for JPEG library support"
 1748     CheckForLibrary jpeg_std_error -ljpeg &&
 1749         CheckForIncludeFile jpeglib.h && {
 1750             HAVE_JPEG="#define HAVE_JPEG 1"
 1751             LIBJPEG="-ljpeg"
 1752         }
 1753     if [ "x$LIBJPEG" = "x" ]; then
 1754         Note "... not found. Disabling JPEG library support"
 1755     else
 1756         Note "... found. Enabling JPEG library support"
 1757     fi
 1758 else
 1759     Note "Disabling JPEG library support"
 1760 fi
 1761 HAVE_LCMS="/*#define HAVE_LCMS 1*/"
 1762 HAVE_LCMS2="/*#define HAVE_LCMS2 1*/"
 1763 LIBLCMS=""
 1764 if [ "$DISABLE_LCMS" != "yes" ]; then
 1765     Note "Checking for Little CMS library support"
 1766     CheckForLibrary cmsOpenProfileFromMem -llcms2 &&
 1767         CheckForIncludeFile lcms2.h && {
 1768             HAVE_LCMS2="#define HAVE_LCMS2 1"
 1769             LIBLCMS="-llcms2"
 1770         }
 1771     if [ "x$LIBLCMS" = "x" ]; then
 1772         CheckForLibrary cmsOpenProfileFromMem -llcms &&
 1773             CheckForIncludeFile lcms.h && {
 1774                 HAVE_LCMS="#define HAVE_LCMS 1"
 1775                 LIBLCMS="-llcms"
 1776             }
 1777     fi
 1778     if [ "x$LIBLCMS" = "x" ]; then
 1779         Note "... not found. Disabling Little CMS support"
 1780     else
 1781         Note "... found. Enabling Little CMS support"
 1782     fi
 1783 else
 1784     Note "Disabling Little CMS support"
 1785 fi
 1786 HAVE_LDAP="/*#define HAVE_LDAP 1*/"
 1787 LDAPLIBS=""
 1788 if [ "$DISABLE_LDAP" != "yes" ]; then
 1789     Note "Checking for LDAP (Lightweight Directory Access Protocol) support"
 1790     CheckForLibrary ldap_initialize -lldap &&
 1791         CheckForLibrary ber_get_null -llber &&
 1792             CheckForIncludeFile ldap.h && {
 1793                 HAVE_LDAP="#define HAVE_LDAP 1"
 1794                 LDAPLIBS="-lldap -llber -lresolv"
 1795             }
 1796     if [ "x$LDAPLIBS" = "x" ]; then
 1797         Note "... not found. Disabling LDAP support"
 1798         else
 1799         Note "... found. Enabling LDAP support"
 1800     fi
 1801 else
 1802     Note "Disabling LDAP support"
 1803 fi
 1804 CheckForLibrary crypt -lc || {
 1805     #
 1806     # FreeBSD-2.1 in particular needs -lcrypt.
 1807     # SCO sometime has -lcrypt_d (domestic) and
 1808     #    sometimes -lcrypt_i (import?)
 1809     #
 1810     for i in -lcrypt -lcrypt_d -lcrypt_i; do
 1811     if CheckForLibrary crypt $i; then
 1812         Note "Looks like $i is needed for crypt."
 1813         MACHDEPLIBS="$MACHDEPLIBS $i"
 1814         break;
 1815     fi
 1816     done
 1817 }
 1818 CheckForLibraryWithArgs time.h strftime "(void*)0, 0, (void*)0, (void*)0" -lc || {
 1819     #
 1820     # SCO has strftime in -lintl.
 1821     #
 1822     if CheckForLibrary strftime -lintl; then
 1823     Note "Looks like -lintl is needed for strftime."
 1824     MACHDEPLIBS="$MACHDEPLIBS -lintl"
 1825     else
 1826     cat 1>&2 <<EOF
 1827 No strftime function located in system libraries.
 1828 
 1829 The strftime function used to format date&time information was not located
 1830 in the normal C library or in the -lintl library (present on some systems).
 1831 This software expects this to be available and will not compile without it.
 1832 If this function is located in a non-standard location you can specify the
 1833 library in the MACHDEPLIBS configuration parameter.  Otherwise you should
 1834 figure out why the usual testing done by this script failed; consult the
 1835 diagnostics in the config.log file for more information.
 1836 EOF
 1837     boom
 1838     fi
 1839 }
 1840 CheckForLibrary socket -lc || {
 1841     #
 1842     # Socket support is not in normal C library, check
 1843     # for SVR4-style networking w/ -lsocket & -lnsl
 1844     #
 1845     if CheckForLibrary socket -lsocket -lnsl; then
 1846     Note "Looks like -lsocket & -lnsl are needed for socket support."
 1847     MACHDEPLIBS="$MACHDEPLIBS -lsocket -lnsl"
 1848     elif CheckForLibrary socket -linet -lnsl_s; then
 1849     Note "Looks like -linet & -lnsl_s are needed for socket support."
 1850     MACHDEPLIBS="$MACHDEPLIBS -linet -lnsl_s"
 1851     elif CheckForLibrary socket -lsocket; then
 1852     Note "Looks like -lsocket is needed for socket support."
 1853     MACHDEPLIBS="$MACHDEPLIBS -lsocket"
 1854     else
 1855     cat 1>&2 <<EOF
 1856 No socket networking support located in system libraries.
 1857 
 1858 The socket function used to create a network connection was not located
 1859 in the normal C library or in the -lsocket or -linet libraries (present
 1860 mainly on SVR4-style systems).  This software expects this to be
 1861 available and will not compile without it.  If this function is located
 1862 in a non-standard location you can specify the needed libraries in the
 1863 MACHDEPLIBS configuration parameter.  Otherwise you should figure out
 1864 why the usual testing done by this script failed; consult the
 1865 diagnostics in the config.log file for more information.
 1866 EOF
 1867     boom
 1868     fi
 1869 }
 1870 
 1871 CheckForLibrary inet_aton -lc || {
 1872     CheckForLibrary inet_aton -lresolv && {
 1873     MACHDEPLIBS="$MACHDEPLIBS -lresolv"
 1874     }
 1875 }
 1876 
 1877 if CheckForLibrary logwtmp -lutil; then
 1878     Note "Looks like -lutil is needed for wtmp file logging."
 1879     MACHDEPLIBS="$MACHDEPLIBS -lutil"
 1880     HAS_LOGWTMP=yes
 1881 else
 1882     HAS_LOGWTMP=no
 1883 fi
 1884 CheckForLibrary ftruncate -lc || {
 1885     CheckForLibrary chsize -lx && {
 1886     Note "Looks like -lx is needed for chsize (used to emulate ftruncate)."
 1887     MACHDEPLIBS="$MACHDEPLIBS -lx"
 1888     }
 1889 }
 1890 CheckForLibrary flock -lc || {
 1891     CheckForLibrary flock -lbsd && {
 1892     Note "Looks like -lbsd is needed for flock."
 1893     MACHDEPLIBS="$MACHDEPLIBS -lbsd"
 1894     }
 1895 }
 1896 for f in openlog pututxline; do
 1897     CheckForLibrary $f -lc || {
 1898     CheckForLibrary $f -lgen && {
 1899         Note "Looks like -lgen is needed for $f."
 1900         MACHDEPLIBS="$MACHDEPLIBS -lgen"
 1901         break;
 1902     }
 1903     }
 1904 done
 1905 if [ "$ISGXX" = yes ]; then
 1906     if [ -z "$CXXRUNTIME" ]; then
 1907     for f in memmove strdup; do
 1908         if [ $f = "memmove" ]; then
 1909         CheckForLibraryWithArgs string.h $f "(void*)0, (void*)0, 0" -lc || {
 1910             CheckForLibraryWithArgs string.h $f "(void*0), (void*)0, 0" -lg++ && {
 1911             Note "Looks like we need -lg++ for $f"
 1912             MACHDEPLIBS="$MACHDEPLIBS -lg++"
 1913             break;
 1914             }
 1915         }
 1916         else
 1917         CheckForLibraryWithArgs string.h $f "(void*)0" -lc || {
 1918             CheckForLibraryWithArgs string.h $f "(void*)0" -lg++ && {
 1919             Note "Looks like we need -lg++ for $f"
 1920             MACHDEPLIBS="$MACHDEPLIBS -lg++"
 1921             break;
 1922             }
 1923         }
 1924         fi
 1925     done
 1926     fi
 1927     for f in strtoul strerror memmove random; do
 1928     if [ $f = "memmove" ]; then
 1929         CheckForLibraryWithArgs string.h $f "(void*)0, (void*)0, 0" -lc || {
 1930         CheckForLibraryWithArgs string.h $f "(void*0), (void*)0, 0" -liberty && {
 1931             Note "Looks like we need -liberty for $f"
 1932             MACHDEPLIBS="$MACHDEPLIBS -liberty"
 1933             break;
 1934         }
 1935         }
 1936     elif [ $f = "strerror" ]; then
 1937         CheckForLibraryWithArgs string.h $f "0" -lc || {
 1938         CheckForLibraryWithArgs string.h $f "0" -liberty && {
 1939             Note "Looks like we need -liberty for $f"
 1940             MACHDEPLIBS="$MACHDEPLIBS -liberty"
 1941             break;
 1942         }
 1943         }
 1944     else
 1945         CheckForLibraryWithArgs string.h $f "" -lc || {
 1946         CheckForLibraryWithArgs string.h $f "" -liberty && {
 1947             Note "Looks like we need -liberty for $f"
 1948             MACHDEPLIBS="$MACHDEPLIBS -liberty"
 1949             break;
 1950         }
 1951         }
 1952     fi
 1953     done
 1954 fi
 1955 CheckForLibraryWithArgs math.h floor "0" -lm && {
 1956     Note "Looks like -lm is the library for math functions."
 1957     MACHDEPLIBS="$MACHDEPLIBS -lm"
 1958 }
 1959 MACHDEPLIBS="$MACHDEPLIBS $CXXRUNTIME"
 1960 test "$LIBSUN" = yes && MACHDEPLIBS="$MACHDEPLIBS -lsun"
 1961 test "$LIBMALLOC" = yes && MACHDEPLIBS="$MACHDEPLIBS -lmalloc"
 1962 
 1963 #
 1964 # Figure out if certain system-specific interfaces are
 1965 # supported.  We craft a port.h file that has external
 1966 # declarations for missing routines that are required by
 1967 # the system and modify defs to reflect which optional
 1968 # interfaces are supported.
 1969 #
 1970 
 1971 EmitCPlusPlusPrologue()
 1972 {
 1973     echo '/*'
 1974     echo ' * Warning, this file was automatically created by the HylaFAX configure script'
 1975     echo ' * VERSION:   ' $VERSION
 1976     echo ' * DATE:  ' $DATE
 1977     echo ' * TARGET:    ' $TARGET
 1978     echo ' * RELEASE:   ' $RELEASE
 1979     if [ $ISGCC = yes ]; then
 1980     echo ' * CCOMPILER: ' ${CCOMPILER}-${GCCversion}
 1981     else
 1982     echo ' * CCOMPILER: ' $CCOMPILER
 1983     fi
 1984     if [ $ISGXX = yes ]; then
 1985     echo ' * CXXCOMPILER:   ' ${CXXCOMPILER}-${GCCversion}
 1986     else
 1987     echo ' * CXXCOMPILER:   ' $CXXCOMPILER
 1988     fi
 1989     echo ' */'
 1990     echo "#ifndef $1"
 1991     echo "#define $1 1"
 1992     echo '#ifdef __cplusplus'
 1993     echo 'extern "C" {'
 1994     echo '#endif'
 1995 }
 1996 
 1997 EmitCPlusPlusEpilogue()
 1998 {
 1999     echo '#ifdef __cplusplus'
 2000     echo '}'
 2001     echo '#endif'
 2002     echo '#endif'
 2003 }
 2004 
 2005 releaseAtLeast()
 2006 {
 2007     expr $RELEASE \>= $1 >/dev/null 2>&1
 2008 }
 2009 
 2010 #
 2011 # Emit the port.h definitions that reflect
 2012 # the system configuration.
 2013 #
 2014 EmitConfigurationDefinitions()
 2015 {
 2016     #
 2017     # Do bool stuff
 2018     #
 2019     if [ "$CONFIG_NEEDBOOL" = "yes" ]; then
 2020         Note "... adding definition for C++ bool type"
 2021         echo
 2022         echo "#define NEED_BOOL"
 2023         echo
 2024     fi
 2025 
 2026     #
 2027     # On some systems the argument for ioctl(fd, TIOCMBIS, arg)
 2028     # is passed by value and some by reference.
 2029     # This can not be deduced with a dynamic check.
 2030     #
 2031     test "$CONFIG_TIOCMBIS_ARG_REF" || {
 2032     case $TARGET in
 2033     *-sysv4*)   CONFIG_TIOCMBISBYREF=yes;;
 2034     *-sysv5*)   CONFIG_TIOCMBISBYREF=yes;;
 2035     *-linux*)   CONFIG_TIOCMBISBYREF=yes;;
 2036     *-sunos*)   CONFIG_TIOCMBISBYREF=yes;;
 2037     *)      CONFIG_TIOCMBISBYREF=yes;;
 2038     esac
 2039     }
 2040     if [ "$CONFIG_TIOCMBISBYREF" = yes ]; then
 2041     Note "... using call-by-reference for TIOCMBIS ioctl"
 2042     echo "#define CONFIG_TIOCMBISBYREF $CONFIG_TIOCMBISBYREF"
 2043     else
 2044     Note "... using call-by-value for TIOCMBIS ioctl"
 2045     fi
 2046     
 2047     #
 2048     # On some systems it's necessary to include
 2049     # <sys/stream.h> and <sys/ptem.h> to get the
 2050     # necessary definitions for TIOCWINSZ.  This
 2051     # should be deduced with a dynamic check.
 2052     #
 2053     test "$CONFIG_WINSZHACK" || {
 2054     case $TARGET in
 2055     *-*-sco*)   CONFIG_WINSZHACK=yes;;
 2056     *-isc*)     CONFIG_WINSZHACK=yes;;
 2057     *)      CONFIG_WINSZHACK=no;;
 2058     esac
 2059     }
 2060     if [ "$CONFIG_WINSZHACK" = yes ]; then
 2061     Note "... enable additional include files for TIOCGWINSZ"
 2062     echo "#define CONFIG_WINSZHACK"
 2063     fi
 2064 
 2065     #
 2066     # On some systems the server does not work properly
 2067     # if a recursive call is made to the dispatcher to
 2068     # poll for an message on the FIFO file that says to
 2069     # abort an outbound or inbound job.   The only know
 2070     # workaround for this problem is to ignore messages
 2071     # while processing a job.
 2072     #
 2073     test "$CONFIG_ABORTBUG" || {
 2074     case $TARGET in
 2075     *-aix*)     CONFIG_ABORTBUG=yes;;
 2076     *-hpux*)    CONFIG_ABORTBUG=yes;;
 2077     *)      CONFIG_ABORTBUG=no;;
 2078     esac
 2079     }
 2080     if [ "$CONFIG_ABORTBUG" = yes ]; then
 2081     Note "... disable support for aborting sends & receives"
 2082     echo '#define SERVERABORTBUG'
 2083     fi
 2084 
 2085     #
 2086     # On some systems redirecting stdout to the controlling
 2087     # tty causes stty to issue an annoying warning message.
 2088     # This should probably be deduced with a dynamic test.
 2089     #
 2090     test "$CONFIG_NOSTDINDUP" || {
 2091     case $TARGET in
 2092     *-freebsd*) CONFIG_NOSTDINDUP=yes;;
 2093     *)      CONFIG_NOSTDINDUP=no;;
 2094     esac
 2095     }
 2096     if [ "$CONFIG_NOSTDINDUP" = yes ]; then
 2097     Note "... assuming stty bitches when stdout is set to stdin"
 2098     echo "#define ONDELAY_NOSTDINDUP"
 2099     fi
 2100     #
 2101     # Some systems cannot handle re-opening the tty device
 2102     # after the modem is reset.  This is true for modems
 2103     # attached to some terminal servers and also on HP-UX
 2104     # where the modem control state is lost across opens.
 2105     # Basically if the OS and modem correctly handle toggling
 2106     # DTR to reset the modem then it's safe to configure
 2107     # the software to not re-open the device.
 2108     #
 2109     test "$CONFIG_NOREOPEN" || {
 2110     case $TARGET in
 2111     *-hpux*)    CONFIG_NOREOPEN=yes;;
 2112     *)      CONFIG_NOREOPEN=no;;
 2113     esac
 2114     }
 2115     if [ "$CONFIG_NOREOPEN" = yes ]; then
 2116     Note "... don't reopen the tty device after reset"
 2117     echo "#define CONFIG_NOREOPEN"
 2118     fi
 2119     #
 2120     # Workarounds for systems with system include files
 2121     # that have incorrect function declarations (wrong
 2122     # parameter types that require explicit casts to make
 2123     # the code compile with certain compilers).
 2124     #
 2125     test "$CONFIG_BADEXECVPROTO" || {       # char* const* vs. const char**
 2126     case $TARGET in
 2127     *-*-sco3.2v5.*) CONFIG_BADEXECVPROTO=no;;
 2128     *-*-sco*)   CONFIG_BADEXECVPROTO=yes;;
 2129     *)      CONFIG_BADEXECVPROTO=no;;
 2130     esac
 2131     }
 2132     if [ "$CONFIG_BADEXECVPROTO" = yes ]; then
 2133     Note "... workaround incorrect execv function declaration"
 2134     echo "#define CONFIG_BADEXECVPROTO"
 2135     fi
 2136     test "$CONFIG_BADEXECVEPROTO" || {      # char* const* vs. const char**
 2137     case $TARGET in
 2138     *-*-sco3.2v5.*) CONFIG_BADEXECVEPROTO=no;;
 2139     *-*-sco*)   CONFIG_BADEXECVEPROTO=yes;;
 2140     *)      CONFIG_BADEXECVEPROTO=no;;
 2141     esac
 2142     }
 2143     if [ "$CONFIG_BADEXECVEPROTO" = yes ]; then
 2144     Note "... workaround incorrect execve function declaration"
 2145     echo "#define CONFIG_BADEXECVEPROTO"
 2146     fi
 2147     test "$CONFIG_BADGETOPTPROTO" || {      # char* const* vs. char**
 2148     case $TARGET in
 2149     *-aix*)     CONFIG_BADGETOPTPROTO=yes;;
 2150     *-*-sco3.2v4.*) CONFIG_BADGETOPTPROTO=yes;;
 2151     *)      CONFIG_BADGETOPTPROTO=no;;
 2152     esac
 2153     }
 2154     if [ "$CONFIG_GETOPTPROTO" = yes ]; then
 2155     Note "... workaround incorrect getopt function declaration"
 2156     echo "#define CONFIG_GETOPTPROTO"
 2157     fi
 2158     test "$CONFIG_BADSELECTPROTO" || {      # int* vs. fd_set*
 2159     case $TARGET in
 2160     *-hpux10.20*)   CONFIG_BADSELECTPROTO=no;;
 2161     *-hpux11*)  CONFIG_BADSELECTPROTO=no;;
 2162     *-hpux*)    CONFIG_BADSELECTPROTO=yes;;
 2163     *)      CONFIG_BADSELECTPROTO=no;;
 2164     esac
 2165     }
 2166     if [ "$CONFIG_BADSELECTPROTO" = yes ]; then
 2167     Note "... workaround incorrect select function declaration"
 2168     echo "#define CONFIG_BADSELECTPROTO"
 2169     fi
 2170     #
 2171     # Select the maximum fax UID.  This value is stored
 2172     # in the GID of files so must be constrained by any
 2173     # system limitations.  The maximum value is used for
 2174     # anonymous logins.  The default value of 60002 comes
 2175     # from NFS/nobody usage on various systems.
 2176     #
 2177     test "$CONFIG_MAXGID" || {
 2178     case $TARGET in
 2179     *-*-sco*)   CONFIG_MAXGID=60000;;
 2180     *-sysv5UnixWare*)   CONFIG_MAXGID=60000;;   # UnixWare 7
 2181     *-sysv5OpenUNIX*)   CONFIG_MAXGID=60000;;   # OpenUNIX 8
 2182     *-sysv5SCO_SV*)     CONFIG_MAXGID=60000;;   # OpenServer 6
 2183     *-hpux*)    CONFIG_MAXGID=60000;;
 2184     *)      CONFIG_MAXGID=60002;;   # default
 2185     esac
 2186     }
 2187     if [ "$CONFIG_MAXGID" ]; then
 2188     if [ "$CONFIG_MAXGID" -le 60002 ]; then
 2189         Note "... constrain client IDs to be <= $CONFIG_MAXGID"
 2190         echo "#define CONFIG_MAXGID $CONFIG_MAXGID"
 2191     else
 2192         Note "... max client ID too large ($CONFIG_MAXGID); using default"
 2193     fi
 2194     fi
 2195 }
 2196 
 2197 #
 2198 # Look for a function in one of the standard libraries
 2199 # or one of the machine-dependent libraries selected above.
 2200 #
 2201 CheckForFunc()
 2202 {
 2203     echo "#include <stdlib.h>" > t.c
 2204     echo "extern int $1(); int main(int argc, char *argv[]){$1($2);exit(0);}" >> t.c
 2205     capture cat t.c
 2206     runMake t "t:; \${CC} t.c ${MACHDEPLIBS}"
 2207 }
 2208 CheckForStdFunc()
 2209 {
 2210     echo "#include <stdlib.h>" > t.c
 2211     echo "main(){$1($2);exit(0);}" >> t.c
 2212     capture cat t.c
 2213     runMake t "t:; \${CC} t.c ${MACHDEPLIBS}"
 2214 }
 2215 CheckForStdioFunc()
 2216 {
 2217     echo "#include <stdlib.h>" > t.c
 2218     echo "#include <stdio.h>" >> t.c
 2219     echo "main(){$1($2);exit(0);}" >> t.c
 2220     capture cat t.c
 2221     runMake t "t:; \${CC} t.c ${MACHDEPLIBS}"
 2222 }
 2223 CheckForUnistdFunc()
 2224 {
 2225     echo "#include <stdlib.h>" > t.c
 2226     echo "#include <unistd.h>" >> t.c
 2227     echo "main(){$1($2);exit(0);}" >> t.c
 2228     capture cat t.c
 2229     runMake t "t:; \${CC} t.c ${MACHDEPLIBS}"
 2230 }
 2231 
 2232 #
 2233 # Look for a function declaration in system include files.
 2234 #
 2235 AddFuncDecl()
 2236 {
 2237     echo "$2";
 2238     Note "... add function prototype for $1"
 2239 }
 2240 CheckForFuncDecl()
 2241 {
 2242     f=$1; shift
 2243     (for i do
 2244     echo "#include \"$i\""
 2245      done)>t.c++
 2246     capture cat t.c++
 2247     runMakeX t "t:; \${C++F} \${C++FILE} -E t.c++${MAKECXXOVERRIDE}" |\
 2248      stripComments |\
 2249      awk '{while($0~/[,(][ \t]*$/){printf"%s",$0;getline}print}' |\
 2250      grep "$f[ ]*(.*)" >&5
 2251     return
 2252 }
 2253 CheckFuncDecl()
 2254 {
 2255     f=$1; shift
 2256     decl=$1; shift
 2257     CheckForFuncDecl "$f" "$@" || AddFuncDecl "$f" "$decl"
 2258 }
 2259 
 2260 #
 2261 # Look for a variable declaration in system include files.
 2262 #
 2263 CheckForVarDecl()
 2264 {
 2265     v="$1"; shift
 2266     (for i do
 2267     echo "#include \"$i\""
 2268      done)>t.c++
 2269     capture cat t.c++
 2270     runMakeX t "t:; \${C++F} \${C++FILE} -E t.c++${MAKECXXOVERRIDE}" |\
 2271     stripComments |\
 2272     grep "$v" >&5
 2273     return
 2274 }
 2275 CheckVarDecl()
 2276 {
 2277     v="$1"; shift
 2278     decl="$1"; shift
 2279     CheckForVarDecl "$v" "$@" || \
 2280     (echo "$decl"; Note "... add declaration $decl")
 2281 }
 2282 
 2283 #
 2284 # Look for a #define with a positive value in system include files.
 2285 # This is especially useful for POSIX defines which may be defined
 2286 # to -1 or 0 when the functionnality is not supported.
 2287 #
 2288 CheckForPositiveDefine()
 2289 {
 2290     def=$1; shift
 2291     (for i do
 2292     echo "#include \"$i\""
 2293      done
 2294      for i in "#if defined($def) && ($def > 0L)" "FOUND" "#endif"; do
 2295     echo "$i"
 2296      done
 2297     )>t.c
 2298     capture cat t.c
 2299     runMakeX t 't:; ${CCF} -E t.c' | grep FOUND >&5
 2300 } 
 2301 
 2302 CheckTermioFuncDecls()
 2303 {
 2304     CheckFuncDecl cfsetospeed \
 2305     'extern int cfsetospeed(const struct termios*, speed_t);' $@
 2306     CheckFuncDecl cfsetispeed \
 2307     'extern int cfsetispeed(const struct termios*, speed_t);' $@
 2308     CheckFuncDecl tcgetattr 'extern int tcgetattr(int, struct termios*);' $@
 2309     CheckFuncDecl tcsetattr \
 2310     'extern int tcsetattr(int, int, const struct termios*);' $@
 2311     CheckFuncDecl tcsendbreak 'extern int tcsendbreak(int, int);' $@
 2312     CheckFuncDecl tcdrain 'extern int tcdrain(int);' $@
 2313     CheckFuncDecl tcflush 'extern int tcflush(int, int);' $@
 2314     CheckFuncDecl tcflow 'extern int tcflow(int, int);' $@
 2315 }
 2316 
 2317 BuildTermiosDotH()
 2318 {
 2319     CheckForIncludeFile termios.h || {
 2320     CheckForIncludeFile sys/termios.h || {
 2321         bitch "Cannot locate termios.h or sys/termios.h."
 2322         boom
 2323     }
 2324     Note ""
 2325     Note "No termios.h found; creating one with necessary definitions."
 2326     (EmitCPlusPlusPrologue _TERMIOS_
 2327      echo '#include "sys/termios.h"'
 2328      CheckTermioFuncDecls sys/termios.h
 2329      EmitCPlusPlusEpilogue
 2330     )>xtermios.h
 2331     mv xtermios.h termios.h; chmod 444 termios.h
 2332     }
 2333 }
 2334 
 2335 CheckSigvecHandler()
 2336 {
 2337     cat>t.c++<<EOF
 2338 #include <sys/types.h>
 2339 #include <signal.h>
 2340 void sigHUP(int) {}
 2341 void f() {
 2342     struct sigvec sv;
 2343     sv.sv_handler = $1 (sigHUP);
 2344     (void) sigvec(SIGHUP, &sv, (struct sigvec*) 0);
 2345 }
 2346 int main() { f(); return 0; }
 2347 EOF
 2348     capture cat t.c++
 2349     runMake t "t:; \${C++F} \${C++FILE} -c t.c++${MAKECXXOVERRIDE}"
 2350 }
 2351 CheckSigactionHandler()
 2352 {
 2353     cat>t.c++<<EOF
 2354 #include <sys/types.h>
 2355 #include <signal.h>
 2356 void sigHUP(int) {}
 2357 void f() {
 2358     struct sigaction sa;
 2359     sa.sa_handler = $1 (sigHUP);
 2360     (void) sigaction(SIGHUP, &sa, (struct sigaction*) 0);
 2361 }
 2362 int main() { f(); return 0; }
 2363 EOF
 2364     capture cat t.c++
 2365     runMake t "t:; \${C++F} \${C++FILE} -c t.c++${MAKECXXOVERRIDE}"
 2366 }
 2367 CheckSignalHandler()
 2368 {
 2369     cat>t.c++<<EOF
 2370 #include <sys/types.h>
 2371 #include <signal.h>
 2372 void sigHUP(int) {}
 2373 void f() { (void) signal(SIGHUP, $1 (sigHUP)); }
 2374 int main() { f(); return 0; }
 2375 EOF
 2376     capture cat t.c++
 2377     runMake t "t:; \${C++F} \${C++FILE} -c t.c++${MAKECXXOVERRIDE}"
 2378 }
 2379 
 2380 CheckForMMAP()
 2381 {
 2382     (cat<<'EOF'
 2383 /* part of this was lifted from GNU autoconf */
 2384 #include <sys/types.h>
 2385 #include <fcntl.h>
 2386 #include <sys/mman.h>
 2387 EOF
 2388     CheckForFunc getpagesize || {
 2389     cat<<'EOF'
 2390 #ifdef BSD
 2391 # ifndef BSD4_1
 2392 #  define HAVE_GETPAGESIZE
 2393 # endif
 2394 #endif
 2395 
 2396 #ifndef HAVE_GETPAGESIZE
 2397 # include <sys/param.h>
 2398 # ifdef EXEC_PAGESIZE
 2399 #  define getpagesize() EXEC_PAGESIZE
 2400 # else
 2401 #  ifdef NBPG
 2402 #   define getpagesize() NBPG * CLSIZE
 2403 #   ifndef CLSIZE
 2404 #    define CLSIZE 1
 2405 #   endif
 2406 #  else
 2407 #   ifdef NBPC
 2408 #    define getpagesize() NBPC
 2409 #   else
 2410 #    define getpagesize() PAGESIZE /* SVR4 */
 2411 #   endif
 2412 #  endif
 2413 # endif
 2414 #endif
 2415 EOF
 2416     }
 2417 cat<<'EOF'
 2418 #include <stdlib.h>
 2419 #include <stdio.h>
 2420 static void
 2421 boom(const char* msg)
 2422 {
 2423     printf("%s.\n", msg);
 2424     exit(1);
 2425 }
 2426 
 2427 int main(int argc, char *argv[])
 2428 {
 2429     const char* filename = "conftestmmap";
 2430     char* buf;
 2431     char* addr;
 2432     int i, fd, cc;
 2433 
 2434     cc = getpagesize();
 2435     buf = malloc(cc);
 2436     for (i = 0; i < cc; ++i)
 2437     buf[i] = rand();
 2438     fd = open(filename, O_WRONLY|O_CREAT, 0666);
 2439     if (fd < 0)
 2440     boom("Cannot open test file");
 2441     if (write(fd, buf, cc) != cc)
 2442     boom("Write to test file failed");
 2443     close(fd);
 2444     fd = open(filename, O_RDONLY);
 2445     if (fd < 0)
 2446     boom("Cannot reopen test file");
 2447     addr = (char*) mmap(0, cc, PROT_READ, MAP_SHARED, fd, 0);
 2448     if (addr == (char*) -1)
 2449     boom("Cannot mmap test file");
 2450     for (i = 0; i < cc; ++i)
 2451     if (buf[i] != addr[i])
 2452         boom("Compare of mmap-file contents failed");
 2453     exit(0);
 2454 }
 2455 EOF
 2456     )>m.c
 2457     capture cat m.c
 2458     runMake m "m:; \${CC} m.c ${MACHDEPLIBS}" && capture ./a.out
 2459 }
 2460 
 2461 CheckForStructExitStatus()
 2462 {
 2463     decl=$1; shift
 2464     (echo '#include <utmp.h>'
 2465     for i do
 2466     echo "$i"
 2467     done
 2468     cat<<EOF
 2469 int main()
 2470 {
 2471     struct $decl x;
 2472     x.ut_exit.e_exit = 0;
 2473     x.ut_exit.e_termination = 0;
 2474     return 0;
 2475 }
 2476 EOF
 2477     )>t.c++
 2478     capture cat t.c++
 2479     runMake t "t:; \${C++F} \${C++FILE} t.c++${MAKECXXOVERRIDE}"
 2480 }
 2481 
 2482 CheckForTimeZoneHandling()
 2483 {
 2484     (echo '#include <time.h>'
 2485     cat<<EOF
 2486 int main()
 2487 {
 2488     struct tm x;
 2489     const char* cp;
 2490     long off;
 2491     cp = x.tm_zone;
 2492     off = x.tm_gmtoff;
 2493     return 0;
 2494 }
 2495 EOF
 2496     )>t.c++
 2497     capture cat t.c++
 2498     runMake t "t:; \${C++F} \${C++FILE} t.c++${MAKECXXOVERRIDE}"
 2499 }
 2500 
 2501 CheckForTXCD()
 2502 {
 2503     cat>t.c<<EOF
 2504 #include <sys/ioctl.h>
 2505 int main(int argc, char *argv[])
 2506 {
 2507     ioctl(0, TXADDCD, "rts");
 2508     ioctl(0, TXDELCD, "rts");
 2509 }
 2510 EOF
 2511     capture cat t.c
 2512     runMake t 't:; ${CC} t.c'
 2513 }
 2514 
 2515 #
 2516 # Check for a function declaration in <stdio.h>
 2517 # and if it is missing emit the appropriate decl
 2518 # along with an include of <stdio.h> (for any
 2519 # FILE definition).  Apparently some combinations
 2520 # of systems+compilers do not react well to
 2521 # function declarations w/o various definitions
 2522 # that appear only in stdio.h.
 2523 #
 2524 STDIO_H=no
 2525 CheckStdio()
 2526 {
 2527     f=$1
 2528     decl="$2"
 2529     CheckForFuncDecl $f stdio.h || {
 2530     if [ $STDIO_H = no ]; then
 2531         echo '#include <stdio.h>'
 2532         STDIO_H=yes
 2533     fi
 2534     AddFuncDecl $f "$decl"
 2535     }
 2536 }
 2537 
 2538 getConfigTag()
 2539 {
 2540     param=`grep "$1:" $2 | sed -e 's/.*:[   ]*\([^  ]*\).*/\1/'`
 2541 }
 2542 
 2543 #
 2544 # Check if TIFF library is compatible. If successful,
 2545 # set $tiff_runlen_t on exit to "uint16" or "uint32"
 2546 # and $tiff_offset_t to "uint32" or "uint64".
 2547 #
 2548 CheckLibtiff()
 2549 {
 2550     Note "... checking TIFF library version"
 2551     tiff_runlen_t=""
 2552     tiff_offset_t=""
 2553     cat>t.c<<EOF
 2554 #include <stdlib.h>
 2555 #include <stdio.h>
 2556 #include "tiffio.h"
 2557 int main(int argc, char *argv[])
 2558 {
 2559     printf( "header_ver=%d lib_ver=%s", TIFFLIB_VERSION, TIFFGetVersion() );
 2560     exit(0);
 2561 }
 2562 EOF
 2563     capture cat t.c
 2564     if runMake t "t:; \${CC} \${CVERSION} ${OTIFFINC} t.c ${LIBTIFF} ${MACHDEPLIBS}"; then
 2565         header_ver=0
 2566         lib_ver=""
 2567     eval `./a.out | \
 2568         sed -n -e 's/header_ver=\([0-9][0-9]*\) lib_ver=.*Version *\([0-9][0-9]*\.[0-9]\).*/\
 2569                        header_ver=\1;lib_ver=\2/p'`
 2570     Note "  Found tiffio.h version ${header_ver}"
 2571     Note "  Found libtiff version ${lib_ver}"
 2572     if [ ${header_ver} -ge 19960307 ]; then
 2573         case ${lib_ver} in
 2574         3.4)        tiff_runlen_t="uint16"
 2575                 tiff_offset_t="uint32"
 2576                 echo '#define TIFFSTRIPBYTECOUNTS uint32'
 2577                 echo '#define TIFFVERSION TIFF_VERSION'
 2578                 echo '#define TIFFHEADER TIFFHeader';;
 2579         3.[56789])  tiff_runlen_t="uint32"
 2580                 tiff_offset_t="uint32"
 2581                 echo '#define TIFFSTRIPBYTECOUNTS uint32'
 2582                 echo '#define TIFFVERSION TIFF_VERSION'
 2583                 echo '#define TIFFHEADER TIFFHeader';;
 2584         4.[01])     tiff_runlen_t="uint32"
 2585                 tiff_offset_t="uint64"
 2586                 echo '#define TIFFSTRIPBYTECOUNTS uint64'
 2587                 echo '#define TIFFVERSION TIFF_VERSION_CLASSIC'
 2588                 echo '#define TIFFHEADER TIFFHeaderClassic';;
 2589         esac
 2590     fi
 2591     else
 2592     cat 1>&2 <<EOF
 2593 
 2594 Missing TIFF Library.
 2595 
 2596 Compilation of the following test program failed:
 2597 
 2598 ----------------------------------------------------------
 2599 EOF
 2600         cat t.c 1>&2
 2601         cat 1>&2 <<EOF
 2602 ----------------------------------------------------------
 2603 
 2604 TIFFINC=${OTIFFINC}
 2605 LIBTIFF=${LIBTIFF}
 2606 
 2607 Verify that you have the TIFFINC and LIBTIFF configuration parameters
 2608 set correctly for your system (see above) and that any environment
 2609 variables are setup that are needed to locate a libtiff DSO at runtime
 2610 (e.g. LD_LIBRARY_PATH). Also be sure that any relative pathnames are
 2611 made relative to the top of the build area.
 2612 EOF
 2613     boom
 2614     return 1
 2615     fi
 2616     if [ "${tiff_runlen_t}" != "" ] && [ "${tiff_offset_t}" != "" ]; then
 2617     export tiff_runlen_t
 2618     export tiff_offset_t
 2619     return 0
 2620     else
 2621     cat 1>&2 <<EOF
 2622 
 2623 Incompatible TIFF Library.
 2624 
 2625 HylaFAX ${VERSION} requires TIFF software distribution versions 3.4 through
 2626 4.0.  If you do not have up to date TIFF software on your system
 2627 then you can retrieve it from the location where you obtained this software.
 2628 The Home Page for version 3.5 and later is http://www.remotesensing.org/libtiff/
 2629 EOF
 2630     boom
 2631     return 1
 2632     fi
 2633 }
 2634 
 2635 #
 2636 # Check an existing port.h to see if it was created
 2637 # for the target and compiler we're using.
 2638 #
 2639 CheckPortDotH()
 2640 {
 2641     getConfigTag TARGET port.h; target="$param"
 2642     getConfigTag CCOMPILER port.h; ccompiler="$param"
 2643     getConfigTag CXXCOMPILER port.h; cxxcompiler="$param"
 2644     CCOMP=$CCOMPILER;
 2645     test $ISGCC = yes && CCOMP="${CCOMP}-${GCCversion}"
 2646     CXXCOMP=$CXXCOMPILER;
 2647     test $ISGXX = yes && CXXCOMP="${CXXCOMP}-${GCCversion}"
 2648     test "$target" = "$TARGET" && \
 2649     test "$ccompiler" = "$CCOMP" && \
 2650     test "$cxxcompiler" = "$CXXCOMP"
 2651 }
 2652 
 2653 #
 2654 # Built port.h and, optionally, termios.h based on
 2655 # the system and compiler setup.
 2656 #
 2657 BuildPortDotH()
 2658 {
 2659     Note ""
 2660     Note "Creating port.h with necessary definitions."
 2661 
 2662     (EmitCPlusPlusPrologue _PORT_
 2663     EmitConfigurationDefinitions
 2664 
 2665     echo '#include <sys/types.h>'
 2666     TYPES_H="sys/types.h"
 2667     if CheckForIncludeFile sys/bsdtypes.h; then
 2668     Note "... configure use of <sys/bsdtypes.h>"
 2669         echo '#include <sys/bsdtypes.h>'
 2670     TYPES_H="$TYPES_H sys/bsdtypes.h"
 2671     fi
 2672     CheckVarDecl uid_t 'typedef int uid_t;' $TYPES_H
 2673     CheckVarDecl gid_t 'typedef int gid_t;' $TYPES_H
 2674     CheckVarDecl mode_t 'typedef int mode_t;' $TYPES_H stdlib.h
 2675     CheckVarDecl off_t 'typedef long off_t;' $TYPES_H stdlib.h
 2676     CheckVarDecl pid_t 'typedef int pid_t;' $TYPES_H stdlib.h
 2677     CheckVarDecl size_t 'typedef unsigned size_t;' $TYPES_H stdlib.h
 2678     CheckVarDecl dev_t 'typedef int dev_t;' $TYPES_H stdlib.h
 2679     if CheckForIncludeFile stdint.h; then
 2680     Note "... configure use of <stdint.h>"
 2681         echo '#define HAVE_STDINT_H 1'
 2682     TYPES_H="$TYPES_H stdint.h"
 2683     fi
 2684     CheckVarDecl intptr_t 'typedef long intptr_t;' $TYPES_H
 2685 
 2686     if [ $CONFIG_OSFCNH = auto ]; then
 2687         if CheckForIncludeFile osfcn.h; then
 2688             CONFIG_OSFCNH=yes
 2689         else
 2690             CONFIG_OSFCNH=no
 2691         fi
 2692     fi
 2693     if [ $CONFIG_OSFCNH = yes ]; then
 2694     Note "... configure use of <osfcn.h>"
 2695     echo '#define HAS_OSFCN_H 1'
 2696     OSFCNH='osfcn.h'
 2697     else
 2698     OSFCNH=
 2699     fi
 2700     if CheckForIncludeFile sys/select.h; then
 2701     Note "... configure use of <sys/select.h>"
 2702     echo '#define HAS_SELECT_H 1'
 2703     SELECTH='sys/select.h'
 2704     else
 2705     SELECTH=
 2706     fi
 2707 
 2708     #
 2709     # Check whether compiler uses new C++ header style
 2710     #
 2711     CheckForIncludeFile new || {
 2712         Note "... configure use of new.h"
 2713             echo '#define HAS_OLD_NEW_H 1'
 2714     }
 2715 
 2716     #
 2717     # Some vendors have changed the socket API so that
 2718     # call-by-reference parameters that give buffer
 2719     # lengths are not int; this must be dealt with to
 2720     # get the code to compile.  Note that we only emit
 2721     # the define if the type is not an int; we do this
 2722     # so Socket.h can include code that assumes the
 2723     # default so folks don't have to rerun configure.
 2724     #
 2725     # The HP-UX case is a bit peculiar.  There socklen_t 
 2726     # is defined as size_t, but in order to use it...
 2727     # "To use UNIX95/98 style sockets in HP-UX, the libxnet 
 2728     # library needs to be added to the link line. Also, the 
 2729     # macro, _XOPEN_SOURCE, needs to be defined, and the 
 2730     # macro, _XOPEN_SOURCE_EXTENDED, needs to be defined as 1. 
 2731     # Refer to HP-UX manpage, xopen_networking(7) for further 
 2732     # details."  Otherwise, we must define
 2733     # CONFIG_HPUX_SOCKLEN_T_BRAINDAMAGE.
 2734     #
 2735     test "$CONFIG_SOCKARGLENTYPE" || {      # int vs unsigned long vs ...
 2736         case $TARGET in
 2737         # XXX fill in for busted systems
 2738         *-aix4*)    CONFIG_SOCKARGLENTYPE=size_t;;
 2739         *-hpux11*)  CONFIG_SOCKARGLENTYPE=size_t;;
 2740         *sysv4.2uw2*)   CONFIG_SOCKARGLENTYPE=size_t;;
 2741         *-univel-*) CONFIG_SOCKARGLENTYPE=size_t;;
 2742         *-sysv5UnixWare*)   CONFIG_SOCKARGLENTYPE=size_t;;
 2743         *-sysv5OpenUNIX*)   CONFIG_SOCKARGLENTYPE=size_t;;
 2744         *-sysv5SCO_SV*) CONFIG_SOCKARGLENTYPE=size_t;;
 2745     *-freebsd4*)    CONFIG_SOCKARGLENTYPE=u_int32_t;;
 2746     *-freebsd5*)    CONFIG_SOCKARGLENTYPE=u_int32_t;;
 2747         *)      CONFIG_SOCKARGLENTYPE=int;;
 2748         esac
 2749     }
 2750     TYPES_H="$TYPES_H sys/socket.h"
 2751     CheckVarDecl socklen_t "typedef $CONFIG_SOCKARGLENTYPE socklen_t;" $TYPES_H
 2752 
 2753     #
 2754     # Select signal handler type casts.
 2755     #
 2756     if [ $ISGXX = yes ]; then
 2757         #
 2758         # Must use -pendantic-errors with gcc to insure (sig_t) (...)
 2759         # is treated as an error instead of a warning when searching
 2760         # for the proper signal handler types below.
 2761         #
 2762         OGCXXOPTS="$GCXXOPTS"
 2763         GCXXOPTS="$GCXXOPTS -pedantic-errors"
 2764         makeDefs xdefs
 2765     fi
 2766     SIGHANDLERTYPES="
 2767         $SIGHANDLERTYPES
 2768         (sig_t)
 2769         (SIG_PF)
 2770         (void(*)(int))
 2771         (void(*)())
 2772         (int)
 2773     "
 2774     SIGHANDLERTYPE=
 2775     for i in $SIGHANDLERTYPES; do
 2776         CheckSigactionHandler "$i" && {
 2777             SIGHANDLERTYPE="#define fxSIGACTIONHANDLER $i"
 2778             Note "... use $i for sigaction handler type"
 2779             break;
 2780         }
 2781     done
 2782     # Only look for sigvec if we cannot find a sigaction() type
 2783     if [ -z "$SIGHANDLERTYPE" ]; then
 2784         for i in $SIGHANDLERTYPES; do
 2785             CheckSigvecHandler "$i" && {
 2786                 SIGHANDLERTYPE="#define fxSIGVECHANDLER $i"
 2787                 Note "... use $i for sigvec handler type"
 2788                 break;
 2789             }
 2790         done
 2791     fi
 2792     echo $SIGHANDLERTYPE
 2793     SIGHANDLERTYPE=
 2794     for i in $SIGHANDLERTYPES; do
 2795         CheckSignalHandler "$i" && {
 2796             SIGHANDLERTYPE="#define fxSIGHANDLER $i"
 2797             Note "... use $i for signal handler type"
 2798             break;
 2799         }
 2800     done
 2801     echo $SIGHANDLERTYPE
 2802 
 2803     if [ $ISGXX = yes ]; then
 2804     GCXXOPTS="$OGCXXOPTS"
 2805     makeDefs xdefs
 2806     fi
 2807 
 2808     CheckForMMAP && {
 2809     echo '#define HAS_MMAP 1'
 2810     Note "... configure use of mmap for memory-mapped files"
 2811     CheckFuncDecl mmap \
 2812         'extern void* mmap(void*, size_t, int, int, int, off_t);' sys/mman.h
 2813     CheckFuncDecl munmap 'extern int munmap (caddr_t, int);' sys/mman.h
 2814     }
 2815 
 2816     CheckFuncDecl bzero 'extern void bzero(void *, int);' string.h
 2817     CheckFuncDecl mkstemp 'extern int mkstemp(char *);' stdlib.h stdio.h unistd.h
 2818     CheckFuncDecl strerror 'extern char* strerror(int);' string.h
 2819     CheckFuncDecl strncasecmp \
 2820     'extern int strncasecmp(const char*, const char*, size_t);' string.h
 2821     CheckFuncDecl strcasecmp \
 2822     'extern int strcasecmp(const char*, const char*);' string.h
 2823     CheckFuncDecl strdup 'extern char* strdup(const char*);' string.h
 2824     CheckFuncDecl memset 'extern void* memset(void*, int, size_t);' string.h
 2825     CheckFuncDecl getpass 'extern char* getpass(const char *);' stdlib.h unistd.h
 2826     CheckFuncDecl random 'extern long random(void);' math.h stdlib.h
 2827     CheckFuncDecl srandom 'extern void srandom(int);' math.h stdlib.h
 2828     CheckFuncDecl floor 'extern double floor(double);' math.h
 2829     CheckFuncDecl waitpid 'extern pid_t waitpid(pid_t, int *, int);' sys/wait.h
 2830     CheckForFunc sysconf && {
 2831     echo '#define HAS_SYSCONF 1'
 2832     Note "... configure use of sysconf"
 2833     CheckFuncDecl sysconf 'extern long sysconf(int);' unistd.h
 2834     }
 2835     CheckForFunc ulimit && {
 2836     echo '#define HAS_ULIMIT 1'
 2837     Note "... configure use of ulimit"
 2838     CheckFuncDecl ulimit 'extern long ulimit(int, ...);' ulimit.h
 2839     }
 2840     CheckForFunc getdtablesize && {
 2841     echo '#define HAS_GETDTABLESIZE 1'
 2842     Note "... configure use of getdtablesize"
 2843     CheckFuncDecl getdtablesize 'extern int getdtablesize(void);' unistd.h
 2844     }
 2845     CheckDefine _POSIX_OPEN_MAX '_POSIX_OPEN_MAX 16' limits.h
 2846     CheckDefine howmany 'howmany(x, y)  (((x)+((y)-1))/(y))' $TYPES_H
 2847     CheckForFuncDecl sigvec signal.h || {
 2848     echo 'struct sigvec;'
 2849     AddFuncDecl sigvec \
 2850         'extern int sigvec(int, const struct sigvec*, struct sigvec*);'
 2851     }
 2852     CheckForFuncDecl sigaction signal.h || {
 2853     echo 'struct sigaction;'
 2854     AddFuncDecl sigaction \
 2855         'extern int sigaction(int, const struct sigaction*, struct sigaction*);'
 2856     }
 2857     CheckFuncDecl kill 'extern int kill(pid_t, int);' signal.h
 2858     CheckFuncDecl close 'extern int close(int);' unistd.h
 2859     CheckFuncDecl getuid 'extern uid_t getuid(void);' unistd.h
 2860     CheckFuncDecl geteuid 'extern uid_t geteuid(void);' unistd.h
 2861     CheckFuncDecl seteuid 'extern int seteuid(uid_t);' unistd.h
 2862     CheckFuncDecl setegid 'extern int setegid(gid_t);' unistd.h
 2863     CheckFuncDecl setenv 'int setenv(const char *, const char *, int);' stdlib.h
 2864     CheckFuncDecl ftruncate 'extern int ftruncate(int, off_t);' unistd.h
 2865     CheckFuncDecl getdtablesize 'extern int getdtablesize(void);' unistd.h
 2866     CheckFuncDecl chroot 'extern int chroot(const char *path);' unistd.h
 2867     #
 2868     # unistd.h is where many people put it
 2869     # sys/select.h is for USL-derived code
 2870     # sys/time.h is for HP systems (sigh)
 2871     # sys/types.h is for yet other systems (sigh sigh)
 2872     #
 2873     CheckForFuncDecl select unistd.h $SELECTH sys/time.h $TYPES_H || {
 2874     echo 'struct fd_set;'
 2875     echo 'struct timeval;'
 2876     AddFuncDecl select \
 2877         'extern int select(int,struct fd_set*,struct fd_set*,struct fd_set*,struct timeval*);'
 2878     }
 2879     CheckFuncDecl unlink 'extern int unlink(const char*);' unistd.h
 2880     CheckFuncDecl read 'extern int read(int, const void*, unsigned int);' unistd.h
 2881     CheckFuncDecl ioctl 'extern int ioctl(int, int, ...);' unistd.h sys/ioctl.h
 2882     CheckForFunc fchown && {
 2883     echo '#define HAS_FCHOWN 1'
 2884     Note "... configure use of fchown"
 2885     CheckFuncDecl fchown 'extern int fchown(int, uid_t, gid_t);' unistd.h
 2886     }
 2887     CheckFuncDecl gethostname 'extern int gethostname(char*, int);' unistd.h $OSFCNH
 2888     CheckFuncDecl malloc 'extern void* malloc(size_t);' stdlib.h
 2889     CheckFuncDecl realloc 'extern void* realloc(void*, size_t);' stdlib.h
 2890     CheckFuncDecl free 'extern void free(void*);' stdlib.h
 2891     CheckFuncDecl strtoul \
 2892     'extern unsigned long strtoul(const char*, char**, int);' stdlib.h
 2893     #
 2894     # unistd.h is for sco3.2v4.[0-2] and GNU libc (yech!)
 2895     #
 2896     CheckFuncDecl getopt \
 2897     'extern int getopt(int, char* const*, const char*);' stdlib.h unistd.h
 2898     CheckFuncDecl isatty 'extern int isatty(int);' stdlib.h unistd.h
 2899     CheckVarDecl 'char.*optarg' 'extern char* optarg;' stdlib.h unistd.h
 2900     CheckVarDecl 'int.*opterr' 'extern int opterr;' stdlib.h unistd.h
 2901     CheckVarDecl 'int.*optind' 'extern int optind;' stdlib.h unistd.h
 2902     CheckFuncDecl system 'extern int system(const char*);' stdlib.h
 2903     CheckFuncDecl mktemp 'extern char* mktemp(char*);' stdlib.h stdio.h unistd.h
 2904     CheckStdio popen 'extern FILE* popen(const char *, const char *);'
 2905     CheckStdio pclose 'extern int pclose(FILE*);'
 2906     CheckStdio fdopen 'extern FILE* fdopen(int, const char*);'
 2907     CheckStdio snprintf 'extern int snprintf(char*, size_t, const char*,...);'
 2908     CheckForFuncDecl vsnprintf stdio.h || {
 2909     echo '#include <stdarg.h>'
 2910     AddFuncDecl vsnprintf 'extern int vsnprintf(char*, size_t, const char*, va_list);'
 2911     }
 2912     CheckForDefine fileno stdio.h || {
 2913     CheckStdio fileno 'extern int fileno(FILE*);'
 2914     }
 2915     CheckFuncDecl opendir 'extern DIR* opendir(const char*);' dirent.h
 2916     CheckFuncDecl syslog 'extern void syslog(int, const char*, ...);' syslog.h
 2917     CheckForFuncDecl vsyslog syslog.h || {
 2918     echo '#include <stdarg.h>'
 2919     AddFuncDecl vsyslog 'extern void vsyslog(int, const char*, va_list);'
 2920     }
 2921     CheckFuncDecl closelog 'extern void closelog(void);' syslog.h
 2922     CheckFuncDecl openlog 'extern void openlog(const char*, int, int);' syslog.h
 2923     CheckForFunc fchmod && {
 2924     echo '#define HAS_FCHMOD 1'
 2925     Note "... configure use of fchmod"
 2926     CheckFuncDecl fchmod 'extern int fchmod(int, mode_t);' \
 2927         unistd.h $OSFCNH sys/stat.h
 2928     }
 2929     CheckFuncDecl mknod 'extern int mknod(const char*, mode_t, dev_t);' \
 2930     unistd.h sys/stat.h
 2931     CheckForFuncDecl gettimeofday sys/time.h || {
 2932     echo 'struct timezone;'
 2933     echo 'struct timeval;'
 2934     AddFuncDecl gettimeofday \
 2935         'extern int gettimeofday(struct timeval*, struct timezone*);'
 2936     }
 2937     CheckForFuncDecl strftime time.h || {
 2938     echo 'struct tm;'
 2939     AddFuncDecl strftime \
 2940         'extern size_t strftime(char*,size_t,const char*,const struct tm*);'
 2941     }
 2942     CheckForFuncDecl localtime time.h || {
 2943     echo 'struct tm;'
 2944     AddFuncDecl localtime 'struct tm* localtime(const time_t* clock);'
 2945     }
 2946     CheckForTimeZoneHandling && {
 2947     echo '#define HAS_TM_ZONE 1'
 2948     Note "... configure use of struct tm timezone information"
 2949     }
 2950     CheckForFuncDecl setitimer sys/time.h || {
 2951     echo '#ifdef ITIMER_REAL'
 2952     echo 'struct itimerval;'
 2953     AddFuncDecl setitimer \
 2954         'extern int setitimer(int,struct itimerval*,struct itimerval*);'
 2955     echo '#endif'
 2956     }
 2957     CheckFuncDecl setpwent 'extern void setpwent(void);' pwd.h
 2958     CheckFuncDecl endpwent 'extern void endpwent(void);' pwd.h
 2959     CheckFuncDecl getpwnam 'extern struct passwd* getpwnam(const char*);' pwd.h
 2960     case "$TARGET" in
 2961     *-reno*)
 2962     ;;
 2963     *)
 2964     for i in toupper tolower; do
 2965         CheckFuncDecl $i "extern int $i(int);" ctype.h
 2966     done
 2967     ;;
 2968     esac
 2969     CheckForIncludeFile net/errno.h && {
 2970     Note "... configure use of <net/errno.h>"
 2971         echo '#define HAS_NETERRNO_H 1'
 2972     }
 2973     CheckForFuncDecl getpeername sys/socket.h || {
 2974     echo 'struct sockaddr;'
 2975     AddFuncDecl getpeername 'extern int getpeername(int,struct sockaddr*,int*);'
 2976     }
 2977     CheckForFuncDecl getsockname sys/socket.h || {
 2978     echo 'struct sockaddr;'
 2979     AddFuncDecl getsockname 'extern int getsockname(int,struct sockaddr*,int*);'
 2980     }
 2981     CheckFuncDecl socket 'extern int socket(int, int, int);' sys/socket.h
 2982     CheckFuncDecl connect 'extern int connect(int, const void*, int);' sys/socket.h
 2983     CheckForFuncDecl bind sys/socket.h || {
 2984     echo 'struct sockaddr;'
 2985     AddFuncDecl bind 'extern int bind(int, const struct sockaddr*, int);'
 2986     }
 2987     CheckFuncDecl listen 'extern int listen(int, int);' sys/socket.h
 2988     CheckFuncDecl getsockopt \
 2989     'extern int getsockopt(int, int, int, const char*, int*);' sys/socket.h
 2990     CheckFuncDecl setsockopt \
 2991     'extern int setsockopt(int, int, int, const char*, int);' sys/socket.h
 2992     CheckForFuncDecl accept sys/socket.h || {
 2993     echo 'struct sockaddr;'
 2994     AddFuncDecl accept 'extern int accept(int, struct sockaddr*, int*);'
 2995     }
 2996     CheckFuncDecl send \
 2997     'extern int send(int, const void*, int, int);' sys/socket.h
 2998     CheckFuncDecl setutent 'extern void setutent(void);' utmp.h
 2999     CheckFuncDecl endutent 'extern void endutent(void);' utmp.h
 3000     CheckForFuncDecl getutent utmp.h || {
 3001     echo 'struct utmp;'
 3002     AddFuncDecl getutent 'extern struct utmp* getutent(void);'
 3003     }
 3004     CheckForFuncDecl pututline utmp.h || {
 3005     echo 'struct utmp;'
 3006     AddFuncDecl pututline \
 3007         'extern struct utmp* pututline(const struct utmp*);'
 3008     }
 3009     CheckForFuncDecl gethostbyname netdb.h || {
 3010     echo 'struct hostent;'
 3011     AddFuncDecl gethostbyname \
 3012         'extern struct hostent* gethostbyname(const char*);'
 3013     }
 3014     CheckForFuncDecl gethostbyaddr netdb.h || {
 3015     echo 'struct hostent;'
 3016     AddFuncDecl gethostbyaddr \
 3017         'extern struct hostent* gethostbyaddr(const void*, int, int);'
 3018     }
 3019     CheckForFuncDecl getservbyname netdb.h || {
 3020     echo 'struct servent;'
 3021     AddFuncDecl getservbyname \
 3022         'extern struct servent* getservbyname(const char*, const char*);'
 3023     }
 3024     CheckForDefine LOCK_SH sys/file.h || {
 3025     AddDefine LOCK_SH 'LOCK_SH  1   /* shared lock */'
 3026     AddDefine LOCK_EX 'LOCK_EX  2   /* exclusive lock */'
 3027     AddDefine LOCK_NB 'LOCK_NB  4   /* dont block when locking */'
 3028     AddDefine LOCK_UN 'LOCK_UN  8   /* unlock */'
 3029     }
 3030     CheckFuncDecl flock 'extern int flock(int, int);' sys/file.h
 3031     CheckForFuncDecl sigsetjmp setjmp.h || {
 3032     echo '#include <setjmp.h>'
 3033     echo '#ifndef sigsetjmp'
 3034     AddDefine sigjmp_buf 'sigjmp_buf jmp_buf    /* hopefully compatible */'
 3035     AddFuncDecl sigsetjmp 'extern int sigsetjmp(sigjmp_buf, int);'
 3036     AddFuncDecl siglongjmp 'extern void siglongjmp(sigjmp_buf, int);'
 3037     echo '#endif'
 3038     }
 3039     CheckForFuncDecl inet_ntoa arpa/inet.h || {
 3040     echo 'struct in_addr;'
 3041     AddFuncDecl inet_ntoa 'extern char* inet_ntoa(struct in_addr);'
 3042     }
 3043     CheckForIncludeFile sys/mkdev.h && {
 3044     Note "... configure use of <sys/mkdev.h> (for SVR4-style lock files)"
 3045     echo '#define HAS_MKDEV 1'
 3046     }
 3047     CheckForIncludeFile locale.h && {
 3048     Note "... configure use of <locale.h> (internationalization support)"
 3049     echo '#define HAS_LOCALE 1'
 3050     }
 3051     CheckForIncludeFile langinfo.h && {
 3052     Note "... configure use of <langinfo.h> (internationalization support)"
 3053     echo '#define HAS_LANGINFO 1'
 3054     }
 3055     CheckForIncludeFile paths.h && {
 3056     Note "... configure use of <paths.h>"
 3057     echo '#include <paths.h>'
 3058     }
 3059     CheckForIncludeFile sys/modem.h && {
 3060     Note "... configure use of <sys/modem.h>"
 3061     echo '#define HAS_MODEM_H 1'
 3062     }
 3063     CheckForIncludeFile sys/termiox.h && {
 3064     case $TARGET in
 3065     *-*-sco3.2v5.*) ;;
 3066     *)      Note "... configure use of SVR4 termiox support"
 3067             echo '#define HAS_TERMIOX 1'
 3068             ;;
 3069     esac
 3070     }
 3071     CheckForFunc flock || {
 3072     #
 3073     # Emit the necessary #defines for emulating flock
 3074     #
 3075     if CheckForFunc fcntl; then
 3076         echo '#define HAS_FCNTL 1'
 3077     fi
 3078     if CheckForFunc lockf; then
 3079         echo '#define HAS_LOCKF 1'
 3080     fi
 3081     }
 3082     # NB: logwtmp checked above when looking for -lutil
 3083     test $HAS_LOGWTMP = yes && {
 3084     #
 3085     # Configure use of logwtmp in the BSD getty support and
 3086     # verify that the accompanying logout function is present
 3087     # also.  Note that we put out proper declarations for the
 3088     # functions since they don't appear to be declared anywhere.
 3089     #
 3090     echo '#define HAS_LOGWTMP 1'
 3091     Note "... configure use of logwtmp (BSD-style wtmp logging)"
 3092     CheckForFuncDecl logwtmp utmp.h || {
 3093         AddFuncDecl logwtmp \
 3094         'int logwtmp(const char*, const char*, const char*);'
 3095     }
 3096     CheckForLibrary logout -lutil && {
 3097         echo '#define HAS_LOGOUT 1'
 3098         Note "... configure use of logout (BSD-style utmp support)"
 3099         CheckForFuncDecl logout utmp.h || {
 3100             AddFuncDecl logout 'int logout(const char*);'
 3101         }
 3102     }
 3103     }
 3104     CheckDefine _PATH_DEV     '_PATH_DEV    "/dev/"'    paths.h
 3105     CheckDefine _PATH_DEVNULL '_PATH_DEVNULL    "/dev/null"'    paths.h
 3106     CheckDefine _PATH_TMP     '_PATH_TMP    "/tmp/"'    paths.h
 3107     if [ $UTMP = auto ]; then
 3108     if CheckForIncludeFile utmpx.h; then
 3109         case $TARGET in
 3110         *-hpux10.20*)   UTMP=utmp;;
 3111         *-hpux11*)      UTMP=utmp;;
 3112         *-aix4*)        UTMP=utmp;;
 3113         *-aix5*)        UTMP=utmp;;
 3114         *-aix)      UTMP=utmp;;
 3115         *-dec-osf4.0*)  UTMP=utmp;;
 3116         *-osf-5.1a*)    UTMP=utmp;;
 3117         *-linux*)       UTMP=utmp;;
 3118         *)          UTMP=utmpx;;
 3119         esac
 3120     else
 3121         UTMP=utmp;
 3122     fi
 3123     fi
 3124     if [ $UTMP = utmpx ]; then
 3125     Note "... configure use of <utmpx.h> (extended utmp interface)"
 3126     echo '#define HAS_UTMPX 1'
 3127     CheckForDefine _PATH_WTMPX paths.h utmp.h utmpx.h || {
 3128         if CheckForDefine WTMPX_FILE utmpx.h; then
 3129         AddDefine _PATH_WTMPX '_PATH_WTMPX  WTMPX_FILE'
 3130         else
 3131         PATHWTMPX=`findFile wtmpx /etc:/var/adm:/usr/adm`
 3132         test "$PATHWTMPX" && {
 3133             AddDefine _PATH_WTMPX "_PATH_WTMPX  \"${PATHWTMPX}\""
 3134         }
 3135         fi
 3136     }
 3137     #
 3138     # struct exit_status is defined for all systems with
 3139     # utmpx support, but SVR4.0.3 headers define the extended
 3140     # exit status structure *within* struct utmp and then reuse
 3141     # it within struct utmpx.  This does not work for all
 3142     # compilers so we must look for this case and, if present,
 3143     # enable a workaround declaration of struct exit_status (sigh).
 3144     #
 3145     if CheckForStructExitStatus utmpx '#include <utmpx.h>'; then
 3146         echo '#define HAS_UTEXIT 1'
 3147         echo '#define HAS_EXIT_STATUS 1'
 3148     elif CheckForStructExitStatus utmpx \
 3149         'struct exit_status { short e_termination; short e_exit; };' \
 3150         '#include <utmpx.h>'; then
 3151         Note "... add declaration for struct exit_status"
 3152         echo '#define HAS_UTEXIT 1'
 3153         echo '#define HAS_EXIT_STATUS 0'
 3154     fi
 3155     else
 3156     Note "... configure use of <utmp.h> (normal utmp interface)"
 3157     CheckForDefine _PATH_UTMP paths.h utmp.h || {
 3158         if CheckForDefine UTMP_FILE utmp.h; then
 3159         AddDefine _PATH_UTMP '_PATH_UTMP    UTMP_FILE'
 3160         else
 3161         PATHUTMP=`findFile utmp /etc:/var/adm:/usr/adm`
 3162         test "$PATHUTMP" && {
 3163             AddDefine _PATH_UTMP "_PATH_UTMP    \"${PATHUTMP}\""
 3164         }
 3165         fi
 3166     }
 3167     CheckForStructExitStatus utmp && {
 3168         Note "... configure use of extended exit status in utmp"
 3169         echo '#define HAS_UTEXIT 1'
 3170     }
 3171     CheckForDefine _PATH_WTMP paths.h utmp.h || {
 3172         if CheckForDefine WTMP_FILE utmp.h; then
 3173         AddDefine _PATH_WTMP '_PATH_WTMP    WTMP_FILE'
 3174         else
 3175         PATHWTMP=`findFile wtmp /etc:/var/adm:/usr/adm`
 3176         test "$PATHWTMP" && {
 3177             AddDefine _PATH_WTMP "_PATH_WTMP    \"${PATHWTMP}\""
 3178         }
 3179         fi
 3180     }
 3181     fi
 3182     CheckForDefine RT_NOCHANGE sys/priocntl.h sys/rtpriocntl.h && \
 3183     CheckForDefine TS_NOCHANGE sys/priocntl.h sys/tspriocntl.h && {
 3184     case $TARGET in
 3185     *-*-sco3.2v5.*) ;;
 3186     *)  Note "... configure use of SVR4 realtime process control interface"
 3187         echo '#define HAS_PRIOCNTL 1'
 3188             ;;
 3189     esac
 3190     }
 3191     CheckForDefine FP_NOCHANGE sys/priocntl.h sys/fppriocntl.h && {
 3192     Note "... called FP instead of RT"
 3193     echo '#define HAS_FPPRIOCNTL 1'
 3194     }
 3195     CheckForDefine NDPRI sys/schedctl.h && {
 3196     Note "... configure use of IRIX realtime process control interface"
 3197     echo '#define HAS_SCHEDCTL 1'
 3198     }
 3199     CheckForDefine RTPRIO_RTOFF sys/rtprio.h && {
 3200     Note "... configure use of HP-UX realtime process control interface"
 3201     echo '#define HAS_RTPRIO 1'
 3202     }
 3203     CheckForPositiveDefine _POSIX_PRIORITY_SCHEDULING unistd.h sched.h && {
 3204     Note "... configure use of POSIX realtime process control interface"
 3205     echo '#define HAS_POSIXSCHED 1'
 3206     case $TARGET in
 3207     *-*-sco3.2v5.*) echo '#define RT_PRIORITY 96';;
 3208     *-linux*)   echo '#define RT_PRIORITY 1';;
 3209     *)      echo '#define RT_PRIORITY 1';;
 3210     esac
 3211     }
 3212     CheckForTXCD && {
 3213     Note "... configure use of TXADDCD and TXDELCD ioctls"
 3214     echo '#define HAS_TXCD 1'
 3215     }
 3216     if CheckForIncludeFile crypt.h; then
 3217     Note "... configure use of <crypt.h>"
 3218     echo '#define HAS_CRYPT_H 1'
 3219     CheckFuncDecl crypt 'extern const char* crypt(const char*, const char*);' unistd.h crypt.h
 3220     else
 3221     CheckFuncDecl crypt 'extern const char* crypt(const char*, const char*);' unistd.h stdlib.h
 3222     fi
 3223     CheckTermioFuncDecls termios.h
 3224     if CheckLibtiff; then
 3225     Note "... add declaration for tiff_runlen_t and tiff_offset_t"
 3226     echo "#define tiff_runlen_t ${tiff_runlen_t}"
 3227     echo "#define tiff_offset_t ${tiff_offset_t}"
 3228     fi
 3229     if [ "x$PAMLIBS" != "x" ]; then
 3230     CheckPAMType
 3231     fi
 3232 
 3233     CheckForDefine s6_addr32 net/if.h  ||  {
 3234     case $TARGET in
 3235         *-*-sysv5*) AddDefine s6_addr32 's6_addr32  S6_un.S6_l' ;;
 3236         sparc-sun-*)    AddDefine s6_addr32 's6_addr32  S6_un.S6_l' ;;
 3237     esac
 3238     }
 3239 
 3240     case $TARGET in
 3241     *aix) Note "... use tmpfile instead of open_memstream"
 3242          echo '#define HAS_NO_OPEN_MEMSTREAM 1';;
 3243     *)   CheckForStdioFunc open_memstream "(void*)0, (void*)0" || {
 3244          Note "... use tmpfile instead of open_memstream"
 3245          echo '#define HAS_NO_OPEN_MEMSTREAM 1'
 3246          };;
 3247     esac
 3248 
 3249     # Emit the version variable that port will always give us.
 3250     echo "extern const char* HYLAFAX_VERSION_STRING;"
 3251 
 3252     EmitCPlusPlusEpilogue
 3253     )>xport.h
 3254     mv xport.h port.h; chmod 444 port.h
 3255     Note "Done creating port.h."
 3256 }
 3257 
 3258 if test -f port.h && CheckPortDotH; then
 3259     Note ""
 3260     Note "Using previously created port.h."
 3261 else
 3262     $RM xport.h xtermios.h t.c t.c++ a.out port.h termios.h
 3263     BuildTermiosDotH
 3264     BuildPortDotH
 3265 fi
 3266 
 3267 Note ""
 3268 Note "Checking system libraries for functionality to emulate."
 3269 
 3270 FUNCS="
 3271     flock
 3272     ftruncate
 3273     setegid
 3274     seteuid
 3275     setvbuf
 3276     strcasecmp
 3277     writev
 3278 "
 3279 
 3280 for i in $FUNCS; do
 3281     CheckForFunc $i || {
 3282     Note "... emulate $i"
 3283     PORTFUNCS="$PORTFUNCS $i.c"
 3284     }
 3285 done
 3286 
 3287 FUNCS="
 3288     random
 3289 "
 3290 
 3291 for i in $FUNCS; do
 3292     CheckForStdFunc $i || {
 3293     Note "... emulate $i"
 3294     PORTFUNCS="$PORTFUNCS $i.c"
 3295     }
 3296 done
 3297 
 3298 #
 3299 # Now for those functions that need args.
 3300 #
 3301 CheckForUnistdFunc getopt "0, (void*)0, (void*)0" || {
 3302     Note "... emulate getopt"
 3303     PORTFUNCS="$PORTFUNCS getopt.c"
 3304 }
 3305 CheckForStdioFunc snprintf "(void*)0, 0, (void*)0" || {
 3306     Note "... emulate snprintf"
 3307     PORTFUNCS="$PORTFUNCS snprintf.c"
 3308 }
 3309 CheckForFunc vsnprintf "(void*)0, 0, (void*)0, (void*)0" || {
 3310     Note "... emulate vsnprintf"
 3311     PORTFUNCS="$PORTFUNCS vsnprintf.c"
 3312 }
 3313 CheckForFunc mkstemp "(void*)0" || {
 3314     Note "... emulate mkstemp"
 3315     PORTFUNCS="$PORTFUNCS mkstemp.c"
 3316 }
 3317 CheckForFunc setenv "(void*)0, (void*)0, 0" || {
 3318     Note "... emulate setenv"
 3319     PORTFUNCS="$PORTFUNCS setenv.c"
 3320 }
 3321 CheckForStdFunc srandom "0" || {
 3322     Note "... emulate srandom"
 3323     PORTFUNCS="$PORTFUNCS srandom.c"
 3324 }
 3325 CheckForStdFunc strtod "(void*)0, (void*)0" || {
 3326     Note "... emulate strtod"
 3327     PORTFUNCS="$PORTFUNCS strtod.c"
 3328 }
 3329 CheckForStdFunc strtoul "(void*)0, (void*)0, 0" || {
 3330     Note "... emulate strtoul"
 3331     PORTFUNCS="$PORTFUNCS strtoul.c"
 3332 }
 3333 
 3334 #
 3335 # SCO OS 5 #defines syslog as another function
 3336 # so it is necessary to include syslog.h when
 3337 # checking if the function is present in the
 3338 # library (sigh).
 3339 #
 3340 CheckForSyslog()
 3341 {
 3342     (echo '#include <syslog.h>';
 3343      echo '#include <stdlib.h>';
 3344      echo '#include "port.h"';
 3345      echo 'int main(int argc, char *argv[]){syslog(0,"foo");exit(0);}') >t.c
 3346     capture cat t.c
 3347     runMake t "t:; \${CC} t.c ${MACHDEPLIBS}"
 3348 }
 3349 CheckForVSyslog()
 3350 {
 3351     (echo '#include <syslog.h>';
 3352      echo '#include <stdarg.h>';
 3353      echo '#include <stdlib.h>';
 3354      echo '#include "port.h"';
 3355      echo 'int main(int argc, char *argv[]){va_list ap; vsyslog(0,"foo", ap);exit(0);}') >t.c
 3356     capture cat t.c
 3357     runMake t "t:; \${CC} t.c ${MACHDEPLIBS}"
 3358 }
 3359 if CheckForSyslog; then
 3360     CheckForVSyslog || {
 3361     Note "... emulate vsyslog"
 3362     PORTFUNCS="$PORTFUNCS vsyslog.c"
 3363     }
 3364 else
 3365     Note "... emulate syslog&co."
 3366     PORTFUNCS="$PORTFUNCS syslog.c"
 3367 fi
 3368 LIBPORT='${PORT}/libport.a'
 3369 
 3370 Note "Done checking system libraries."
 3371 
 3372 Note ""
 3373 Note "Checking ZLIB support."
 3374 #
 3375 # Verify library is compatible.
 3376 #
 3377 cat>t.c<<EOF
 3378 #include <stdlib.h>
 3379 #include <stdio.h>
 3380 #include "zlib.h"
 3381 int main(int argc, char *argv[])
 3382 {
 3383     if (strcmp(ZLIB_VERSION, "0.95") < 0) {     /* include file version */
 3384         printf("old include files: version %u\n", ZLIB_VERSION);
 3385         exit(-1);
 3386     }
 3387     if (strncmp(zlib_version, ZLIB_VERSION, 4) != 0) {
 3388         printf("library/header file incompatibility: %s %s\n",
 3389         zlib_version, ZLIB_VERSION);
 3390         exit(-1);
 3391     } else {
 3392         exit(0);
 3393     }
 3394 }
 3395 EOF
 3396 capture cat t.c
 3397 if runMake t "t:; \${CC} \${CVERSION} ${OZLIBINC} t.c ${LIBZ} ${MACHDEPLIBS}" && capture ./a.out; then
 3398                 ZLIBINC="${OZLIBINC}"
 3399     if [ -n "$OZLIBINC" ]; then
 3400     Note "Using ZLIB include files from $OZLIBINC"
 3401     fi
 3402     Note "Using pre-built ZLIB library $LIBZ"
 3403 else
 3404     LIBZ=
 3405     DIRS="/opt/freeware /usr/local /opt/zlib"
 3406     for i in $DIRS; do
 3407         if runMake t "t:; \${CC} \${CVERSION} -I${i}/include t.c -L${i}/lib -lz ${MACHDEPLIBS}" && capture ./a.out; then
 3408             OZLIBINC="-I${i}/include"
 3409             ZLIBINC="-I${i}/include"
 3410             LIBZ="-L${i}/lib -lz"
 3411             Note "Using ZLIB include files from ${i}/include"
 3412             Note "Using pre-built ZLIB library $LIBZ"
 3413             break
 3414         fi
 3415     done
 3416     if [ -z "$LIBZ" ]; then
 3417         cat 1>&2 <<EOF
 3418 
 3419 Incompatible/missing ZLIB Library.
 3420 
 3421 Compilation or execution of the following test program failed:
 3422 
 3423 ----------------------------------------------------------
 3424 EOF
 3425     cat t.c 1>&2
 3426     cat 1>&2 <<EOF
 3427 ----------------------------------------------------------
 3428 
 3429 With the following directories tried:
 3430 DIRS=<default compiler search path> ${DIRS}
 3431 
 3432 The above program checks the version of the ZLIB library to ensure it
 3433 is suitable for use with HylaFAX.  HylaFAX ${VERSION} requires a recent
 3434 ZLIB software distribution; version 0.95 or newer.  If you have the right
 3435 software, verify that you have the ZLIBINC(location of zlib.h) and
 3436 LIBZ(location of libz.a/libz.so) configuration parameters set correctly
 3437 for your system and that any environment variables are setup that are
 3438 needed to locate a libz DSO at runtime (e.g.  LD_LIBRARY_PATH).
 3439 Also be sure that any relative pathnames are made relative to the top of
 3440 the build area.
 3441 
 3442 EOF
 3443         boom
 3444     fi
 3445 fi
 3446 Note "Done checking ZLIB support."
 3447 
 3448 Note ""
 3449 Note "Checking TIFF support."
 3450 #
 3451 # Location of TIFF binaries
 3452 #
 3453 if [ -z "$TIFFBIN" ]; then
 3454     DIRS="/opt/freeware/bin /opt/local/bin /usr/local/bin /usr/contrib/bin /usr/gnu/bin /usr/bin"
 3455     for i in $DIRS; do
 3456         test -x $i/tiff2ps && { TIFFBIN=$i; break; }
 3457     done
 3458 fi
 3459 if [ -z "$TIFFBIN" ]; then
 3460     cat 1>&2 <<EOF
 3461     Cannot locate the TIFF binary files(ie tiff2ps) anywhere.
 3462 
 3463     Please install the TIFF binaries and set the TIFFBIN parameter 
 3464     to the correct path.
 3465 EOF
 3466     boom
 3467 else
 3468     Note "Using TIFF binary files from $TIFFBIN"
 3469 fi
 3470 
 3471 HAVE_JBIGTIFF="/*#define HAVE_JBIGTIFF 1*/"
 3472 if [ "$DISABLE_JBIG" != "yes" ]; then
 3473     Note "Checking JBIG-in-TIFF conversion support."
 3474     exec 3>&2 2> /dev/null  # Mute stderr, tiffcp may segfault here
 3475     $TIFFBIN/tiffcp -c g4 misc/jbig.tif misc/foo.tif > /dev/null 2>&1
 3476     EV=$?
 3477     exec 2>&3 3>&-      # Restore stderr
 3478     if [ $EV = 0 ]; then
 3479     $TIFFBIN/tiffcp misc/jbig.tif misc/foo.tif > /dev/null
 3480     if [ -n "`$TIFFBIN/tiffinfo misc/foo.tif | grep 'Fax *D[Cc][Ss]'`" ]; then
 3481         HAVE_JBIGTIFF="#define HAVE_JBIGTIFF 1"
 3482         Note "JBIG-in-TIFF conversion support found."
 3483     else
 3484         Note "JBIG-in-TIFF fax support not found."
 3485     fi
 3486     else
 3487     Note "JBIG-in-TIFF conversion support not found."
 3488     fi
 3489     rm -f misc/foo.tif
 3490 fi
 3491 
 3492 Note "Done checking TIFF support."
 3493 
 3494 if [ "$DSO" = auto ] || [ "$DSO" = yes ]; then
 3495     Note ""
 3496     Note "Checking for Dynamic Shared Object (DSO) support."
 3497     case $DSO-$TARGET in
 3498     *-*-irix*)
 3499     if (findApp rld /lib:/usr/lib:$PATH) >/dev/null 2>&1; then
 3500         DSOSUF=so
 3501         DSOOPTS="${CVERSION} -shared -rdata_shared -check_registry \${DEPTH}/${SRCDIR}/port/irix/so_locations -quickstart_info"
 3502         DSODELAY=-delay_load
 3503         LLDOPTS='-rpath ${LIBEXEC}'
 3504         DSO=IRIX
 3505         CheckCCDSO()
 3506         {
 3507         $RM t.c t.o t.${DSOSUF}
 3508         echo 'int f(void) { return 0; }'>t.c
 3509         capture cat t.c
 3510         runMake t \
 3511             't.o:; ${CCF} -c t.c' \
 3512             "t: t.o; \${CCF} ${DSOOPTS} -o t.${DSOSUF} t.o"
 3513         }
 3514         CheckCXXDSO()
 3515         {
 3516         $RM t.c++ t.o t.${DSOSUF}
 3517         echo 'int f() { return 0; }'>t.c++
 3518         capture cat t.c++
 3519         runMake t \
 3520             "t.o:; \${C++F} -c \${C++FILE} t.c++${MAKECXXOVERRIDE}" \
 3521             "t:t.o; \${C++F} ${DSOOPTS} -o t.${DSOSUF} t.o"
 3522         }
 3523     else
 3524         Note "No runtime loader found, looks like your system does not supports DSOs."
 3525         DSO=no
 3526     fi
 3527     ;;
 3528     *-*-linux*)
 3529     if [ "X${DIR_LIB}" != "X/usr/lib" ] && [ "X${DIR_LIB}" != "X/usr/lib64" ]; then
 3530         USE_RPATH=' -Wl,-rpath,${LIBDIR}'
 3531     else
 3532         USE_RPATH=''
 3533     fi
 3534     DSOSUF=so.$VERSION
 3535     LIBFAXSERVER='${FAXD}/'$LIBFAXSERVER
 3536     FAXD='${DEPTH}/faxd'
 3537     DSOOPTS='-shared -fpic -Wl,-soname,$@'
 3538     LLDOPTS='-L${UTIL} -L${FAXD} '$LIBUTIL$USE_RPATH
 3539     GCOPTS="${GCOPTS} -fpic"
 3540     GCXXOPTS="${GCXXOPTS} -pthread -fpic"
 3541     DSO=LINUX
 3542     CheckCCDSO()
 3543     {
 3544     $RM t.c t.o t.${DSOSUF}
 3545     echo 'int f(void) { return 0; }'>t.c
 3546     capture cat t.c
 3547     runMake t \
 3548         't.o:; ${CCF} -c t.c' \
 3549         "t: t.o; \${CCF} ${DSOOPTS} -o t.${DSOSUF} t.o"
 3550     }
 3551     CheckCXXDSO()
 3552     {
 3553     $RM t.c++ t.o t.${DSOSUF}
 3554     echo 'int f() { return 0; }'>t.c++
 3555     capture cat t.c++
 3556     runMake t \
 3557         "t.o:; \${C++F} -c \${C++FILE} t.c++${MAKECXXOVERRIDE}" \
 3558         "t:t.o; \${C++F} ${DSOOPTS} -o t.${DSOSUF} t.o"
 3559     }
 3560     ;;
 3561 # There has been a fair amount of back-and-forth on Solaris DSO defaults
 3562 # because it always seems to be that there is some Solaris version out there
 3563 # that won't work right, and it causes more trouble than it's worth.
 3564 # So it's defaulted to "no" since it's the path of least-resistance and the
 3565 # value of the DSO usage is rather small.
 3566     auto-*-solaris*)
 3567     Note "Automatic DSO usage on Solaris is disabled.  Use --with-DSO=yes to enable."
 3568     DSO=no
 3569     ;;
 3570     yes-*-solaris*)
 3571     if [ "X${DIR_LIB}" != "X/usr/lib" ] && [ "X${DIR_LIB}" != "X/usr/lib64" ]; then
 3572         USE_RPATH=' -R${LIBDIR}'
 3573     else
 3574         USE_RPATH=''
 3575     fi
 3576     DSOSUF=so
 3577     LIBUTIL=''
 3578     FAXD='${DEPTH}/faxd'
 3579     LIBFAXSERVER='-L${FAXD} -lfaxserver'
 3580     # options here are passed directly to ld, not through g++ first
 3581     if [ ${ISGCC} = "yes" ] ; then
 3582         DSOOPTS='-shared -Wl,-G,-h,$@'
 3583         LLDOPTS='-L${UTIL} -L${FAXD} -R${LIBDIR} -lfaxutil -lstdc++'
 3584         GCOPTS="${GCOPTS} -fpic"
 3585         GCXXOPTS="${GCXXOPTS} -pthread -fpic"
 3586     else
 3587         DSOOPTS='-G -h $@'
 3588         LLDOPTS='-L${UTIL} -L${FAXD} -R${LIBDIR} -lfaxutil -lCrun'
 3589         GCOPTS="${GCOPTS} -Kpic"
 3590         GCXXOPTS="${GCXXOPTS} -pthread -Kpic"
 3591     fi
 3592     #LLDOPTS='-L${UTIL} -L${FAXD} -R${LIBDIR} -lfaxutil'
 3593     DSO=SOLARIS
 3594     CheckCCDSO()
 3595     {
 3596     $RM t.c t.o t.${DSOSUF}
 3597     echo 'int f(void) { return 0; }'>t.c
 3598     capture cat t.c
 3599     runMake t \
 3600         't.o:; ${CCF} -c t.c' \
 3601         "t: t.o; \${CCF} ${DSOOPTS} -o t.${DSOSUF} t.o"
 3602     }
 3603     CheckCXXDSO()
 3604     {
 3605     $RM t.c++ t.o t.${DSOSUF}
 3606     echo 'int f() { return 0; }'>t.c++
 3607     capture cat t.c++
 3608     runMake t \
 3609         "t.o:; \${C++F} -c \${C++FILE} t.c++${MAKECXXOVERRIDE}" \
 3610         "t:t.o; \${C++F} ${DSOOPTS} -o t.${DSOSUF} t.o"
 3611     }
 3612     ;;
 3613     *-sysv5*)
 3614     if [ "X${DIR_LIB}" != "X/usr/lib" ]; then
 3615         USE_RPATH=' -R${LIBDIR}'
 3616     else
 3617         USE_RPATH=''
 3618     fi
 3619     DSOSUF=so
 3620     FAXD='${DEPTH}/faxd'
 3621     LIBFAXSERVER='-L${FAXD} -lfaxserver'
 3622     # options here are passed to CC, not directly to ld
 3623     DSOOPTS='-G -Wl,-h,$@'
 3624     if [ ${ISGCC} = "yes" ] ; then
 3625         LLDOPTS='-L${UTIL} -L${FAXD} -R${LIBDIR} -lfaxutil -lstdc++'
 3626         GCOPTS="${GCOPTS} -fpic"
 3627         GCXXOPTS="${GCXXOPTS} -pthread -fpic"
 3628     else
 3629         LLDOPTS='-L${UTIL} -L${FAXD} -R${LIBDIR} -lfaxutil'
 3630         GCOPTS="${GCOPTS} -Kpic"
 3631         GCXXOPTS="${GCXXOPTS} -pthread -Kpic"
 3632     fi
 3633     #LLDOPTS='-L${UTIL} -L${FAXD} -R${LIBDIR} -lfaxutil'
 3634     DSO=SYSV5
 3635     CheckCCDSO()
 3636     {
 3637     $RM t.c t.o t.${DSOSUF}
 3638     echo 'int f(void) { return 0; }'>t.c
 3639     capture cat t.c
 3640     runMake t \
 3641         't.o:; ${CCF} -c t.c' \
 3642         "t: t.o; \${CCF} ${DSOOPTS} -o t.${DSOSUF} t.o"
 3643     }
 3644     CheckCXXDSO()
 3645     {
 3646     $RM t.c++ t.o t.${DSOSUF}
 3647     echo 'int f() { return 0; }'>t.c++
 3648     capture cat t.c++
 3649     runMake t \
 3650         "t.o:; \${C++F} -c \${C++FILE} t.c++${MAKECXXOVERRIDE}" \
 3651         "t:t.o; \${C++F} ${DSOOPTS} -o t.${DSOSUF} t.o"
 3652     }
 3653     ;;
 3654     *)  Note "There is no support for building HylaFAX as DSOs on your system."
 3655     DSO=no
 3656     ;;
 3657     esac
 3658     if [ "$DSO" != no ]; then
 3659     JUNK="$JUNK t.${DSOSUF}"
 3660     # We need the new shared/DSO OPTS/FLAGS
 3661     makeDefs xdefs
 3662     if CheckCCDSO; then
 3663         if CheckCXXDSO; then
 3664         Note "Looks like your system supports $DSO-style DSOs."
 3665         else
 3666         cat 1>&4 <<EOF
 3667 Looks like your system supports DSOs...
 3668 ... but $CXXCOMPILER does not support them in the expected way.
 3669 EOF
 3670         DSO=no
 3671         fi
 3672     else
 3673         cat 1>&4 <<EOF
 3674 Looks like your system supports DSOs...
 3675 ... sigh, but $CCOMPILER does not support them in the expected way.
 3676 EOF
 3677         DSO=no
 3678     fi
 3679     fi
 3680 elif [ "$DSO" != no ]; then
 3681     Note ""
 3682     Note "Looks like your system supports $DSO-style DSOs."
 3683 fi
 3684 
 3685 if [ "$DSO" = no ]; then
 3686     MAKEDSOINCLUDE='#'
 3687     DSOSUF=a DSOOPTS= DSODELAY= LLDOPTS=
 3688 else
 3689     MAKEDSOINCLUDE="$MAKEINCLUDE"
 3690 fi
 3691 
 3692 Note ""
 3693 Note "Selecting programs used during installation and operation."
 3694 
 3695 if [ -z "$AWK" ]; then
 3696     # we need an awk that supports functions and -v
 3697     CheckAwk()
 3698     {
 3699     (set -x; $1 -v BAR=bar '
 3700 function foo(x) {
 3701     print "GOT" x
 3702 }
 3703 BEGIN { foo(BAR) }
 3704 ' </dev/null | grep GOTbar) >&5 2>&1
 3705     return
 3706     }
 3707     for i in mawk nawk gawk awk; do
 3708     x=`findApp $i $PATH`
 3709     if test "$x" && CheckAwk "$x"; then
 3710         AWK=$x
 3711         break
 3712     fi
 3713     done
 3714 fi
 3715 if [ -z "$AWK" ]; then
 3716     AWK=awk
 3717     Note ""
 3718     Note "WARNING, could not locate a suitable AWK for processing the command"
 3719     Note "         scripts included in this software distribution; using $AWK."
 3720 else
 3721     Note "Looks like $AWK should be used in command scripts."
 3722 fi
 3723 
 3724 test "$SED" || SED=`findApp sed $PATH`
 3725 if [ -z "$SED" ]; then
 3726     SED=sed
 3727     Note "WARNING, could not locate a suitable SED command; using $SED."
 3728 fi
 3729 
 3730 test "$PATH_SENDMAIL" || \
 3731     PATH_SENDMAIL=`findApp sendmail $PATH:/usr/lib:/usr/ucblib`
 3732 if [ -z "$PATH_SENDMAIL" ]; then
 3733     cat<<EOF
 3734 WARNING, could not locate sendmail on your system.
 3735 
 3736 Beware that the mail notification work done by this software uses
 3737 sendmail-specific command line options.  If you do not have a
 3738 sendmail-compatible mailer things will break.
 3739 EOF
 3740     PATH_SENDMAIL=/usr/lib/sendmail
 3741     Note "Using $PATH_SENDMAIL to deliver mail."
 3742 else
 3743     Note "Looks like $PATH_SENDMAIL should be used to deliver mail."
 3744 fi
 3745 
 3746 #
 3747 # Miscellaneous ``little'' programs.  We want absolute
 3748 # pathnames so that work done by the super-user (e.g.
 3749 # installation) is safer.
 3750 #
 3751 test "$CAT" || CAT=`findAppDef cat $PATH cat`
 3752 test "$CHGRP"   || CHGRP=`findAppDef chgrp $PATH chgrp`
 3753 test "$CHMOD"   || CHMOD=`findAppDef chmod $PATH chmod`
 3754 test "$CHOWN"   || CHOWN=`findAppDef chown $PATH chown`
 3755 test "$CMP" || CMP=`findAppDef cmp $PATH cmp`
 3756 test "$COL" || COL=`findAppDef col $PATH col`
 3757 test "$CP"  || CP=`findAppDef cp $PATH cp`
 3758 test "$ECHO"    || ECHO=`findAppDef echo $PATH echo`
 3759 test "$FILECMD" || FILECMD=`findAppDef file $PATH file`
 3760 test "$FUSER"   || FUSER=`findAppDef fuser /sbin:$PATH fuser`
 3761 test "$GENDIST" || GENDIST=`findAppDef gendist $PATH gendist`
 3762 test "$GREP"    || GREP=`findAppDef grep $PATH grep`
 3763 test "$LN"  || LN=`findAppDef ln $PATH ln`
 3764 test "$MAN" || MAN=`findAppDef man $PATH man`
 3765 test "$MIMENCODE" || MIMENCODE=`findAppDef mimencode $PATH mimencode`
 3766 test "$MIMENCODE" || MIMENCODE=`findAppDef base64-encode $PATH base64-encode`
 3767 test "$MIMENCODE" || MIMENCODE=`findAppDef base64 $PATH base64`
 3768 test "$MKDIR"   || MKDIR=`findAppDef mkdir $PATH mkdir`
 3769 test "$MV"  || MV=`findAppDef mv $PATH mv`
 3770 if [ "x$SSL" != "x" ]; then
 3771     test "$OPENSSL" || OPENSSL=`findAppDef openssl $PATH openssl`
 3772 else
 3773     OPENSSL=disabled    # the libraries are missing, cannot act as server
 3774 fi
 3775 test "$PCL6CMD" || PCL6CMD=`findAppDef pcl6 $PATH pcl6`
 3776 test "$PWDCMD"  || PWDCMD=`findAppDef pwd $PATH pwd`
 3777 test "$RMCMD"   || RMCMD=`findAppDef rm $PATH rm`
 3778 test "$SORT"    || SORT=`findAppDef sort $PATH sort`
 3779 test "$STRIP"   || STRIP=`findAppDef strip $PATH strip`
 3780 test "$TIFF2PDF" || TIFF2PDF=`findAppDef tiff2pdf $PATH bin/tiff2pdf`
 3781 test "$TTYCMD"  || TTYCMD=`findAppDef tty $PATH tty`
 3782 test "$UUENCODE" || UUENCODE=`findAppDef uuencode $PATH uuencode`
 3783 test "$UUENCODE" || UUENCODE=`findAppDef gmime-uuencode $PATH gmime-uuencode`
 3784 
 3785 #
 3786 # Test/verify we know how to create FIFO special files.
 3787 #
 3788 $RM conffifo;
 3789 if capture mkfifo conffifo && test -p conffifo >/dev/null 2>&1; then
 3790     Note "Looks like $MKFIFO creates FIFO special files."
 3791 elif test -f conffifo; then         # NB: not everyone has test -p
 3792     Note "Looks like $MKFIFO creates FIFO special files (unable to verify)."
 3793 else
 3794     # NB: we can't be certain of this because on some systems
 3795     # only root can create a FIFO special file
 3796     Note "WARNING, $MKFIFO may create FIFO special files, but testing failed."
 3797 fi
 3798 
 3799 #
 3800 # Check if mv -f is supported
 3801 #
 3802 if [ -z "$MV_F" ]; then
 3803     $RM t.c; echo "">t.c
 3804     if capture $MV -f t.c t.o; then
 3805     Note "Looks like $MV supports the -f option to force a move."
 3806     MV_F=-f
 3807     else
 3808     Note "WARNING, looks like $MV has no -f option to force move operations;"
 3809     Note "         this may cause problems during installation."
 3810     MV_F=
 3811     fi
 3812 fi
 3813 
 3814 #
 3815 # Check if ln -s creates a symbolic link.
 3816 #
 3817 if [ -z "$LN_S" ]; then
 3818     capture "$RM t.c; $LN -s foo t.c" && LN_S=-s
 3819 fi
 3820 if [ -n "$LN_S" ]; then
 3821     Note "Looks like $LN supports the -s option to create a symbolic link."
 3822 else
 3823     Note "WARNING, looks like $LN has no -s option to create symbolic links;"
 3824     Note "         this may cause problems during installation."
 3825 fi
 3826 
 3827 #
 3828 # Check if uuencode supports base64 encoding.
 3829 #
 3830 if [ -z "$ENCODING" ]; then
 3831     if [ -x "$MIMENCODE" ]; then
 3832     ENCODING=base64
 3833     Note "Looks like $MIMENCODE supports base64 encoding."
 3834     elif [ -x "$UUENCODE" ]; then
 3835     if capture "$UUENCODE -m port.h foo"; then
 3836         ENCODING=base64
 3837         Note "Looks like $UUENCODE supports base64 encoding."
 3838     else
 3839         ENCODING=x-uuencode
 3840         Note "Looks like $UUENCODE does not support base64 encoding."
 3841     fi
 3842     fi
 3843 fi
 3844 
 3845 #
 3846 # Pick install mechanism.
 3847 #
 3848 if [ -z "$INSTALL" ]; then
 3849     case $TARGET in
 3850     *-irix*)    INSTALL=`findApp install /sbin:$PATH`;;
 3851     *)      INSTALL='${SHELL} ${PORT}/install.sh';;
 3852     esac
 3853 fi
 3854 
 3855 # Location SysV style init scripts
 3856 if [ -z "$DIR_SYSVINIT" ]; then
 3857     DIR_SYSVINITS="
 3858     /etc/rc.d/init.d
 3859     /etc/init.d
 3860     "
 3861     case $TARGET in
 3862     *-sunos*)   DIR_SYSVINITS="$DIR_SYSVINITS $DIR_SBIN";;
 3863     *-hpux*)    DIR_SYSVINITS="/sbin/init.d $DIR_SYSVINITS";;
 3864     *-dec-osf*) DIR_SYSVINITS="/sbin/init.d $DIR_SYSVINITS";;
 3865     *)      ;;
 3866     esac
 3867     DIR_SYSVINIT=
 3868     for i in $DIR_SYSVINITS; do
 3869     test -d $i && { DIR_SYSVINIT=$i; break; }
 3870     done
 3871 fi
 3872 
 3873 if [ "$SYSVINIT" = auto ]; then
 3874     if test -d "$DIR_SYSVINIT"; then
 3875     SYSVINIT=yes
 3876     Note "Looks like a SysV-style init is used, enabling installation of startup code."
 3877     else
 3878     SYSVINIT=no
 3879     fi
 3880 fi
 3881 
 3882 if [ "$SYSVINIT" = yes ]; then
 3883     Note "Looks like SysV init scripts go in $DIR_SYSVINIT."
 3884 fi
 3885 
 3886 if [ "$SYSVINIT" = yes ]; then
 3887     if [ -z "$DIR_SYSVINITSTART" ]; then
 3888     case $TARGET in
 3889         *-linux*)   DIR_SYSVINITSTART="../rc2.d ../rc3.d ../rc4.d ../rc5.d";;
 3890         *)      DIR_SYSVINITSTART="../rc2.d";;
 3891     esac
 3892     fi
 3893     if [ -z "$DIR_SYSVINITSTOP" ]; then
 3894     case $TARGET in
 3895         *-linux*)   DIR_SYSVINITSTOP="../rc0.d ../rc1.d ../rc6.d";;
 3896         *-solaris*) DIR_SYSVINITSTOP="../rc0.d ../rc1.d ../rcS.d";;
 3897         *sysv4.2uw2*)   DIR_SYSVINITSTOP="../rc0.d ../rc1.d";;
 3898         *-sysv5UnixWare*)   DIR_SYSVINITSTOP="../rc0.d ../rc1.d";;
 3899         *-sysv5OpenUNIX*)   DIR_SYSVINITSTOP="../rc0.d ../rc1.d";;
 3900         *)      DIR_SYSVINITSTOP="../rc0.d";;
 3901     esac
 3902     fi
 3903     if [ -z "$NAME_SYSVINITSTART" ]; then
 3904     case $TARGET in
 3905         *-hpux*)        NAME_SYSVINITSTART="S905hylafax" ;;
 3906         *-linux*)       NAME_SYSVINITSTART="S97hylafax" ;;
 3907         *-*-sco3.2v5*)  NAME_SYSVINITSTART="S90hylafax" ;;
 3908         *)          NAME_SYSVINITSTART="S80hylafax" ;;
 3909     esac
 3910     fi
 3911     if [ -z "$NAME_SYSVINITSTOP" ]; then
 3912     case $TARGET in
 3913         *-hpux*)        NAME_SYSVINITSTOP="K095hylafax" ;;
 3914         *-solaris*)     NAME_SYSVINITSTOP="K20hylafax" ;;
 3915         *)          NAME_SYSVINITSTOP="K05hylafax" ;;
 3916     esac
 3917     fi
 3918 fi
 3919 
 3920 # now to keep from breaking etc/Makefile
 3921 if [ -z "$DIR_SYSVINITSTART" ]; then
 3922     DIR_SYSVINITSTART="dir_sysvinitstart_set_to_non_null_string"
 3923 fi
 3924 if [ -z "$DIR_SYSVINITSTOP" ]; then
 3925     DIR_SYSVINITSTOP="dir_sysvinitstop_set_to_non_null_string"
 3926 fi
 3927 
 3928 Note "Done selecting programs."
 3929 
 3930 #
 3931 # User-changable configuration parameters section.
 3932 # Anything selected here is presented to the user
 3933 # and may be interactively changed.
 3934 #
 3935 
 3936 Note ""
 3937 Note "Selecting default HylaFAX configuration parameters."
 3938 Note ""
 3939 
 3940 #
 3941 # Fill in any other configuration parameters not
 3942 # setup in the site and local files.
 3943 #
 3944 
 3945 #
 3946 # Fax user GID
 3947 #
 3948 if [ -z "$FAXGID" ]; then
 3949     case $TARGET in
 3950     *-aix*) FAXGID=uucp;;
 3951     *-bsdi*)    FAXGID=uucp;;
 3952     *freebsd2.1*) FAXGID=uucp; break;; # Not sure when this changed..
 3953     *bsd*)  FAXGID=dialer;;
 3954     *-hpux*)    FAXGID=sys;;
 3955     *-irix*)    FAXGID=nuucp;;
 3956     *-isc*) FAXGID=uucp;;
 3957     *-linux*)   FAXGID=uucp;;
 3958     *-*-sco*)   FAXGID=uucp;;
 3959     *-solaris*) FAXGID=uucp;;
 3960     *-sunos*)   FAXGID=uucp;;
 3961     *-sysv4*)   FAXGID=uucp;;
 3962     *-sysv5*)   FAXGID=uucp;;
 3963     *-ultrix*)  FAXGID=uucp;;
 3964     *)  
 3965     FAXGID=uucp
 3966     for i in uucp dialer nuucp sys; do
 3967         grep "^${i}:" /etc/group >/dev/null 2>&1 && { FAXGID=$i; break; }
 3968     done
 3969     ;;
 3970     esac
 3971 fi
 3972 Note "Using uid $FAXUID and gid $FAXGID for controlling access to fax stuff."
 3973 
 3974 #
 3975 # System installation group ID.
 3976 #
 3977 if [ -z "$SYSGID" ]; then
 3978     case $TARGET in
 3979     *-aix*) SYSGID=sys;;
 3980     *netbsd*)   SYSGID=wheel;;
 3981     *bsd*)  SYSGID=bin;;
 3982     *-hpux*)    SYSGID=bin;;
 3983     *-irix*)    SYSGID=sys;;
 3984     *-isc*) SYSGID=sys;;
 3985     *-linux*)   SYSGID=bin;;
 3986     *-*-sco*)   SYSGID=sys;;
 3987     *-solaris*) SYSGID=sys;;
 3988     *-sunos*)   SYSGID=bin;;
 3989     *-sysv4*)   SYSGID=sys;;
 3990     *-sysv5*)   SYSGID=sys;;
 3991     *-ultrix*)  SYSGID=bin;;
 3992     *)  
 3993     SYSGID=sys
 3994     for i in sys bin; do
 3995         grep "^${i}:" /etc/group >/dev/null 2>&1 && { SYSGID=$i; break; }
 3996     done
 3997     ;;
 3998     esac
 3999 fi
 4000 Note "Using uid $SYSUID and gid $SYSGID for installing programs."
 4001 
 4002 if [ -z "$FILLORDER" ]; then
 4003     #
 4004     # Host bit order within a word.
 4005     #
 4006     case $TARGET in
 4007     mips-dec-*) FILLORDER=LSB2MSB;;
 4008     i[3-6]86-*) FILLORDER=LSB2MSB;;
 4009     *)      FILLORDER=MSB2LSB;;
 4010     esac
 4011 fi
 4012 CPU=`echo $TARGET | sed 's/-.*//'`
 4013 Note "Using $FILLORDER bit order for your $CPU cpu."
 4014 
 4015 # SVR4 packaging stuff
 4016 if [ -z "$PKG_ARCH" ]; then
 4017     PKG_ARCH=$CPU
 4018 fi
 4019 
 4020 #
 4021 # Style of getty support.
 4022 #
 4023 if [ "$GETTY" = auto ]; then
 4024     case $TARGET in
 4025     *bsd*)  GETTY=BSD;;
 4026     *-sunos*)   GETTY=BSD;;
 4027     *-ultrix*)  GETTY=BSD;;
 4028     *darwin*)   GETTY=BSD;;
 4029     *)      GETTY=SysV;;
 4030     esac
 4031 fi
 4032 Note "Looks like you need $GETTY getty support."
 4033 if [ -z "$PATH_GETTY" ]; then
 4034     if CheckForDefine _PATH_GETTY paths.h; then
 4035     Note "Using _PATH_GETTY from <paths.h> as the program to exec for a data call."
 4036     else
 4037     #
 4038     # NB: use findFile instead of findApp because on some
 4039     #     systems this file is mode 544; so if configure
 4040     #     is run by an unprivileged user the file will not
 4041     #     be located.
 4042     #
 4043     PATH_GETTY=`findFile ttymon /usr/lib/saf:/usr/libexec:/sbin:$PATH`
 4044     test -z "$PATH_GETTY" && \
 4045         PATH_GETTY=`findApp agetty /usr/libexec:/sbin:$PATH`
 4046     test -z "$PATH_GETTY" && \
 4047         PATH_GETTY=`findApp mgetty /usr/libexec:/sbin:$PATH`
 4048     test -z "$PATH_GETTY" && \
 4049         PATH_GETTY=`findApp getty /usr/libexec:/sbin:$PATH`
 4050     if [ -z "$PATH_GETTY" ]; then
 4051         PATH_GETTY=/etc/getty
 4052         Note ""
 4053         Note "WARNING, could not locate a suitable getty program to exec for a"
 4054         Note "         data call; using a default value $PATH_GETTY."
 4055         Note ""
 4056     else
 4057         Note "Looks like $PATH_GETTY is the program to exec for a data call."
 4058     fi
 4059     fi
 4060 else
 4061     Note "Using $PATH_GETTY as the program to exec for a data call."
 4062 fi
 4063 
 4064 # vgetty support
 4065 if [ -z "$PATH_VGETTY" ]; then
 4066     PATH_VGETTY=`findApp vgetty /usr/libexec:/sbin:$PATH` 
 4067     if [ -z "$PATH_VGETTY" ]; then
 4068     PATH_VGETTY=/bin/vgetty
 4069     Note "WARNING, no vgetty program found to handle a voice call, using $PATH_VGETTY."
 4070     else
 4071     Note "Looks like $PATH_VGETTY is the program to exec for a voice call."
 4072     fi
 4073 else
 4074     Note "Using $PATH_VGETTY as the program to exec for a voice call."
 4075 fi
 4076 
 4077 # egetty support
 4078 if [ -z "$PATH_EGETTY" ]; then
 4079     PATH_EGETTY=`findApp egetty /usr/libexec:/sbin:$PATH` 
 4080     if [ -z "$PATH_EGETTY" ]; then
 4081     PATH_EGETTY=/bin/egetty
 4082     Note "WARNING, no egetty program found, using $PATH_EGETTY."
 4083     else
 4084     Note "Looks like $PATH_EGETTY is the program to exec for an extern call."
 4085     fi
 4086 else
 4087     Note "Using $PATH_EGETTY as the program to exec for an extern call."
 4088 fi
 4089 
 4090 #
 4091 # UUCP lock file type and location.
 4092 #
 4093 if [ "$LOCKS" = auto ]; then
 4094     case $TARGET in
 4095     *-aix*) LOCKS=ascii;;
 4096     *-*-sco*)   LOCKS="-ascii";;
 4097     *-sysv2*)   LOCKS=binary;;
 4098     *-hpux*)    LOCKS=binary;;
 4099     *-sysv4*)   LOCKS="+ascii";;
 4100     *-sysv5*)   LOCKS="-ascii";;
 4101     *-solaris*) LOCKS="+ascii";;
 4102     *-freebsd*) LOCKS=ascii;;
 4103     *-netbsd*)  LOCKS=ascii;;
 4104     *bsd*)  LOCKS=binary;;
 4105     *)      LOCKS=ascii;;
 4106     esac
 4107 fi
 4108 Note "Looks like you use ${LOCKS}-style UUCP lock files."
 4109 if [ -z "$DIR_LOCKS" ]; then
 4110     LOCKDIRS="
 4111     /var/spool/locks
 4112     /usr/spool/locks
 4113     /var/spool/lock
 4114     /usr/spool/lock
 4115     /var/spool/uucp
 4116     /usr/spool/uucp
 4117     "
 4118     case $TARGET in
 4119     *-aix*)     LOCKDIRS="/etc/locks $LOCKDIRS";;
 4120     *-linux*)   LOCKDIRS="/var/lock/uucp /var/lock $LOCKDIRS";;
 4121     *-*-sco*)   LOCKDIRS="/usr/spool/uucp $LOCKDIRS";;
 4122     *-*-sysv5*) LOCKDIRS="/usr/spool/uucp $LOCKDIRS";;
 4123     esac
 4124     DIR_LOCKS=
 4125     for i in $LOCKDIRS; do
 4126     test -d $i && { DIR_LOCKS=$i; break; }
 4127     done
 4128 fi
 4129 if [ -z "$DIR_LOCKS" ]; then
 4130     DIR_LOCKS=/var/spool/uucp
 4131     Note "WARNING, could not locate a directory for UUCP lock files,"
 4132     Note "guessing that UUCP lock files go in $DIR_LOCKS."
 4133 else
 4134     Note "Looks like UUCP lock files go in $DIR_LOCKS."
 4135 fi
 4136 
 4137 bitchExecutable()
 4138 {
 4139     echo ""
 4140     echo "WARNING, $1 does not seem to be an executable program;"
 4141     echo "         you may need to correct this before starting up the fax server."
 4142     ls -lL $1
 4143     echo ""
 4144 }
 4145 
 4146 #
 4147 # PostScript package and RIP location.
 4148 #
 4149 PickRIP()
 4150 {
 4151     if [ -z "$PATH_GSRIP" ]; then
 4152     GSLOCS="
 4153         /opt/local/bin/gs
 4154         /usr/local/bin/gs
 4155         /usr/contrib/bin/gs
 4156         /opt/freeware/bin/gs
 4157         /usr/gnu/bin/gs
 4158         /opt/gnu/bin/gs
 4159         /usr/bin/gs
 4160         /usr/sfw/bin/gs
 4161     "
 4162     for i in $GSLOCS; do
 4163         # verify Ghostscript was linked with the tiffg3 device driver
 4164         capture "$i -h 2>&1 | grep tiffg3" && { PATH_GSRIP=$i; break; }
 4165     done
 4166     fi
 4167     case $PS in
 4168     dps)    PATH_PSRIP=$PATH_DPSRIP;;
 4169     imp)    PATH_PSRIP=$PATH_IMPRIP;;
 4170     gs)     PATH_PSRIP=$PATH_GSRIP;;
 4171     esac
 4172 }
 4173 CheckRIP()
 4174 {
 4175     if [ -x "$PATH_PSRIP" ]; then
 4176     if [ $PS = gs ]; then
 4177         # verify Ghostscript was linked with the tiffg3 device driver
 4178         capture "$PATH_PSRIP -h 2>&1 | grep tiffg3" || cat<<EOF
 4179 
 4180 WARNING, no tiffg3 driver in $PATH_PSRIP.
 4181 
 4182 The PostScript imaging program $PATH_PSRIP does not appear to be
 4183 to be configured with the tiffg3 device driver.  This is necessary for the
 4184 fax software to operate correctly.  See the documentation for information
 4185 on building Ghostscript with the necessary TIFF driver.
 4186 EOF
 4187     fi
 4188     elif [ -n "$PATH_PSRIP" ]; then
 4189     bitchExecutable $PATH_PSRIP
 4190     else
 4191     cat<<EOF
 4192 
 4193 WARNING, no PostScript imaging program.
 4194 
 4195 No suitable PostScript imaging program was located on your system.
 4196 This may be due to your not having Ghostscript installed or not having
 4197 Ghostscript configured with the tiffg3 device driver.  A default pathname
 4198 will be used for the moment.  You must correct this situation for the
 4199 fax software to operate correctly.  See the WWW documentation for information
 4200 on building Ghostscript with the necessary TIFF driver.
 4201 
 4202 EOF
 4203     PATH_PSRIP=/usr/local/bin/gs
 4204     PATH_GSRIP=$PATH_PSRIP
 4205     fi
 4206 }
 4207 
 4208 if [ "$PS" = auto ]; then
 4209     case $TARGET in
 4210     *-irix*)    if expr $RELEASE \>= 6.2 >/dev/null; then
 4211             PS=gs;
 4212         else
 4213             PS=dps;
 4214         fi
 4215         ;;
 4216     *)      PS=gs;;
 4217     esac
 4218 fi
 4219 Note "Looks like the $PS imager package should be used."
 4220 PickRIP
 4221 Note "Looks like $PATH_PSRIP is the PostScript RIP to use."
 4222 CheckRIP
 4223 
 4224 #
 4225 # Ghostscript Fontmap File
 4226 #
 4227 
 4228 getGSFonts()
 4229 {
 4230     if [ ! "$PS" = gs ] && [ -n $PATH_PSRIP ];then
 4231         return 1
 4232     fi
 4233     $PATH_PSRIP -h | $AWK -F '[ ]' '
 4234         BEGIN { start = 0; }
 4235         /Search path:/ { start = 1 }
 4236         {
 4237             if (start == 1) {
 4238                 if ($1 == "") {
 4239                     gsub(" ","")
 4240                     gsub("^[.]","")
 4241                     gsub("^:","")
 4242                     printf "%s", $0
 4243                 } else if ($1 != "Search") start = 0
 4244             }
 4245         }   
 4246     '
 4247     return 0
 4248 }
 4249 
 4250 case $TARGET in
 4251     *-freebsd*)     PATH_AFM=/usr/local/lib/afm ;;
 4252     *)      if [ -z "$FONTMAP" ]; then
 4253             FONTMAP=`getGSFonts`;
 4254         fi
 4255         ;;
 4256 esac
 4257 Note "Setting the Fontmap path to $FONTMAP"
 4258 
 4259 #
 4260 # Location of Adobe Font Metric files.
 4261 #
 4262 if [ -z "$PATH_AFM" ]; then
 4263     # if the fontmap path is available use that
 4264     # else just guess
 4265     if [ -n "$FONTMAP" ]; then
 4266     PATH_AFM=$FONTMAP
 4267     else
 4268         DIR_AFMS="
 4269         /usr/lib/afm
 4270         /opt/local/lib/afm
 4271         /opt/freeware/lib/afm
 4272         /opt/freeware/share/ghostscript/fonts
 4273         /usr/local/lib/afm
 4274         /usr/local/share/ghostscript/fonts
 4275         /usr/local/lib/ghostscript/fonts
 4276         /usr/share/ghostscript/fonts
 4277         /usr/gnu/lib/ghostscript/fonts
 4278         /opt/gnu/lib/ghostscript/fonts
 4279         /usr/lib/ghostscript/fonts
 4280         /usr/lib/gnu/ghostscript/fonts
 4281         "
 4282         case $TARGET in
 4283         *-irix*)    DIR_AFMS="/usr/lib/DPS/AFM $DIR_AFMS";;
 4284         *-bsdi*)    DIR_AFMS="/usr/contrib/lib/flexfax/afm $DIR_AFMS";;
 4285         *-sunos*)   DIR_AFMS="/usr/openwin/lib/fonts/afm $DIR_AFMS";;
 4286         esac
 4287         PATH_AFM=
 4288         for i in $DIR_AFMS; do
 4289         test -d $i && { PATH_AFM=$i; break; }
 4290         done
 4291     fi
 4292 fi
 4293 if [ -z "$PATH_AFM" ]; then
 4294     # put it where ghostscript normally puts things
 4295     PATH_AFM=/usr/local/lib/ghostscript/fonts
 4296     Note "WARNING, could not locate a directory with font metric information,"
 4297     Note "guessing that font metric information goes in $PATH_AFM."
 4298 else
 4299     Note "Looks like font metric information goes in $PATH_AFM."
 4300 fi
 4301 
 4302 #
 4303 # Setup manual page-related stuff.
 4304 #
 4305 # Manual pages are processed according to:
 4306 # 1. Section organization (BSD or System V)
 4307 # 2. Pre-formatted (w/ nroff) or source.
 4308 # 3. Compressed (compress, gzip, pack) or uncompressed.
 4309 # 4. Whether or not the FlexFAX ``F'' suffix must be
 4310 #    stripped for pages to be found (only for 4F pages).
 4311 #
 4312 if [ -z "$DIR_MAN" ]; then
 4313     MANPATH="
 4314     $MANPATH
 4315     /opt/freeware/man
 4316     /usr/share/man
 4317     /usr/local/man
 4318     /usr/contrib/man
 4319     /usr/catman/local
 4320     "
 4321     DIR_MAN=
 4322     for i in $MANPATH; do
 4323     test -d $i && { DIR_MAN=$i; break; }
 4324     done
 4325     test -z "$DIR_MAN" && DIR_MAN=/usr/local/man
 4326 fi
 4327 Note "Looks like manual pages go in $DIR_MAN."
 4328 if [ -z "$MANSCHEME" ]; then
 4329     case $TARGET in
 4330     *-bsdi*|*-netbsd*)      MANSCHEME=bsd-nroff-gzip-0.gz;;
 4331     *-freebsd*)         MANSCHEME=bsd-source-cat;;
 4332     *-linux*)           MANSCHEME=bsd-source-cat;;
 4333     *-ultrix*)          MANSCHEME=bsd-source-cat;;
 4334     *-sunos*)           MANSCHEME=bsd-source-cat-strip;;
 4335     *-sysv[2345]*)      MANSCHEME=sysv-source-cat-strip;;
 4336     *-hpux*)            MANSCHEME=sysv-source-cat-strip;;
 4337     *-solaris*)         MANSCHEME=sysv-source-cat-strip;;
 4338     *-aix*)         MANSCHEME=sysv-source-strip;;
 4339     *-isc*|*-*-sco*)        MANSCHEME=sysv-source-cat;;
 4340     *-irix*)            MANSCHEME=sysv-nroff-compress-Z;;
 4341     *)
 4342     #
 4343     # Try to deduce the setup from existing manual pages.
 4344     # XXX needs more work XXX
 4345     #
 4346     MANSCHEME=sysv-source-cat
 4347     if [ -d /usr/share/man ]; then
 4348         if [ -d /usr/share/man/u_man ]; then
 4349            MANSCHEME=sysv-source-cat
 4350         elif [ -d /usr/share/man/man8 ]; then
 4351            MANSCHEME=bsd-source-cat
 4352         fi
 4353     elif [ -d /usr/share/catman ]; then
 4354         if [ -d /usr/share/catman/u_man ]; then
 4355            MANSCHEME=sysv-nroff-cat
 4356         elif [ -d /usr/share/catman/man8 ]; then
 4357            MANSCHEME=bsd-nroff-cat
 4358         fi
 4359     fi
 4360     ;;
 4361     esac
 4362 fi
 4363 Note "Looks like manual pages should be installed with $MANSCHEME."
 4364 
 4365 #
 4366 # Figure out which brand of echo we have and define
 4367 # prompt and print shell functions accordingly.
 4368 #
 4369 if [ "`echo foo\\\c`@" = "foo@" ]; then
 4370     prompt()
 4371     {
 4372     echo "$* \\c"
 4373     }
 4374 elif [ "`echo -n foo`@" = "foo@" ]; then
 4375     prompt()
 4376     {
 4377     echo -n "$* "
 4378     }
 4379 else
 4380     prompt()
 4381     {
 4382     echo "$*"
 4383     }
 4384 fi
 4385 
 4386 #
 4387 # Prompt the user for a string that can not be null.
 4388 #
 4389 promptForNonNullStringParameter()
 4390 {
 4391     x="" val="$1" desc="$2"
 4392     while [ -z "$x" ]; do
 4393     prompt "$desc [$val]?"; read x
 4394     if [ "$x" ]; then
 4395         # strip leading and trailing white space
 4396         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[   ]*$//'`
 4397     else
 4398         x="$val"
 4399     fi
 4400     done
 4401     param="$x"
 4402 }
 4403 
 4404 #
 4405 # Prompt the user for a numeric value.
 4406 #
 4407 promptForNumericParameter()
 4408 {
 4409     x="" val="$1" desc="$2"
 4410     while [ -z "$x" ]; do
 4411     prompt "$desc [$val]?"; read x
 4412     if [ "$x" ]; then
 4413         # strip leading and trailing white space
 4414         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[   ]*$//'`
 4415         match=`expr "$x" : "\([0-9]*\)"`
 4416         if [ "$match" != "$x" ]; then
 4417         echo ""
 4418         echo "This must be entirely numeric; please correct it."
 4419         echo ""
 4420         x="";
 4421         fi
 4422     else
 4423         x="$val"
 4424     fi
 4425     done
 4426     param="$x"
 4427 }
 4428 
 4429 promptForImagerPackage()
 4430 {
 4431     x=""
 4432     while [ -z "$x" ]; do
 4433     prompt "PostScript imager package [$PS]?"; read x
 4434     if [ "$x" ]; then
 4435         # strip leading and trailing white space
 4436         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[   ]*$//'`
 4437         case "$x" in
 4438         [dD]ps|DPS)         x="dps";;
 4439         [gG]s|[gG]host[sS]cript)    x="gs";;
 4440         imp)            x="imp";;
 4441         *)
 4442 cat <<EOF
 4443 
 4444 "$x" is not a PostScript imager package; choose one of:
 4445 
 4446 dps for Display PostScript on a Silicon Graphics machine running
 4447     any version of IRIX *prior* to 6.2
 4448 gs  for the freely available Ghostscript package
 4449 imp for Impressario 2.1 on a Silicon Graphics machine
 4450 
 4451 EOF
 4452         x="";;
 4453         esac
 4454     else
 4455         x="$PS"
 4456     fi
 4457     done
 4458     PS="$x"
 4459 }
 4460 
 4461 promptForPageSize()
 4462 {
 4463     file=$1 x=""
 4464     while [ -z "$x" ]; do
 4465     prompt "Default page size [$PAGESIZE]?"; read x
 4466     if [ "$x" ]; then
 4467         # strip leading and trailing white space
 4468         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[   ]*$//'`
 4469         # search pagesizes file for an entry
 4470         y=`sed -e '/^#/d' $file | grep -i "$x" | sed -e 's/ .*//;q'`
 4471         if [ -z "$y" ]; then
 4472         cat<<EOF
 4473 
 4474 "$x" is not a known page size; the following are known page sizes:
 4475 
 4476 Name            Abbrev  Width   Height  Width   Height  Top Left
 4477 EOF
 4478         sed -e '/^#/d' -e '/@DEFPAGESIZE@/d' $file
 4479         echo ""
 4480         x=""
 4481         else
 4482         x="$y"
 4483         fi
 4484     else
 4485         x="$PAGESIZE"
 4486     fi
 4487     done
 4488     PAGESIZE="$x"
 4489 }
 4490 
 4491 #
 4492 # Prompt the user for a numeric value.
 4493 #
 4494 promptForVRes()
 4495 {
 4496     x=""
 4497     while [ -z "$x" ]; do
 4498     prompt "Default vertical res (lpi) [$DEFVRES]?"; read x
 4499     if [ "$x" ]; then
 4500         # strip leading and trailing white space
 4501         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[   ]*$//'`
 4502         case "$x" in
 4503         98|low|med*)    x="98";;
 4504         196|high|fine)  x="196";;
 4505         *)
 4506 cat <<EOF
 4507 
 4508 "$x" is not a valid vertical resolution; choose either "98" lines/inch
 4509 (low resolution) or "196" lines/inch (often called fine resolution).
 4510 
 4511 EOF
 4512         x="";;
 4513         esac
 4514     else
 4515         x="$DEFVRES"
 4516     fi
 4517     done
 4518     DEFVRES="$x"
 4519 }
 4520 
 4521 promptForUUCPLockScheme()
 4522 {
 4523     x=""
 4524     while [ -z "$x" ]; do
 4525     prompt "UUCP lock file scheme [$LOCKS]?"; read x
 4526     if [ "$x" ]; then
 4527         # strip leading and trailing white space
 4528         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[   ]*$//'`
 4529         case "$x" in
 4530         ascii|[-+]ascii)    ;;
 4531         binary|[-+]binary)  ;;
 4532         *)
 4533 cat <<EOF
 4534 
 4535 "$x" is not a valid UUCP lock file scheme; choose "ascii" or
 4536 "binary" to get lock files with the process ID of the lock holder
 4537 written as ASCII or binary values and optionally prefix this with
 4538 "+" for SVR4-style lock file names (LK.xxx.yyy.zzz) or "-" for
 4539 SCO-style lock file names (convert tty names from upper to lower
 4540 case when forming the lock file name).
 4541 
 4542 EOF
 4543         x="";;
 4544         esac
 4545     else
 4546         x="$LOCKS"
 4547     fi
 4548     done
 4549     LOCKS="$x"
 4550 }
 4551 
 4552 promptForManPageScheme()
 4553 {
 4554     x=""
 4555     while [ -z "$x" ]; do
 4556     prompt "Manual page installation scheme [$MANSCHEME]?"; read x
 4557     if [ "$x" ]; then
 4558         # strip leading and trailing white space
 4559         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[   ]*$//'`
 4560         # XXX do a better job of validating...
 4561         case "$x" in
 4562         bsd-nroff-cat*|sysv-nroff-cat*) ;;
 4563         bsd-nroff-gzip*|sysv-nroff-gzip*)   ;;
 4564         bsd-nroff-comp*|sysv-nroff-comp*)   ;;
 4565         bsd-nroff-pack*|sysv-nroff-pack*)   ;;
 4566         bsd-source-cat*|sysv-source-cat*)   ;;
 4567         bsd-source-gzip*|sysv-source-gzip*) ;;
 4568         bsd-source-comp*|sysv-source-comp*) ;;
 4569         bsd-source-pack*|sysv-source-pack*) ;;
 4570         *)
 4571 cat <<EOF
 4572 
 4573 "$x" is not a valid manual page installation scheme.  Schemes are
 4574 constructed according to:
 4575 
 4576     <organization>-<formatting>-<compression>[-<suffix>]
 4577 
 4578 where:
 4579 
 4580 <organization>  is either "bsd" for BSD-style section organization (e.g.
 4581         file formats in section 5) or "sysv" for System V-style
 4582         organization (e.g. file formats in section 4).
 4583 
 4584 <formatting>    is either "nroff" to force installation of formatted
 4585                 materials (using nroff) or "source" to get the nroff
 4586         source installed.
 4587 
 4588 <compression>   is either the name of a program to compress the manual
 4589                 pages (gipz, compress, pack) or "cat" for uncompressed data.
 4590 
 4591 <suffix>        is either the file suffix to convert installed pages to
 4592                 (e.g. 0.gz for gzip-compressed pages under BSD) or "strip"
 4593         to force the normal ".4f" suffix to be converted to ".4"
 4594         (or ".5" if using the BSD organization).  If no -<suffix>
 4595         is specified then filenames are not converted when they
 4596         are installed.
 4597 
 4598 Common schemes are:
 4599 
 4600 bsd-nroff-gzip-0.gz compressed formatted pages for BSD 
 4601 bsd-source-cat      nroff source w/ BSD organization
 4602 sysv-source-cat-strip   nroff source for SysV w/o .4f suffix
 4603 sysv-source-cat     nroff source for SysV as-is
 4604 
 4605 EOF
 4606         x="";;
 4607         esac
 4608     else
 4609         x="$MANSCHEME"
 4610     fi
 4611     done
 4612     MANSCHEME="$x"
 4613 }
 4614 
 4615 getPageSizeInfo()
 4616 {
 4617     pat=`grep '^default' $1 | \
 4618     sed -e 's/default[   ]*//' -e 's/[  ][  ]*/\[   \]*/g'`
 4619     param=`grep "$pat" $1 | sed -e 's/  .*//;q'`
 4620 }
 4621 
 4622 printConfig1()
 4623 {
 4624     cat<<EOF
 4625 
 4626 HylaFAX configuration parameters (part 1 of 2) are:
 4627 
 4628 [ 1] Directory for applications:        $DIR_BIN
 4629 [ 2] Directory for lib data files:      $DIR_LIBDATA
 4630 [ 3] Directory for lib executables:     $DIR_LIBEXEC
 4631 [ 4] Directory for system apps:     $DIR_SBIN
 4632 [ 5] Directory for manual pages:        $DIR_MAN
 4633 [ 6] Directory for spooling:            $DIR_SPOOL
 4634 [ 7] Directory for uucp lock files:     $DIR_LOCKS
 4635 [ 8] Uucp lock file scheme:             $LOCKS
 4636 [ 9] PostScript imager package:         $PS
 4637 [10] PostScript imager program:         $PATH_PSRIP
 4638 [11] Manual page installation scheme:   $MANSCHEME
 4639 [12] Default page size:                 $PAGESIZE
 4640 [13] Default vertical res (lpi):        $DEFVRES
 4641 
 4642 EOF
 4643 }
 4644 
 4645 printConfig2()
 4646 {
 4647     cat<<EOF
 4648 
 4649 HylaFAX configuration parameters (part 2 of 2) are:
 4650 
 4651 [14] Location of getty program:         $PATH_GETTY
 4652 [15] Location of voice getty program:   $PATH_VGETTY
 4653 [16] Location of sendmail program:      $PATH_SENDMAIL
 4654 [17] Location of TIFF tools:            $TIFFBIN
 4655 [18] Location of SysV init scripts: $DIR_SYSVINIT
 4656 [19] Location of SysV start scripts:    $DIR_SYSVINITSTART
 4657 [20] Location of SysV stop scripts: $DIR_SYSVINITSTOP
 4658 [21] Name of SysV start script:     $NAME_SYSVINITSTART
 4659 [22] Name of SysV stop script:      $NAME_SYSVINITSTOP
 4660 [23] Init script starts faxq:       $FAXQ_SERVER
 4661 [24] Init script starts hfaxd       $HFAXD_SERVER
 4662 [25] Start paging protocol:     $HFAXD_SNPP_SERVER
 4663 EOF
 4664 }
 4665   
 4666 
 4667 promptForParameter()
 4668 {
 4669     case $1 in
 4670     1)  promptForNonNullStringParameter "$DIR_BIN" \
 4671         "Directory to install applications";    DIR_BIN="$param"
 4672     ;;
 4673     2)  promptForNonNullStringParameter "$DIR_LIBDATA" \
 4674         "Directory to install library data files";  DIR_LIBDATA="$param"
 4675     ;;
 4676     3)  promptForNonNullStringParameter "$DIR_LIBEXEC" \
 4677         "Directory to install library executables"; DIR_LIBEXEC="$param"
 4678     ;;
 4679     4)  promptForNonNullStringParameter "$DIR_SBIN" \
 4680         "Directory to install system apps";     DIR_SBIN="$param"
 4681     ;;
 4682     5)  promptForNonNullStringParameter "$DIR_MAN" \
 4683         "Directory to install manual pages";    DIR_MAN="$param"
 4684     ;;
 4685     6)  promptForNonNullStringParameter "$DIR_SPOOL" \
 4686         "Directory to setup server spooling area";  DIR_SPOOL="$param"
 4687     ;;
 4688     7)  promptForNonNullStringParameter "$DIR_LOCKS" \
 4689         "Directory for uucp lock files";        DIR_LOCKS="$param"
 4690     ;;
 4691     8)  promptForUUCPLockScheme;;
 4692     9)  promptForImagerPackage; PickRIP; CheckRIP;;
 4693     10) promptForNonNullStringParameter "$PATH_PSRIP" \
 4694         "PostScript imager program";        PATH_PSRIP="$param"
 4695     case "$PS" in
 4696     dps)    PATH_DPSRIP=$PATH_PSRIP;;
 4697     imp)    PATH_IMPRIP=$PATH_PSRIP;;
 4698     gs) PATH_GSRIP=$PATH_PSRIP;;
 4699     esac
 4700     ;;
 4701     11) promptForManPageScheme;;
 4702     12) promptForPageSize $SRCDIR/util/pagesizes.in;;
 4703     13) promptForVRes;;
 4704     14) promptForNonNullStringParameter "$PATH_GETTY" \
 4705         "Location of getty program";        PATH_GETTY="$param"
 4706     ;;
 4707     15) promptForNonNullStringParameter "$PATH_VGETTY" \
 4708         "Location of vgetty program";           PATH_VGETTY="$param"
 4709     ;;
 4710     16) promptForNonNullStringParameter "$PATH_SENDMAIL" \
 4711         "Location of sendmail program";     PATH_SENDMAIL="$param"
 4712     ;;
 4713     17) promptForNonNullStringParameter "$TIFFBIN" \
 4714         "Location of TIFF tools";           TIFFBIN="$param"
 4715     ;;
 4716     18) promptForNonNullStringParameter "$DIR_SYSVINIT" \
 4717         "Location of SysV init scripts";        DIR_SYSVINIT="$param"
 4718     ;;
 4719     19) promptForNonNullStringParameter "$DIR_SYSVINITSTART" \
 4720         "Location of SysV start scripts";       DIR_SYSVINITSTART="$param"
 4721     ;;
 4722     20) promptForNonNullStringParameter "$DIR_SYSVINITSTOP" \
 4723         "Location of SysV stop scripts";        DIR_SYSVINITSTOP="$param"
 4724     ;;
 4725     21) promptForNonNullStringParameter "$NAME_SYSVINITSTART" \
 4726         "Name of SysV start script";        NAME_SYSVINITSTART="$param"
 4727     ;;
 4728     22) promptForNonNullStringParameter "$NAME_SYSVINITSTOP" \
 4729         "Name of SysV stop script";         NAME_SYSVINITSTOP="$param"
 4730     ;;
 4731     23) promptForNonNullStringParameter "$FAXQ_SERVER" \
 4732         "Init script starts faxq";          FAXQ_SERVER="$param"
 4733     ;;
 4734     24) promptForNonNullStringParameter "$HFAXD_SERVER" \
 4735         "Init script starts hfaxd";         HFAXD_SERVER="$param"
 4736     ;;
 4737     25) promptForNonNullStringParameter "$HFAXD_SNPP_SERVER" \
 4738         "Start paging protocol";            HFAXD_SNPP_SERVER="$param"
 4739     ;;
 4740     esac
 4741 }
 4742 
 4743 checkForExecutable()
 4744 {
 4745     test -x $1 || bitchExecutable $1
 4746 }
 4747 
 4748 if [ $QUIET = no ] && [ $INTERACTIVE != no ]; then
 4749     Note "Press Return to Continue "
 4750     read ok
 4751 fi
 4752 
 4753 if [ $QUIET = no ]; then
 4754     ok=skip
 4755     while [ "$ok" != y ] && [ "$ok" != yes ]; do
 4756     if [ "$ok" != skip ]; then
 4757         for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
 4758         promptForParameter $i;
 4759         done
 4760     fi
 4761     printConfig1
 4762     if [ $INTERACTIVE = no ]; then
 4763         ok=yes
 4764     else
 4765         prompt "Are these ok [yes]?"; read ok
 4766         test -z "$ok" && ok=yes
 4767         case "$ok" in
 4768         [1-9]|1[0-4])   promptForParameter $ok;;
 4769         [yY]*|[nN]*)    continue;;
 4770         ?*)
 4771         echo ""
 4772         echo "\"y\", \"yes\", or <RETURN> accepts the displayed parameters."
 4773         echo "A number lets you change the numbered parameter."
 4774         echo ""
 4775         ;;
 4776         esac
 4777         ok=skip
 4778     fi
 4779     done
 4780 fi
 4781 
 4782 if [ $QUIET = no ]; then
 4783     ok=skip
 4784     while [ "$ok" != y ] && [ "$ok" != yes ]; do
 4785     if [ "$ok" != skip ]; then
 4786         for i in 15 16 17 18 19 20 21 22 23 24 25 26 27 ; do
 4787         promptForParameter $i;
 4788         done
 4789     fi
 4790     printConfig2
 4791     checkForExecutable $PATH_SENDMAIL
 4792     checkForExecutable $PATH_GETTY
 4793     if [ $INTERACTIVE = no ]; then
 4794         ok=yes
 4795     else
 4796         prompt "Are these ok [yes]?"; read ok
 4797         test -z "$ok" && ok=yes
 4798         case "$ok" in
 4799         1[5-9]|2[0-7])  promptForParameter $ok;;
 4800         [yY]*|[nN]*)    continue;;
 4801         ?*)
 4802         echo ""
 4803         echo "\"y\", \"yes\", or <RETURN> accepts the displayed parameters."
 4804         echo "A number lets you change the numbered parameter."
 4805         echo ""
 4806         ;;
 4807         esac
 4808         ok=skip
 4809     fi
 4810     done
 4811 fi
 4812 
 4813 $RM config.cache; dumpvals |sort> config.cache
 4814 case $MANSCHEME in
 4815 bsd-source-*)   MANAPPS=man1 MANSYS=man8 MANFILES=man5;;
 4816 bsd-nroff-*)    MANAPPS=cat1 MANSYS=cat8 MANFILES=cat5;;
 4817 sysv-source-*)  MANAPPS=man1 MANSYS=man1 MANFILES=man4;;
 4818 sysv-nroff-*)   MANAPPS=cat1 MANSYS=cat1 MANFILES=cat4;;
 4819 esac
 4820 case $MANSCHEME in
 4821 bsd-*-strip)    MANNUM4_5=5  MANNUM1_8=8;;
 4822 bsd-*)      MANNUM4_5=5F MANNUM1_8=8C;;
 4823 sysv-*-strip)   MANNUM4_5=4  MANNUM1_8=1;;
 4824 sysv-*)     MANNUM4_5=4F MANNUM1_8=1M;;
 4825 esac
 4826 case $MANSCHEME in
 4827 *-source-*) MANCVT='${MANSED} $? >$@';;
 4828 *-nroff-gzip-*) MANCVT='${MANSED} $? | nroff -man | gzip > $@';;
 4829 *-nroff-pack-*) MANCVT='${MANSED} $? | nroff -man | pack > $@';;
 4830 *-nroff-com*-*) MANCVT='${MANSED} $? | nroff -man | compress > $@';;
 4831 *-nroff-cat-*)  MANCVT='${MANSED} $? | nroff -man > $@';;
 4832 esac
 4833 case $MANSCHEME in
 4834 *-0|*-0.gz|*-0.Z|*-gz|*-Z|*-z)
 4835     suf=`echo $MANSCHEME | $SED 's/.*-/./'`
 4836     A='`echo $$i | sed' B='`'       # workaround shell bugs
 4837     MANCAPPNAME="$A s/\\\\.1\$\$/$suf/$B"
 4838     MANCFILENAME="$A s/\\\\.4f\$\$/$suf/$B"
 4839     MANSAPPNAME="$A s/\\\\.1m\$\$/$suf/$B"
 4840     MANSFILENAME="$A s/\\\\.4f\$\$/$suf/$B"
 4841     ;;
 4842 bsd-*-strip)
 4843     MANCAPPNAME='$$i'
 4844     MANCFILENAME='`echo $$i | sed s/\\.4f$$/.5/`'
 4845     MANSAPPNAME='`echo $$i | sed s/\\.1m$$/.8/`'
 4846     MANSFILENAME='`echo $$i | sed s/\\.4f$$/.5/`'
 4847     ;;
 4848 *-strip)
 4849     MANCAPPNAME='$$i'
 4850     MANCFILENAME='`echo $$i | sed s/\\.4f$$/.4/`'
 4851     MANSAPPNAME='`echo $$i | sed s/\\.1m$$/.1/`'
 4852     MANSFILENAME='`echo $$i | sed s/\\.4f$$/.4/`'
 4853     ;;
 4854 bsd-*)
 4855     MANCAPPNAME='$$i'
 4856     MANCFILENAME='`echo $$i | sed s/\\.4f$$/.5f/`'
 4857     MANSAPPNAME='`echo $$i | sed s/\\.1m$$/.8c/`'
 4858     MANSFILENAME='`echo $$i | sed s/\\.4f$$/.5f/`'
 4859     ;;
 4860 *)
 4861     MANCAPPNAME='$$i' MANCFILENAME='$$i'
 4862     MANSAPPNAME='$$i' MANSFILENAME='$$i'
 4863     ;;
 4864 esac
 4865 
 4866 Note ""
 4867 
 4868 if [ $GS = yes ]; then
 4869     test -d $SRCDIR/gs || {
 4870     Note ""
 4871     Note "WARNING, no Ghostscript build directory exists; disabling building"
 4872     Note "and installation of Ghostscript from source (GS=no)."
 4873     Note ""
 4874     GS=no
 4875     }
 4876 fi
 4877 if [ $DPS = yes ]; then
 4878     test -d $SRCDIR/dps || {
 4879     Note ""
 4880     Note "WARNING, no DPS build directory exists; disabling building"
 4881     Note "and installation of ps2fax for IRIX (DPS=no)."
 4882     Note ""
 4883     DPS=no
 4884     }
 4885 fi
 4886 if [ $IMP = yes ]; then
 4887     test -d $SRCDIR/imp || {
 4888     Note ""
 4889     Note "WARNING, no Impressario build directory exists; disabling building"
 4890     Note "and installation of the Impressario 2.1 back-end for IRIX (IMP=no)."
 4891     Note ""
 4892     IMP=no
 4893     }
 4894 fi
 4895 
 4896 #
 4897 # Convert default page size name to an entry that goes
 4898 # in the pagesizes database file.
 4899 #
 4900 F=$SRCDIR/util/pagesizes
 4901 test -f $F.in || {
 4902     bitch "$F.in is missing; this should be part of the distribution."
 4903     boom
 4904 }
 4905 DEFPAGESIZE=`grep "$PAGESIZE" $F.in | $SED -e 's/[^ ]*/default/;q'`
 4906 x="`relativize ${LIBTIFF}`"; LIBTIFF="$x"
 4907 x="`relativize ${LIBZ}`"; LIBZ="$x"
 4908 x="`relativize ${LIBREGEX}`"; LIBREGEX="$x"
 4909 
 4910 # NB: these should be sorted alphabetically
 4911 $RM confsed1; dumpvars "$VAR1" | sort > confsed1
 4912 $RM confsed2; dumpvars "$VAR2" | sort > confsed2
 4913 
 4914 
 4915 SedConfigFiles()
 4916 {
 4917     for F do
 4918     test -f $SRCDIR/$F.in || {
 4919         bitch "$SRCDIR/$F.in is missing; this should be part of the distribution."
 4920         boom
 4921     }
 4922     dir=`echo $F | $SED 's;/[^/]*$;;'`
 4923     if [ $dir != $F ] && [ ! -d $dir ]; then
 4924         Note "Creating $dir directory"
 4925         $MKDIR $dir
 4926     fi
 4927     suffix=`echo $F | $SED 's/.*\.//'`
 4928     if [ "$suffix" = h ]; then
 4929         #
 4930         # Compare old and new versions so that include files
 4931         # are only updated when something has changed--this
 4932         # saves time for subsequent makes.  Note we screen
 4933         # out use of @DATE@ 'cuz otherwise that'll mess up
 4934         # the comparison (this assumes dates are used in lines
 4935         # of the form DATE: @DATE@).
 4936         #
 4937         unset POSIXLY_CORRECT
 4938         $RM $F.new; $SED -f confsed1 $SRCDIR/$F.in | $SED -f confsed2 > $F.new
 4939         POSIXLY_CORRECT=1 ; export POSIXLY_CORRECT
 4940         $RM confx; $SED '/D[aA][tT][eE]:/d' $F.new >confx
 4941         $RM confy; $SED '/D[aA][tT][eE]:/d' $F >confy 2>/dev/null
 4942         if cmp -s confx confy >/dev/null 2>&1; then
 4943         $RM $F.new
 4944         else
 4945         Note "Creating $F from $SRCDIR/$F.in"
 4946         $RM $F; $MV $F.new $F; $CHMOD 444 $F
 4947         fi
 4948     else
 4949         Note "Creating $F from $SRCDIR/$F.in"
 4950         unset POSIXLY_CORRECT
 4951         if $SED -f confsed1 $SRCDIR/$F.in  | $SED -f confsed2 >$F.new; then
 4952         POSIXLY_CORRECT=1 ; export POSIXLY_CORRECT
 4953         $RM $F; $MV $F.new $F; $CHMOD 444 $F
 4954         else
 4955         POSIXLY_CORRECT=1 ; export POSIXLY_CORRECT
 4956         cat 1>&2 <<EOF
 4957 Help, there was a problem crafting $F from $F.in.
 4958 The command:
 4959 
 4960     $SED -f confsed1 $SRCDIR/$F.in | $SED -f confsed2 >$F.new
 4961 
 4962 failed.  Aborting without cleaning up files so you can take a look...
 4963 EOF
 4964         exit 1          # NB: don't use boom/die
 4965         fi
 4966     fi
 4967     done
 4968 }
 4969 
 4970 #
 4971 # Configuration File Generation
 4972 #
 4973 # The following files are created using the parameters determined above:
 4974 #
 4975 # defs          master make include file for the source code
 4976 # rules         make definitions for building from source code
 4977 # config.h      master definitions compiled into code
 4978 # */Makefile        make rules files
 4979 # port/install.sh   SGI install program emulation script
 4980 # port/mkdepend     makefile dependency generator (if configured)
 4981 # etc/faxsetup.sh   script for setting up a machine
 4982 # etc/faxaddmodem.sh    script for adding/configuring a modem
 4983 # etc/probemodem.sh script for probing a modem for its capabilities
 4984 # etc/hylafax       SysV-style init script for HylaFAX servers
 4985 # faxcover/edit-faxcover.sh script to edit faxcover.ps
 4986 # util/xferfaxstats.sh  script for transmit statistics accounting
 4987 # util/recvstats.sh script for receive statistics accounting
 4988 # util/faxcron.sh   script for cleaning up the spooling area (run from cron)
 4989 # util/pagesizes    client page dimensions database (has default page size)
 4990 # pkg/cpkginfo      SVR4 package stuff (client package info)
 4991 # pkg/cproto.stub   SVR4 package stuff (client prototype stub)
 4992 # pkg/crequest      SVR4 package stuff
 4993 # pkg/make_proto.sh SVR4 package stuff (script for making prototype files)
 4994 # pkg/postinstall   SVR4 package stuff
 4995 # pkg/postremove    SVR4 package stuff
 4996 # pkg/spkginfo      SVR4 package stuff (server package info)
 4997 # pkg/sproto.stub   SVR4 package stuff (server prototype stub)
 4998 # pkg/srequest      SVR4 package stuff
 4999 #
 5000 CONF_FILES="
 5001     defs
 5002     config.h
 5003     rules
 5004 
 5005     Makefile
 5006     config/Makefile
 5007     etc/Makefile
 5008     faxalter/Makefile
 5009     faxcover/Makefile
 5010     faxd/Makefile
 5011     faxmail/Makefile
 5012     faxrm/Makefile
 5013     faxstat/Makefile
 5014     hfaxd/Makefile
 5015     man/Makefile
 5016     sendfax/Makefile
 5017     sendpage/Makefile
 5018     util/Makefile
 5019 
 5020     faxcover/edit-faxcover.sh
 5021     faxmail/application-pdf.sh
 5022     faxmail/application-octet-stream.sh
 5023     faxmail/application-binary.sh
 5024     faxmail/image-tiff.sh
 5025 
 5026     port/Makefile
 5027     port/install.sh
 5028     port/version.c
 5029 
 5030     etc/faxsetup.sh
 5031     etc/faxsetup.linux
 5032     etc/faxaddmodem.sh
 5033     etc/probemodem.sh
 5034     etc/hylafax
 5035 
 5036     util/xferfaxstats.sh
 5037     util/recvstats.sh
 5038     util/faxcron.sh
 5039     util/pagesizes
 5040     util/archive.sh
 5041     util/dictionary.sh
 5042     util/common-functions.sh
 5043     util/faxrcvd.sh
 5044     util/mkcover.sh
 5045     util/notify.sh
 5046     util/pcl2fax.sh
 5047     util/pollrcvd.sh
 5048     util/ps2fax.dps.sh
 5049     util/ps2fax.gs.sh
 5050     util/pdf2fax.gs.sh
 5051     util/ps2fax.imp.sh
 5052     util/tiff2fax.sh
 5053     util/wedged.sh
 5054     util/tiff2pdf.sh
 5055     util/qp-encode.awk
 5056     util/rfc2047-encode.awk
 5057 
 5058     util/dict-de
 5059     util/dict-en
 5060     util/dict-es
 5061     util/dict-he
 5062     util/dict-it
 5063     util/dict-fr
 5064     util/dict-nl_BE
 5065     util/dict-pl
 5066     util/dict-pt
 5067     util/dict-pt_BR
 5068     util/dict-ro
 5069     util/dict-ru
 5070     util/dict-sr
 5071     util/dict-tr
 5072     util/dict-uk
 5073     util/dict-zh
 5074 
 5075     pkg/Makefile
 5076     pkg/cpkginfo
 5077     pkg/cproto.stub
 5078     pkg/crequest
 5079     pkg/make_proto.sh
 5080     pkg/postinstall
 5081     pkg/postremove
 5082     pkg/spkginfo
 5083     pkg/sproto.stub
 5084     pkg/srequest
 5085 "
 5086 SedConfigFiles $CONF_FILES
 5087 test $DPS = yes &&         SedConfigFiles dps/Makefile
 5088 test $GS = yes &&          SedConfigFiles gs/Makefile
 5089 test $IMP = yes &&         SedConfigFiles imp/Makefile
 5090 test "$MKDEPEND" != ":" &&     SedConfigFiles port/mkdepend
 5091 test $SGI2FAX = yes &&         SedConfigFiles sgi2fax/Makefile
 5092 test $REGEX = yes &&           SedConfigFiles regex/Makefile
 5093 
 5094 if [ "$MAKEDEPINCLUDE" != "sinclude" ]; then
 5095     Note "Setting up make dependency files."
 5096     #
 5097     # Setup null make dependency files so that we can include
 5098     # it w/o problem.  Some systems have conditional include
 5099     # support in their make, but others do not, so we use an
 5100     # unconditional include and setup everthing as null here
 5101     #
 5102     DEPEND=".
 5103     faxalter
 5104     faxcover
 5105     faxd
 5106     faxmail
 5107     faxrm
 5108     faxstat
 5109     hfaxd
 5110     sendfax
 5111     sendpage
 5112     util
 5113     man
 5114     etc
 5115     config
 5116     port
 5117     "
 5118     test $GS = yes  && DEPEND="$DEPEND gs"
 5119     test $SGI2FAX = yes && DEPEND="$DEPEND sgi2fax"
 5120     test $PORT = yes    && DEPEND="$DEPEND port"
 5121     test $REGEX = yes   && DEPEND="$DEPEND regex"
 5122     test -d $SRCDIR/faxview && test -d faxview && DEPEND="$DEPEND faxview"
 5123     for i in $DEPEND; do
 5124     test -f $i/Makedepend || cp /dev/null $i/Makedepend
 5125     done
 5126 fi
 5127 
 5128 Note "Done."
 5129 
 5130 $RM $JUNK
 5131 exit 0