configure.in at [1f6689ebb8]
Not logged in

File configure.in artifact 19e43b3702 part of check-in 1f6689ebb8


# -*- autoconf -*-
# FILE: "/disk01/home/joze/src/tclreadline/configure.in"
# LAST MODIFICATION: "Tue Sep 14 11:23:46 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# johannes@zellner.org
# http://www.zellner.org/tclreadline/
#
# ================================================================== */  

dnl	This file is an input file used by the GNU "autoconf" program to
dnl	generate the file "configure", which is run during Tk installation
dnl	to configure the system for the local environment.

AC_REVISION($Revision$)

AC_INIT(tclreadline.c)
AC_CONFIG_HEADER(config.h)

TCLREADLINE_MAJOR_VERSION=0
TCLREADLINE_MINOR_VERSION=9
TCLREADLINE_PATCHLEVEL=3
TCLREADLINE_VERSION=$TCLREADLINE_MAJOR_VERSION.$TCLREADLINE_MINOR_VERSION
TCLREADLINE_PATCHLEVEL_STR=${TCLREADLINE_VERSION}.${TCLREADLINE_PATCHLEVEL}
VERSION=$TCLREADLINE_VERSION


AC_PREREQ(2.13)
AC_CONFIG_AUX_DIR(./aux)
AC_CANONICAL_HOST


TCLREADLINE_LPATH=`echo $LD_LIBRARY_PATH $LD_RUN_PATH $LPATH | sed 's/:/ /g'`
TCLREADLINE_LPATH="$TCLREADLINE_LPATH /lib /usr/lib /usr/local/lib"


#--------------------------------------------------------------------
#   See if there was a command-line option for where Tcl is;  if
#   not, search for Tcl.
#--------------------------------------------------------------------

AC_ARG_WITH(
    tcl,
    [  --with-tcl=DIR          where to look for tclConfig.sh],
    tcl_search=$withval,
    tcl_search=""
)

AC_MSG_CHECKING([which tclConfig.sh to use])
TCL_LIB_DIR=""
for dir in $tcl_search /usr/lib /usr/local/lib $exec_prefix/lib /usr/local/lib/unix /opt/tcl/lib; do
    if test -r $dir/tclConfig.sh; then
        TCL_LIB_DIR=$dir
        break
    fi
done

