WFDB Software Package 10.7.0

File: <base>/configure (24,854 bytes)
#! /bin/sh
# file: configure             G. Moody         24 May 2000
#                             Last revised:    18 May 2022
# Configuration script for the WFDB Software Package

# This script was not generated using 'autoconf'.  If you can implement
# autoconf input files for a 'configure' that does what this one does,
# please send them to wfdb@physionet.org for inclusion in a future
# version of this package.

# Note that any -m options (although parsed below) are currently ignored,
# except on x86_64 Linux, where they are prefixed to CFLAGS.  The help
# text below documents only -m32;  see the gcc manual for other -m options.

# Defaults (overridden by --interactive):
INTERACTIVE=no
LIBTYPE=dynamic
DIR=/usr/local
MANDIR=unknown
LIBDIR=unknown
HOST=
MFLAGS=
ARCHLIST=

NETLIB=unknown
FLAC=unknown
WAVE=unknown
OWHOME=/usr/openwin
LIBFLAC_CFLAGS=
LIBFLAC_LIBS=

LC_ALL=C
export LC_ALL

# Read and process command-line arguments
for i in $*
do
  case $i in
    --dynamic)          LIBTYPE=dynamic ;;
    -i|--interactive)   INTERACTIVE=yes
    			LIBTYPE=
			DIR=
			MANDIR= ;;
    -m*)                if [ "x$MFLAGS" = x ]
                        then
		            MFLAGS=$i
		        else
		            MFLAGS="$MFLAGS $i"
		        fi ;;
    --enable-arch=*)    a=`echo $i | sed 's/[-a-zA-Z0-9]*=//' | tr , ' '`
                        ARCHLIST="$ARCHLIST $a" ;;
    --host=*)           HOST=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
    --mandir=*)         MANDIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
    --prefix=*)         DIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
    --libdir=*)         LIBDIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
    -q)			;; # ignored
    --shared)           LIBTYPE=dynamic ;;
    --static)           LIBTYPE=static
                        SYSLIBS=dynamic ;;
    --static_only)      LIBTYPE=static
		        SYSLIBS=static ;;
    --without-cygwin)   NOCYGWIN=yes ;;
    --without-netfiles) NETLIB=none ;;
    --with-libcurl)     NETLIB=libcurl ;;
    --without-flac)     FLAC=0 ;;
    --with-flac)        FLAC=1 ;;
    --with-flac=*)      dir=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
                        LIBFLAC_LIBS="-L$dir/lib -lFLAC"
                        LIBFLAC_CFLAGS="-I$dir/include"
                        FLAC=1 ;;
    --without-xview)    WAVE=0 ;;
    --with-xview=*)     OWHOME=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
			WAVE=1 ;;
    *)                  cat <<EOF
usage: $0 [options]
Options:
    --dynamic           make a shared (dynamically linkable) WFDB library
                         if possible [default]
    --help              print this message
    --interactive       ask about library type and installation directories
    -m32                on 64-bit Linux, force compilation in 32-bit mode
    --mandir=MANDIR     install man pages in MANDIR
    --prefix=PREFIX     install files in PREFIX [default: $DIR]
    --shared            (same as --dynamic)
    --static            make a static WFDB library (do not make a shared
                         library even if possible)
    --static_only       link WFDB applications to static libraries only
                         (assumes --static;  compilation may fail if any
	                 necessary libraries are available as shared libraries
		         only)
    --without-cygwin    on Cygwin, compile binaries that do not link to the
                         Cygwin DLL. WAVE will not be built.
    --without-netfiles  disable NETFILES even if libcurl is available
    --with-libcurl      enable NETFILES via libcurl [default]
    --without-flac      disable FLAC compressed signal support
    --with-flac=PREFIX  use FLAC libraries and headers installed in PREFIX
    --without-xview     disable WAVE even if XView is available
    --with-xview=PREFIX use XView libraries and headers installed in PREFIX
