Ignore:
Timestamp:
Jun 8, 2008 6:24:34 PM (16 years ago)
Author:
gah
Message:

Massive changes: New directory/file layout

Location:
trunk/lang
Files:
1 added
1 edited
1 moved

Legend:

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

    r618 r1018  
    1 # tcl.m4 --
    2 #
    3 #       This file provides a set of autoconf macros to help TEA-enable
    4 #       a Tcl extension.
    5 #
    6 # Copyright (c) 1999-2000 Ajuba Solutions.
    7 # Copyright (c) 2002-2005 ActiveState Corporation.
    8 #
    9 # See the file "license.terms" for information on usage and redistribution
    10 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    11 #
    12 # RCS: @(#) $Id: tcl.m4,v 1.92 2006/05/26 19:15:38 das Exp $
    13 
    14 AC_PREREQ(2.50)
    15 
    16 dnl TEA extensions pass this us the version of TEA they think they
    17 dnl are compatible with (must be set in TEA_INIT below)
    18 dnl 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 
    261#------------------------------------------------------------------------
    27 # TEA_PATH_TCLCONFIG --
     2# SC_PATH_TCLCONFIG --
    283#
    294#       Locate the tclConfig.sh file and perform a sanity check on
     
    4318#------------------------------------------------------------------------
    4419
    45 AC_DEFUN([TEA_PATH_TCLCONFIG], [
    46     dnl Make sure we are initialized
    47     AC_REQUIRE([TEA_INIT])
     20AC_DEFUN([SC_PATH_TCLCONFIG], [
    4821    #
    4922    # Ok, lets find the tcl configuration
     
    5528        # we reset no_tcl in case something fails here
    5629        no_tcl=true
    57         AC_ARG_WITH(tcl,
    58             AC_HELP_STRING([--with-tcl],
    59                 [directory containing tcl configuration (tclConfig.sh)]),
    60             with_tclconfig=${withval})
     30        AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
    6131        AC_MSG_CHECKING([for Tcl configuration])
    6232        AC_CACHE_VAL(ac_cv_c_tclconfig,[
     
    6434            # First check to see if --with-tcl was specified.
    6535            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
    7336                if test -f "${with_tclconfig}/tclConfig.sh" ; then
    7437                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
     
    11477            fi
    11578
    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
    122                     if test -f "$i/tclConfig.sh" ; then
    123                         ac_cv_c_tclconfig=`(cd $i; pwd)`
    124                         break
    125                     fi
    126                 done
    127             fi
    128 
    12979            # check in a few common install locations
    13080            if test x"${ac_cv_c_tclconfig}" = x ; then
     
    171121
    172122#------------------------------------------------------------------------
    173 # TEA_PATH_TKCONFIG --
     123# SC_PATH_TKCONFIG --
    174124#
    175125#       Locate the tkConfig.sh file
     
    188138#------------------------------------------------------------------------
    189139
    190 AC_DEFUN([TEA_PATH_TKCONFIG], [
     140AC_DEFUN([SC_PATH_TKCONFIG], [
    191141    #
    192142    # Ok, lets find the tk configuration
     
    198148        # we reset no_tk in case something fails here
    199149        no_tk=true
    200         AC_ARG_WITH(tk,
    201             AC_HELP_STRING([--with-tk],
    202                 [directory containing tk configuration (tkConfig.sh)]),
    203             with_tkconfig=${withval})
     150        AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
    204151        AC_MSG_CHECKING([for Tk configuration])
    205152        AC_CACHE_VAL(ac_cv_c_tkconfig,[
     
    207154            # First check to see if --with-tkconfig was specified.
    208155            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
    216156                if test -f "${with_tkconfig}/tkConfig.sh" ; then
    217157                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
     
    272212                done
    273213            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 
    288214            # check in a few other private locations
    289215            if test x"${ac_cv_c_tkconfig}" = x ; then
     
    314240
    315241#------------------------------------------------------------------------
    316 # TEA_LOAD_TCLCONFIG --
     242# SC_LOAD_TCLCONFIG --
    317243#
    318244#       Load the tclConfig.sh file
     
    332258#------------------------------------------------------------------------
    333259
    334 AC_DEFUN([TEA_LOAD_TCLCONFIG], [
     260AC_DEFUN([SC_LOAD_TCLCONFIG], [
    335261    AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
    336262
     
    386312
    387313    AC_SUBST(TCL_VERSION)
     314    AC_SUBST(TCL_PATCH_LEVEL)
    388315    AC_SUBST(TCL_BIN_DIR)
    389316    AC_SUBST(TCL_SRC_DIR)
     
    396323    AC_SUBST(TCL_STUB_LIB_FLAG)
    397324    AC_SUBST(TCL_STUB_LIB_SPEC)
    398 
    399     AC_SUBST(TCL_LIBS)
    400     AC_SUBST(TCL_DEFS)
    401     AC_SUBST(TCL_EXTRA_CFLAGS)
    402     AC_SUBST(TCL_LD_FLAGS)
    403     AC_SUBST(TCL_SHLIB_LD_LIBS)
    404325])
    405326
    406327#------------------------------------------------------------------------
    407 # TEA_LOAD_TKCONFIG --
     328# SC_LOAD_TKCONFIG --
    408329#
    409330#       Load the tkConfig.sh file
     
    420341#------------------------------------------------------------------------
    421342
    422 AC_DEFUN([TEA_LOAD_TKCONFIG], [
     343AC_DEFUN([SC_LOAD_TKCONFIG], [
    423344    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
    424345
     
    473394    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
    474395
    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 
    490396    AC_SUBST(TK_VERSION)
    491397    AC_SUBST(TK_BIN_DIR)
     
    499405    AC_SUBST(TK_STUB_LIB_FLAG)
    500406    AC_SUBST(TK_STUB_LIB_SPEC)
    501 
    502     AC_SUBST(TK_LIBS)
    503     AC_SUBST(TK_XINCLUDES)
    504407])
    505408
    506409#------------------------------------------------------------------------
    507 # TEA_ENABLE_SHARED --
     410# SC_PROG_TCLSH
     411#       Locate a tclsh shell installed on the system path. This macro
     412#       will only find a Tcl shell that already exists on the system.
     413#       It will not find a Tcl shell in the Tcl build directory or
     414#       a Tcl shell that has been installed from the Tcl build directory.
     415#       If a Tcl shell can't be located on the PATH, then TCLSH_PROG will
     416#       be set to "". Extensions should take care not to create Makefile
     417#       rules that are run by default and depend on TCLSH_PROG. An
     418#       extension can't assume that an executable Tcl shell exists at
     419#       build time.
     420#
     421# Arguments
     422#       none
     423#
     424# Results
     425#       Subst's the following values:
     426#               TCLSH_PROG
     427#------------------------------------------------------------------------
     428
     429AC_DEFUN([SC_PROG_TCLSH], [
     430    AC_MSG_CHECKING([for tclsh])
     431    AC_CACHE_VAL(ac_cv_path_tclsh, [
     432        search_path=`echo ${PATH} | sed -e 's/:/ /g'`
     433        for dir in $search_path ; do
     434            for j in `ls -r $dir/tclsh[[8-9]]* 2> /dev/null` \
     435                    `ls -r $dir/tclsh* 2> /dev/null` ; do
     436                if test x"$ac_cv_path_tclsh" = x ; then
     437                    if test -f "$j" ; then
     438                        ac_cv_path_tclsh=$j
     439                        break
     440                    fi
     441                fi
     442            done
     443        done
     444    ])
     445
     446    if test -f "$ac_cv_path_tclsh" ; then
     447        TCLSH_PROG="$ac_cv_path_tclsh"
     448        AC_MSG_RESULT([$TCLSH_PROG])
     449    else
     450        # It is not an error if an installed version of Tcl can't be located.
     451        TCLSH_PROG=""
     452        AC_MSG_RESULT([No tclsh found on PATH])
     453    fi
     454    AC_SUBST(TCLSH_PROG)
     455])
     456
     457#------------------------------------------------------------------------
     458# SC_BUILD_TCLSH
     459#       Determine the fully qualified path name of the tclsh executable
     460#       in the Tcl build directory. This macro will correctly determine
     461#       the name of the tclsh executable even if tclsh has not yet
     462#       been built in the build directory. The build tclsh must be used
     463#       when running tests from an extension build directory. It is not
     464#       correct to use the TCLSH_PROG in cases like this.
     465#
     466# Arguments
     467#       none
     468#
     469# Results
     470#       Subst's the following values:
     471#               BUILD_TCLSH
     472#------------------------------------------------------------------------
     473
     474AC_DEFUN([SC_BUILD_TCLSH], [
     475    AC_MSG_CHECKING([for tclsh in Tcl build directory])
     476    BUILD_TCLSH=${TCL_BIN_DIR}/tclsh
     477    AC_MSG_RESULT([$BUILD_TCLSH])
     478    AC_SUBST(BUILD_TCLSH)
     479])
     480
     481#------------------------------------------------------------------------
     482# SC_ENABLE_SHARED --
    508483#
    509484#       Allows the building of shared libraries
     
    525500#------------------------------------------------------------------------
    526501
    527 AC_DEFUN([TEA_ENABLE_SHARED], [
     502AC_DEFUN([SC_ENABLE_SHARED], [
    528503    AC_MSG_CHECKING([how to build libraries])
    529504    AC_ARG_ENABLE(shared,
    530         AC_HELP_STRING([--enable-shared],
    531             [build and link with shared libraries (default: on)]),
     505        [  --enable-shared         build and link with shared libraries [--enable-shared]],
    532506        [tcl_ok=$enableval], [tcl_ok=yes])
    533507
     
    545519        AC_MSG_RESULT([static])
    546520        SHARED_BUILD=0
    547         AC_DEFINE(STATIC_BUILD, 1, [Is this a static build?])
    548     fi
    549     AC_SUBST(SHARED_BUILD)
     521        AC_DEFINE(STATIC_BUILD)
     522    fi
    550523])
    551524
    552525#------------------------------------------------------------------------
    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.
     526# SC_ENABLE_FRAMEWORK --
     527#
     528#       Allows the building of shared libraries into frameworks
    566529#
    567530# Arguments:
     
    571534#
    572535#       Adds the following arguments to configure:
     536#               --enable-framework=yes|no
     537#
     538#       Sets the following vars:
     539#               FRAMEWORK_BUILD Value of 1 or 0
     540#------------------------------------------------------------------------
     541
     542AC_DEFUN([SC_ENABLE_FRAMEWORK], [
     543    if test "`uname -s`" = "Darwin" ; then
     544        AC_MSG_CHECKING([how to package libraries])
     545        AC_ARG_ENABLE(framework,
     546            [  --enable-framework      package shared libraries in MacOSX frameworks [--disable-framework]],
     547            [enable_framework=$enableval], [enable_framework=no])
     548        if test $enable_framework = yes; then
     549            if test $SHARED_BUILD = 0; then
     550                AC_MSG_WARN([Frameworks can only be built if --enable-shared is yes])
     551                enable_framework=no
     552            fi
     553            if test $tcl_corefoundation = no; then
     554                AC_MSG_WARN([Frameworks can only be used when CoreFoundation is available])
     555                enable_framework=no
     556            fi
     557        fi
     558        if test $enable_framework = yes; then
     559            AC_MSG_RESULT([framework])
     560            FRAMEWORK_BUILD=1
     561        else
     562            if test $SHARED_BUILD = 1; then
     563                AC_MSG_RESULT([shared library])
     564            else
     565                AC_MSG_RESULT([static library])
     566            fi
     567            FRAMEWORK_BUILD=0
     568        fi
     569    fi
     570])
     571
     572#------------------------------------------------------------------------
     573# SC_ENABLE_THREADS --
     574#
     575#       Specify if thread support should be enabled.  TCL_THREADS is
     576#       checked so that if you are compiling an extension against a
     577#       threaded core, your extension must be compiled threaded as well.
     578#
     579# Arguments:
     580#       none
     581#       
     582# Results:
     583#
     584#       Adds the following arguments to configure:
    573585#               --enable-threads
    574586#
     
    583595#------------------------------------------------------------------------
    584596
    585 AC_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
     597AC_DEFUN([SC_ENABLE_THREADS], [
     598    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
     599        [tcl_ok=$enableval], [tcl_ok=no])
     600
     601    if test "${TCL_THREADS}" = 1; then
     602        tcl_threaded_core=1;
    596603    fi
    597604
    598605    if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
    599606        TCL_THREADS=1
    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 
     607        # USE_THREAD_ALLOC tells us to try the special thread-based
     608        # allocator that significantly reduces lock contention
     609        AC_DEFINE(USE_THREAD_ALLOC)
     610        AC_DEFINE(_REENTRANT)
     611        if test "`uname -s`" = "SunOS" ; then
     612            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
     613        fi
     614        AC_DEFINE(_THREAD_SAFE)
     615        AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
     616        if test "$tcl_ok" = "no"; then
     617            # Check a little harder for __pthread_mutex_init in the same
     618            # library, as some systems hide it there until pthread.h is
     619            # defined.  We could alternatively do an AC_TRY_COMPILE with
     620            # pthread.h, but that will work with libpthread really doesn't
     621            # exist, like AIX 4.2.  [Bug: 4359]
     622            AC_CHECK_LIB(pthread, __pthread_mutex_init,
     623                tcl_ok=yes, tcl_ok=no)
     624        fi
     625
     626        if test "$tcl_ok" = "yes"; then
     627            # The space is needed
     628            THREADS_LIBS=" -lpthread"
     629        else
     630            AC_CHECK_LIB(pthreads, pthread_mutex_init,
     631                tcl_ok=yes, tcl_ok=no)
    625632            if test "$tcl_ok" = "yes"; then
    626633                # The space is needed
    627                 THREADS_LIBS=" -lpthread"
     634                THREADS_LIBS=" -lpthreads"
    628635            else
    629                 AC_CHECK_LIB(pthreads, pthread_mutex_init,
     636                AC_CHECK_LIB(c, pthread_mutex_init,
    630637                    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,
     638                if test "$tcl_ok" = "no"; then
     639                    AC_CHECK_LIB(c_r, pthread_mutex_init,
    636640                        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
     641                    if test "$tcl_ok" = "yes"; then
     642                        # The space is needed
     643                        THREADS_LIBS=" -pthread"
     644                    else
     645                        TCL_THREADS=0
     646                        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...])
    647647                    fi
    648648                fi
    649649            fi
    650650        fi
     651
     652        # Does the pthread-implementation provide
     653        # 'pthread_attr_setstacksize' ?
     654
     655        ac_saved_libs=$LIBS
     656        LIBS="$LIBS $THREADS_LIBS"
     657        AC_CHECK_FUNCS(pthread_attr_setstacksize)
     658        AC_CHECK_FUNCS(pthread_atfork)
     659        LIBS=$ac_saved_libs
    651660    else
    652661        TCL_THREADS=0
     
    656665    if test "${TCL_THREADS}" = 1; then
    657666        AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
    658         AC_MSG_RESULT([yes (default)])
     667        if test "${tcl_threaded_core}" = 1; then
     668            AC_MSG_RESULT([yes (threaded core)])
     669        else
     670            AC_MSG_RESULT([yes])
     671        fi
    659672    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
     673        AC_MSG_RESULT([no (default)])
     674    fi
     675
    681676    AC_SUBST(TCL_THREADS)
    682677])
    683678
    684679#------------------------------------------------------------------------
    685 # TEA_ENABLE_SYMBOLS --
     680# SC_ENABLE_SYMBOLS --
    686681#
    687682#       Specify if debugging symbols should be used.
    688 #       Memory (TCL_MEM_DEBUG) debugging can also be enabled.
     683#       Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
     684#       can also be enabled.
    689685#
    690686# Arguments:
    691687#       none
    692688#       
    693 #       TEA varies from core Tcl in that C|LDFLAGS_DEFAULT receives
    694 #       the value of C|LDFLAGS_OPTIMIZE|DEBUG already substituted.
    695689#       Requires the following vars to be set in the Makefile:
    696 #               CFLAGS_DEFAULT
    697 #               LDFLAGS_DEFAULT
     690#               CFLAGS_DEBUG
     691#               CFLAGS_OPTIMIZE
     692#               LDFLAGS_DEBUG
     693#               LDFLAGS_OPTIMIZE
    698694#       
    699695# Results:
     
    707703#               LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
    708704#                               Sets to $(LDFLAGS_OPTIMIZE) if false
    709 #               DBGX            Formerly used as debug library extension;
    710 #                               always blank now.
     705#               DBGX            Debug library extension
    711706#
    712707#------------------------------------------------------------------------
    713708
    714 AC_DEFUN([TEA_ENABLE_SYMBOLS], [
    715     dnl Make sure we are initialized
    716     AC_REQUIRE([TEA_CONFIG_CFLAGS])
     709AC_DEFUN([SC_ENABLE_SYMBOLS], [
    717710    AC_MSG_CHECKING([for build with symbols])
    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=""
     711    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
     712# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
    723713    if test "$tcl_ok" = "no"; then
    724         CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
    725         LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
     714        CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
     715        LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
     716        DBGX=""
    726717        AC_MSG_RESULT([no])
    727718    else
    728         CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
    729         LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
     719        CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
     720        LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
     721        DBGX=g
    730722        if test "$tcl_ok" = "yes"; then
    731723            AC_MSG_RESULT([yes (standard debugging)])
    732724        fi
    733725    fi
    734     if test "${TEA_PLATFORM}" != "windows" ; then
    735         LDFLAGS_DEFAULT="${LDFLAGS}"
    736     fi
    737 
    738     AC_SUBST(TCL_DBGX)
    739726    AC_SUBST(CFLAGS_DEFAULT)
    740727    AC_SUBST(LDFLAGS_DEFAULT)
    741728
    742729    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
    743         AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?])
     730        AC_DEFINE(TCL_MEM_DEBUG)
     731    fi
     732
     733    if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
     734        AC_DEFINE(TCL_COMPILE_DEBUG)
     735        AC_DEFINE(TCL_COMPILE_STATS)
    744736    fi
    745737
    746738    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
    747739        if test "$tcl_ok" = "all"; then
    748             AC_MSG_RESULT([enabled symbols mem debugging])
     740            AC_MSG_RESULT([enabled symbols mem compile debugging])
    749741        else
    750742            AC_MSG_RESULT([enabled $tcl_ok debugging])
     
    754746
    755747#------------------------------------------------------------------------
    756 # TEA_ENABLE_LANGINFO --
     748# SC_ENABLE_LANGINFO --
    757749#
    758750#       Allows use of modern nl_langinfo check for better l10n.
     
    772764#------------------------------------------------------------------------
    773765
    774 AC_DEFUN([TEA_ENABLE_LANGINFO], [
     766AC_DEFUN([SC_ENABLE_LANGINFO], [
    775767    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)]),
     768        [  --enable-langinfo      use nl_langinfo if possible to determine
     769                          encoding at startup, otherwise use old heuristic],
    778770        [langinfo_ok=$enableval], [langinfo_ok=yes])
    779771
     
    784776    AC_MSG_CHECKING([whether to use nl_langinfo])
    785777    if test "$langinfo_ok" = "yes"; then
    786         AC_CACHE_VAL(tcl_cv_langinfo_h,
     778        AC_CACHE_VAL(tcl_cv_langinfo_h, [
    787779            AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
    788                     [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no]))
     780                    [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no])])
    789781        AC_MSG_RESULT([$tcl_cv_langinfo_h])
    790782        if test $tcl_cv_langinfo_h = yes; then
    791             AC_DEFINE(HAVE_LANGINFO, 1, [Do we have nl_langinfo()?])
     783            AC_DEFINE(HAVE_LANGINFO)
    792784        fi
    793785    else
     
    797789
    798790#--------------------------------------------------------------------
    799 # TEA_CONFIG_SYSTEM
     791# SC_CONFIG_MANPAGES
     792#       
     793#       Decide whether to use symlinks for linking the manpages,
     794#       whether to compress the manpages after installation, and
     795#       whether to add a package name suffix to the installed
     796#       manpages to avoidfile name clashes.
     797#       If compression is enabled also find out what file name suffix
     798#       the given compression program is using.
     799#
     800# Arguments:
     801#       none
     802#
     803# Results:
     804#
     805#       Adds the following arguments to configure:
     806#               --enable-man-symlinks
     807#               --enable-man-compression=PROG
     808#               --enable-man-suffix[=STRING]
     809#
     810#       Defines the following variable:
     811#
     812#       MAN_FLAGS -     The apropriate flags for installManPage
     813#                       according to the user's selection.
     814#
     815#--------------------------------------------------------------------
     816
     817AC_DEFUN([SC_CONFIG_MANPAGES], [
     818    AC_MSG_CHECKING([whether to use symlinks for manpages])
     819    AC_ARG_ENABLE(man-symlinks,
     820            [  --enable-man-symlinks   use symlinks for the manpages],
     821        test "$enableval" != "no" && MAN_FLAGS="$MAN_FLAGS --symlinks",
     822        enableval="no")
     823    AC_MSG_RESULT([$enableval])
     824
     825    AC_MSG_CHECKING([whether to compress the manpages])
     826    AC_ARG_ENABLE(man-compression,
     827            [  --enable-man-compression=PROG
     828                      compress the manpages with PROG],
     829        [case $enableval in
     830            yes) AC_MSG_ERROR([missing argument to --enable-man-compression]);;
     831            no)  ;;
     832            *)   MAN_FLAGS="$MAN_FLAGS --compress $enableval";;
     833        esac],
     834        enableval="no")
     835    AC_MSG_RESULT([$enableval])
     836    if test "$enableval" != "no"; then
     837        AC_MSG_CHECKING([for compressed file suffix])
     838        touch TeST
     839        $enableval TeST
     840        Z=`ls TeST* | sed 's/^....//'`
     841        rm -f TeST*
     842        MAN_FLAGS="$MAN_FLAGS --extension $Z"
     843        AC_MSG_RESULT([$Z])
     844    fi
     845
     846    AC_MSG_CHECKING([whether to add a package name suffix for the manpages])
     847    AC_ARG_ENABLE(man-suffix,
     848            [  --enable-man-suffix=STRING
     849                      use STRING as a suffix to manpage file names
     850                      (default: $1)],
     851        [case $enableval in
     852            yes) enableval="$1" MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
     853            no)  ;;
     854            *)   MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
     855        esac],
     856        enableval="no")
     857    AC_MSG_RESULT([$enableval])
     858
     859    AC_SUBST(MAN_FLAGS)
     860])
     861
     862#--------------------------------------------------------------------
     863# SC_CONFIG_SYSTEM
    800864#
    801865#       Determine what the system is (some things cannot be easily checked
     
    814878#--------------------------------------------------------------------
    815879
    816 AC_DEFUN([TEA_CONFIG_SYSTEM], [
     880AC_DEFUN([SC_CONFIG_SYSTEM], [
    817881    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
     882        if test -f /usr/lib/NextStep/software_version; then
    821883            tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
    822884        else
     
    830892
    831893                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`
     894                    tcl_cv_sys_version=MP-RAS-`awk '{print $[3]}' /etc/.relid`
    833895                fi
    834896                if test "`uname -s`" = "AIX" ; then
     
    842904
    843905#--------------------------------------------------------------------
    844 # TEA_CONFIG_CFLAGS
     906# SC_CONFIG_CFLAGS
    845907#
    846908#       Try to determine the proper flags to pass to the compiler
     
    870932#                       for shared libraries such as libtcl.so.  Depends on
    871933#                       the variable LIB_RUNTIME_DIR in the Makefile.
     934#       MAKE_LIB -      Command to execute to build the a library;
     935#                       differs when building shared or static.
     936#       MAKE_STUB_LIB -
     937#                       Command to execute to build a stub library.
     938#       INSTALL_LIB -   Command to execute to install a library;
     939#                       differs when building shared or static.
     940#       INSTALL_STUB_LIB -
     941#                       Command to execute to install a stub library.
     942#       STLIB_LD -      Base command to use for combining object files
     943#                       into a static library.
    872944#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
    873945#                       of a shared library (may request position-independent
     
    889961#                       extensions.  An empty string means we don't know how
    890962#                       to use shared libraries on this platform.
     963# TCL_SHLIB_LD_EXTRAS - Additional element which are added to SHLIB_LD_LIBS
     964#  TK_SHLIB_LD_EXTRAS   for the build of Tcl and Tk, but not recorded in the
     965#                       tclConfig.sh, since they are only used for the build
     966#                       of Tcl and Tk.
     967#                       Examples: MacOS X records the library version and
     968#                       compatibility version in the shared library.  But
     969#                       of course the Tcl version of this is only used for Tcl.
    891970#       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
    892971#                       in a static or shared library name, using the $VERSION variable
     
    917996#--------------------------------------------------------------------
    918997
    919 AC_DEFUN([TEA_CONFIG_CFLAGS], [
    920     dnl Make sure we are initialized
    921     AC_REQUIRE([TEA_INIT])
     998AC_DEFUN([SC_CONFIG_CFLAGS], [
    922999
    9231000    # Step 0.a: Enable 64 bit support?
    9241001
    9251002    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)]),
     1003    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support (where applicable)],
    9291004        [do64bit=$enableval], [do64bit=no])
    9301005    AC_MSG_RESULT([$do64bit])
     
    9331008
    9341009    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)]),
     1010    AC_ARG_ENABLE(64bit-vis,[  --enable-64bit-vis      enable 64bit Sparc VIS support],
    9381011        [do64bitVIS=$enableval], [do64bitVIS=no])
    9391012    AC_MSG_RESULT([$do64bitVIS])
     
    9441017    fi
    9451018
    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 
    9541019    # Step 1: set the variable "system" to hold the name and version number
    9551020    # for the system.
    9561021
    957     TEA_CONFIG_SYSTEM
     1022    SC_CONFIG_SYSTEM
    9581023
    9591024    # Step 2: check for existence of -ldl library.  This is needed because
     
    9671032
    9681033    # 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.
    9711034
    9721035    do64bit_ok=no
    9731036    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=""
    9781037    TCL_EXPORT_FILE_SUFFIX=""
    9791038    UNSHARED_LIB_SUFFIX=""
    980     TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`'
    981     ECHO_VERSION='`echo ${PACKAGE_VERSION}`'
     1039    TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
     1040    ECHO_VERSION='`echo ${VERSION}`'
    9821041    TCL_LIB_VERSIONS_OK=ok
    9831042    CFLAGS_DEBUG=-g
    9841043    CFLAGS_OPTIMIZE=-O
    9851044    if test "$GCC" = "yes" ; then
    986         CFLAGS_OPTIMIZE=-O2
    987         CFLAGS_WARNING="-Wall -Wno-implicit-int"
     1045        CFLAGS_WARNING="-Wall -Wno-implicit-int -fno-strict-aliasing"
    9881046    else
    9891047        CFLAGS_WARNING=""
     
    9951053dnl AC_CHECK_TOOL(AR, ar)
    9961054    AC_CHECK_PROG(AR, ar, ar)
     1055    if test "${AR}" = "" ; then
     1056        AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
     1057    fi
    9971058    STLIB_LD='${AR} cr'
    9981059    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
     1060    PLAT_OBJS=""
     1061    PLAT_SRCS=""
    9991062    case $system in
    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             ;;
    11831063        AIX-*)
    11841064            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
     
    11961076            LIBS="$LIBS -lc"
    11971077            SHLIB_CFLAGS=""
     1078            # Note: need the LIBS below, otherwise Tk won't find Tcl's
     1079            # symbols when dynamically loaded into tclsh.
    11981080            SHLIB_LD_LIBS='${LIBS}'
    11991081            SHLIB_SUFFIX=".so"
     
    12091091                    do64bit_ok=yes
    12101092                    CFLAGS="$CFLAGS -q64"
    1211                     LDFLAGS_ARCH="-q64"
     1093                    LDFLAGS="$LDFLAGS -q64"
    12121094                    RANLIB="${RANLIB} -X64"
    12131095                    AR="${AR} -X64"
     
    12381120                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
    12391121                TCL_NEEDS_EXP_FILE=1
    1240                 TCL_EXPORT_FILE_SUFFIX='${PACKAGE_VERSION}.exp'
     1122                TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
    12411123            fi
    12421124
    12431125            # AIX v<=4.1 has some different flags than 4.2+
    12441126            if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
    1245                 AC_LIBOBJ([tclLoadAix])
     1127                LIBOBJS="$LIBOBJS tclLoadAix.o"
    12461128                DL_LIBS="-lld"
    12471129            fi
     
    12621144            if test $libbsd = yes; then
    12631145                MATH_LIBS="$MATH_LIBS -lbsd"
    1264                 AC_DEFINE(USE_DELTA_FOR_TZ, 1, [Do we need a special AIX hack for timezones?])
     1146                AC_DEFINE(USE_DELTA_FOR_TZ)
    12651147            fi
    12661148            ;;
     
    13131195        HP-UX-*.11.*)
    13141196            # 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"
     1197            AC_DEFINE(_XOPEN_SOURCE)          # Use the XOPEN network library
     1198            AC_DEFINE(_XOPEN_SOURCE_EXTENDED) # Use the XOPEN network library
     1199            LIBS="$LIBS -lxnet"               # Use the XOPEN network library
     1200
     1201            if test "`uname -m`" = "ia64" ; then
     1202                SHLIB_SUFFIX=".so"
     1203            else
     1204                SHLIB_SUFFIX=".sl"
     1205            fi
    13211206            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
    13221207            if test "$tcl_ok" = yes; then
     
    13601245                    do64bit_ok=yes
    13611246                    CFLAGS="$CFLAGS +DD64"
    1362                     LDFLAGS_ARCH="+DD64"
     1247                    LDFLAGS="$LDFLAGS +DD64"
    13631248                fi
    13641249            fi
     
    13781263                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
    13791264            fi
     1265            ;;
     1266        IRIX-4.*)
     1267            SHLIB_CFLAGS="-G 0"
     1268            SHLIB_SUFFIX=".a"
     1269            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
     1270            SHLIB_LD_LIBS='${LIBS}'
     1271            DL_OBJS="tclLoadAout.o"
     1272            DL_LIBS=""
     1273            LDFLAGS="$LDFLAGS -Wl,-D,08000000"
     1274            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1275            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1276            SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
    13801277            ;;
    13811278        IRIX-5.*)
     
    14331330                    SHLIB_LD="ld -64 -shared -rdata_shared"
    14341331                    CFLAGS="$CFLAGS -64"
    1435                     LDFLAGS_ARCH="-64"
     1332                    LDFLAGS="$LDFLAGS -64"
    14361333                fi
    14371334            fi
     
    14421339            SHLIB_SUFFIX=".so"
    14431340
    1444             CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
     1341            CFLAGS_OPTIMIZE=-O2
    14451342            # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
    14461343            # when you inline the string and math operations.  Turn this off to
     
    14481345            #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
    14491346
    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}
     1347            if test "$have_dl" = yes; then
     1348                SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
     1349                DL_OBJS="tclLoadDl.o"
     1350                DL_LIBS="-ldl"
     1351                LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
     1352                CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1353                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1354            else
     1355                AC_CHECK_HEADER(dld.h, [
     1356                    SHLIB_LD="ld -shared"
     1357                    DL_OBJS="tclLoadDld.o"
     1358                    DL_LIBS="-ldld"
     1359                    CC_SEARCH_FLAGS=""
     1360                    LD_SEARCH_FLAGS=""])
     1361            fi
    14561362            if test "`uname -m`" = "alpha" ; then
    14571363                CFLAGS="$CFLAGS -mieee"
     1364            fi
     1365            if test $do64bit = yes; then
     1366                AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
     1367                    hold_cflags=$CFLAGS
     1368                    CFLAGS="$CFLAGS -m64"
     1369                    AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no)
     1370                    CFLAGS=$hold_cflags])
     1371                if test $tcl_cv_cc_m64 = yes; then
     1372                    CFLAGS="$CFLAGS -m64"
     1373                    do64bit_ok=yes
     1374                fi
    14581375            fi
    14591376
     
    14651382            # Disable inlining only when one of the
    14661383            # files in compat/*.c is being linked in.
    1467             if test x"${USE_COMPAT}" != x ; then
     1384            if test x"${LIBOBJS}" != x ; then
    14681385                CFLAGS="$CFLAGS -fno-inline"
    14691386            fi
     1387
     1388            # XIM peeking works under XFree86.
     1389            AC_DEFINE(PEEK_XCLOSEIM)
    14701390
    14711391            ;;
     
    14751395            SHLIB_SUFFIX=".so"
    14761396
    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=""
     1397            if test "$have_dl" = yes; then
     1398                SHLIB_LD="${CC} -shared"
     1399                DL_OBJS=""
     1400                DL_LIBS="-ldl"
     1401                LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
     1402                CC_SEARCH_FLAGS=""
     1403                LD_SEARCH_FLAGS=""
     1404            else
     1405                AC_CHECK_HEADER(dld.h, [
     1406                    SHLIB_LD="ld -shared"
     1407                    DL_OBJS=""
     1408                    DL_LIBS="-ldld"
     1409                    CC_SEARCH_FLAGS=""
     1410                    LD_SEARCH_FLAGS=""])
     1411            fi
    14831412            if test "`uname -m`" = "alpha" ; then
    14841413                CFLAGS="$CFLAGS -mieee"
     
    15191448            ;;
    15201449        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, [
     1450            # Not available on all versions:  check for include file.
     1451            AC_CHECK_HEADER(dlfcn.h, [
     1452                # NetBSD/SPARC needs -fPIC, -fpic will not do.
     1453                SHLIB_CFLAGS="-fPIC"
     1454                SHLIB_LD="ld -Bshareable -x"
     1455                SHLIB_LD_LIBS='${LIBS}'
     1456                SHLIB_SUFFIX=".so"
     1457                DL_OBJS="tclLoadDl.o"
     1458                DL_LIBS=""
     1459                CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1460                LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
     1461                AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
     1462                    AC_EGREP_CPP(yes, [
    15321463#ifdef __ELF__
    15331464        yes
    15341465#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'
     1466                    ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
     1467                if test $tcl_cv_ld_elf = yes; then
     1468                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
     1469                else
     1470                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
     1471                fi
     1472            ], [
     1473                SHLIB_CFLAGS=""
     1474                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
     1475                SHLIB_LD_LIBS='${LIBS}'
     1476                SHLIB_SUFFIX=".a"
     1477                DL_OBJS="tclLoadAout.o"
     1478                DL_LIBS=""
     1479                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1480                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1481                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
     1482            ])
     1483
     1484            # FreeBSD doesn't handle version numbers with dots.
     1485
     1486            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
    15451487            TCL_LIB_VERSIONS_OK=nodots
    15461488            ;;
    15471489        OpenBSD-*)
    1548             # OpenBSD/SPARC[64] needs -fPIC, -fpic will not do.
    1549             case `machine` in
    1550             sparc|sparc64)
    1551                 SHLIB_CFLAGS="-fPIC";;
     1490            case `arch -s` in
     1491            m88k|vax)
     1492                SHLIB_CFLAGS=""
     1493                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
     1494                SHLIB_LD_LIBS='${LIBS}'
     1495                SHLIB_SUFFIX=".a"
     1496                DL_OBJS="tclLoadAout.o"
     1497                DL_LIBS=""
     1498                LDFLAGS=""
     1499                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1500                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1501                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
     1502                ;;
    15521503            *)
    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, [
     1504                # OpenBSD/SPARC[64] needs -fPIC, -fpic will not do.
     1505                case `machine` in
     1506                sparc|sparc64)
     1507                    SHLIB_CFLAGS="-fPIC";;
     1508                *)
     1509                    SHLIB_CFLAGS="-fpic";;
     1510                esac
     1511                SHLIB_LD="${CC} -shared ${SHLIB_CFLAGS}"
     1512                SHLIB_LD_LIBS='${LIBS}'
     1513                SHLIB_SUFFIX=".so"
     1514                DL_OBJS="tclLoadDl.o"
     1515                DL_LIBS=""
     1516                CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
     1517                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1518                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
     1519                AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
     1520                    AC_EGREP_CPP(yes, [
    15651521#ifdef __ELF__
    15661522        yes
    15671523#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
    1572                 LDFLAGS=""
    1573             fi
     1524                    ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
     1525                if test $tcl_cv_ld_elf = yes; then
     1526                    LDFLAGS=-Wl,-export-dynamic
     1527                else
     1528                    LDFLAGS=""
     1529                fi
     1530                ;;
     1531            esac
    15741532
    15751533            # OpenBSD doesn't do version numbers with dots.
    1576             UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
     1534            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
    15771535            TCL_LIB_VERSIONS_OK=nodots
    15781536            ;;
     
    15971555            FreeBSD-3.*)
    15981556                # 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'
     1557                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
     1558                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
    16011559                TCL_LIB_VERSIONS_OK=nodots
    16021560                ;;
     
    16061564            CFLAGS_OPTIMIZE="-Os"
    16071565            SHLIB_CFLAGS="-fno-common"
     1566            # To avoid discrepancies between what headers configure sees during
     1567            # preprocessing tests and compiling tests, move any -isysroot and
     1568            # -mmacosx-version-min flags from CFLAGS to CPPFLAGS:
     1569            CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \
     1570                awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
     1571                if ([$]i~/^(isysroot|mmacosx-version-min)/) print "-"[$]i}'`"
     1572            CFLAGS="`echo " ${CFLAGS}" | \
     1573                awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
     1574                if (!([$]i~/^(isysroot|mmacosx-version-min)/)) print "-"[$]i}'`"
    16081575            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}'
     1576                case `arch` in
     1577                    ppc)
     1578                        AC_CACHE_CHECK([if compiler accepts -arch ppc64 flag],
     1579                                tcl_cv_cc_arch_ppc64, [
     1580                            hold_cflags=$CFLAGS
     1581                            CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
     1582                            AC_TRY_LINK(,, tcl_cv_cc_arch_ppc64=yes,
     1583                                    tcl_cv_cc_arch_ppc64=no)
     1584                            CFLAGS=$hold_cflags])
     1585                        if test $tcl_cv_cc_arch_ppc64 = yes; then
     1586                            CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
     1587                            do64bit_ok=yes
     1588                        fi;;
     1589                    i386)
     1590                        AC_CACHE_CHECK([if compiler accepts -arch x86_64 flag],
     1591                                tcl_cv_cc_arch_x86_64, [
     1592                            hold_cflags=$CFLAGS
     1593                            CFLAGS="$CFLAGS -arch x86_64"
     1594                            AC_TRY_LINK(,, tcl_cv_cc_arch_x86_64=yes,
     1595                                    tcl_cv_cc_arch_x86_64=no)
     1596                            CFLAGS=$hold_cflags])
     1597                        if test $tcl_cv_cc_arch_x86_64 = yes; then
     1598                            CFLAGS="$CFLAGS -arch x86_64"
     1599                            do64bit_ok=yes
     1600                        fi;;
     1601                    *)
     1602                        AC_MSG_WARN([Don't know how enable 64-bit on architecture `arch`]);;
     1603                esac
     1604            else
     1605                # Check for combined 32-bit and 64-bit fat build
     1606                echo "$CFLAGS " | grep -E -q -- '-arch (ppc64|x86_64) ' && \
     1607                    echo "$CFLAGS " | grep -E -q -- '-arch (ppc|i386) ' && \
     1608                    fat_32_64=yes
     1609            fi
     1610            SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS}'
    16141611            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])
     1612                hold_ldflags=$LDFLAGS
     1613                LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
     1614                AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
     1615                LDFLAGS=$hold_ldflags])
    16191616            if test $tcl_cv_ld_single_module = yes; then
    1620                 SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
     1617                SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
    16211618            fi
    16221619            SHLIB_LD_LIBS='${LIBS}'
     
    16251622            DL_LIBS=""
    16261623            # 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 && \
     1624            test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int([$]2)}'`" -lt 4 -a \
     1625                "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int([$]2)}'`" -lt 4 && \
    16291626                LDFLAGS="$LDFLAGS -prebind"
    16301627            LDFLAGS="$LDFLAGS -headerpad_max_install_names"
    16311628            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])
     1629                hold_ldflags=$LDFLAGS
     1630                LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
     1631                AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, tcl_cv_ld_search_paths_first=no)
     1632                LDFLAGS=$hold_ldflags])
    16361633            if test $tcl_cv_ld_search_paths_first = yes; then
    1637                 LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
     1634                LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
    16381635            fi
    16391636            CC_SEARCH_FLAGS=""
    16401637            LD_SEARCH_FLAGS=""
    16411638            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'`"
     1639            PLAT_OBJS=\$\(MAC\_OSX_OBJS\)
     1640            PLAT_SRCS=\$\(MAC\_OSX_SRCS\)
     1641            AC_MSG_CHECKING([whether to use CoreFoundation])
     1642            AC_ARG_ENABLE(corefoundation, [  --enable-corefoundation use CoreFoundation API [--enable-corefoundation]],
     1643                [tcl_corefoundation=$enableval], [tcl_corefoundation=yes])
     1644            AC_MSG_RESULT([$tcl_corefoundation])
     1645            if test $tcl_corefoundation = yes; then
     1646                AC_CACHE_CHECK([for CoreFoundation.framework], tcl_cv_lib_corefoundation, [
     1647                    hold_libs=$LIBS
     1648                    if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do
     1649                        # On Tiger there is no 64-bit CF, so remove 64-bit archs
     1650                        # from CFLAGS et al. while testing for presence of CF.
     1651                        # 64-bit CF is disabled in tclUnixPort.h if necessary.
     1652                        eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
     1653                    done; fi
     1654                    LIBS="$LIBS -framework CoreFoundation"
     1655                    AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
     1656                        [CFBundleRef b = CFBundleGetMainBundle();],
     1657                        tcl_cv_lib_corefoundation=yes, tcl_cv_lib_corefoundation=no)
     1658                    if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do
     1659                        eval $v'="$hold_'$v'"'
     1660                    done; fi; LIBS=$hold_libs])
     1661                if test $tcl_cv_lib_corefoundation = yes; then
     1662                    LIBS="$LIBS -framework CoreFoundation"
     1663                    AC_DEFINE(HAVE_COREFOUNDATION)
     1664                else
     1665                    tcl_corefoundation=no
     1666                fi
     1667                if test "$fat_32_64" = yes -a $tcl_corefoundation = yes; then
     1668                    AC_CACHE_CHECK([for 64-bit CoreFoundation], tcl_cv_lib_corefoundation_64, [
     1669                        for v in CFLAGS CPPFLAGS LDFLAGS; do
     1670                            eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
     1671                        done
     1672                        AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
     1673                            [CFBundleRef b = CFBundleGetMainBundle();],
     1674                            tcl_cv_lib_corefoundation_64=yes, tcl_cv_lib_corefoundation_64=no)
     1675                        for v in CFLAGS CPPFLAGS LDFLAGS; do
     1676                            eval $v'="$hold_'$v'"'
     1677                        done])
     1678                    if test $tcl_cv_lib_corefoundation_64 = no; then
     1679                        AC_DEFINE(NO_COREFOUNDATION_64)
     1680                    fi
     1681                fi
     1682            fi
     1683            AC_DEFINE(MAC_OSX_TCL)
    16481684            ;;
    16491685        NEXTSTEP-*)
     
    16591695        OS/390-*)
    16601696            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?])
     1697            AC_DEFINE(_OE_SOCKETS)      # needed in sys/socket.h
    16631698            ;;     
    16641699        OSF1-1.0|OSF1-1.1|OSF1-1.2)
     
    17351770            LD_SEARCH_FLAGS=""
    17361771            ;;
     1772        RISCos-*)
     1773            SHLIB_CFLAGS="-G 0"
     1774            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
     1775            SHLIB_LD_LIBS='${LIBS}'
     1776            SHLIB_SUFFIX=".a"
     1777            DL_OBJS="tclLoadAout.o"
     1778            DL_LIBS=""
     1779            LDFLAGS="$LDFLAGS -Wl,-D,08000000"
     1780            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1781            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1782            ;;
    17371783        SCO_SV-3.2*)
    17381784            # Note, dlopen is available only on SCO 3.2.5 and greater. However,
     
    17791825            # So, the library has to have a name like libtcl75.so.1.0
    17801826
    1781             SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.1.0'
    1782             UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
     1827            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
     1828            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
    17831829            TCL_LIB_VERSIONS_OK=nodots
    17841830            ;;
     
    17891835            # won't define thread-safe library routines.
    17901836
    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!])
     1837            AC_DEFINE(_REENTRANT)
     1838            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
    17941839
    17951840            SHLIB_CFLAGS="-KPIC"
     
    18161861            # won't define thread-safe library routines.
    18171862
    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!])
     1863            AC_DEFINE(_REENTRANT)
     1864            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
    18211865
    18221866            SHLIB_CFLAGS="-KPIC"
     
    18391883                            if test "$do64bitVIS" = "yes" ; then
    18401884                                CFLAGS="$CFLAGS -xarch=v9a"
    1841                                 LDFLAGS_ARCH="-xarch=v9a"
     1885                                LDFLAGS="$LDFLAGS -xarch=v9a"
    18421886                            else
    18431887                                CFLAGS="$CFLAGS -xarch=v9"
    1844                                 LDFLAGS_ARCH="-xarch=v9"
     1888                                LDFLAGS="$LDFLAGS -xarch=v9"
    18451889                            fi
    18461890                            # Solaris 64 uses this as well
     
    18741918                    # We need to specify -static-libgcc or we need to
    18751919                    # add the path to the sparv9 libgcc.
    1876                     # JH: static-libgcc is necessary for core Tcl, but may
    1877                     # not be necessary for extensions.
    18781920                    SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
    18791921                    # for finding sparcv9 libgcc, get the regular libgcc
     
    18831925                fi
    18841926            else
    1885                 SHLIB_LD="/usr/ccs/bin/ld -G -z text"
     1927                case $system in
     1928                    SunOS-5.[[1-9]][[0-9]]*)
     1929                        SHLIB_LD='${CC} -G -z text ${LDFLAGS}';;
     1930                    *)
     1931                        SHLIB_LD="/usr/ccs/bin/ld -G -z text";;
     1932                esac
    18861933                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
    18871934                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
     1935            fi
     1936            ;;
     1937        ULTRIX-4.*)
     1938            SHLIB_CFLAGS="-G 0"
     1939            SHLIB_SUFFIX=".a"
     1940            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
     1941            SHLIB_LD_LIBS='${LIBS}'
     1942            DL_OBJS="tclLoadAout.o"
     1943            DL_LIBS=""
     1944            LDFLAGS="$LDFLAGS -Wl,-D,08000000"
     1945            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
     1946            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
     1947            if test "$GCC" != "yes" ; then
     1948                CFLAGS="$CFLAGS -DHAVE_TZSET -std1"
    18881949            fi
    18891950            ;;
     
    19141975    fi
    19151976
    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)]),
     1977dnl # Add any CPPFLAGS set in the environment to our CFLAGS, but delay doing so
     1978dnl # until the end of configure, as configure's compile and link tests use
     1979dnl # both CPPFLAGS and CFLAGS (unlike our compile and link) but configure's
     1980dnl # preprocessing tests use only CPPFLAGS.
     1981    SC_CONFIG_COMMANDS_PRE([CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""])
     1982
     1983    # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
     1984    # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
     1985    # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
     1986    # to determine which of several header files defines the a.out file
     1987    # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
     1988    # support only a file format that is more or less version-7-compatible.
     1989    # In particular,
     1990    #   - a.out files must begin with `struct exec'.
     1991    #   - the N_TXTOFF on the `struct exec' must compute the seek address
     1992    #     of the text segment
     1993    #   - The `struct exec' must contain a_magic, a_text, a_data, a_bss
     1994    #     and a_entry fields.
     1995    # The following compilation should succeed if and only if either sys/exec.h
     1996    # or a.out.h is usable for the purpose.
     1997    #
     1998    # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
     1999    # `struct exec' includes a second header that contains information that
     2000    # duplicates the v7 fields that are needed.
     2001
     2002    if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
     2003        AC_CACHE_CHECK([sys/exec.h], tcl_cv_sysexec_h, [
     2004        AC_TRY_COMPILE([#include <sys/exec.h>],[
     2005            struct exec foo;
     2006            unsigned long seek;
     2007            int flag;
     2008#if defined(__mips) || defined(mips)
     2009            seek = N_TXTOFF (foo.ex_f, foo.ex_o);
     2010#else
     2011            seek = N_TXTOFF (foo);
     2012#endif
     2013            flag = (foo.a_magic == OMAGIC);
     2014            return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
     2015    ], tcl_cv_sysexec_h=usable, tcl_cv_sysexec_h=unusable)])
     2016        if test $tcl_cv_sysexec_h = usable; then
     2017            AC_DEFINE(USE_SYS_EXEC_H)
     2018        else
     2019            AC_CACHE_CHECK([a.out.h], tcl_cv_aout_h, [
     2020            AC_TRY_COMPILE([#include <a.out.h>],[
     2021                struct exec foo;
     2022                unsigned long seek;
     2023                int flag;
     2024#if defined(__mips) || defined(mips)
     2025                seek = N_TXTOFF (foo.ex_f, foo.ex_o);
     2026#else
     2027                seek = N_TXTOFF (foo);
     2028#endif
     2029                flag = (foo.a_magic == OMAGIC);
     2030                return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
     2031            ], tcl_cv_aout_h=usable, tcl_cv_aout_h=unusable)])
     2032            if test $tcl_cv_aout_h = usable; then
     2033                AC_DEFINE(USE_A_OUT_H)
     2034            else
     2035                AC_CACHE_CHECK([sys/exec_aout.h], tcl_cv_sysexecaout_h, [
     2036                AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
     2037                    struct exec foo;
     2038                    unsigned long seek;
     2039                    int flag;
     2040#if defined(__mips) || defined(mips)
     2041                    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
     2042#else
     2043                    seek = N_TXTOFF (foo);
     2044#endif
     2045                    flag = (foo.a_midmag == OMAGIC);
     2046                    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
     2047                ], tcl_cv_sysexecaout_h=usable, tcl_cv_sysexecaout_h=unusable)])
     2048                if test $tcl_cv_sysexecaout_h = usable; then
     2049                    AC_DEFINE(USE_SYS_EXEC_AOUT_H)
     2050                else
     2051                    DL_OBJS=""
     2052                fi
     2053            fi
     2054        fi
     2055    fi
     2056
     2057    # Step 5: disable dynamic loading if requested via a command-line switch.
     2058
     2059    AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
    19212060        [tcl_ok=$enableval], [tcl_ok=yes])
    19222061    if test "$tcl_ok" = "no"; then
     
    19392078        BUILD_DLTEST=""
    19402079    fi
    1941     LDFLAGS="$LDFLAGS $LDFLAGS_ARCH"
    19422080
    19432081    # If we're running gcc, then change the C flags for compiling shared
     
    19542092                IRIX*)
    19552093                    ;;
    1956                 NetBSD-*|FreeBSD-*)
     2094                NetBSD-*|FreeBSD-*|OpenBSD-*)
    19572095                    ;;
    19582096                Darwin-*)
    19592097                    ;;
     2098                RISCos-*)
     2099                    ;;
    19602100                SCO_SV-3.2*)
    19612101                    ;;
    1962                 windows)
     2102                ULTRIX-4.*)
    19632103                    ;;
    19642104                *)
     
    19702110
    19712111    if test "$SHARED_LIB_SUFFIX" = "" ; then
    1972         SHARED_LIB_SUFFIX='${PACKAGE_VERSION}${SHLIB_SUFFIX}'
     2112        SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
    19732113    fi
    19742114    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
    1975         UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}.a'
    1976     fi
     2115        UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
     2116    fi
     2117
     2118    if test "${SHARED_BUILD}" = "1" && test "${SHLIB_SUFFIX}" != "" ; then
     2119        LIB_SUFFIX=${SHARED_LIB_SUFFIX}
     2120        MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
     2121        INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
     2122    else
     2123        LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}
     2124
     2125        if test "$RANLIB" = "" ; then
     2126            MAKE_LIB='$(STLIB_LD) [$]@ ${OBJS}'
     2127            INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
     2128        else
     2129            MAKE_LIB='${STLIB_LD} [$]@ ${OBJS} ; ${RANLIB} [$]@'
     2130            INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(LIB_FILE))'
     2131        fi
     2132
     2133dnl        Not at all clear what this was doing in Tcl's configure.in
     2134dnl        or why it was needed was needed. In any event, this sort of
     2135dnl        things needs to be done in the big loop above.
     2136dnl        REMOVE THIS BLOCK LATER! (mdejong)
     2137dnl        case $system in
     2138dnl            BSD/OS*)
     2139dnl                ;;
     2140dnl            AIX-[[1-4]].*)
     2141dnl                ;;
     2142dnl            *)
     2143dnl                SHLIB_LD_LIBS=""
     2144dnl                ;;
     2145dnl        esac
     2146    fi
     2147
     2148
     2149    # Stub lib does not depend on shared/static configuration
     2150    if test "$RANLIB" = "" ; then
     2151        MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS}'
     2152        INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE)'
     2153    else
     2154        MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS} ; ${RANLIB} [$]@'
     2155        INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(STUB_LIB_FILE))'
     2156    fi
     2157
    19772158
    19782159    AC_SUBST(DL_LIBS)
    19792160
     2161    AC_SUBST(DL_OBJS)
     2162    AC_SUBST(PLAT_OBJS)
     2163    AC_SUBST(PLAT_SRCS)
     2164    AC_SUBST(CFLAGS)
    19802165    AC_SUBST(CFLAGS_DEBUG)
    19812166    AC_SUBST(CFLAGS_OPTIMIZE)
    19822167    AC_SUBST(CFLAGS_WARNING)
    19832168
     2169    AC_SUBST(LDFLAGS)
     2170    AC_SUBST(LDFLAGS_DEBUG)
     2171    AC_SUBST(LDFLAGS_OPTIMIZE)
     2172    AC_SUBST(CC_SEARCH_FLAGS)
     2173    AC_SUBST(LD_SEARCH_FLAGS)
     2174
    19842175    AC_SUBST(STLIB_LD)
    19852176    AC_SUBST(SHLIB_LD)
    1986 
     2177    AC_SUBST(TCL_SHLIB_LD_EXTRAS)
     2178    AC_SUBST(TK_SHLIB_LD_EXTRAS)
    19872179    AC_SUBST(SHLIB_LD_LIBS)
    19882180    AC_SUBST(SHLIB_CFLAGS)
    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
     2181    AC_SUBST(SHLIB_SUFFIX)
     2182
     2183    AC_SUBST(MAKE_LIB)
     2184    AC_SUBST(MAKE_STUB_LIB)
     2185    AC_SUBST(INSTALL_LIB)
     2186    AC_SUBST(INSTALL_STUB_LIB)
     2187    AC_SUBST(RANLIB)
    19962188])
    19972189
    19982190#--------------------------------------------------------------------
    1999 # TEA_SERIAL_PORT
     2191# SC_SERIAL_PORT
    20002192#
    20012193#       Determine which interface to use to talk to the serial port.
     
    20182210#--------------------------------------------------------------------
    20192211
    2020 AC_DEFUN([TEA_SERIAL_PORT], [
     2212AC_DEFUN([SC_SERIAL_PORT], [
    20212213    AC_CHECK_HEADERS(sys/modem.h)
    20222214    AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
     
    21082300    fi])
    21092301    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]);;
     2302        termios) AC_DEFINE(USE_TERMIOS);;
     2303        termio)  AC_DEFINE(USE_TERMIO);;
     2304        sgtty)   AC_DEFINE(USE_SGTTY);;
    21132305    esac
    21142306])
    21152307
    21162308#--------------------------------------------------------------------
    2117 # TEA_MISSING_POSIX_HEADERS
     2309# SC_MISSING_POSIX_HEADERS
    21182310#
    21192311#       Supply substitutes for missing POSIX header files.  Special
     
    21382330#               NO_SYS_WAIT_H
    21392331#               NO_DLFCN_H
     2332#               HAVE_UNISTD_H
    21402333#               HAVE_SYS_PARAM_H
    21412334#
    21422335#               HAVE_STRING_H ?
    21432336#
    2144 # tkUnixPort.h checks for HAVE_LIMITS_H, so do both HAVE and
    2145 # CHECK on limits.h
    2146 #--------------------------------------------------------------------
    2147 
    2148 AC_DEFUN([TEA_MISSING_POSIX_HEADERS], [
    2149     AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h,
     2337#--------------------------------------------------------------------
     2338
     2339AC_DEFUN([SC_MISSING_POSIX_HEADERS], [
     2340    AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [
    21502341    AC_TRY_LINK([#include <sys/types.h>
    21512342#include <dirent.h>], [
     
    21672358p = entryPtr->d_name;
    21682359closedir(d);
    2169 ], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no))
     2360], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no)])
    21702361
    21712362    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>?])])
     2363        AC_DEFINE(NO_DIRENT_H)
     2364    fi
     2365
     2366    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H)])
     2367    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H)])
     2368    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H)])
    21782369    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>?])])
     2370        [AC_DEFINE(HAVE_LIMITS_H)], [AC_DEFINE(NO_LIMITS_H)])
    21812371    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
    21822372    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
     
    21842374    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
    21852375    if test $tcl_ok = 0; then
    2186         AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?])
     2376        AC_DEFINE(NO_STDLIB_H)
    21872377    fi
    21882378    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
     
    21942384
    21952385    if test $tcl_ok = 0; then
    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>?])])
     2386        AC_DEFINE(NO_STRING_H)
     2387    fi
     2388
     2389    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H)])
     2390    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H)])
    22012391
    22022392    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
    2203     AC_HAVE_HEADERS(sys/param.h)
     2393    AC_HAVE_HEADERS(unistd.h sys/param.h)
    22042394])
    22052395
    22062396#--------------------------------------------------------------------
    2207 # TEA_PATH_X
     2397# SC_PATH_X
    22082398#
    22092399#       Locate the X11 header files and the X11 library archive.  Try
     
    22142404#       no include files, so double-check its result just to be safe.
    22152405#
    2216 #       This should be called after TEA_CONFIG_CFLAGS as setting the
    2217 #       LIBS line can confuse some configure macro magic.
    2218 #
    22192406# Arguments:
    22202407#       none
     
    22222409# Results:
    22232410#
    2224 #       Sets the following vars:
     2411#       Sets the the following vars:
    22252412#               XINCLUDES
    22262413#               XLIBSW
    2227 #               PKG_LIBS (appends to)
    2228 #
    2229 #--------------------------------------------------------------------
    2230 
    2231 AC_DEFUN([TEA_PATH_X], [
    2232     if test "${TEA_WINDOWINGSYSTEM}" = "x11" ; then
    2233         TEA_PATH_UNIX_X
    2234     fi
    2235 ])
    2236 
    2237 AC_DEFUN([TEA_PATH_UNIX_X], [
     2414#
     2415#--------------------------------------------------------------------
     2416
     2417AC_DEFUN([SC_PATH_X], [
    22382418    AC_PATH_X
    22392419    not_really_there=""
     
    22982478        XLIBSW=-lX11
    22992479    fi
    2300     if test x"${XLIBSW}" != x ; then
    2301         PKG_LIBS="${PKG_LIBS} ${XLIBSW}"
    2302     fi
    23032480])
    23042481
    23052482#--------------------------------------------------------------------
    2306 # TEA_BLOCKING_STYLE
     2483# SC_BLOCKING_STYLE
    23072484#
    23082485#       The statements below check for systems where POSIX-style
     
    23242501#--------------------------------------------------------------------
    23252502
    2326 AC_DEFUN([TEA_BLOCKING_STYLE], [
     2503AC_DEFUN([SC_BLOCKING_STYLE], [
    23272504    AC_CHECK_HEADERS(sys/ioctl.h)
    23282505    AC_CHECK_HEADERS(sys/filio.h)
    2329     TEA_CONFIG_SYSTEM
     2506    SC_CONFIG_SYSTEM
    23302507    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
    23312508    case $system in
     
    23362513
    23372514        OSF*)
    2338             AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
     2515            AC_DEFINE(USE_FIONBIO)
    23392516            AC_MSG_RESULT([FIONBIO])
    23402517            ;;
    23412518        SunOS-4*)
    2342             AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
     2519            AC_DEFINE(USE_FIONBIO)
     2520            AC_MSG_RESULT([FIONBIO])
     2521            ;;
     2522        ULTRIX-4.*)
     2523            AC_DEFINE(USE_FIONBIO)
    23432524            AC_MSG_RESULT([FIONBIO])
    23442525            ;;
     
    23502531
    23512532#--------------------------------------------------------------------
    2352 # TEA_TIME_HANLDER
     2533# SC_TIME_HANLDER
    23532534#
    23542535#       Checks how the system deals with time.h, what time structures
     
    23682549#--------------------------------------------------------------------
    23692550
    2370 AC_DEFUN([TEA_TIME_HANDLER], [
     2551AC_DEFUN([SC_TIME_HANDLER], [
    23712552    AC_CHECK_HEADERS(sys/time.h)
    23722553    AC_HEADER_TIME
     
    23752556    AC_CHECK_FUNCS(gmtime_r localtime_r)
    23762557
    2377     AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj,
     2558    AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [
    23782559        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))
     2560            tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no)])
    23802561    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,
     2562        AC_DEFINE(HAVE_TM_TZADJ)
     2563    fi
     2564
     2565    AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
    23852566        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))
     2567            tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)])
    23872568    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?])
     2569        AC_DEFINE(HAVE_TM_GMTOFF)
    23892570    fi
    23902571
     
    23932574    # (like convex) have timezone functions, etc.
    23942575    #
    2395     AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long,
     2576    AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [
    23962577        AC_TRY_COMPILE([#include <time.h>],
    23972578            [extern long timezone;
    23982579            timezone += 1;
    23992580            exit (0);],
    2400             tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no))
     2581            tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no)])
    24012582    if test $tcl_cv_timezone_long = yes ; then
    2402         AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
     2583        AC_DEFINE(HAVE_TIMEZONE_VAR)
    24032584    else
    24042585        #
    24052586        # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
    24062587        #
    2407         AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time,
     2588        AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [
    24082589            AC_TRY_COMPILE([#include <time.h>],
    24092590                [extern time_t timezone;
    24102591                timezone += 1;
    24112592                exit (0);],
    2412                 tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no))
     2593                tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no)])
    24132594        if test $tcl_cv_timezone_time = yes ; then
    2414             AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
     2595            AC_DEFINE(HAVE_TIMEZONE_VAR)
    24152596        fi
    24162597    fi
     
    24182599
    24192600#--------------------------------------------------------------------
    2420 # TEA_BUGGY_STRTOD
     2601# SC_BUGGY_STRTOD
    24212602#
    24222603#       Under Solaris 2.4, strtod returns the wrong value for the
     
    24372618#--------------------------------------------------------------------
    24382619
    2439 AC_DEFUN([TEA_BUGGY_STRTOD], [
     2620AC_DEFUN([SC_BUGGY_STRTOD], [
    24402621    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
    24412622    if test "$tcl_strtod" = 1; then
     
    24632644                    tcl_cv_strtod_buggy=buggy)])
    24642645        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?])
     2646            LIBOBJS="$LIBOBJS fixstrtod.o"
     2647            AC_DEFINE(strtod, fixstrtod)
    24682648        fi
    24692649    fi
     
    24712651
    24722652#--------------------------------------------------------------------
    2473 # TEA_TCL_LINK_LIBS
     2653# SC_TCL_LINK_LIBS
    24742654#
    24752655#       Search for the libraries needed to link the Tcl shell.
     
    24972677#--------------------------------------------------------------------
    24982678
    2499 AC_DEFUN([TEA_TCL_LINK_LIBS], [
     2679AC_DEFUN([SC_TCL_LINK_LIBS], [
    25002680    #--------------------------------------------------------------------
    25012681    # On a few very rare systems, all of the libm.a stuff is
     
    25142694
    25152695    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
    2516     AC_CHECK_HEADER(net/errno.h, [
    2517         AC_DEFINE(HAVE_NET_ERRNO_H, 1, [Do we have <net/errno.h>?])])
     2696    AC_CHECK_HEADER(net/errno.h, [AC_DEFINE(HAVE_NET_ERRNO_H)])
    25182697
    25192698    #--------------------------------------------------------------------
     
    25502729   
    25512730    # Don't perform the eval of the libraries here because DL_LIBS
    2552     # won't be set until we call TEA_CONFIG_CFLAGS
     2731    # won't be set until we call SC_CONFIG_CFLAGS
    25532732
    25542733    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
     
    25582737
    25592738#--------------------------------------------------------------------
    2560 # TEA_TCL_EARLY_FLAGS
     2739# SC_TCL_EARLY_FLAGS
    25612740#
    25622741#       Check for what flags are needed to be passed so the correct OS
     
    25752754#--------------------------------------------------------------------
    25762755
    2577 AC_DEFUN([TEA_TCL_EARLY_FLAG],[
     2756AC_DEFUN([SC_TCL_EARLY_FLAG],[
    25782757    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
    25792758        AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
     
    25832762                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
    25842763    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])
     2764        AC_DEFINE($1)
    25862765        tcl_flags="$tcl_flags $1"
    25872766    fi
    25882767])
    25892768
    2590 AC_DEFUN([TEA_TCL_EARLY_FLAGS],[
     2769AC_DEFUN([SC_TCL_EARLY_FLAGS],[
    25912770    AC_MSG_CHECKING([for required early compiler flags])
    25922771    tcl_flags=""
    2593     TEA_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
     2772    SC_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
    25942773        [char *p = (char *)strtoll; char *q = (char *)strtoull;])
    2595     TEA_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
     2774    SC_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
    25962775        [struct stat64 buf; int i = stat64("/", &buf);])
    2597     TEA_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
     2776    SC_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
    25982777        [char *p = (char *)open64;])
    25992778    if test "x${tcl_flags}" = "x" ; then
     
    26052784
    26062785#--------------------------------------------------------------------
    2607 # TEA_TCL_64BIT_FLAGS
     2786# SC_TCL_64BIT_FLAGS
    26082787#
    26092788#       Check for what is defined in the way of 64-bit features.
     
    26232802#--------------------------------------------------------------------
    26242803
    2625 AC_DEFUN([TEA_TCL_64BIT_FLAGS], [
     2804AC_DEFUN([SC_TCL_64BIT_FLAGS], [
    26262805    AC_MSG_CHECKING([for 64-bit integer type])
    26272806    AC_CACHE_VAL(tcl_cv_type_64bit,[
     
    26372816        }],tcl_cv_type_64bit=${tcl_type_64bit})])
    26382817    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?])
     2818        AC_DEFINE(TCL_WIDE_INT_IS_LONG)
    26402819        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])
    26462820    else
    2647         AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit},
    2648             [What type should be used to define wide integers?])
     2821        AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit})
    26492822        AC_MSG_RESULT([${tcl_cv_type_64bit}])
    26502823
     
    26552828                tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
    26562829        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
    2657             AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?])
     2830            AC_DEFINE(HAVE_STRUCT_DIRENT64)
    26582831        fi
    26592832
     
    26632836                tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
    26642837        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
    2665             AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in <sys/stat.h>?])
     2838            AC_DEFINE(HAVE_STRUCT_STAT64)
    26662839        fi
    26672840
     
    26772850                test "x${ac_cv_func_lseek64}" = "xyes" && \
    26782851                test "x${ac_cv_func_open64}" = "xyes" ; then
    2679             AC_DEFINE(HAVE_TYPE_OFF64_T, 1, [Is off64_t in <sys/types.h>?])
     2852            AC_DEFINE(HAVE_TYPE_OFF64_T)
    26802853            AC_MSG_RESULT([yes])
    26812854        else
     
    26852858])
    26862859
    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.
     2860#--------------------------------------------------------------------
     2861# SC_TCL_GETHOSTBYADDR_R
     2862#
     2863#       Check if we have MT-safe variant of gethostbyaddr().
    26972864#
    26982865# Arguments:
    2699 #       none
    2700 #
     2866#       None
     2867#       
    27012868# Results:
    27022869#
    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 
    2721 AC_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([
    2729 The PACKAGE_NAME variable must be defined by your TEA configure.in])
    2730     fi
    2731     if test x"$1" = x ; then
    2732         AC_MSG_ERROR([
    2733 TEA version not specified.])
    2734     elif test "$1" != "${TEA_VERSION}" ; then
    2735         AC_MSG_RESULT([warning: requested TEA version "$1", have "${TEA_VERSION}"])
     2870#       Might define the following vars:
     2871#               HAVE_GETHOSTBYADDR_R
     2872#               HAVE_GETHOSTBYADDR_R_7
     2873#               HAVE_GETHOSTBYADDR_R_8
     2874#
     2875#--------------------------------------------------------------------
     2876
     2877AC_DEFUN([SC_TCL_GETHOSTBYADDR_R], [AC_CHECK_FUNC(gethostbyaddr_r, [
     2878    AC_CACHE_CHECK([for gethostbyaddr_r with 7 args], tcl_cv_api_gethostbyaddr_r_7, [
     2879    AC_TRY_COMPILE([
     2880        #include <netdb.h>
     2881    ], [
     2882        char *addr;
     2883        int length;
     2884        int type;
     2885        struct hostent *result;
     2886        char buffer[2048];
     2887        int buflen = 2048;
     2888        int h_errnop;
     2889
     2890        (void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
     2891                               &h_errnop);
     2892    ], tcl_cv_api_gethostbyaddr_r_7=yes, tcl_cv_api_gethostbyaddr_r_7=no)])
     2893    tcl_ok=$tcl_cv_api_gethostbyaddr_r_7
     2894    if test "$tcl_ok" = yes; then
     2895        AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
    27362896    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).
     2897        AC_CACHE_CHECK([for gethostbyaddr_r with 8 args], tcl_cv_api_gethostbyaddr_r_8, [
     2898        AC_TRY_COMPILE([
     2899            #include <netdb.h>
     2900        ], [
     2901            char *addr;
     2902            int length;
     2903            int type;
     2904            struct hostent *result, *resultp;
     2905            char buffer[2048];
     2906            int buflen = 2048;
     2907            int h_errnop;
     2908
     2909            (void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
     2910                                   &resultp, &h_errnop);
     2911        ], tcl_cv_api_gethostbyaddr_r_8=yes, tcl_cv_api_gethostbyaddr_r_8=no)])
     2912        tcl_ok=$tcl_cv_api_gethostbyaddr_r_8
     2913        if test "$tcl_ok" = yes; then
     2914            AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
     2915        fi
     2916    fi
     2917    if test "$tcl_ok" = yes; then
     2918        AC_DEFINE(HAVE_GETHOSTBYADDR_R)
     2919    fi
     2920])])
     2921
     2922#--------------------------------------------------------------------
     2923# SC_TCL_GETHOSTBYNAME_R
     2924#
     2925#       Check to see what variant of gethostbyname_r() we have.
     2926#       Based on David Arnold's example from the comp.programming.threads
     2927#       FAQ Q213
    27872928#
    27882929# Arguments:
    2789 #       one or more file names
    2790 #
     2930#       None
     2931#       
    27912932# Results:
    27922933#
    2793 #       Defines and substs the following vars:
    2794 #               PKG_SOURCES
    2795 #               PKG_OBJECTS
    2796 #------------------------------------------------------------------------
    2797 AC_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).
     2934#       Might define the following vars:
     2935#               HAVE_GETHOSTBYADDR_R
     2936#               HAVE_GETHOSTBYADDR_R_3
     2937#               HAVE_GETHOSTBYADDR_R_5
     2938#               HAVE_GETHOSTBYADDR_R_6
     2939#
     2940#--------------------------------------------------------------------
     2941
     2942AC_DEFUN([SC_TCL_GETHOSTBYNAME_R], [AC_CHECK_FUNC(gethostbyname_r, [
     2943    AC_CACHE_CHECK([for gethostbyname_r with 6 args], tcl_cv_api_gethostbyname_r_6, [
     2944    AC_TRY_COMPILE([
     2945        #include <netdb.h>
     2946    ], [
     2947        char *name;
     2948        struct hostent *he, *res;
     2949        char buffer[2048];
     2950        int buflen = 2048;
     2951        int h_errnop;
     2952
     2953        (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop);
     2954    ], tcl_cv_api_gethostbyname_r_6=yes, tcl_cv_api_gethostbyname_r_6=no)])
     2955    tcl_ok=$tcl_cv_api_gethostbyname_r_6
     2956    if test "$tcl_ok" = yes; then
     2957        AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
     2958    else
     2959        AC_CACHE_CHECK([for gethostbyname_r with 5 args], tcl_cv_api_gethostbyname_r_5, [
     2960        AC_TRY_COMPILE([
     2961            #include <netdb.h>
     2962        ], [
     2963            char *name;
     2964            struct hostent *he;
     2965            char buffer[2048];
     2966            int buflen = 2048;
     2967            int h_errnop;
     2968
     2969            (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop);
     2970        ], tcl_cv_api_gethostbyname_r_5=yes, tcl_cv_api_gethostbyname_r_5=no)])
     2971        tcl_ok=$tcl_cv_api_gethostbyname_r_5
     2972        if test "$tcl_ok" = yes; then
     2973            AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
     2974        else
     2975            AC_CACHE_CHECK([for gethostbyname_r with 3 args], tcl_cv_api_gethostbyname_r_3, [
     2976            AC_TRY_COMPILE([
     2977                #include <netdb.h>
     2978            ], [
     2979                char *name;
     2980                struct hostent *he;
     2981                struct hostent_data data;
     2982
     2983                (void) gethostbyname_r(name, he, &data);
     2984            ], tcl_cv_api_gethostbyname_r_3=yes, tcl_cv_api_gethostbyname_r_3=no)])
     2985            tcl_ok=$tcl_cv_api_gethostbyname_r_3
     2986            if test "$tcl_ok" = yes; then
     2987                AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
     2988            fi
     2989        fi
     2990    fi
     2991    if test "$tcl_ok" = yes; then
     2992        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
     2993    fi
     2994])])
     2995
     2996#--------------------------------------------------------------------
     2997# SC_TCL_GETPWUID_R
     2998#
     2999#       Check if we have MT-safe variant of getpwuid() and if yes,
     3000#       which one exactly.
    28373001#
    28383002# Arguments:
    2839 #       one or more file names
    2840 #
     3003#       None
     3004#       
    28413005# Results:
    28423006#
    2843 #       Defines and substs the following vars:
    2844 #               PKG_STUB_SOURCES
    2845 #               PKG_STUB_OBJECTS
    2846 #------------------------------------------------------------------------
    2847 AC_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'])
     3007#       Might define the following vars:
     3008#               HAVE_GETPWUID_R
     3009#               HAVE_GETPWUID_R_4
     3010#               HAVE_GETPWUID_R_5
     3011#
     3012#--------------------------------------------------------------------
     3013
     3014AC_DEFUN([SC_TCL_GETPWUID_R], [AC_CHECK_FUNC(getpwuid_r, [
     3015    AC_CACHE_CHECK([for getpwuid_r with 5 args], tcl_cv_api_getpwuid_r_5, [
     3016    AC_TRY_COMPILE([
     3017        #include <sys/types.h>
     3018        #include <pwd.h>
     3019    ], [
     3020        uid_t uid;
     3021        struct passwd pw, *pwp;
     3022        char buf[512];
     3023        int buflen = 512;
     3024
     3025        (void) getpwuid_r(uid, &pw, buf, buflen, &pwp);
     3026    ], tcl_cv_api_getpwuid_r_5=yes, tcl_cv_api_getpwuid_r_5=no)])
     3027    tcl_ok=$tcl_cv_api_getpwuid_r_5
     3028    if test "$tcl_ok" = yes; then
     3029        AC_DEFINE(HAVE_GETPWUID_R_5)
     3030    else
     3031        AC_CACHE_CHECK([for getpwuid_r with 4 args], tcl_cv_api_getpwuid_r_4, [
     3032        AC_TRY_COMPILE([
     3033            #include <sys/types.h>
     3034            #include <pwd.h>
     3035        ], [
     3036            uid_t uid;
     3037            struct passwd pw;
     3038            char buf[512];
     3039            int buflen = 512;
     3040
     3041            (void)getpwnam_r(uid, &pw, buf, buflen);
     3042        ], tcl_cv_api_getpwuid_r_4=yes, tcl_cv_api_getpwuid_r_4=no)])
     3043        tcl_ok=$tcl_cv_api_getpwuid_r_4
     3044        if test "$tcl_ok" = yes; then
     3045            AC_DEFINE(HAVE_GETPWUID_R_4)
    28553046        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}"
     3047    fi
     3048    if test "$tcl_ok" = yes; then
     3049        AC_DEFINE(HAVE_GETPWUID_R)
     3050    fi
     3051])])
     3052
     3053#--------------------------------------------------------------------
     3054# SC_TCL_GETPWNAM_R
     3055#
     3056#       Check if we have MT-safe variant of getpwnam() and if yes,
     3057#       which one exactly.
     3058#
     3059# Arguments:
     3060#       None
     3061#       
     3062# Results:
     3063#
     3064#       Might define the following vars:
     3065#               HAVE_GETPWNAM_R
     3066#               HAVE_GETPWNAM_R_4
     3067#               HAVE_GETPWNAM_R_5
     3068#
     3069#--------------------------------------------------------------------
     3070
     3071AC_DEFUN([SC_TCL_GETPWNAM_R], [AC_CHECK_FUNC(getpwnam_r, [
     3072    AC_CACHE_CHECK([for getpwnam_r with 5 args], tcl_cv_api_getpwnam_r_5, [
     3073    AC_TRY_COMPILE([
     3074        #include <sys/types.h>
     3075        #include <pwd.h>
     3076    ], [
     3077        char *name;
     3078        struct passwd pw, *pwp;
     3079        char buf[512];
     3080        int buflen = 512;
     3081
     3082        (void) getpwnam_r(name, &pw, buf, buflen, &pwp);
     3083    ], tcl_cv_api_getpwnam_r_5=yes, tcl_cv_api_getpwnam_r_5=no)])
     3084    tcl_ok=$tcl_cv_api_getpwnam_r_5
     3085    if test "$tcl_ok" = yes; then
     3086        AC_DEFINE(HAVE_GETPWNAM_R_5)
     3087    else
     3088        AC_CACHE_CHECK([for getpwnam_r with 4 args], tcl_cv_api_getpwnam_r_4, [
     3089        AC_TRY_COMPILE([
     3090            #include <sys/types.h>
     3091            #include <pwd.h>
     3092        ], [
     3093            char *name;
     3094            struct passwd pw;
     3095            char buf[512];
     3096            int buflen = 512;
     3097
     3098            (void)getpwnam_r(name, &pw, buf, buflen);
     3099        ], tcl_cv_api_getpwnam_r_4=yes, tcl_cv_api_getpwnam_r_4=no)])
     3100        tcl_ok=$tcl_cv_api_getpwnam_r_4
     3101        if test "$tcl_ok" = yes; then
     3102            AC_DEFINE(HAVE_GETPWNAM_R_4)
    28643103        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.
     3104    fi
     3105    if test "$tcl_ok" = yes; then
     3106        AC_DEFINE(HAVE_GETPWNAM_R)
     3107    fi
     3108])])
     3109
     3110#--------------------------------------------------------------------
     3111# SC_TCL_GETGRGID_R
     3112#
     3113#       Check if we have MT-safe variant of getgrgid() and if yes,
     3114#       which one exactly.
    28763115#
    28773116# Arguments:
    2878 #       one or more file names
    2879 #
     3117#       None
     3118#       
    28803119# Results:
    28813120#
    2882 #       Defines and substs the following vars:
    2883 #               PKG_TCL_SOURCES
    2884 #------------------------------------------------------------------------
    2885 AC_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'])
     3121#       Might define the following vars:
     3122#               HAVE_GETGRGID_R
     3123#               HAVE_GETGRGID_R_4
     3124#               HAVE_GETGRGID_R_5
     3125#
     3126#--------------------------------------------------------------------
     3127
     3128AC_DEFUN([SC_TCL_GETGRGID_R], [AC_CHECK_FUNC(getgrgid_r, [
     3129    AC_CACHE_CHECK([for getgrgid_r with 5 args], tcl_cv_api_getgrgid_r_5, [
     3130    AC_TRY_COMPILE([
     3131        #include <sys/types.h>
     3132        #include <grp.h>
     3133    ], [
     3134        gid_t gid;
     3135        struct group gr, *grp;
     3136        char buf[512];
     3137        int buflen = 512;
     3138
     3139        (void) getgrgid_r(gid, &gr, buf, buflen, &grp);
     3140    ], tcl_cv_api_getgrgid_r_5=yes, tcl_cv_api_getgrgid_r_5=no)])
     3141    tcl_ok=$tcl_cv_api_getgrgid_r_5
     3142    if test "$tcl_ok" = yes; then
     3143        AC_DEFINE(HAVE_GETGRGID_R_5)
     3144    else
     3145        AC_CACHE_CHECK([for getgrgid_r with 4 args], tcl_cv_api_getgrgid_r_4, [
     3146        AC_TRY_COMPILE([
     3147            #include <sys/types.h>
     3148            #include <grp.h>
     3149        ], [
     3150            gid_t gid;
     3151            struct group gr;
     3152            char buf[512];
     3153            int buflen = 512;
     3154
     3155            (void)getgrgid_r(gid, &gr, buf, buflen);
     3156        ], tcl_cv_api_getgrgid_r_4=yes, tcl_cv_api_getgrgid_r_4=no)])
     3157        tcl_ok=$tcl_cv_api_getgrgid_r_4
     3158        if test "$tcl_ok" = yes; then
     3159            AC_DEFINE(HAVE_GETGRGID_R_4)
    28913160        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.
     3161    fi
     3162    if test "$tcl_ok" = yes; then
     3163        AC_DEFINE(HAVE_GETGRGID_R)
     3164    fi
     3165])])
     3166
     3167#--------------------------------------------------------------------
     3168# SC_TCL_GETGRNAM_R
     3169#
     3170#       Check if we have MT-safe variant of getgrnam() and if yes,
     3171#       which one exactly.
    29023172#
    29033173# Arguments:
    2904 #       one or more file names
    2905 #
     3174#       None
     3175#       
    29063176# Results:
    29073177#
    2908 #       Defines and substs the following vars:
    2909 #               PKG_HEADERS
    2910 #------------------------------------------------------------------------
    2911 AC_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'])
     3178#       Might define the following vars:
     3179#               HAVE_GETGRNAM_R
     3180#               HAVE_GETGRNAM_R_4
     3181#               HAVE_GETGRNAM_R_5
     3182#
     3183#--------------------------------------------------------------------
     3184
     3185AC_DEFUN([SC_TCL_GETGRNAM_R], [AC_CHECK_FUNC(getgrnam_r, [
     3186    AC_CACHE_CHECK([for getgrnam_r with 5 args], tcl_cv_api_getgrnam_r_5, [
     3187    AC_TRY_COMPILE([
     3188        #include <sys/types.h>
     3189        #include <grp.h>
     3190    ], [
     3191        char *name;
     3192        struct group gr, *grp;
     3193        char buf[512];
     3194        int buflen = 512;
     3195
     3196        (void) getgrnam_r(name, &gr, buf, buflen, &grp);
     3197    ], tcl_cv_api_getgrnam_r_5=yes, tcl_cv_api_getgrnam_r_5=no)])
     3198    tcl_ok=$tcl_cv_api_getgrnam_r_5
     3199    if test "$tcl_ok" = yes; then
     3200        AC_DEFINE(HAVE_GETGRNAM_R_5)
     3201    else
     3202        AC_CACHE_CHECK([for getgrnam_r with 4 args], tcl_cv_api_getgrnam_r_4, [
     3203        AC_TRY_COMPILE([
     3204            #include <sys/types.h>
     3205            #include <grp.h>
     3206        ], [
     3207            char *name;
     3208            struct group gr;
     3209            char buf[512];
     3210            int buflen = 512;
     3211
     3212            (void)getgrnam_r(name, &gr, buf, buflen);
     3213        ], tcl_cv_api_getgrnam_r_4=yes, tcl_cv_api_getgrnam_r_4=no)])
     3214        tcl_ok=$tcl_cv_api_getgrnam_r_4
     3215        if test "$tcl_ok" = yes; then
     3216            AC_DEFINE(HAVE_GETGRNAM_R_4)
    29173217        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 #------------------------------------------------------------------------
    2937 AC_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 #------------------------------------------------------------------------
    2961 AC_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 #------------------------------------------------------------------------
    2987 AC_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 #------------------------------------------------------------------------
    3006 AC_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 #------------------------------------------------------------------------
    3042 AC_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_CXX
    3054     AC_PROG_CPP
    3055 
    3056     AC_PROG_INSTALL
    3057 
    3058     #--------------------------------------------------------------------
    3059     # Checks to see if the make program sets the $MAKE variable.
    3060     #--------------------------------------------------------------------
    3061 
    3062     AC_PROG_MAKE_SET
    3063 
    3064     #--------------------------------------------------------------------
    3065     # Find ranlib
    3066     #--------------------------------------------------------------------
    3067 
    3068     AC_PROG_RANLIB
    3069 
    3070     #--------------------------------------------------------------------
    3071     # Determines the correct binary file extension (.o, .obj, .exe etc.)
    3072     #--------------------------------------------------------------------
    3073 
    3074     AC_OBJEXT
    3075     AC_EXEEXT
    3076 ])
    3077 
    3078 #------------------------------------------------------------------------
    3079 # TEA_SETUP_COMPILER --
    3080 #
    3081 #       Do compiler checks that use the compiler.  This must go after
    3082 #       TEA_SETUP_COMPILER_CC, which does the actual compiler check.
    3083 #
    3084 # Arguments:
    3085 #       none
    3086 #
    3087 # Results:
    3088 #
    3089 #       Sets up CC var and other standard bits we need to make executables.
    3090 #------------------------------------------------------------------------
    3091 AC_DEFUN([TEA_SETUP_COMPILER], [
    3092     # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here.
    3093     AC_REQUIRE([TEA_SETUP_COMPILER_CC])
    3094 
    3095     #------------------------------------------------------------------------
    3096     # If we're using GCC, see if the compiler understands -pipe. If so, use it.
    3097     # It makes compiling go faster.  (This is only a performance feature.)
    3098     #------------------------------------------------------------------------
    3099 
    3100     if test -z "$no_pipe" -a -n "$GCC"; then
    3101         AC_MSG_CHECKING([if the compiler understands -pipe])
    3102         OLDCC="$CC"
    3103         CC="$CC -pipe"
    3104         AC_TRY_COMPILE(,, AC_MSG_RESULT([yes]), CC="$OLDCC"
    3105             AC_MSG_RESULT([no]))
    3106     fi
    3107 
    3108     #--------------------------------------------------------------------
    3109     # Common compiler flag setup
    3110     #--------------------------------------------------------------------
    3111 
    3112     AC_C_BIGENDIAN
    3113     if test "${TEA_PLATFORM}" = "unix" ; then
    3114         TEA_TCL_LINK_LIBS
    3115         TEA_MISSING_POSIX_HEADERS
    3116         # Let the user call this, because if it triggers, they will
    3117         # need a compat/strtod.c that is correct.  Users can also
    3118         # use Tcl_GetDouble(FromObj) instead.
    3119         #TEA_BUGGY_STRTOD
    3120     fi
    3121 ])
    3122 
    3123 #------------------------------------------------------------------------
    3124 # TEA_MAKE_LIB --
    3125 #
    3126 #       Generate a line that can be used to build a shared/unshared library
    3127 #       in a platform independent manner.
    3128 #
    3129 # Arguments:
    3130 #       none
    3131 #
    3132 #       Requires:
    3133 #
    3134 # Results:
    3135 #
    3136 #       Defines the following vars:
    3137 #       CFLAGS -        Done late here to note disturb other AC macros
    3138 #       MAKE_LIB -      Command to execute to build the Tcl library;
    3139 #                       differs depending on whether or not Tcl is being
    3140 #                       compiled as a shared library.
    3141 #       MAKE_SHARED_LIB Makefile rule for building a shared library
    3142 #       MAKE_STATIC_LIB Makefile rule for building a static library
    3143 #       MAKE_STUB_LIB   Makefile rule for building a stub library
    3144 #------------------------------------------------------------------------
    3145 
    3146 AC_DEFUN([TEA_MAKE_LIB], [
    3147     if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then
    3148         MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_OBJECTS)"
    3149         MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\[$]@ \$(PKG_OBJECTS)"
    3150         MAKE_STUB_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_STUB_OBJECTS)"
    3151     else
    3152         MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(PKG_OBJECTS)"
    3153         MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}"
    3154         MAKE_STUB_LIB="\${STLIB_LD} \[$]@ \$(PKG_STUB_OBJECTS)"
    3155     fi
    3156 
    3157     if test "${SHARED_BUILD}" = "1" ; then
    3158         MAKE_LIB="${MAKE_SHARED_LIB} "
    3159     else
    3160         MAKE_LIB="${MAKE_STATIC_LIB} "
    3161     fi
    3162 
    3163     #--------------------------------------------------------------------
    3164     # Shared libraries and static libraries have different names.
    3165     # Use the double eval to make sure any variables in the suffix is
    3166     # substituted. (@@@ Might not be necessary anymore)
    3167     #--------------------------------------------------------------------
    3168 
    3169     if test "${TEA_PLATFORM}" = "windows" ; then
    3170         if test "${SHARED_BUILD}" = "1" ; then
    3171             # We force the unresolved linking of symbols that are really in
    3172             # the private libraries of Tcl and Tk.
    3173             SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\""
    3174             if test x"${TK_BIN_DIR}" != x ; then
    3175                 SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\""
    3176             fi
    3177             eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
    3178         else
    3179             eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
    3180         fi
    3181         # Some packages build their own stubs libraries
    3182         eval eval "PKG_STUB_LIB_FILE=${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
    3183         if test "$GCC" = "yes"; then
    3184             PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE}
    3185         fi
    3186         # These aren't needed on Windows (either MSVC or gcc)
    3187         RANLIB="mt -manifest ${PKG_LIB_FILE}.manifest -outputresource:${PKG_LIB_FILE}\;2 ; test -f"
    3188         RANLIB_STUB=:
    3189     else
    3190         RANLIB_STUB="${RANLIB}"
    3191         if test "${SHARED_BUILD}" = "1" ; then
    3192             SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}"
    3193             if test x"${TK_BIN_DIR}" != x ; then
    3194                 SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}"
    3195             fi
    3196             eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
    3197             RANLIB=:
    3198         else
    3199             eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
    3200         fi
    3201         # Some packages build their own stubs libraries
    3202         eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
    3203     fi
    3204 
    3205     # These are escaped so that only CFLAGS is picked up at configure time.
    3206     # The other values will be substituted at make time.
    3207     CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}"
    3208     if test "${SHARED_BUILD}" = "1" ; then
    3209         CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}"
    3210     fi
    3211 
    3212     AC_SUBST(MAKE_LIB)
    3213     AC_SUBST(MAKE_SHARED_LIB)
    3214     AC_SUBST(MAKE_STATIC_LIB)
    3215     AC_SUBST(MAKE_STUB_LIB)
    3216     AC_SUBST(RANLIB_STUB)
    3217     AC_SUBST(RANLIB)
    3218 ])
    3219 
    3220 #------------------------------------------------------------------------
    3221 # TEA_LIB_SPEC --
    3222 #
    3223 #       Compute the name of an existing object library located in libdir
    3224 #       from the given base name and produce the appropriate linker flags.
    3225 #
    3226 # Arguments:
    3227 #       basename        The base name of the library without version
    3228 #                       numbers, extensions, or "lib" prefixes.
    3229 #       extra_dir       Extra directory in which to search for the
    3230 #                       library.  This location is used first, then
    3231 #                       $prefix/$exec-prefix, then some defaults.
    3232 #
    3233 # Requires:
    3234 #       TEA_INIT and TEA_PREFIX must be called first.
    3235 #
    3236 # Results:
    3237 #
    3238 #       Defines the following vars:
    3239 #               ${basename}_LIB_NAME    The computed library name.
    3240 #               ${basename}_LIB_SPEC    The computed linker flags.
    3241 #------------------------------------------------------------------------
    3242 
    3243 AC_DEFUN([TEA_LIB_SPEC], [
    3244     AC_MSG_CHECKING([for $1 library])
    3245 
    3246     # Look in exec-prefix for the library (defined by TEA_PREFIX).
    3247 
    3248     tea_lib_name_dir="${exec_prefix}/lib"
    3249 
    3250     # Or in a user-specified location.
    3251 
    3252     if test x"$2" != x ; then
    3253         tea_extra_lib_dir=$2
    3254     else
    3255         tea_extra_lib_dir=NONE
    3256     fi
    3257 
    3258     for i in \
    3259             `ls -dr ${tea_extra_lib_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
    3260             `ls -dr ${tea_extra_lib_dir}/lib$1[[0-9]]* 2>/dev/null ` \
    3261             `ls -dr ${tea_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
    3262             `ls -dr ${tea_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
    3263             `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
    3264             `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
    3265             `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
    3266             `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
    3267         if test -f "$i" ; then
    3268             tea_lib_name_dir=`dirname $i`
    3269             $1_LIB_NAME=`basename $i`
    3270             $1_LIB_PATH_NAME=$i
    3271             break
    3272         fi
    3273     done
    3274 
    3275     if test "${TEA_PLATFORM}" = "windows"; then
    3276         $1_LIB_SPEC=\"`${CYGPATH} ${$1_LIB_PATH_NAME} 2>/dev/null`\"
    3277     else
    3278         # Strip off the leading "lib" and trailing ".a" or ".so"
    3279 
    3280         tea_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//' -e 's/\.so.*//'`
    3281         $1_LIB_SPEC="-L${tea_lib_name_dir} -l${tea_lib_name_lib}"
    3282     fi
    3283 
    3284     if test "x${$1_LIB_NAME}" = x ; then
    3285         AC_MSG_ERROR([not found])
    3286     else
    3287         AC_MSG_RESULT([${$1_LIB_SPEC}])
    3288     fi
    3289 ])
    3290 
    3291 #------------------------------------------------------------------------
    3292 # TEA_PRIVATE_TCL_HEADERS --
    3293 #
    3294 #       Locate the private Tcl include files
    3295 #
    3296 # Arguments:
    3297 #
    3298 #       Requires:
    3299 #               TCL_SRC_DIR     Assumes that TEA_LOAD_TCLCONFIG has
    3300 #                                already been called.
    3301 #
    3302 # Results:
    3303 #
    3304 #       Substs the following vars:
    3305 #               TCL_TOP_DIR_NATIVE
    3306 #               TCL_GENERIC_DIR_NATIVE
    3307 #               TCL_UNIX_DIR_NATIVE
    3308 #               TCL_WIN_DIR_NATIVE
    3309 #               TCL_BMAP_DIR_NATIVE
    3310 #               TCL_TOOL_DIR_NATIVE
    3311 #               TCL_PLATFORM_DIR_NATIVE
    3312 #               TCL_BIN_DIR_NATIVE
    3313 #               TCL_INCLUDES
    3314 #------------------------------------------------------------------------
    3315 
    3316 AC_DEFUN([TEA_PRIVATE_TCL_HEADERS], [
    3317     AC_MSG_CHECKING([for Tcl private include files])
    3318 
    3319     TCL_SRC_DIR_NATIVE=`${CYGPATH} ${TCL_SRC_DIR}`
    3320     TCL_TOP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}\"
    3321     TCL_GENERIC_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/generic\"
    3322     TCL_UNIX_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/unix\"
    3323     TCL_WIN_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/win\"
    3324     TCL_BMAP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/bitmaps\"
    3325     TCL_TOOL_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/tools\"
    3326     TCL_COMPAT_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/compat\"
    3327 
    3328     if test "${TEA_PLATFORM}" = "windows"; then
    3329         TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
    3330     else
    3331         TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
    3332     fi
    3333     # We want to ensure these are substituted so as not to require
    3334     # any *_NATIVE vars be defined in the Makefile
    3335     TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
    3336     if test "`uname -s`" = "Darwin"; then
    3337         # If Tcl was built as a framework, attempt to use
    3338         # the framework's Headers and PrivateHeaders directories
    3339         case ${TCL_DEFS} in
    3340             *TCL_FRAMEWORK*)
    3341                 if test -d "${TCL_BIN_DIR}/Headers" -a -d "${TCL_BIN_DIR}/PrivateHeaders"; then
    3342                 TCL_INCLUDES="-I\"${TCL_BIN_DIR}/Headers\" -I\"${TCL_BIN_DIR}/PrivateHeaders\" ${TCL_INCLUDES}"; else
    3343                 TCL_INCLUDES="${TCL_INCLUDES} ${TCL_INCLUDE_SPEC} `echo "${TCL_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`"; fi
    3344                 ;;
    3345         esac
    3346     fi
    3347 
    3348     AC_SUBST(TCL_TOP_DIR_NATIVE)
    3349     AC_SUBST(TCL_GENERIC_DIR_NATIVE)
    3350     AC_SUBST(TCL_UNIX_DIR_NATIVE)
    3351     AC_SUBST(TCL_WIN_DIR_NATIVE)
    3352     AC_SUBST(TCL_BMAP_DIR_NATIVE)
    3353     AC_SUBST(TCL_TOOL_DIR_NATIVE)
    3354     AC_SUBST(TCL_PLATFORM_DIR_NATIVE)
    3355 
    3356     AC_SUBST(TCL_INCLUDES)
    3357     AC_MSG_RESULT([Using srcdir found in tclConfig.sh: ${TCL_SRC_DIR}])
    3358 ])
    3359 
    3360 #------------------------------------------------------------------------
    3361 # TEA_PUBLIC_TCL_HEADERS --
    3362 #
    3363 #       Locate the installed public Tcl header files
    3364 #
    3365 # Arguments:
    3366 #       None.
    3367 #
    3368 # Requires:
    3369 #       CYGPATH must be set
    3370 #
    3371 # Results:
    3372 #
    3373 #       Adds a --with-tclinclude switch to configure.
    3374 #       Result is cached.
    3375 #
    3376 #       Substs the following vars:
    3377 #               TCL_INCLUDES
    3378 #------------------------------------------------------------------------
    3379 
    3380 AC_DEFUN([TEA_PUBLIC_TCL_HEADERS], [
    3381     AC_MSG_CHECKING([for Tcl public headers])
    3382 
    3383     AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory containing the public Tcl header files], with_tclinclude=${withval})
    3384 
    3385     AC_CACHE_VAL(ac_cv_c_tclh, [
    3386         # Use the value from --with-tclinclude, if it was given
    3387 
    3388         if test x"${with_tclinclude}" != x ; then
    3389             if test -f "${with_tclinclude}/tcl.h" ; then
    3390                 ac_cv_c_tclh=${with_tclinclude}
    3391             else
    3392                 AC_MSG_ERROR([${with_tclinclude} directory does not contain tcl.h])
    3393             fi
    3394         else
    3395             if test "`uname -s`" = "Darwin"; then
    3396                 # If Tcl was built as a framework, attempt to use
    3397                 # the framework's Headers directory
    3398                 case ${TCL_DEFS} in
    3399                     *TCL_FRAMEWORK*)
    3400                         list="`ls -d ${TCL_BIN_DIR}/Headers 2>/dev/null`"
    3401                         ;;
    3402                 esac
    3403             fi
    3404 
    3405             # Look in the source dir only if Tcl is not installed,
    3406             # and in that situation, look there before installed locations.
    3407             if test -f "${TCL_BIN_DIR}/Makefile" ; then
    3408                 list="$list `ls -d ${TCL_SRC_DIR}/generic 2>/dev/null`"
    3409             fi
    3410 
    3411             # Check order: pkg --prefix location, Tcl's --prefix location,
    3412             # relative to directory of tclConfig.sh.
    3413 
    3414             eval "temp_includedir=${includedir}"
    3415             list="$list \
    3416                 `ls -d ${temp_includedir}        2>/dev/null` \
    3417                 `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
    3418                 `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
    3419             if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
    3420                 list="$list /usr/local/include /usr/include"
    3421                 if test x"${TCL_INCLUDE_SPEC}" != x ; then
    3422                     d=`echo "${TCL_INCLUDE_SPEC}" | sed -e 's/^-I//'`
    3423                     list="$list `ls -d ${d} 2>/dev/null`"
    3424                 fi
    3425             fi
    3426             for i in $list ; do
    3427                 if test -f "$i/tcl.h" ; then
    3428                     ac_cv_c_tclh=$i
    3429                     break
    3430                 fi
    3431             done
    3432         fi
    3433     ])
    3434 
    3435     # Print a message based on how we determined the include path
    3436 
    3437     if test x"${ac_cv_c_tclh}" = x ; then
    3438         AC_MSG_ERROR([tcl.h not found.  Please specify its location with --with-tclinclude])
    3439     else
    3440         AC_MSG_RESULT([${ac_cv_c_tclh}])
    3441     fi
    3442 
    3443     # Convert to a native path and substitute into the output files.
    3444 
    3445     INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
    3446 
    3447     TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
    3448 
    3449     AC_SUBST(TCL_INCLUDES)
    3450 ])
    3451 
    3452 #------------------------------------------------------------------------
    3453 # TEA_PRIVATE_TK_HEADERS --
    3454 #
    3455 #       Locate the private Tk include files
    3456 #
    3457 # Arguments:
    3458 #
    3459 #       Requires:
    3460 #               TK_SRC_DIR      Assumes that TEA_LOAD_TKCONFIG has
    3461 #                                already been called.
    3462 #
    3463 # Results:
    3464 #
    3465 #       Substs the following vars:
    3466 #               TK_INCLUDES
    3467 #------------------------------------------------------------------------
    3468 
    3469 AC_DEFUN([TEA_PRIVATE_TK_HEADERS], [
    3470     AC_MSG_CHECKING([for Tk private include files])
    3471 
    3472     TK_SRC_DIR_NATIVE=`${CYGPATH} ${TK_SRC_DIR}`
    3473     TK_TOP_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}\"
    3474     TK_UNIX_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/unix\"
    3475     TK_WIN_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/win\"
    3476     TK_GENERIC_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/generic\"
    3477     TK_XLIB_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/xlib\"
    3478     if test "${TEA_PLATFORM}" = "windows"; then
    3479         TK_PLATFORM_DIR_NATIVE=${TK_WIN_DIR_NATIVE}
    3480     else
    3481         TK_PLATFORM_DIR_NATIVE=${TK_UNIX_DIR_NATIVE}
    3482     fi
    3483     # We want to ensure these are substituted so as not to require
    3484     # any *_NATIVE vars be defined in the Makefile
    3485     TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
    3486     if test "${TEA_WINDOWINGSYSTEM}" = "win32" \
    3487         -o "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
    3488         TK_INCLUDES="${TK_INCLUDES} -I${TK_XLIB_DIR_NATIVE}"
    3489     fi
    3490     if test "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
    3491         TK_INCLUDES="${TK_INCLUDES} -I${TK_SRC_DIR_NATIVE}/macosx"
    3492     fi
    3493     if test "`uname -s`" = "Darwin"; then
    3494         # If Tk was built as a framework, attempt to use
    3495         # the framework's Headers and PrivateHeaders directories
    3496         case ${TK_DEFS} in
    3497             *TK_FRAMEWORK*)
    3498                 if test -d "${TK_BIN_DIR}/Headers" -a -d "${TK_BIN_DIR}/PrivateHeaders"; then
    3499                 TK_INCLUDES="-I\"${TK_BIN_DIR}/Headers\" -I\"${TK_BIN_DIR}/PrivateHeaders\" ${TK_INCLUDES}"; fi
    3500                 ;;
    3501         esac
    3502     fi
    3503 
    3504     AC_SUBST(TK_TOP_DIR_NATIVE)
    3505     AC_SUBST(TK_UNIX_DIR_NATIVE)
    3506     AC_SUBST(TK_WIN_DIR_NATIVE)
    3507     AC_SUBST(TK_GENERIC_DIR_NATIVE)
    3508     AC_SUBST(TK_XLIB_DIR_NATIVE)
    3509     AC_SUBST(TK_PLATFORM_DIR_NATIVE)
    3510 
    3511     AC_SUBST(TK_INCLUDES)
    3512     AC_MSG_RESULT([Using srcdir found in tkConfig.sh: ${TK_SRC_DIR}])
    3513 ])
    3514 
    3515 #------------------------------------------------------------------------
    3516 # TEA_PUBLIC_TK_HEADERS --
    3517 #
    3518 #       Locate the installed public Tk header files
    3519 #
    3520 # Arguments:
    3521 #       None.
    3522 #
    3523 # Requires:
    3524 #       CYGPATH must be set
    3525 #
    3526 # Results:
    3527 #
    3528 #       Adds a --with-tkinclude switch to configure.
    3529 #       Result is cached.
    3530 #
    3531 #       Substs the following vars:
    3532 #               TK_INCLUDES
    3533 #------------------------------------------------------------------------
    3534 
    3535 AC_DEFUN([TEA_PUBLIC_TK_HEADERS], [
    3536     AC_MSG_CHECKING([for Tk public headers])
    3537 
    3538     AC_ARG_WITH(tkinclude, [  --with-tkinclude      directory containing the public Tk header files.], with_tkinclude=${withval})
    3539 
    3540     AC_CACHE_VAL(ac_cv_c_tkh, [
    3541         # Use the value from --with-tkinclude, if it was given
    3542 
    3543         if test x"${with_tkinclude}" != x ; then
    3544             if test -f "${with_tkinclude}/tk.h" ; then
    3545                 ac_cv_c_tkh=${with_tkinclude}
    3546             else
    3547                 AC_MSG_ERROR([${with_tkinclude} directory does not contain tk.h])
    3548             fi
    3549         else
    3550             if test "`uname -s`" = "Darwin"; then
    3551                 # If Tk was built as a framework, attempt to use
    3552                 # the framework's Headers directory.
    3553                 case ${TK_DEFS} in
    3554                     *TK_FRAMEWORK*)
    3555                         list="`ls -d ${TK_BIN_DIR}/Headers 2>/dev/null`"
    3556                         ;;
    3557                 esac
    3558             fi
    3559 
    3560             # Look in the source dir only if Tk is not installed,
    3561             # and in that situation, look there before installed locations.
    3562             if test -f "${TK_BIN_DIR}/Makefile" ; then
    3563                 list="$list `ls -d ${TK_SRC_DIR}/generic 2>/dev/null`"
    3564             fi
    3565 
    3566             # Check order: pkg --prefix location, Tk's --prefix location,
    3567             # relative to directory of tkConfig.sh, Tcl's --prefix location,
    3568             # relative to directory of tclConfig.sh.
    3569 
    3570             eval "temp_includedir=${includedir}"
    3571             list="$list \
    3572                 `ls -d ${temp_includedir}        2>/dev/null` \
    3573                 `ls -d ${TK_PREFIX}/include      2>/dev/null` \
    3574                 `ls -d ${TK_BIN_DIR}/../include  2>/dev/null` \
    3575                 `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
    3576                 `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
    3577             if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
    3578                 list="$list /usr/local/include /usr/include"
    3579             fi
    3580             for i in $list ; do
    3581                 if test -f "$i/tk.h" ; then
    3582                     ac_cv_c_tkh=$i
    3583                     break
    3584                 fi
    3585             done
    3586         fi
    3587     ])
    3588 
    3589     # Print a message based on how we determined the include path
    3590 
    3591     if test x"${ac_cv_c_tkh}" = x ; then
    3592         AC_MSG_ERROR([tk.h not found.  Please specify its location with --with-tkinclude])
    3593     else
    3594         AC_MSG_RESULT([${ac_cv_c_tkh}])
    3595     fi
    3596 
    3597     # Convert to a native path and substitute into the output files.
    3598 
    3599     INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}`
    3600 
    3601     TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
    3602 
    3603     AC_SUBST(TK_INCLUDES)
    3604 
    3605     if test "${TEA_WINDOWINGSYSTEM}" = "win32" \
    3606         -o "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
    3607         # On Windows and Aqua, we need the X compat headers
    3608         AC_MSG_CHECKING([for X11 header files])
    3609         if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then
    3610             INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`"
    3611             TK_XINCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
    3612             AC_SUBST(TK_XINCLUDES)
    3613         fi
    3614         AC_MSG_RESULT([${INCLUDE_DIR_NATIVE}])
    3615     fi
    3616 ])
    3617 
    3618 #------------------------------------------------------------------------
    3619 # TEA_PROG_TCLSH
    3620 #       Determine the fully qualified path name of the tclsh executable
    3621 #       in the Tcl build directory or the tclsh installed in a bin
    3622 #       directory. This macro will correctly determine the name
    3623 #       of the tclsh executable even if tclsh has not yet been
    3624 #       built in the build directory. The tclsh found is always
    3625 #       associated with a tclConfig.sh file. This tclsh should be used
    3626 #       only for running extension test cases. It should never be
    3627 #       or generation of files (like pkgIndex.tcl) at build time.
    3628 #
    3629 # Arguments
    3630 #       none
    3631 #
    3632 # Results
    3633 #       Subst's the following values:
    3634 #               TCLSH_PROG
    3635 #------------------------------------------------------------------------
    3636 
    3637 AC_DEFUN([TEA_PROG_TCLSH], [
    3638     AC_MSG_CHECKING([for tclsh])
    3639     if test -f "${TCL_BIN_DIR}/Makefile" ; then
    3640         # tclConfig.sh is in Tcl build directory
    3641         if test "${TEA_PLATFORM}" = "windows"; then
    3642             TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
    3643         else
    3644             TCLSH_PROG="${TCL_BIN_DIR}/tclsh"
    3645         fi
    3646     else
    3647         # tclConfig.sh is in install location
    3648         if test "${TEA_PLATFORM}" = "windows"; then
    3649             TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
    3650         else
    3651             TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}"
    3652         fi
    3653         list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \
    3654               `ls -d ${TCL_BIN_DIR}/..     2>/dev/null` \
    3655               `ls -d ${TCL_PREFIX}/bin     2>/dev/null`"
    3656         for i in $list ; do
    3657             if test -f "$i/${TCLSH_PROG}" ; then
    3658                 REAL_TCL_BIN_DIR="`cd "$i"; pwd`"
    3659                 break
    3660             fi
    3661         done
    3662         TCLSH_PROG="${REAL_TCL_BIN_DIR}/${TCLSH_PROG}"
    3663     fi
    3664     AC_MSG_RESULT([${TCLSH_PROG}])
    3665     AC_SUBST(TCLSH_PROG)
    3666 ])
    3667 
    3668 #------------------------------------------------------------------------
    3669 # TEA_PROG_WISH
    3670 #       Determine the fully qualified path name of the wish executable
    3671 #       in the Tk build directory or the wish installed in a bin
    3672 #       directory. This macro will correctly determine the name
    3673 #       of the wish executable even if wish has not yet been
    3674 #       built in the build directory. The wish found is always
    3675 #       associated with a tkConfig.sh file. This wish should be used
    3676 #       only for running extension test cases. It should never be
    3677 #       or generation of files (like pkgIndex.tcl) at build time.
    3678 #
    3679 # Arguments
    3680 #       none
    3681 #
    3682 # Results
    3683 #       Subst's the following values:
    3684 #               WISH_PROG
    3685 #------------------------------------------------------------------------
    3686 
    3687 AC_DEFUN([TEA_PROG_WISH], [
    3688     AC_MSG_CHECKING([for wish])
    3689     if test -f "${TK_BIN_DIR}/Makefile" ; then
    3690         # tkConfig.sh is in Tk build directory
    3691         if test "${TEA_PLATFORM}" = "windows"; then
    3692             WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}"
    3693         else
    3694             WISH_PROG="${TK_BIN_DIR}/wish"
    3695         fi
    3696     else
    3697         # tkConfig.sh is in install location
    3698         if test "${TEA_PLATFORM}" = "windows"; then
    3699             WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}"
    3700         else
    3701             WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_DBGX}"
    3702         fi
    3703         list="`ls -d ${TK_BIN_DIR}/../bin 2>/dev/null` \
    3704               `ls -d ${TK_BIN_DIR}/..     2>/dev/null` \
    3705               `ls -d ${TK_PREFIX}/bin     2>/dev/null`"
    3706         for i in $list ; do
    3707             if test -f "$i/${WISH_PROG}" ; then
    3708                 REAL_TK_BIN_DIR="`cd "$i"; pwd`"
    3709                 break
    3710             fi
    3711         done
    3712         WISH_PROG="${REAL_TK_BIN_DIR}/${WISH_PROG}"
    3713     fi
    3714     AC_MSG_RESULT([${WISH_PROG}])
    3715     AC_SUBST(WISH_PROG)
    3716 ])
    3717 
    3718 #------------------------------------------------------------------------
    3719 # TEA_PATH_CONFIG --
    3720 #
    3721 #       Locate the ${1}Config.sh file and perform a sanity check on
    3722 #       the ${1} compile flags.  These are used by packages like
    3723 #       [incr Tk] that load *Config.sh files from more than Tcl and Tk.
    3724 #
    3725 # Arguments:
    3726 #       none
    3727 #
    3728 # Results:
    3729 #
    3730 #       Adds the following arguments to configure:
    3731 #               --with-$1=...
    3732 #
    3733 #       Defines the following vars:
    3734 #               $1_BIN_DIR      Full path to the directory containing
    3735 #                               the $1Config.sh file
    3736 #------------------------------------------------------------------------
    3737 
    3738 AC_DEFUN([TEA_PATH_CONFIG], [
    3739     #
    3740     # Ok, lets find the $1 configuration
    3741     # First, look for one uninstalled.
    3742     # the alternative search directory is invoked by --with-$1
    3743     #
    3744 
    3745     if test x"${no_$1}" = x ; then
    3746         # we reset no_$1 in case something fails here
    3747         no_$1=true
    3748         AC_ARG_WITH($1, [  --with-$1              directory containing $1 configuration ($1Config.sh)], with_$1config=${withval})
    3749         AC_MSG_CHECKING([for $1 configuration])
    3750         AC_CACHE_VAL(ac_cv_c_$1config,[
    3751 
    3752             # First check to see if --with-$1 was specified.
    3753             if test x"${with_$1config}" != x ; then
    3754                 case ${with_$1config} in
    3755                     */$1Config.sh )
    3756                         if test -f ${with_$1config}; then
    3757                             AC_MSG_WARN([--with-$1 argument should refer to directory containing $1Config.sh, not to $1Config.sh itself])
    3758                             with_$1config=`echo ${with_$1config} | sed 's!/$1Config\.sh$!!'`
    3759                         fi;;
    3760                 esac
    3761                 if test -f "${with_$1config}/$1Config.sh" ; then
    3762                     ac_cv_c_$1config=`(cd ${with_$1config}; pwd)`
    3763                 else
    3764                     AC_MSG_ERROR([${with_$1config} directory doesn't contain $1Config.sh])
    3765                 fi
    3766             fi
    3767 
    3768             # then check for a private $1 installation
    3769             if test x"${ac_cv_c_$1config}" = x ; then
    3770                 for i in \
    3771                         ../$1 \
    3772                         `ls -dr ../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
    3773                         `ls -dr ../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
    3774                         `ls -dr ../$1*[[0-9]].[[0-9]] 2>/dev/null` \
    3775                         `ls -dr ../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
    3776                         ../../$1 \
    3777                         `ls -dr ../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
    3778                         `ls -dr ../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
    3779                         `ls -dr ../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
    3780                         `ls -dr ../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
    3781                         ../../../$1 \
    3782                         `ls -dr ../../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
    3783                         `ls -dr ../../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
    3784                         `ls -dr ../../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
    3785                         `ls -dr ../../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
    3786                         ${srcdir}/../$1 \
    3787                         `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
    3788                         `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
    3789                         `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]] 2>/dev/null` \
    3790                         `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
    3791                         ; do
    3792                     if test -f "$i/$1Config.sh" ; then
    3793                         ac_cv_c_$1config=`(cd $i; pwd)`
    3794                         break
    3795                     fi
    3796                     if test -f "$i/unix/$1Config.sh" ; then
    3797                         ac_cv_c_$1config=`(cd $i/unix; pwd)`
    3798                         break
    3799                     fi
    3800                 done
    3801             fi
    3802 
    3803             # check in a few common install locations
    3804             if test x"${ac_cv_c_$1config}" = x ; then
    3805                 for i in `ls -d ${libdir} 2>/dev/null` \
    3806                         `ls -d ${exec_prefix}/lib 2>/dev/null` \
    3807                         `ls -d ${prefix}/lib 2>/dev/null` \
    3808                         `ls -d /usr/local/lib 2>/dev/null` \
    3809                         `ls -d /usr/contrib/lib 2>/dev/null` \
    3810                         `ls -d /usr/lib 2>/dev/null` \
    3811                         ; do
    3812                     if test -f "$i/$1Config.sh" ; then
    3813                         ac_cv_c_$1config=`(cd $i; pwd)`
    3814                         break
    3815                     fi
    3816                 done
    3817             fi
    3818         ])
    3819 
    3820         if test x"${ac_cv_c_$1config}" = x ; then
    3821             $1_BIN_DIR="# no $1 configs found"
    3822             AC_MSG_WARN([Cannot find $1 configuration definitions])
    3823             exit 0
    3824         else
    3825             no_$1=
    3826             $1_BIN_DIR=${ac_cv_c_$1config}
    3827             AC_MSG_RESULT([found $$1_BIN_DIR/$1Config.sh])
    3828         fi
    3829     fi
    3830 ])
    3831 
    3832 #------------------------------------------------------------------------
    3833 # TEA_LOAD_CONFIG --
    3834 #
    3835 #       Load the $1Config.sh file
    3836 #
    3837 # Arguments:
    3838 #       
    3839 #       Requires the following vars to be set:
    3840 #               $1_BIN_DIR
    3841 #
    3842 # Results:
    3843 #
    3844 #       Subst the following vars:
    3845 #               $1_SRC_DIR
    3846 #               $1_LIB_FILE
    3847 #               $1_LIB_SPEC
    3848 #
    3849 #------------------------------------------------------------------------
    3850 
    3851 AC_DEFUN([TEA_LOAD_CONFIG], [
    3852     AC_MSG_CHECKING([for existence of ${$1_BIN_DIR}/$1Config.sh])
    3853 
    3854     if test -f "${$1_BIN_DIR}/$1Config.sh" ; then
    3855         AC_MSG_RESULT([loading])
    3856         . ${$1_BIN_DIR}/$1Config.sh
    3857     else
    3858         AC_MSG_RESULT([file not found])
    3859     fi
    3860 
    3861     #
    3862     # If the $1_BIN_DIR is the build directory (not the install directory),
    3863     # then set the common variable name to the value of the build variables.
    3864     # For example, the variable $1_LIB_SPEC will be set to the value
    3865     # of $1_BUILD_LIB_SPEC. An extension should make use of $1_LIB_SPEC
    3866     # instead of $1_BUILD_LIB_SPEC since it will work with both an
    3867     # installed and uninstalled version of Tcl.
    3868     #
    3869 
    3870     if test -f ${$1_BIN_DIR}/Makefile ; then
    3871         AC_MSG_WARN([Found Makefile - using build library specs for $1])
    3872         $1_LIB_SPEC=${$1_BUILD_LIB_SPEC}
    3873         $1_STUB_LIB_SPEC=${$1_BUILD_STUB_LIB_SPEC}
    3874         $1_STUB_LIB_PATH=${$1_BUILD_STUB_LIB_PATH}
    3875     fi
    3876 
    3877     AC_SUBST($1_VERSION)
    3878     AC_SUBST($1_BIN_DIR)
    3879     AC_SUBST($1_SRC_DIR)
    3880 
    3881     AC_SUBST($1_LIB_FILE)
    3882     AC_SUBST($1_LIB_SPEC)
    3883 
    3884     AC_SUBST($1_STUB_LIB_FILE)
    3885     AC_SUBST($1_STUB_LIB_SPEC)
    3886     AC_SUBST($1_STUB_LIB_PATH)
    3887 ])
    3888 
    3889 #------------------------------------------------------------------------
    3890 # TEA_PATH_CELIB --
    3891 #
    3892 #       Locate Keuchel's celib emulation layer for targeting Win/CE
    3893 #
    3894 # Arguments:
    3895 #       none
    3896 #
    3897 # Results:
    3898 #
    3899 #       Adds the following arguments to configure:
    3900 #               --with-celib=...
    3901 #
    3902 #       Defines the following vars:
    3903 #               CELIB_DIR       Full path to the directory containing
    3904 #                               the include and platform lib files
    3905 #------------------------------------------------------------------------
    3906 
    3907 AC_DEFUN([TEA_PATH_CELIB], [
    3908     # First, look for one uninstalled.
    3909     # the alternative search directory is invoked by --with-celib
    3910 
    3911     if test x"${no_celib}" = x ; then
    3912         # we reset no_celib in case something fails here
    3913         no_celib=true
    3914         AC_ARG_WITH(celib,[  --with-celib=DIR        use Windows/CE support library from DIR], with_celibconfig=${withval})
    3915         AC_MSG_CHECKING([for Windows/CE celib directory])
    3916         AC_CACHE_VAL(ac_cv_c_celibconfig,[
    3917             # First check to see if --with-celibconfig was specified.
    3918             if test x"${with_celibconfig}" != x ; then
    3919                 if test -d "${with_celibconfig}/inc" ; then
    3920                     ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)`
    3921                 else
    3922                     AC_MSG_ERROR([${with_celibconfig} directory doesn't contain inc directory])
    3923                 fi
    3924             fi
    3925 
    3926             # then check for a celib library
    3927             if test x"${ac_cv_c_celibconfig}" = x ; then
    3928                 for i in \
    3929                         ../celib-palm-3.0 \
    3930                         ../celib \
    3931                         ../../celib-palm-3.0 \
    3932                         ../../celib \
    3933                         `ls -dr ../celib-*3.[[0-9]]* 2>/dev/null` \
    3934                         ${srcdir}/../celib-palm-3.0 \
    3935                         ${srcdir}/../celib \
    3936                         `ls -dr ${srcdir}/../celib-*3.[[0-9]]* 2>/dev/null` \
    3937                         ; do
    3938                     if test -d "$i/inc" ; then
    3939                         ac_cv_c_celibconfig=`(cd $i; pwd)`
    3940                         break
    3941                     fi
    3942                 done
    3943             fi
    3944         ])
    3945         if test x"${ac_cv_c_celibconfig}" = x ; then
    3946             AC_MSG_ERROR([Cannot find celib support library directory])
    3947         else
    3948             no_celib=
    3949             CELIB_DIR=${ac_cv_c_celibconfig}
    3950             CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'`
    3951             AC_MSG_RESULT([found $CELIB_DIR])
    3952         fi
    3953     fi
    3954 ])
    3955 
    3956 
    3957 # Local Variables:
    3958 # mode: autoconf
    3959 # End:
     3218    fi
     3219    if test "$tcl_ok" = yes; then
     3220        AC_DEFINE(HAVE_GETGRNAM_R)
     3221    fi
     3222])])
     3223
     3224#--------------------------------------------------------------------
     3225# SC_CONFIG_COMMANDS_PRE(CMDS)
     3226#
     3227#       Replacement for autoconf 2.5x AC_COMMANDS_PRE:
     3228#               Commands to run right before config.status is
     3229#               created. Accumulates.
     3230#
     3231#       Requires presence of SC_OUTPUT_COMMANDS_PRE at the end
     3232#       of configure.in (right before AC_OUTPUT).
     3233#
     3234#--------------------------------------------------------------------
     3235
     3236AC_DEFUN([SC_CONFIG_COMMANDS_PRE], [
     3237    define([SC_OUTPUT_COMMANDS_PRE], defn([SC_OUTPUT_COMMANDS_PRE])[$1
     3238])])
     3239AC_DEFUN([SC_OUTPUT_COMMANDS_PRE])
     3240
Note: See TracChangeset for help on using the changeset viewer.