if test -z "$TCL_LIB_DIR"; then
    AC_MSG_ERROR(Can't find Tcl libraries.  Use --with-tcl to specify the directory containing tclConfig.sh on your system.)
else
    . $TCL_LIB_DIR/tclConfig.sh
    AC_MSG_RESULT($TCL_LIB_DIR/tclConfig.sh)
    AC_MSG_CHECKING([for your tcl version])
    AC_MSG_RESULT([$TCL_VERSION, patchlevel $TCL_PATCH_LEVEL])
fi

#--------------------------------------------------------------------
#   Read in configuration information generated by Tcl for shared
#   libraries, and arrange for it to be substituted into our
#   Makefile.
#--------------------------------------------------------------------


SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
SHLIB_LD=$TCL_SHLIB_LD
if test $TCL_SHLIB_SUFFIX = ""; then
    AC_MSG_ERROR(TCL_SHLIB_SUFFIX not defined -- should be something like .so or .sl on unix.)
else
    SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
fi
DL_LIBS=$TCL_DL_LIBS
LD_FLAGS=$TCL_LD_FLAGS
SHLIB_LD_LIBS=$TCL_SHLIB_LD_LIBS
TCLREADLINE_PACKAGE_PATH=$TCL_PACKAGE_PATH


#--------------------------------------------------------------------
#   Check, if tcl_version is > 8.0
#--------------------------------------------------------------------
if test $TCL_MAJOR_VERSION -lt 8; then
    AC_MSG_ERROR(need tcl 8.0 or higher.)
fi



# -----------------------------------------------------------------------
#   Set up a new default --prefix.
# -----------------------------------------------------------------------

# this is the default anyway:
# AC_PREFIX_DEFAULT(/usr/local)

if test "${prefix}" = "NONE"; then
    prefix=$TCL_PREFIX
fi
if test "${exec_prefix}" = "NONE"; then
    exec_prefix=$TCL_EXEC_PREFIX
else
    TCLREADLINE_PACKAGE_PATH=${exec_prefix}/lib
fi

TCLREADLINE_LIBRARY=${exec_prefix}/lib/tclreadline$TCLREADLINE_VERSION


# -----------------------------------------------------------------------
#   Check for some programs here.
# -----------------------------------------------------------------------

AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_LN_S



# -----------------------------------------------------------------------
#   Prefer the compiler, which was used
#   to build tcl.
# -----------------------------------------------------------------------


AC_ARG_ENABLE(gcc, [  --enable-gcc            allow use of gcc if available],
    [gcc_ok=$enableval], [gcc_ok=no])
if test "$gcc_ok" = "yes"; then
    AC_PROG_CC
else
    CC=$TCL_CC
    AC_SUBST(CC)
fi




# -----------------------------------------------------------------------
#   checking for the preprocessor.
#   FIXME: do we need this ?
# -----------------------------------------------------------------------

AC_PROG_CPP



#--------------------------------------------------------------------
#   If this is gcc, add some extra compile flags.
#--------------------------------------------------------------------

AC_MSG_CHECKING([whether C compiler is gcc])
AC_CACHE_VAL(tclreadline_cv_prog_gcc,
    AC_EGREP_CPP(_cc_is_gcc_, [
#ifdef __GNUC__
_cc_is_gcc_
#endif
],      [tclreadline_cv_prog_gcc=yes], [tclreadline_cv_prog_gcc=no]))
AC_MSG_RESULT([$tclreadline_cv_prog_gcc])

if test -z "$CFLAGS" ; then
    CFLAGS=$TCL_CFLAGS_OPTIMIZE
fi
if test "$tclreadline_cv_prog_gcc" = "yes" ; then
    CFLAGS="$CFLAGS -Wshadow -Wtraditional -Wall"
fi

AC_MSG_CHECKING([default compiler flags])
AC_ARG_WITH(cflags, [  --with-cflags=FLAGS     set compiler flags to FLAGS],
    [CFLAGS="$with_cflags"])

AC_MSG_RESULT([$CFLAGS])

if test "$TCL_CC" != "$CC" ; then
    echo ""
    echo "WARNING:  Compiler is $CC but Tcl was compiled with $TCL_CC"
    echo ""
fi

#--------------------------------------------------------------------
#   The statements below define a collection of symbols related to
#   building libtclreadline as a shared library instead of a static library.
#   (static is not implemented yet anyway).
#--------------------------------------------------------------------

AC_ARG_ENABLE(shared,
    [  --disable-shared        don't build libtclreadline as a shared library
                          (not implemented -- probably never).],
    [ok=$enableval], [ok=yes])
if test "$ok" = "yes"; then
    if test ${TCL_SHARED_BUILD} = 0; then
        AC_MSG_ERROR(Tcl was not built with --enable-shared, so you can't use shared libraries.)
    fi
    SHLIB_CFLAGS="${SHLIB_CFLAGS}"
    eval "TCLREADLINE_LIB_FILE=libtclreadline${VERSION}${SHLIB_SUFFIX}"
    TCLREADLINE_PKG_FILE="[[file join [file dirname \$dir] ${TCLREADLINE_LIB_FILE}]]"
    MAKE_LIB="\$(SHLIB_LD) -o ${TCLREADLINE_LIB_FILE} \$(OBJS) ${SHLIB_LD_LIBS}"
    RANLIB=":"
else
    AC_MSG_ERROR(non-shared not implemented yet. (probably never))
    SHLIB_CFLAGS=""
    eval "TCLREADLINE_LIB_FILE=libtclreadline${VERSION}.a"
    TCLREADLINE_PKG_FILE=""
    MAKE_LIB="ar cr ${TCLREADLINE_LIB_FILE} \${OBJS}"
fi

# Note:  in the following variable, it's important to use the absolute
# path name of the Tcl directory rather than "..":  this is because
# AIX remembers this path and will attempt to use it at run-time to look
# up the Tcl library.

if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
    TCLREADLINE_BUILD_LIB_SPEC="-L`pwd` -ltclreadline${VERSION}"
    TCLREADLINE_LIB_SPEC="-L${TCLREADLINE_LIBRARY} -ltclreadline${VERSION}"
else
    TCLREADLINE_BUILD_LIB_SPEC="-L`pwd` -ltclreadline`echo ${VERSION} | tr -d .`"
    TCLREADLINE_LIB_SPEC="-L${TCLREADLINE_LIBRARY} -ltclreadline`echo ${VERSION} | tr -d .`"
fi




# HEADER CHECKS
#
AC_HEADER_STDC


#--------------------------------------------------------------------
#   Check for tcl.h
#--------------------------------------------------------------------

AC_ARG_WITH(tcl-includes,
            [  --with-tcl-includes=DIR where to look for tcl.h],
            tcl_includes=$withval, tcl_includes=$prefix/include)

AC_MSG_CHECKING([where to look for tcl.h])
TCL_INCLUDE_DIR=""
for dir in $tcl_includes $prefix/include/ /usr/include; do
    if test -r $dir/tcl.h; then
        TCL_INCLUDE_DIR=$dir
        break
    fi
done

if test -z "$TCL_INCLUDE_DIR"; then
    AC_MSG_ERROR([
  Can't find tcl.h.  Use --with-tcl-includes to specify the directory
  containing tcl.h on your system.])
else
    AC_MSG_RESULT($TCL_INCLUDE_DIR/tcl.h)
fi



#--------------------------------------------------------------------
#   Check for readline.h
#--------------------------------------------------------------------

AC_ARG_WITH(readline-includes,
            [  --with-readline-includes=DIR
                          readline include files in DIR],
            rl_includes=$withval, rl_includes=$prefix/include)

AC_MSG_CHECKING([where to look for readline.h])
READLINE_INCLUDE_DIR=""
for dir in $rl_includes $prefix/include/readline /usr/include/readline /usr/include /usr/local/include/readline /usr/local/include; do
    if test -r $dir/readline.h; then
        READLINE_INCLUDE_DIR=$dir
        break
    fi
done

if test -z "$READLINE_INCLUDE_DIR"; then
    AC_MSG_ERROR([
  Can't find readline.h.
  Use --with-readline-includes to specify the directory
  containing readline.h on your system.])
else
    AC_MSG_RESULT($READLINE_INCLUDE_DIR/readline.h)
fi



#--------------------------------------------------------------------
#   Check for libreadline
#--------------------------------------------------------------------

AC_ARG_WITH(readline-library,
            [  --with-readline-library=DIR
                          readline library files in DIR],
            rl_library=$withval, rl_library=$exec_prefix/lib)

AC_MSG_CHECKING([where to look for libreadline$SHLIB_SUFFIX])
READLINE_LIB_DIR=""
READLINE_VERSION_SUFFIX=""
for dir in $rl_library $TCLREADLINE_LPATH $prefix/lib/readline; do
    if test -r $dir/libreadline$SHLIB_SUFFIX; then
        READLINE_LIB_DIR=$dir
        break
    fi
    if test -r $dir/libreadline$SHLIB_SUFFIX.3.0; then
        READLINE_VERSION_SUFFIX=".3.0"
        READLINE_LIB_DIR=$dir
        break
    fi
    if test -r $dir/libreadline$SHLIB_SUFFIX.4.0; then
        READLINE_VERSION_SUFFIX=".4.0"
        READLINE_LIB_DIR=$dir
        break
    fi
done

if test -z "$READLINE_LIB_DIR"; then
    AC_MSG_ERROR([
  Can't find libreadline$SHLIB_SUFFIX.
  Use --with-readline-library to specify the directory
  containing libreadline$SHLIB_SUFFIX on your system.])
else
    AC_MSG_RESULT(${READLINE_LIB_DIR}/libreadline${SHLIB_SUFFIX}${READLINE_VERSION_SUFFIX})
fi



# ---
# check, if curses or termcap is already
# linked with libreadline. (on newer Linux
# systems it is.)
# ---

# TERM_LIB=""
# AC_CHECK_LIB(readline, tputs, termcaps=yes, termcaps=no)
termcaps=no
if test "$termcaps" = "no"; then

    # ---
    # nope. tputs() is unresolved in libreadline, so
    # check if we want libcurses or libtermcap.
    # ---

    AC_ARG_WITH(
        termcap, 
        [  --with-termcap          use termcap library instead of curses.],
        TERM_LIB="termcap",
        TERM_LIB="curses"
    )
    AC_CHECK_LIB($TERM_LIB, tputs, tputs_ok=yes, tputs_ok=no)
    if test "$tputs_ok" = "no"; then
        AC_MSG_ERROR(tputs() not found in lib$TERM_LIB.)
    else
        TERM_LIB=-l$TERM_LIB
    fi
fi


#--------------------------------------------------------------------
#   Check for appropriate version of gnu readline
#   (older versions of gnu readline don't have
#    rl_callback_read_char ()).
#--------------------------------------------------------------------

save=$LIBS
LIBS="-L$READLINE_LIB_DIR -lreadline $TERM_LIB"
alternate=no
AC_CHECK_FUNC(
    rl_callback_read_char, alternate=yes, alternate=no
)
if test "$alternate" = "no"; then
    AC_MSG_ERROR(alternate interface not supported by this readline version.)
fi


# check for readline's (macro.c) private variable
# _rl_executing_macro.

AC_MSG_CHECKING([for _rl_executing_macro in -lreadline])
AC_TRY_LINK(,[
extern char* _rl_executing_macro;
int main () {
    _rl_executing_macro = (char*) 0;
    return 0;
}],
    AC_MSG_RESULT(yes); AC_DEFINE_UNQUOTED(EXECUTING_MACRO_HACK, 1),
    AC_MSG_RESULT(no))


AC_MSG_CHECKING([for the readline version number])
AC_TRY_RUN([
#include <stdio.h>
int main () {
    FILE *fp = fopen("conftestversion", "w");
    extern char *rl_library_version;
    fprintf(fp, "%s", rl_library_version);
    close(fp);
    return 0;
}],
    READLINE_VERSION=`cat conftestversion`
    AC_MSG_RESULT($READLINE_VERSION),
    AC_MSG_RESULT(failed),
    AC_MSG_RESULT(no cross compiling))


LIBS=$LIBS



# This is a test
#AC_C_BIGENDIAN

# TODO: check for readline version
# (link testprogram with -lreadline)

AC_SUBST(TCLREADLINE_MAJOR_VERSION)
AC_SUBST(TCLREADLINE_MINOR_VERSION)
AC_SUBST(TCLREADLINE_VERSION)
AC_SUBST(TCLREADLINE_PATCHLEVEL)
AC_SUBST(TCLREADLINE_LIBRARY)
AC_SUBST(TCLREADLINE_PATCHLEVEL_STR)


AC_SUBST(TCL_LIB_DIR)
AC_SUBST(TCL_INCLUDE_DIR)
AC_SUBST(READLINE_INCLUDE_DIR)

AC_SUBST(CFLAGS)
AC_SUBST(DL_LIBS)
AC_SUBST(LD_FLAGS)
AC_SUBST(RANLIB)

AC_SUBST(MAKE_LIB)
AC_SUBST(SHLIB_CFLAGS)

AC_SUBST(SHLIB_LD)
AC_SUBST(SHLIB_LD_LIBS)

AC_SUBST(SHLIB_SUFFIX)

AC_SUBST(TERM_LIB)
AC_SUBST(READLINE_LIB_DIR)

AC_SUBST(TCLREADLINE_LIB_FILE)
AC_SUBST(TCLREADLINE_BUILD_LIB_SPEC)
AC_SUBST(TCLREADLINE_LIB_SPEC)

AC_SUBST(TCLREADLINE_LIB_DIR)
AC_SUBST(TCLREADLINE_PKG_FILE)

AC_SUBST(TCLREADLINE_PACKAGE_PATH)


AC_OUTPUT(Makefile tclreadline.h tclreadlineInit.tcl tclreadlineSetup.tcl tclreadlineConfig.sh tclreadline.n pkgIndex.tcl)


#TCL_CC='cc'
#TCL_CFLAGS_DEBUG='-g'
#TCL_CFLAGS_OPTIMIZE='-O'
#TCL_SHARED_BUILD=1
#
#TCL_PREFIX='/usr/local'
#TCL_EXEC_PREFIX='/usr/local'
#
#TCL_SHLIB_CFLAGS='-fPIC'
#TCL_SHLIB_LD='cc -shared'
#TCL_SHLIB_SUFFIX='.so'
#TCL_DL_LIBS='-ldl'
#TCL_LD_FLAGS='-rdynamic'
#TCL_LD_SEARCH_FLAGS=''
#TCL_RANLIB=':'
#TCL_PACKAGE_PATH='/usr/local/lib'