EOF
                        exit 1 ;;
  esac
done

# If cross-compiling, don't search for libraries automatically; only
# use curl and/or xview if specified on the command line.
if [ "x$HOST" != "x" ]
then
    if [ "x$NETLIB" = "xunknown" ]
    then
        NETLIB=none
    fi
    if [ "x$WAVE" = "xunknown" ]
    then
        WAVE=0
    fi
fi

echo "Checking the operating system type ..."
case x$HOST in
 x)        MACHINE=`uname -m | tr -d " "`
           KERNEL=`uname -s | tr -d " "`
           ;;
 x*-*-*)   MACHINE=`echo $HOST | cut -d- -f1`
           KERNEL=`echo $HOST | cut -d- -f3-`
           ;;
 x*-*)     MACHINE=`echo $HOST | cut -d- -f1`
           KERNEL=`echo $HOST | cut -d- -f2-`
           ;;
 x*)       MACHINE=unknown
           KERNEL=$HOST
           ;;
esac
ARCH=$MACHINE-$KERNEL
case `echo $KERNEL | tr A-Z a-z` in
  linux*)    case $MACHINE in
	        x86_64) OS=Linux-64 ;;
                *) OS=Linux ;;
             esac ;;
  freebsd*)  OS=FreeBSD ;;
  solaris*)  OS=Solaris ;;
  sunos*)    OS=Solaris ;;
  hp-ux*)    OS=HPUX ;;
  cygwin*)   if [ "x$NOCYGWIN" = "xyes" ]
             then
	         OS=mingw-compat
		 T=`echo $ARCH | sed s/CYGWIN/MINGW/`
		 ARCH=$T
             else
	         OS=cygwin
             fi ;;
  mingw*)    OS=mingw
             T=`echo $ARCH | sed s/CYGWIN/MINGW/`
             ARCH=$T ;;
  darwin*)   OS=Darwin ;;
  *)         OS=generic ;;
esac
echo "Configuring the WFDB software package for $OS."

SRCDIR="`pwd`"
LIB=lib
cd conf

echo "Checking the echo command ..."
echo -n >echo.out
if [ -s echo.out ]
then
ln -sf prompt-c prompt
else
ln -sf prompt-n prompt
fi
rm echo.out

if [ -x "`command -v /bin/sh`" ]
then
    which=./which-c
else
    which=./which-w
fi

PACKAGE=`basename "$SRCDIR"`
VERSION=
if [ -e ../.git ]
then
    ./prompt "Checking the package version number ..."
    VERSION=`cd ..; git --git-dir=.git describe --dirty 2>conf/gitver.t1`
    rm -f gitver.t1
    if [ "x$VERSION" = "x" ]
    then
       echo "unknown"
    else
       echo "$VERSION"
    fi
fi
if [ "x$VERSION" = "x" ]
then
    VERSION=`echo "$PACKAGE" | sed s/^wfdb-//`
fi
MAJOR=
MINOR=
RELEASE=
VNUM=`echo "$VERSION" | sed 's/[^0-9.].*//'`
case $VNUM in
 *.*.*) MAJOR=`echo $VNUM | cut -d . -f 1`
	MINOR=`echo $VNUM | cut -d . -f 2`
	RELEASE=`echo $VNUM | cut -d . -f 3` ;;
 *)     ./prompt "Major version number: "; read MAJOR
        ./prompt "Minor version number: "; read MINOR
        ./prompt "Release number: "; read RELEASE
        VERSION=$MAJOR.$MINOR.$RELEASE ;;
esac

if [ "x$MAJOR" = "x" ]; then MAJOR=0; fi
if [ "x$MINOR" = "x" ]; then MINOR=0; fi
if [ "x$RELEASE" = "x" ]; then RELEASE=0; fi

sed s/VMAJ/$MAJOR/ <version.def | sed s/VMIN/$MINOR/ | \
 sed s/VREL/$RELEASE/ | sed "s/VTAG/$VERSION/" >site.def
