source: trunk/src/tcl/tclconfig/tcl.m4 @ 618

Last change on this file since 618 was 618, checked in by nkissebe, 17 years ago

Update tclconfig files to TEA 3.5, with Windows support

File size: 121.2 KB
Line 
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
14AC_PREREQ(2.50)
15
16dnl TEA extensions pass this us the version of TEA they think they
17dnl are compatible with (must be set in TEA_INIT below)
18dnl TEA_VERSION="3.5"
19
20# Possible values for key variables defined:
21#
22# TEA_WINDOWINGSYSTEM - win32 aqua x11 (mirrors 'tk windowingsystem')
23# TEA_PLATFORM        - windows unix
24#
25
26#------------------------------------------------------------------------
27# TEA_PATH_TCLCONFIG --
28#
29#       Locate the tclConfig.sh file and perform a sanity check on
30#       the Tcl compile flags
31#
32# Arguments:
33#       none
34#
35# Results:
36#
37#       Adds the following arguments to configure:
38#               --with-tcl=...
39#
40#       Defines the following vars:
41#               TCL_BIN_DIR     Full path to the directory containing
42#                               the tclConfig.sh file
43#------------------------------------------------------------------------
44
45AC_DEFUN([TEA_PATH_TCLCONFIG], [
46    dnl Make sure we are initialized
47    AC_REQUIRE([TEA_INIT])
48    #
49    # Ok, lets find the tcl configuration
50    # First, look for one uninstalled.
51    # the alternative search directory is invoked by --with-tcl
52    #
53
54    if test x"${no_tcl}" = x ; then
55        # we reset no_tcl in case something fails here
56        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})
61        AC_MSG_CHECKING([for Tcl configuration])
62        AC_CACHE_VAL(ac_cv_c_tclconfig,[
63
64            # First check to see if --with-tcl was specified.
65            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
73                if test -f "${with_tclconfig}/tclConfig.sh" ; then
74                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
75                else
76                    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
77                fi
78            fi
79
80            # then check for a private Tcl installation
81            if test x"${ac_cv_c_tclconfig}" = x ; then
82                for i in \
83                        ../tcl \
84                        `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
85                        `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
86                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
87                        ../../tcl \
88                        `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
89                        `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
90                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
91                        ../../../tcl \
92                        `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
93                        `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
94                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
95                    if test -f "$i/unix/tclConfig.sh" ; then
96                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
97                        break
98                    fi
99                done
100            fi
101
102            # on Darwin, check in Framework installation locations
103            if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
104                for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
105                        `ls -d /Library/Frameworks 2>/dev/null` \
106                        `ls -d /Network/Library/Frameworks 2>/dev/null` \
107                        `ls -d /System/Library/Frameworks 2>/dev/null` \
108                        ; do
109                    if test -f "$i/Tcl.framework/tclConfig.sh" ; then
110                        ac_cv_c_tclconfig=`(cd $i/Tcl.framework; pwd)`
111                        break
112                    fi
113                done
114            fi
115
116            # on Windows, check in common installation locations
117            if test "${TEA_PLATFORM}" = "windows" \
118                -a x"${ac_cv_c_tclconfig}" = x ; then
119                for i in `ls -d C:/Tcl/lib 2>/dev/null` \
120                        `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
121                        ; do
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
129            # check in a few common install locations
130            if test x"${ac_cv_c_tclconfig}" = x ; then
131                for i in `ls -d ${libdir} 2>/dev/null` \
132                        `ls -d ${exec_prefix}/lib 2>/dev/null` \
133                        `ls -d ${prefix}/lib 2>/dev/null` \
134                        `ls -d /usr/local/lib 2>/dev/null` \
135                        `ls -d /usr/contrib/lib 2>/dev/null` \
136                        `ls -d /usr/lib 2>/dev/null` \
137                        ; do
138                    if test -f "$i/tclConfig.sh" ; then
139                        ac_cv_c_tclconfig=`(cd $i; pwd)`
140                        break
141                    fi
142                done
143            fi
144
145            # check in a few other private locations
146            if test x"${ac_cv_c_tclconfig}" = x ; then
147                for i in \
148                        ${srcdir}/../tcl \
149                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
150                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
151                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
152                    if test -f "$i/unix/tclConfig.sh" ; then
153                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
154                    break
155                fi
156                done
157            fi
158        ])
159
160        if test x"${ac_cv_c_tclconfig}" = x ; then
161            TCL_BIN_DIR="# no Tcl configs found"
162            AC_MSG_WARN([Can't find Tcl configuration definitions])
163            exit 0
164        else
165            no_tcl=
166            TCL_BIN_DIR=${ac_cv_c_tclconfig}
167            AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
168        fi
169    fi
170])
171
172#------------------------------------------------------------------------
173# TEA_PATH_TKCONFIG --
174#
175#       Locate the tkConfig.sh file
176#
177# Arguments:
178#       none
179#
180# Results:
181#
182#       Adds the following arguments to configure:
183#               --with-tk=...
184#
185#       Defines the following vars:
186#               TK_BIN_DIR      Full path to the directory containing
187#                               the tkConfig.sh file
188#------------------------------------------------------------------------
189
190AC_DEFUN([TEA_PATH_TKCONFIG], [
191    #
192    # Ok, lets find the tk configuration
193    # First, look for one uninstalled.
194    # the alternative search directory is invoked by --with-tk
195    #
196
197    if test x"${no_tk}" = x ; then
198        # we reset no_tk in case something fails here
199        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})
204        AC_MSG_CHECKING([for Tk configuration])
205        AC_CACHE_VAL(ac_cv_c_tkconfig,[
206
207            # First check to see if --with-tkconfig was specified.
208            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
216                if test -f "${with_tkconfig}/tkConfig.sh" ; then
217                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
218                else
219                    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
220                fi
221            fi
222
223            # then check for a private Tk library
224            if test x"${ac_cv_c_tkconfig}" = x ; then
225                for i in \
226                        ../tk \
227                        `ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
228                        `ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
229                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
230                        ../../tk \
231                        `ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
232                        `ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
233                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
234                        ../../../tk \
235                        `ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
236                        `ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
237                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
238                    if test -f "$i/unix/tkConfig.sh" ; then
239                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
240                        break
241                    fi
242                done
243            fi
244
245            # on Darwin, check in Framework installation locations
246            if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then
247                for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
248                        `ls -d /Library/Frameworks 2>/dev/null` \
249                        `ls -d /Network/Library/Frameworks 2>/dev/null` \
250                        `ls -d /System/Library/Frameworks 2>/dev/null` \
251                        ; do
252                    if test -f "$i/Tk.framework/tkConfig.sh" ; then
253                        ac_cv_c_tkconfig=`(cd $i/Tk.framework; pwd)`
254                        break
255                    fi
256                done
257            fi
258
259            # check in a few common install locations
260            if test x"${ac_cv_c_tkconfig}" = x ; then
261                for i in `ls -d ${libdir} 2>/dev/null` \
262                        `ls -d ${exec_prefix}/lib 2>/dev/null` \
263                        `ls -d ${prefix}/lib 2>/dev/null` \
264                        `ls -d /usr/local/lib 2>/dev/null` \
265                        `ls -d /usr/contrib/lib 2>/dev/null` \
266                        `ls -d /usr/lib 2>/dev/null` \
267                        ; do
268                    if test -f "$i/tkConfig.sh" ; then
269                        ac_cv_c_tkconfig=`(cd $i; pwd)`
270                        break
271                    fi
272                done
273            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
288            # check in a few other private locations
289            if test x"${ac_cv_c_tkconfig}" = x ; then
290                for i in \
291                        ${srcdir}/../tk \
292                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
293                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
294                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
295                    if test -f "$i/unix/tkConfig.sh" ; then
296                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
297                        break
298                    fi
299                done
300            fi
301        ])
302
303        if test x"${ac_cv_c_tkconfig}" = x ; then
304            TK_BIN_DIR="# no Tk configs found"
305            AC_MSG_WARN([Can't find Tk configuration definitions])
306            exit 0
307        else
308            no_tk=
309            TK_BIN_DIR=${ac_cv_c_tkconfig}
310            AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
311        fi
312    fi
313])
314
315#------------------------------------------------------------------------
316# TEA_LOAD_TCLCONFIG --
317#
318#       Load the tclConfig.sh file
319#
320# Arguments:
321#       
322#       Requires the following vars to be set:
323#               TCL_BIN_DIR
324#
325# Results:
326#
327#       Subst the following vars:
328#               TCL_BIN_DIR
329#               TCL_SRC_DIR
330#               TCL_LIB_FILE
331#
332#------------------------------------------------------------------------
333
334AC_DEFUN([TEA_LOAD_TCLCONFIG], [
335    AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
336
337    if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
338        AC_MSG_RESULT([loading])
339        . ${TCL_BIN_DIR}/tclConfig.sh
340    else
341        AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
342    fi
343
344    # eval is required to do the TCL_DBGX substitution
345    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
346    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
347
348    # If the TCL_BIN_DIR is the build directory (not the install directory),
349    # then set the common variable name to the value of the build variables.
350    # For example, the variable TCL_LIB_SPEC will be set to the value
351    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
352    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
353    # installed and uninstalled version of Tcl.
354    if test -f ${TCL_BIN_DIR}/Makefile ; then
355        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
356        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
357        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
358    elif test "`uname -s`" = "Darwin"; then
359        # If Tcl was built as a framework, attempt to use the libraries
360        # from the framework at the given location so that linking works
361        # against Tcl.framework installed in an arbitary location.
362        case ${TCL_DEFS} in
363            *TCL_FRAMEWORK*)
364                if test -f ${TCL_BIN_DIR}/${TCL_LIB_FILE}; then
365                    for i in "`cd ${TCL_BIN_DIR}; pwd`" \
366                             "`cd ${TCL_BIN_DIR}/../..; pwd`"; do
367                        if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
368                            TCL_LIB_SPEC="-F`dirname "$i"` -framework ${TCL_LIB_FILE}"
369                            break
370                        fi
371                    done
372                fi
373                if test -f ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}; then
374                    TCL_STUB_LIB_SPEC="-L${TCL_BIN_DIR} ${TCL_STUB_LIB_FLAG}"
375                    TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
376                fi
377                ;;
378        esac
379    fi
380
381    # eval is required to do the TCL_DBGX substitution
382    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
383    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
384    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
385    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
386
387    AC_SUBST(TCL_VERSION)
388    AC_SUBST(TCL_BIN_DIR)
389    AC_SUBST(TCL_SRC_DIR)
390
391    AC_SUBST(TCL_LIB_FILE)
392    AC_SUBST(TCL_LIB_FLAG)
393    AC_SUBST(TCL_LIB_SPEC)
394
395    AC_SUBST(TCL_STUB_LIB_FILE)
396    AC_SUBST(TCL_STUB_LIB_FLAG)
397    AC_SUBST(TCL_STUB_LIB_SPEC)
398
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)
404])
405
406#------------------------------------------------------------------------
407# TEA_LOAD_TKCONFIG --
408#
409#       Load the tkConfig.sh file
410#
411# Arguments:
412#       
413#       Requires the following vars to be set:
414#               TK_BIN_DIR
415#
416# Results:
417#
418#       Sets the following vars that should be in tkConfig.sh:
419#               TK_BIN_DIR
420#------------------------------------------------------------------------
421
422AC_DEFUN([TEA_LOAD_TKCONFIG], [
423    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
424
425    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
426        AC_MSG_RESULT([loading])
427        . ${TK_BIN_DIR}/tkConfig.sh
428    else
429        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
430    fi
431
432    # eval is required to do the TK_DBGX substitution
433    eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
434    eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
435
436    # If the TK_BIN_DIR is the build directory (not the install directory),
437    # then set the common variable name to the value of the build variables.
438    # For example, the variable TK_LIB_SPEC will be set to the value
439    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
440    # instead of TK_BUILD_LIB_SPEC since it will work with both an
441    # installed and uninstalled version of Tcl.
442    if test -f ${TK_BIN_DIR}/Makefile ; then
443        TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
444        TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
445        TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
446    elif test "`uname -s`" = "Darwin"; then
447        # If Tk was built as a framework, attempt to use the libraries
448        # from the framework at the given location so that linking works
449        # against Tk.framework installed in an arbitary location.
450        case ${TK_DEFS} in
451            *TK_FRAMEWORK*)
452                if test -f ${TK_BIN_DIR}/${TK_LIB_FILE}; then
453                    for i in "`cd ${TK_BIN_DIR}; pwd`" \
454                             "`cd ${TK_BIN_DIR}/../..; pwd`"; do
455                        if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
456                            TK_LIB_SPEC="-F`dirname "$i"` -framework ${TK_LIB_FILE}"
457                            break
458                        fi
459                    done
460                fi
461                if test -f ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}; then
462                    TK_STUB_LIB_SPEC="-L${TK_BIN_DIR} ${TK_STUB_LIB_FLAG}"
463                    TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
464                fi
465                ;;
466        esac
467    fi
468
469    # eval is required to do the TK_DBGX substitution
470    eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
471    eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
472    eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
473    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
474
475    # Ensure windowingsystem is defined
476    if test "${TEA_PLATFORM}" = "unix" ; then
477        case ${TK_DEFS} in
478            *MAC_OSX_TK*)
479                AC_DEFINE(MAC_OSX_TK, 1, [Are we building against Mac OS X TkAqua?])
480                TEA_WINDOWINGSYSTEM="aqua"
481                ;;
482            *)
483                TEA_WINDOWINGSYSTEM="x11"
484                ;;
485        esac
486    elif test "${TEA_PLATFORM}" = "windows" ; then
487        TEA_WINDOWINGSYSTEM="win32"
488    fi
489
490    AC_SUBST(TK_VERSION)
491    AC_SUBST(TK_BIN_DIR)
492    AC_SUBST(TK_SRC_DIR)
493
494    AC_SUBST(TK_LIB_FILE)
495    AC_SUBST(TK_LIB_FLAG)
496    AC_SUBST(TK_LIB_SPEC)
497
498    AC_SUBST(TK_STUB_LIB_FILE)
499    AC_SUBST(TK_STUB_LIB_FLAG)
500    AC_SUBST(TK_STUB_LIB_SPEC)
501
502    AC_SUBST(TK_LIBS)
503    AC_SUBST(TK_XINCLUDES)
504])
505
506#------------------------------------------------------------------------
507# TEA_ENABLE_SHARED --
508#
509#       Allows the building of shared libraries
510#
511# Arguments:
512#       none
513#       
514# Results:
515#
516#       Adds the following arguments to configure:
517#               --enable-shared=yes|no
518#
519#       Defines the following vars:
520#               STATIC_BUILD    Used for building import/export libraries
521#                               on Windows.
522#
523#       Sets the following vars:
524#               SHARED_BUILD    Value of 1 or 0
525#------------------------------------------------------------------------
526
527AC_DEFUN([TEA_ENABLE_SHARED], [
528    AC_MSG_CHECKING([how to build libraries])
529    AC_ARG_ENABLE(shared,
530        AC_HELP_STRING([--enable-shared],
531            [build and link with shared libraries (default: on)]),
532        [tcl_ok=$enableval], [tcl_ok=yes])
533
534    if test "${enable_shared+set}" = set; then
535        enableval="$enable_shared"
536        tcl_ok=$enableval
537    else
538        tcl_ok=yes
539    fi
540
541    if test "$tcl_ok" = "yes" ; then
542        AC_MSG_RESULT([shared])
543        SHARED_BUILD=1
544    else
545        AC_MSG_RESULT([static])
546        SHARED_BUILD=0
547        AC_DEFINE(STATIC_BUILD, 1, [Is this a static build?])
548    fi
549    AC_SUBST(SHARED_BUILD)
550])
551
552#------------------------------------------------------------------------
553# TEA_ENABLE_THREADS --
554#
555#       Specify if thread support should be enabled.  If "yes" is specified
556#       as an arg (optional), threads are enabled by default, "no" means
557#       threads are disabled.  "yes" is the default.
558#
559#       TCL_THREADS is checked so that if you are compiling an extension
560#       against a threaded core, your extension must be compiled threaded
561#       as well.
562#
563#       Note that it is legal to have a thread enabled extension run in a
564#       threaded or non-threaded Tcl core, but a non-threaded extension may
565#       only run in a non-threaded Tcl core.
566#
567# Arguments:
568#       none
569#       
570# Results:
571#
572#       Adds the following arguments to configure:
573#               --enable-threads
574#
575#       Sets the following vars:
576#               THREADS_LIBS    Thread library(s)
577#
578#       Defines the following vars:
579#               TCL_THREADS
580#               _REENTRANT
581#               _THREAD_SAFE
582#
583#------------------------------------------------------------------------
584
585AC_DEFUN([TEA_ENABLE_THREADS], [
586    AC_ARG_ENABLE(threads,
587        AC_HELP_STRING([--enable-threads],
588            [build with threads]),
589        [tcl_ok=$enableval], [tcl_ok=yes])
590
591    if test "${enable_threads+set}" = set; then
592        enableval="$enable_threads"
593        tcl_ok=$enableval
594    else
595        tcl_ok=yes
596    fi
597
598    if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
599        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
625            if test "$tcl_ok" = "yes"; then
626                # The space is needed
627                THREADS_LIBS=" -lpthread"
628            else
629                AC_CHECK_LIB(pthreads, pthread_mutex_init,
630                    tcl_ok=yes, tcl_ok=no)
631                if test "$tcl_ok" = "yes"; then
632                    # The space is needed
633                    THREADS_LIBS=" -lpthreads"
634                else
635                    AC_CHECK_LIB(c, pthread_mutex_init,
636                        tcl_ok=yes, tcl_ok=no)
637                    if test "$tcl_ok" = "no"; then
638                        AC_CHECK_LIB(c_r, pthread_mutex_init,
639                            tcl_ok=yes, tcl_ok=no)
640                        if test "$tcl_ok" = "yes"; then
641                            # The space is needed
642                            THREADS_LIBS=" -pthread"
643                        else
644                            TCL_THREADS=0
645                            AC_MSG_WARN([Do not know how to find pthread lib on your system - thread support disabled])
646                        fi
647                    fi
648                fi
649            fi
650        fi
651    else
652        TCL_THREADS=0
653    fi
654    # Do checking message here to not mess up interleaved configure output
655    AC_MSG_CHECKING([for building with threads])
656    if test "${TCL_THREADS}" = 1; then
657        AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
658        AC_MSG_RESULT([yes (default)])
659    else
660        AC_MSG_RESULT([no])
661    fi
662    # TCL_THREADS sanity checking.  See if our request for building with
663    # threads is the same as the way Tcl was built.  If not, warn the user.
664    case ${TCL_DEFS} in
665        *THREADS=1*)
666            if test "${TCL_THREADS}" = "0"; then
667                AC_MSG_WARN([
668    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
669    that IS thread-enabled.  It is recommended to use --enable-threads.])
670            fi
671            ;;
672        *)
673            if test "${TCL_THREADS}" = "1"; then
674                AC_MSG_WARN([
675    --enable-threads requested, but building against a Tcl that is NOT
676    thread-enabled.  This is an OK configuration that will also run in
677    a thread-enabled core.])
678            fi
679            ;;
680    esac
681    AC_SUBST(TCL_THREADS)
682])
683
684#------------------------------------------------------------------------
685# TEA_ENABLE_SYMBOLS --
686#
687#       Specify if debugging symbols should be used.
688#       Memory (TCL_MEM_DEBUG) debugging can also be enabled.
689#
690# Arguments:
691#       none
692#       
693#       TEA varies from core Tcl in that C|LDFLAGS_DEFAULT receives
694#       the value of C|LDFLAGS_OPTIMIZE|DEBUG already substituted.
695#       Requires the following vars to be set in the Makefile:
696#               CFLAGS_DEFAULT
697#               LDFLAGS_DEFAULT
698#       
699# Results:
700#
701#       Adds the following arguments to configure:
702#               --enable-symbols
703#
704#       Defines the following vars:
705#               CFLAGS_DEFAULT  Sets to $(CFLAGS_DEBUG) if true
706#                               Sets to $(CFLAGS_OPTIMIZE) if false
707#               LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
708#                               Sets to $(LDFLAGS_OPTIMIZE) if false
709#               DBGX            Formerly used as debug library extension;
710#                               always blank now.
711#
712#------------------------------------------------------------------------
713
714AC_DEFUN([TEA_ENABLE_SYMBOLS], [
715    dnl Make sure we are initialized
716    AC_REQUIRE([TEA_CONFIG_CFLAGS])
717    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=""
723    if test "$tcl_ok" = "no"; then
724        CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
725        LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
726        AC_MSG_RESULT([no])
727    else
728        CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
729        LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
730        if test "$tcl_ok" = "yes"; then
731            AC_MSG_RESULT([yes (standard debugging)])
732        fi
733    fi
734    if test "${TEA_PLATFORM}" != "windows" ; then
735        LDFLAGS_DEFAULT="${LDFLAGS}"
736    fi
737
738    AC_SUBST(TCL_DBGX)
739    AC_SUBST(CFLAGS_DEFAULT)
740    AC_SUBST(LDFLAGS_DEFAULT)
741
742    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
743        AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?])
744    fi
745
746    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
747        if test "$tcl_ok" = "all"; then
748            AC_MSG_RESULT([enabled symbols mem debugging])
749        else
750            AC_MSG_RESULT([enabled $tcl_ok debugging])
751        fi
752    fi
753])
754
755#------------------------------------------------------------------------
756# TEA_ENABLE_LANGINFO --
757#
758#       Allows use of modern nl_langinfo check for better l10n.
759#       This is only relevant for Unix.
760#
761# Arguments:
762#       none
763#       
764# Results:
765#
766#       Adds the following arguments to configure:
767#               --enable-langinfo=yes|no (default is yes)
768#
769#       Defines the following vars:
770#               HAVE_LANGINFO   Triggers use of nl_langinfo if defined.
771#
772#------------------------------------------------------------------------
773
774AC_DEFUN([TEA_ENABLE_LANGINFO], [
775    AC_ARG_ENABLE(langinfo,
776        AC_HELP_STRING([--enable-langinfo],
777            [use nl_langinfo if possible to determine encoding at startup, otherwise use old heuristic (default: on)]),
778        [langinfo_ok=$enableval], [langinfo_ok=yes])
779
780    HAVE_LANGINFO=0
781    if test "$langinfo_ok" = "yes"; then
782        AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
783    fi
784    AC_MSG_CHECKING([whether to use nl_langinfo])
785    if test "$langinfo_ok" = "yes"; then
786        AC_CACHE_VAL(tcl_cv_langinfo_h,
787            AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
788                    [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no]))
789        AC_MSG_RESULT([$tcl_cv_langinfo_h])
790        if test $tcl_cv_langinfo_h = yes; then
791            AC_DEFINE(HAVE_LANGINFO, 1, [Do we have nl_langinfo()?])
792        fi
793    else
794        AC_MSG_RESULT([$langinfo_ok])
795    fi
796])
797
798#--------------------------------------------------------------------
799# TEA_CONFIG_SYSTEM
800#
801#       Determine what the system is (some things cannot be easily checked
802#       on a feature-driven basis, alas). This can usually be done via the
803#       "uname" command, but there are a few systems, like Next, where
804#       this doesn't work.
805#
806# Arguments:
807#       none
808#
809# Results:
810#       Defines the following var:
811#
812#       system -        System/platform/version identification code.
813#
814#--------------------------------------------------------------------
815
816AC_DEFUN([TEA_CONFIG_SYSTEM], [
817    AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
818        if test "${TEA_PLATFORM}" = "windows" ; then
819            tcl_cv_sys_version=windows
820        elif test -f /usr/lib/NextStep/software_version; then
821            tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
822        else
823            tcl_cv_sys_version=`uname -s`-`uname -r`
824            if test "$?" -ne 0 ; then
825                AC_MSG_WARN([can't find uname command])
826                tcl_cv_sys_version=unknown
827            else
828                # Special check for weird MP-RAS system (uname returns weird
829                # results, and the version is kept in special file).
830
831                if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
832                    tcl_cv_sys_version=MP-RAS-`awk '{print [$]3}' /etc/.relid`
833                fi
834                if test "`uname -s`" = "AIX" ; then
835                    tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
836                fi
837            fi
838        fi
839    ])
840    system=$tcl_cv_sys_version
841])
842
843#--------------------------------------------------------------------
844# TEA_CONFIG_CFLAGS
845#
846#       Try to determine the proper flags to pass to the compiler
847#       for building shared libraries and other such nonsense.
848#
849# Arguments:
850#       none
851#
852# Results:
853#
854#       Defines and substitutes the following vars:
855#
856#       DL_OBJS -       Name of the object file that implements dynamic
857#                       loading for Tcl on this system.
858#       DL_LIBS -       Library file(s) to include in tclsh and other base
859#                       applications in order for the "load" command to work.
860#       LDFLAGS -      Flags to pass to the compiler when linking object
861#                       files into an executable application binary such
862#                       as tclsh.
863#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
864#                       that tell the run-time dynamic linker where to look
865#                       for shared libraries such as libtcl.so.  Depends on
866#                       the variable LIB_RUNTIME_DIR in the Makefile. Could
867#                       be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
868#       CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
869#                       that tell the run-time dynamic linker where to look
870#                       for shared libraries such as libtcl.so.  Depends on
871#                       the variable LIB_RUNTIME_DIR in the Makefile.
872#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
873#                       of a shared library (may request position-independent
874#                       code, among other things).
875#       SHLIB_LD -      Base command to use for combining object files
876#                       into a shared library.
877#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
878#                       creating shared libraries.  This symbol typically
879#                       goes at the end of the "ld" commands that build
880#                       shared libraries. The value of the symbol is
881#                       "${LIBS}" if all of the dependent libraries should
882#                       be specified when creating a shared library.  If
883#                       dependent libraries should not be specified (as on
884#                       SunOS 4.x, where they cause the link to fail, or in
885#                       general if Tcl and Tk aren't themselves shared
886#                       libraries), then this symbol has an empty string
887#                       as its value.
888#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
889#                       extensions.  An empty string means we don't know how
890#                       to use shared libraries on this platform.
891#       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
892#                       in a static or shared library name, using the $VERSION variable
893#                       to put the version in the right place.  This is used
894#                       by platforms that need non-standard library names.
895#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
896#                       to have a version after the .so, and ${VERSION}.a
897#                       on AIX, since a shared library needs to have
898#                       a .a extension whereas shared objects for loadable
899#                       extensions have a .so extension.  Defaults to
900#                       ${VERSION}${SHLIB_SUFFIX}.
901#       TCL_NEEDS_EXP_FILE -
902#                       1 means that an export file is needed to link to a
903#                       shared library.
904#       TCL_EXP_FILE -  The name of the installed export / import file which
905#                       should be used to link to the Tcl shared library.
906#                       Empty if Tcl is unshared.
907#       TCL_BUILD_EXP_FILE -
908#                       The name of the built export / import file which
909#                       should be used to link to the Tcl shared library.
910#                       Empty if Tcl is unshared.
911#       CFLAGS_DEBUG -
912#                       Flags used when running the compiler in debug mode
913#       CFLAGS_OPTIMIZE -
914#                       Flags used when running the compiler in optimize mode
915#       CFLAGS -        Additional CFLAGS added as necessary (usually 64-bit)
916#
917#--------------------------------------------------------------------
918
919AC_DEFUN([TEA_CONFIG_CFLAGS], [
920    dnl Make sure we are initialized
921    AC_REQUIRE([TEA_INIT])
922
923    # Step 0.a: Enable 64 bit support?
924
925    AC_MSG_CHECKING([if 64bit support is requested])
926    AC_ARG_ENABLE(64bit,
927        AC_HELP_STRING([--enable-64bit],
928            [enable 64bit support (default: off)]),
929        [do64bit=$enableval], [do64bit=no])
930    AC_MSG_RESULT([$do64bit])
931
932    # Step 0.b: Enable Solaris 64 bit VIS support?
933
934    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
935    AC_ARG_ENABLE(64bit-vis,
936        AC_HELP_STRING([--enable-64bit-vis],
937            [enable 64bit Sparc VIS support (default: off)]),
938        [do64bitVIS=$enableval], [do64bitVIS=no])
939    AC_MSG_RESULT([$do64bitVIS])
940
941    if test "$do64bitVIS" = "yes"; then
942        # Force 64bit on with VIS
943        do64bit=yes
944    fi
945
946    # Step 0.c: Cross-compiling options for Windows/CE builds?
947
948    if test "${TEA_PLATFORM}" = "windows" ; then
949        AC_MSG_CHECKING([if Windows/CE build is requested])
950        AC_ARG_ENABLE(wince,[  --enable-wince          enable Win/CE support (where applicable)], [doWince=$enableval], [doWince=no])
951        AC_MSG_RESULT([$doWince])
952    fi
953
954    # Step 1: set the variable "system" to hold the name and version number
955    # for the system.
956
957    TEA_CONFIG_SYSTEM
958
959    # Step 2: check for existence of -ldl library.  This is needed because
960    # Linux can use either -ldl or -ldld for dynamic loading.
961
962    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
963
964    # Require ranlib early so we can override it in special cases below.
965
966    AC_REQUIRE([AC_PROG_RANLIB])
967
968    # 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.
971
972    do64bit_ok=no
973    LDFLAGS_ORIG="$LDFLAGS"
974    # When ld needs options to work in 64-bit mode, put them in
975    # LDFLAGS_ARCH so they eventually end up in LDFLAGS even if [load]
976    # is disabled by the user. [Bug 1016796]
977    LDFLAGS_ARCH=""
978    TCL_EXPORT_FILE_SUFFIX=""
979    UNSHARED_LIB_SUFFIX=""
980    TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`'
981    ECHO_VERSION='`echo ${PACKAGE_VERSION}`'
982    TCL_LIB_VERSIONS_OK=ok
983    CFLAGS_DEBUG=-g
984    CFLAGS_OPTIMIZE=-O
985    if test "$GCC" = "yes" ; then
986        CFLAGS_OPTIMIZE=-O2
987        CFLAGS_WARNING="-Wall -Wno-implicit-int"
988    else
989        CFLAGS_WARNING=""
990    fi
991    TCL_NEEDS_EXP_FILE=0
992    TCL_BUILD_EXP_FILE=""
993    TCL_EXP_FILE=""
994dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
995dnl AC_CHECK_TOOL(AR, ar)
996    AC_CHECK_PROG(AR, ar, ar)
997    STLIB_LD='${AR} cr'
998    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
999    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            ;;
1183        AIX-*)
1184            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
1185                # AIX requires the _r compiler when gcc isn't being used
1186                case "${CC}" in
1187                    *_r)
1188                        # ok ...
1189                        ;;
1190                    *)
1191                        CC=${CC}_r
1192                        ;;
1193                esac
1194                AC_MSG_RESULT([Using $CC for compiling with threads])
1195            fi
1196            LIBS="$LIBS -lc"
1197            SHLIB_CFLAGS=""
1198            SHLIB_LD_LIBS='${LIBS}'
1199            SHLIB_SUFFIX=".so"
1200
1201            DL_OBJS="tclLoadDl.o"
1202            LD_LIBRARY_PATH_VAR="LIBPATH"
1203
1204            # Check to enable 64-bit flags for compiler/linker on AIX 4+
1205            if test "$do64bit" = "yes" -a "`uname -v`" -gt "3" ; then
1206                if test "$GCC" = "yes" ; then
1207                    AC_MSG_WARN([64bit mode not supported with GCC on $system])
1208                else
1209                    do64bit_ok=yes
1210                    CFLAGS="$CFLAGS -q64"
1211                    LDFLAGS_ARCH="-q64"
1212                    RANLIB="${RANLIB} -X64"
1213                    AR="${AR} -X64"
1214                    SHLIB_LD_FLAGS="-b64"
1215                fi
1216            fi
1217
1218            if test "`uname -m`" = "ia64" ; then
1219                # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
1220                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1221                # AIX-5 has dl* in libc.so
1222                DL_LIBS=""
1223                if test "$GCC" = "yes" ; then
1224                    CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1225                else
1226                    CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
1227                fi
1228                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1229            else
1230                if test "$GCC" = "yes" ; then
1231                    SHLIB_LD="gcc -shared"
1232                else
1233                    SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
1234                fi
1235                SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix ${SHLIB_LD} ${SHLIB_LD_FLAGS}"
1236                DL_LIBS="-ldl"
1237                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1238                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1239                TCL_NEEDS_EXP_FILE=1
1240                TCL_EXPORT_FILE_SUFFIX='${PACKAGE_VERSION}.exp'
1241            fi
1242
1243            # AIX v<=4.1 has some different flags than 4.2+
1244            if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
1245                AC_LIBOBJ([tclLoadAix])
1246                DL_LIBS="-lld"
1247            fi
1248
1249            # On AIX <=v4 systems, libbsd.a has to be linked in to support
1250            # non-blocking file IO.  This library has to be linked in after
1251            # the MATH_LIBS or it breaks the pow() function.  The way to
1252            # insure proper sequencing, is to add it to the tail of MATH_LIBS.
1253            # This library also supplies gettimeofday.
1254            #
1255            # AIX does not have a timezone field in struct tm. When the AIX
1256            # bsd library is used, the timezone global and the gettimeofday
1257            # methods are to be avoided for timezone deduction instead, we
1258            # deduce the timezone by comparing the localtime result on a
1259            # known GMT value.
1260
1261            AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
1262            if test $libbsd = yes; then
1263                MATH_LIBS="$MATH_LIBS -lbsd"
1264                AC_DEFINE(USE_DELTA_FOR_TZ, 1, [Do we need a special AIX hack for timezones?])
1265            fi
1266            ;;
1267        BeOS*)
1268            SHLIB_CFLAGS="-fPIC"
1269            SHLIB_LD="${CC} -nostart"
1270            SHLIB_LD_LIBS='${LIBS}'
1271            SHLIB_SUFFIX=".so"
1272            DL_OBJS="tclLoadDl.o"
1273            DL_LIBS="-ldl"
1274
1275            #-----------------------------------------------------------
1276            # Check for inet_ntoa in -lbind, for BeOS (which also needs
1277            # -lsocket, even if the network functions are in -lnet which
1278            # is always linked to, for compatibility.
1279            #-----------------------------------------------------------
1280            AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"])
1281            ;;
1282        BSD/OS-2.1*|BSD/OS-3*)
1283            SHLIB_CFLAGS=""
1284            SHLIB_LD="shlicc -r"
1285            SHLIB_LD_LIBS='${LIBS}'
1286            SHLIB_SUFFIX=".so"
1287            DL_OBJS="tclLoadDl.o"
1288            DL_LIBS="-ldl"
1289            CC_SEARCH_FLAGS=""
1290            LD_SEARCH_FLAGS=""
1291            ;;
1292        BSD/OS-4.*)
1293            SHLIB_CFLAGS="-export-dynamic -fPIC"
1294            SHLIB_LD="cc -shared"
1295            SHLIB_LD_LIBS='${LIBS}'
1296            SHLIB_SUFFIX=".so"
1297            DL_OBJS="tclLoadDl.o"
1298            DL_LIBS="-ldl"
1299            LDFLAGS="$LDFLAGS -export-dynamic"
1300            CC_SEARCH_FLAGS=""
1301            LD_SEARCH_FLAGS=""
1302            ;;
1303        dgux*)
1304            SHLIB_CFLAGS="-K PIC"
1305            SHLIB_LD="cc -G"
1306            SHLIB_LD_LIBS=""
1307            SHLIB_SUFFIX=".so"
1308            DL_OBJS="tclLoadDl.o"
1309            DL_LIBS="-ldl"
1310            CC_SEARCH_FLAGS=""
1311            LD_SEARCH_FLAGS=""
1312            ;;
1313        HP-UX-*.11.*)
1314            # Use updated header definitions where possible
1315            AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Do we want to use the XOPEN network library?])
1316            # Needed by Tcl, but not most extensions
1317            #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?])
1318            #LIBS="$LIBS -lxnet"               # Use the XOPEN network library
1319
1320            SHLIB_SUFFIX=".sl"
1321            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1322            if test "$tcl_ok" = yes; then
1323                SHLIB_CFLAGS="+z"
1324                SHLIB_LD="ld -b"
1325                SHLIB_LD_LIBS='${LIBS}'
1326                DL_OBJS="tclLoadShl.o"
1327                DL_LIBS="-ldld"
1328                LDFLAGS="$LDFLAGS -Wl,-E"
1329                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1330                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1331                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1332            fi
1333            if test "$GCC" = "yes" ; then
1334                SHLIB_LD="gcc -shared"
1335                SHLIB_LD_LIBS='${LIBS}'
1336                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1337            fi
1338
1339            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
1340            #CFLAGS="$CFLAGS +DAportable"
1341
1342            # Check to enable 64-bit flags for compiler/linker
1343            if test "$do64bit" = "yes" ; then
1344                if test "$GCC" = "yes" ; then
1345                    hpux_arch=`${CC} -dumpmachine`
1346                    case $hpux_arch in
1347                        hppa64*)
1348                            # 64-bit gcc in use.  Fix flags for GNU ld.
1349                            do64bit_ok=yes
1350                            SHLIB_LD="${CC} -shared"
1351                            SHLIB_LD_LIBS='${LIBS}'
1352                            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1353                            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1354                            ;;
1355                        *)
1356                            AC_MSG_WARN([64bit mode not supported with GCC on $system])
1357                            ;;
1358                    esac
1359                else
1360                    do64bit_ok=yes
1361                    CFLAGS="$CFLAGS +DD64"
1362                    LDFLAGS_ARCH="+DD64"
1363                fi
1364            fi
1365            ;;
1366        HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
1367            SHLIB_SUFFIX=".sl"
1368            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1369            if test "$tcl_ok" = yes; then
1370                SHLIB_CFLAGS="+z"
1371                SHLIB_LD="ld -b"
1372                SHLIB_LD_LIBS=""
1373                DL_OBJS="tclLoadShl.o"
1374                DL_LIBS="-ldld"
1375                LDFLAGS="$LDFLAGS -Wl,-E"
1376                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1377                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1378                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1379            fi
1380            ;;
1381        IRIX-5.*)
1382            SHLIB_CFLAGS=""
1383            SHLIB_LD="ld -shared -rdata_shared"
1384            SHLIB_LD_LIBS='${LIBS}'
1385            SHLIB_SUFFIX=".so"
1386            DL_OBJS="tclLoadDl.o"
1387            DL_LIBS=""
1388            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1389            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1390            ;;
1391        IRIX-6.*)
1392            SHLIB_CFLAGS=""
1393            SHLIB_LD="ld -n32 -shared -rdata_shared"
1394            SHLIB_LD_LIBS='${LIBS}'
1395            SHLIB_SUFFIX=".so"
1396            DL_OBJS="tclLoadDl.o"
1397            DL_LIBS=""
1398            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1399            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1400            if test "$GCC" = "yes" ; then
1401                CFLAGS="$CFLAGS -mabi=n32"
1402                LDFLAGS="$LDFLAGS -mabi=n32"
1403            else
1404                case $system in
1405                    IRIX-6.3)
1406                        # Use to build 6.2 compatible binaries on 6.3.
1407                        CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS"
1408                        ;;
1409                    *)
1410                        CFLAGS="$CFLAGS -n32"
1411                        ;;
1412                esac
1413                LDFLAGS="$LDFLAGS -n32"
1414            fi
1415            ;;
1416        IRIX64-6.*)
1417            SHLIB_CFLAGS=""
1418            SHLIB_LD="ld -n32 -shared -rdata_shared"
1419            SHLIB_LD_LIBS='${LIBS}'
1420            SHLIB_SUFFIX=".so"
1421            DL_OBJS="tclLoadDl.o"
1422            DL_LIBS=""
1423            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1424            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1425
1426            # Check to enable 64-bit flags for compiler/linker
1427
1428            if test "$do64bit" = "yes" ; then
1429                if test "$GCC" = "yes" ; then
1430                    AC_MSG_WARN([64bit mode not supported by gcc])
1431                else
1432                    do64bit_ok=yes
1433                    SHLIB_LD="ld -64 -shared -rdata_shared"
1434                    CFLAGS="$CFLAGS -64"
1435                    LDFLAGS_ARCH="-64"
1436                fi
1437            fi
1438            ;;
1439        Linux*)
1440            SHLIB_CFLAGS="-fPIC"
1441            SHLIB_LD_LIBS='${LIBS}'
1442            SHLIB_SUFFIX=".so"
1443
1444            CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
1445            # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
1446            # when you inline the string and math operations.  Turn this off to
1447            # get rid of the warnings.
1448            #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
1449
1450            SHLIB_LD="${CC} -shared"
1451            DL_OBJS="tclLoadDl.o"
1452            DL_LIBS="-ldl"
1453            LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1454            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1455            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1456            if test "`uname -m`" = "alpha" ; then
1457                CFLAGS="$CFLAGS -mieee"
1458            fi
1459
1460            # The combo of gcc + glibc has a bug related
1461            # to inlining of functions like strtod(). The
1462            # -fno-builtin flag should address this problem
1463            # but it does not work. The -fno-inline flag
1464            # is kind of overkill but it works.
1465            # Disable inlining only when one of the
1466            # files in compat/*.c is being linked in.
1467            if test x"${USE_COMPAT}" != x ; then
1468                CFLAGS="$CFLAGS -fno-inline"
1469            fi
1470
1471            ;;
1472        GNU*)
1473            SHLIB_CFLAGS="-fPIC"
1474            SHLIB_LD_LIBS='${LIBS}'
1475            SHLIB_SUFFIX=".so"
1476
1477            SHLIB_LD="${CC} -shared"
1478            DL_OBJS=""
1479            DL_LIBS="-ldl"
1480            LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1481            CC_SEARCH_FLAGS=""
1482            LD_SEARCH_FLAGS=""
1483            if test "`uname -m`" = "alpha" ; then
1484                CFLAGS="$CFLAGS -mieee"
1485            fi
1486            ;;
1487        Lynx*)
1488            SHLIB_CFLAGS="-fPIC"
1489            SHLIB_LD_LIBS='${LIBS}'
1490            SHLIB_SUFFIX=".so"
1491            CFLAGS_OPTIMIZE=-02
1492            SHLIB_LD="${CC} -shared "
1493            DL_OBJS="tclLoadDl.o"
1494            DL_LIBS="-mshared -ldl"
1495            LD_FLAGS="-Wl,--export-dynamic"
1496            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1497            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1498            ;;
1499        MP-RAS-02*)
1500            SHLIB_CFLAGS="-K PIC"
1501            SHLIB_LD="cc -G"
1502            SHLIB_LD_LIBS=""
1503            SHLIB_SUFFIX=".so"
1504            DL_OBJS="tclLoadDl.o"
1505            DL_LIBS="-ldl"
1506            CC_SEARCH_FLAGS=""
1507            LD_SEARCH_FLAGS=""
1508            ;;
1509        MP-RAS-*)
1510            SHLIB_CFLAGS="-K PIC"
1511            SHLIB_LD="cc -G"
1512            SHLIB_LD_LIBS=""
1513            SHLIB_SUFFIX=".so"
1514            DL_OBJS="tclLoadDl.o"
1515            DL_LIBS="-ldl"
1516            LDFLAGS="$LDFLAGS -Wl,-Bexport"
1517            CC_SEARCH_FLAGS=""
1518            LD_SEARCH_FLAGS=""
1519            ;;
1520        NetBSD-*|FreeBSD-[[1-2]].*)
1521            # NetBSD/SPARC needs -fPIC, -fpic will not do.
1522            SHLIB_CFLAGS="-fPIC"
1523            SHLIB_LD="ld -Bshareable -x"
1524            SHLIB_LD_LIBS='${LIBS}'
1525            SHLIB_SUFFIX=".so"
1526            DL_OBJS="tclLoadDl.o"
1527            DL_LIBS=""
1528            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1529            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1530            AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
1531                AC_EGREP_CPP(yes, [
1532#ifdef __ELF__
1533        yes
1534#endif
1535                ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
1536            if test $tcl_cv_ld_elf = yes; then
1537                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
1538            else
1539                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.1.0'
1540            fi
1541
1542            # Ancient FreeBSD doesn't handle version numbers with dots.
1543
1544            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1545            TCL_LIB_VERSIONS_OK=nodots
1546            ;;
1547        OpenBSD-*)
1548            # OpenBSD/SPARC[64] needs -fPIC, -fpic will not do.
1549            case `machine` in
1550            sparc|sparc64)
1551                SHLIB_CFLAGS="-fPIC";;
1552            *)
1553                SHLIB_CFLAGS="-fpic";;
1554            esac
1555            SHLIB_LD="${CC} -shared ${SHLIB_CFLAGS}"
1556            SHLIB_LD_LIBS='${LIBS}'
1557            SHLIB_SUFFIX=".so"
1558            DL_OBJS="tclLoadDl.o"
1559            DL_LIBS=""
1560            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1561            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1562            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.1.0'
1563            AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
1564                AC_EGREP_CPP(yes, [
1565#ifdef __ELF__
1566        yes
1567#endif
1568                ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
1569            if test $tcl_cv_ld_elf = yes; then
1570                LDFLAGS=-Wl,-export-dynamic
1571            else
1572                LDFLAGS=""
1573            fi
1574
1575            # OpenBSD doesn't do version numbers with dots.
1576            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1577            TCL_LIB_VERSIONS_OK=nodots
1578            ;;
1579        FreeBSD-*)
1580            # FreeBSD 3.* and greater have ELF.
1581            SHLIB_CFLAGS="-fPIC"
1582            SHLIB_LD="ld -Bshareable -x"
1583            SHLIB_LD_LIBS='${LIBS}'
1584            SHLIB_SUFFIX=".so"
1585            DL_OBJS="tclLoadDl.o"
1586            DL_LIBS=""
1587            LDFLAGS="$LDFLAGS -export-dynamic"
1588            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1589            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1590            if test "${TCL_THREADS}" = "1" ; then
1591                # The -pthread needs to go in the CFLAGS, not LIBS
1592                LIBS=`echo $LIBS | sed s/-pthread//`
1593                CFLAGS="$CFLAGS -pthread"
1594                LDFLAGS="$LDFLAGS -pthread"
1595            fi
1596            case $system in
1597            FreeBSD-3.*)
1598                # FreeBSD-3 doesn't handle version numbers with dots.
1599                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1600                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
1601                TCL_LIB_VERSIONS_OK=nodots
1602                ;;
1603            esac
1604            ;;
1605        Darwin-*)
1606            CFLAGS_OPTIMIZE="-Os"
1607            SHLIB_CFLAGS="-fno-common"
1608            if test $do64bit = yes; then
1609                do64bit_ok=yes
1610                CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1611            fi
1612            # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS here:
1613            SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}'
1614            AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
1615                hold_ldflags=$LDFLAGS
1616                LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
1617                AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
1618                LDFLAGS=$hold_ldflags])
1619            if test $tcl_cv_ld_single_module = yes; then
1620                SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
1621            fi
1622            SHLIB_LD_LIBS='${LIBS}'
1623            SHLIB_SUFFIX=".dylib"
1624            DL_OBJS="tclLoadDyld.o"
1625            DL_LIBS=""
1626            # Don't use -prebind when building for Mac OS X 10.4 or later only:
1627            test -z "${MACOSX_DEPLOYMENT_TARGET}" || \
1628                test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F. '{print [$]2}'`" -lt 4 && \
1629                LDFLAGS="$LDFLAGS -prebind"
1630            LDFLAGS="$LDFLAGS -headerpad_max_install_names"
1631            AC_CACHE_CHECK([if ld accepts -search_paths_first flag], tcl_cv_ld_search_paths_first, [
1632                hold_ldflags=$LDFLAGS
1633                LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1634                AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, tcl_cv_ld_search_paths_first=no)
1635                LDFLAGS=$hold_ldflags])
1636            if test $tcl_cv_ld_search_paths_first = yes; then
1637                LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1638            fi
1639            CC_SEARCH_FLAGS=""
1640            LD_SEARCH_FLAGS=""
1641            LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
1642
1643            # TEA specific: for Tk extensions, remove -arch ppc64 from CFLAGS
1644            # for fat builds, as neither TkAqua nor TkX11 can be built for 64bit
1645            # at present (no 64bit GUI libraries).
1646            test $do64bit_ok = no && test -n "${TK_BIN_DIR}" && \
1647                CFLAGS="`echo "$CFLAGS" | sed -e 's/-arch ppc64/-arch ppc/g'`"
1648            ;;
1649        NEXTSTEP-*)
1650            SHLIB_CFLAGS=""
1651            SHLIB_LD="cc -nostdlib -r"
1652            SHLIB_LD_LIBS=""
1653            SHLIB_SUFFIX=".so"
1654            DL_OBJS="tclLoadNext.o"
1655            DL_LIBS=""
1656            CC_SEARCH_FLAGS=""
1657            LD_SEARCH_FLAGS=""
1658            ;;
1659        OS/390-*)
1660            CFLAGS_OPTIMIZE=""          # Optimizer is buggy
1661            AC_DEFINE(_OE_SOCKETS, 1,   # needed in sys/socket.h
1662                [Should OS/390 do the right thing with sockets?])
1663            ;;     
1664        OSF1-1.0|OSF1-1.1|OSF1-1.2)
1665            # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
1666            SHLIB_CFLAGS=""
1667            # Hack: make package name same as library name
1668            SHLIB_LD='ld -R -export $@:'
1669            SHLIB_LD_LIBS=""
1670            SHLIB_SUFFIX=".so"
1671            DL_OBJS="tclLoadOSF.o"
1672            DL_LIBS=""
1673            CC_SEARCH_FLAGS=""
1674            LD_SEARCH_FLAGS=""
1675            ;;
1676        OSF1-1.*)
1677            # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
1678            SHLIB_CFLAGS="-fPIC"
1679            if test "$SHARED_BUILD" = "1" ; then
1680                SHLIB_LD="ld -shared"
1681            else
1682                SHLIB_LD="ld -non_shared"
1683            fi
1684            SHLIB_LD_LIBS=""
1685            SHLIB_SUFFIX=".so"
1686            DL_OBJS="tclLoadDl.o"
1687            DL_LIBS=""
1688            CC_SEARCH_FLAGS=""
1689            LD_SEARCH_FLAGS=""
1690            ;;
1691        OSF1-V*)
1692            # Digital OSF/1
1693            SHLIB_CFLAGS=""
1694            if test "$SHARED_BUILD" = "1" ; then
1695                SHLIB_LD='ld -shared -expect_unresolved "*"'
1696            else
1697                SHLIB_LD='ld -non_shared -expect_unresolved "*"'
1698            fi
1699            SHLIB_LD_LIBS=""
1700            SHLIB_SUFFIX=".so"
1701            DL_OBJS="tclLoadDl.o"
1702            DL_LIBS=""
1703            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1704            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1705            if test "$GCC" = "yes" ; then
1706                CFLAGS="$CFLAGS -mieee"
1707            else
1708                CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"
1709            fi
1710            # see pthread_intro(3) for pthread support on osf1, k.furukawa
1711            if test "${TCL_THREADS}" = "1" ; then
1712                CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
1713                CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
1714                LIBS=`echo $LIBS | sed s/-lpthreads//`
1715                if test "$GCC" = "yes" ; then
1716                    LIBS="$LIBS -lpthread -lmach -lexc"
1717                else
1718                    CFLAGS="$CFLAGS -pthread"
1719                    LDFLAGS="$LDFLAGS -pthread"
1720                fi
1721            fi
1722
1723            ;;
1724        QNX-6*)
1725            # QNX RTP
1726            # This may work for all QNX, but it was only reported for v6.
1727            SHLIB_CFLAGS="-fPIC"
1728            SHLIB_LD="ld -Bshareable -x"
1729            SHLIB_LD_LIBS=""
1730            SHLIB_SUFFIX=".so"
1731            DL_OBJS="tclLoadDl.o"
1732            # dlopen is in -lc on QNX
1733            DL_LIBS=""
1734            CC_SEARCH_FLAGS=""
1735            LD_SEARCH_FLAGS=""
1736            ;;
1737        SCO_SV-3.2*)
1738            # Note, dlopen is available only on SCO 3.2.5 and greater. However,
1739            # this test works, since "uname -s" was non-standard in 3.2.4 and
1740            # below.
1741            if test "$GCC" = "yes" ; then
1742                SHLIB_CFLAGS="-fPIC -melf"
1743                LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
1744            else
1745                SHLIB_CFLAGS="-Kpic -belf"
1746                LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
1747            fi
1748            SHLIB_LD="ld -G"
1749            SHLIB_LD_LIBS=""
1750            SHLIB_SUFFIX=".so"
1751            DL_OBJS="tclLoadDl.o"
1752            DL_LIBS=""
1753            CC_SEARCH_FLAGS=""
1754            LD_SEARCH_FLAGS=""
1755            ;;
1756        SINIX*5.4*)
1757            SHLIB_CFLAGS="-K PIC"
1758            SHLIB_LD="cc -G"
1759            SHLIB_LD_LIBS=""
1760            SHLIB_SUFFIX=".so"
1761            DL_OBJS="tclLoadDl.o"
1762            DL_LIBS="-ldl"
1763            CC_SEARCH_FLAGS=""
1764            LD_SEARCH_FLAGS=""
1765            ;;
1766        SunOS-4*)
1767            SHLIB_CFLAGS="-PIC"
1768            SHLIB_LD="ld"
1769            SHLIB_LD_LIBS=""
1770            SHLIB_SUFFIX=".so"
1771            DL_OBJS="tclLoadDl.o"
1772            DL_LIBS="-ldl"
1773            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1774            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1775
1776            # SunOS can't handle version numbers with dots in them in library
1777            # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
1778            # requires an extra version number at the end of .so file names.
1779            # So, the library has to have a name like libtcl75.so.1.0
1780
1781            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.1.0'
1782            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1783            TCL_LIB_VERSIONS_OK=nodots
1784            ;;
1785        SunOS-5.[[0-6]])
1786            # Careful to not let 5.10+ fall into this case
1787
1788            # Note: If _REENTRANT isn't defined, then Solaris
1789            # won't define thread-safe library routines.
1790
1791            AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
1792            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
1793                [Do we really want to follow the standard? Yes we do!])
1794
1795            SHLIB_CFLAGS="-KPIC"
1796
1797            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1798            # symbols when dynamically loaded into tclsh.
1799
1800            SHLIB_LD_LIBS='${LIBS}'
1801            SHLIB_SUFFIX=".so"
1802            DL_OBJS="tclLoadDl.o"
1803            DL_LIBS="-ldl"
1804            if test "$GCC" = "yes" ; then
1805                SHLIB_LD="$CC -shared"
1806                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1807                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1808            else
1809                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1810                CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1811                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1812            fi
1813            ;;
1814        SunOS-5*)
1815            # Note: If _REENTRANT isn't defined, then Solaris
1816            # won't define thread-safe library routines.
1817
1818            AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
1819            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
1820                [Do we really want to follow the standard? Yes we do!])
1821
1822            SHLIB_CFLAGS="-KPIC"
1823
1824            # Check to enable 64-bit flags for compiler/linker
1825            if test "$do64bit" = "yes" ; then
1826                arch=`isainfo`
1827                if test "$arch" = "sparcv9 sparc" ; then
1828                        if test "$GCC" = "yes" ; then
1829                            if test "`gcc -dumpversion | awk -F. '{print [$]1}'`" -lt "3" ; then
1830                                AC_MSG_WARN([64bit mode not supported with GCC < 3.2 on $system])
1831                            else
1832                                do64bit_ok=yes
1833                                CFLAGS="$CFLAGS -m64 -mcpu=v9"
1834                                LDFLAGS="$LDFLAGS -m64 -mcpu=v9"
1835                                SHLIB_CFLAGS="-fPIC"
1836                            fi
1837                        else
1838                            do64bit_ok=yes
1839                            if test "$do64bitVIS" = "yes" ; then
1840                                CFLAGS="$CFLAGS -xarch=v9a"
1841                                LDFLAGS_ARCH="-xarch=v9a"
1842                            else
1843                                CFLAGS="$CFLAGS -xarch=v9"
1844                                LDFLAGS_ARCH="-xarch=v9"
1845                            fi
1846                            # Solaris 64 uses this as well
1847                            #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
1848                        fi
1849                elif test "$arch" = "amd64 i386" ; then
1850                    if test "$GCC" = "yes" ; then
1851                        AC_MSG_WARN([64bit mode not supported with GCC on $system])
1852                    else
1853                        do64bit_ok=yes
1854                        CFLAGS="$CFLAGS -xarch=amd64"
1855                        LDFLAGS="$LDFLAGS -xarch=amd64"
1856                    fi
1857                else
1858                    AC_MSG_WARN([64bit mode not supported for $arch])
1859                fi
1860            fi
1861           
1862            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1863            # symbols when dynamically loaded into tclsh.
1864
1865            SHLIB_LD_LIBS='${LIBS}'
1866            SHLIB_SUFFIX=".so"
1867            DL_OBJS="tclLoadDl.o"
1868            DL_LIBS="-ldl"
1869            if test "$GCC" = "yes" ; then
1870                SHLIB_LD="$CC -shared"
1871                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1872                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1873                if test "$do64bit_ok" = "yes" ; then
1874                    # We need to specify -static-libgcc or we need to
1875                    # add the path to the sparv9 libgcc.
1876                    # JH: static-libgcc is necessary for core Tcl, but may
1877                    # not be necessary for extensions.
1878                    SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
1879                    # for finding sparcv9 libgcc, get the regular libgcc
1880                    # path, remove so name and append 'sparcv9'
1881                    #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..."
1882                    #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir"
1883                fi
1884            else
1885                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1886                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1887                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1888            fi
1889            ;;
1890        UNIX_SV* | UnixWare-5*)
1891            SHLIB_CFLAGS="-KPIC"
1892            SHLIB_LD="cc -G"
1893            SHLIB_LD_LIBS=""
1894            SHLIB_SUFFIX=".so"
1895            DL_OBJS="tclLoadDl.o"
1896            DL_LIBS="-ldl"
1897            # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
1898            # that don't grok the -Bexport option.  Test that it does.
1899            AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [
1900                hold_ldflags=$LDFLAGS
1901                LDFLAGS="$LDFLAGS -Wl,-Bexport"
1902                AC_TRY_LINK(, [int i;], tcl_cv_ld_Bexport=yes, tcl_cv_ld_Bexport=no)
1903                LDFLAGS=$hold_ldflags])
1904            if test $tcl_cv_ld_Bexport = yes; then
1905                LDFLAGS="$LDFLAGS -Wl,-Bexport"
1906            fi
1907            CC_SEARCH_FLAGS=""
1908            LD_SEARCH_FLAGS=""
1909            ;;
1910    esac
1911
1912    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
1913        AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform])
1914    fi
1915
1916    # Step 4: disable dynamic loading if requested via a command-line switch.
1917
1918    AC_ARG_ENABLE(load,
1919        AC_HELP_STRING([--disable-load],
1920            [disallow dynamic loading and "load" command (default: enabled)]),
1921        [tcl_ok=$enableval], [tcl_ok=yes])
1922    if test "$tcl_ok" = "no"; then
1923        DL_OBJS=""
1924    fi
1925
1926    if test "x$DL_OBJS" != "x" ; then
1927        BUILD_DLTEST="\$(DLTEST_TARGETS)"
1928    else
1929        echo "Can't figure out how to do dynamic loading or shared libraries"
1930        echo "on this system."
1931        SHLIB_CFLAGS=""
1932        SHLIB_LD=""
1933        SHLIB_SUFFIX=""
1934        DL_OBJS="tclLoadNone.o"
1935        DL_LIBS=""
1936        LDFLAGS="$LDFLAGS_ORIG"
1937        CC_SEARCH_FLAGS=""
1938        LD_SEARCH_FLAGS=""
1939        BUILD_DLTEST=""
1940    fi
1941    LDFLAGS="$LDFLAGS $LDFLAGS_ARCH"
1942
1943    # If we're running gcc, then change the C flags for compiling shared
1944    # libraries to the right flags for gcc, instead of those for the
1945    # standard manufacturer compiler.
1946
1947    if test "$DL_OBJS" != "tclLoadNone.o" ; then
1948        if test "$GCC" = "yes" ; then
1949            case $system in
1950                AIX-*)
1951                    ;;
1952                BSD/OS*)
1953                    ;;
1954                IRIX*)
1955                    ;;
1956                NetBSD-*|FreeBSD-*)
1957                    ;;
1958                Darwin-*)
1959                    ;;
1960                SCO_SV-3.2*)
1961                    ;;
1962                windows)
1963                    ;;
1964                *)
1965                    SHLIB_CFLAGS="-fPIC"
1966                    ;;
1967            esac
1968        fi
1969    fi
1970
1971    if test "$SHARED_LIB_SUFFIX" = "" ; then
1972        SHARED_LIB_SUFFIX='${PACKAGE_VERSION}${SHLIB_SUFFIX}'
1973    fi
1974    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
1975        UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}.a'
1976    fi
1977
1978    AC_SUBST(DL_LIBS)
1979
1980    AC_SUBST(CFLAGS_DEBUG)
1981    AC_SUBST(CFLAGS_OPTIMIZE)
1982    AC_SUBST(CFLAGS_WARNING)
1983
1984    AC_SUBST(STLIB_LD)
1985    AC_SUBST(SHLIB_LD)
1986
1987    AC_SUBST(SHLIB_LD_LIBS)
1988    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
1996])
1997
1998#--------------------------------------------------------------------
1999# TEA_SERIAL_PORT
2000#
2001#       Determine which interface to use to talk to the serial port.
2002#       Note that #include lines must begin in leftmost column for
2003#       some compilers to recognize them as preprocessor directives,
2004#       and some build environments have stdin not pointing at a
2005#       pseudo-terminal (usually /dev/null instead.)
2006#
2007# Arguments:
2008#       none
2009#       
2010# Results:
2011#
2012#       Defines only one of the following vars:
2013#               HAVE_SYS_MODEM_H
2014#               USE_TERMIOS
2015#               USE_TERMIO
2016#               USE_SGTTY
2017#
2018#--------------------------------------------------------------------
2019
2020AC_DEFUN([TEA_SERIAL_PORT], [
2021    AC_CHECK_HEADERS(sys/modem.h)
2022    AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
2023    AC_TRY_RUN([
2024#include <termios.h>
2025
2026int main() {
2027    struct termios t;
2028    if (tcgetattr(0, &t) == 0) {
2029        cfsetospeed(&t, 0);
2030        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2031        return 0;
2032    }
2033    return 1;
2034}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2035    if test $tcl_cv_api_serial = no ; then
2036        AC_TRY_RUN([
2037#include <termio.h>
2038
2039int main() {
2040    struct termio t;
2041    if (ioctl(0, TCGETA, &t) == 0) {
2042        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2043        return 0;
2044    }
2045    return 1;
2046}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2047    fi
2048    if test $tcl_cv_api_serial = no ; then
2049        AC_TRY_RUN([
2050#include <sgtty.h>
2051
2052int main() {
2053    struct sgttyb t;
2054    if (ioctl(0, TIOCGETP, &t) == 0) {
2055        t.sg_ospeed = 0;
2056        t.sg_flags |= ODDP | EVENP | RAW;
2057        return 0;
2058    }
2059    return 1;
2060}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2061    fi
2062    if test $tcl_cv_api_serial = no ; then
2063        AC_TRY_RUN([
2064#include <termios.h>
2065#include <errno.h>
2066
2067int main() {
2068    struct termios t;
2069    if (tcgetattr(0, &t) == 0
2070        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2071        cfsetospeed(&t, 0);
2072        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2073        return 0;
2074    }
2075    return 1;
2076}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2077    fi
2078    if test $tcl_cv_api_serial = no; then
2079        AC_TRY_RUN([
2080#include <termio.h>
2081#include <errno.h>
2082
2083int main() {
2084    struct termio t;
2085    if (ioctl(0, TCGETA, &t) == 0
2086        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2087        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2088        return 0;
2089    }
2090    return 1;
2091    }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2092    fi
2093    if test $tcl_cv_api_serial = no; then
2094        AC_TRY_RUN([
2095#include <sgtty.h>
2096#include <errno.h>
2097
2098int main() {
2099    struct sgttyb t;
2100    if (ioctl(0, TIOCGETP, &t) == 0
2101        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2102        t.sg_ospeed = 0;
2103        t.sg_flags |= ODDP | EVENP | RAW;
2104        return 0;
2105    }
2106    return 1;
2107}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
2108    fi])
2109    case $tcl_cv_api_serial in
2110        termios) AC_DEFINE(USE_TERMIOS, 1, [Use the termios API for serial lines]);;
2111        termio)  AC_DEFINE(USE_TERMIO, 1, [Use the termio API for serial lines]);;
2112        sgtty)   AC_DEFINE(USE_SGTTY, 1, [Use the sgtty API for serial lines]);;
2113    esac
2114])
2115
2116#--------------------------------------------------------------------
2117# TEA_MISSING_POSIX_HEADERS
2118#
2119#       Supply substitutes for missing POSIX header files.  Special
2120#       notes:
2121#           - stdlib.h doesn't define strtol, strtoul, or
2122#             strtod insome versions of SunOS
2123#           - some versions of string.h don't declare procedures such
2124#             as strstr
2125#
2126# Arguments:
2127#       none
2128#       
2129# Results:
2130#
2131#       Defines some of the following vars:
2132#               NO_DIRENT_H
2133#               NO_ERRNO_H
2134#               NO_VALUES_H
2135#               HAVE_LIMITS_H or NO_LIMITS_H
2136#               NO_STDLIB_H
2137#               NO_STRING_H
2138#               NO_SYS_WAIT_H
2139#               NO_DLFCN_H
2140#               HAVE_SYS_PARAM_H
2141#
2142#               HAVE_STRING_H ?
2143#
2144# tkUnixPort.h checks for HAVE_LIMITS_H, so do both HAVE and
2145# CHECK on limits.h
2146#--------------------------------------------------------------------
2147
2148AC_DEFUN([TEA_MISSING_POSIX_HEADERS], [
2149    AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h,
2150    AC_TRY_LINK([#include <sys/types.h>
2151#include <dirent.h>], [
2152#ifndef _POSIX_SOURCE
2153#   ifdef __Lynx__
2154        /*
2155         * Generate compilation error to make the test fail:  Lynx headers
2156         * are only valid if really in the POSIX environment.
2157         */
2158
2159        missing_procedure();
2160#   endif
2161#endif
2162DIR *d;
2163struct dirent *entryPtr;
2164char *p;
2165d = opendir("foobar");
2166entryPtr = readdir(d);
2167p = entryPtr->d_name;
2168closedir(d);
2169], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no))
2170
2171    if test $tcl_cv_dirent_h = no; then
2172        AC_DEFINE(NO_DIRENT_H, 1, [Do we have <dirent.h>?])
2173    fi
2174
2175    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H, 1, [Do we have <errno.h>?])])
2176    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H, 1, [Do we have <float.h>?])])
2177    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H, 1, [Do we have <values.h>?])])
2178    AC_CHECK_HEADER(limits.h,
2179        [AC_DEFINE(HAVE_LIMITS_H, 1, [Do we have <limits.h>?])],
2180        [AC_DEFINE(NO_LIMITS_H, 1, [Do we have <limits.h>?])])
2181    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
2182    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
2183    AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
2184    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
2185    if test $tcl_ok = 0; then
2186        AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?])
2187    fi
2188    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
2189    AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
2190    AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
2191
2192    # See also memmove check below for a place where NO_STRING_H can be
2193    # set and why.
2194
2195    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>?])])
2201
2202    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
2203    AC_HAVE_HEADERS(sys/param.h)
2204])
2205
2206#--------------------------------------------------------------------
2207# TEA_PATH_X
2208#
2209#       Locate the X11 header files and the X11 library archive.  Try
2210#       the ac_path_x macro first, but if it doesn't find the X stuff
2211#       (e.g. because there's no xmkmf program) then check through
2212#       a list of possible directories.  Under some conditions the
2213#       autoconf macro will return an include directory that contains
2214#       no include files, so double-check its result just to be safe.
2215#
2216#       This should be called after TEA_CONFIG_CFLAGS as setting the
2217#       LIBS line can confuse some configure macro magic.
2218#
2219# Arguments:
2220#       none
2221#       
2222# Results:
2223#
2224#       Sets the following vars:
2225#               XINCLUDES
2226#               XLIBSW
2227#               PKG_LIBS (appends to)
2228#
2229#--------------------------------------------------------------------
2230
2231AC_DEFUN([TEA_PATH_X], [
2232    if test "${TEA_WINDOWINGSYSTEM}" = "x11" ; then
2233        TEA_PATH_UNIX_X
2234    fi
2235])
2236
2237AC_DEFUN([TEA_PATH_UNIX_X], [
2238    AC_PATH_X
2239    not_really_there=""
2240    if test "$no_x" = ""; then
2241        if test "$x_includes" = ""; then
2242            AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
2243        else
2244            if test ! -r $x_includes/X11/Intrinsic.h; then
2245                not_really_there="yes"
2246            fi
2247        fi
2248    fi
2249    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
2250        AC_MSG_CHECKING([for X11 header files])
2251        found_xincludes="no"
2252        AC_TRY_CPP([#include <X11/Intrinsic.h>], found_xincludes="yes", found_xincludes="no")
2253        if test "$found_xincludes" = "no"; then
2254            dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/X11R6/include /usr/X11R5/include /usr/include/X11R5 /usr/include/X11R4 /usr/openwin/include /usr/X11/include /usr/sww/include"
2255            for i in $dirs ; do
2256                if test -r $i/X11/Intrinsic.h; then
2257                    AC_MSG_RESULT([$i])
2258                    XINCLUDES=" -I$i"
2259                    found_xincludes="yes"
2260                    break
2261                fi
2262            done
2263        fi
2264    else
2265        if test "$x_includes" != ""; then
2266            XINCLUDES="-I$x_includes"
2267            found_xincludes="yes"
2268        fi
2269    fi
2270    if test found_xincludes = "no"; then
2271        AC_MSG_RESULT([couldn't find any!])
2272    fi
2273
2274    if test "$no_x" = yes; then
2275        AC_MSG_CHECKING([for X11 libraries])
2276        XLIBSW=nope
2277        dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/X11R6/lib /usr/X11R5/lib /usr/lib/X11R5 /usr/lib/X11R4 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib"
2278        for i in $dirs ; do
2279            if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
2280                AC_MSG_RESULT([$i])
2281                XLIBSW="-L$i -lX11"
2282                x_libraries="$i"
2283                break
2284            fi
2285        done
2286    else
2287        if test "$x_libraries" = ""; then
2288            XLIBSW=-lX11
2289        else
2290            XLIBSW="-L$x_libraries -lX11"
2291        fi
2292    fi
2293    if test "$XLIBSW" = nope ; then
2294        AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
2295    fi
2296    if test "$XLIBSW" = nope ; then
2297        AC_MSG_RESULT([could not find any!  Using -lX11.])
2298        XLIBSW=-lX11
2299    fi
2300    if test x"${XLIBSW}" != x ; then
2301        PKG_LIBS="${PKG_LIBS} ${XLIBSW}"
2302    fi
2303])
2304
2305#--------------------------------------------------------------------
2306# TEA_BLOCKING_STYLE
2307#
2308#       The statements below check for systems where POSIX-style
2309#       non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
2310#       On these systems (mostly older ones), use the old BSD-style
2311#       FIONBIO approach instead.
2312#
2313# Arguments:
2314#       none
2315#       
2316# Results:
2317#
2318#       Defines some of the following vars:
2319#               HAVE_SYS_IOCTL_H
2320#               HAVE_SYS_FILIO_H
2321#               USE_FIONBIO
2322#               O_NONBLOCK
2323#
2324#--------------------------------------------------------------------
2325
2326AC_DEFUN([TEA_BLOCKING_STYLE], [
2327    AC_CHECK_HEADERS(sys/ioctl.h)
2328    AC_CHECK_HEADERS(sys/filio.h)
2329    TEA_CONFIG_SYSTEM
2330    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
2331    case $system in
2332        # There used to be code here to use FIONBIO under AIX.  However, it
2333        # was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
2334        # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
2335        # code (JO, 5/31/97).
2336
2337        OSF*)
2338            AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
2339            AC_MSG_RESULT([FIONBIO])
2340            ;;
2341        SunOS-4*)
2342            AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
2343            AC_MSG_RESULT([FIONBIO])
2344            ;;
2345        *)
2346            AC_MSG_RESULT([O_NONBLOCK])
2347            ;;
2348    esac
2349])
2350
2351#--------------------------------------------------------------------
2352# TEA_TIME_HANLDER
2353#
2354#       Checks how the system deals with time.h, what time structures
2355#       are used on the system, and what fields the structures have.
2356#
2357# Arguments:
2358#       none
2359#       
2360# Results:
2361#
2362#       Defines some of the following vars:
2363#               USE_DELTA_FOR_TZ
2364#               HAVE_TM_GMTOFF
2365#               HAVE_TM_TZADJ
2366#               HAVE_TIMEZONE_VAR
2367#
2368#--------------------------------------------------------------------
2369
2370AC_DEFUN([TEA_TIME_HANDLER], [
2371    AC_CHECK_HEADERS(sys/time.h)
2372    AC_HEADER_TIME
2373    AC_STRUCT_TIMEZONE
2374
2375    AC_CHECK_FUNCS(gmtime_r localtime_r)
2376
2377    AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj,
2378        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
2379            tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no))
2380    if test $tcl_cv_member_tm_tzadj = yes ; then
2381        AC_DEFINE(HAVE_TM_TZADJ, 1, [Should we use the tm_tzadj field of struct tm?])
2382    fi
2383
2384    AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff,
2385        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
2386            tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no))
2387    if test $tcl_cv_member_tm_gmtoff = yes ; then
2388        AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?])
2389    fi
2390
2391    #
2392    # Its important to include time.h in this check, as some systems
2393    # (like convex) have timezone functions, etc.
2394    #
2395    AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long,
2396        AC_TRY_COMPILE([#include <time.h>],
2397            [extern long timezone;
2398            timezone += 1;
2399            exit (0);],
2400            tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no))
2401    if test $tcl_cv_timezone_long = yes ; then
2402        AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
2403    else
2404        #
2405        # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
2406        #
2407        AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time,
2408            AC_TRY_COMPILE([#include <time.h>],
2409                [extern time_t timezone;
2410                timezone += 1;
2411                exit (0);],
2412                tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no))
2413        if test $tcl_cv_timezone_time = yes ; then
2414            AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
2415        fi
2416    fi
2417])
2418
2419#--------------------------------------------------------------------
2420# TEA_BUGGY_STRTOD
2421#
2422#       Under Solaris 2.4, strtod returns the wrong value for the
2423#       terminating character under some conditions.  Check for this
2424#       and if the problem exists use a substitute procedure
2425#       "fixstrtod" (provided by Tcl) that corrects the error.
2426#       Also, on Compaq's Tru64 Unix 5.0,
2427#       strtod(" ") returns 0.0 instead of a failure to convert.
2428#
2429# Arguments:
2430#       none
2431#       
2432# Results:
2433#
2434#       Might defines some of the following vars:
2435#               strtod (=fixstrtod)
2436#
2437#--------------------------------------------------------------------
2438
2439AC_DEFUN([TEA_BUGGY_STRTOD], [
2440    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
2441    if test "$tcl_strtod" = 1; then
2442        AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[
2443            AC_TRY_RUN([
2444                extern double strtod();
2445                int main() {
2446                    char *infString="Inf", *nanString="NaN", *spaceString=" ";
2447                    char *term;
2448                    double value;
2449                    value = strtod(infString, &term);
2450                    if ((term != infString) && (term[-1] == 0)) {
2451                        exit(1);
2452                    }
2453                    value = strtod(nanString, &term);
2454                    if ((term != nanString) && (term[-1] == 0)) {
2455                        exit(1);
2456                    }
2457                    value = strtod(spaceString, &term);
2458                    if (term == (spaceString+1)) {
2459                        exit(1);
2460                    }
2461                    exit(0);
2462                }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy,
2463                    tcl_cv_strtod_buggy=buggy)])
2464        if test "$tcl_cv_strtod_buggy" = buggy; then
2465            AC_LIBOBJ([fixstrtod])
2466            USE_COMPAT=1
2467            AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?])
2468        fi
2469    fi
2470])
2471
2472#--------------------------------------------------------------------
2473# TEA_TCL_LINK_LIBS
2474#
2475#       Search for the libraries needed to link the Tcl shell.
2476#       Things like the math library (-lm) and socket stuff (-lsocket vs.
2477#       -lnsl) are dealt with here.
2478#
2479# Arguments:
2480#       Requires the following vars to be set in the Makefile:
2481#               DL_LIBS
2482#               LIBS
2483#               MATH_LIBS
2484#       
2485# Results:
2486#
2487#       Subst's the following var:
2488#               TCL_LIBS
2489#               MATH_LIBS
2490#
2491#       Might append to the following vars:
2492#               LIBS
2493#
2494#       Might define the following vars:
2495#               HAVE_NET_ERRNO_H
2496#
2497#--------------------------------------------------------------------
2498
2499AC_DEFUN([TEA_TCL_LINK_LIBS], [
2500    #--------------------------------------------------------------------
2501    # On a few very rare systems, all of the libm.a stuff is
2502    # already in libc.a.  Set compiler flags accordingly.
2503    # Also, Linux requires the "ieee" library for math to work
2504    # right (and it must appear before "-lm").
2505    #--------------------------------------------------------------------
2506
2507    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
2508    AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
2509
2510    #--------------------------------------------------------------------
2511    # Interactive UNIX requires -linet instead of -lsocket, plus it
2512    # needs net/errno.h to define the socket-related error codes.
2513    #--------------------------------------------------------------------
2514
2515    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>?])])
2518
2519    #--------------------------------------------------------------------
2520    #   Check for the existence of the -lsocket and -lnsl libraries.
2521    #   The order here is important, so that they end up in the right
2522    #   order in the command line generated by make.  Here are some
2523    #   special considerations:
2524    #   1. Use "connect" and "accept" to check for -lsocket, and
2525    #      "gethostbyname" to check for -lnsl.
2526    #   2. Use each function name only once:  can't redo a check because
2527    #      autoconf caches the results of the last check and won't redo it.
2528    #   3. Use -lnsl and -lsocket only if they supply procedures that
2529    #      aren't already present in the normal libraries.  This is because
2530    #      IRIX 5.2 has libraries, but they aren't needed and they're
2531    #      bogus:  they goof up name resolution if used.
2532    #   4. On some SVR4 systems, can't use -lsocket without -lnsl too.
2533    #      To get around this problem, check for both libraries together
2534    #      if -lsocket doesn't work by itself.
2535    #--------------------------------------------------------------------
2536
2537    tcl_checkBoth=0
2538    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
2539    if test "$tcl_checkSocket" = 1; then
2540        AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
2541            LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
2542    fi
2543    if test "$tcl_checkBoth" = 1; then
2544        tk_oldLibs=$LIBS
2545        LIBS="$LIBS -lsocket -lnsl"
2546        AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
2547    fi
2548    AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
2549            [LIBS="$LIBS -lnsl"])])
2550   
2551    # Don't perform the eval of the libraries here because DL_LIBS
2552    # won't be set until we call TEA_CONFIG_CFLAGS
2553
2554    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
2555    AC_SUBST(TCL_LIBS)
2556    AC_SUBST(MATH_LIBS)
2557])
2558
2559#--------------------------------------------------------------------
2560# TEA_TCL_EARLY_FLAGS
2561#
2562#       Check for what flags are needed to be passed so the correct OS
2563#       features are available.
2564#
2565# Arguments:
2566#       None
2567#       
2568# Results:
2569#
2570#       Might define the following vars:
2571#               _ISOC99_SOURCE
2572#               _LARGEFILE64_SOURCE
2573#               _LARGEFILE_SOURCE64
2574#
2575#--------------------------------------------------------------------
2576
2577AC_DEFUN([TEA_TCL_EARLY_FLAG],[
2578    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
2579        AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
2580            AC_TRY_COMPILE([[#define ]$1[ 1
2581]$2], $3,
2582                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
2583                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
2584    if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
2585        AC_DEFINE($1, 1, [Add the ]$1[ flag when building])
2586        tcl_flags="$tcl_flags $1"
2587    fi
2588])
2589
2590AC_DEFUN([TEA_TCL_EARLY_FLAGS],[
2591    AC_MSG_CHECKING([for required early compiler flags])
2592    tcl_flags=""
2593    TEA_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
2594        [char *p = (char *)strtoll; char *q = (char *)strtoull;])
2595    TEA_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
2596        [struct stat64 buf; int i = stat64("/", &buf);])
2597    TEA_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
2598        [char *p = (char *)open64;])
2599    if test "x${tcl_flags}" = "x" ; then
2600        AC_MSG_RESULT([none])
2601    else
2602        AC_MSG_RESULT([${tcl_flags}])
2603    fi
2604])
2605
2606#--------------------------------------------------------------------
2607# TEA_TCL_64BIT_FLAGS
2608#
2609#       Check for what is defined in the way of 64-bit features.
2610#
2611# Arguments:
2612#       None
2613#       
2614# Results:
2615#
2616#       Might define the following vars:
2617#               TCL_WIDE_INT_IS_LONG
2618#               TCL_WIDE_INT_TYPE
2619#               HAVE_STRUCT_DIRENT64
2620#               HAVE_STRUCT_STAT64
2621#               HAVE_TYPE_OFF64_T
2622#
2623#--------------------------------------------------------------------
2624
2625AC_DEFUN([TEA_TCL_64BIT_FLAGS], [
2626    AC_MSG_CHECKING([for 64-bit integer type])
2627    AC_CACHE_VAL(tcl_cv_type_64bit,[
2628        tcl_cv_type_64bit=none
2629        # See if the compiler knows natively about __int64
2630        AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
2631            tcl_type_64bit=__int64, tcl_type_64bit="long long")
2632        # See if we should use long anyway  Note that we substitute in the
2633        # type that is our current guess for a 64-bit type inside this check
2634        # program, so it should be modified only carefully...
2635        AC_TRY_COMPILE(,[switch (0) {
2636            case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ;
2637        }],tcl_cv_type_64bit=${tcl_type_64bit})])
2638    if test "${tcl_cv_type_64bit}" = none ; then
2639        AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Are wide integers to be implemented with C 'long's?])
2640        AC_MSG_RESULT([using long])
2641    elif test "${tcl_cv_type_64bit}" = "__int64" \
2642                -a "${TEA_PLATFORM}" = "windows" ; then
2643        # We actually want to use the default tcl.h checks in this
2644        # case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER*
2645        AC_MSG_RESULT([using Tcl header defaults])
2646    else
2647        AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit},
2648            [What type should be used to define wide integers?])
2649        AC_MSG_RESULT([${tcl_cv_type_64bit}])
2650
2651        # Now check for auxiliary declarations
2652        AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
2653            AC_TRY_COMPILE([#include <sys/types.h>
2654#include <sys/dirent.h>],[struct dirent64 p;],
2655                tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
2656        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
2657            AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?])
2658        fi
2659
2660        AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[
2661            AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
2662],
2663                tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
2664        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
2665            AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in <sys/stat.h>?])
2666        fi
2667
2668        AC_CHECK_FUNCS(open64 lseek64)
2669        AC_MSG_CHECKING([for off64_t])
2670        AC_CACHE_VAL(tcl_cv_type_off64_t,[
2671            AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
2672],
2673                tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
2674        dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the
2675        dnl functions lseek64 and open64 are defined.
2676        if test "x${tcl_cv_type_off64_t}" = "xyes" && \
2677                test "x${ac_cv_func_lseek64}" = "xyes" && \
2678                test "x${ac_cv_func_open64}" = "xyes" ; then
2679            AC_DEFINE(HAVE_TYPE_OFF64_T, 1, [Is off64_t in <sys/types.h>?])
2680            AC_MSG_RESULT([yes])
2681        else
2682            AC_MSG_RESULT([no])
2683        fi
2684    fi
2685])
2686
2687##
2688## Here ends the standard Tcl configuration bits and starts the
2689## TEA specific functions
2690##
2691
2692#------------------------------------------------------------------------
2693# TEA_INIT --
2694#
2695#       Init various Tcl Extension Architecture (TEA) variables.
2696#       This should be the first called TEA_* macro.
2697#
2698# Arguments:
2699#       none
2700#
2701# Results:
2702#
2703#       Defines and substs the following vars:
2704#               CYGPATH
2705#               EXEEXT
2706#       Defines only:
2707#               TEA_VERSION
2708#               TEA_INITED
2709#               TEA_PLATFORM (windows or unix)
2710#
2711# "cygpath" is used on windows to generate native path names for include
2712# files. These variables should only be used with the compiler and linker
2713# since they generate native path names.
2714#
2715# EXEEXT
2716#       Select the executable extension based on the host type.  This
2717#       is a lightweight replacement for AC_EXEEXT that doesn't require
2718#       a compiler.
2719#------------------------------------------------------------------------
2720
2721AC_DEFUN([TEA_INIT], [
2722    # TEA extensions pass this us the version of TEA they think they
2723    # are compatible with.
2724    TEA_VERSION="3.5"
2725
2726    AC_MSG_CHECKING([for correct TEA configuration])
2727    if test x"${PACKAGE_NAME}" = x ; then
2728        AC_MSG_ERROR([
2729The PACKAGE_NAME variable must be defined by your TEA configure.in])
2730    fi
2731    if test x"$1" = x ; then
2732        AC_MSG_ERROR([
2733TEA version not specified.])
2734    elif test "$1" != "${TEA_VERSION}" ; then
2735        AC_MSG_RESULT([warning: requested TEA version "$1", have "${TEA_VERSION}"])
2736    else
2737        AC_MSG_RESULT([ok (TEA ${TEA_VERSION})])
2738    fi
2739    case "`uname -s`" in
2740        *win32*|*WIN32*|*CYGWIN_NT*|*CYGWIN_9*|*CYGWIN_ME*|*MINGW32_*|*MSYS_NT*)
2741            AC_CHECK_PROG(CYGPATH, cygpath, cygpath -w, echo)
2742            EXEEXT=".exe"
2743            TEA_PLATFORM="windows"
2744            ;;
2745        *)
2746            CYGPATH=echo
2747            EXEEXT=""
2748            TEA_PLATFORM="unix"
2749            ;;
2750    esac
2751
2752    # Check if exec_prefix is set. If not use fall back to prefix.
2753    # Note when adjusted, so that TEA_PREFIX can correct for this.
2754    # This is needed for recursive configures, since autoconf propagates
2755    # $prefix, but not $exec_prefix (doh!).
2756    if test x$exec_prefix = xNONE ; then
2757        exec_prefix_default=yes
2758        exec_prefix=$prefix
2759    fi
2760
2761    AC_SUBST(EXEEXT)
2762    AC_SUBST(CYGPATH)
2763
2764    # This package name must be replaced statically for AC_SUBST to work
2765    AC_SUBST(PKG_LIB_FILE)
2766    # Substitute STUB_LIB_FILE in case package creates a stub library too.
2767    AC_SUBST(PKG_STUB_LIB_FILE)
2768
2769    # We AC_SUBST these here to ensure they are subst'ed,
2770    # in case the user doesn't call TEA_ADD_...
2771    AC_SUBST(PKG_STUB_SOURCES)
2772    AC_SUBST(PKG_STUB_OBJECTS)
2773    AC_SUBST(PKG_TCL_SOURCES)
2774    AC_SUBST(PKG_HEADERS)
2775    AC_SUBST(PKG_INCLUDES)
2776    AC_SUBST(PKG_LIBS)
2777    AC_SUBST(PKG_CFLAGS)
2778])
2779
2780#------------------------------------------------------------------------
2781# TEA_ADD_SOURCES --
2782#
2783#       Specify one or more source files.  Users should check for
2784#       the right platform before adding to their list.
2785#       It is not important to specify the directory, as long as it is
2786#       in the generic, win or unix subdirectory of $(srcdir).
2787#
2788# Arguments:
2789#       one or more file names
2790#
2791# Results:
2792#
2793#       Defines and substs the following vars:
2794#               PKG_SOURCES
2795#               PKG_OBJECTS
2796#------------------------------------------------------------------------
2797AC_DEFUN([TEA_ADD_SOURCES], [
2798    vars="$@"
2799    for i in $vars; do
2800        case $i in
2801            [\$]*)
2802                # allow $-var names
2803                PKG_SOURCES="$PKG_SOURCES $i"
2804                PKG_OBJECTS="$PKG_OBJECTS $i"
2805                ;;
2806            *)
2807                # check for existence - allows for generic/win/unix VPATH
2808                if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/src/$i" \
2809                    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
2810                    ; then
2811                    AC_MSG_ERROR([could not find source file '$i'])
2812                fi
2813                PKG_SOURCES="$PKG_SOURCES $i"
2814                # this assumes it is in a VPATH dir
2815                i=`basename $i`
2816                # handle user calling this before or after TEA_SETUP_COMPILER
2817                if test x"${OBJEXT}" != x ; then
2818                    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
2819                else
2820                    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
2821                fi
2822                PKG_OBJECTS="$PKG_OBJECTS $j"
2823                ;;
2824        esac
2825    done
2826    AC_SUBST(PKG_SOURCES)
2827    AC_SUBST(PKG_OBJECTS)
2828])
2829
2830#------------------------------------------------------------------------
2831# TEA_ADD_STUB_SOURCES --
2832#
2833#       Specify one or more source files.  Users should check for
2834#       the right platform before adding to their list.
2835#       It is not important to specify the directory, as long as it is
2836#       in the generic, win or unix subdirectory of $(srcdir).
2837#
2838# Arguments:
2839#       one or more file names
2840#
2841# Results:
2842#
2843#       Defines and substs the following vars:
2844#               PKG_STUB_SOURCES
2845#               PKG_STUB_OBJECTS
2846#------------------------------------------------------------------------
2847AC_DEFUN([TEA_ADD_STUB_SOURCES], [
2848    vars="$@"
2849    for i in $vars; do
2850        # check for existence - allows for generic/win/unix VPATH
2851        if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
2852            -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
2853            ; then
2854            AC_MSG_ERROR([could not find stub source file '$i'])
2855        fi
2856        PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i"
2857        # this assumes it is in a VPATH dir
2858        i=`basename $i`
2859        # handle user calling this before or after TEA_SETUP_COMPILER
2860        if test x"${OBJEXT}" != x ; then
2861            j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
2862        else
2863            j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
2864        fi
2865        PKG_STUB_OBJECTS="$PKG_STUB_OBJECTS $j"
2866    done
2867    AC_SUBST(PKG_STUB_SOURCES)
2868    AC_SUBST(PKG_STUB_OBJECTS)
2869])
2870
2871#------------------------------------------------------------------------
2872# TEA_ADD_TCL_SOURCES --
2873#
2874#       Specify one or more Tcl source files.  These should be platform
2875#       independent runtime files.
2876#
2877# Arguments:
2878#       one or more file names
2879#
2880# Results:
2881#
2882#       Defines and substs the following vars:
2883#               PKG_TCL_SOURCES
2884#------------------------------------------------------------------------
2885AC_DEFUN([TEA_ADD_TCL_SOURCES], [
2886    vars="$@"
2887    for i in $vars; do
2888        # check for existence, be strict because it is installed
2889        if test ! -f "${srcdir}/$i" ; then
2890            AC_MSG_ERROR([could not find tcl source file '${srcdir}/$i'])
2891        fi
2892        PKG_TCL_SOURCES="$PKG_TCL_SOURCES $i"
2893    done
2894    AC_SUBST(PKG_TCL_SOURCES)
2895])
2896
2897#------------------------------------------------------------------------
2898# TEA_ADD_HEADERS --
2899#
2900#       Specify one or more source headers.  Users should check for
2901#       the right platform before adding to their list.
2902#
2903# Arguments:
2904#       one or more file names
2905#
2906# Results:
2907#
2908#       Defines and substs the following vars:
2909#               PKG_HEADERS
2910#------------------------------------------------------------------------
2911AC_DEFUN([TEA_ADD_HEADERS], [
2912    vars="$@"
2913    for i in $vars; do
2914        # check for existence, be strict because it is installed
2915        if test ! -f "${srcdir}/$i" ; then
2916            AC_MSG_ERROR([could not find header file '${srcdir}/$i'])
2917        fi
2918        PKG_HEADERS="$PKG_HEADERS $i"
2919    done
2920    AC_SUBST(PKG_HEADERS)
2921])
2922
2923#------------------------------------------------------------------------
2924# TEA_ADD_INCLUDES --
2925#
2926#       Specify one or more include dirs.  Users should check for
2927#       the right platform before adding to their list.
2928#
2929# Arguments:
2930#       one or more file names
2931#
2932# Results:
2933#
2934#       Defines and substs the following vars:
2935#               PKG_INCLUDES
2936#------------------------------------------------------------------------
2937AC_DEFUN([TEA_ADD_INCLUDES], [
2938    vars="$@"
2939    for i in $vars; do
2940        PKG_INCLUDES="$PKG_INCLUDES $i"
2941    done
2942    AC_SUBST(PKG_INCLUDES)
2943])
2944
2945#------------------------------------------------------------------------
2946# TEA_ADD_LIBS --
2947#
2948#       Specify one or more libraries.  Users should check for
2949#       the right platform before adding to their list.  For Windows,
2950#       libraries provided in "foo.lib" format will be converted to
2951#       "-lfoo" when using GCC (mingw).
2952#
2953# Arguments:
2954#       one or more file names
2955#
2956# Results:
2957#
2958#       Defines and substs the following vars:
2959#               PKG_LIBS
2960#------------------------------------------------------------------------
2961AC_DEFUN([TEA_ADD_LIBS], [
2962    vars="$@"
2963    for i in $vars; do
2964        if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
2965            # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
2966            i=`echo "$i" | sed -e 's/^\([[^-]].*\)\.lib[$]/-l\1/i'`
2967        fi
2968        PKG_LIBS="$PKG_LIBS $i"
2969    done
2970    AC_SUBST(PKG_LIBS)
2971])
2972
2973#------------------------------------------------------------------------
2974# TEA_ADD_CFLAGS --
2975#
2976#       Specify one or more CFLAGS.  Users should check for
2977#       the right platform before adding to their list.
2978#
2979# Arguments:
2980#       one or more file names
2981#
2982# Results:
2983#
2984#       Defines and substs the following vars:
2985#               PKG_CFLAGS
2986#------------------------------------------------------------------------
2987AC_DEFUN([TEA_ADD_CFLAGS], [
2988    PKG_CFLAGS="$PKG_CFLAGS $@"
2989    AC_SUBST(PKG_CFLAGS)
2990])
2991
2992#------------------------------------------------------------------------
2993# TEA_PREFIX --
2994#
2995#       Handle the --prefix=... option by defaulting to what Tcl gave
2996#
2997# Arguments:
2998#       none
2999#
3000# Results:
3001#
3002#       If --prefix or --exec-prefix was not specified, $prefix and
3003#       $exec_prefix will be set to the values given to Tcl when it was
3004#       configured.
3005#------------------------------------------------------------------------
3006AC_DEFUN([TEA_PREFIX], [
3007    if test "${prefix}" = "NONE"; then
3008        prefix_default=yes
3009        if test x"${TCL_PREFIX}" != x; then
3010            AC_MSG_NOTICE([--prefix defaulting to TCL_PREFIX ${TCL_PREFIX}])
3011            prefix=${TCL_PREFIX}
3012        else
3013            AC_MSG_NOTICE([--prefix defaulting to /usr/local])
3014            prefix=/usr/local
3015        fi
3016    fi
3017    if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" \
3018        -o x"${exec_prefix_default}" = x"yes" ; then
3019        if test x"${TCL_EXEC_PREFIX}" != x; then
3020            AC_MSG_NOTICE([--exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}])
3021            exec_prefix=${TCL_EXEC_PREFIX}
3022        else
3023            AC_MSG_NOTICE([--exec-prefix defaulting to ${prefix}])
3024            exec_prefix=$prefix
3025        fi
3026    fi
3027])
3028
3029#------------------------------------------------------------------------
3030# TEA_SETUP_COMPILER_CC --
3031#
3032#       Do compiler checks the way we want.  This is just a replacement
3033#       for AC_PROG_CC in TEA configure.in files to make them cleaner.
3034#
3035# Arguments:
3036#       none
3037#
3038# Results:
3039#
3040#       Sets up CC var and other standard bits we need to make executables.
3041#------------------------------------------------------------------------
3042AC_DEFUN([TEA_SETUP_COMPILER_CC], [
3043    # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE)
3044    # in this macro, they need to go into TEA_SETUP_COMPILER instead.
3045
3046    # If the user did not set CFLAGS, set it now to keep
3047    # the AC_PROG_CC macro from adding "-g -O2".
3048    if test "${CFLAGS+set}" != "set" ; then
3049        CFLAGS=""
3050    fi
3051
3052    AC_PROG_CC
3053    AC_PROG_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#------------------------------------------------------------------------
3091AC_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
3146AC_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
3243AC_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
3316AC_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
3380AC_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
3469AC_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
3535AC_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
3637AC_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
3687AC_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
3738AC_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
3851AC_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
3907AC_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:
Note: See TracBrowser for help on using the repository browser.