Changeset 505 for trunk/gui/tclconfig


Ignore:
Timestamp:
Aug 8, 2006 8:36:23 AM (18 years ago)
Author:
nkissebe
Message:

new location, customized TEA 3.5 tcl.m4

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/gui/tclconfig/tcl.m4

    r502 r505  
    44#       a Tcl extension.
    55#
    6 # Copyright (c) 1999 Scriptics Corporation.
     6# Copyright (c) 1999-2000 Ajuba Solutions.
     7# Copyright (c) 2002-2005 ActiveState Corporation.
    78#
    89# See the file "license.terms" for information on usage and redistribution
    910# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    10 
    11 #------------------------------------------------------------------------
    12 # SC_PATH_TCLCONFIG --
     11#
     12# RCS: @(#) $Id: tcl.m4,v 1.92 2006/05/26 19:15:38 das Exp $
     13
     14AC_PREREQ(2.50)
     15
     16dnl TEA extensions pass this us the version of TEA they think they
     17dnl are compatible with (must be set in TEA_INIT below)
     18dnl TEA_VERSION="3.5"
     19
     20# Possible values for key variables defined:
     21#
     22# TEA_WINDOWINGSYSTEM - win32 aqua x11 (mirrors 'tk windowingsystem')
     23# TEA_PLATFORM        - windows unix
     24#
     25
     26#------------------------------------------------------------------------
     27# TEA_PATH_TCLCONFIG --
    1328#
    1429#       Locate the tclConfig.sh file and perform a sanity check on
     
    2843#------------------------------------------------------------------------
    2944
    30 AC_DEFUN(SC_PATH_TCLCONFIG, [
     45AC_DEFUN([TEA_PATH_TCLCONFIG], [
     46    dnl Make sure we are initialized
     47    AC_REQUIRE([TEA_INIT])
    3148    #
    3249    # Ok, lets find the tcl configuration
     
    3855        # we reset no_tcl in case something fails here
    3956        no_tcl=true
    40         AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
     57        AC_ARG_WITH(tcl,
     58            AC_HELP_STRING([--with-tcl],
     59                [directory containing tcl configuration (tclConfig.sh)]),
     60            with_tclconfig=${withval})
    4161        AC_MSG_CHECKING([for Tcl configuration])
    4262        AC_CACHE_VAL(ac_cv_c_tclconfig,[
     
    4464            # First check to see if --with-tcl was specified.
    4565            if test x"${with_tclconfig}" != x ; then
     66                case ${with_tclconfig} in
     67                    */tclConfig.sh )
     68                        if test -f ${with_tclconfig}; then
     69                            AC_MSG_WARN([--with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself])
     70                            with_tclconfig=`echo ${with_tclconfig} | sed 's!/tclConfig\.sh$!!'`
     71                        fi ;;
     72                esac
    4673                if test -f "${with_tclconfig}/tclConfig.sh" ; then
    4774                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
     
    5582                for i in \
    5683                        ../tcl \
     84                        `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
     85                        `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
    5786                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
    5887                        ../../tcl \
     88                        `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
     89                        `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
    5990                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
    6091                        ../../../tcl \
     92                        `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
     93                        `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
    6194                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
    6295                    if test -f "$i/unix/tclConfig.sh" ; then
     
    67100            fi
    68101
    69             # check in a few common install locations
    70             if test x"${ac_cv_c_tclconfig}" = x ; then
    71                 for i in `ls -d ${prefix}/lib 2>/dev/null` \
    72                         `ls -d /usr/local/lib 2>/dev/null` ; do
     102            # on Darwin, check in Framework installation locations
     103            if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
     104                for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
     105                        `ls -d /Library/Frameworks 2>/dev/null` \
     106                        `ls -d /Network/Library/Frameworks 2>/dev/null` \
     107                        `ls -d /System/Library/Frameworks 2>/dev/null` \
     108                        ; do
     109                    if test -f "$i/Tcl.framework/tclConfig.sh" ; then
     110                        ac_cv_c_tclconfig=`(cd $i/Tcl.framework; pwd)`
     111                        break
     112                    fi
     113                done
     114            fi
     115
     116            # on Windows, check in common installation locations
     117            if test "${TEA_PLATFORM}" = "windows" \
     118                -a x"${ac_cv_c_tclconfig}" = x ; then
     119                for i in `ls -d C:/Tcl/lib 2>/dev/null` \
     120                        `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
     121                        ; do
    73122                    if test -f "$i/tclConfig.sh" ; then
    74123                        ac_cv_c_tclconfig=`(cd $i; pwd)`
     
    78127            fi
    79128
     129            # check in a few common install locations
     130            if test x"${ac_cv_c_tclconfig}" = x ; then
     131                for i in `ls -d ${libdir} 2>/dev/null` \
     132                        `ls -d ${exec_prefix}/lib 2>/dev/null` \
     133                        `ls -d ${prefix}/lib 2>/dev/null` \
     134                        `ls -d /usr/local/lib 2>/dev/null` \
     135                        `ls -d /usr/contrib/lib 2>/dev/null` \
     136                        `ls -d /usr/lib 2>/dev/null` \
     137                        ; do
     138                    if test -f "$i/tclConfig.sh" ; then
     139                        ac_cv_c_tclconfig=`(cd $i; pwd)`
     140                        break
     141                    fi
     142                done
     143            fi
     144
    80145            # check in a few other private locations
    81146            if test x"${ac_cv_c_tclconfig}" = x ; then
    82147                for i in \
    83148                        ${srcdir}/../tcl \
     149                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
     150                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
    84151                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
    85152                    if test -f "$i/unix/tclConfig.sh" ; then
     
    93160        if test x"${ac_cv_c_tclconfig}" = x ; then
    94161            TCL_BIN_DIR="# no Tcl configs found"
    95             AC_MSG_WARN(Can't find Tcl configuration definitions)
     162            AC_MSG_WARN([Can't find Tcl configuration definitions])
    96163            exit 0
    97164        else
    98165            no_tcl=
    99166            TCL_BIN_DIR=${ac_cv_c_tclconfig}
    100             AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
     167            AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
    101168        fi
    102169    fi
     
    104171
    105172#------------------------------------------------------------------------
    106 # SC_PATH_TKCONFIG --
     173# TEA_PATH_TKCONFIG --
    107174#
    108175#       Locate the tkConfig.sh file
     
    121188#------------------------------------------------------------------------
    122189
    123 AC_DEFUN(SC_PATH_TKCONFIG, [
     190AC_DEFUN([TEA_PATH_TKCONFIG], [
    124191    #
    125192    # Ok, lets find the tk configuration
     
    131198        # we reset no_tk in case something fails here
    132199        no_tk=true
    133         AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
     200        AC_ARG_WITH(tk,
     201            AC_HELP_STRING([--with-tk],
     202                [directory containing tk configuration (tkConfig.sh)]),
     203            with_tkconfig=${withval})
    134204        AC_MSG_CHECKING([for Tk configuration])
    135205        AC_CACHE_VAL(ac_cv_c_tkconfig,[
     
    137207            # First check to see if --with-tkconfig was specified.
    138208            if test x"${with_tkconfig}" != x ; then
     209                case ${with_tkconfig} in
     210                    */tkConfig.sh )
     211                        if test -f ${with_tkconfig}; then
     212                            AC_MSG_WARN([--with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself])
     213                            with_tkconfig=`echo ${with_tkconfig} | sed 's!/tkConfig\.sh$!!'`
     214                        fi ;;
     215                esac
    139216                if test -f "${with_tkconfig}/tkConfig.sh" ; then
    140217                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
     
    148225                for i in \
    149226                        ../tk \
     227                        `ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
     228                        `ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
    150229                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
    151230                        ../../tk \
     231                        `ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
     232                        `ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
    152233                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
    153234                        ../../../tk \
     235                        `ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
     236                        `ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
    154237                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
    155238                    if test -f "$i/unix/tkConfig.sh" ; then
     
    159242                done
    160243            fi
     244
     245            # on Darwin, check in Framework installation locations
     246            if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then
     247                for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
     248                        `ls -d /Library/Frameworks 2>/dev/null` \
     249                        `ls -d /Network/Library/Frameworks 2>/dev/null` \
     250                        `ls -d /System/Library/Frameworks 2>/dev/null` \
     251                        ; do
     252                    if test -f "$i/Tk.framework/tkConfig.sh" ; then
     253                        ac_cv_c_tkconfig=`(cd $i/Tk.framework; pwd)`
     254                        break
     255                    fi
     256                done
     257            fi
     258
    161259            # check in a few common install locations
    162260            if test x"${ac_cv_c_tkconfig}" = x ; then
    163                 for i in `ls -d ${prefix}/lib 2>/dev/null` \
    164                         `ls -d /usr/local/lib 2>/dev/null` ; do
     261                for i in `ls -d ${libdir} 2>/dev/null` \
     262                        `ls -d ${exec_prefix}/lib 2>/dev/null` \
     263                        `ls -d ${prefix}/lib 2>/dev/null` \
     264                        `ls -d /usr/local/lib 2>/dev/null` \
     265                        `ls -d /usr/contrib/lib 2>/dev/null` \
     266                        `ls -d /usr/lib 2>/dev/null` \
     267                        ; do
    165268                    if test -f "$i/tkConfig.sh" ; then
    166269                        ac_cv_c_tkconfig=`(cd $i; pwd)`
     
    169272                done
    170273            fi
     274
     275            # on Windows, check in common installation locations
     276            if test "${TEA_PLATFORM}" = "windows" \
     277                -a x"${ac_cv_c_tkconfig}" = x ; then
     278                for i in `ls -d C:/Tcl/lib 2>/dev/null` \
     279                        `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
     280                        ; do
     281                    if test -f "$i/tkConfig.sh" ; then
     282                        ac_cv_c_tkconfig=`(cd $i; pwd)`
     283                        break
     284                    fi
     285                done
     286            fi
     287
    171288            # check in a few other private locations
    172289            if test x"${ac_cv_c_tkconfig}" = x ; then
    173290                for i in \
    174291                        ${srcdir}/../tk \
     292                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
     293                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
    175294                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
    176295                    if test -f "$i/unix/tkConfig.sh" ; then
     
    181300            fi
    182301        ])
     302
    183303        if test x"${ac_cv_c_tkconfig}" = x ; then
    184304            TK_BIN_DIR="# no Tk configs found"
    185             AC_MSG_WARN(Can't find Tk configuration definitions)
     305            AC_MSG_WARN([Can't find Tk configuration definitions])
    186306            exit 0
    187307        else
    188308            no_tk=
    189309            TK_BIN_DIR=${ac_cv_c_tkconfig}
    190             AC_MSG_RESULT(found $TK_BIN_DIR/tkConfig.sh)
     310            AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
    191311        fi
    192312    fi
    193 
    194 ])
    195 
    196 #------------------------------------------------------------------------
    197 # SC_LOAD_TCLCONFIG --
     313])
     314
     315#------------------------------------------------------------------------
     316# TEA_LOAD_TCLCONFIG --
    198317#
    199318#       Load the tclConfig.sh file
     
    213332#------------------------------------------------------------------------
    214333
    215 AC_DEFUN(SC_LOAD_TCLCONFIG, [
    216     AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
    217 
    218     if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
     334AC_DEFUN([TEA_LOAD_TCLCONFIG], [
     335    AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
     336
     337    if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
    219338        AC_MSG_RESULT([loading])
    220         . $TCL_BIN_DIR/tclConfig.sh
     339        . ${TCL_BIN_DIR}/tclConfig.sh
    221340    else
    222         AC_MSG_RESULT([file not found])
    223     fi
    224 
    225     #
    226     # The eval is required to do the TCL_DBGX substitution in the
    227     # TCL_LIB_FILE variable
    228     #
    229 
    230     eval TCL_LIB_FILE=${TCL_LIB_FILE}
    231     eval TCL_LIB_FLAG=${TCL_LIB_FLAG}
    232 
     341        AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
     342    fi
     343
     344    # eval is required to do the TCL_DBGX substitution
     345    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
     346    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
     347
     348    # If the TCL_BIN_DIR is the build directory (not the install directory),
     349    # then set the common variable name to the value of the build variables.
     350    # For example, the variable TCL_LIB_SPEC will be set to the value
     351    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
     352    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
     353    # installed and uninstalled version of Tcl.
     354    if test -f ${TCL_BIN_DIR}/Makefile ; then
     355        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
     356        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
     357        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
     358    elif test "`uname -s`" = "Darwin"; then
     359        # If Tcl was built as a framework, attempt to use the libraries
     360        # from the framework at the given location so that linking works
     361        # against Tcl.framework installed in an arbitary location.
     362        case ${TCL_DEFS} in
     363            *TCL_FRAMEWORK*)
     364                if test -f ${TCL_BIN_DIR}/${TCL_LIB_FILE}; then
     365                    for i in "`cd ${TCL_BIN_DIR}; pwd`" \
     366                             "`cd ${TCL_BIN_DIR}/../..; pwd`"; do
     367                        if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
     368                            TCL_LIB_SPEC="-F`dirname "$i"` -framework ${TCL_LIB_FILE}"
     369                            break
     370                        fi
     371                    done
     372                fi
     373                if test -f ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}; then
     374                    TCL_STUB_LIB_SPEC="-L${TCL_BIN_DIR} ${TCL_STUB_LIB_FLAG}"
     375                    TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
     376                fi
     377                ;;
     378        esac
     379    fi
     380
     381    # eval is required to do the TCL_DBGX substitution
     382    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
     383    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
     384    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
     385    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
     386
     387    AC_SUBST(TCL_VERSION)
    233388    AC_SUBST(TCL_BIN_DIR)
    234389    AC_SUBST(TCL_SRC_DIR)
     390
    235391    AC_SUBST(TCL_LIB_FILE)
     392    AC_SUBST(TCL_LIB_FLAG)
     393    AC_SUBST(TCL_LIB_SPEC)
     394
     395    AC_SUBST(TCL_STUB_LIB_FILE)
     396    AC_SUBST(TCL_STUB_LIB_FLAG)
     397    AC_SUBST(TCL_STUB_LIB_SPEC)
     398
    236399    AC_SUBST(TCL_LIBS)
    237400    AC_SUBST(TCL_DEFS)
    238     AC_SUBST(TCL_SHLIB_LD_LIBS)
    239401    AC_SUBST(TCL_EXTRA_CFLAGS)
    240402    AC_SUBST(TCL_LD_FLAGS)
    241     AC_SUBST(TCL_LIB_FILE)
    242     AC_SUBST(TCL_STUB_LIB_FILE)
    243     AC_SUBST(TCL_LIB_SPEC)
    244     AC_SUBST(TCL_BUILD_LIB_SPEC)
    245     AC_SUBST(TCL_STUB_LIB_SPEC)
    246     AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
    247 ])
    248 
    249 #------------------------------------------------------------------------
    250 # SC_LOAD_TKCONFIG --
     403    AC_SUBST(TCL_SHLIB_LD_LIBS)
     404])
     405
     406#------------------------------------------------------------------------
     407# TEA_LOAD_TKCONFIG --
    251408#
    252409#       Load the tkConfig.sh file
     
    263420#------------------------------------------------------------------------
    264421
    265 AC_DEFUN(SC_LOAD_TKCONFIG, [
    266     AC_MSG_CHECKING([for existence of $TCLCONFIG])
    267 
    268     if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
    269         AC_MSG_CHECKING([loading $TK_BIN_DIR/tkConfig.sh])
    270         . $TK_BIN_DIR/tkConfig.sh
     422AC_DEFUN([TEA_LOAD_TKCONFIG], [
     423    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
     424
     425    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
     426        AC_MSG_RESULT([loading])
     427        . ${TK_BIN_DIR}/tkConfig.sh
    271428    else
    272         AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
    273     fi
    274 
     429        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
     430    fi
     431
     432    # eval is required to do the TK_DBGX substitution
     433    eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
     434    eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
     435
     436    # If the TK_BIN_DIR is the build directory (not the install directory),
     437    # then set the common variable name to the value of the build variables.
     438    # For example, the variable TK_LIB_SPEC will be set to the value
     439    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
     440    # instead of TK_BUILD_LIB_SPEC since it will work with both an
     441    # installed and uninstalled version of Tcl.
     442    if test -f ${TK_BIN_DIR}/Makefile ; then
     443        TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
     444        TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
     445        TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
     446    elif test "`uname -s`" = "Darwin"; then
     447        # If Tk was built as a framework, attempt to use the libraries
     448        # from the framework at the given location so that linking works
     449        # against Tk.framework installed in an arbitary location.
     450        case ${TK_DEFS} in
     451            *TK_FRAMEWORK*)
     452                if test -f ${TK_BIN_DIR}/${TK_LIB_FILE}; then
     453                    for i in "`cd ${TK_BIN_DIR}; pwd`" \
     454                             "`cd ${TK_BIN_DIR}/../..; pwd`"; do
     455                        if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
     456                            TK_LIB_SPEC="-F`dirname "$i"` -framework ${TK_LIB_FILE}"
     457                            break
     458                        fi
     459                    done
     460                fi
     461                if test -f ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}; then
     462                    TK_STUB_LIB_SPEC="-L${TK_BIN_DIR} ${TK_STUB_LIB_FLAG}"
     463                    TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
     464                fi
     465                ;;
     466        esac
     467    fi
     468
     469    # eval is required to do the TK_DBGX substitution
     470    eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
     471    eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
     472    eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
     473    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
     474
     475    # Ensure windowingsystem is defined
     476    if test "${TEA_PLATFORM}" = "unix" ; then
     477        case ${TK_DEFS} in
     478            *MAC_OSX_TK*)
     479                AC_DEFINE(MAC_OSX_TK, 1, [Are we building against Mac OS X TkAqua?])
     480                TEA_WINDOWINGSYSTEM="aqua"
     481                ;;
     482            *)
     483                TEA_WINDOWINGSYSTEM="x11"
     484                ;;
     485        esac
     486    elif test "${TEA_PLATFORM}" = "windows" ; then
     487        TEA_WINDOWINGSYSTEM="win32"
     488    fi
     489
     490    AC_SUBST(TK_VERSION)
    275491    AC_SUBST(TK_BIN_DIR)
    276492    AC_SUBST(TK_SRC_DIR)
     493
    277494    AC_SUBST(TK_LIB_FILE)
    278 ])
    279 
    280 #------------------------------------------------------------------------
    281 # SC_ENABLE_GCC --
    282 #
    283 #       Allows the use of GCC if available
     495    AC_SUBST(TK_LIB_FLAG)
     496    AC_SUBST(TK_LIB_SPEC)
     497
     498    AC_SUBST(TK_STUB_LIB_FILE)
     499    AC_SUBST(TK_STUB_LIB_FLAG)
     500    AC_SUBST(TK_STUB_LIB_SPEC)
     501
     502    AC_SUBST(TK_LIBS)
     503    AC_SUBST(TK_XINCLUDES)
     504])
     505
     506#------------------------------------------------------------------------
     507# TEA_ENABLE_SHARED --
     508#
     509#       Allows the building of shared libraries
    284510#
    285511# Arguments:
     
    289515#
    290516#       Adds the following arguments to configure:
    291 #               --enable-gcc
    292 #
    293 #       Sets the following vars:
    294 #               CC      Command to use for the compiler
    295 #------------------------------------------------------------------------
    296 
    297 AC_DEFUN(SC_ENABLE_GCC, [
    298     AC_ARG_ENABLE(gcc, [  --enable-gcc            allow use of gcc if available [--disable-gcc]],
    299         [ok=$enableval], [ok=no])
    300     if test "$ok" = "yes"; then
    301         CC=gcc
    302     else
    303         case "`uname -s`" in
    304             *win32* | *WIN32* | *CYGWIN_NT*)
    305                 CC=cl
    306             ;;
    307             *)
    308                 CC=${CC-cc}
    309             ;;
    310         esac
    311     fi
    312     AC_PROG_CC
    313 ])
    314 
    315 #------------------------------------------------------------------------
    316 # SC_ENABLE_SHARED --
    317 #
    318 #       Allows the building of shared libraries
    319 #
    320 # Arguments:
    321 #       none
    322 #       
    323 # Results:
    324 #
    325 #       Adds the following arguments to configure:
    326517#               --enable-shared=yes|no
    327518#
     
    334525#------------------------------------------------------------------------
    335526
    336 AC_DEFUN(SC_ENABLE_SHARED, [
     527AC_DEFUN([TEA_ENABLE_SHARED], [
    337528    AC_MSG_CHECKING([how to build libraries])
    338529    AC_ARG_ENABLE(shared,
    339         [  --enable-shared         build and link with shared libraries [--enable-shared]],
     530        AC_HELP_STRING([--enable-shared],
     531            [build and link with shared libraries (default: on)]),
    340532        [tcl_ok=$enableval], [tcl_ok=yes])
    341533
     
    353545        AC_MSG_RESULT([static])
    354546        SHARED_BUILD=0
    355         AC_DEFINE(STATIC_BUILD)
    356     fi
    357 ])
    358 
    359 #------------------------------------------------------------------------
    360 # SC_ENABLE_THREADS --
    361 #
    362 #       Specify if thread support should be enabled
     547        AC_DEFINE(STATIC_BUILD, 1, [Is this a static build?])
     548    fi
     549    AC_SUBST(SHARED_BUILD)
     550])
     551
     552#------------------------------------------------------------------------
     553# TEA_ENABLE_THREADS --
     554#
     555#       Specify if thread support should be enabled.  If "yes" is specified
     556#       as an arg (optional), threads are enabled by default, "no" means
     557#       threads are disabled.  "yes" is the default.
     558#
     559#       TCL_THREADS is checked so that if you are compiling an extension
     560#       against a threaded core, your extension must be compiled threaded
     561#       as well.
     562#
     563#       Note that it is legal to have a thread enabled extension run in a
     564#       threaded or non-threaded Tcl core, but a non-threaded extension may
     565#       only run in a non-threaded Tcl core.
    363566#
    364567# Arguments:
     
    376579#               TCL_THREADS
    377580#               _REENTRANT
    378 #
    379 #------------------------------------------------------------------------
    380 
    381 AC_DEFUN(SC_ENABLE_THREADS, [
    382     AC_MSG_CHECKING(for building with threads)
    383     AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
    384         [tcl_ok=$enableval], [tcl_ok=no])
    385 
    386     if test "$tcl_ok" = "yes"; then
    387         AC_MSG_RESULT(yes)
     581#               _THREAD_SAFE
     582#
     583#------------------------------------------------------------------------
     584
     585AC_DEFUN([TEA_ENABLE_THREADS], [
     586    AC_ARG_ENABLE(threads,
     587        AC_HELP_STRING([--enable-threads],
     588            [build with threads]),
     589        [tcl_ok=$enableval], [tcl_ok=yes])
     590
     591    if test "${enable_threads+set}" = set; then
     592        enableval="$enable_threads"
     593        tcl_ok=$enableval
     594    else
     595        tcl_ok=yes
     596    fi
     597
     598    if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
    388599        TCL_THREADS=1
    389         AC_DEFINE(TCL_THREADS)
    390         AC_DEFINE(_REENTRANT)
    391 
    392         AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
    393         if test "$tcl_ok" = "yes"; then
    394             # The space is needed
    395             THREADS_LIBS=" -lpthread"
    396         else
    397             TCL_THREADS=0
    398             AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")
     600
     601        if test "${TEA_PLATFORM}" != "windows" ; then
     602            # We are always OK on Windows, so check what this platform wants:
     603   
     604            # USE_THREAD_ALLOC tells us to try the special thread-based
     605            # allocator that significantly reduces lock contention
     606            AC_DEFINE(USE_THREAD_ALLOC, 1,
     607                [Do we want to use the threaded memory allocator?])
     608            AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
     609            if test "`uname -s`" = "SunOS" ; then
     610                AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
     611                        [Do we really want to follow the standard? Yes we do!])
     612            fi
     613            AC_DEFINE(_THREAD_SAFE, 1, [Do we want the thread-safe OS API?])
     614            AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
     615            if test "$tcl_ok" = "no"; then
     616                # Check a little harder for __pthread_mutex_init in the same
     617                # library, as some systems hide it there until pthread.h is
     618                # defined.  We could alternatively do an AC_TRY_COMPILE with
     619                # pthread.h, but that will work with libpthread really doesn't
     620                # exist, like AIX 4.2.  [Bug: 4359]
     621                AC_CHECK_LIB(pthread, __pthread_mutex_init,
     622                    tcl_ok=yes, tcl_ok=no)
     623            fi
     624
     625            if test "$tcl_ok" = "yes"; then
     626                # The space is needed
     627                THREADS_LIBS=" -lpthread"
     628            else
     629                AC_CHECK_LIB(pthreads, pthread_mutex_init,
     630                    tcl_ok=yes, tcl_ok=no)
     631                if test "$tcl_ok" = "yes"; then
     632                    # The space is needed
     633                    THREADS_LIBS=" -lpthreads"
     634                else
     635                    AC_CHECK_LIB(c, pthread_mutex_init,
     636                        tcl_ok=yes, tcl_ok=no)
     637                    if test "$tcl_ok" = "no"; then
     638                        AC_CHECK_LIB(c_r, pthread_mutex_init,
     639                            tcl_ok=yes, tcl_ok=no)
     640                        if test "$tcl_ok" = "yes"; then
     641                            # The space is needed
     642                            THREADS_LIBS=" -pthread"
     643                        else
     644                            TCL_THREADS=0
     645                            AC_MSG_WARN([Do not know how to find pthread lib on your system - thread support disabled])
     646                        fi
     647                    fi
     648                fi
     649            fi
    399650        fi
    400651    else
    401652        TCL_THREADS=0
    402         AC_MSG_RESULT(no (default))
    403     fi
    404 
    405 ])
    406 
    407 #------------------------------------------------------------------------
    408 # SC_ENABLE_SYMBOLS --
    409 #
    410 #       Specify if debugging symbols should be used
     653    fi
     654    # Do checking message here to not mess up interleaved configure output
     655    AC_MSG_CHECKING([for building with threads])
     656    if test "${TCL_THREADS}" = 1; then
     657        AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
     658        AC_MSG_RESULT([yes (default)])
     659    else
     660        AC_MSG_RESULT([no])
     661    fi
     662    # TCL_THREADS sanity checking.  See if our request for building with
     663    # threads is the same as the way Tcl was built.  If not, warn the user.
     664    case ${TCL_DEFS} in
     665        *THREADS=1*)
     666            if test "${TCL_THREADS}" = "0"; then
     667                AC_MSG_WARN([
     668    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
     669    that IS thread-enabled.  It is recommended to use --enable-threads.])
     670            fi
     671            ;;
     672        *)
     673            if test "${TCL_THREADS}" = "1"; then
     674                AC_MSG_WARN([
     675    --enable-threads requested, but building against a Tcl that is NOT
     676    thread-enabled.  This is an OK configuration that will also run in
     677    a thread-enabled core.])
     678            fi
     679            ;;
     680    esac
     681    AC_SUBST(TCL_THREADS)
     682])
     683
     684#------------------------------------------------------------------------
     685# TEA_ENABLE_SYMBOLS --
     686#
     687#       Specify if debugging symbols should be used.
     688#       Memory (TCL_MEM_DEBUG) debugging can also be enabled.
    411689#
    412690# Arguments:
    413691#       none
    414692#       
    415 #       Requires the following vars to be set:
    416 #               CFLAGS_DEBUG
    417 #               CFLAGS_OPTIMIZE
    418 #               LDFLAGS_DEBUG
    419 #               LDFLAGS_OPTIMIZE
     693#       TEA varies from core Tcl in that C|LDFLAGS_DEFAULT receives
     694#       the value of C|LDFLAGS_OPTIMIZE|DEBUG already substituted.
     695#       Requires the following vars to be set in the Makefile:
     696#               CFLAGS_DEFAULT
     697#               LDFLAGS_DEFAULT
    420698#       
    421699# Results:
     
    425703#
    426704#       Defines the following vars:
    427 #               CFLAGS_DEFAULT  Sets to CFLAGS_DEBUG if true
    428 #                               Sets to CFLAGS_OPTIMIZE if false
    429 #               LDFLAGS_DEFAULT Sets to LDFLAGS_DEBUG if true
    430 #                               Sets to LDFLAGS_OPTIMIZE if false
    431 #               DBGX            Debug library extension
    432 #
    433 #------------------------------------------------------------------------
    434 
    435 AC_DEFUN(SC_ENABLE_SYMBOLS, [
    436     case "`uname -s`" in
    437         *win32* | *WIN32* | *CYGWIN_NT*)
    438             tcl_dbgx=d
    439         ;;
    440         *)
    441             tcl_dbgx=g
    442         ;;
    443     esac
    444 
     705#               CFLAGS_DEFAULT  Sets to $(CFLAGS_DEBUG) if true
     706#                               Sets to $(CFLAGS_OPTIMIZE) if false
     707#               LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
     708#                               Sets to $(LDFLAGS_OPTIMIZE) if false
     709#               DBGX            Formerly used as debug library extension;
     710#                               always blank now.
     711#
     712#------------------------------------------------------------------------
     713
     714AC_DEFUN([TEA_ENABLE_SYMBOLS], [
     715    dnl Make sure we are initialized
     716    AC_REQUIRE([TEA_CONFIG_CFLAGS])
    445717    AC_MSG_CHECKING([for build with symbols])
    446     AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
    447     if test "$tcl_ok" = "yes"; then
     718    AC_ARG_ENABLE(symbols,
     719        AC_HELP_STRING([--enable-symbols],
     720            [build with debugging symbols (default: off)]),
     721        [tcl_ok=$enableval], [tcl_ok=no])
     722    DBGX=""
     723    if test "$tcl_ok" = "no"; then
     724        CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
     725        LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
     726        AC_MSG_RESULT([no])
     727    else
    448728        CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
    449729        LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
    450         DBGX=${tcl_dbgx}
    451         TCL_DBGX=${tcl_dbgx}
    452         AC_MSG_RESULT([yes])
    453     else
    454         CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
    455         LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
    456         DBGX=""
    457         TCL_DBGX=""
    458         AC_MSG_RESULT([no])
     730        if test "$tcl_ok" = "yes"; then
     731            AC_MSG_RESULT([yes (standard debugging)])
     732        fi
     733    fi
     734    if test "${TEA_PLATFORM}" != "windows" ; then
     735        LDFLAGS_DEFAULT="${LDFLAGS}"
    459736    fi
    460737
     
    462739    AC_SUBST(CFLAGS_DEFAULT)
    463740    AC_SUBST(LDFLAGS_DEFAULT)
     741
     742    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
     743        AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?])
     744    fi
     745
     746    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
     747        if test "$tcl_ok" = "all"; then
     748            AC_MSG_RESULT([enabled symbols mem debugging])
     749        else
     750            AC_MSG_RESULT([enabled $tcl_ok debugging])
     751        fi
     752    fi
     753])
     754
     755#------------------------------------------------------------------------
     756# TEA_ENABLE_LANGINFO --
     757#
     758#       Allows use of modern nl_langinfo check for better l10n.
     759#       This is only relevant for Unix.
     760#
     761# Arguments:
     762#       none
     763#       
     764# Results:
     765#
     766#       Adds the following arguments to configure:
     767#               --enable-langinfo=yes|no (default is yes)
     768#
     769#       Defines the following vars:
     770#               HAVE_LANGINFO   Triggers use of nl_langinfo if defined.
     771#
     772#------------------------------------------------------------------------
     773
     774AC_DEFUN([TEA_ENABLE_LANGINFO], [
     775    AC_ARG_ENABLE(langinfo,
     776        AC_HELP_STRING([--enable-langinfo],
     777            [use nl_langinfo if possible to determine encoding at startup, otherwise use old heuristic (default: on)]),
     778        [langinfo_ok=$enableval], [langinfo_ok=yes])
     779
     780    HAVE_LANGINFO=0
     781    if test "$langinfo_ok" = "yes"; then
     782        AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
     783    fi
     784    AC_MSG_CHECKING([whether to use nl_langinfo])
     785    if test "$langinfo_ok" = "yes"; then
     786        AC_CACHE_VAL(tcl_cv_langinfo_h,
     787            AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
     788                    [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no]))
     789        AC_MSG_RESULT([$tcl_cv_langinfo_h])
     790        if test $tcl_cv_langinfo_h = yes; then
     791            AC_DEFINE(HAVE_LANGINFO, 1, [Do we have nl_langinfo()?])
     792        fi
     793    else
     794        AC_MSG_RESULT([$langinfo_ok])
     795    fi
    464796])
    465797
    466798#--------------------------------------------------------------------
    467 # SC_CONFIG_CFLAGS
     799# TEA_CONFIG_SYSTEM
     800#
     801#       Determine what the system is (some things cannot be easily checked
     802#       on a feature-driven basis, alas). This can usually be done via the
     803#       "uname" command, but there are a few systems, like Next, where
     804#       this doesn't work.
     805#
     806# Arguments:
     807#       none
     808#
     809# Results:
     810#       Defines the following var:
     811#
     812#       system -        System/platform/version identification code.
     813#
     814#--------------------------------------------------------------------
     815
     816AC_DEFUN([TEA_CONFIG_SYSTEM], [
     817    AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
     818        if test "${TEA_PLATFORM}" = "windows" ; then
     819            tcl_cv_sys_version=windows
     820        elif test -f /usr/lib/NextStep/software_version; then
     821            tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
     822        else
     823            tcl_cv_sys_version=`uname -s`-`uname -r`
     824            if test "$?" -ne 0 ; then
     825                AC_MSG_WARN([can't find uname command])
     826                tcl_cv_sys_version=unknown
     827            else
     828                # Special check for weird MP-RAS system (uname returns weird
     829                # results, and the version is kept in special file).
     830
     831                if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
     832                    tcl_cv_sys_version=MP-RAS-`awk '{print [$]3}' /etc/.relid`
     833                fi
     834                if test "`uname -s`" = "AIX" ; then
     835                    tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
     836                fi
     837            fi
     838        fi
     839    ])
     840    system=$tcl_cv_sys_version
     841])
     842
     843#--------------------------------------------------------------------
     844# TEA_CONFIG_CFLAGS
    468845#
    469846#       Try to determine the proper flags to pass to the compiler
     
    475852# Results:
    476853#
    477 #       Defines the following vars:
     854#       Defines and substitutes the following vars:
    478855#
    479856#       DL_OBJS -       Name of the object file that implements dynamic
     
    487864#                       that tell the run-time dynamic linker where to look
    488865#                       for shared libraries such as libtcl.so.  Depends on
     866#                       the variable LIB_RUNTIME_DIR in the Makefile. Could
     867#                       be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
     868#       CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
     869#                       that tell the run-time dynamic linker where to look
     870#                       for shared libraries such as libtcl.so.  Depends on
    489871#                       the variable LIB_RUNTIME_DIR in the Makefile.
    490 #       MAKE_LIB -      Command to execute to build the Tcl library;
    491 #                       differs depending on whether or not Tcl is being
    492 #                       compiled as a shared library.
    493872#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
    494873#                       of a shared library (may request position-independent
     
    510889#                       extensions.  An empty string means we don't know how
    511890#                       to use shared libraries on this platform.
    512 #       TCL_LIB_FILE -  Name of the file that contains the Tcl library, such
    513 #                       as libtcl7.8.so or libtcl7.8.a.
    514 #       TCL_LIB_SUFFIX -Specifies everything that comes after the "libtcl"
    515 #                       in the shared library name, using the $VERSION variable
     891#       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
     892#                       in a static or shared library name, using the $VERSION variable
    516893#                       to put the version in the right place.  This is used
    517894#                       by platforms that need non-standard library names.
    518895#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
    519896#                       to have a version after the .so, and ${VERSION}.a
    520 #                       on AIX, since the Tcl shared library needs to have
     897#                       on AIX, since a shared library needs to have
    521898#                       a .a extension whereas shared objects for loadable
    522899#                       extensions have a .so extension.  Defaults to
     
    536913#       CFLAGS_OPTIMIZE -
    537914#                       Flags used when running the compiler in optimize mode
    538 #
    539 #       EXTRA_CFLAGS
    540 #
    541 #       Subst's the following vars:
    542 #               DL_LIBS
    543 #               CFLAGS_DEBUG
    544 #               CFLAGS_OPTIMIZE
     915#       CFLAGS -        Additional CFLAGS added as necessary (usually 64-bit)
     916#
    545917#--------------------------------------------------------------------
    546918
    547 AC_DEFUN(SC_CONFIG_CFLAGS, [
    548 
    549     # Step 0: Enable 64 bit support?
    550 
    551     AC_MSG_CHECKING([if 64bit support is enabled])
    552     AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support],,enableval="no")
    553 
    554     if test "$enableval" = "yes"; then
    555         AC_MSG_RESULT(Will compile with 64bit support)
     919AC_DEFUN([TEA_CONFIG_CFLAGS], [
     920    dnl Make sure we are initialized
     921    AC_REQUIRE([TEA_INIT])
     922
     923    # Step 0.a: Enable 64 bit support?
     924
     925    AC_MSG_CHECKING([if 64bit support is requested])
     926    AC_ARG_ENABLE(64bit,
     927        AC_HELP_STRING([--enable-64bit],
     928            [enable 64bit support (default: off)]),
     929        [do64bit=$enableval], [do64bit=no])
     930    AC_MSG_RESULT([$do64bit])
     931
     932    # Step 0.b: Enable Solaris 64 bit VIS support?
     933
     934    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
     935    AC_ARG_ENABLE(64bit-vis,
     936        AC_HELP_STRING([--enable-64bit-vis],
     937            [enable 64bit Sparc VIS support (default: off)]),
     938        [do64bitVIS=$enableval], [do64bitVIS=no])
     939    AC_MSG_RESULT([$do64bitVIS])
     940
     941    if test "$do64bitVIS" = "yes"; then
     942        # Force 64bit on with VIS
    556943        do64bit=yes
    557     else
    558         do64bit=no
    559     fi
    560     AC_MSG_RESULT($do64bit)
    561  
     944    fi
     945
     946    # Step 0.c: Cross-compiling options for Windows/CE builds?
     947
     948    if test "${TEA_PLATFORM}" = "windows" ; then
     949        AC_MSG_CHECKING([if Windows/CE build is requested])
     950        AC_ARG_ENABLE(wince,[  --enable-wince          enable Win/CE support (where applicable)], [doWince=$enableval], [doWince=no])
     951        AC_MSG_RESULT([$doWince])
     952    fi
     953
    562954    # Step 1: set the variable "system" to hold the name and version number
    563     # for the system.  This can usually be done via the "uname" command, but
    564     # there are a few systems, like Next, where this doesn't work.
    565 
    566     AC_MSG_CHECKING([system version (for dynamic loading)])
    567     if test -f /usr/lib/NextStep/software_version; then
    568         system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
    569     else
    570         system=`uname -s`-`uname -r`
    571         if test "$?" -ne 0 ; then
    572             AC_MSG_RESULT([unknown (can't find uname command)])
    573             system=unknown
    574         else
    575             # Special check for weird MP-RAS system (uname returns weird
    576             # results, and the version is kept in special file).
    577        
    578             if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
    579                 system=MP-RAS-`awk '{print $3}' /etc/.relid'`
    580             fi
    581             if test "`uname -s`" = "AIX" ; then
    582                 system=AIX-`uname -v`.`uname -r`
    583             fi
    584             AC_MSG_RESULT($system)
    585         fi
    586     fi
     955    # for the system.
     956
     957    TEA_CONFIG_SYSTEM
    587958
    588959    # Step 2: check for existence of -ldl library.  This is needed because
     
    591962    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
    592963
     964    # Require ranlib early so we can override it in special cases below.
     965
     966    AC_REQUIRE([AC_PROG_RANLIB])
     967
    593968    # Step 3: set configuration options based on system name and version.
     969    # This is similar to Tcl's unix/tcl.m4 except that we've added a
     970    # "windows" case.
    594971
    595972    do64bit_ok=no
    596     fullSrcDir=`cd $srcdir; pwd`
    597     EXTRA_CFLAGS=""
     973    LDFLAGS_ORIG="$LDFLAGS"
     974    # When ld needs options to work in 64-bit mode, put them in
     975    # LDFLAGS_ARCH so they eventually end up in LDFLAGS even if [load]
     976    # is disabled by the user. [Bug 1016796]
     977    LDFLAGS_ARCH=""
    598978    TCL_EXPORT_FILE_SUFFIX=""
    599979    UNSHARED_LIB_SUFFIX=""
    600     TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
    601     ECHO_VERSION='`echo ${VERSION}`'
     980    TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`'
     981    ECHO_VERSION='`echo ${PACKAGE_VERSION}`'
    602982    TCL_LIB_VERSIONS_OK=ok
    603983    CFLAGS_DEBUG=-g
    604984    CFLAGS_OPTIMIZE=-O
     985    if test "$GCC" = "yes" ; then
     986        CFLAGS_OPTIMIZE=-O2
     987        CFLAGS_WARNING="-Wall -Wno-implicit-int"
     988    else
     989        CFLAGS_WARNING=""
     990    fi
    605991    TCL_NEEDS_EXP_FILE=0
    606992    TCL_BUILD_EXP_FILE=""
    607993    TCL_EXP_FILE=""
    608     STLIB_LD="ar cr"
     994dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
     995dnl AC_CHECK_TOOL(AR, ar)
     996    AC_CHECK_PROG(AR, ar, ar)
     997    STLIB_LD='${AR} cr'
     998    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
    609999    case $system in
    610         AIX-4.[[2-9]])
     1000        windows)
     1001            # This is a 2-stage check to make sure we have the 64-bit SDK
     1002            # We have to know where the SDK is installed.
     1003            # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
     1004            # MACHINE is IX86 for LINK, but this is used by the manifest,
     1005            # which requires x86|amd64|ia64.
     1006            MACHINE="X86"
     1007            if test "$do64bit" != "no" ; then
     1008                if test "x${MSSDK}x" = "xx" ; then
     1009                    MSSDK="C:/Progra~1/Microsoft Platform SDK"
     1010                fi
     1011                MSSDK=`echo "$MSSDK" | sed -e  's!\\\!/!g'`
     1012                PATH64=""
     1013                case "$do64bit" in
     1014                    amd64|x64|yes)
     1015                        MACHINE="AMD64" ; # default to AMD64 64-bit build
     1016                        PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
     1017                        ;;
     1018                    ia64)
     1019                        MACHINE="IA64"
     1020                        PATH64="${MSSDK}/Bin/Win64"
     1021                        ;;
     1022                esac
     1023                if test ! -d "${PATH64}" ; then
     1024                    AC_MSG_WARN([Could not find 64-bit $MACHINE SDK to enable 64bit mode])
     1025                    AC_MSG_WARN([Ensure latest Platform SDK is installed])
     1026                    do64bit="no"
     1027                else
     1028                    AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
     1029                    do64bit_ok="yes"
     1030                fi
     1031            fi
     1032
     1033            if test "$doWince" != "no" ; then
     1034                if test "$do64bit" != "no" ; then
     1035                    AC_MSG_ERROR([Windows/CE and 64-bit builds incompatible])
     1036                fi
     1037                if test "$GCC" = "yes" ; then
     1038                    AC_MSG_ERROR([Windows/CE and GCC builds incompatible])
     1039                fi
     1040                TEA_PATH_CELIB
     1041                # Set defaults for common evc4/PPC2003 setup
     1042                # Currently Tcl requires 300+, possibly 420+ for sockets
     1043                CEVERSION=420;          # could be 211 300 301 400 420 ...
     1044                TARGETCPU=ARMV4;        # could be ARMV4 ARM MIPS SH3 X86 ...
     1045                ARCH=ARM;               # could be ARM MIPS X86EM ...
     1046                PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002"
     1047                if test "$doWince" != "yes"; then
     1048                    # If !yes then the user specified something
     1049                    # Reset ARCH to allow user to skip specifying it
     1050                    ARCH=
     1051                    eval `echo $doWince | awk -F, '{ \
     1052            if (length([$]1)) { printf "CEVERSION=\"%s\"\n", [$]1; \
     1053            if ([$]1 < 400)   { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \
     1054            if (length([$]2)) { printf "TARGETCPU=\"%s\"\n", toupper([$]2) }; \
     1055            if (length([$]3)) { printf "ARCH=\"%s\"\n", toupper([$]3) }; \
     1056            if (length([$]4)) { printf "PLATFORM=\"%s\"\n", [$]4 }; \
     1057                    }'`
     1058                    if test "x${ARCH}" = "x" ; then
     1059                        ARCH=$TARGETCPU;
     1060                    fi
     1061                fi
     1062                OSVERSION=WCE$CEVERSION;
     1063                if test "x${WCEROOT}" = "x" ; then
     1064                        WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0"
     1065                    if test ! -d "${WCEROOT}" ; then
     1066                        WCEROOT="C:/Program Files/Microsoft eMbedded Tools"
     1067                    fi
     1068                fi
     1069                if test "x${SDKROOT}" = "x" ; then
     1070                    SDKROOT="C:/Program Files/Windows CE Tools"
     1071                    if test ! -d "${SDKROOT}" ; then
     1072                        SDKROOT="C:/Windows CE Tools"
     1073                    fi
     1074                fi
     1075                WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'`
     1076                SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'`
     1077                if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \
     1078                    -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
     1079                    AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]])
     1080                    doWince="no"
     1081                else
     1082                    # We could PATH_NOSPACE these, but that's not important,
     1083                    # as long as we quote them when used.
     1084                    CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include"
     1085                    if test -d "${CEINCLUDE}/${TARGETCPU}" ; then
     1086                        CEINCLUDE="${CEINCLUDE}/${TARGETCPU}"
     1087                    fi
     1088                    CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"
     1089                fi
     1090            fi
     1091
     1092            if test "$GCC" != "yes" ; then
     1093                if test "${SHARED_BUILD}" = "0" ; then
     1094                    runtime=-MT
     1095                else
     1096                    runtime=-MD
     1097                fi
     1098
     1099                if test "$do64bit" != "no" ; then
     1100                    # All this magic is necessary for the Win64 SDK RC1 - hobbs
     1101                    CC="\"${PATH64}/cl.exe\""
     1102                    CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\""
     1103                    RC="\"${MSSDK}/bin/rc.exe\""
     1104                    lflags="-nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
     1105                    LINKBIN="\"${PATH64}/link.exe\""
     1106                    CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d"
     1107                    CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}"
     1108                    # Avoid 'unresolved external symbol __security_cookie'
     1109                    # errors, c.f. http://support.microsoft.com/?id=894573
     1110                    TEA_ADD_LIBS([bufferoverflowU.lib])
     1111                elif test "$doWince" != "no" ; then
     1112                    CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin"
     1113                    if test "${TARGETCPU}" = "X86"; then
     1114                        CC="\"${CEBINROOT}/cl.exe\""
     1115                    else
     1116                        CC="\"${CEBINROOT}/cl${ARCH}.exe\""
     1117                    fi
     1118                    CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
     1119                    RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
     1120                    arch=`echo ${ARCH} | awk '{print tolower([$]0)}'`
     1121                    defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS"
     1122                    if test "${SHARED_BUILD}" = "1" ; then
     1123                        # Static CE builds require static celib as well
     1124                        defs="${defs} _DLL"
     1125                    fi
     1126                    for i in $defs ; do
     1127                        AC_DEFINE_UNQUOTED($i, 1, [WinCE def ]$i)
     1128                    done
     1129                    AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION, [_WIN32_WCE version])
     1130                    AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION, [UNDER_CE version])
     1131                    CFLAGS_DEBUG="-nologo -Zi -Od"
     1132                    CFLAGS_OPTIMIZE="-nologo -Ox"
     1133                    lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'`
     1134                    lflags="-MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo"
     1135                    LINKBIN="\"${CEBINROOT}/link.exe\""
     1136                    AC_SUBST(CELIB_DIR)
     1137                else
     1138                    RC="rc"
     1139                    lflags="-nologo"
     1140                    LINKBIN="link"
     1141                    CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d"
     1142                    CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}"
     1143                fi
     1144            fi
     1145
     1146            if test "$GCC" = "yes"; then
     1147                # mingw gcc mode
     1148                RC="windres"
     1149                CFLAGS_DEBUG="-g"
     1150                CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
     1151                SHLIB_LD="$CC -shared"
     1152                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
     1153                LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}"
     1154                LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}"
     1155            else
     1156                SHLIB_LD="${LINKBIN} -dll ${lflags}"
     1157                # link -lib only works when -lib is the first arg
     1158                STLIB_LD="${LINKBIN} -lib ${lflags}"
     1159                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.lib'
     1160                PATHTYPE=-w
     1161                # For information on what debugtype is most useful, see:
     1162                # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp
     1163                # This essentially turns it all on.
     1164                LDFLAGS_DEBUG="-debug:full -debugtype:both -warn:2"
     1165                LDFLAGS_OPTIMIZE="-release"
     1166                if test "$doWince" != "no" ; then
     1167                    LDFLAGS_CONSOLE="-link ${lflags}"
     1168                    LDFLAGS_WINDOW=${LDFLAGS_CONSOLE}
     1169                else
     1170                    LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
     1171                    LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
     1172                fi
     1173            fi
     1174
     1175            SHLIB_LD_LIBS='${LIBS}'
     1176            SHLIB_SUFFIX=".dll"
     1177            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll'
     1178
     1179            TCL_LIB_VERSIONS_OK=nodots
     1180            # Bogus to avoid getting this turned off
     1181            DL_OBJS="tclLoadNone.obj"
     1182            ;;
     1183        AIX-*)
     1184            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
     1185                # AIX requires the _r compiler when gcc isn't being used
     1186                case "${CC}" in
     1187                    *_r)
     1188                        # ok ...
     1189                        ;;
     1190                    *)
     1191                        CC=${CC}_r
     1192                        ;;
     1193                esac
     1194                AC_MSG_RESULT([Using $CC for compiling with threads])
     1195            fi
     1196            LIBS="$LIBS -lc"
    6111197            SHLIB_CFLAGS=""
    612             SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
     1198            SHLIB_LD_LIBS='${LIBS}'
     1199            SHLIB_SUFFIX=".so"
     1200
     1201            DL_OBJS="tclLoadDl.o"
     1202            LD_LIBRARY_PATH_VAR="LIBPATH"
     1203
     1204            # Check to enable 64-bit flags for compiler/linker on AIX 4+
     1205            if test "$do64bit" = "yes" -a "`uname -v`" -gt "3" ; then
     1206                if test "$GCC" = "yes" ; then
     1207                    AC_MSG_WARN([64bit mode not supported with GCC on $system])
     1208                else
     1209                    do64bit_ok=yes
     1210                    CFLAGS="$CFLAGS -q64"
     1211                    LDFLAGS_ARCH="-q64"
     1212                    RANLIB="${RANLIB} -X64"
     1213                    AR="${AR} -X64"
     1214                    SHLIB_LD_FLAGS="-b64"
     1215                fi
     1216            fi
     1217
     1218            if test "`uname -m`" = "ia64" ; then
     1219                # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
     1220                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
     1221                # AIX-5 has dl* in libc.so
     1222                DL_LIBS=""
     1223                if test "$GCC" = "yes" ; then
     1224                    CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
     1225                else
     1226                    CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
     1227                fi
     1228                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
     1229            else
     1230                if test "$GCC" = "yes" ; then
     1231                    SHLIB_LD="gcc -shared"
     1232                else
     1233                    SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
     1234                fi
     1235                SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix ${SHLIB_LD} ${SHLIB_LD_FLAGS}"
     1236                DL_LIBS="-ldl"
     1237                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1238                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1239                TCL_NEEDS_EXP_FILE=1
     1240                TCL_EXPORT_FILE_SUFFIX='${PACKAGE_VERSION}.exp'
     1241            fi
     1242
     1243            # AIX v<=4.1 has some different flags than 4.2+
     1244            if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
     1245                AC_LIBOBJ([tclLoadAix])
     1246                DL_LIBS="-lld"
     1247            fi
     1248
     1249            # On AIX <=v4 systems, libbsd.a has to be linked in to support
     1250            # non-blocking file IO.  This library has to be linked in after
     1251            # the MATH_LIBS or it breaks the pow() function.  The way to
     1252            # insure proper sequencing, is to add it to the tail of MATH_LIBS.
     1253            # This library also supplies gettimeofday.
     1254            #
     1255            # AIX does not have a timezone field in struct tm. When the AIX
     1256            # bsd library is used, the timezone global and the gettimeofday
     1257            # methods are to be avoided for timezone deduction instead, we
     1258            # deduce the timezone by comparing the localtime result on a
     1259            # known GMT value.
     1260
     1261            AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
     1262            if test $libbsd = yes; then
     1263                MATH_LIBS="$MATH_LIBS -lbsd"
     1264                AC_DEFINE(USE_DELTA_FOR_TZ, 1, [Do we need a special AIX hack for timezones?])
     1265            fi
     1266            ;;
     1267        BeOS*)
     1268            SHLIB_CFLAGS="-fPIC"
     1269            SHLIB_LD="${CC} -nostart"
    6131270            SHLIB_LD_LIBS='${LIBS}'
    6141271            SHLIB_SUFFIX=".so"
    6151272            DL_OBJS="tclLoadDl.o"
    6161273            DL_LIBS="-ldl"
    617             LDFLAGS=""
    618             LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
    619             TCL_NEEDS_EXP_FILE=1
    620             TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
    621             ;;
    622         AIX-*)
    623             SHLIB_CFLAGS=""
    624             SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512"
    625             SHLIB_LD_LIBS='${LIBS}'
    626             SHLIB_SUFFIX=".so"
    627             DL_OBJS="tclLoadDl.o"
    628             LIBOBJS="$LIBOBJS tclLoadAix.o"
    629             DL_LIBS="-lld"
    630             LDFLAGS=""
    631             LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
    632             TCL_NEEDS_EXP_FILE=1
    633             TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
     1274
     1275            #-----------------------------------------------------------
     1276            # Check for inet_ntoa in -lbind, for BeOS (which also needs
     1277            # -lsocket, even if the network functions are in -lnet which
     1278            # is always linked to, for compatibility.
     1279            #-----------------------------------------------------------
     1280            AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"])
    6341281            ;;
    6351282        BSD/OS-2.1*|BSD/OS-3*)
     
    6401287            DL_OBJS="tclLoadDl.o"
    6411288            DL_LIBS="-ldl"
    642             LDFLAGS=""
     1289            CC_SEARCH_FLAGS=""
    6431290            LD_SEARCH_FLAGS=""
    6441291            ;;
     
    6501297            DL_OBJS="tclLoadDl.o"
    6511298            DL_LIBS="-ldl"
    652             LDFLAGS="-export-dynamic"
     1299            LDFLAGS="$LDFLAGS -export-dynamic"
     1300            CC_SEARCH_FLAGS=""
    6531301            LD_SEARCH_FLAGS=""
    654             ;;
    655         *win32*|*WIN32*|CYGWIN_NT*|cygwin_nt*)
    656             CFLAGS_DEBUG="-nologo -Z7 -Od -WX ${runtime}d"
    657             CFLAGS_OPTIMIZE="-nologo -Oti -Gs -GD ${runtime}"
    658             LDFLAGS_CONSOLE="-subsystem:console"
    659             LDFLAGS_WINDOW="-subsystem:windows"
    660             LDFLAGS_DEBUG="-debug:full -debugtype:cv"
    661             LDFLAGS_OPTIMIZE="-release"
    662             EXTRA_CFLAGS="-YX"
    663             PATHTYPE=-w
    664             STLIB_LD="lib -nologo"
    665             SHLIB_LD="link -dll -nologo"
    666             SHLIB_LD_LIBS="user32.lib advapi32.lib"
    667             RC="rc"
    6681302            ;;
    6691303        dgux*)
     
    6741308            DL_OBJS="tclLoadDl.o"
    6751309            DL_LIBS="-ldl"
    676             LDFLAGS=""
     1310            CC_SEARCH_FLAGS=""
    6771311            LD_SEARCH_FLAGS=""
    6781312            ;;
    679         HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*|HP-UX-*.11.*)
     1313        HP-UX-*.11.*)
     1314            # Use updated header definitions where possible
     1315            AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Do we want to use the XOPEN network library?])
     1316            # Needed by Tcl, but not most extensions
     1317            #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?])
     1318            #LIBS="$LIBS -lxnet"               # Use the XOPEN network library
     1319
     1320            SHLIB_SUFFIX=".sl"
     1321            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
     1322            if test "$tcl_ok" = yes; then
     1323                SHLIB_CFLAGS="+z"
     1324                SHLIB_LD="ld -b"
     1325                SHLIB_LD_LIBS='${LIBS}'
     1326                DL_OBJS="tclLoadShl.o"
     1327                DL_LIBS="-ldld"
     1328                LDFLAGS="$LDFLAGS -Wl,-E"
     1329                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
     1330                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
     1331                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
     1332            fi
     1333            if test "$GCC" = "yes" ; then
     1334                SHLIB_LD="gcc -shared"
     1335                SHLIB_LD_LIBS='${LIBS}'
     1336                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1337            fi
     1338
     1339            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
     1340            #CFLAGS="$CFLAGS +DAportable"
     1341
     1342            # Check to enable 64-bit flags for compiler/linker
     1343            if test "$do64bit" = "yes" ; then
     1344                if test "$GCC" = "yes" ; then
     1345                    hpux_arch=`${CC} -dumpmachine`
     1346                    case $hpux_arch in
     1347                        hppa64*)
     1348                            # 64-bit gcc in use.  Fix flags for GNU ld.
     1349                            do64bit_ok=yes
     1350                            SHLIB_LD="${CC} -shared"
     1351                            SHLIB_LD_LIBS='${LIBS}'
     1352                            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1353                            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1354                            ;;
     1355                        *)
     1356                            AC_MSG_WARN([64bit mode not supported with GCC on $system])
     1357                            ;;
     1358                    esac
     1359                else
     1360                    do64bit_ok=yes
     1361                    CFLAGS="$CFLAGS +DD64"
     1362                    LDFLAGS_ARCH="+DD64"
     1363                fi
     1364            fi
     1365            ;;
     1366        HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
    6801367            SHLIB_SUFFIX=".sl"
    6811368            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
     
    6861373                DL_OBJS="tclLoadShl.o"
    6871374                DL_LIBS="-ldld"
    688                 LDFLAGS="-Wl,-E"
    689                 LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
     1375                LDFLAGS="$LDFLAGS -Wl,-E"
     1376                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
     1377                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
     1378                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
    6901379            fi
    6911380            ;;
    692         IRIX-4.*)
    693             SHLIB_CFLAGS="-G 0"
    694             SHLIB_SUFFIX=".a"
    695             SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
     1381        IRIX-5.*)
     1382            SHLIB_CFLAGS=""
     1383            SHLIB_LD="ld -shared -rdata_shared"
    6961384            SHLIB_LD_LIBS='${LIBS}'
    697             DL_OBJS="tclLoadAout.o"
    698             DL_LIBS=""
    699             LDFLAGS="-Wl,-D,08000000"
    700             LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
    701             SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
    702             ;;
    703         IRIX-5.*|IRIX-6.*|IRIX64-6.5*)
    704             SHLIB_CFLAGS=""
    705             SHLIB_LD="ld -n32 -shared -rdata_shared"
    706             SHLIB_LD_LIBS=""
    7071385            SHLIB_SUFFIX=".so"
    7081386            DL_OBJS="tclLoadDl.o"
    7091387            DL_LIBS=""
    710             LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
    711             if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
    712                 EXTRA_CFLAGS="-mabi=n32"
    713                 LDFLAGS="-mabi=n32"
     1388            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1389            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
     1390            ;;
     1391        IRIX-6.*)
     1392            SHLIB_CFLAGS=""
     1393            SHLIB_LD="ld -n32 -shared -rdata_shared"
     1394            SHLIB_LD_LIBS='${LIBS}'
     1395            SHLIB_SUFFIX=".so"
     1396            DL_OBJS="tclLoadDl.o"
     1397            DL_LIBS=""
     1398            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1399            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
     1400            if test "$GCC" = "yes" ; then
     1401                CFLAGS="$CFLAGS -mabi=n32"
     1402                LDFLAGS="$LDFLAGS -mabi=n32"
    7141403            else
    7151404                case $system in
    7161405                    IRIX-6.3)
    7171406                        # Use to build 6.2 compatible binaries on 6.3.
    718                         EXTRA_CFLAGS="-n32 -D_OLD_TERMIOS"
     1407                        CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS"
    7191408                        ;;
    7201409                    *)
    721                         EXTRA_CFLAGS="-n32"
     1410                        CFLAGS="$CFLAGS -n32"
    7221411                        ;;
    7231412                esac
    724                 LDFLAGS="-n32"
     1413                LDFLAGS="$LDFLAGS -n32"
    7251414            fi
    7261415            ;;
    7271416        IRIX64-6.*)
    7281417            SHLIB_CFLAGS=""
    729             SHLIB_LD="ld -32 -shared -rdata_shared"
     1418            SHLIB_LD="ld -n32 -shared -rdata_shared"
    7301419            SHLIB_LD_LIBS='${LIBS}'
    7311420            SHLIB_SUFFIX=".so"
    7321421            DL_OBJS="tclLoadDl.o"
    7331422            DL_LIBS=""
    734             LDFLAGS=""
    735             LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1423            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1424            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
     1425
     1426            # Check to enable 64-bit flags for compiler/linker
     1427
     1428            if test "$do64bit" = "yes" ; then
     1429                if test "$GCC" = "yes" ; then
     1430                    AC_MSG_WARN([64bit mode not supported by gcc])
     1431                else
     1432                    do64bit_ok=yes
     1433                    SHLIB_LD="ld -64 -shared -rdata_shared"
     1434                    CFLAGS="$CFLAGS -64"
     1435                    LDFLAGS_ARCH="-64"
     1436                fi
     1437            fi
    7361438            ;;
    7371439        Linux*)
     
    7401442            SHLIB_SUFFIX=".so"
    7411443
     1444            CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
    7421445            # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
    7431446            # when you inline the string and math operations.  Turn this off to
    7441447            # get rid of the warnings.
    745 
    746             CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
    747 
    748             if test "$have_dl" = yes; then
    749                 SHLIB_LD="${CC} -shared"
    750                 DL_OBJS="tclLoadDl.o"
    751                 DL_LIBS="-ldl"
    752                 LDFLAGS="-rdynamic"
    753                 LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
    754             else
    755                 AC_CHECK_HEADER(dld.h, [
    756                     SHLIB_LD="ld -shared"
    757                     DL_OBJS="tclLoadDld.o"
    758                     DL_LIBS="-ldld"
    759                     LDFLAGS=""
    760                     LD_SEARCH_FLAGS=""])
    761             fi
     1448            #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
     1449
     1450            SHLIB_LD="${CC} -shared"
     1451            DL_OBJS="tclLoadDl.o"
     1452            DL_LIBS="-ldl"
     1453            LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
     1454            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1455            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
    7621456            if test "`uname -m`" = "alpha" ; then
    763                 EXTRA_CFLAGS="-mieee"
    764             fi
     1457                CFLAGS="$CFLAGS -mieee"
     1458            fi
     1459
     1460            # The combo of gcc + glibc has a bug related
     1461            # to inlining of functions like strtod(). The
     1462            # -fno-builtin flag should address this problem
     1463            # but it does not work. The -fno-inline flag
     1464            # is kind of overkill but it works.
     1465            # Disable inlining only when one of the
     1466            # files in compat/*.c is being linked in.
     1467            if test x"${USE_COMPAT}" != x ; then
     1468                CFLAGS="$CFLAGS -fno-inline"
     1469            fi
     1470
     1471            ;;
     1472        GNU*)
     1473            SHLIB_CFLAGS="-fPIC"
     1474            SHLIB_LD_LIBS='${LIBS}'
     1475            SHLIB_SUFFIX=".so"
     1476
     1477            SHLIB_LD="${CC} -shared"
     1478            DL_OBJS=""
     1479            DL_LIBS="-ldl"
     1480            LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
     1481            CC_SEARCH_FLAGS=""
     1482            LD_SEARCH_FLAGS=""
     1483            if test "`uname -m`" = "alpha" ; then
     1484                CFLAGS="$CFLAGS -mieee"
     1485            fi
     1486            ;;
     1487        Lynx*)
     1488            SHLIB_CFLAGS="-fPIC"
     1489            SHLIB_LD_LIBS='${LIBS}'
     1490            SHLIB_SUFFIX=".so"
     1491            CFLAGS_OPTIMIZE=-02
     1492            SHLIB_LD="${CC} -shared "
     1493            DL_OBJS="tclLoadDl.o"
     1494            DL_LIBS="-mshared -ldl"
     1495            LD_FLAGS="-Wl,--export-dynamic"
     1496            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1497            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
    7651498            ;;
    7661499        MP-RAS-02*)
     
    7711504            DL_OBJS="tclLoadDl.o"
    7721505            DL_LIBS="-ldl"
    773             LDFLAGS=""
     1506            CC_SEARCH_FLAGS=""
    7741507            LD_SEARCH_FLAGS=""
    7751508            ;;
     
    7811514            DL_OBJS="tclLoadDl.o"
    7821515            DL_LIBS="-ldl"
    783             LDFLAGS="-Wl,-Bexport"
     1516            LDFLAGS="$LDFLAGS -Wl,-Bexport"
     1517            CC_SEARCH_FLAGS=""
    7841518            LD_SEARCH_FLAGS=""
    7851519            ;;
    786         NetBSD-*|FreeBSD-[[12]].*|OpenBSD-*)
    787             # Not available on all versions:  check for include file.
    788             AC_CHECK_HEADER(dlfcn.h, [
    789                 SHLIB_CFLAGS="-fpic"
    790                 SHLIB_LD="ld -Bshareable -x"
    791                 SHLIB_LD_LIBS=""
    792                 SHLIB_SUFFIX=".so"
    793                 DL_OBJS="tclLoadDl.o"
    794                 DL_LIBS=""
     1520        NetBSD-*|FreeBSD-[[1-2]].*)
     1521            # NetBSD/SPARC needs -fPIC, -fpic will not do.
     1522            SHLIB_CFLAGS="-fPIC"
     1523            SHLIB_LD="ld -Bshareable -x"
     1524            SHLIB_LD_LIBS='${LIBS}'
     1525            SHLIB_SUFFIX=".so"
     1526            DL_OBJS="tclLoadDl.o"
     1527            DL_LIBS=""
     1528            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1529            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
     1530            AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
     1531                AC_EGREP_CPP(yes, [
     1532#ifdef __ELF__
     1533        yes
     1534#endif
     1535                ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
     1536            if test $tcl_cv_ld_elf = yes; then
     1537                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
     1538            else
     1539                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.1.0'
     1540            fi
     1541
     1542            # Ancient FreeBSD doesn't handle version numbers with dots.
     1543
     1544            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
     1545            TCL_LIB_VERSIONS_OK=nodots
     1546            ;;
     1547        OpenBSD-*)
     1548            # OpenBSD/SPARC[64] needs -fPIC, -fpic will not do.
     1549            case `machine` in
     1550            sparc|sparc64)
     1551                SHLIB_CFLAGS="-fPIC";;
     1552            *)
     1553                SHLIB_CFLAGS="-fpic";;
     1554            esac
     1555            SHLIB_LD="${CC} -shared ${SHLIB_CFLAGS}"
     1556            SHLIB_LD_LIBS='${LIBS}'
     1557            SHLIB_SUFFIX=".so"
     1558            DL_OBJS="tclLoadDl.o"
     1559            DL_LIBS=""
     1560            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1561            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1562            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.1.0'
     1563            AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
     1564                AC_EGREP_CPP(yes, [
     1565#ifdef __ELF__
     1566        yes
     1567#endif
     1568                ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
     1569            if test $tcl_cv_ld_elf = yes; then
     1570                LDFLAGS=-Wl,-export-dynamic
     1571            else
    7951572                LDFLAGS=""
    796                 LD_SEARCH_FLAGS=""
    797                 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
    798             ], [
    799                 SHLIB_CFLAGS=""
    800                 SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
    801                 SHLIB_LD_LIBS='${LIBS}'
    802                 SHLIB_SUFFIX=".a"
    803                 DL_OBJS="tclLoadAout.o"
    804                 DL_LIBS=""
    805                 LDFLAGS=""
    806                 LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
    807                 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
    808             ])
    809 
    810             # FreeBSD doesn't handle version numbers with dots.
    811 
    812             UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
     1573            fi
     1574
     1575            # OpenBSD doesn't do version numbers with dots.
     1576            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
    8131577            TCL_LIB_VERSIONS_OK=nodots
    8141578            ;;
    8151579        FreeBSD-*)
    8161580            # FreeBSD 3.* and greater have ELF.
    817             SHLIB_CFLAGS="-fpic"
     1581            SHLIB_CFLAGS="-fPIC"
    8181582            SHLIB_LD="ld -Bshareable -x"
    819             SHLIB_LD_LIBS=""
     1583            SHLIB_LD_LIBS='${LIBS}'
    8201584            SHLIB_SUFFIX=".so"
    8211585            DL_OBJS="tclLoadDl.o"
    8221586            DL_LIBS=""
    823             LDFLAGS=""
     1587            LDFLAGS="$LDFLAGS -export-dynamic"
     1588            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1589            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
     1590            if test "${TCL_THREADS}" = "1" ; then
     1591                # The -pthread needs to go in the CFLAGS, not LIBS
     1592                LIBS=`echo $LIBS | sed s/-pthread//`
     1593                CFLAGS="$CFLAGS -pthread"
     1594                LDFLAGS="$LDFLAGS -pthread"
     1595            fi
     1596            case $system in
     1597            FreeBSD-3.*)
     1598                # FreeBSD-3 doesn't handle version numbers with dots.
     1599                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
     1600                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
     1601                TCL_LIB_VERSIONS_OK=nodots
     1602                ;;
     1603            esac
     1604            ;;
     1605        Darwin-*)
     1606            CFLAGS_OPTIMIZE="-Os"
     1607            SHLIB_CFLAGS="-fno-common"
     1608            if test $do64bit = yes; then
     1609                do64bit_ok=yes
     1610                CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
     1611            fi
     1612            # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS here:
     1613            SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}'
     1614            AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
     1615                hold_ldflags=$LDFLAGS
     1616                LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
     1617                AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
     1618                LDFLAGS=$hold_ldflags])
     1619            if test $tcl_cv_ld_single_module = yes; then
     1620                SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
     1621            fi
     1622            SHLIB_LD_LIBS='${LIBS}'
     1623            SHLIB_SUFFIX=".dylib"
     1624            DL_OBJS="tclLoadDyld.o"
     1625            DL_LIBS=""
     1626            # Don't use -prebind when building for Mac OS X 10.4 or later only:
     1627            test -z "${MACOSX_DEPLOYMENT_TARGET}" || \
     1628                test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F. '{print [$]2}'`" -lt 4 && \
     1629                LDFLAGS="$LDFLAGS -prebind"
     1630            LDFLAGS="$LDFLAGS -headerpad_max_install_names"
     1631            AC_CACHE_CHECK([if ld accepts -search_paths_first flag], tcl_cv_ld_search_paths_first, [
     1632                hold_ldflags=$LDFLAGS
     1633                LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
     1634                AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, tcl_cv_ld_search_paths_first=no)
     1635                LDFLAGS=$hold_ldflags])
     1636            if test $tcl_cv_ld_search_paths_first = yes; then
     1637                LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
     1638            fi
     1639            CC_SEARCH_FLAGS=""
    8241640            LD_SEARCH_FLAGS=""
     1641            LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
     1642
     1643            # TEA specific: for Tk extensions, remove -arch ppc64 from CFLAGS
     1644            # for fat builds, as neither TkAqua nor TkX11 can be built for 64bit
     1645            # at present (no 64bit GUI libraries).
     1646            test $do64bit_ok = no && test -n "${TK_BIN_DIR}" && \
     1647                CFLAGS="`echo "$CFLAGS" | sed -e 's/-arch ppc64/-arch ppc/g'`"
    8251648            ;;
    8261649        NEXTSTEP-*)
     
    8311654            DL_OBJS="tclLoadNext.o"
    8321655            DL_LIBS=""
    833             LDFLAGS=""
     1656            CC_SEARCH_FLAGS=""
    8341657            LD_SEARCH_FLAGS=""
    8351658            ;;
    8361659        OS/390-*)
    837             CFLAGS_OPTIMIZE=""      # Optimizer is buggy
    838             AC_DEFINE(_OE_SOCKETS)  # needed in sys/socket.h
     1660            CFLAGS_OPTIMIZE=""          # Optimizer is buggy
     1661            AC_DEFINE(_OE_SOCKETS, 1,   # needed in sys/socket.h
     1662                [Should OS/390 do the right thing with sockets?])
    8391663            ;;     
    8401664        OSF1-1.0|OSF1-1.1|OSF1-1.2)
     
    8471671            DL_OBJS="tclLoadOSF.o"
    8481672            DL_LIBS=""
    849             LDFLAGS=""
     1673            CC_SEARCH_FLAGS=""
    8501674            LD_SEARCH_FLAGS=""
    8511675            ;;
    8521676        OSF1-1.*)
    8531677            # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
    854             SHLIB_CFLAGS="-fpic"
    855             SHLIB_LD="ld -shared"
     1678            SHLIB_CFLAGS="-fPIC"
     1679            if test "$SHARED_BUILD" = "1" ; then
     1680                SHLIB_LD="ld -shared"
     1681            else
     1682                SHLIB_LD="ld -non_shared"
     1683            fi
    8561684            SHLIB_LD_LIBS=""
    8571685            SHLIB_SUFFIX=".so"
    8581686            DL_OBJS="tclLoadDl.o"
    8591687            DL_LIBS=""
    860             LDFLAGS=""
     1688            CC_SEARCH_FLAGS=""
    8611689            LD_SEARCH_FLAGS=""
    8621690            ;;
     
    8641692            # Digital OSF/1
    8651693            SHLIB_CFLAGS=""
    866             SHLIB_LD='ld -shared -expect_unresolved "*"'
     1694            if test "$SHARED_BUILD" = "1" ; then
     1695                SHLIB_LD='ld -shared -expect_unresolved "*"'
     1696            else
     1697                SHLIB_LD='ld -non_shared -expect_unresolved "*"'
     1698            fi
    8671699            SHLIB_LD_LIBS=""
    8681700            SHLIB_SUFFIX=".so"
    8691701            DL_OBJS="tclLoadDl.o"
    8701702            DL_LIBS=""
    871             LDFLAGS=""
    872             LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1703            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1704            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
     1705            if test "$GCC" = "yes" ; then
     1706                CFLAGS="$CFLAGS -mieee"
     1707            else
     1708                CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"
     1709            fi
     1710            # see pthread_intro(3) for pthread support on osf1, k.furukawa
     1711            if test "${TCL_THREADS}" = "1" ; then
     1712                CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
     1713                CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
     1714                LIBS=`echo $LIBS | sed s/-lpthreads//`
     1715                if test "$GCC" = "yes" ; then
     1716                    LIBS="$LIBS -lpthread -lmach -lexc"
     1717                else
     1718                    CFLAGS="$CFLAGS -pthread"
     1719                    LDFLAGS="$LDFLAGS -pthread"
     1720                fi
     1721            fi
     1722
    8731723            ;;
    874         RISCos-*)
    875             SHLIB_CFLAGS="-G 0"
    876             SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
    877             SHLIB_LD_LIBS='${LIBS}'
    878             SHLIB_SUFFIX=".a"
    879             DL_OBJS="tclLoadAout.o"
     1724        QNX-6*)
     1725            # QNX RTP
     1726            # This may work for all QNX, but it was only reported for v6.
     1727            SHLIB_CFLAGS="-fPIC"
     1728            SHLIB_LD="ld -Bshareable -x"
     1729            SHLIB_LD_LIBS=""
     1730            SHLIB_SUFFIX=".so"
     1731            DL_OBJS="tclLoadDl.o"
     1732            # dlopen is in -lc on QNX
    8801733            DL_LIBS=""
    881             LDFLAGS="-Wl,-D,08000000"
    882             LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1734            CC_SEARCH_FLAGS=""
     1735            LD_SEARCH_FLAGS=""
    8831736            ;;
    8841737        SCO_SV-3.2*)
    885             # Note, dlopen is available only on SCO 3.2.5 and greater.  However,
     1738            # Note, dlopen is available only on SCO 3.2.5 and greater. However,
    8861739            # this test works, since "uname -s" was non-standard in 3.2.4 and
    8871740            # below.
    888             SHLIB_CFLAGS="-Kpic -belf"
     1741            if test "$GCC" = "yes" ; then
     1742                SHLIB_CFLAGS="-fPIC -melf"
     1743                LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
     1744            else
     1745                SHLIB_CFLAGS="-Kpic -belf"
     1746                LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
     1747            fi
    8891748            SHLIB_LD="ld -G"
    8901749            SHLIB_LD_LIBS=""
     
    8921751            DL_OBJS="tclLoadDl.o"
    8931752            DL_LIBS=""
    894             LDFLAGS="-belf -Wl,-Bexport"
     1753            CC_SEARCH_FLAGS=""
    8951754            LD_SEARCH_FLAGS=""
    8961755            ;;
     
    9021761            DL_OBJS="tclLoadDl.o"
    9031762            DL_LIBS="-ldl"
    904             LDFLAGS=""
     1763            CC_SEARCH_FLAGS=""
    9051764            LD_SEARCH_FLAGS=""
    9061765            ;;
     
    9121771            DL_OBJS="tclLoadDl.o"
    9131772            DL_LIBS="-ldl"
    914             LDFLAGS=""
    915             LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1773            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1774            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
    9161775
    9171776            # SunOS can't handle version numbers with dots in them in library
     
    9201779            # So, the library has to have a name like libtcl75.so.1.0
    9211780
    922             SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
    923             UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
     1781            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.1.0'
     1782            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
    9241783            TCL_LIB_VERSIONS_OK=nodots
    9251784            ;;
    926         SunOS-5.[[0-6]]*)
     1785        SunOS-5.[[0-6]])
     1786            # Careful to not let 5.10+ fall into this case
     1787
     1788            # Note: If _REENTRANT isn't defined, then Solaris
     1789            # won't define thread-safe library routines.
     1790
     1791            AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
     1792            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
     1793                [Do we really want to follow the standard? Yes we do!])
     1794
    9271795            SHLIB_CFLAGS="-KPIC"
    928             SHLIB_LD="/usr/ccs/bin/ld -G -z text"
    9291796
    9301797            # Note: need the LIBS below, otherwise Tk won't find Tcl's
     
    9351802            DL_OBJS="tclLoadDl.o"
    9361803            DL_LIBS="-ldl"
    937             LDFLAGS=""
    938             LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
     1804            if test "$GCC" = "yes" ; then
     1805                SHLIB_LD="$CC -shared"
     1806                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
     1807                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1808            else
     1809                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
     1810                CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
     1811                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1812            fi
    9391813            ;;
    9401814        SunOS-5*)
     1815            # Note: If _REENTRANT isn't defined, then Solaris
     1816            # won't define thread-safe library routines.
     1817
     1818            AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
     1819            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
     1820                [Do we really want to follow the standard? Yes we do!])
     1821
    9411822            SHLIB_CFLAGS="-KPIC"
    942             SHLIB_LD="/usr/ccs/bin/ld -G -z text"
    943             LDFLAGS=""
    944    
    945             do64bit_ok=no
     1823
     1824            # Check to enable 64-bit flags for compiler/linker
    9461825            if test "$do64bit" = "yes" ; then
    947             arch=`isainfo`
    948             if test "$arch" = "sparcv9 sparc" ; then
    949                 if test "$CC" != "gcc" -a `$CC -v 2>&1 | grep -c gcc` = "0" ; then
    950                 do64bit_ok=yes
    951                 EXTRA_CFLAGS="-xarch=v9"
    952                 LDFLAGS="-xarch=v9"
    953                 else
    954                 AC_MSG_WARN("64bit mode not supported using GCC on $system")
     1826                arch=`isainfo`
     1827                if test "$arch" = "sparcv9 sparc" ; then
     1828                        if test "$GCC" = "yes" ; then
     1829                            if test "`gcc -dumpversion | awk -F. '{print [$]1}'`" -lt "3" ; then
     1830                                AC_MSG_WARN([64bit mode not supported with GCC < 3.2 on $system])
     1831                            else
     1832                                do64bit_ok=yes
     1833                                CFLAGS="$CFLAGS -m64 -mcpu=v9"
     1834                                LDFLAGS="$LDFLAGS -m64 -mcpu=v9"
     1835                                SHLIB_CFLAGS="-fPIC"
     1836                            fi
     1837                        else
     1838                            do64bit_ok=yes
     1839                            if test "$do64bitVIS" = "yes" ; then
     1840                                CFLAGS="$CFLAGS -xarch=v9a"
     1841                                LDFLAGS_ARCH="-xarch=v9a"
     1842                            else
     1843                                CFLAGS="$CFLAGS -xarch=v9"
     1844                                LDFLAGS_ARCH="-xarch=v9"
     1845                            fi
     1846                            # Solaris 64 uses this as well
     1847                            #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
     1848                        fi
     1849                elif test "$arch" = "amd64 i386" ; then
     1850                    if test "$GCC" = "yes" ; then
     1851                        AC_MSG_WARN([64bit mode not supported with GCC on $system])
     1852                    else
     1853                        do64bit_ok=yes
     1854                        CFLAGS="$CFLAGS -xarch=amd64"
     1855                        LDFLAGS="$LDFLAGS -xarch=amd64"
     1856                    fi
     1857                else
     1858                    AC_MSG_WARN([64bit mode not supported for $arch])
    9551859                fi
    956             else
    957                 AC_MSG_WARN("64bit mode only supported sparcv9 system")
    958             fi
    9591860            fi
    9601861           
     
    9661867            DL_OBJS="tclLoadDl.o"
    9671868            DL_LIBS="-ldl"
    968             if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
    969                 LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
     1869            if test "$GCC" = "yes" ; then
     1870                SHLIB_LD="$CC -shared"
     1871                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
     1872                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1873                if test "$do64bit_ok" = "yes" ; then
     1874                    # We need to specify -static-libgcc or we need to
     1875                    # add the path to the sparv9 libgcc.
     1876                    # JH: static-libgcc is necessary for core Tcl, but may
     1877                    # not be necessary for extensions.
     1878                    SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
     1879                    # for finding sparcv9 libgcc, get the regular libgcc
     1880                    # path, remove so name and append 'sparcv9'
     1881                    #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..."
     1882                    #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir"
     1883                fi
    9701884            else
     1885                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
     1886                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
    9711887                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
    9721888            fi
    973             ;;
    974         ULTRIX-4.*)
    975             SHLIB_CFLAGS="-G 0"
    976             SHLIB_SUFFIX=".a"
    977             SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
    978             SHLIB_LD_LIBS='${LIBS}'
    979             DL_OBJS="tclLoadAout.o"
    980             DL_LIBS=""
    981             LDFLAGS="-Wl,-D,08000000"
    982             LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
    9831889            ;;
    9841890        UNIX_SV* | UnixWare-5*)
     
    9911897            # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
    9921898            # that don't grok the -Bexport option.  Test that it does.
    993             hold_ldflags=$LDFLAGS
    994             AC_MSG_CHECKING(for ld accepts -Bexport flag)
    995             LDFLAGS="${LDFLAGS} -Wl,-Bexport"
    996             AC_TRY_LINK(, [int i;], found=yes, found=no)
    997             LDFLAGS=$hold_ldflags
    998             AC_MSG_RESULT($found)
    999             if test $found = yes; then
    1000             LDFLAGS="-Wl,-Bexport"
    1001             else
    1002             LDFLAGS=""
    1003             fi
     1899            AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [
     1900                hold_ldflags=$LDFLAGS
     1901                LDFLAGS="$LDFLAGS -Wl,-Bexport"
     1902                AC_TRY_LINK(, [int i;], tcl_cv_ld_Bexport=yes, tcl_cv_ld_Bexport=no)
     1903                LDFLAGS=$hold_ldflags])
     1904            if test $tcl_cv_ld_Bexport = yes; then
     1905                LDFLAGS="$LDFLAGS -Wl,-Bexport"
     1906            fi
     1907            CC_SEARCH_FLAGS=""
    10041908            LD_SEARCH_FLAGS=""
    10051909            ;;
     
    10071911
    10081912    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
    1009     AC_MSG_WARN("64bit support being disabled -- not supported on this platform")
    1010     fi
    1011 
    1012     # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
    1013     # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
    1014     # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
    1015     # to determine which of several header files defines the a.out file
    1016     # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
    1017     # support only a file format that is more or less version-7-compatible.
    1018     # In particular,
    1019     #   - a.out files must begin with `struct exec'.
    1020     #   - the N_TXTOFF on the `struct exec' must compute the seek address
    1021     #     of the text segment
    1022     #   - The `struct exec' must contain a_magic, a_text, a_data, a_bss
    1023     #     and a_entry fields.
    1024     # The following compilation should succeed if and only if either sys/exec.h
    1025     # or a.out.h is usable for the purpose.
    1026     #
    1027     # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
    1028     # `struct exec' includes a second header that contains information that
    1029     # duplicates the v7 fields that are needed.
    1030 
    1031     if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
    1032         AC_MSG_CHECKING(sys/exec.h)
    1033         AC_TRY_COMPILE([#include <sys/exec.h>],[
    1034             struct exec foo;
    1035             unsigned long seek;
    1036             int flag;
    1037 #if defined(__mips) || defined(mips)
    1038             seek = N_TXTOFF (foo.ex_f, foo.ex_o);
    1039 #else
    1040             seek = N_TXTOFF (foo);
    1041 #endif
    1042             flag = (foo.a_magic == OMAGIC);
    1043             return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
    1044     ], tcl_ok=usable, tcl_ok=unusable)
    1045         AC_MSG_RESULT($tcl_ok)
    1046         if test $tcl_ok = usable; then
    1047             AC_DEFINE(USE_SYS_EXEC_H)
    1048         else
    1049             AC_MSG_CHECKING(a.out.h)
    1050             AC_TRY_COMPILE([#include <a.out.h>],[
    1051                 struct exec foo;
    1052                 unsigned long seek;
    1053                 int flag;
    1054 #if defined(__mips) || defined(mips)
    1055                 seek = N_TXTOFF (foo.ex_f, foo.ex_o);
    1056 #else
    1057                 seek = N_TXTOFF (foo);
    1058 #endif
    1059                 flag = (foo.a_magic == OMAGIC);
    1060                 return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
    1061             ], tcl_ok=usable, tcl_ok=unusable)
    1062             AC_MSG_RESULT($tcl_ok)
    1063             if test $tcl_ok = usable; then
    1064                 AC_DEFINE(USE_A_OUT_H)
    1065             else
    1066                 AC_MSG_CHECKING(sys/exec_aout.h)
    1067                 AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
    1068                     struct exec foo;
    1069                     unsigned long seek;
    1070                     int flag;
    1071 #if defined(__mips) || defined(mips)
    1072                     seek = N_TXTOFF (foo.ex_f, foo.ex_o);
    1073 #else
    1074                     seek = N_TXTOFF (foo);
    1075 #endif
    1076                     flag = (foo.a_midmag == OMAGIC);
    1077                     return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
    1078                 ], tcl_ok=usable, tcl_ok=unusable)
    1079                 AC_MSG_RESULT($tcl_ok)
    1080                 if test $tcl_ok = usable; then
    1081                     AC_DEFINE(USE_SYS_EXEC_AOUT_H)
    1082                 else
    1083                     DL_OBJS=""
    1084                 fi
    1085             fi
    1086         fi
    1087     fi
    1088 
    1089     # Step 5: disable dynamic loading if requested via a command-line switch.
    1090 
    1091     AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
     1913        AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform])
     1914    fi
     1915
     1916    # Step 4: disable dynamic loading if requested via a command-line switch.
     1917
     1918    AC_ARG_ENABLE(load,
     1919        AC_HELP_STRING([--disable-load],
     1920            [disallow dynamic loading and "load" command (default: enabled)]),
    10921921        [tcl_ok=$enableval], [tcl_ok=yes])
    10931922    if test "$tcl_ok" = "no"; then
     
    11051934        DL_OBJS="tclLoadNone.o"
    11061935        DL_LIBS=""
    1107         LDFLAGS=""
     1936        LDFLAGS="$LDFLAGS_ORIG"
     1937        CC_SEARCH_FLAGS=""
    11081938        LD_SEARCH_FLAGS=""
    11091939        BUILD_DLTEST=""
    11101940    fi
     1941    LDFLAGS="$LDFLAGS $LDFLAGS_ARCH"
    11111942
    11121943    # If we're running gcc, then change the C flags for compiling shared
     
    11151946
    11161947    if test "$DL_OBJS" != "tclLoadNone.o" ; then
    1117         if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
     1948        if test "$GCC" = "yes" ; then
    11181949            case $system in
    11191950                AIX-*)
     
    11231954                IRIX*)
    11241955                    ;;
    1125                 NetBSD-*|FreeBSD-*|OpenBSD-*)
     1956                NetBSD-*|FreeBSD-*)
    11261957                    ;;
    1127                 RISCos-*)
     1958                Darwin-*)
    11281959                    ;;
    1129                 ULTRIX-4.*)
     1960                SCO_SV-3.2*)
     1961                    ;;
     1962                windows)
    11301963                    ;;
    11311964                *)
     
    11371970
    11381971    if test "$SHARED_LIB_SUFFIX" = "" ; then
    1139         SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
     1972        SHARED_LIB_SUFFIX='${PACKAGE_VERSION}${SHLIB_SUFFIX}'
    11401973    fi
    11411974    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
    1142         UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
    1143     fi
     1975        UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}.a'
     1976    fi
     1977
     1978    AC_SUBST(DL_LIBS)
     1979
     1980    AC_SUBST(CFLAGS_DEBUG)
     1981    AC_SUBST(CFLAGS_OPTIMIZE)
     1982    AC_SUBST(CFLAGS_WARNING)
    11441983
    11451984    AC_SUBST(STLIB_LD)
    11461985    AC_SUBST(SHLIB_LD)
     1986
     1987    AC_SUBST(SHLIB_LD_LIBS)
    11471988    AC_SUBST(SHLIB_CFLAGS)
    1148     AC_SUBST(SHLIB_LDFLAGS)
    1149     AC_SUBST(DL_LIBS)
    1150     AC_SUBST(CFLAGS_DEBUG)
    1151     AC_SUBST(CFLAGS_OPTIMIZE)
    1152     AC_SUBST(LDFLAGS_DEBUG)
    1153     AC_SUBST(LDFLAGS_OPTIMIZE)
     1989
     1990    AC_SUBST(LD_LIBRARY_PATH_VAR)
     1991
     1992    # These must be called after we do the basic CFLAGS checks and
     1993    # verify any possible 64-bit or similar switches are necessary
     1994    TEA_TCL_EARLY_FLAGS
     1995    TEA_TCL_64BIT_FLAGS
    11541996])
    11551997
    11561998#--------------------------------------------------------------------
    1157 # SC_SERIAL_PORT
     1999# TEA_SERIAL_PORT
    11582000#
    11592001#       Determine which interface to use to talk to the serial port.
    11602002#       Note that #include lines must begin in leftmost column for
    1161 #       some compilers to recognize them as preprocessor directives.
     2003#       some compilers to recognize them as preprocessor directives,
     2004#       and some build environments have stdin not pointing at a
     2005#       pseudo-terminal (usually /dev/null instead.)
    11622006#
    11632007# Arguments:
     
    11672011#
    11682012#       Defines only one of the following vars:
     2013#               HAVE_SYS_MODEM_H
    11692014#               USE_TERMIOS
    11702015#               USE_TERMIO
     
    11732018#--------------------------------------------------------------------
    11742019
    1175 AC_DEFUN(SC_SERIAL_PORT, [
    1176     AC_MSG_CHECKING([termios vs. termio vs. sgtty])
    1177 
     2020AC_DEFUN([TEA_SERIAL_PORT], [
     2021    AC_CHECK_HEADERS(sys/modem.h)
     2022    AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
    11782023    AC_TRY_RUN([
    11792024#include <termios.h>
    11802025
    1181 main()
    1182 {
     2026int main() {
    11832027    struct termios t;
    11842028    if (tcgetattr(0, &t) == 0) {
     
    11882032    }
    11892033    return 1;
    1190 }], tk_ok=termios, tk_ok=no, tk_ok=no)
    1191 
    1192     if test $tk_ok = termios; then
    1193         AC_DEFINE(USE_TERMIOS)
    1194     else
     2034}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
     2035    if test $tcl_cv_api_serial = no ; then
    11952036        AC_TRY_RUN([
    11962037#include <termio.h>
    11972038
    1198 main()
    1199 {
     2039int main() {
    12002040    struct termio t;
    12012041    if (ioctl(0, TCGETA, &t) == 0) {
     
    12042044    }
    12052045    return 1;
    1206     }], tk_ok=termio, tk_ok=no, tk_ok=no)
    1207 
    1208     if test $tk_ok = termio; then
    1209         AC_DEFINE(USE_TERMIO)
    1210     else
     2046}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
     2047    fi
     2048    if test $tcl_cv_api_serial = no ; then
    12112049        AC_TRY_RUN([
    12122050#include <sgtty.h>
    12132051
    1214 main()
    1215 {
     2052int main() {
    12162053    struct sgttyb t;
    12172054    if (ioctl(0, TIOCGETP, &t) == 0) {
     
    12212058    }
    12222059    return 1;
    1223 }], tk_ok=sgtty, tk_ok=none, tk_ok=none)
    1224     if test $tk_ok = sgtty; then
    1225         AC_DEFINE(USE_SGTTY)
    1226     fi
    1227     fi
    1228     fi
    1229     AC_MSG_RESULT($tk_ok)
     2060}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
     2061    fi
     2062    if test $tcl_cv_api_serial = no ; then
     2063        AC_TRY_RUN([
     2064#include <termios.h>
     2065#include <errno.h>
     2066
     2067int main() {
     2068    struct termios t;
     2069    if (tcgetattr(0, &t) == 0
     2070        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
     2071        cfsetospeed(&t, 0);
     2072        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
     2073        return 0;
     2074    }
     2075    return 1;
     2076}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
     2077    fi
     2078    if test $tcl_cv_api_serial = no; then
     2079        AC_TRY_RUN([
     2080#include <termio.h>
     2081#include <errno.h>
     2082
     2083int main() {
     2084    struct termio t;
     2085    if (ioctl(0, TCGETA, &t) == 0
     2086        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
     2087        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
     2088        return 0;
     2089    }
     2090    return 1;
     2091    }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
     2092    fi
     2093    if test $tcl_cv_api_serial = no; then
     2094        AC_TRY_RUN([
     2095#include <sgtty.h>
     2096#include <errno.h>
     2097
     2098int main() {
     2099    struct sgttyb t;
     2100    if (ioctl(0, TIOCGETP, &t) == 0
     2101        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
     2102        t.sg_ospeed = 0;
     2103        t.sg_flags |= ODDP | EVENP | RAW;
     2104        return 0;
     2105    }
     2106    return 1;
     2107}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
     2108    fi])
     2109    case $tcl_cv_api_serial in
     2110        termios) AC_DEFINE(USE_TERMIOS, 1, [Use the termios API for serial lines]);;
     2111        termio)  AC_DEFINE(USE_TERMIO, 1, [Use the termio API for serial lines]);;
     2112        sgtty)   AC_DEFINE(USE_SGTTY, 1, [Use the sgtty API for serial lines]);;
     2113    esac
    12302114])
    12312115
    12322116#--------------------------------------------------------------------
    1233 # SC_MISSING_POSIX_HEADERS
     2117# TEA_MISSING_POSIX_HEADERS
    12342118#
    12352119#       Supply substitutes for missing POSIX header files.  Special
     
    12492133#               NO_ERRNO_H
    12502134#               NO_VALUES_H
    1251 #               NO_LIMITS_H
     2135#               HAVE_LIMITS_H or NO_LIMITS_H
    12522136#               NO_STDLIB_H
    12532137#               NO_STRING_H
    12542138#               NO_SYS_WAIT_H
    12552139#               NO_DLFCN_H
    1256 #               HAVE_UNISTD_H
    12572140#               HAVE_SYS_PARAM_H
    12582141#
    12592142#               HAVE_STRING_H ?
    12602143#
     2144# tkUnixPort.h checks for HAVE_LIMITS_H, so do both HAVE and
     2145# CHECK on limits.h
    12612146#--------------------------------------------------------------------
    12622147
    1263 AC_DEFUN(SC_MISSING_POSIX_HEADERS, [
    1264 
    1265     AC_MSG_CHECKING(dirent.h)
     2148AC_DEFUN([TEA_MISSING_POSIX_HEADERS], [
     2149    AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h,
    12662150    AC_TRY_LINK([#include <sys/types.h>
    12672151#include <dirent.h>], [
     
    12832167p = entryPtr->d_name;
    12842168closedir(d);
    1285 ], tcl_ok=yes, tcl_ok=no)
    1286 
    1287     if test $tcl_ok = no; then
    1288         AC_DEFINE(NO_DIRENT_H)
    1289     fi
    1290 
    1291     AC_MSG_RESULT($tcl_ok)
    1292     AC_CHECK_HEADER(errno.h, , AC_DEFINE(NO_ERRNO_H))
    1293     AC_CHECK_HEADER(float.h, , AC_DEFINE(NO_FLOAT_H))
    1294     AC_CHECK_HEADER(values.h, , AC_DEFINE(NO_VALUES_H))
    1295     AC_CHECK_HEADER(limits.h, , AC_DEFINE(NO_LIMITS_H))
     2169], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no))
     2170
     2171    if test $tcl_cv_dirent_h = no; then
     2172        AC_DEFINE(NO_DIRENT_H, 1, [Do we have <dirent.h>?])
     2173    fi
     2174
     2175    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H, 1, [Do we have <errno.h>?])])
     2176    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H, 1, [Do we have <float.h>?])])
     2177    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H, 1, [Do we have <values.h>?])])
     2178    AC_CHECK_HEADER(limits.h,
     2179        [AC_DEFINE(HAVE_LIMITS_H, 1, [Do we have <limits.h>?])],
     2180        [AC_DEFINE(NO_LIMITS_H, 1, [Do we have <limits.h>?])])
    12962181    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
    12972182    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
     
    12992184    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
    13002185    if test $tcl_ok = 0; then
    1301         AC_DEFINE(NO_STDLIB_H)
     2186        AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?])
    13022187    fi
    13032188    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
     
    13092194
    13102195    if test $tcl_ok = 0; then
    1311         AC_DEFINE(NO_STRING_H)
    1312     fi
    1313 
    1314     AC_CHECK_HEADER(sys/wait.h, , AC_DEFINE(NO_SYS_WAIT_H))
    1315     AC_CHECK_HEADER(dlfcn.h, , AC_DEFINE(NO_DLFCN_H))
     2196        AC_DEFINE(NO_STRING_H, 1, [Do we have <string.h>?])
     2197    fi
     2198
     2199    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H, 1, [Do we have <sys/wait.h>?])])
     2200    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H, 1, [Do we have <dlfcn.h>?])])
    13162201
    13172202    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
    1318 
    1319     AC_HAVE_HEADERS(unistd.h sys/param.h)
    1320 
     2203    AC_HAVE_HEADERS(sys/param.h)
    13212204])
    13222205
    13232206#--------------------------------------------------------------------
    1324 # SC_PATH_X
     2207# TEA_PATH_X
    13252208#
    13262209#       Locate the X11 header files and the X11 library archive.  Try
     
    13312214#       no include files, so double-check its result just to be safe.
    13322215#
     2216#       This should be called after TEA_CONFIG_CFLAGS as setting the
     2217#       LIBS line can confuse some configure macro magic.
     2218#
    13332219# Arguments:
    13342220#       none
     
    13362222# Results:
    13372223#
    1338 #       Sets the the following vars:
     2224#       Sets the following vars:
    13392225#               XINCLUDES
    13402226#               XLIBSW
     2227#               PKG_LIBS (appends to)
    13412228#
    13422229#--------------------------------------------------------------------
    13432230
    1344 AC_DEFUN(SC_PATH_X, [
     2231AC_DEFUN([TEA_PATH_X], [
     2232    if test "${TEA_WINDOWINGSYSTEM}" = "x11" ; then
     2233        TEA_PATH_UNIX_X
     2234    fi
     2235])
     2236
     2237AC_DEFUN([TEA_PATH_UNIX_X], [
    13452238    AC_PATH_X
    13462239    not_really_there=""
     
    13552248    fi
    13562249    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
    1357         AC_MSG_CHECKING(for X11 header files)
    1358         XINCLUDES="# no special path needed"
    1359         AC_TRY_CPP([#include <X11/Intrinsic.h>], , XINCLUDES="nope")
    1360         if test "$XINCLUDES" = nope; then
     2250        AC_MSG_CHECKING([for X11 header files])
     2251        found_xincludes="no"
     2252        AC_TRY_CPP([#include <X11/Intrinsic.h>], found_xincludes="yes", found_xincludes="no")
     2253        if test "$found_xincludes" = "no"; then
    13612254            dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/X11R6/include /usr/X11R5/include /usr/include/X11R5 /usr/include/X11R4 /usr/openwin/include /usr/X11/include /usr/sww/include"
    13622255            for i in $dirs ; do
    13632256                if test -r $i/X11/Intrinsic.h; then
    1364                     AC_MSG_RESULT($i)
     2257                    AC_MSG_RESULT([$i])
    13652258                    XINCLUDES=" -I$i"
     2259                    found_xincludes="yes"
    13662260                    break
    13672261                fi
     
    13702264    else
    13712265        if test "$x_includes" != ""; then
    1372             XINCLUDES=-I$x_includes
    1373         else
    1374             XINCLUDES="# no special path needed"
     2266            XINCLUDES="-I$x_includes"
     2267            found_xincludes="yes"
    13752268        fi
    13762269    fi
    1377     if test "$XINCLUDES" = nope; then
    1378         AC_MSG_RESULT(couldn't find any!)
    1379         XINCLUDES="# no include files found"
     2270    if test found_xincludes = "no"; then
     2271        AC_MSG_RESULT([couldn't find any!])
    13802272    fi
    13812273
    13822274    if test "$no_x" = yes; then
    1383         AC_MSG_CHECKING(for X11 libraries)
     2275        AC_MSG_CHECKING([for X11 libraries])
    13842276        XLIBSW=nope
    13852277        dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/X11R6/lib /usr/X11R5/lib /usr/lib/X11R5 /usr/lib/X11R4 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib"
    13862278        for i in $dirs ; do
    13872279            if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
    1388                 AC_MSG_RESULT($i)
     2280                AC_MSG_RESULT([$i])
    13892281                XLIBSW="-L$i -lX11"
    13902282                x_libraries="$i"
     
    14032295    fi
    14042296    if test "$XLIBSW" = nope ; then
    1405         AC_MSG_RESULT(couldn't find any!  Using -lX11.)
     2297        AC_MSG_RESULT([could not find any!  Using -lX11.])
    14062298        XLIBSW=-lX11
    14072299    fi
    1408 ])
     2300    if test x"${XLIBSW}" != x ; then
     2301        PKG_LIBS="${PKG_LIBS} ${XLIBSW}"
     2302    fi
     2303])
     2304
    14092305#--------------------------------------------------------------------
    1410 # SC_BLOCKING_STYLE
     2306# TEA_BLOCKING_STYLE
    14112307#
    14122308#       The statements below check for systems where POSIX-style
     
    14282324#--------------------------------------------------------------------
    14292325
    1430 AC_DEFUN(SC_BLOCKING_STYLE, [
     2326AC_DEFUN([TEA_BLOCKING_STYLE], [
    14312327    AC_CHECK_HEADERS(sys/ioctl.h)
    14322328    AC_CHECK_HEADERS(sys/filio.h)
     2329    TEA_CONFIG_SYSTEM
    14332330    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
    1434     if test -f /usr/lib/NextStep/software_version; then
    1435         system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
    1436     else
    1437         system=`uname -s`-`uname -r`
    1438         if test "$?" -ne 0 ; then
    1439             system=unknown
    1440         else
    1441             # Special check for weird MP-RAS system (uname returns weird
    1442             # results, and the version is kept in special file).
    1443        
    1444             if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
    1445                 system=MP-RAS-`awk '{print $3}' /etc/.relid'`
    1446             fi
    1447             if test "`uname -s`" = "AIX" ; then
    1448                 system=AIX-`uname -v`.`uname -r`
    1449             fi
    1450         fi
    1451     fi
    14522331    case $system in
    14532332        # There used to be code here to use FIONBIO under AIX.  However, it
     
    14572336
    14582337        OSF*)
    1459             AC_DEFINE(USE_FIONBIO)
    1460             AC_MSG_RESULT(FIONBIO)
     2338            AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
     2339            AC_MSG_RESULT([FIONBIO])
    14612340            ;;
    14622341        SunOS-4*)
    1463             AC_DEFINE(USE_FIONBIO)
    1464             AC_MSG_RESULT(FIONBIO)
    1465             ;;
    1466         ULTRIX-4.*)
    1467             AC_DEFINE(USE_FIONBIO)
    1468             AC_MSG_RESULT(FIONBIO)
     2342            AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
     2343            AC_MSG_RESULT([FIONBIO])
    14692344            ;;
    14702345        *)
    1471             AC_MSG_RESULT(O_NONBLOCK)
     2346            AC_MSG_RESULT([O_NONBLOCK])
    14722347            ;;
    14732348    esac
     
    14752350
    14762351#--------------------------------------------------------------------
    1477 # SC_HAVE_VFORK
    1478 #
    1479 #       Check to see whether the system provides a vfork kernel call.
    1480 #       If not, then use fork instead.  Also, check for a problem with
    1481 #       vforks and signals that can cause core dumps if a vforked child
    1482 #       resets a signal handler.  If the problem exists, then use fork
    1483 #       instead of vfork.
    1484 #
    1485 # Arguments:
    1486 #       none
    1487 #       
    1488 # Results:
    1489 #
    1490 #       Defines some of the following vars:
    1491 #               vfork (=fork)
    1492 #
    1493 #--------------------------------------------------------------------
    1494 
    1495 AC_DEFUN(SC_HAVE_VFORK, [
    1496     AC_TYPE_SIGNAL()
    1497     AC_CHECK_FUNC(vfork, tcl_ok=1, tcl_ok=0)
    1498     if test "$tcl_ok" = 1; then
    1499         AC_MSG_CHECKING([vfork/signal bug]);
    1500         AC_TRY_RUN([
    1501 #include <stdio.h>
    1502 #include <signal.h>
    1503 #include <sys/wait.h>
    1504 int gotSignal = 0;
    1505 sigProc(sig)
    1506     int sig;
    1507 {
    1508     gotSignal = 1;
    1509 }
    1510 main()
    1511 {
    1512     int pid, sts;
    1513     (void) signal(SIGCHLD, sigProc);
    1514     pid = vfork();
    1515     if (pid <  0) {
    1516         exit(1);
    1517     } else if (pid == 0) {
    1518         (void) signal(SIGCHLD, SIG_DFL);
    1519         _exit(0);
    1520     } else {
    1521         (void) wait(&sts);
    1522     }
    1523     exit((gotSignal) ? 0 : 1);
    1524 }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
    1525 
    1526         if test "$tcl_ok" = 1; then
    1527             AC_MSG_RESULT(ok)
    1528         else
    1529             AC_MSG_RESULT([buggy, using fork instead])
    1530         fi
    1531     fi
    1532     rm -f core
    1533     if test "$tcl_ok" = 0; then
    1534         AC_DEFINE(vfork, fork)
    1535     fi
    1536 ])
    1537 
    1538 #--------------------------------------------------------------------
    1539 # SC_TIME_HANLDER
     2352# TEA_TIME_HANLDER
    15402353#
    15412354#       Checks how the system deals with time.h, what time structures
     
    15552368#--------------------------------------------------------------------
    15562369
    1557 AC_DEFUN(SC_TIME_HANDLER, [
     2370AC_DEFUN([TEA_TIME_HANDLER], [
    15582371    AC_CHECK_HEADERS(sys/time.h)
    15592372    AC_HEADER_TIME
    15602373    AC_STRUCT_TIMEZONE
    15612374
    1562     AC_MSG_CHECKING([tm_tzadj in struct tm])
    1563     AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
    1564             [AC_DEFINE(HAVE_TM_TZADJ)
    1565             AC_MSG_RESULT(yes)],
    1566             AC_MSG_RESULT(no))
    1567 
    1568     AC_MSG_CHECKING([tm_gmtoff in struct tm])
    1569     AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
    1570             [AC_DEFINE(HAVE_TM_GMTOFF)
    1571             AC_MSG_RESULT(yes)],
    1572             AC_MSG_RESULT(no))
     2375    AC_CHECK_FUNCS(gmtime_r localtime_r)
     2376
     2377    AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj,
     2378        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
     2379            tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no))
     2380    if test $tcl_cv_member_tm_tzadj = yes ; then
     2381        AC_DEFINE(HAVE_TM_TZADJ, 1, [Should we use the tm_tzadj field of struct tm?])
     2382    fi
     2383
     2384    AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff,
     2385        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
     2386            tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no))
     2387    if test $tcl_cv_member_tm_gmtoff = yes ; then
     2388        AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?])
     2389    fi
    15732390
    15742391    #
     
    15762393    # (like convex) have timezone functions, etc.
    15772394    #
    1578     have_timezone=no
    1579     AC_MSG_CHECKING([long timezone variable])
    1580     AC_TRY_COMPILE([#include <time.h>],
     2395    AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long,
     2396        AC_TRY_COMPILE([#include <time.h>],
    15812397            [extern long timezone;
    15822398            timezone += 1;
    15832399            exit (0);],
    1584             [have_timezone=yes
    1585             AC_DEFINE(HAVE_TIMEZONE_VAR)
    1586             AC_MSG_RESULT(yes)],
    1587             AC_MSG_RESULT(no))
    1588 
    1589     #
    1590     # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
    1591     #
    1592     if test "$have_timezone" = no; then
    1593     AC_MSG_CHECKING([time_t timezone variable])
    1594     AC_TRY_COMPILE([#include <time.h>],
    1595             [extern time_t timezone;
    1596             timezone += 1;
    1597             exit (0);],
    1598             [AC_DEFINE(HAVE_TIMEZONE_VAR)
    1599             AC_MSG_RESULT(yes)],
    1600             AC_MSG_RESULT(no))
    1601     fi
    1602 
    1603     #
    1604     # AIX does not have a timezone field in struct tm. When the AIX bsd
    1605     # library is used, the timezone global and the gettimeofday methods are
    1606     # to be avoided for timezone deduction instead, we deduce the timezone
    1607     # by comparing the localtime result on a known GMT value.
    1608     #
    1609 
    1610     if test "`uname -s`" = "AIX" ; then
    1611         AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes)
    1612         if test $libbsd = yes; then
    1613             AC_DEFINE(USE_DELTA_FOR_TZ)
     2400            tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no))
     2401    if test $tcl_cv_timezone_long = yes ; then
     2402        AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
     2403    else
     2404        #
     2405        # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
     2406        #
     2407        AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time,
     2408            AC_TRY_COMPILE([#include <time.h>],
     2409                [extern time_t timezone;
     2410                timezone += 1;
     2411                exit (0);],
     2412                tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no))
     2413        if test $tcl_cv_timezone_time = yes ; then
     2414            AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
    16142415        fi
    16152416    fi
     
    16172418
    16182419#--------------------------------------------------------------------
    1619 # SC_BUGGY_STRTOD
     2420# TEA_BUGGY_STRTOD
    16202421#
    16212422#       Under Solaris 2.4, strtod returns the wrong value for the
     
    16232424#       and if the problem exists use a substitute procedure
    16242425#       "fixstrtod" (provided by Tcl) that corrects the error.
     2426#       Also, on Compaq's Tru64 Unix 5.0,
     2427#       strtod(" ") returns 0.0 instead of a failure to convert.
    16252428#
    16262429# Arguments:
     
    16342437#--------------------------------------------------------------------
    16352438
    1636 AC_DEFUN(SC_BUGGY_STRTOD, [
    1637     AC_CHECK_FUNC(strtod, tk_strtod=1, tk_strtod=0)
    1638     if test "$tk_strtod" = 1; then
    1639         AC_MSG_CHECKING([for Solaris 2.4 strtod bug])
    1640         AC_TRY_RUN([
    1641             extern double strtod();
    1642             int main()
    1643             {
    1644                 char *string = "NaN";
    1645                 char *term;
    1646                 strtod(string, &term);
    1647                 if ((term != string) && (term[-1] == 0)) {
    1648                     exit(1);
    1649                 }
    1650                 exit(0);
    1651             }], tk_ok=1, tk_ok=0, tk_ok=0)
    1652         if test "$tk_ok" = 1; then
    1653             AC_MSG_RESULT(ok)
    1654         else
    1655             AC_MSG_RESULT(buggy)
    1656             AC_DEFINE(strtod, fixstrtod)
     2439AC_DEFUN([TEA_BUGGY_STRTOD], [
     2440    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
     2441    if test "$tcl_strtod" = 1; then
     2442        AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[
     2443            AC_TRY_RUN([
     2444                extern double strtod();
     2445                int main() {
     2446                    char *infString="Inf", *nanString="NaN", *spaceString=" ";
     2447                    char *term;
     2448                    double value;
     2449                    value = strtod(infString, &term);
     2450                    if ((term != infString) && (term[-1] == 0)) {
     2451                        exit(1);
     2452                    }
     2453                    value = strtod(nanString, &term);
     2454                    if ((term != nanString) && (term[-1] == 0)) {
     2455                        exit(1);
     2456                    }
     2457                    value = strtod(spaceString, &term);
     2458                    if (term == (spaceString+1)) {
     2459                        exit(1);
     2460                    }
     2461                    exit(0);
     2462                }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy,
     2463                    tcl_cv_strtod_buggy=buggy)])
     2464        if test "$tcl_cv_strtod_buggy" = buggy; then
     2465            AC_LIBOBJ([fixstrtod])
     2466            USE_COMPAT=1
     2467            AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?])
    16572468        fi
    16582469    fi
     
    16602471
    16612472#--------------------------------------------------------------------
    1662 # SC_TCL_LINK_LIBS
     2473# TEA_TCL_LINK_LIBS
    16632474#
    16642475#       Search for the libraries needed to link the Tcl shell.
     
    16862497#--------------------------------------------------------------------
    16872498
    1688 AC_DEFUN(SC_TCL_LINK_LIBS, [
     2499AC_DEFUN([TEA_TCL_LINK_LIBS], [
    16892500    #--------------------------------------------------------------------
    16902501    # On a few very rare systems, all of the libm.a stuff is
     
    16982509
    16992510    #--------------------------------------------------------------------
    1700     # On AIX systems, libbsd.a has to be linked in to support
    1701     # non-blocking file IO.  This library has to be linked in after
    1702     # the MATH_LIBS or it breaks the pow() function.  The way to
    1703     # insure proper sequencing, is to add it to the tail of MATH_LIBS.
    1704     # This library also supplies gettimeofday.
    1705     #--------------------------------------------------------------------
    1706 
    1707     libbsd=no
    1708     if test "`uname -s`" = "AIX" ; then
    1709         AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes)
    1710         if test $libbsd = yes; then
    1711             MATH_LIBS="$MATH_LIBS -lbsd"
    1712         fi
    1713     fi
    1714 
    1715 
    1716     #--------------------------------------------------------------------
    17172511    # Interactive UNIX requires -linet instead of -lsocket, plus it
    17182512    # needs net/errno.h to define the socket-related error codes.
     
    17202514
    17212515    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
    1722     AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))
     2516    AC_CHECK_HEADER(net/errno.h, [
     2517        AC_DEFINE(HAVE_NET_ERRNO_H, 1, [Do we have <net/errno.h>?])])
    17232518
    17242519    #--------------------------------------------------------------------
     
    17432538    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
    17442539    if test "$tcl_checkSocket" = 1; then
    1745         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tcl_checkBoth=1)
     2540        AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
     2541            LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
    17462542    fi
    17472543    if test "$tcl_checkBoth" = 1; then
     
    17502546        AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
    17512547    fi
    1752     AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main,
    1753             [LIBS="$LIBS -lnsl"]))
     2548    AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
     2549            [LIBS="$LIBS -lnsl"])])
    17542550   
    17552551    # Don't perform the eval of the libraries here because DL_LIBS
    1756     # won't be set until we call SC_CONFIG_CFLAGS
     2552    # won't be set until we call TEA_CONFIG_CFLAGS
    17572553
    17582554    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
     
    17612557])
    17622558
    1763 #------------------------------------------------------------------------
    1764 # SC_MAKE_LIB --
     2559#--------------------------------------------------------------------
     2560# TEA_TCL_EARLY_FLAGS
     2561#
     2562#       Check for what flags are needed to be passed so the correct OS
     2563#       features are available.
     2564#
     2565# Arguments:
     2566#       None
     2567#       
     2568# Results:
     2569#
     2570#       Might define the following vars:
     2571#               _ISOC99_SOURCE
     2572#               _LARGEFILE64_SOURCE
     2573#               _LARGEFILE_SOURCE64
     2574#
     2575#--------------------------------------------------------------------
     2576
     2577AC_DEFUN([TEA_TCL_EARLY_FLAG],[
     2578    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
     2579        AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
     2580            AC_TRY_COMPILE([[#define ]$1[ 1
     2581]$2], $3,
     2582                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
     2583                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
     2584    if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
     2585        AC_DEFINE($1, 1, [Add the ]$1[ flag when building])
     2586        tcl_flags="$tcl_flags $1"
     2587    fi
     2588])
     2589
     2590AC_DEFUN([TEA_TCL_EARLY_FLAGS],[
     2591    AC_MSG_CHECKING([for required early compiler flags])
     2592    tcl_flags=""
     2593    TEA_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
     2594        [char *p = (char *)strtoll; char *q = (char *)strtoull;])
     2595    TEA_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
     2596        [struct stat64 buf; int i = stat64("/", &buf);])
     2597    TEA_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
     2598        [char *p = (char *)open64;])
     2599    if test "x${tcl_flags}" = "x" ; then
     2600        AC_MSG_RESULT([none])
     2601    else
     2602        AC_MSG_RESULT([${tcl_flags}])
     2603    fi
     2604])
     2605
     2606#--------------------------------------------------------------------
     2607# TEA_TCL_64BIT_FLAGS
     2608#
     2609#       Check for what is defined in the way of 64-bit features.
     2610#
     2611# Arguments:
     2612#       None
     2613#       
     2614# Results:
     2615#
     2616#       Might define the following vars:
     2617#               TCL_WIDE_INT_IS_LONG
     2618#               TCL_WIDE_INT_TYPE
     2619#               HAVE_STRUCT_DIRENT64
     2620#               HAVE_STRUCT_STAT64
     2621#               HAVE_TYPE_OFF64_T
     2622#
     2623#--------------------------------------------------------------------
     2624
     2625AC_DEFUN([TEA_TCL_64BIT_FLAGS], [
     2626    AC_MSG_CHECKING([for 64-bit integer type])
     2627    AC_CACHE_VAL(tcl_cv_type_64bit,[
     2628        tcl_cv_type_64bit=none
     2629        # See if the compiler knows natively about __int64
     2630        AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
     2631            tcl_type_64bit=__int64, tcl_type_64bit="long long")
     2632        # See if we should use long anyway  Note that we substitute in the
     2633        # type that is our current guess for a 64-bit type inside this check
     2634        # program, so it should be modified only carefully...
     2635        AC_TRY_COMPILE(,[switch (0) {
     2636            case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ;
     2637        }],tcl_cv_type_64bit=${tcl_type_64bit})])
     2638    if test "${tcl_cv_type_64bit}" = none ; then
     2639        AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Are wide integers to be implemented with C 'long's?])
     2640        AC_MSG_RESULT([using long])
     2641    elif test "${tcl_cv_type_64bit}" = "__int64" \
     2642                -a "${TEA_PLATFORM}" = "windows" ; then
     2643        # We actually want to use the default tcl.h checks in this
     2644        # case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER*
     2645        AC_MSG_RESULT([using Tcl header defaults])
     2646    else
     2647        AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit},
     2648            [What type should be used to define wide integers?])
     2649        AC_MSG_RESULT([${tcl_cv_type_64bit}])
     2650
     2651        # Now check for auxiliary declarations
     2652        AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
     2653            AC_TRY_COMPILE([#include <sys/types.h>
     2654#include <sys/dirent.h>],[struct dirent64 p;],
     2655                tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
     2656        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
     2657            AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?])
     2658        fi
     2659
     2660        AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[
     2661            AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
     2662],
     2663                tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
     2664        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
     2665            AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in <sys/stat.h>?])
     2666        fi
     2667
     2668        AC_CHECK_FUNCS(open64 lseek64)
     2669        AC_MSG_CHECKING([for off64_t])
     2670        AC_CACHE_VAL(tcl_cv_type_off64_t,[
     2671            AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
     2672],
     2673                tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
     2674        dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the
     2675        dnl functions lseek64 and open64 are defined.
     2676        if test "x${tcl_cv_type_off64_t}" = "xyes" && \
     2677                test "x${ac_cv_func_lseek64}" = "xyes" && \
     2678                test "x${ac_cv_func_open64}" = "xyes" ; then
     2679            AC_DEFINE(HAVE_TYPE_OFF64_T, 1, [Is off64_t in <sys/types.h>?])
     2680            AC_MSG_RESULT([yes])
     2681        else
     2682            AC_MSG_RESULT([no])
     2683        fi
     2684    fi
     2685])
     2686
     2687##
     2688## Here ends the standard Tcl configuration bits and starts the
     2689## TEA specific functions
     2690##
     2691
     2692#------------------------------------------------------------------------
     2693# TEA_INIT --
     2694#
     2695#       Init various Tcl Extension Architecture (TEA) variables.
     2696#       This should be the first called TEA_* macro.
     2697#
     2698# Arguments:
     2699#       none
     2700#
     2701# Results:
     2702#
     2703#       Defines and substs the following vars:
     2704#               CYGPATH
     2705#               EXEEXT
     2706#       Defines only:
     2707#               TEA_VERSION
     2708#               TEA_INITED
     2709#               TEA_PLATFORM (windows or unix)
     2710#
     2711# "cygpath" is used on windows to generate native path names for include
     2712# files. These variables should only be used with the compiler and linker
     2713# since they generate native path names.
     2714#
     2715# EXEEXT
     2716#       Select the executable extension based on the host type.  This
     2717#       is a lightweight replacement for AC_EXEEXT that doesn't require
     2718#       a compiler.
     2719#------------------------------------------------------------------------
     2720
     2721AC_DEFUN([TEA_INIT], [
     2722    # TEA extensions pass this us the version of TEA they think they
     2723    # are compatible with.
     2724    TEA_VERSION="3.5"
     2725
     2726    AC_MSG_CHECKING([for correct TEA configuration])
     2727    if test x"${PACKAGE_NAME}" = x ; then
     2728        AC_MSG_ERROR([
     2729The PACKAGE_NAME variable must be defined by your TEA configure.in])
     2730    fi
     2731    if test x"$1" = x ; then
     2732        AC_MSG_ERROR([
     2733TEA version not specified.])
     2734    elif test "$1" != "${TEA_VERSION}" ; then
     2735        AC_MSG_RESULT([warning: requested TEA version "$1", have "${TEA_VERSION}"])
     2736    else
     2737        AC_MSG_RESULT([ok (TEA ${TEA_VERSION})])
     2738    fi
     2739    case "`uname -s`" in
     2740        *win32*|*WIN32*|*CYGWIN_NT*|*CYGWIN_9*|*CYGWIN_ME*|*MINGW32_*|*MSYS_NT*)
     2741            AC_CHECK_PROG(CYGPATH, cygpath, cygpath -w, echo)
     2742            EXEEXT=".exe"
     2743            TEA_PLATFORM="windows"
     2744            ;;
     2745        *)
     2746            CYGPATH=echo
     2747            EXEEXT=""
     2748            TEA_PLATFORM="unix"
     2749            ;;
     2750    esac
     2751
     2752    # Check if exec_prefix is set. If not use fall back to prefix.
     2753    # Note when adjusted, so that TEA_PREFIX can correct for this.
     2754    # This is needed for recursive configures, since autoconf propagates
     2755    # $prefix, but not $exec_prefix (doh!).
     2756    if test x$exec_prefix = xNONE ; then
     2757        exec_prefix_default=yes
     2758        exec_prefix=$prefix
     2759    fi
     2760
     2761    AC_SUBST(EXEEXT)
     2762    AC_SUBST(CYGPATH)
     2763
     2764    # This package name must be replaced statically for AC_SUBST to work
     2765    AC_SUBST(PKG_LIB_FILE)
     2766    # Substitute STUB_LIB_FILE in case package creates a stub library too.
     2767    AC_SUBST(PKG_STUB_LIB_FILE)
     2768
     2769    # We AC_SUBST these here to ensure they are subst'ed,
     2770    # in case the user doesn't call TEA_ADD_...
     2771    AC_SUBST(PKG_STUB_SOURCES)
     2772    AC_SUBST(PKG_STUB_OBJECTS)
     2773    AC_SUBST(PKG_TCL_SOURCES)
     2774    AC_SUBST(PKG_HEADERS)
     2775    AC_SUBST(PKG_INCLUDES)
     2776    AC_SUBST(PKG_LIBS)
     2777    AC_SUBST(PKG_CFLAGS)
     2778])
     2779
     2780#------------------------------------------------------------------------
     2781# TEA_ADD_SOURCES --
     2782#
     2783#       Specify one or more source files.  Users should check for
     2784#       the right platform before adding to their list.
     2785#       It is not important to specify the directory, as long as it is
     2786#       in the generic, win or unix subdirectory of $(srcdir).
     2787#
     2788# Arguments:
     2789#       one or more file names
     2790#
     2791# Results:
     2792#
     2793#       Defines and substs the following vars:
     2794#               PKG_SOURCES
     2795#               PKG_OBJECTS
     2796#------------------------------------------------------------------------
     2797AC_DEFUN([TEA_ADD_SOURCES], [
     2798    vars="$@"
     2799    for i in $vars; do
     2800        case $i in
     2801            [\$]*)
     2802                # allow $-var names
     2803                PKG_SOURCES="$PKG_SOURCES $i"
     2804                PKG_OBJECTS="$PKG_OBJECTS $i"
     2805                ;;
     2806            *)
     2807                # check for existence - allows for generic/win/unix VPATH
     2808                if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/src/$i" \
     2809                    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
     2810                    ; then
     2811                    AC_MSG_ERROR([could not find source file '$i'])
     2812                fi
     2813                PKG_SOURCES="$PKG_SOURCES $i"
     2814                # this assumes it is in a VPATH dir
     2815                i=`basename $i`
     2816                # handle user calling this before or after TEA_SETUP_COMPILER
     2817                if test x"${OBJEXT}" != x ; then
     2818                    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
     2819                else
     2820                    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
     2821                fi
     2822                PKG_OBJECTS="$PKG_OBJECTS $j"
     2823                ;;
     2824        esac
     2825    done
     2826    AC_SUBST(PKG_SOURCES)
     2827    AC_SUBST(PKG_OBJECTS)
     2828])
     2829
     2830#------------------------------------------------------------------------
     2831# TEA_ADD_STUB_SOURCES --
     2832#
     2833#       Specify one or more source files.  Users should check for
     2834#       the right platform before adding to their list.
     2835#       It is not important to specify the directory, as long as it is
     2836#       in the generic, win or unix subdirectory of $(srcdir).
     2837#
     2838# Arguments:
     2839#       one or more file names
     2840#
     2841# Results:
     2842#
     2843#       Defines and substs the following vars:
     2844#               PKG_STUB_SOURCES
     2845#               PKG_STUB_OBJECTS
     2846#------------------------------------------------------------------------
     2847AC_DEFUN([TEA_ADD_STUB_SOURCES], [
     2848    vars="$@"
     2849    for i in $vars; do
     2850        # check for existence - allows for generic/win/unix VPATH
     2851        if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
     2852            -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
     2853            ; then
     2854            AC_MSG_ERROR([could not find stub source file '$i'])
     2855        fi
     2856        PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i"
     2857        # this assumes it is in a VPATH dir
     2858        i=`basename $i`
     2859        # handle user calling this before or after TEA_SETUP_COMPILER
     2860        if test x"${OBJEXT}" != x ; then
     2861            j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
     2862        else
     2863            j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
     2864        fi
     2865        PKG_STUB_OBJECTS="$PKG_STUB_OBJECTS $j"
     2866    done
     2867    AC_SUBST(PKG_STUB_SOURCES)
     2868    AC_SUBST(PKG_STUB_OBJECTS)
     2869])
     2870
     2871#------------------------------------------------------------------------
     2872# TEA_ADD_TCL_SOURCES --
     2873#
     2874#       Specify one or more Tcl source files.  These should be platform
     2875#       independent runtime files.
     2876#
     2877# Arguments:
     2878#       one or more file names
     2879#
     2880# Results:
     2881#
     2882#       Defines and substs the following vars:
     2883#               PKG_TCL_SOURCES
     2884#------------------------------------------------------------------------
     2885AC_DEFUN([TEA_ADD_TCL_SOURCES], [
     2886    vars="$@"
     2887    for i in $vars; do
     2888        # check for existence, be strict because it is installed
     2889        if test ! -f "${srcdir}/$i" ; then
     2890            AC_MSG_ERROR([could not find tcl source file '${srcdir}/$i'])
     2891        fi
     2892        PKG_TCL_SOURCES="$PKG_TCL_SOURCES $i"
     2893    done
     2894    AC_SUBST(PKG_TCL_SOURCES)
     2895])
     2896
     2897#------------------------------------------------------------------------
     2898# TEA_ADD_HEADERS --
     2899#
     2900#       Specify one or more source headers.  Users should check for
     2901#       the right platform before adding to their list.
     2902#
     2903# Arguments:
     2904#       one or more file names
     2905#
     2906# Results:
     2907#
     2908#       Defines and substs the following vars:
     2909#               PKG_HEADERS
     2910#------------------------------------------------------------------------
     2911AC_DEFUN([TEA_ADD_HEADERS], [
     2912    vars="$@"
     2913    for i in $vars; do
     2914        # check for existence, be strict because it is installed
     2915        if test ! -f "${srcdir}/$i" ; then
     2916            AC_MSG_ERROR([could not find header file '${srcdir}/$i'])
     2917        fi
     2918        PKG_HEADERS="$PKG_HEADERS $i"
     2919    done
     2920    AC_SUBST(PKG_HEADERS)
     2921])
     2922
     2923#------------------------------------------------------------------------
     2924# TEA_ADD_INCLUDES --
     2925#
     2926#       Specify one or more include dirs.  Users should check for
     2927#       the right platform before adding to their list.
     2928#
     2929# Arguments:
     2930#       one or more file names
     2931#
     2932# Results:
     2933#
     2934#       Defines and substs the following vars:
     2935#               PKG_INCLUDES
     2936#------------------------------------------------------------------------
     2937AC_DEFUN([TEA_ADD_INCLUDES], [
     2938    vars="$@"
     2939    for i in $vars; do
     2940        PKG_INCLUDES="$PKG_INCLUDES $i"
     2941    done
     2942    AC_SUBST(PKG_INCLUDES)
     2943])
     2944
     2945#------------------------------------------------------------------------
     2946# TEA_ADD_LIBS --
     2947#
     2948#       Specify one or more libraries.  Users should check for
     2949#       the right platform before adding to their list.  For Windows,
     2950#       libraries provided in "foo.lib" format will be converted to
     2951#       "-lfoo" when using GCC (mingw).
     2952#
     2953# Arguments:
     2954#       one or more file names
     2955#
     2956# Results:
     2957#
     2958#       Defines and substs the following vars:
     2959#               PKG_LIBS
     2960#------------------------------------------------------------------------
     2961AC_DEFUN([TEA_ADD_LIBS], [
     2962    vars="$@"
     2963    for i in $vars; do
     2964        if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
     2965            # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
     2966            i=`echo "$i" | sed -e 's/^\([[^-]].*\)\.lib[$]/-l\1/i'`
     2967        fi
     2968        PKG_LIBS="$PKG_LIBS $i"
     2969    done
     2970    AC_SUBST(PKG_LIBS)
     2971])
     2972
     2973#------------------------------------------------------------------------
     2974# TEA_ADD_CFLAGS --
     2975#
     2976#       Specify one or more CFLAGS.  Users should check for
     2977#       the right platform before adding to their list.
     2978#
     2979# Arguments:
     2980#       one or more file names
     2981#
     2982# Results:
     2983#
     2984#       Defines and substs the following vars:
     2985#               PKG_CFLAGS
     2986#------------------------------------------------------------------------
     2987AC_DEFUN([TEA_ADD_CFLAGS], [
     2988    PKG_CFLAGS="$PKG_CFLAGS $@"
     2989    AC_SUBST(PKG_CFLAGS)
     2990])
     2991
     2992#------------------------------------------------------------------------
     2993# TEA_PREFIX --
     2994#
     2995#       Handle the --prefix=... option by defaulting to what Tcl gave
     2996#
     2997# Arguments:
     2998#       none
     2999#
     3000# Results:
     3001#
     3002#       If --prefix or --exec-prefix was not specified, $prefix and
     3003#       $exec_prefix will be set to the values given to Tcl when it was
     3004#       configured.
     3005#------------------------------------------------------------------------
     3006AC_DEFUN([TEA_PREFIX], [
     3007    if test "${prefix}" = "NONE"; then
     3008        prefix_default=yes
     3009        if test x"${TCL_PREFIX}" != x; then
     3010            AC_MSG_NOTICE([--prefix defaulting to TCL_PREFIX ${TCL_PREFIX}])
     3011            prefix=${TCL_PREFIX}
     3012        else
     3013            AC_MSG_NOTICE([--prefix defaulting to /usr/local])
     3014            prefix=/usr/local
     3015        fi
     3016    fi
     3017    if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" \
     3018        -o x"${exec_prefix_default}" = x"yes" ; then
     3019        if test x"${TCL_EXEC_PREFIX}" != x; then
     3020            AC_MSG_NOTICE([--exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}])
     3021            exec_prefix=${TCL_EXEC_PREFIX}
     3022        else
     3023            AC_MSG_NOTICE([--exec-prefix defaulting to ${prefix}])
     3024            exec_prefix=$prefix
     3025        fi
     3026    fi
     3027])
     3028
     3029#------------------------------------------------------------------------
     3030# TEA_SETUP_COMPILER_CC --
     3031#
     3032#       Do compiler checks the way we want.  This is just a replacement
     3033#       for AC_PROG_CC in TEA configure.in files to make them cleaner.
     3034#
     3035# Arguments:
     3036#       none
     3037#
     3038# Results:
     3039#
     3040#       Sets up CC var and other standard bits we need to make executables.
     3041#------------------------------------------------------------------------
     3042AC_DEFUN([TEA_SETUP_COMPILER_CC], [
     3043    # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE)
     3044    # in this macro, they need to go into TEA_SETUP_COMPILER instead.
     3045
     3046    # If the user did not set CFLAGS, set it now to keep
     3047    # the AC_PROG_CC macro from adding "-g -O2".
     3048    if test "${CFLAGS+set}" != "set" ; then
     3049        CFLAGS=""
     3050    fi
     3051
     3052    AC_PROG_CC
     3053    AC_PROG_CPP
     3054
     3055    AC_PROG_INSTALL
     3056
     3057    #--------------------------------------------------------------------
     3058    # Checks to see if the make program sets the $MAKE variable.
     3059    #--------------------------------------------------------------------
     3060
     3061    AC_PROG_MAKE_SET
     3062
     3063    #--------------------------------------------------------------------
     3064    # Find ranlib
     3065    #--------------------------------------------------------------------
     3066
     3067    AC_PROG_RANLIB
     3068
     3069    #--------------------------------------------------------------------
     3070    # Determines the correct binary file extension (.o, .obj, .exe etc.)
     3071    #--------------------------------------------------------------------
     3072
     3073    AC_OBJEXT
     3074    AC_EXEEXT
     3075])
     3076
     3077#------------------------------------------------------------------------
     3078# TEA_SETUP_COMPILER --
     3079#
     3080#       Do compiler checks that use the compiler.  This must go after
     3081#       TEA_SETUP_COMPILER_CC, which does the actual compiler check.
     3082#
     3083# Arguments:
     3084#       none
     3085#
     3086# Results:
     3087#
     3088#       Sets up CC var and other standard bits we need to make executables.
     3089#------------------------------------------------------------------------
     3090AC_DEFUN([TEA_SETUP_COMPILER], [
     3091    # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here.
     3092    AC_REQUIRE([TEA_SETUP_COMPILER_CC])
     3093
     3094    #------------------------------------------------------------------------
     3095    # If we're using GCC, see if the compiler understands -pipe. If so, use it.
     3096    # It makes compiling go faster.  (This is only a performance feature.)
     3097    #------------------------------------------------------------------------
     3098
     3099    if test -z "$no_pipe" -a -n "$GCC"; then
     3100        AC_MSG_CHECKING([if the compiler understands -pipe])
     3101        OLDCC="$CC"
     3102        CC="$CC -pipe"
     3103        AC_TRY_COMPILE(,, AC_MSG_RESULT([yes]), CC="$OLDCC"
     3104            AC_MSG_RESULT([no]))
     3105    fi
     3106
     3107    #--------------------------------------------------------------------
     3108    # Common compiler flag setup
     3109    #--------------------------------------------------------------------
     3110
     3111    AC_C_BIGENDIAN
     3112    if test "${TEA_PLATFORM}" = "unix" ; then
     3113        TEA_TCL_LINK_LIBS
     3114        TEA_MISSING_POSIX_HEADERS
     3115        # Let the user call this, because if it triggers, they will
     3116        # need a compat/strtod.c that is correct.  Users can also
     3117        # use Tcl_GetDouble(FromObj) instead.
     3118        #TEA_BUGGY_STRTOD
     3119    fi
     3120])
     3121
     3122#------------------------------------------------------------------------
     3123# TEA_MAKE_LIB --
    17653124#
    17663125#       Generate a line that can be used to build a shared/unshared library
     
    17753134#
    17763135#       Defines the following vars:
    1777 #               MAKE_LIB        Makefile rule for building a library
    1778 #               MAKE_SHARED_LIB Makefile rule for building a shared library
    1779 #               MAKE_UNSHARED_LIB       Makefile rule for building a static
    1780 #                               library
    1781 #------------------------------------------------------------------------
    1782 
    1783 AC_DEFUN(SC_MAKE_LIB, [
    1784     case "`uname -s`" in
    1785         *win32* | *WIN32* | *CYGWIN_NT*)
    1786             if test "${CC-cc}" = "cl"; then
    1787                 MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(\[$]@_OBJECTS) "
    1788                 MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS} \$(LDFLAGS) -out:\[$]@ \$(\[$]@_OBJECTS) "
    1789             fi
    1790             ;;
    1791         *)
    1792             MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(\[$]@_OBJECTS)"
    1793             MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(\[$]@_OBJECTS) \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS}"
    1794             ;;
    1795     esac
     3136#       CFLAGS -        Done late here to note disturb other AC macros
     3137#       MAKE_LIB -      Command to execute to build the Tcl library;
     3138#                       differs depending on whether or not Tcl is being
     3139#                       compiled as a shared library.
     3140#       MAKE_SHARED_LIB Makefile rule for building a shared library
     3141#       MAKE_STATIC_LIB Makefile rule for building a static library
     3142#       MAKE_STUB_LIB   Makefile rule for building a stub library
     3143#------------------------------------------------------------------------
     3144
     3145AC_DEFUN([TEA_MAKE_LIB], [
     3146    if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then
     3147        MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_OBJECTS)"
     3148        MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\[$]@ \$(PKG_OBJECTS)"
     3149        MAKE_STUB_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_STUB_OBJECTS)"
     3150    else
     3151        MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(PKG_OBJECTS)"
     3152        MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}"
     3153        MAKE_STUB_LIB="\${STLIB_LD} \[$]@ \$(PKG_STUB_OBJECTS)"
     3154    fi
    17963155
    17973156    if test "${SHARED_BUILD}" = "1" ; then
    1798         MAKE_LIB=${MAKE_SHARED_LIB}
     3157        MAKE_LIB="${MAKE_SHARED_LIB} "
    17993158    else
    1800         MAKE_LIB=${MAKE_STATIC_LIB}
     3159        MAKE_LIB="${MAKE_STATIC_LIB} "
     3160    fi
     3161
     3162    #--------------------------------------------------------------------
     3163    # Shared libraries and static libraries have different names.
     3164    # Use the double eval to make sure any variables in the suffix is
     3165    # substituted. (@@@ Might not be necessary anymore)
     3166    #--------------------------------------------------------------------
     3167
     3168    if test "${TEA_PLATFORM}" = "windows" ; then
     3169        if test "${SHARED_BUILD}" = "1" ; then
     3170            # We force the unresolved linking of symbols that are really in
     3171            # the private libraries of Tcl and Tk.
     3172            SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\""
     3173            if test x"${TK_BIN_DIR}" != x ; then
     3174                SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\""
     3175            fi
     3176            eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
     3177        else
     3178            eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
     3179        fi
     3180        # Some packages build their own stubs libraries
     3181        eval eval "PKG_STUB_LIB_FILE=${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
     3182        if test "$GCC" = "yes"; then
     3183            PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE}
     3184        fi
     3185        # These aren't needed on Windows (either MSVC or gcc)
     3186        RANLIB="mt -manifest ${PKG_LIB_FILE}.manifest -outputresource:${PKG_LIB_FILE}\;2 ; test -f"
     3187        RANLIB_STUB=:
     3188    else
     3189        RANLIB_STUB="${RANLIB}"
     3190        if test "${SHARED_BUILD}" = "1" ; then
     3191            SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}"
     3192            if test x"${TK_BIN_DIR}" != x ; then
     3193                SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}"
     3194            fi
     3195            eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
     3196            RANLIB=:
     3197        else
     3198            eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
     3199        fi
     3200        # Some packages build their own stubs libraries
     3201        eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
     3202    fi
     3203
     3204    # These are escaped so that only CFLAGS is picked up at configure time.
     3205    # The other values will be substituted at make time.
     3206    CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}"
     3207    if test "${SHARED_BUILD}" = "1" ; then
     3208        CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}"
    18013209    fi
    18023210
     
    18043212    AC_SUBST(MAKE_SHARED_LIB)
    18053213    AC_SUBST(MAKE_STATIC_LIB)
    1806 ])
    1807 
    1808 #------------------------------------------------------------------------
    1809 # SC_LIB_SPEC --
     3214    AC_SUBST(MAKE_STUB_LIB)
     3215    AC_SUBST(RANLIB_STUB)
     3216    AC_SUBST(RANLIB)
     3217])
     3218
     3219#------------------------------------------------------------------------
     3220# TEA_LIB_SPEC --
    18103221#
    18113222#       Compute the name of an existing object library located in libdir
     
    18153226#       basename        The base name of the library without version
    18163227#                       numbers, extensions, or "lib" prefixes.
    1817 #
    1818 #       Requires:
     3228#       extra_dir       Extra directory in which to search for the
     3229#                       library.  This location is used first, then
     3230#                       $prefix/$exec-prefix, then some defaults.
     3231#
     3232# Requires:
     3233#       TEA_INIT and TEA_PREFIX must be called first.
    18193234#
    18203235# Results:
     
    18253240#------------------------------------------------------------------------
    18263241
    1827 AC_DEFUN(SC_LIB_SPEC, [
    1828     AC_MSG_CHECKING(for $1 library)
    1829     eval "sc_lib_name_dir=${libdir}"
     3242AC_DEFUN([TEA_LIB_SPEC], [
     3243    AC_MSG_CHECKING([for $1 library])
     3244
     3245    # Look in exec-prefix for the library (defined by TEA_PREFIX).
     3246
     3247    tea_lib_name_dir="${exec_prefix}/lib"
     3248
     3249    # Or in a user-specified location.
     3250
     3251    if test x"$2" != x ; then
     3252        tea_extra_lib_dir=$2
     3253    else
     3254        tea_extra_lib_dir=NONE
     3255    fi
     3256
    18303257    for i in \
    1831             `ls -dr ${sc_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
    1832             `ls -dr ${sc_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
     3258            `ls -dr ${tea_extra_lib_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
     3259            `ls -dr ${tea_extra_lib_dir}/lib$1[[0-9]]* 2>/dev/null ` \
     3260            `ls -dr ${tea_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
     3261            `ls -dr ${tea_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
    18333262            `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
    18343263            `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
     
    18363265            `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
    18373266        if test -f "$i" ; then
    1838 
    1839             sc_lib_name_dir=`dirname $i`
     3267            tea_lib_name_dir=`dirname $i`
    18403268            $1_LIB_NAME=`basename $i`
     3269            $1_LIB_PATH_NAME=$i
    18413270            break
    18423271        fi
    18433272    done
    18443273
    1845     case "`uname -s`" in
    1846         *win32* | *WIN32* | *CYGWIN_NT*)
    1847             $1_LIB_SPEC=${$1_LIB_NAME}
    1848             ;;
    1849         *)
    1850             # Strip off the leading "lib" and trailing ".a" or ".so"
    1851 
    1852             sc_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//'`
    1853             $1_LIB_SPEC="-L${sc_lib_name_dir} -l${sc_lib_name_lib}"
    1854             ;;
    1855     esac
    1856     if test "x$1_LIB_NAME" = x ; then
    1857         AC_MSG_ERROR(not found)
     3274    if test "${TEA_PLATFORM}" = "windows"; then
     3275        $1_LIB_SPEC=\"`${CYGPATH} ${$1_LIB_PATH_NAME} 2>/dev/null`\"
    18583276    else
    1859         AC_MSG_RESULT(${$1_LIB_SPEC})
    1860     fi
    1861 ])
    1862 
    1863 #------------------------------------------------------------------------
    1864 # SC_PRIVATE_TCL_INCLUDE --
     3277        # Strip off the leading "lib" and trailing ".a" or ".so"
     3278
     3279        tea_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//' -e 's/\.so.*//'`
     3280        $1_LIB_SPEC="-L${tea_lib_name_dir} -l${tea_lib_name_lib}"
     3281    fi
     3282
     3283    if test "x${$1_LIB_NAME}" = x ; then
     3284        AC_MSG_ERROR([not found])
     3285    else
     3286        AC_MSG_RESULT([${$1_LIB_SPEC}])
     3287    fi
     3288])
     3289
     3290#------------------------------------------------------------------------
     3291# TEA_PRIVATE_TCL_HEADERS --
    18653292#
    18663293#       Locate the private Tcl include files
     
    18693296#
    18703297#       Requires:
    1871 #               TCL_SRC_DIR     Assumes that SC_LOAD_TCLCONFIG has
     3298#               TCL_SRC_DIR     Assumes that TEA_LOAD_TCLCONFIG has
    18723299#                                already been called.
    18733300#
     
    18863313#------------------------------------------------------------------------
    18873314
    1888 AC_DEFUN(SC_PRIVATE_TCL_HEADERS, [
    1889     AC_MSG_CHECKING(for Tcl private include files)
    1890 
    1891     case "`uname -s`" in
    1892         *win32* | *WIN32* | *CYGWIN_NT*)
    1893             TCL_TOP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/..`\"
    1894             TCL_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../generic`\"
    1895             TCL_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../unix`\"
    1896             TCL_WIN_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../win`\"
    1897             TCL_BMAP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../bitmaps`\"
    1898             TCL_TOOL_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../tools`\"
    1899             TCL_COMPAT_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../compat`\"
    1900             TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
    1901         ;;
    1902         *)
    1903             TCL_TOP_DIR_NATIVE=${TCL_SRC_DIR}
    1904             TCL_GENERIC_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/generic'
    1905             TCL_UNIX_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/unix'
    1906             TCL_WIN_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/win'
    1907             TCL_BMAP_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/bitmaps'
    1908             TCL_TOOL_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/tools'
    1909             TCL_COMPAT_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/compat'
    1910             TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
    1911         ;;
    1912     esac
     3315AC_DEFUN([TEA_PRIVATE_TCL_HEADERS], [
     3316    AC_MSG_CHECKING([for Tcl private include files])
     3317
     3318    TCL_SRC_DIR_NATIVE=`${CYGPATH} ${TCL_SRC_DIR}`
     3319    TCL_TOP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}\"
     3320    TCL_GENERIC_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/generic\"
     3321    TCL_UNIX_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/unix\"
     3322    TCL_WIN_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/win\"
     3323    TCL_BMAP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/bitmaps\"
     3324    TCL_TOOL_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/tools\"
     3325    TCL_COMPAT_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/compat\"
     3326
     3327    if test "${TEA_PLATFORM}" = "windows"; then
     3328        TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
     3329    else
     3330        TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
     3331    fi
     3332    # We want to ensure these are substituted so as not to require
     3333    # any *_NATIVE vars be defined in the Makefile
     3334    TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
     3335    if test "`uname -s`" = "Darwin"; then
     3336        # If Tcl was built as a framework, attempt to use
     3337        # the framework's Headers and PrivateHeaders directories
     3338        case ${TCL_DEFS} in
     3339            *TCL_FRAMEWORK*)
     3340                if test -d "${TCL_BIN_DIR}/Headers" -a -d "${TCL_BIN_DIR}/PrivateHeaders"; then
     3341                TCL_INCLUDES="-I\"${TCL_BIN_DIR}/Headers\" -I\"${TCL_BIN_DIR}/PrivateHeaders\" ${TCL_INCLUDES}"; else
     3342                TCL_INCLUDES="${TCL_INCLUDES} ${TCL_INCLUDE_SPEC} `echo "${TCL_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`"; fi
     3343                ;;
     3344        esac
     3345    fi
    19133346
    19143347    AC_SUBST(TCL_TOP_DIR_NATIVE)
     
    19203353    AC_SUBST(TCL_PLATFORM_DIR_NATIVE)
    19213354
    1922     TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
    19233355    AC_SUBST(TCL_INCLUDES)
    1924     AC_MSG_RESULT(Using srcdir found in tclConfig.sh)
    1925 ])
    1926 
    1927 #------------------------------------------------------------------------
    1928 # SC_PUBLIC_TCL_HEADERS --
     3356    AC_MSG_RESULT([Using srcdir found in tclConfig.sh: ${TCL_SRC_DIR}])
     3357])
     3358
     3359#------------------------------------------------------------------------
     3360# TEA_PUBLIC_TCL_HEADERS --
    19293361#
    19303362#       Locate the installed public Tcl header files
     
    19453377#------------------------------------------------------------------------
    19463378
    1947 AC_DEFUN(SC_PUBLIC_TCL_HEADERS, [
    1948     AC_MSG_CHECKING(for Tcl public headers)
    1949 
    1950     AC_ARG_WITH(tclinclude, [ --with-tclinclude      directory containing the public Tcl header files.], with_tclinclude=${withval})
    1951 
    1952     if test x"${with_tclinclude}" != x ; then
    1953         if test -f "${with_tclinclude}/tcl.h" ; then
    1954             ac_cv_c_tclh=${with_tclinclude}
    1955         else
    1956             AC_MSG_ERROR([${with_tclinclude} directory does not contain Tcl public header file tcl.h])
    1957         fi
    1958     else
    1959         AC_CACHE_VAL(ac_cv_c_tclh, [
    1960             # Use the value from --with-tclinclude, if it was given
    1961 
    1962             if test x"${with_tclinclude}" != x ; then
     3379AC_DEFUN([TEA_PUBLIC_TCL_HEADERS], [
     3380    AC_MSG_CHECKING([for Tcl public headers])
     3381
     3382    AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory containing the public Tcl header files], with_tclinclude=${withval})
     3383
     3384    AC_CACHE_VAL(ac_cv_c_tclh, [
     3385        # Use the value from --with-tclinclude, if it was given
     3386
     3387        if test x"${with_tclinclude}" != x ; then
     3388            if test -f "${with_tclinclude}/tcl.h" ; then
    19633389                ac_cv_c_tclh=${with_tclinclude}
    19643390            else
    1965                 # Check in the includedir, if --prefix was specified
    1966 
    1967                 eval "temp_includedir=${includedir}"
     3391                AC_MSG_ERROR([${with_tclinclude} directory does not contain tcl.h])
     3392            fi
     3393        else
     3394            if test "`uname -s`" = "Darwin"; then
     3395                # If Tcl was built as a framework, attempt to use
     3396                # the framework's Headers directory
     3397                case ${TCL_DEFS} in
     3398                    *TCL_FRAMEWORK*)
     3399                        list="`ls -d ${TCL_BIN_DIR}/Headers 2>/dev/null`"
     3400                        ;;
     3401                esac
     3402            fi
     3403
     3404            # Look in the source dir only if Tcl is not installed,
     3405            # and in that situation, look there before installed locations.
     3406            if test -f "${TCL_BIN_DIR}/Makefile" ; then
     3407                list="$list `ls -d ${TCL_SRC_DIR}/generic 2>/dev/null`"
     3408            fi
     3409
     3410            # Check order: pkg --prefix location, Tcl's --prefix location,
     3411            # relative to directory of tclConfig.sh.
     3412
     3413            eval "temp_includedir=${includedir}"
     3414            list="$list \
     3415                `ls -d ${temp_includedir}        2>/dev/null` \
     3416                `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
     3417                `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
     3418            if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
     3419                list="$list /usr/local/include /usr/include"
     3420                if test x"${TCL_INCLUDE_SPEC}" != x ; then
     3421                    d=`echo "${TCL_INCLUDE_SPEC}" | sed -e 's/^-I//'`
     3422                    list="$list `ls -d ${d} 2>/dev/null`"
     3423                fi
     3424            fi
     3425            for i in $list ; do
     3426                if test -f "$i/tcl.h" ; then
     3427                    ac_cv_c_tclh=$i
     3428                    break
     3429                fi
     3430            done
     3431        fi
     3432    ])
     3433
     3434    # Print a message based on how we determined the include path
     3435
     3436    if test x"${ac_cv_c_tclh}" = x ; then
     3437        AC_MSG_ERROR([tcl.h not found.  Please specify its location with --with-tclinclude])
     3438    else
     3439        AC_MSG_RESULT([${ac_cv_c_tclh}])
     3440    fi
     3441
     3442    # Convert to a native path and substitute into the output files.
     3443
     3444    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
     3445
     3446    TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
     3447
     3448    AC_SUBST(TCL_INCLUDES)
     3449])
     3450
     3451#------------------------------------------------------------------------
     3452# TEA_PRIVATE_TK_HEADERS --
     3453#
     3454#       Locate the private Tk include files
     3455#
     3456# Arguments:
     3457#
     3458#       Requires:
     3459#               TK_SRC_DIR      Assumes that TEA_LOAD_TKCONFIG has
     3460#                                already been called.
     3461#
     3462# Results:
     3463#
     3464#       Substs the following vars:
     3465#               TK_INCLUDES
     3466#------------------------------------------------------------------------
     3467
     3468AC_DEFUN([TEA_PRIVATE_TK_HEADERS], [
     3469    AC_MSG_CHECKING([for Tk private include files])
     3470
     3471    TK_SRC_DIR_NATIVE=`${CYGPATH} ${TK_SRC_DIR}`
     3472    TK_TOP_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}\"
     3473    TK_UNIX_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/unix\"
     3474    TK_WIN_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/win\"
     3475    TK_GENERIC_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/generic\"
     3476    TK_XLIB_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/xlib\"
     3477    if test "${TEA_PLATFORM}" = "windows"; then
     3478        TK_PLATFORM_DIR_NATIVE=${TK_WIN_DIR_NATIVE}
     3479    else
     3480        TK_PLATFORM_DIR_NATIVE=${TK_UNIX_DIR_NATIVE}
     3481    fi
     3482    # We want to ensure these are substituted so as not to require
     3483    # any *_NATIVE vars be defined in the Makefile
     3484    TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
     3485    if test "${TEA_WINDOWINGSYSTEM}" = "win32" \
     3486        -o "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
     3487        TK_INCLUDES="${TK_INCLUDES} -I${TK_XLIB_DIR_NATIVE}"
     3488    fi
     3489    if test "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
     3490        TK_INCLUDES="${TK_INCLUDES} -I${TK_SRC_DIR_NATIVE}/macosx"
     3491    fi
     3492    if test "`uname -s`" = "Darwin"; then
     3493        # If Tk was built as a framework, attempt to use
     3494        # the framework's Headers and PrivateHeaders directories
     3495        case ${TK_DEFS} in
     3496            *TK_FRAMEWORK*)
     3497                if test -d "${TK_BIN_DIR}/Headers" -a -d "${TK_BIN_DIR}/PrivateHeaders"; then
     3498                TK_INCLUDES="-I\"${TK_BIN_DIR}/Headers\" -I\"${TK_BIN_DIR}/PrivateHeaders\" ${TK_INCLUDES}"; fi
     3499                ;;
     3500        esac
     3501    fi
     3502
     3503    AC_SUBST(TK_TOP_DIR_NATIVE)
     3504    AC_SUBST(TK_UNIX_DIR_NATIVE)
     3505    AC_SUBST(TK_WIN_DIR_NATIVE)
     3506    AC_SUBST(TK_GENERIC_DIR_NATIVE)
     3507    AC_SUBST(TK_XLIB_DIR_NATIVE)
     3508    AC_SUBST(TK_PLATFORM_DIR_NATIVE)
     3509
     3510    AC_SUBST(TK_INCLUDES)
     3511    AC_MSG_RESULT([Using srcdir found in tkConfig.sh: ${TK_SRC_DIR}])
     3512])
     3513
     3514#------------------------------------------------------------------------
     3515# TEA_PUBLIC_TK_HEADERS --
     3516#
     3517#       Locate the installed public Tk header files
     3518#
     3519# Arguments:
     3520#       None.
     3521#
     3522# Requires:
     3523#       CYGPATH must be set
     3524#
     3525# Results:
     3526#
     3527#       Adds a --with-tkinclude switch to configure.
     3528#       Result is cached.
     3529#
     3530#       Substs the following vars:
     3531#               TK_INCLUDES
     3532#------------------------------------------------------------------------
     3533
     3534AC_DEFUN([TEA_PUBLIC_TK_HEADERS], [
     3535    AC_MSG_CHECKING([for Tk public headers])
     3536
     3537    AC_ARG_WITH(tkinclude, [  --with-tkinclude      directory containing the public Tk header files.], with_tkinclude=${withval})
     3538
     3539    AC_CACHE_VAL(ac_cv_c_tkh, [
     3540        # Use the value from --with-tkinclude, if it was given
     3541
     3542        if test x"${with_tkinclude}" != x ; then
     3543            if test -f "${with_tkinclude}/tk.h" ; then
     3544                ac_cv_c_tkh=${with_tkinclude}
     3545            else
     3546                AC_MSG_ERROR([${with_tkinclude} directory does not contain tk.h])
     3547            fi
     3548        else
     3549            if test "`uname -s`" = "Darwin"; then
     3550                # If Tk was built as a framework, attempt to use
     3551                # the framework's Headers directory.
     3552                case ${TK_DEFS} in
     3553                    *TK_FRAMEWORK*)
     3554                        list="`ls -d ${TK_BIN_DIR}/Headers 2>/dev/null`"
     3555                        ;;
     3556                esac
     3557            fi
     3558
     3559            # Look in the source dir only if Tk is not installed,
     3560            # and in that situation, look there before installed locations.
     3561            if test -f "${TK_BIN_DIR}/Makefile" ; then
     3562                list="$list `ls -d ${TK_SRC_DIR}/generic 2>/dev/null`"
     3563            fi
     3564
     3565            # Check order: pkg --prefix location, Tk's --prefix location,
     3566            # relative to directory of tkConfig.sh, Tcl's --prefix location,
     3567            # relative to directory of tclConfig.sh.
     3568
     3569            eval "temp_includedir=${includedir}"
     3570            list="$list \
     3571                `ls -d ${temp_includedir}        2>/dev/null` \
     3572                `ls -d ${TK_PREFIX}/include      2>/dev/null` \
     3573                `ls -d ${TK_BIN_DIR}/../include  2>/dev/null` \
     3574                `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
     3575                `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
     3576            if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
     3577                list="$list /usr/local/include /usr/include"
     3578            fi
     3579            for i in $list ; do
     3580                if test -f "$i/tk.h" ; then
     3581                    ac_cv_c_tkh=$i
     3582                    break
     3583                fi
     3584            done
     3585        fi
     3586    ])
     3587
     3588    # Print a message based on how we determined the include path
     3589
     3590    if test x"${ac_cv_c_tkh}" = x ; then
     3591        AC_MSG_ERROR([tk.h not found.  Please specify its location with --with-tkinclude])
     3592    else
     3593        AC_MSG_RESULT([${ac_cv_c_tkh}])
     3594    fi
     3595
     3596    # Convert to a native path and substitute into the output files.
     3597
     3598    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}`
     3599
     3600    TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
     3601
     3602    AC_SUBST(TK_INCLUDES)
     3603
     3604    if test "${TEA_WINDOWINGSYSTEM}" = "win32" \
     3605        -o "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
     3606        # On Windows and Aqua, we need the X compat headers
     3607        AC_MSG_CHECKING([for X11 header files])
     3608        if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then
     3609            INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`"
     3610            TK_XINCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
     3611            AC_SUBST(TK_XINCLUDES)
     3612        fi
     3613        AC_MSG_RESULT([${INCLUDE_DIR_NATIVE}])
     3614    fi
     3615])
     3616
     3617#------------------------------------------------------------------------
     3618# TEA_PROG_TCLSH
     3619#       Determine the fully qualified path name of the tclsh executable
     3620#       in the Tcl build directory or the tclsh installed in a bin
     3621#       directory. This macro will correctly determine the name
     3622#       of the tclsh executable even if tclsh has not yet been
     3623#       built in the build directory. The tclsh found is always
     3624#       associated with a tclConfig.sh file. This tclsh should be used
     3625#       only for running extension test cases. It should never be
     3626#       or generation of files (like pkgIndex.tcl) at build time.
     3627#
     3628# Arguments
     3629#       none
     3630#
     3631# Results
     3632#       Subst's the following values:
     3633#               TCLSH_PROG
     3634#------------------------------------------------------------------------
     3635
     3636AC_DEFUN([TEA_PROG_TCLSH], [
     3637    AC_MSG_CHECKING([for tclsh])
     3638    if test -f "${TCL_BIN_DIR}/Makefile" ; then
     3639        # tclConfig.sh is in Tcl build directory
     3640        if test "${TEA_PLATFORM}" = "windows"; then
     3641            TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
     3642        else
     3643            TCLSH_PROG="${TCL_BIN_DIR}/tclsh"
     3644        fi
     3645    else
     3646        # tclConfig.sh is in install location
     3647        if test "${TEA_PLATFORM}" = "windows"; then
     3648            TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
     3649        else
     3650            TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}"
     3651        fi
     3652        list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \
     3653              `ls -d ${TCL_BIN_DIR}/..     2>/dev/null` \
     3654              `ls -d ${TCL_PREFIX}/bin     2>/dev/null`"
     3655        for i in $list ; do
     3656            if test -f "$i/${TCLSH_PROG}" ; then
     3657                REAL_TCL_BIN_DIR="`cd "$i"; pwd`"
     3658                break
     3659            fi
     3660        done
     3661        TCLSH_PROG="${REAL_TCL_BIN_DIR}/${TCLSH_PROG}"
     3662    fi
     3663    AC_MSG_RESULT([${TCLSH_PROG}])
     3664    AC_SUBST(TCLSH_PROG)
     3665])
     3666
     3667#------------------------------------------------------------------------
     3668# TEA_PROG_WISH
     3669#       Determine the fully qualified path name of the wish executable
     3670#       in the Tk build directory or the wish installed in a bin
     3671#       directory. This macro will correctly determine the name
     3672#       of the wish executable even if wish has not yet been
     3673#       built in the build directory. The wish found is always
     3674#       associated with a tkConfig.sh file. This wish should be used
     3675#       only for running extension test cases. It should never be
     3676#       or generation of files (like pkgIndex.tcl) at build time.
     3677#
     3678# Arguments
     3679#       none
     3680#
     3681# Results
     3682#       Subst's the following values:
     3683#               WISH_PROG
     3684#------------------------------------------------------------------------
     3685
     3686AC_DEFUN([TEA_PROG_WISH], [
     3687    AC_MSG_CHECKING([for wish])
     3688    if test -f "${TK_BIN_DIR}/Makefile" ; then
     3689        # tkConfig.sh is in Tk build directory
     3690        if test "${TEA_PLATFORM}" = "windows"; then
     3691            WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}"
     3692        else
     3693            WISH_PROG="${TK_BIN_DIR}/wish"
     3694        fi
     3695    else
     3696        # tkConfig.sh is in install location
     3697        if test "${TEA_PLATFORM}" = "windows"; then
     3698            WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}"
     3699        else
     3700            WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_DBGX}"
     3701        fi
     3702        list="`ls -d ${TK_BIN_DIR}/../bin 2>/dev/null` \
     3703              `ls -d ${TK_BIN_DIR}/..     2>/dev/null` \
     3704              `ls -d ${TK_PREFIX}/bin     2>/dev/null`"
     3705        for i in $list ; do
     3706            if test -f "$i/${WISH_PROG}" ; then
     3707                REAL_TK_BIN_DIR="`cd "$i"; pwd`"
     3708                break
     3709            fi
     3710        done
     3711        WISH_PROG="${REAL_TK_BIN_DIR}/${WISH_PROG}"
     3712    fi
     3713    AC_MSG_RESULT([${WISH_PROG}])
     3714    AC_SUBST(WISH_PROG)
     3715])
     3716
     3717#------------------------------------------------------------------------
     3718# TEA_PATH_CONFIG --
     3719#
     3720#       Locate the ${1}Config.sh file and perform a sanity check on
     3721#       the ${1} compile flags.  These are used by packages like
     3722#       [incr Tk] that load *Config.sh files from more than Tcl and Tk.
     3723#
     3724# Arguments:
     3725#       none
     3726#
     3727# Results:
     3728#
     3729#       Adds the following arguments to configure:
     3730#               --with-$1=...
     3731#
     3732#       Defines the following vars:
     3733#               $1_BIN_DIR      Full path to the directory containing
     3734#                               the $1Config.sh file
     3735#------------------------------------------------------------------------
     3736
     3737AC_DEFUN([TEA_PATH_CONFIG], [
     3738    #
     3739    # Ok, lets find the $1 configuration
     3740    # First, look for one uninstalled.
     3741    # the alternative search directory is invoked by --with-$1
     3742    #
     3743
     3744    if test x"${no_$1}" = x ; then
     3745        # we reset no_$1 in case something fails here
     3746        no_$1=true
     3747        AC_ARG_WITH($1, [  --with-$1              directory containing $1 configuration ($1Config.sh)], with_$1config=${withval})
     3748        AC_MSG_CHECKING([for $1 configuration])
     3749        AC_CACHE_VAL(ac_cv_c_$1config,[
     3750
     3751            # First check to see if --with-$1 was specified.
     3752            if test x"${with_$1config}" != x ; then
     3753                case ${with_$1config} in
     3754                    */$1Config.sh )
     3755                        if test -f ${with_$1config}; then
     3756                            AC_MSG_WARN([--with-$1 argument should refer to directory containing $1Config.sh, not to $1Config.sh itself])
     3757                            with_$1config=`echo ${with_$1config} | sed 's!/$1Config\.sh$!!'`
     3758                        fi;;
     3759                esac
     3760                if test -f "${with_$1config}/$1Config.sh" ; then
     3761                    ac_cv_c_$1config=`(cd ${with_$1config}; pwd)`
     3762                else
     3763                    AC_MSG_ERROR([${with_$1config} directory doesn't contain $1Config.sh])
     3764                fi
     3765            fi
     3766
     3767            # then check for a private $1 installation
     3768            if test x"${ac_cv_c_$1config}" = x ; then
    19683769                for i in \
    1969                         `ls -d ${temp_includedir} 2>/dev/null` \
    1970                         /usr/local/include /usr/include ; do
    1971                     if test -f "$i/tcl.h" ; then
    1972                         ac_cv_c_tclh=$i
     3770                        ../$1 \
     3771                        `ls -dr ../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
     3772                        `ls -dr ../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
     3773                        `ls -dr ../$1*[[0-9]].[[0-9]] 2>/dev/null` \
     3774                        `ls -dr ../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
     3775                        ../../$1 \
     3776                        `ls -dr ../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
     3777                        `ls -dr ../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
     3778                        `ls -dr ../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
     3779                        `ls -dr ../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
     3780                        ../../../$1 \
     3781                        `ls -dr ../../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
     3782                        `ls -dr ../../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
     3783                        `ls -dr ../../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
     3784                        `ls -dr ../../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
     3785                        ${srcdir}/../$1 \
     3786                        `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
     3787                        `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
     3788                        `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]] 2>/dev/null` \
     3789                        `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
     3790                        ; do
     3791                    if test -f "$i/$1Config.sh" ; then
     3792                        ac_cv_c_$1config=`(cd $i; pwd)`
     3793                        break
     3794                    fi
     3795                    if test -f "$i/unix/$1Config.sh" ; then
     3796                        ac_cv_c_$1config=`(cd $i/unix; pwd)`
    19733797                        break
    19743798                    fi
    19753799                done
    19763800            fi
     3801
     3802            # check in a few common install locations
     3803            if test x"${ac_cv_c_$1config}" = x ; then
     3804                for i in `ls -d ${libdir} 2>/dev/null` \
     3805                        `ls -d ${exec_prefix}/lib 2>/dev/null` \
     3806                        `ls -d ${prefix}/lib 2>/dev/null` \
     3807                        `ls -d /usr/local/lib 2>/dev/null` \
     3808                        `ls -d /usr/contrib/lib 2>/dev/null` \
     3809                        `ls -d /usr/lib 2>/dev/null` \
     3810                        ; do
     3811                    if test -f "$i/$1Config.sh" ; then
     3812                        ac_cv_c_$1config=`(cd $i; pwd)`
     3813                        break
     3814                    fi
     3815                done
     3816            fi
    19773817        ])
    1978     fi
    1979 
    1980     # Print a message based on how we determined the include path
    1981 
    1982     if test x"${ac_cv_c_tclh}" = x ; then
    1983         AC_MSG_ERROR(tcl.h not found.  Please specify its location with --with-tclinclude)
     3818
     3819        if test x"${ac_cv_c_$1config}" = x ; then
     3820            $1_BIN_DIR="# no $1 configs found"
     3821            AC_MSG_WARN([Cannot find $1 configuration definitions])
     3822            exit 0
     3823        else
     3824            no_$1=
     3825            $1_BIN_DIR=${ac_cv_c_$1config}
     3826            AC_MSG_RESULT([found $$1_BIN_DIR/$1Config.sh])
     3827        fi
     3828    fi
     3829])
     3830
     3831#------------------------------------------------------------------------
     3832# TEA_LOAD_CONFIG --
     3833#
     3834#       Load the $1Config.sh file
     3835#
     3836# Arguments:
     3837#       
     3838#       Requires the following vars to be set:
     3839#               $1_BIN_DIR
     3840#
     3841# Results:
     3842#
     3843#       Subst the following vars:
     3844#               $1_SRC_DIR
     3845#               $1_LIB_FILE
     3846#               $1_LIB_SPEC
     3847#
     3848#------------------------------------------------------------------------
     3849
     3850AC_DEFUN([TEA_LOAD_CONFIG], [
     3851    AC_MSG_CHECKING([for existence of ${$1_BIN_DIR}/$1Config.sh])
     3852
     3853    if test -f "${$1_BIN_DIR}/$1Config.sh" ; then
     3854        AC_MSG_RESULT([loading])
     3855        . ${$1_BIN_DIR}/$1Config.sh
    19843856    else
    1985         AC_MSG_RESULT(${ac_cv_c_tclh})
    1986     fi
    1987 
    1988     # Convert to a native path and substitute into the output files.
    1989 
    1990     INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
    1991 
    1992     TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
    1993 
    1994     AC_SUBST(TCL_INCLUDES)
    1995 ])
     3857        AC_MSG_RESULT([file not found])
     3858    fi
     3859
     3860    #
     3861    # If the $1_BIN_DIR is the build directory (not the install directory),
     3862    # then set the common variable name to the value of the build variables.
     3863    # For example, the variable $1_LIB_SPEC will be set to the value
     3864    # of $1_BUILD_LIB_SPEC. An extension should make use of $1_LIB_SPEC
     3865    # instead of $1_BUILD_LIB_SPEC since it will work with both an
     3866    # installed and uninstalled version of Tcl.
     3867    #
     3868
     3869    if test -f ${$1_BIN_DIR}/Makefile ; then
     3870        AC_MSG_WARN([Found Makefile - using build library specs for $1])
     3871        $1_LIB_SPEC=${$1_BUILD_LIB_SPEC}
     3872        $1_STUB_LIB_SPEC=${$1_BUILD_STUB_LIB_SPEC}
     3873        $1_STUB_LIB_PATH=${$1_BUILD_STUB_LIB_PATH}
     3874    fi
     3875
     3876    AC_SUBST($1_VERSION)
     3877    AC_SUBST($1_BIN_DIR)
     3878    AC_SUBST($1_SRC_DIR)
     3879
     3880    AC_SUBST($1_LIB_FILE)
     3881    AC_SUBST($1_LIB_SPEC)
     3882
     3883    AC_SUBST($1_STUB_LIB_FILE)
     3884    AC_SUBST($1_STUB_LIB_SPEC)
     3885    AC_SUBST($1_STUB_LIB_PATH)
     3886])
     3887
     3888#------------------------------------------------------------------------
     3889# TEA_PATH_CELIB --
     3890#
     3891#       Locate Keuchel's celib emulation layer for targeting Win/CE
     3892#
     3893# Arguments:
     3894#       none
     3895#
     3896# Results:
     3897#
     3898#       Adds the following arguments to configure:
     3899#               --with-celib=...
     3900#
     3901#       Defines the following vars:
     3902#               CELIB_DIR       Full path to the directory containing
     3903#                               the include and platform lib files
     3904#------------------------------------------------------------------------
     3905
     3906AC_DEFUN([TEA_PATH_CELIB], [
     3907    # First, look for one uninstalled.
     3908    # the alternative search directory is invoked by --with-celib
     3909
     3910    if test x"${no_celib}" = x ; then
     3911        # we reset no_celib in case something fails here
     3912        no_celib=true
     3913        AC_ARG_WITH(celib,[  --with-celib=DIR        use Windows/CE support library from DIR], with_celibconfig=${withval})
     3914        AC_MSG_CHECKING([for Windows/CE celib directory])
     3915        AC_CACHE_VAL(ac_cv_c_celibconfig,[
     3916            # First check to see if --with-celibconfig was specified.
     3917            if test x"${with_celibconfig}" != x ; then
     3918                if test -d "${with_celibconfig}/inc" ; then
     3919                    ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)`
     3920                else
     3921                    AC_MSG_ERROR([${with_celibconfig} directory doesn't contain inc directory])
     3922                fi
     3923            fi
     3924
     3925            # then check for a celib library
     3926            if test x"${ac_cv_c_celibconfig}" = x ; then
     3927                for i in \
     3928                        ../celib-palm-3.0 \
     3929                        ../celib \
     3930                        ../../celib-palm-3.0 \
     3931                        ../../celib \
     3932                        `ls -dr ../celib-*3.[[0-9]]* 2>/dev/null` \
     3933                        ${srcdir}/../celib-palm-3.0 \
     3934                        ${srcdir}/../celib \
     3935                        `ls -dr ${srcdir}/../celib-*3.[[0-9]]* 2>/dev/null` \
     3936                        ; do
     3937                    if test -d "$i/inc" ; then
     3938                        ac_cv_c_celibconfig=`(cd $i; pwd)`
     3939                        break
     3940                    fi
     3941                done
     3942            fi
     3943        ])
     3944        if test x"${ac_cv_c_celibconfig}" = x ; then
     3945            AC_MSG_ERROR([Cannot find celib support library directory])
     3946        else
     3947            no_celib=
     3948            CELIB_DIR=${ac_cv_c_celibconfig}
     3949            CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'`
     3950            AC_MSG_RESULT([found $CELIB_DIR])
     3951        fi
     3952    fi
     3953])
     3954
     3955
     3956# Local Variables:
     3957# mode: autoconf
     3958# End:
Note: See TracChangeset for help on using the changeset viewer.