echo "# Definitions generated by 'configure'" >>site.def
echo >>site.def
echo "PACKAGE = $PACKAGE" >>site.def
echo "SRCDIR = \"$SRCDIR\"" >>site.def

if [ "x$SOURCE_DATE_EPOCH" = "x" ]
then
    date=date
else
    if date -d @0 >date.t1 2>date.t1
    then
        date="date -u -d @$SOURCE_DATE_EPOCH"
    else
        date="date -u -r $SOURCE_DATE_EPOCH"
    fi
    bd=`$date '+"%b %e %Y"'`
    echo "BUILD_DATE_FLAGS = -DWFDB_BUILD_DATE='$bd'" >>site.def
    rm -f date.t1
fi
echo LONGDATE = `$date "+%e %B %Y"` >>site.def
echo SHORTDATE = `$date "+%B %Y" | tr a-z A-Z` >>site.def
echo YEAR = `$date "+%Y"` >>site.def
echo "ARCH = $ARCH" >>site.def

if [ "x$HOST" = "x" ]
then
    echo "BUILD_CC = \$(CC)" >> site.def
else
    echo "BUILD_CC = cc" >> site.def
fi

echo "# _____________________________________________________________________________" >>site.def
echo >>site.def

rm -f site-slib.def
touch site-slib.def

case $OS in
  Linux)
	cat site.def linux-slib.def >site-slib.def
	cat linux.def >>site.def ;;
  Linux-64)
	if [ "x$MFLAGS" = "x-m32" ]
	then
	    OS=Linux
	    cat site.def linux-slib.def | \
		sed "s+MFLAGS =+MFLAGS = $MFLAGS+" >site-slib.def
	    cat linux.def | \
		sed "s+MFLAGS =+MFLAGS = $MFLAGS+" >>site.def
	else
	    LIB=lib64
            WAVE=0
	    cat site.def linux-slib.def >site-slib.def
	    cat linux.def >>site.def
	fi ;;
  FreeBSD)
	cat site.def freebsd-slib.def >site-slib.def
	cat freebsd.def >>site.def ;;
  Solaris)
	cat site.def solaris-slib.def >site-slib.def
	cat solaris.def >>site.def ;;
  HP-UX)
	cat site.def hpux-slib.def >site-slib.def
	cat hpux.def >>site.def ;;
  cygwin)
	LIB=bin
	cat site.def cygwin-slib.def >site-slib.def
	cat cygwin.def >>site.def ;;
  mingw)
	LIB=bin
	WAVE=0
	sed 's/NOCYGWIN//' site.def mingw-slib.def >site-slib.def
	sed 's/NOCYGWIN//' mingw.def >>site.def
        ( cd ../checkpkg; ./dosify ) ;;
  mingw-compat)
	LIB=bin
	OS=mingw
	WAVE=0
	sed 's/NOCYGWIN/-mno-cygwin/' site.def mingw-slib.def >site-slib.def
	sed 's/NOCYGWIN/-mno-cygwin/' mingw.def >>site.def ;;
  Darwin)
	echo "It is normal for Mac OS X to be recognized as Darwin."
	LMFLAGS=$MFLAGS
	WMFLAGS=$MFLAGS
	for a in $ARCHLIST
	do
	    LMFLAGS="$LMFLAGS -arch $a"
	    case $a in
	      i386|ppc) WMFLAGS="$WMFLAGS -arch $a" ;;
	    esac
	done
	if [ $WAVE = unknown ] && [ "x$WMFLAGS" = "x$MFLAGS" ]
	then
            WAVE=0
	fi
	cat site.def darwin-slib.def | \
	    sed "s+^MFLAGS =+MFLAGS = $LMFLAGS+" >site-slib.def
	cat darwin.def | \
	    sed "s+^MFLAGS =+MFLAGS = $LMFLAGS+;s+^WMFLAGS =+WMFLAGS = $WMFLAGS+" >>site.def ;;
  *)    OS=generic
	cat site.def generic-slib.def >site-slib.def
	cat generic.def >>site.def
	echo "Using the generic configuration, which may need to be customized"
	echo "for your operating system.  'configure' will offer suggestions"
	echo "for customization after it completes the generic configuration."
	;;
