configure
上传用户:weiyuanprp
上传日期:2020-05-20
资源大小:1169k
文件大小:135k
- #!/bin/sh
- # $Id: configure,v 1.64 2009/05/25 18:41:23 faxguy Exp $
- #
- # HylaFAX Facsimile Software
- #
- # Copyright (c) 1988-1996 Sam Leffler
- # Copyright (c) 1991-1996 Silicon Graphics, Inc.
- # HylaFAX is a trademark of Silicon Graphics
- #
- # Permission to use, copy, modify, distribute, and sell this software and
- # its documentation for any purpose is hereby granted without fee, provided
- # that (i) the above copyright notices and this permission notice appear in
- # all copies of the software and related documentation, and (ii) the names of
- # Sam Leffler and Silicon Graphics may not be used in any advertising or
- # publicity relating to the software without the specific, prior written
- # permission of Sam Leffler and Silicon Graphics.
- #
- # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- #
- # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- # OF THIS SOFTWARE.
- #
- # Configuration script for HylaFAX (tm) (aka FlexFAX)
- #
- # Shell script to setup machine-dependent files in
- # preparation for building HylaFax source.
- #
- #
- # Setup general configuration parameters.
- #
- DIR_BIN=/usr/local/bin
- DIR_SBIN=/usr/local/sbin
- DIR_LIBDATA=/usr/local/lib/fax
- DIR_LIB=/usr/local/lib
- DIR_LIBEXEC=$DIR_SBIN
- DIR_SPOOL=/var/spool/hylafax
- DIR_CGI=/var/httpd/cgi-bin
- PATH_DPSRIP=$DIR_LIBEXEC/ps2fax.exe
- PATH_IMPRIP=/usr/lib/print/psrip
- CGIPATH=/cgi-bin
- DEFVRES=98
- PAGESIZE="North American Letter"
- FAXUID=uucp
- FAXGID=
- SYSUID=bin
- SYSGID=
- DSO=auto
- GETTY=auto
- PS=auto
- SYSVINIT=auto
- FAXQ_SERVER=yes # init script starts faxq
- HFAXD_SERVER=yes # init script starts hfaxd
- HFAXD_SNPP_SERVER=no # don't start paging protocol
- SGI2FAX=auto
- PORT=auto
- LIBMALLOC=auto
- LOCKS=auto
- DPS=no
- GS=no
- IMP=no
- UTMP=auto
- OPTIMIZER="-O"
- LIBTIFF="-ltiff"
- TIFFINC=
- TIFFBIN=
- LIBZ=-lz
- ZLIBINC=
- REGEX=yes
- LIBREGEX='-L${DEPTH}/regex -lregex'
- REGEXINC='-I${DEPTH}/${TOPSRCDIR}/regex'
- FAXD=
- LIBFAXSERVER='libfaxserver.${DSO}'
- LIBUTIL='${UTIL}/libfaxutil.${DSO}'
- CONFIG_OSFCNH=auto
- MANNUM4_5=4F
- MANNUM1_8=1M
- INSTALLROOT=/
- # SVR4 packaging stuff
- PKG_ARCH= # ARCH variable in pkginfo file
- PKG_EMAIL=someone@somehost.somedomain # EMAIL variable in pkginfo file
- PKG_VENDOR="Your Name Here" # VENDOR variable in pkginfo file
- : ${MAKE=make} # make to use
- # screws up the test of `-f -'
- unset MAKEFLAGS
- RM="rm -f"
- #
- # Note VARX parameters cannot contain more that 100 entries as it
- # breaks HP's sed
- #
- VAR1="ANSICPP
- ANSICXXPP
- AR
- AROPTS
- AWK
- BIN DIR_BIN
- CAT
- CGIDIR DIR_CGI
- CGIPATH
- CHGRP
- CHMOD
- CHOWN
- CC
- CCOMPILER
- CMP
- COL
- CP
- CXX
- CXXCOMPILER
- CXXFILE
- DATE
- DEFPAGESIZE
- DEFVRES
- DIST_ALPHA
- DIST_MAJOR
- DIST_MINOR
- DIST_TYPE
- DPS
- DPSRIP PATH_DPSRIP
- DSO
- DSOSUF
- DSODELAY
- DSOOPTS
- ECHO
- ENCODING
- ENVOPTS
- FAXD
- FAXGID
- FAXUID
- FAXQ_SERVER
- FILECMD
- FILLORDER
- FONTMAP
- FONTPATH PATH_AFM
- FUSER
- GCOPTS
- GCXXOPTS
- GENDIST
- GETTY
- GREP
- GS
- GSRIP PATH_GSRIP
- HFAXD_SERVER
- HFAXD_SNPP_SERVER
- IMP
- IMPRIP PATH_IMPRIP
- INSTALL
- INSTALLROOT
- LIBDATA DIR_LIBDATA
- LIBDIR DIR_LIB
- LIBEXEC DIR_LIBEXEC
- LIBFAXSERVER
- LIBPORT
- LIBREGEX
- LIBTIFF
- LIBUTIL
- LIBZ
- LLDOPTS
- LN
- LN_S
- HAVE_PAM
- PAMLIBS
- HAVE_JBIG
- HAVE_JBIGTIFF
- LIBJBIG
- HAVE_LDAP
- LDAPLIBS"
- VAR2="MACHDEPLIBS
- MAKECXXOVERRIDE
- MAKEDEPINCLUDE
- MAKEDSOINCLUDE
- MAKEINCLUDE
- MAKELQUOTE
- MAKERQUOTE
- MAN
- MANDIR DIR_MAN
- MANAPPS
- MANCAPPNAME
- MANCFILENAME
- MANCVT
- MANFILES
- MANNUM4_5
- MANNUM1_8
- MANSAPPNAME
- MANSCHEME
- MANSFILENAME
- MANSYS
- MIMENCODE
- MKDEPCOPTS
- MKDEPCXXOPTS
- MKDEPEND
- MKDIR
- MKFIFO
- MV
- MV_F
- NOCLOBBER_OFF
- NOCLOBBER_ON
- OPTIMIZER
- PAGESIZE
- PATHGETTY PATH_GETTY
- PATHVGETTY PATH_VGETTY
- PATHEGETTY PATH_EGETTY
- PCL6CMD
- PKG_ARCH
- PKG_EMAIL
- PKG_VENDOR
- PORT
- PORTFUNCS
- PROTOTYPES
- PSPACKAGE PS
- PWDCMD
- RANLIB
- REGEX
- REGEXINC
- RM RMCMD
- SBIN DIR_SBIN
- SCRIPT_SH
- SED
- SENDMAIL PATH_SENDMAIL
- SETMAKE
- SGI2FAX
- SHDLIBC
- SORT
- SPOOL DIR_SPOOL
- SRCDIR
- STRIP
- SYSGID
- SYSUID
- SYSVINIT
- SYSVINITDIR DIR_SYSVINIT
- SYSVINITSTARTDIR DIR_SYSVINITSTART
- SYSVINITSTARTNAME NAME_SYSVINITSTART
- SYSVINITSTOPDIR DIR_SYSVINITSTOP
- SYSVINITSTOPNAME NAME_SYSVINITSTOP
- TARGET
- TIFF2PDF
- TIFFBIN
- TIFFINC
- TTYCMD
- UTMP
- UUCP_LOCKDIR DIR_LOCKS
- UUCP_LOCKTYPE LOCKS
- UUENCODE
- VERSION
- WARNING
- ZLIBINC"
- dumpvars()
- {
- (for i do echo "$i"; done) |
- while read a b; do eval c=$${b:-$a}; echo "/@$a@/s;;$c;g"; done
- }
- dumpvals()
- {
- (echo "$VAR1"; echo "$VAR2") |
- while read a b; do eval c=$${b:-$a}; echo "${b:-$a}='$c'"; done
- }
- #
- # We expect the PATH to point to trusted programs. However,
- # because we appear to need it, we add to the PATH to help
- # some systems along.
- #
- PATH=$PATH:/bin:/usr/bin:/etc
- test -d /usr/ccs/bin && PATH=$PATH:/usr/ccs/bin # SVR4/Solaris2
- test -d /usr/sbin && PATH=$PATH:/usr/sbin # SGI and others
- test -d /usr/bsd && PATH=$PATH:/usr/bsd # SGI
- test -d /usr/ucb && PATH=$PATH:/usr/ucb # Sun and others
- test -d /usr/contrib/bin && PATH=$PATH:/usr/contrib/bin # BSDi
- test -d /usr/5bin && PATH=/usr/5bin:$PATH:/usr/etc # Sun and others
- test -d /usr/local/bin && PATH=$PATH:/usr/local/bin # for GNU stuff
- POSIXLY_CORRECT=1; export POSIXLY_CORRECT # disable GNU extensions
- LC_ALL=C; export LC_ALL # set a common language
- #
- # Error diagnostics that should go to the terminal are
- # done with this interface (or cat).
- #
- bitch()
- {
- echo "$@" 1>&2
- }
- die()
- {
- kill -1 $$ # use kill so trap handler is called
- }
- #
- # This is the preferred interface for
- # configure to terminate abnormally.
- #
- boom()
- {
- bitch ""
- bitch "Unrecoverable error! Once you've corrected the problem rerun this script."
- die
- }
- usage()
- {
- cat<<'EOF'
- Usage: configure [options] [host]
- Options: [defaults in brackets after descriptions]
- --help print this message
- --quiet do not print `Using ...' messages
- --nointeractive do not prompt for input [INTERACTIVE=no]
- --verbose opposite of --quiet
- --version print the version of autoconf that created configure
- --target=TARGET configure for TARGET [TARGET=HOST]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --disable-pam disable all PAM support
- --disable-jbig disable all JBIG support
- --disable-ldap disable all LDAP support
- --with-PARAM[=ARG] set configuration PARAM [ARG=yes]
- EOF
- }
- QUIET=no
- INTERACTIVE=${INTERACTIVE:="yes"}
- SITE=
- TARGET=
- RELEASE=
- SRCDIR=
- WITHARGS=no
- #
- # Crack command line arguments. We purposely
- # use syntax and options that are compatible
- # with GNU autoconf.
- #
- ac_prev=
- for ac_option
- do
- if [ -n "$ac_prev" ]; then # assign the argument to previous option
- eval "$ac_prev=$ac_option"
- ac_prev=
- continue
- fi
- case "$ac_option" in # collect optional argument
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'`;;
- *) ac_optarg=;;
- esac
- case "$ac_option" in
- -with-*|--with-*)
- ac_with=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if [ -n "`echo $ac_with| sed 's/[-_a-zA-Z0-9]//g'`" ]; then
- bitch "configure: $ac_with: invalid parameter name."
- die
- fi
- ac_with=`echo $ac_with| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes;;
- esac
- eval "${ac_with}='$ac_optarg'"
- WITHARGS=yes
- ;;
- -quiet|--quiet) QUIET=yes;;
- -nointeractive|--nointeractive) INTERACTIVE=no;;
- -verbose|--verbose) QUIET=no;;
- -site|--site) ac_prev=SITE;;
- -site=*|--site=*) SITE="$ac_optarg";;
- -srcdir|--srcdir) ac_prev=SRCDIR;;
- -srcdir=*|--srcdir=*) SRCDIR="$ac_optarg";;
- -target|--target) ac_prev=TARGET;;
- -target=*|--target=*) TARGET="$ac_optarg" ;;
- -disable-pam|--disable-pam) DISABLE_PAM="yes" ;;
- -disable-ldap|--disable-ldap) DISABLE_LDAP="yes" ;;
- -disable-jbig|--disable-jbig) DISABLE_JBIG="yes" ;;
- -version|--version)
- echo "This is HylaFAX configure $Revision: 1.64 $"
- exit 0
- ;;
- -help|--help) usage; exit 0;;
- -*)
- bitch "configure: $ac_option: invalid option; use -help for usage."
- die
- ;;
- *)
- if [ x"$TARGET" != x ]; then
- bitch "configure: Can only configure for one target at a time."
- kill -1 $$
- fi
- TARGET="$ac_option"
- ;;
- esac
- done
- if [ -n "$ac_prev" ]; then
- bitch "configure: missing argument to --`echo $ac_prev | sed 's/_/-/g'`"
- die
- fi
- #
- # Our GCOPTS and GCXXOPTS are equivalent in usage to the more-traditional
- # CFLAGS and CXXFLAGS. So if GCOPTS and GCXXOPTS are unset, then apply
- # CFLAGS and CXXFLAGS to them.
- #
- if [ -z "$GCOPTS" ]; then GCOPTS=$CFLAGS; fi
- if [ -z "$GCXXOPTS" ]; then GCXXOPTS=$CXXFLAGS; fi
- #
- # Locate source directory by looking for the VERSION file.
- # The directory must either be specified through the
- # environment or be located in the current directory or a
- # parent of the current directory.
- #
- test "$SRCDIR" || {
- configure=$0
- # NB: don't use dirname since it may not exist
- SRCDIR=`echo $configure | sed 's;/[^/][^/]*$;;'`
- if [ @"$SRCDIR" = @"$configure" ]; then
- SRCDIR=.
- fi
- while [ ! -r $SRCDIR/VERSION ]; do
- # strip last directory from pathname
- newdir=`echo $SRCDIR | sed 's;/[^/]*$;;'`
- if [ -z "$newdir" ] || [ "$newdir" = $SRCDIR ]; then
- break;
- fi
- SRCDIR=$newdir
- done
- }
- if [ ! -r $SRCDIR/VERSION ]; then
- bitch "Can not locate sources in $SRCDIR; the file $SRCDIR/VERSION"
- bitch "does not exist or is unreadable."
- boom
- fi
- SRCDIR=`echo "$SRCDIR" | sed 's;([^/])/*$;1;'`
- #
- # Descriptor usage:
- # 1: ???
- # 2: messages that should be seen even if we're in the background.
- # 3: [stdout from test runs]
- # 4: verbose-style messages (Using ...)
- # 5: compiler stderr when running tests
- #
- if [ $QUIET = yes ]; then
- exec 4>/dev/null # chuck messages
- else
- exec 4>&1 # messages go to stdout
- fi
- $RM ./config.log
- exec 5>./config.log # compiler messages and the like
- DATE=`date`
- eval `cat $SRCDIR/VERSION | sed 's/([0-9][0-9]*).([0-9][0-9]*)(.*)/DIST_MAJOR=1; DIST_MINOR=2; DIST_TYPE=3/'`
- DIST_ALPHA=`awk '{print $3}' $SRCDIR/dist/hylafax.alpha`
- VERSION="${DIST_MAJOR}.${DIST_MINOR}${DIST_TYPE}"
- if [ "$DIST_TYPE" = beta ]; then
- VERSION="${VERSION}${DIST_ALPHA}"
- fi
- Note()
- {
- echo "$@" 1>&4
- }
- capture()
- {
- (eval "set -x; $*") >&5 2>&1
- return
- }
- captureX()
- {
- (eval "set -x; $*") 2>&5
- return
- }
- date >&5
- cat 1>&5 <<'EOF'
- This file contains information that was captured from running the configure
- script. Lines that begin with a "+" are command lines echoed by the
- shell. Other lines are the output of commands; usually the contents of
- test case files or the output from compilers. If configure does the
- wrong thing, use the information captured here to aid in debugging.
- EOF
- Note ""
- Note "Configuring HylaFAX (tm) (aka FlexFAX) $VERSION."
- Note ""
- Note "If configure does the wrong thing, check the file config.log for"
- Note "information that may help you understand what went wrong."
- Note ""
- # test for broken expr (Tru64 UNIX)
- x="00"
- match=`expr "$x" : "([0-9]*)"`
- if [ "$match" != "$x" ]; then
- bitch "Your expr is broken. It strips leading zeroes"
- bitch "This may cause problems with configure, faxsetup, & faxaddmodem"
- bitch "Perhaps there is an environment variable you can set"
- bitch "to get the desired behavior."
- fi
- #
- # Read site and local configuration parameters.
- #
- CONFIG_FILES=
- if [ -f $SITE/config.site ]; then
- Note "Reading site-wide parameters from $SITE/config.site."
- . $SITE/config.site
- capture . $SITE/config.site
- CONFIG_FILES=$SITE/config.site
- elif [ -f $SRCDIR/config.site ]; then
- Note "Reading site-wide parameters from $SRCDIR/config.site."
- . $SRCDIR/config.site
- capture . $SRCDIR/config.site
- CONFIG_FILES=$SRCDIR/config.site
- fi
- if [ -f config.local ]; then
- Note "Reading local parameters from config.local."
- . ./config.local
- capture . ./config.local
- CONFIG_FILES="$CONFIG_FILES config.local"
- elif [ -f $SRCDIR/config.local ]; then
- Note "Reading local parameters from $SRCDIR/config.local."
- . $SRCDIR/config.local
- capture . $SRCDIR/config.local
- CONFIG_FILES="$CONFIG_FILES $SRCDIR/config.local"
- fi
- #
- # Flush cached values if something was specified on the
- # command line or if the contents of a config parameter
- # file was changed more recently.
- #
- REASON=
- if [ $WITHARGS = yes ]; then
- REASON="of command line parameters"
- elif [ "$CONFIG_FILES" ]; then
- REASON=`find $CONFIG_FILES -newer config.cache -print 2>/dev/null`
- test "$REASON" && REASON="$REASON has been updated"
- fi
- if [ "$REASON" ] && [ -f config.cache ]; then
- Note "Flushing cached parameters because $REASON."
- Note ""
- rm -f config.cache
- fi
- if [ -f config.cache ]; then
- Note "Reading cached parameters from config.cache."
- Note ""
- ODATE="$DATE"; OVERSION="$VERSION"
- OPORTFUNCS="$PORTFUNCS"; OMACHDEPLIBS="$MACHDEPLIBS"
- OTIFFINC="$TIFFINC"; OLIBTIFF="$LIBTIFF"
- OZLIBINC="$ZLIBINC"; OLIBZ="$LIBZ"
- OREGEXINC="$REGEXINC"; OLIBREGEX="$LIBREGEX"
- . ./config.cache
- capture . ./config.cache
- # NB: these are calculated each time from scratch
- DATE="$ODATE"; VERSION="$OVERSION"
- MACHDEPLIBS="$OMACHDEPLIBS"; PORTFUNCS="$OPORTFUNCS"
- # NB: these are relativized each time so beware of cached value
- TIFFINC="$OTIFFINC"; LIBTIFF="$OLIBTIFF"
- ZLIBINC="$OZLIBINC"; LIBZ="$OLIBZ"
- REGEXINC="$OREGEXINC"; LIBREGEX="$OLIBREGEX"
- fi
- identifyTarget()
- {
- random=`date | awk '{print $4}' | sed -e 's/.*://'` 2>/dev/null
- case "$random" in
- *0) Note "Wow, you've got a $1 system!";;
- *1) Note "Hmm, looks like a $1 system.";;
- *2) Note "Oh no, not another $1 system...";;
- *3) Note "Well I'll be, a $1 system.";;
- *4) Note "Fee, fie, foe, this smells like a $1 system.";;
- *5) Note "Gosh, aren't you lucky to have a $1 system!";;
- *6) Note "YOW!! Did something bad happen or am I on a $1 system?";;
- *7) Note "Do they really still make $1 systems?!";;
- *8) Note "I'm always happy to encounter another $1 system.";;
- *9) Note "Here we are again, this time on a $1 system.";;
- esac
- }
- #
- # If no target is specified, try to deduce the system.
- # We use the GNU scripts for guessing and canonicalizing
- # the system identification, if available.
- #
- if [ -z "$TARGET" ]; then
- test -f $SRCDIR/config.guess && TARGET=`sh $SRCDIR/config.guess` 2>/dev/null
- if [ -z "$TARGET" ]; then
- bitch "Sorry, no target was specified on the command line and I don't seem to"
- bitch "have the GNU config.guess script that is used to deduce your system type."
- boom
- fi
- identifyTarget $TARGET
- elif [ -f $SRCDIR/config.sub ]; then
- TARGET=`sh $SRCDIR/config.sub "$TARGET"`
- else
- Note "WARNING, the GNU config.sub script does not seem to be present. This"
- Note " script is used to canonicalize your target specification; not"
- Note " having it may cause problems later on..."
- fi
- echo "TARGET: $TARGET" >&5
- RELEASE=`(uname -r) 2>/dev/null` || RELEASE=unknown
- echo "RELEASE: $RELEASE" >&5
- #
- # Find the full pathname of a file
- # using the specified test operation.
- #
- findThing()
- {
- t="$1"; app=$2; path=$3;
- case $app in
- /*) eval $t $app && { echo $app; return; };;
- esac
- IFS=:
- for i in $path; do
- eval $t $i/$app && { echo $i/$app; return 0; }
- done
- return 1
- }
- #
- # Find the full pathname of a plain file.
- #
- findFile()
- {
- findThing "test -f" $1 $2
- }
- #
- # Find the full pathname of an executable.
- #
- findApp()
- {
- t="$1"; app=$1; path=$2;
- case $app in
- /*) eval test -x $app && test ! -d $app && { echo $app; return; };;
- esac
- IFS=:
- for i in $path; do
- eval test -x $i/$app && test ! -d $i/$app && { echo $i/$app; return 0; }
- done
- return 1
- }
- #
- # Find the full pathname of an executable;
- # supply a default if nothing is found.
- #
- findAppDef()
- {
- app=$1; path=$2; def=$3
- case $app in
- /*) test -x $app && { echo $app; return; };;
- esac
- IFS=:
- for i in $path; do
- test -x $i/$app && { echo $i/$app; return; }
- done
- echo $def
- }
- #
- # Fixup a list of potentially relative pathnames so
- # that they work when used in a subdirectory. The
- # string sent to stdout has no extraneous spaces so
- # it can be used, for example, in building pathnames.
- #
- # NB: There's an extra echo done here so we get a
- # n-terminated string passed to sed.
- #
- relativize()
- {
- echo `(for i do
- case "$i" in
- -Wl*) echo "$i" ;;
- /*|-l*|-l[$]{DEPTH}/*) echo "$i" ;;
- -L|-L/*|-L[$]{DEPTH}/*) echo "$i" ;;
- -I|-I/*|-I[$]{DEPTH}/*) echo "$i" ;;
- -R|-R/*|-R[$]{DEPTH}/*) echo "$i" ;;
- [$][{]DEPTH[}]/*) echo "$i" ;;
- -L*) echo "$i" | sed 's;^-L;-L../;' ;;
- -R*) echo "$i" | sed 's;^-R;-R../;' ;;
- -I*) echo "$i" | sed 's;^-I;-I../;' ;;
- *) echo "../$i" ;;
- esac
- done) | tr ' 12' ' '` |
- sed -e 's;/[.]/;/;g' -e 's;[ ][ ]*$;;' -e 's;/[.]$;;'
- }
- #
- # Locate a C and C++ compiler and verify they work and
- # satisfy our needs (using assorted heuristics).
- #
- JUNK="
- a.out
- conffifo
- confsed1
- confsed2
- conftestmmap
- confx confy
- confMakefile
- conf.db
- core
- dummy
- dummy.C
- dummy.a
- dummy.c
- dummy.o
- foo
- m.c
- so_locations
- t.c
- t.c++
- t.o
- t
- xMakedepend
- xdefs
- xgnu.c
- xmakeinc
- xport.h
- xtermios.h
- "
- trap "$RM $JUNK; exit 1" 1 2 15
- $RM $JUNK
- #
- # Before we go too far, check some features required by the software
- #
- if [ -z "$MKFIFO" ]; then
- MKFIFO=`findApp mkfifo $PATH`
- if [ "$MKFIFO" ]; then
- mkfifo()
- {
- $MKFIFO $1
- }
- else
- MKFIFO=`findApp mknod /sbin:$PATH`
- if [ -z "$MKFIFO" ]; then
- cat <<EOF
- No support for creating a FIFO special file.
- There does not appear to be a way to create a FIFO special file.
- No mkfifo program or mknod program was located in the expected
- locations. One of these programs is required for proper operation
- of this software. If these programs are located in a non-standard
- location then you can setup the MKFIFO configuration parameter to
- reflect the appropriate location. Otherwise you may need to install
- additional software on your system to support FIFO special files
- before you can configure the building of this software.
- EOF
- boom
- fi
- mkfifo()
- {
- $MKFIFO $1 p
- }
- fi
- fi
- cat>xgnu.c<<EOF
- #ifdef __GNUC__
- yes;
- #endif
- EOF
- #
- # Check if the specified compiler is from GNU
- #
- isGNU()
- {
- capture "cat xgnu.c; ($1 -E xgnu.c 2>&5 | egrep yes)"
- }
- checkGCCVersion()
- {
- app=$1; shift
- eval `$app -v 2>&1 |
- sed -n -e '/[Vv]ersion/s/[^(]* [a-z-]*([0-9]*).([0-9]*).([0-9]*).*/GCCdist=1;GCCmajor=2;GCCminor=3/p'`
- GCCversion="${GCCdist}.${GCCmajor}.${GCCminor}"; export GCCversion
- if [ ${GCCdist} -gt $1 ]; then
- return 0
- fi
- if [ ${GCCdist} -eq $1 ]; then
- if [ ${GCCmajor} -gt $2 ]; then
- return 0
- fi
- if [ ${GCCmajor} -eq $2 ] && [ ${GCCminor} -ge $3 ]; then
- return 0
- fi
- fi
- return 1
- }
- #
- # NB: use ANSI C prototype to weed out non-ANSI compilers.
- #
- cat>dummy.c<<EOF
- #include <stdlib.h>
- main(int argc, char* argv) { exit(0); }
- EOF
- checkCompiler()
- {
- compiler=$1
- if isGNU $compiler; then
- ISGCC=yes
- else
- ISGCC=no
- fi
- #
- # Guess special options needed to get an
- # ANSI C compiler and/or similar. Must
- # be combined with above checks so we only
- # select an ANSI C compiler.
- #
- if [ -z "${ENVOPTS:-}" ]; then
- case $ISGCC-$TARGET in
- no-*-hpux11*) C_ANSI="-Aa -D_HPUX_SOURCE -Dhpux -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED";;
- yes-*-hpux11*) C_ANSI="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED";;
- no-*-hp*) C_ANSI="-Aa -D_HPUX_SOURCE -Dhpux";;
- no-*-sco3.2v5.*) C_ANSI="-Dsco -Dsco5 -b elf";;
- yes-*-sco3.2v5.*) C_ANSI="-Dsco -Dsco5 -m486";;
- *-*-sco*) C_ANSI="-Dsco";;
- *-isc*) C_ANSI="-posix -D_SYSV3 -DISC";;
- yes-*-solaris*) C_ANSI="-L/usr/local/lib -R/usr/local/lib";;
- esac
- else
- C_ANSI="$ENVOPTS"
- fi
- $RM dummy dummy.o
- capture $compiler -o dummy ${C_ANSI} dummy.c && {
- CC=$compiler;
- test -z "${CCOMPILER:-}" && CCOMPILER=`findApp $compiler $PATH`
- test -z "${ENVOPTS:-}" && ENVOPTS="${C_ANSI:-}"
- return 0
- }
- return 1
- }
- CCtested=
- capture cat dummy.c
- if [ -z "${CC:-}" ]; then
- CCOMPILER=
- for i in gcc cc ncc dcc xlc c89 gcc2 acc; do
- CCtested="$CCtested $i"
- checkCompiler $i && break
- done
- else
- CCtested="$CCtested $CC"
- checkCompiler $CC
- fi
- if [ -z "$CCOMPILER" ]; then
- cat<<EOF
- Cannot locate a working ANSI C compiler.
- We attempted to compile the following test program:
- ----------------------------------------------------------
- EOF
- cat dummy.c
- cat<<EOF
- ----------------------------------------------------------
- with these compilers:
- $CCtested
- but none of them were successful.
- If your compiler is in a non-standard location, you can specify its
- location in several ways:
- o set the environment variable CC
- o create a config.local or config.site file that includes a
- definition for CC
- o supply it on the command line using -with-CC=<pathname>
- If command line options are required for ANSI C compilation, set the
- ENVOPTS parameter to these options in a similar way (either through
- an environment variable or config.local/config.site) and then rerun
- this script.
- EOF
- boom
- fi
- Note "Using $CCOMPILER for a C compiler (set CC to override)."
- test "$ENVOPTS" && {
- Note "Using $ENVOPTS to get the appropriate compilation environment."
- }
- CheckForGandO()
- {
- f=$1
- if test -s $f; then
- capture egrep -i "error|warning" $f || return 1
- fi
- return 0
- }
- if [ -z "$GCOPTS" ]; then
- capture $CCOMPILER $ENVOPTS -g -c dummy.c && {
- Note "Looks like $CCOMPILER supports the -g option."
- # NB: cannot use captureX here 'cuz we lose stderr
- if $CCOMPILER $ENVOPTS $GCOPTS -c -g -O dummy.c >t 2>&1 && CheckForGandO t; then
- GCOPTS="$GCOPTS -g"
- else
- Note "... but not together with the -O option, not using it."
- fi
- }
- fi
- if [ "$GCOPTS" ]; then
- Note "Using "$GCOPTS" for C compiler options."
- fi
- #
- # Figure out if there is an ANSI C-preprocessor and,
- # if __ANSI_CPP__ is not automatically set, configure
- # it to be set.
- #
- cat>dummy.c<<EOF
- #define ansiIDENT(a) a
- #define ansiCAT(a,b) a##b
- A=ansiCAT(ANSI,CPP);
- EOF
- capture cat dummy.c
- if capture "$CCOMPILER $ENVOPTS -E dummy.c | grep ANSICPP"; then
- Note "Looks like $CCOMPILER has an ANSI C preprocessor."
- cat>dummy.c<<EOF
- #ifdef __ANSI_CPP__
- yes
- #else
- no
- #endif
- EOF
- capture cat dummy.c
- if capture "$CCOMPILER $ENVOPTS -E dummy.c | grep no"; then
- ANSICPP='-D__ANSI_CPP__'
- Note "... but __ANSI_CPP__ is not automatically defined, will compensate."
- fi
- else
- Note "Looks like $CCOMPILER has a non-ANSI C preprocessor, will try to compensate."
- fi
- #
- # Figure out if the C compiler supports a -M option for generating
- # Make dependency information.
- #
- cat>dummy.c<<EOF
- #include <stdlib.h>
- main(int argc, char* argv) { exit(0); }
- EOF
- capture cat dummy.c
- if capture "$CCOMPILER -c -M $MKDEPCOPTS dummy.c | grep '^dummy.o[ ]*:[ ]*dummy.c'"; then
- Note "Looks like $CCOMPILER supports the -M option for generating make dependencies."
- MKDEPEND='${SHELL} ${PORT}/mkdepend'
- else
- Note "Looks like $CCOMPILER does not support the -M option for generating"
- Note "make dependencies; will disable automatic make dependency building."
- MKDEPEND=":"
- fi
- cat>dummy.C<<EOF
- class foo {
- public:
- struct bar {
- int a;
- bar();
- };
- foo();
- };
- foo::bar::bar() { a = 0; }
- foo::foo() { bar x; }
- int main() { foo t; return 0; }
- EOF
- checkCompiler()
- {
- compiler=$1
- if isGNU $compiler; then
- ISGXX=yes
- checkGCCVersion $compiler 2 6 1 || return 1
- else
- ISGXX=no
- fi
- $RM dummy dummy.o
- capture $compiler -o dummy dummy.C && {
- CXX=$compiler;
- test -z "${CXXCOMPILER:-}" && CXXCOMPILER=`findApp $compiler $PATH`
- return 0
- }
- return 1
- }
- CCtested=; ISGXX=no
- capture cat dummy.C
- if [ -z "${CXX:-}" ]; then
- CXXCOMPILER=
- CXXCOMPILERS="g++ gcc CC NCC DCC gcc2 xlC"
- for i in $CXXCOMPILERS; do
- CCtested="$CCtested $i"
- checkCompiler $i && break
- done
- else
- CCtested="$CCtested $CXX"
- checkCompiler $CXX
- fi
- if [ -z "$CXXCOMPILER" ]; then
- cat<<EOF
- Cannot locate a suitable C++ compiler.
- We attempted to compile the following test program:
- ----------------------------------------------------------
- EOF
- cat dummy.C
- cat<<EOF
- ----------------------------------------------------------
- with these compilers:
- $CCtested
- but none of them were successful.
- To build this software you need a C++ compiler that supports a
- reasonably modern version of C++. In particular the compiler must
- support nested types and process temporary variables according to the
- ANSI Reference Manual (the ARM).
- If such a compiler is in a non-standard location, you can specify its
- location in several ways:
- o set the environment variable CXX
- o create a config.local or config.site file that includes a
- definition for CXX
- o supply it on the command line using -with-CXX=<pathname>
- If you are trying to use GNU gcc, but you do not have version 2.6.1
- or newer, then you must update your compiler (and probably libg++ as
- well) before you can compile this software. Consult the documentation
- for information about obtaining an up-to-date version of gcc.
- EOF
- boom
- fi
- Note "Using $CXXCOMPILER for a C++ compiler (set CXX to override)."
- if [ -z "$GCXXOPTS" ]; then
- case $CXX-$TARGET in
- *CC-*-irix*) # cfront-based or cfront-compatible
- GCXXOPTS='+a1 +w +p'
- ;;
- *xlC-*-aix*)
- GCXXOPTS='-qlanglvl=compat -I/usr/lpp/xlC/include -I/usr/include'
- ;;
- *CC-*-sco3.2v5.*) # cfront-based or cfront-compatible
- GCXXOPTS='+a1 +p'
- ;;
- *)
- GCXXOPTS=
- ;;
- esac
- capture $CXXCOMPILER $ENVOPTS -c -g dummy.C && {
- Note "Looks like $CXXCOMPILER supports the -g option."
- # NB: cannot use captureX here 'cuz we lose stderr
- if $CXXCOMPILER $ENVOPTS -c -g -O dummy.C >t 2>&1 && CheckForGandO t; then
- GCXXOPTS="$GCXXOPTS -g"
- else
- Note "... but not together with the -O option, not using it."
- fi
- }
- fi
- if [ "$GCXXOPTS" ]; then
- Note "Using "$GCXXOPTS" for C++ compiler options."
- fi
- #
- # Figure out if there is an ANSI preprocessor for the C++
- # compiler and, if __ANSI_CPP__ is not automatically set,
- # configure it to be set.
- #
- cat>dummy.C<<EOF
- #define ansiIDENT(a) a
- #define ansiCAT(a,b) a##b
- A=ansiCAT(ANSI,CPP);
- EOF
- capture cat dummy.C
- if capture "$CXXCOMPILER $ENVOPTS -E dummy.C | grep ANSICPP"; then
- Note "Looks like $CXXCOMPILER has an ANSI C preprocessor."
- cat>dummy.C<<EOF
- #ifdef __ANSI_CPP__
- yes
- #else
- no
- #endif
- EOF
- if capture "$CXXCOMPILER $ENVOPTS -E dummy.C | grep no"; then
- ANSICXXPP='-D__ANSI_CPP__'
- Note "... but __ANSI_CPP__ is not automatically defined, will compensate."
- fi
- else
- Note "Looks like $CXXCOMPILER has a non-ANSI C++ preprocessor, will try to compensate."
- fi
- #
- # Some pre-processors (e.g. SunPRO prior to version 3.0.1)
- # leave comments in a file when invoked with the -E option.
- # This messes up the default scheme used below to check for
- # function declarations. Consequently we check for this
- # behaviour here and try to work around the problem with
- # some sed hackery.
- #
- cat>dummy.C<<EOF
- /* this comment should be stripped */
- something else just in case
- and another line also
- EOF
- capture cat dummy.C
- if capture "$CXXCOMPILER $ENVOPTS -E dummy.C | grep comment"; then
- Note "WARNING, "$CXX -E" does not strip comments, will try to compensate."
- Note " Beware that this may not work and you may need to edit port.h"
- Note " to remove extraneous function declarations."
- stripComments()
- {
- sed -e '//*/,/*//d' -e 's;//.*$;;'
- }
- else
- stripComments()
- {
- cat
- }
- fi
- #
- # Check to see if the C++ compiler has an inbuilt 'bool' type
- #
- cat>dummy.C<<EOF
- int main()
- {
- bool success = false;
- return 0;
- }
- EOF
- capture cat dummy.C
- if capture "$CXXCOMPILER $ENVOPTS dummy.C"; then
- CONFIG_NEEDBOOL=no
- else
- Note "Looks like will need to define the 'bool' type."
- CONFIG_NEEDBOOL=yes
- fi
- #
- # Verify that $MAKE is accessible
- #
- PATHMAKE=`findApp ${MAKE} $PATH`
- if [ "$PATHMAKE" ]; then
- Note "Using $PATHMAKE to configure the software."
- else
- cat<<EOF
- No $MAKE located in the search path.
- There was no $MAKE program in the search path used by this script.
- If $MAKE is in a non-standard location, then set the MAKE environment
- variable to the pathname of the appropriate program or change your
- shell search path to include the directory where the program is located.
- EOF
- boom
- fi
- #
- # Deduce the include syntax supported by make.
- #
- CheckForMakeIncludeSyntax()
- {
- cat>confMakefile<<EOF
- $1
- all:
- EOF
- capture "cat confMakefile; ${MAKE} -f confMakefile"
- }
- if [ -z "$MAKEINCLUDE" ] || [ -z "$MAKELQUOTE" ] || [ -z "$MAKERQUOTE" ]; then
- INC=xmakeinc
- $RM $INC; echo "" >$INC
- if CheckForMakeIncludeSyntax "include $INC"; then
- MAKEINCLUDE="include"
- MAKELQUOTE=
- MAKERQUOTE=
- elif CheckForMakeIncludeSyntax ".include <$INC>"; then
- MAKEINCLUDE=".include"
- MAKELQUOTE="<"
- MAKERQUOTE=">"
- elif CheckForMakeIncludeSyntax "#include "$INC""; then
- MAKEINCLUDE="#include"
- MAKELQUOTE='"'
- MAKERQUOTE='"'
- else
- cat 1>&2 <<EOF
- $MAKE does not support a known include syntax.
- The make program configured for use in building this software does not
- support a known syntax for including other files in a Makefile. The
- Makefiles distributed with this software depend on the ability to include
- other files and will not work without this functionaliy. The following
- syntaxes are understood and configure automatically selects one for use
- if $MAKE looks to support it:
- include file
- .include <file>
- #include "file"
- If $MAKE does support including files then you should use a different
- program to build this software; consult the documentation for help in
- locating a suitable make program. Otherwise if $MAKE supports include
- files, but using a different syntax, then you can setup the MAKEINCLUDE,
- MAKELQUOTE, and MAKERQUOTE configuration parameters to define the
- appropriate syntax.
- EOF
- boom
- fi
- fi
- Note "Using "${MAKEINCLUDE} ${MAKELQUOTE}file${MAKERQUOTE}" syntax for Makefiles."
- if [ -z "$MAKEDEPINCLUDE" ]; then
- if [ "$MKDEPEND" != ":" ]; then
- $RM xMakedepend
- if CheckForMakeIncludeSyntax "sinclude xMakedepend"; then
- Note "Looks like $MAKE supports "sinclude" for conditional includes."
- MAKEDEPINCLUDE="sinclude"
- else
- MAKEDEPINCLUDE="$MAKEINCLUDE"
- fi
- else
- MAKEDEPINCLUDE='#'
- fi
- fi
- #
- # Check whether or not $MAKE automatically sets MAKE
- # in the Makefiles. If not, we add an explicit define
- # for places where recursive calls are made.
- #
- if [ -z "$SETMAKE" ]; then
- cat>confMakefile<<EOF
- all:
- @echo M="${MAKE}"
- EOF
- M=; eval `$MAKE -f confMakefile` >&5 2>&1
- if [ "$M" ]; then
- SETMAKE=
- else
- Note "Looks like $MAKE does not setup MAKE in Makefiles, will compensate."
- SETMAKE="MAKE = ${MAKE}"
- fi
- fi
- if [ -z "$MAKECXXOVERRIDE" ]; then
- case $ISGXX-$TARGET in
- no-*-solaris*|no-*-sunos*) # SunPRO C++ compiler
- #
- # Yech, the SunPro C++ compiler < v5 has no option to force a source
- # file w/ a .c++ suffix to be treated as C++ source code; instead one
- # must specify file.c++=.C. We patch the Makefiles with explicit
- # construction rules to do this...
- #
- if [ "`$CXX -V 2>&1 | sed 'q' | sed 's/.* C++ ([^ .]*).*/1/g'`" -lt "5" ]; then
- MAKECXXOVERRIDE="=.C";
- fi
- ;;
- esac
- fi
- if [ -z "$CXXFILE" ]; then
- case $CXX-$TARGET in
- xlC-*-aix*) CXXFILE="-+";;
- gcc-*) CXXFILE="-x c++";;
- *-*darwin*) CXXFILE="-x c++";;
- CC-*-sco3.2v5.*) CXXFILE="+.c++";;
- esac
- fi
- test "$AR" || AR=`findApp ar $PATH`
- if [ -z "$AR" ]; then
- Note "WARNING, could not locate a suitable ar command; using a default."
- AR=ar
- fi
- test "$AROPTS" || AROPTS=rc
- test "$RANLIB" || RANLIB=`findApp ranlib $PATH`
- if [ -z "$RANLIB" ]; then
- Note "WARNING, no ranlib, assuming it's not needed."
- RANLIB=":"
- $RM dummy.a
- if capture $AR rcs dummy.a; then
- AROPTS=crs
- Note "Looks like ar has an s option to build symbol tables."
- fi
- fi
- cat>dummy.C<<EOF
- #include <new>
- struct foo {
- int x;
- foo();
- ~foo();
- };
- foo::foo() {}
- foo::~foo() {}
- int main()
- {
- foo* ptr = 0;
- foo* a = new(ptr) foo;
- a->x = 0;
- delete a;
- return 0;
- }
- EOF
- #
- # Look for appropriate C++ runtime support library.
- #
- CXXRUNTIME=
- capture cat dummy.C
- capture $CXXCOMPILER $ENVOPTS -o dummy dummy.C || {
- #
- # Compiler does not provide it automatically, check known libraries.
- #
- if [ "$ISGXX" = yes ]; then
- capture $CXXCOMPILER $ENVOPTS -o dummy dummy.C -lg++ &&
- { CXXRUNTIME="-lg++"; }
- else
- capture $CXXCOMPILER $ENVOPTS -o dummy dummy.C -lC &&
- { CXXRUNTIME="-lC"; }
- fi
- }
- test "$CXXRUNTIME" && {
- Note "Using explicit $CXXRUNTIME reference for C++ runtime support."
- }
- #
- # XXX we should deduce the shell bugs that require us to use
- # bash and ksh instead of sh on certain platforms (notably the
- # BSD-crowd: Linux, BSDI, FreeBSD, NetBSD) but they are very
- # hard to isolate. We choose bash over ksh over sh; though
- # this may be iffy (ksh appears to be just as busted some places).
- #
- test "$SCRIPT_SH" || SCRIPT_SH=`findApp bash $PATH`
- test "$SCRIPT_SH" || SCRIPT_SH=`findApp ksh $PATH`
- test "$SCRIPT_SH" || SCRIPT_SH=`findApp sh $PATH`
- if [ -z "$SCRIPT_SH" ]; then
- Note ""
- Note "WARNING, could not locate a suitable shell for processing the command"
- Note " scripts included in this distribution; using a default value"
- Note " /bin/sh."
- Note ""
- SCRIPT_SH=/bin/sh
- else
- Note "Using $SCRIPT_SH to process command scripts."
- # Security stuff
- case $SCRIPT_SH in
- */sh) ;;
- */ksh) NOCLOBBER_ON='"set -o noclobber"'
- NOCLOBBER_OFF='"set +o noclobber"' ;;
- */bash) NOCLOBBER_ON='"set -o noclobber"'
- NOCLOBBER_OFF='"set +o noclobber"' ;;
- esac
- fi
- makeDefs()
- {
- WARNING="Warning, this file was automatically created by the HylaFAX configure script"
- $RM confsed1; dumpvars "$VAR1" | sort>confsed1
- $RM confsed2; dumpvars "$VAR2" | sort>confsed2
- unset POSIXLY_CORRECT
- $RM xdefs; sed -f confsed1 $SRCDIR/defs.in | sed -f confsed2 >$1
- POSIXLY_CORRECT=1 ; export POSIXLY_CORRECT
- }
- # NB: save original values for use in checks below
- OTIFFINC="${TIFFINC}"; x="`relativize ${TIFFINC}`"; TIFFINC="$x"
- OZLIBINC="${ZLIBINC}"; x="`relativize ${ZLIBINC}`"; ZLIBINC="$x"
- OREGEXINC="${REGEXINC}"; x="`relativize ${REGEXINC}`"; REGEXINC="$x"
- makeDefs xdefs
- #
- # runMake target rules ...
- #
- runMakeX()
- {
- target="$1"; shift
- $RM $target
- (echo DEPTH=.; echo SRCDIR=.; cat xdefs;
- for i in "$@"; do
- echo "$i";
- done
- )>confMakefile
- captureX ${MAKE} -f confMakefile $target
- return
- }
- runMake()
- {
- runMakeX "$@" >&5
- return
- }
- #
- # Verify everything is setup for the C++ runtime environment.
- #
- CheckForCXXRuntime()
- {
- cat>t.c++<<EOF
- #include <iostream>
- int main(){ std::cout << "Hello World!" << std::endl; return 0;}
- EOF
- runMake t "t:; ${C++F} ${C++FILE} t.c++${MAKECXXOVERRIDE}"
- }
- CheckForCXXRuntime || {
- cat 1>&2 <<EOF
- Missing C++ runtime support for $CXX ($CXXCOMPILER).
- Compilation of the following test program failed:
- ----------------------------------------------------------
- EOF
- cat t.c++ 1>&2
- cat 1>&2 <<EOF
- ----------------------------------------------------------
- Usually this is because you do not have a standard C++ library
- installed on your system or you have installed it in a non-standard
- location. If you do not have a C++ library installed, then you must
- install it. If it is installed in a non-standard location, then you
- should configure the compiler so that it will automatically be found.
- (For recent gcc releases this is libstdc++, for older gcc - libg++)
- EOF
- boom
- }
- #
- # Verify C++ built executables properly handle global
- # static variables with constructors.
- #
- CheckForCXXGlobalConstructors()
- {
- cat>t.c++<<EOF
- class foo {
- private:
- int a;
- public:
- foo() { a = -1; }
- int isInitialized() { return a == -1; }
- };
- static foo instanceOfFoo;
- int main() { return instanceOfFoo.isInitialized() ? 0 : 1; }
- EOF
- runMake t "t:; ${C++F} ${C++FILE} t.c++${MAKECXXOVERRIDE}" && ./a.out
- }
- CheckForCXXGlobalConstructors || {
- cat 1>&2 <<EOF
- Broken C++ handling of global constructors ($CXX/$CXXCOMPILER).
- Compilation or execution of the following test program failed:
- ----------------------------------------------------------
- EOF
- cat t.c++ 1>&2
- cat 1>&2 <<EOF
- ----------------------------------------------------------
- This program tests whether or not the C++ compilation support properly
- handles global static variables with constructors. A working C++
- compilation environment is expected to arrange that global variables
- that have a constructor function (foo::foo() above) be called prior to
- the start of main(). HylaFAX will not operate properly if the C++
- compilation environment does not correctly implement this.
- EOF
- if [ $ISGXX = yes ]; then
- if expr $CXX : '.*g++.*' >/dev/null 2>&1; then
- cat 1>&2 <<EOF
- When using GNU gcc this can sometimes happen if gcc is improperly
- configured; consult your local GNU guru/support person for help with
- this problem.
- EOF
- else
- cat 1>&2 <<EOF
- When using GNU gcc to compile C++ programs this can sometimes happen
- when g++ is not used to link executables. You might try setting
- CXX to "g++" (or similar) in a config.local file or on the command
- line. Otherwise you should consult your local GNU guru/support person
- for help with this problem.
- EOF
- fi
- fi
- boom
- }
- #
- # Look for a library using a known (unique) function.
- #
- CheckForLibrary()
- {
- f=$1; shift
- libs="$@";
- cat>t.c<<EOF
- extern int $f();
- int t() { $f(); return 0; }
- int main(){ t(); return 0; }
- EOF
- capture cat t.c
- runMake t "t:; ${CCF} t.c $libs"
- }
- #
- # Look for a library using a known (unique) function.
- #
- CheckForLibraryWithArgs()
- {
- l=$1; shift
- f=$1; shift
- a=$1; shift
- libs="$@";
- cat>t.c<<EOF
- #include <$l>
- int t() { $f($a); return 0; }
- int main(){ t(); return 0; }
- EOF
- capture cat t.c
- runMake t "t:; ${CCF} t.c $libs"
- }
- #
- # Look for an include file.
- #
- CheckForIncludeFile()
- {
- (for i do
- echo "#include "$i""
- done)>t.c++
- capture cat t.c++
- runMake t "t:; ${C++F} ${C++FILE} -E t.c++${MAKECXXOVERRIDE}"
- }
- if [ "$SGI2FAX" = auto ]; then
- if CheckForLibrary iopen -limage && CheckForIncludeFile gl/image.h; then
- Note "Looks like there is support for SGI RGB images, configuring sgi2fax."
- SGI2FAX=yes
- else
- SGI2FAX=no
- fi
- fi
- if [ "$LIBMALLOC" = auto ]; then
- if CheckForLibrary mallopt -lmalloc; then
- Note "Looks like -lmalloc is here, using it for memory allocation."
- LIBMALLOC=yes
- else
- LIBMALLOC=no
- fi
- fi
- if [ "$LIBSUN" = auto ]; then
- if CheckForLibrary getpwnam -lsun; then
- Note "Looks like -lsun is here, using it for NIS passwd & group stuff."
- LIBSUN=yes
- else
- LIBSUN=no
- fi
- fi
- #
- # PAM libraries are slightly different. So we run some tests to try to
- # distinguish between them.
- #
- CheckPAMType()
- {
- Note "... checking PAM library version"
- cat>t.c++<<EOF
- #include "security/pam_appl.h"
- int
- pamconv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata)
- {
- return(0);
- }
- main()
- {
- struct pam_conv conv = { pamconv };
- }
- EOF
- if runMake t "t:; ${C++F} $PAMLIBS ${C++FILE} t.c++${MAKECXXOVERRIDE}"; then
- echo '#define STRUCT_PAM_MESSAGE const struct pam_message'
- else
- echo '#define STRUCT_PAM_MESSAGE struct pam_message'
- fi
- case $TARGET in
- *-hpux11*) echo '#define PAM_MSG_VERSION';;
- esac
- }
- HAVE_PAM="/*#define HAVE_PAM 1*/"
- PAMLIBS=""
- if [ "$DISABLE_PAM" != "yes" ]; then
- Note "Checking for PAM (Pluggable Authentication Module) support"
- CheckForLibrary pam_authenticate -lpam &&
- CheckForIncludeFile security/pam_appl.h && {
- HAVE_PAM="#define HAVE_PAM 1"
- PAMLIBS="-lpam"
- }
- if [ "x$PAMLIBS" = "x" ]; then
- Note "... not found. Disabling PAM support"
- else
- Note "... found. Enabling PAM support"
- fi
- else
- Note "Disabling PAM support"
- fi
- HAVE_JBIG="/*#define HAVE_JBIG 1*/"
- LIBJBIG=""
- if [ "$DISABLE_JBIG" != "yes" ]; then
- Note "Checking for JBIG library support"
- CheckForLibrary jbg_enc_init -ljbig &&
- CheckForIncludeFile jbig.h && {
- HAVE_JBIG="#define HAVE_JBIG 1"
- LIBJBIG="-ljbig"
- }
- if [ "x$LIBJBIG" = "x" ]; then
- Note "... not found. Disabling JBIG support"
- else
- Note "... found. Enabling JBIG support"
- fi
- else
- Note "Disabling JBIG support"
- fi
- HAVE_LDAP="/*#define HAVE_LDAP 1*/"
- LDAPLIBS=""
- if [ "$DISABLE_LDAP" != "yes" ]; then
- Note "Checking for LDAP (Lightweight Directory Access Protocol) support"
- CheckForLibrary ldap_initialize -lldap &&
- CheckForLibrary ber_get_null -llber &&
- CheckForIncludeFile ldap.h && {
- HAVE_LDAP="#define HAVE_LDAP 1"
- LDAPLIBS="-lldap -llber -lresolv"
- }
- if [ "x$LDAPLIBS" = "x" ]; then
- Note "... not found. Disabling LDAP support"
- else
- Note "... found. Enabling LDAP support"
- fi
- else
- Note "Disabling LDAP support"
- fi
- CheckForLibrary crypt -lc || {
- #
- # FreeBSD-2.1 in particular needs -lcrypt.
- # SCO sometime has -lcrypt_d (domestic) and
- # sometimes -lcrypt_i (import?)
- #
- for i in -lcrypt -lcrypt_d -lcrypt_i; do
- if CheckForLibrary crypt $i; then
- Note "Looks like $i is needed for crypt."
- MACHDEPLIBS="$MACHDEPLIBS $i"
- break;
- fi
- done
- }
- CheckForLibraryWithArgs time.h strftime "(void*)0, 0, (void*)0, (void*)0" -lc || {
- #
- # SCO has strftime in -lintl.
- #
- if CheckForLibrary strftime -lintl; then
- Note "Looks like -lintl is needed for strftime."
- MACHDEPLIBS="$MACHDEPLIBS -lintl"
- else
- cat 1>&2 <<EOF
- No strftime function located in system libraries.
- The strftime function used to format date&time information was not located
- in the normal C library or in the -lintl library (present on some systems).
- This software expects this to be available and will not compile without it.
- If this function is located in a non-standard location you can specify the
- library in the MACHDEPLIBS configuration parameter. Otherwise you should
- figure out why the usual testing done by this script failed; consult the
- diagnostics in the config.log file for more information.
- EOF
- boom
- fi
- }
- CheckForLibrary socket -lc || {
- #
- # Socket support is not in normal C library, check
- # for SVR4-style networking w/ -lsocket & -lnsl
- #
- if CheckForLibrary socket -lsocket -lnsl; then
- Note "Looks like -lsocket & -lnsl are needed for socket support."
- MACHDEPLIBS="$MACHDEPLIBS -lsocket -lnsl"
- elif CheckForLibrary socket -linet -lnsl_s; then
- Note "Looks like -linet & -lnsl_s are needed for socket support."
- MACHDEPLIBS="$MACHDEPLIBS -linet -lnsl_s"
- elif CheckForLibrary socket -lsocket; then
- Note "Looks like -lsocket is needed for socket support."
- MACHDEPLIBS="$MACHDEPLIBS -lsocket"
- else
- cat 1>&2 <<EOF
- No socket networking support located in system libraries.
- The socket function used to create a network connection was not located
- in the normal C library or in the -lsocket or -linet libraries (present
- mainly on SVR4-style systems). This software expects this to be
- available and will not compile without it. If this function is located
- in a non-standard location you can specify the needed libraries in the
- MACHDEPLIBS configuration parameter. Otherwise you should figure out
- why the usual testing done by this script failed; consult the
- diagnostics in the config.log file for more information.
- EOF
- boom
- fi
- }
- CheckForLibrary inet_aton -lc || {
- CheckForLibrary inet_aton -lresolv && {
- MACHDEPLIBS="$MACHDEPLIBS -lresolv"
- }
- }
- if CheckForLibrary logwtmp -lutil; then
- Note "Looks like -lutil is needed for wtmp file logging."
- MACHDEPLIBS="$MACHDEPLIBS -lutil"
- HAS_LOGWTMP=yes
- else
- HAS_LOGWTMP=no
- fi
- CheckForLibrary ftruncate -lc || {
- CheckForLibrary chsize -lx && {
- Note "Looks like -lx is needed for chsize (used to emulate ftruncate)."
- MACHDEPLIBS="$MACHDEPLIBS -lx"
- }
- }
- CheckForLibrary flock -lc || {
- CheckForLibrary flock -lbsd && {
- Note "Looks like -lbsd is needed for flock."
- MACHDEPLIBS="$MACHDEPLIBS -lbsd"
- }
- }
- for f in openlog pututxline; do
- CheckForLibrary $f -lc || {
- CheckForLibrary $f -lgen && {
- Note "Looks like -lgen is needed for $f."
- MACHDEPLIBS="$MACHDEPLIBS -lgen"
- break;
- }
- }
- done
- if [ "$ISGXX" = yes ]; then
- if [ -z "$CXXRUNTIME" ]; then
- for f in memmove strdup; do
- if [ $f = "memmove" ]; then
- CheckForLibraryWithArgs string.h $f "(void*)0, (void*)0, 0" -lc || {
- CheckForLibraryWithArgs string.h $f "(void*0), (void*)0, 0" -lg++ && {
- Note "Looks like we need -lg++ for $f"
- MACHDEPLIBS="$MACHDEPLIBS -lg++"
- break;
- }
- }
- else
- CheckForLibraryWithArgs string.h $f "(void*)0" -lc || {
- CheckForLibraryWithArgs string.h $f "(void*)0" -lg++ && {
- Note "Looks like we need -lg++ for $f"
- MACHDEPLIBS="$MACHDEPLIBS -lg++"
- break;
- }
- }
- fi
- done
- fi
- for f in strtoul strerror memmove random; do
- if [ $f = "memmove" ]; then
- CheckForLibraryWithArgs string.h $f "(void*)0, (void*)0, 0" -lc || {
- CheckForLibraryWithArgs string.h $f "(void*0), (void*)0, 0" -liberty && {
- Note "Looks like we need -liberty for $f"
- MACHDEPLIBS="$MACHDEPLIBS -liberty"
- break;
- }
- }
- elif [ $f = "strerror" ]; then
- CheckForLibraryWithArgs string.h $f "0" -lc || {
- CheckForLibraryWithArgs string.h $f "0" -liberty && {
- Note "Looks like we need -liberty for $f"
- MACHDEPLIBS="$MACHDEPLIBS -liberty"
- break;
- }
- }
- else
- CheckForLibraryWithArgs string.h $f "" -lc || {
- CheckForLibraryWithArgs string.h $f "" -liberty && {
- Note "Looks like we need -liberty for $f"
- MACHDEPLIBS="$MACHDEPLIBS -liberty"
- break;
- }
- }
- fi
- done
- fi
- CheckForLibraryWithArgs math.h floor "0" -lm && {
- Note "Looks like -lm is the library for math functions."
- MACHDEPLIBS="$MACHDEPLIBS -lm"
- }
- MACHDEPLIBS="$MACHDEPLIBS $CXXRUNTIME"
- test "$LIBSUN" = yes && MACHDEPLIBS="$MACHDEPLIBS -lsun"
- test "$LIBMALLOC" = yes && MACHDEPLIBS="$MACHDEPLIBS -lmalloc"
- #
- # Figure out if certain system-specific interfaces are
- # supported. We craft a port.h file that has external
- # declarations for missing routines that are required by
- # the system and modify defs to reflect which optional
- # interfaces are supported.
- #
- EmitCPlusPlusPrologue()
- {
- echo '/*'
- echo ' * Warning, this file was automatically created by the HylaFAX configure script'
- echo ' * VERSION: ' $VERSION
- echo ' * DATE: ' $DATE
- echo ' * TARGET: ' $TARGET
- echo ' * RELEASE: ' $RELEASE
- if [ $ISGCC = yes ]; then
- echo ' * CCOMPILER: ' ${CCOMPILER}-${GCCversion}
- else
- echo ' * CCOMPILER: ' $CCOMPILER
- fi
- if [ $ISGXX = yes ]; then
- echo ' * CXXCOMPILER: ' ${CXXCOMPILER}-${GCCversion}
- else
- echo ' * CXXCOMPILER: ' $CXXCOMPILER
- fi
- echo ' */'
- echo "#ifndef $1"
- echo "#define $1 1"
- echo '#ifdef __cplusplus'
- echo 'extern "C" {'
- echo '#endif'
- }
- EmitCPlusPlusEpilogue()
- {
- echo '#ifdef __cplusplus'
- echo '}'
- echo '#endif'
- echo '#endif'
- }
- releaseAtLeast()
- {
- expr $RELEASE >= $1 >/dev/null 2>&1
- }
- #
- # Emit the port.h definitions that reflect
- # the system configuration.
- #
- EmitConfigurationDefinitions()
- {
- #
- # Do bool stuff
- #
- if [ "$CONFIG_NEEDBOOL" = "yes" ]; then
- Note "... adding definition for C++ bool type"
- echo
- echo "#define NEED_BOOL"
- echo
- fi
- #
- # Select the mode to use when opening FIFO files
- # in a server process. One should be able to open
- # them read-only, but on some systems, select will
- # go into a loop when a client does a close. This
- # problem can sometimes be avoided by opening the FIFO
- # read+write on the server side. Otherwise, the
- # FIFO must be closed after each incoming message
- # which can lead to delays and/or lost messages
- # (though we try to compensate by doing some sleeps).
- #
- test "$CONFIG_OPENFIFO" || {
- case $TARGET in
- *-irix*) if releaseAtLeast 5.2; then
- CONFIG_OPENFIFO=O_RDWR;
- else
- CONFIG_OPENFIFO=O_RDONLY;
- fi
- ;;
- *-ultrix*) CONFIG_OPENFIFO=O_RDWR;;
- *-solaris*) CONFIG_OPENFIFO=O_RDWR;;
- *-*-sco*|*-isc*) CONFIG_OPENFIFO=O_RDWR;;
- *-aix*|*-hpux*) CONFIG_OPENFIFO=O_RDWR;;
- alpha-dec*) CONFIG_OPENFIFO=O_RDWR;;
- *-linux*) if releaseAtLeast 1.3.80; then
- CONFIG_OPENFIFO=O_RDWR;
- else
- CONFIG_OPENFIFO=O_RDONLY;
- fi
- ;;
- *-freebsd*) if releaseAtLeast 3.0; then
- CONFIG_OPENFIFO=O_RDWR;
- else
- CONFIG_OPENFIFO=O_RDONLY;
- fi
- ;;
- *sysv4.2uw2.1.3) CONFIG_OPENFIFO=O_RDWR;; # UnixWare 2.1.3
- *-sysv5UnixWare*) CONFIG_OPENFIFO=O_RDWR;; # UnixWare 7
- *-sysv5OpenUNIX*) CONFIG_OPENFIFO=O_RDWR;; # OpenUNIX 8
- *-sysv5SCO_SV*) CONFIG_OPENFIFO=O_RDWR;; # OpenServer 6
- *) CONFIG_OPENFIFO=O_RDONLY;;
- esac
- }
- if [ "$CONFIG_OPENFIFO" = "O_RDWR" ]; then
- Note "... open FIFO files read+write to avoid select bug"
- else
- Note "... open FIFO files read-only"
- fi
- echo "#define CONFIG_OPENFIFO $CONFIG_OPENFIFO"
- test "$CONFIG_FIFOBUG" || {
- case $TARGET in
- *-solaris*) CONFIG_FIFOBUG=yes;;
- *-irix5.[01]*) CONFIG_FIFOBUG=yes;;
- *) CONFIG_FIFOBUG=no;;
- esac
- }
- if [ "$CONFIG_FIFOBUG" = yes ]; then
- Note "... enable workaround for FIFO select bug"
- echo '#define FIFOSELECTBUG 1'
- fi
- #
- # On some systems the argument for ioctl(fd, TIOCMBIS, arg)
- # is passed by value and some by reference.
- # This can not be deduced with a dynamic check.
- #
- test "$CONFIG_TIOCMBIS_ARG_REF" || {
- case $TARGET in
- *-sysv4*) CONFIG_TIOCMBISBYREF=yes;;
- *-sysv5*) CONFIG_TIOCMBISBYREF=yes;;
- *-linux*) CONFIG_TIOCMBISBYREF=yes;;
- *-sunos*) CONFIG_TIOCMBISBYREF=yes;;
- *) CONFIG_TIOCMBISBYREF=yes;;
- esac
- }
- if [ "$CONFIG_TIOCMBISBYREF" = yes ]; then
- Note "... using call-by-reference for TIOCMBIS ioctl"
- echo "#define CONFIG_TIOCMBISBYREF $CONFIG_TIOCMBISBYREF"
- else
- Note "... using call-by-value for TIOCMBIS ioctl"
- fi
-
- #
- # On some systems it's necessary to include
- # <sys/stream.h> and <sys/ptem.h> to get the
- # necessary definitions for TIOCWINSZ. This
- # should be deduced with a dynamic check.
- #
- test "$CONFIG_WINSZHACK" || {
- case $TARGET in
- *-*-sco*) CONFIG_WINSZHACK=yes;;
- *-isc*) CONFIG_WINSZHACK=yes;;
- *) CONFIG_WINSZHACK=no;;
- esac
- }
- if [ "$CONFIG_WINSZHACK" = yes ]; then
- Note "... enable additional include files for TIOCGWINSZ"
- echo "#define CONFIG_WINSZHACK"
- fi
- #
- # On some systems the server does not work properly
- # if a recursive call is made to the dispatcher to
- # poll for an message on the FIFO file that says to
- # abort an outbound or inbound job. The only know
- # workaround for this problem is to ignore messages
- # while processing a job.
- #
- test "$CONFIG_ABORTBUG" || {
- case $TARGET in
- *-aix*) CONFIG_ABORTBUG=yes;;
- *-hpux*) CONFIG_ABORTBUG=yes;;
- *) CONFIG_ABORTBUG=no;;
- esac
- }
- if [ "$CONFIG_ABORTBUG" = yes ]; then
- Note "... disable support for aborting sends & receives"
- echo '#define SERVERABORTBUG'
- fi
- #
- # On some systems redirecting stdout to the controlling
- # tty causes stty to issue an annoying warning message.
- # This should probably be deduced with a dynamic test.
- #
- test "$CONFIG_NOSTDINDUP" || {
- case $TARGET in
- *-freebsd*) CONFIG_NOSTDINDUP=yes;;
- *) CONFIG_NOSTDINDUP=no;;
- esac
- }
- if [ "$CONFIG_NOSTDINDUP" = yes ]; then
- Note "... assuming stty bitches when stdout is set to stdin"
- echo "#define ONDELAY_NOSTDINDUP"
- fi
- #
- # Some systems cannot handle re-opening the tty device
- # after the modem is reset. This is true for modems
- # attached to some terminal servers and also on HP-UX
- # where the modem control state is lost across opens.
- # Basically if the OS and modem correctly handle toggling
- # DTR to reset the modem then it's safe to configure
- # the software to not re-open the device.
- #
- test "$CONFIG_NOREOPEN" || {
- case $TARGET in
- *-hpux*) CONFIG_NOREOPEN=yes;;
- *) CONFIG_NOREOPEN=no;;
- esac
- }
- if [ "$CONFIG_NOREOPEN" = yes ]; then
- Note "... don't reopen the tty device after reset"
- echo "#define CONFIG_NOREOPEN"
- fi
- #
- # Workarounds for systems with system include files
- # that have incorrect function declarations (wrong
- # parameter types that require explicit casts to make
- # the code compile with certain compilers).
- #
- test "$CONFIG_BADEXECVPROTO" || { # char* const* vs. const char**
- case $TARGET in
- *-*-sco3.2v5.*) CONFIG_BADEXECVPROTO=no;;
- *-*-sco*) CONFIG_BADEXECVPROTO=yes;;
- *) CONFIG_BADEXECVPROTO=no;;
- esac
- }
- if [ "$CONFIG_BADEXECVPROTO" = yes ]; then
- Note "... workaround incorrect execv function declaration"
- echo "#define CONFIG_BADEXECVPROTO"
- fi
- test "$CONFIG_BADEXECVEPROTO" || { # char* const* vs. const char**
- case $TARGET in
- *-*-sco3.2v5.*) CONFIG_BADEXECVEPROTO=no;;
- *-*-sco*) CONFIG_BADEXECVEPROTO=yes;;
- *) CONFIG_BADEXECVEPROTO=no;;
- esac
- }
- if [ "$CONFIG_BADEXECVEPROTO" = yes ]; then
- Note "... workaround incorrect execve function declaration"
- echo "#define CONFIG_BADEXECVEPROTO"
- fi
- test "$CONFIG_BADGETOPTPROTO" || { # char* const* vs. char**
- case $TARGET in
- *-aix*) CONFIG_BADGETOPTPROTO=yes;;
- *-*-sco3.2v4.*) CONFIG_BADGETOPTPROTO=yes;;
- *) CONFIG_BADGETOPTPROTO=no;;
- esac
- }
- if [ "$CONFIG_GETOPTPROTO" = yes ]; then
- Note "... workaround incorrect getopt function declaration"
- echo "#define CONFIG_GETOPTPROTO"
- fi
- test "$CONFIG_BADSELECTPROTO" || { # int* vs. fd_set*
- case $TARGET in
- *-hpux10.20*) CONFIG_BADSELECTPROTO=no;;
- *-hpux11*) CONFIG_BADSELECTPROTO=no;;
- *-hpux*) CONFIG_BADSELECTPROTO=yes;;
- *) CONFIG_BADSELECTPROTO=no;;
- esac
- }
- if [ "$CONFIG_BADSELECTPROTO" = yes ]; then
- Note "... workaround incorrect select function declaration"
- echo "#define CONFIG_BADSELECTPROTO"
- fi
- #
- # Select the maximum fax UID. This value is stored
- # in the GID of files so must be constrained by any
- # system limitations. The maximum value is used for
- # anonymous logins. The default value of 60002 comes
- # from NFS/nobody usage on various systems.
- #
- test "$CONFIG_MAXGID" || {
- case $TARGET in
- *-*-sco*) CONFIG_MAXGID=60000;;
- *-sysv5UnixWare*) CONFIG_MAXGID=60000;; # UnixWare 7
- *-sysv5OpenUNIX*) CONFIG_MAXGID=60000;; # OpenUNIX 8
- *-sysv5SCO_SV*) CONFIG_MAXGID=60000;; # OpenServer 6
- *-hpux*) CONFIG_MAXGID=60000;;
- *) CONFIG_MAXGID=60002;; # default
- esac
- }
- if [ "$CONFIG_MAXGID" ]; then
- if [ "$CONFIG_MAXGID" -le 60002 ]; then
- Note "... constrain client IDs to be <= $CONFIG_MAXGID"
- echo "#define CONFIG_MAXGID $CONFIG_MAXGID"
- else
- Note "... max client ID too large ($CONFIG_MAXGID); using default"
- fi
- fi
- }
- #
- # Look for a function in one of the standard libraries
- # or one of the machine-dependent libraries selected above.
- #
- CheckForFunc()
- {
- echo "#include <stdlib.h>" > t.c
- echo "extern int $1(); main(){$1($2);exit(0);}" >> t.c
- capture cat t.c
- runMake t "t:; ${CC} t.c ${MACHDEPLIBS}"
- }
- CheckForStdFunc()
- {
- echo "#include <stdlib.h>" > t.c
- echo "main(){$1($2);exit(0);}" >> t.c
- capture cat t.c
- runMake t "t:; ${CC} t.c ${MACHDEPLIBS}"
- }
- CheckForStdioFunc()
- {
- echo "#include <stdlib.h>" > t.c
- echo "#include <stdio.h>" >> t.c
- echo "main(){$1($2);exit(0);}" >> t.c
- capture cat t.c
- runMake t "t:; ${CC} t.c ${MACHDEPLIBS}"
- }
- CheckForUnistdFunc()
- {
- echo "#include <stdlib.h>" > t.c
- echo "#include <unistd.h>" >> t.c
- echo "main(){$1($2);exit(0);}" >> t.c
- capture cat t.c
- runMake t "t:; ${CC} t.c ${MACHDEPLIBS}"
- }
- #
- # Look for a function declaration in system include files.
- #
- AddFuncDecl()
- {
- echo "$2";
- Note "... add function prototype for $1"
- }
- CheckForFuncDecl()
- {
- f=$1; shift
- (for i do
- echo "#include "$i""
- done)>t.c++
- capture cat t.c++
- runMakeX t "t:; ${C++F} ${C++FILE} -E t.c++${MAKECXXOVERRIDE}" |
- stripComments |
- awk '{while($0~/[,(][ t]*$/){printf"%s",$0;getline}print}' |
- grep "$f[ ]*(.*)" >&5
- return
- }
- CheckFuncDecl()
- {
- f=$1; shift
- decl=$1; shift
- CheckForFuncDecl "$f" "$@" || AddFuncDecl "$f" "$decl"
- }
- #
- # Look for a variable declaration in system include files.
- #
- CheckForVarDecl()
- {
- v="$1"; shift
- (for i do
- echo "#include "$i""
- done)>t.c++
- capture cat t.c++
- runMakeX t "t:; ${C++F} ${C++FILE} -E t.c++${MAKECXXOVERRIDE}" |
- stripComments |
- grep "$v" >&5
- return
- }
- CheckVarDecl()
- {
- v="$1"; shift
- decl="$1"; shift
- CheckForVarDecl "$v" "$@" ||
- (echo "$decl"; Note "... add declaration $decl")
- }
- #
- # Look for a #define in system include files.
- #
- AddDefine()
- {
- echo '#ifndef' $1
- echo '#define' "$2"
- echo '#endif'
- Note '... add #define for' "$1"
- }
- CheckForDefine()
- {
- def=$1; shift
- (for i do
- echo "#include "$i""
- done
- for i in "#ifdef $def" "FOUND" "#endif"; do
- echo "$i"
- done
- )>t.c
- capture cat t.c
- runMakeX t 't:; ${CCF} -E t.c' | grep FOUND >&5
- }
- CheckDefine()
- {
- def=$1; shift
- decl=$1; shift
- CheckForDefine "$def" "$@" || AddDefine "$def" "$decl"
- }
- #
- # Look for a #define with a positive value in system include files.
- # This is especially useful for POSIX defines which may be defined
- # to -1 or 0 when the functionnality is not supported.
- #
- CheckForPositiveDefine()
- {
- def=$1; shift
- (for i do
- echo "#include "$i""
- done
- for i in "#if defined($def) && ($def > 0L)" "FOUND" "#endif"; do
- echo "$i"
- done
- )>t.c
- capture cat t.c
- runMakeX t 't:; ${CCF} -E t.c' | grep FOUND >&5
- }
- CheckTermioFuncDecls()
- {
- CheckFuncDecl cfsetospeed
- 'extern int cfsetospeed(const struct termios*, speed_t);' $@
- CheckFuncDecl cfsetispeed
- 'extern int cfsetispeed(const struct termios*, speed_t);' $@
- CheckFuncDecl tcgetattr 'extern int tcgetattr(int, struct termios*);' $@
- CheckFuncDecl tcsetattr
- 'extern int tcsetattr(int, int, const struct termios*);' $@
- CheckFuncDecl tcsendbreak 'extern int tcsendbreak(int, int);' $@
- CheckFuncDecl tcdrain 'extern int tcdrain(int);' $@
- CheckFuncDecl tcflush 'extern int tcflush(int, int);' $@
- CheckFuncDecl tcflow 'extern int tcflow(int, int);' $@
- }
- BuildTermiosDotH()
- {
- CheckForIncludeFile termios.h || {
- CheckForIncludeFile sys/termios.h || {
- bitch "Cannot locate termios.h or sys/termios.h."
- boom
- }
- Note ""
- Note "No termios.h found; creating one with necessary definitions."
- (EmitCPlusPlusPrologue _TERMIOS_
- echo '#include "sys/termios.h"'
- CheckTermioFuncDecls sys/termios.h
- EmitCPlusPlusEpilogue
- )>xtermios.h
- mv xtermios.h termios.h; chmod 444 termios.h
- }
- }
- CheckSigvecHandler()
- {
- cat>t.c++<<EOF
- #include <sys/types.h>
- #include <signal.h>
- void sigHUP(int) {}
- void f() {
- struct sigvec sv;
- sv.sv_handler = $1 (sigHUP);
- (void) sigvec(SIGHUP, &sv, (struct sigvec*) 0);
- }
- int main() { f(); return 0; }
- EOF
- capture cat t.c++
- runMake t "t:; ${C++F} ${C++FILE} -c t.c++${MAKECXXOVERRIDE}"
- }
- CheckSigactionHandler()
- {
- cat>t.c++<<EOF
- #include <sys/types.h>
- #include <signal.h>
- void sigHUP(int) {}
- void f() {
- struct sigaction sa;
- sa.sa_handler = $1 (sigHUP);
- (void) sigaction(SIGHUP, &sa, (struct sigaction*) 0);
- }
- int main() { f(); return 0; }
- EOF
- capture cat t.c++
- runMake t "t:; ${C++F} ${C++FILE} -c t.c++${MAKECXXOVERRIDE}"
- }
- CheckSignalHandler()
- {
- cat>t.c++<<EOF
- #include <sys/types.h>
- #include <signal.h>
- void sigHUP(int) {}
- void f() { (void) signal(SIGHUP, $1 (sigHUP)); }
- int main() { f(); return 0; }
- EOF
- capture cat t.c++
- runMake t "t:; ${C++F} ${C++FILE} -c t.c++${MAKECXXOVERRIDE}"
- }
- CheckForMMAP()
- {
- (cat<<'EOF'
- /* part of this was lifted from GNU autoconf */
- #include <sys/types.h>
- #include <fcntl.h>
- #include <sys/mman.h>
- EOF
- CheckForFunc getpagesize || {
- cat<<'EOF'
- #ifdef BSD
- # ifndef BSD4_1
- # define HAVE_GETPAGESIZE
- # endif
- #endif
- #ifndef HAVE_GETPAGESIZE
- # include <sys/param.h>
- # ifdef EXEC_PAGESIZE
- # define getpagesize() EXEC_PAGESIZE
- # else
- # ifdef NBPG
- # define getpagesize() NBPG * CLSIZE
- # ifndef CLSIZE
- # define CLSIZE 1
- # endif
- # else
- # ifdef NBPC
- # define getpagesize() NBPC
- # else
- # define getpagesize() PAGESIZE /* SVR4 */
- # endif
- # endif
- # endif
- #endif
- EOF
- }
- cat<<'EOF'
- #include <stdlib.h>
- #include <stdio.h>
- static void
- boom(const char* msg)
- {
- printf("%s.n", msg);
- exit(1);
- }
- int
- main()
- {
- const char* filename = "conftestmmap";
- char* buf;
- char* addr;
- int i, fd, cc;
- cc = getpagesize();
- buf = malloc(cc);
- for (i = 0; i < cc; ++i)
- buf[i] = rand();
- fd = open(filename, O_WRONLY|O_CREAT, 0666);
- if (fd < 0)
- boom("Cannot open test file");
- if (write(fd, buf, cc) != cc)
- boom("Write to test file failed");
- close(fd);
- fd = open(filename, O_RDONLY);
- if (fd < 0)
- boom("Cannot reopen test file");
- addr = (char*) mmap(0, cc, PROT_READ, MAP_SHARED, fd, 0);
- if (addr == (char*) -1)
- boom("Cannot mmap test file");
- for (i = 0; i < cc; ++i)
- if (buf[i] != addr[i])
- boom("Compare of mmap-file contents failed");
- exit(0);
- }
- EOF
- )>m.c
- capture cat m.c
- runMake m "m:; ${CC} m.c ${MACHDEPLIBS}" && capture ./a.out
- }
- CheckForStructExitStatus()
- {
- decl=$1; shift
- (echo '#include <utmp.h>'
- for i do
- echo "$i"
- done
- cat<<EOF
- main()
- {
- struct $decl x;
- x.ut_exit.e_exit = 0;
- x.ut_exit.e_termination = 0;
- return 0;
- }
- EOF
- )>t.c++
- capture cat t.c++
- runMake t "t:; ${C++F} ${C++FILE} t.c++${MAKECXXOVERRIDE}"
- }
- CheckForTimeZoneHandling()
- {
- (echo '#include <time.h>'
- cat<<EOF
- main()
- {
- struct tm x;
- const char* cp;
- long off;
- cp = x.tm_zone;
- off = x.tm_gmtoff;
- return 0;
- }
- EOF
- )>t.c++
- capture cat t.c++
- runMake t "t:; ${C++F} ${C++FILE} t.c++${MAKECXXOVERRIDE}"
- }
- CheckForTXCD()
- {
- cat>t.c<<EOF
- #include <sys/ioctl.h>
- main()
- {
- ioctl(0, TXADDCD, "rts");
- ioctl(0, TXDELCD, "rts");
- }
- EOF
- capture cat t.c
- runMake t 't:; ${CC} t.c'
- }
- #
- # Check for a function declaration in <stdio.h>
- # and if it is missing emit the appropriate decl
- # along with an include of <stdio.h> (for any
- # FILE definition). Apparently some combinations
- # of systems+compilers do not react well to
- # function declarations w/o various definitions
- # that appear only in stdio.h.
- #
- STDIO_H=no
- CheckStdio()
- {
- f=$1
- decl="$2"
- CheckForFuncDecl $f stdio.h || {
- if [ $STDIO_H = no ]; then
- echo '#include <stdio.h>'
- STDIO_H=yes
- fi
- AddFuncDecl $f "$decl"
- }
- }
- getConfigTag()
- {
- param=`grep "$1:" $2 | sed -e 's/.*:[ ]*([^ ]*).*/1/'`
- }
- #
- # Check if TIFF library is compatible. If successful,
- # set $tiff_runlen_t on exit to "uint16" or "uint32"
- #
- CheckLibtiff()
- {
- Note "... checking TIFF library version"
- tiff_runlen_t=""
- cat>t.c<<EOF
- #include <stdlib.h>
- #include <stdio.h>
- #include "tiffio.h"
- main()
- {
- printf( "header_ver=%d lib_ver=%s", TIFFLIB_VERSION, TIFFGetVersion() );
- exit(0);
- }
- EOF
- capture cat t.c
- if runMake t "t:; ${CC} ${CVERSION} ${OTIFFINC} t.c ${LIBTIFF} ${MACHDEPLIBS}"; then
- header_ver=0
- lib_ver=""
- eval `./a.out |
- sed -n -e 's/header_ver=([0-9][0-9]*) lib_ver=.*Version *([0-9][0-9]*.[0-9]).*/
- header_ver=1;lib_ver=2/p'`