esac

if [ -s site-slib.def ]
then
  if [ x$LIBTYPE = x ]
  then
    echo
    echo "The WFDB library may be compiled as a static library or as a"
    echo "dynamically loaded (shared) library (the default).  Type S for a"
    ./prompt "static library, or D for a dynamically loaded library:"
    read LIBTYPE
  fi
else
    LIBTYPE=static
fi

case x$LIBTYPE in
  xS*|xs*) rm -f site-slib.def
           touch site-slib.def
           LIBTYPE=static ;;
        *) LIBTYPE=dynamic ;;
esac

if [ $LIBTYPE = static ]
then
    if [ x$SYSLIBS = x ]
    then
	echo
	echo "You may link the WFDB applications to dynamically loaded"
	echo "system libraries (such as the standard C library) to"
	echo "save disk space and for faster loading even while using"
	echo "the static WFDB library, or you may link them to static"
	echo "libraries only, which will make them easier to copy to"
	echo "other systems.  Note that choosing to link to static"
	echo "libraries only may cause compilation to fail if your"
	echo "system does not have a complete set of static libraries."
	echo "Type S to link to static libraries only, or D to link to"
	./prompt "dynamically loaded libraries where available:"
	read SYSLIBS
    fi
    case x$SYSLIBS in
        xS*|xs*) sed "s/LDFLAGS = -L/LDFLAGS = -static -L/" <site.def >site.tmp
		 mv site.tmp site.def
		 echo "Applications will be linked with static libraries only."
		 SYSLIBS=static
		 ;;
	      *) SYSLIBS=dynamic ;;
    esac
else
    SYSLIBS=dynamic

    dynamic_ldflags=`grep '^LDFLAGS =' site-slib.def | sed 's/LDFLAGS = *//'`
    if [ "x$dynamic_ldflags" != "x" ]; then
        sed "s|^LDFLAGS =.*|LDFLAGS = $dynamic_ldflags|" <site.def >site.tmp
        mv site.tmp site.def
    fi
fi

echo
./prompt "Looking for the C compiler ..."
if [ "x$HOST" != "x" ]
then
    CROSS_COMPILE=$HOST-
fi
WCC=`$which ${CROSS_COMPILE}gcc`
if ! [ -x "$WCC" ]
then
    WCC=`$which ${CROSS_COMPILE}cc`
    if ! [ -x "$WCC" ]
    then
        echo "not found"
	echo
        echo "The WFDB software cannot be compiled, because there does not"
        echo "appear to be a C compiler installed on this system.  Please"
        echo "install one, be sure that it is in your PATH, and that it is"
	echo "accessible as either '${CROSS_COMPILE}cc' or '${CROSS_COMPILE}gcc', then run ./configure again."
	cd ..
	exit 1
    else
	CC=${CROSS_COMPILE}cc
	wflags=
    fi
else
    CC=${CROSS_COMPILE}gcc
    wflags="-Wno-implicit -Wformat "
fi
echo "$CC"
sed "s|CC = gcc|CC = $CC|" <site.def >site.tmp
sed "s|^CFLAGS = |CFLAGS = $wflags|" <site.tmp >site.def
sed "s|CC = gcc|CC = $CC|" <site-slib.def >site.tmp
sed "s|^CFLAGS = |CFLAGS = $wflags|" <site.tmp >site-slib.def
rm -f wcc.t1 wcc.t2 site.tmp

./prompt "Looking for the command to strip debugging metadata ..."
WSTRIP=`$which ${CROSS_COMPILE}strip`
if ! [ -x "$WSTRIP" ]
then
    STRIP=:
    echo "not found"
else
    STRIP=${CROSS_COMPILE}strip
    echo "$STRIP"
fi
if [ "x$STRIP" != "xstrip" ]
then
    sed "s|^STRIP = .*|STRIP = $STRIP|" <site.def >site.tmp
    mv site.tmp site.def
    sed "s|^STRIP = .*|STRIP = $STRIP|" <site-slib.def >site.tmp
    mv site.tmp site-slib.def
fi

if [ $LIBTYPE = static ] && [ "x${CROSS_COMPILE}" != "x" ]
then
    sed "s|^RANLIB = ranlib|RANLIB = ${CROSS_COMPILE}ranlib|" <site.def >site.tmp
    mv site.tmp site.def
fi

if [ x$DIR = x ]
then
    echo
    echo "Where do you wish to install the WFDB Software Package?"
    echo "It will be installed in subdirectories of WFDBROOT (by default,"
    echo "WFDBROOT is /usr, so that files are installed in /usr/bin,"
    echo "/usr/include, /usr/$LIB, etc.).  Other reasonable choices for"
    echo "WFDBROOT are /usr/local, /opt, or your home directory ($HOME)."
    echo "The value of WFDBROOT must be a full pathname (beginning with '/',"
    echo "but without a '/' at the end).  If the subdirectories (bin, include,"
    echo "lib, ...) of WFDBROOT don't exist, they will be created as necessary."
    echo
    DIR=
    while [ x$DIR = x ]
    do
        ./prompt "Choose a location, or press <Enter> to install in /usr:"
        read DIR
        case x$DIR in
            x/usr) ;;
                x) DIR=/usr ;;
              x*/) DIR=
                   echo "Please type the path again, omitting the '/' at the end." ;;
              x/*) ;;
               x*) DIR=
                   echo "Please enter an absolute pathname, beginning with '/'." ;;
        esac
    done
fi

case $DIR in
  /usr) ;;
    /*) sed "s+^WFDBROOT = /usr+WFDBROOT = $DIR+" <site.def >site.tmp
        mv site.tmp site.def
        sed "s+^WFDBROOT = /usr+WFDBROOT = $DIR+" <site-slib.def \
         >site.tmp
        mv site.tmp site-slib.def
esac

echo  "The WFDB software will be installed in '$DIR'."

if [ x$LIBDIR = xunknown ]
then
    case $OS in
      Linux*)
            nativelibdirs=`$CC -print-search-dirs | sed -n '/^libraries:/{s/^[^=]*=//; s/:/\n/g; p}' | sed ':LP; s+/[^/]*/\.\./+/+; tLP; s+/$++'`
            if [ "$MACHINE" = "x86_64" ] && echo "$nativelibdirs" | grep -q "^$DIR/lib64"; then
                if [ "x$MFLAGS" = "x-m32" ]; then
                    LIB=lib
                else
                    LIB=lib64
                fi
            else
                if [ "x$MFLAGS" = "x-m32" ]; then
                    LIB=lib32
                else
                    LIB=lib
                fi
            fi ;;
    esac
    LIBDIR="\$(WFDBROOT)/$LIB"
fi
sed "s+^LIBDIR = .*+LIBDIR = $LIBDIR+" <site.def >site.tmp
mv site.tmp site.def
sed "s+^LIBDIR = .*+LIBDIR = $LIBDIR+" <site-slib.def >site.tmp
mv site.tmp site-slib.def
xlibdir=`echo "$LIBDIR" | sed 's+$(WFDBROOT)+'"$DIR"+`

MANTMP=`grep "MANDIR =" site.def |sed 's+$(WFDBROOT)/++' |cut -d " " -f 3`
MANDEF=$DIR/$MANTMP
if [ x$MANDIR = xunknown ]
then
   MANDIR=$MANDEF
fi

if [ x$MANDIR = x ]
then
    echo
    echo "Where do you wish to install the manual pages?"
    echo "They will be installed in subdirectories of MANDIR (by default,"
    echo "MANDIR is '$MANDEF').  If you install them in a non-standard"
    echo "directory, you will need to add that directory to your MANPATH."
    echo "The value of MANDIR must be a full pathname (beginning with '/',"
    echo "but without a '/' at the end).  If the subdirectories (man1, man3,"
    echo "man5, ...) of MANDIR don't exist, they will be created as necessary."
    echo
    MANDIR=
    while [ x$MANDIR = x ]
    do
       ./prompt "Choose a location, or press <Enter> to install in $MANDEF:"
        read MANDIR
        case x$MANDIR in
            x/usr) ;;
                x) MANDIR=$MANDEF ;;
              x*/) MANDIR=
                   echo "Please type the path again, omitting the '/' at the end." ;;
              x/*) ;;
               x*) MANDIR=
                   echo "Please enter an absolute pathname, beginning with '/'." ;;
        esac
    done
fi

if [ "$MANDIR" != "$MANDEF" ]
then
    sed "s+^MANDIR = $MANDEF+MANDIR = $MANDIR+" <site.def >site.tmp
    mv site.tmp site.def
fi

echo  "The manual pages will be installed in '$MANDIR'."
echo

# Search for NETLIB if not specified on the command line
if [ x$NETLIB = xunknown ]
    then
    ./prompt "Looking for libcurl ..."
    WHICH=`$which curl-config`
    if ! [ -x "$WHICH" ]
	then
	echo "not found"
	echo "The WFDB software will be compiled without NETFILES"
	echo "access, because libcurl does not appear to be"
	echo "installed on this system.  To add NETFILES access,"
	echo "install libcurl and run ./configure again."
	NETLIB=none
    else
	echo "found"
	echo "The WFDB software will be compiled with NETFILES access"
	echo "using libcurl."
	NETLIB=libcurl
    fi
fi

case $NETLIB in
  libcurl) LC="\`curl-config --cflags\`"
	   LL="\`curl-config --libs\`"
	   NETFILES=1
	   NETFILES_LIBCURL=1
	   VIANF=" via libcurl"
	   WITHNF=with
	   ;;
  none)    LC=""
	   LL=""
	   NETFILES=0
	   NETFILES_LIBCURL=0
	   VIANF=""
	   WITHNF=without
	   ;;
esac
echo "NETFILES=$NETFILES" >../config.cache
echo "NETFILES_LIBCURL=$NETFILES_LIBCURL" >>../config.cache

# Search for libFLAC
if [ $FLAC != 0 ] && [ "x$LIBFLAC_LIBS" = "x" ]
then
    ./prompt "Looking for libFLAC ..."
    PC=${CROSS_COMPILE}pkg-config
    WHICH=`$which "$PC"`
    if [ -x "$WHICH" ]
    then
        if $PC --exists flac
        then
            LIBFLAC_CFLAGS="\`$PC --cflags flac\`"
            if [ x$SYSLIBS = xstatic ]
            then
                LIBFLAC_LIBS="\`$PC --libs --static flac\`"
            else
                LIBFLAC_LIBS="\`$PC --libs flac\`"
            fi
        fi
    elif [ "x$HOST" = "x" ]
    then
        for dir in /usr/local /usr
        do
            if [ -f "$dir/include/FLAC/stream_encoder.h" ]
            then
                LIBFLAC_CFLAGS="-I$dir/include"
                LIBFLAC_LIBS="-L$dir/lib -lFLAC"
                break
            fi
        done
    fi
    if [ "x$LIBFLAC_LIBS" = "x" ]
    then
        echo "not found"
        echo
        if [ -x "$WHICH" ]
        then
            $PC --print-errors flac
            echo
        elif [ "x$HOST" != "x" ]
        then
            echo "$PC was not found."
            echo "When cross-compiling, you may need to specify"
            echo "./configure --with-flac=PREFIX"
            echo
        fi
        if [ $FLAC = 1 ]
        then
            exit 1
        fi
        echo "The WFDB software will be compiled without support for"
        echo "compressed signal files.  To add FLAC support, install"
        echo "libFLAC and run ./configure again."
        FLAC=0
    else
        echo "found"
        echo "The WFDB software will be compiled with support for"
        echo "compressed signal files using libFLAC."
        FLAC=1
    fi
fi
if [ $FLAC = 1 ]
then
    sed "s/^CCDEFS = /CCDEFS = -DWFDB_FLAC_SUPPORT /" <site.def >site.tmp
    mv site.tmp site.def
    sed "s/^CCDEFS = /CCDEFS = -DWFDB_FLAC_SUPPORT /" <site-slib.def >site.tmp
    mv site.tmp site-slib.def
fi

sed "s/WFDB_NETFILES 1/WFDB_NETFILES $NETFILES/" < ../lib/wfdb.h0 | \
    sed "s/WFDBMAJOR/$MAJOR/" | \
    sed "s/WFDBMINOR/$MINOR/" | \
    sed "s/WFDBRELEASE/$RELEASE/" | \
    sed "s/WFDB_NETFILES_LIBCURL 1/WFDB_NETFILES_LIBCURL $NETFILES_LIBCURL/" \
      >../lib/wfdb.h

sed "s/^LC =/LC = $LC/" <site.def | sed "s/^LL =/LL = $LL/" | \
    sed "s|^LIBFLAC_CFLAGS = .*|LIBFLAC_CFLAGS = $LIBFLAC_CFLAGS|" | \
    sed "s|^LIBFLAC_LIBS = .*|LIBFLAC_LIBS = $LIBFLAC_LIBS|" >site.tmp
mv site.tmp site.def

sed "s/^LC =/LC = $LC/" <site-slib.def | sed "s/^LL =/LL = $LL/" | \
    sed "s|^LIBFLAC_CFLAGS = .*|LIBFLAC_CFLAGS = $LIBFLAC_CFLAGS|" | \
    sed "s|^LIBFLAC_LIBS = .*|LIBFLAC_LIBS = $LIBFLAC_LIBS|" >site.tmp
mv site.tmp site-slib.def

cd ..
echo
echo "Creating Makefile in lib ..."
if [ -s conf/site-slib.def ]
    then
    cat lib/Makefile.top conf/site-slib.def lib/Makefile.tpl >lib/Makefile
else
    cat lib/Makefile.top conf/site.def lib/Makefile.tpl >lib/Makefile
fi
for D in app checkpkg convert data doc doc/wag-src doc/wpg-src doc/wug-src \
         examples fortran psd wave waverc xml .
  do
  if [ -s $D/Makefile.top ]
      then
      echo "Creating Makefile in $D ..."
      cat $D/Makefile.top conf/site.def $D/Makefile.tpl >$D/Makefile
  fi
done

# Create output directories for documentation
for D in doc/wag doc/wpg doc/wug
do
    [ -d $D ] || mkdir $D
done

echo rm conf/site.def conf/site-slib.def

if [ "x$WAVE" = "xunknown" ]
    then
    echo
    conf/prompt "Looking for the XView libraries ..."
    TEXTEDIT=`cd conf; $which textedit`
    if [ -d $OWHOME ]
    then
	WAVE=1;
    elif [ -d /usr/local/openwin ]
    then
	WAVE=1;
	OWHOME=/usr/local/openwin
    elif [ -d /opt/openwin ]
    then
	WAVE=1;
	OWHOME=/opt/openwin
    elif [ -d /usr/include/xview ]
    then
	WAVE=1;
	OWHOME=/usr
    elif ! [ -x "$TEXTEDIT" ]
    then
	WAVE=0;
    else
	WAVE=1;
	TEDIR=`dirname $TEXTEDIT`;
	OWHOME=`dirname $TEDIR`;
    fi
    if [ $WAVE = 0 ]
	then
	echo "not found"
	echo "WAVE will not be compiled, because the XView libraries do not"
	echo "appear to be installed on this system."
	echo "To compile WAVE, install XView, add the directory containing the"
	echo "XView textedit application to your PATH, and run ./configure again."
    else
	echo "found"
    fi
fi

if [ "x$WAVE" = "x1" ]
    then
    sed "s+/usr/openwin+$OWHOME+" <wave/Makefile >tmp.$$
    mv tmp.$$ wave/Makefile
    WAVECOMP="WAVE will be compiled and installed in '$DIR/bin'."
    echo "WAVE=1" >>config.cache
else
    cp -p wave/nomake wave/Makefile
    cp -p wave/nomake waverc/Makefile
    echo "WAVE=0" >>config.cache
    WAVECOMP="WAVE will not be compiled."
fi

# Clean up old *.o files in lib, to avoid possibly using binaries intended
# for a shared library in a static library or vice versa.
rm -f lib/*.o

if [ $DIR != "/usr" -a  $LIBTYPE = dynamic ]
    then
    cat <<EOF

IMPORTANT: You have chosen to build a dynamic (shared) WFDB library in
a directory, $DIR/$LIB, that is not normally searched for such
libraries.  In order to use the applications that will be compiled
with this library, it may be necessary to add this directory to your
LD_LIBRARY_PATH.  If your shell is csh or a variant, do this by
typing:
EOF
    if [ "x$LD_LIBRARY_PATH" = x ]
	then
	echo "  setenv LD_LIBRARY_PATH $DIR/$LIB"
	echo "Otherwise, do this by typing:"
	echo "  LD_LIBRARY_PATH=$DIR/$LIB"
	echo "  export LD_LIBRARY_PATH"
    else
	echo "  setenv LD_LIBRARY_PATH \${LD_LIBRARY_PATH}:$DIR/$LIB"
	echo "Otherwise, do this by typing:"
	echo "  LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:$DIR/$LIB"
	echo "  export LD_LIBRARY_PATH"
    fi
fi

if [ $OS = generic ]
    then
    cat <<EOF

No specific configuration information is available for your operating
system.  Please try compiling using the generic Makefiles that have
been generated by this configuration utility.  If there are problems,
it may be possible to solve them by customizing conf/generic.def (and
conf/generic-slib.def if you are attempting to compile a shared WFDB
library).  Run ./configure again after making any necessary changes to
these files.  Please send reports of success or failure, together with
the output of the command 'uname -a', and copies of any files you have
changed, to:
             wfdb@physionet.org
EOF

fi

if [ "x$MFLAGS" != x ]
    then
    CC="$CC $MFLAGS"
fi

cat <<EOF

Summary:

$PACKAGE-$OS is now ready to be compiled using '$CC'.
The WFDB library will be compiled as a $LIBTYPE library $WITHNF NETFILES
 access${VIANF}, and it will be installed in '$xlibdir'.
The WFDB library .h files will be installed in '$DIR/include/wfdb'.
The WFDB applications will be linked to $SYSLIBS system libraries, and
 they will be installed in '$DIR/bin'.
$WAVECOMP
Manual pages will be installed in subdirectories of '$MANDIR'.
Sample data files will be installed in '$DIR/database', which
 will be included in the default WFDB path.

If you need to compile a different WFDB library type, or install into different
directories, rerun this script with its "-i" (interactive) option:
      ./configure -i
Other options can be viewed by rerunning this script with its "-h" option:
      ./configure -h

WFDB software configuration is complete.
Now run 'make' to compile and test, followed by 'make install' to recompile
and install the software, man pages, and example data.  Finally, run
'make check' to verify that the installation is complete and successful.

EOF