source: tol/tolbase/tclconfig/tcl.m4 @ b83b8ed3

1941-docker-image-to-testdevel
Last change on this file since b83b8ed3 was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 98.5 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-2003 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.2 2007/11/06 18:48:31 danirus Exp $
13
14AC_PREREQ(2.50)
15
16#------------------------------------------------------------------------
17# TEA_PATH_TCLCONFIG --
18#
19#       Locate the tclConfig.sh file and perform a sanity check on
20#       the Tcl compile flags
21#
22# Arguments:
23#       none
24#
25# Results:
26#
27#       Adds the following arguments to configure:
28#               --with-tcl=...
29#
30#       Defines the following vars:
31#               TCL_BIN_DIR     Full path to the directory containing
32#                               the tclConfig.sh file
33#------------------------------------------------------------------------
34
35AC_DEFUN([TEA_PATH_TCLCONFIG], [
36    dnl Make sure we are initialized
37    AC_REQUIRE([TEA_INIT])
38    #
39    # Ok, lets find the tcl configuration
40    # First, look for one uninstalled.
41    # the alternative search directory is invoked by --with-tcl
42    #
43
44    if test x"${no_tcl}" = x ; then
45        # we reset no_tcl in case something fails here
46        no_tcl=true
47        AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
48        AC_MSG_CHECKING([for Tcl configuration])
49        AC_CACHE_VAL(ac_cv_c_tclconfig,[
50
51            # First check to see if --with-tcl was specified.
52            if test x"${with_tclconfig}" != x ; then
53                if test -f "${with_tclconfig}/tclConfig.sh" ; then
54                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
55                else
56                    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
57                fi
58            fi
59
60            # then check for a private Tcl installation
61            if test x"${ac_cv_c_tclconfig}" = x ; then
62                for i in \
63                        ../tcl \
64                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
65                        ../../tcl \
66                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
67                        ../../../tcl \
68                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
69                    if test -f "$i/unix/tclConfig.sh" ; then
70                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
71                        break
72                    fi
73                done
74            fi
75
76            # check in a few common install locations
77            if test x"${ac_cv_c_tclconfig}" = x ; then
78                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
79                        `ls -d ${prefix}/lib 2>/dev/null` \
80                        `ls -d /usr/local/lib 2>/dev/null` \
81                        `ls -d /usr/contrib/lib 2>/dev/null` \
82                        `ls -d /usr/lib 2>/dev/null` \
83                        ; do
84                    if test -f "$i/tclConfig.sh" ; then
85                        ac_cv_c_tclconfig=`(cd $i; pwd)`
86                        break
87                    fi
88                done
89            fi
90
91            # check in a few other private locations
92            if test x"${ac_cv_c_tclconfig}" = x ; then
93                for i in \
94                        ${srcdir}/../tcl \
95                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
96                    if test -f "$i/unix/tclConfig.sh" ; then
97                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
98                    break
99                fi
100                done
101            fi
102        ])
103
104        if test x"${ac_cv_c_tclconfig}" = x ; then
105            TCL_BIN_DIR="# no Tcl configs found"
106            AC_MSG_WARN("Cannot find Tcl configuration definitions")
107            exit 0
108        else
109            no_tcl=
110            TCL_BIN_DIR=${ac_cv_c_tclconfig}
111            AC_MSG_RESULT([found $TCL_BIN_DIR/tclConfig.sh])
112        fi
113    fi
114])
115
116#------------------------------------------------------------------------
117# TEA_PATH_TKCONFIG --
118#
119#       Locate the tkConfig.sh file
120#
121# Arguments:
122#       none
123#
124# Results:
125#
126#       Adds the following arguments to configure:
127#               --with-tk=...
128#
129#       Defines the following vars:
130#               TK_BIN_DIR      Full path to the directory containing
131#                               the tkConfig.sh file
132#------------------------------------------------------------------------
133
134AC_DEFUN([TEA_PATH_TKCONFIG], [
135    #
136    # Ok, lets find the tk configuration
137    # First, look for one uninstalled.
138    # the alternative search directory is invoked by --with-tk
139    #
140
141    if test x"${no_tk}" = x ; then
142        # we reset no_tk in case something fails here
143        no_tk=true
144        AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
145        AC_MSG_CHECKING([for Tk configuration])
146        AC_CACHE_VAL(ac_cv_c_tkconfig,[
147
148            # First check to see if --with-tkconfig was specified.
149            if test x"${with_tkconfig}" != x ; then
150                if test -f "${with_tkconfig}/tkConfig.sh" ; then
151                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
152                else
153                    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
154                fi
155            fi
156
157            # then check for a private Tk library
158            if test x"${ac_cv_c_tkconfig}" = x ; then
159                for i in \
160                        ../tk \
161                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
162                        ../../tk \
163                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
164                        ../../../tk \
165                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
166                    if test -f "$i/unix/tkConfig.sh" ; then
167                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
168                        break
169                    fi
170                done
171            fi
172            # check in a few common install locations
173            if test x"${ac_cv_c_tkconfig}" = x ; then
174                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
175                        `ls -d ${prefix}/lib 2>/dev/null` \
176                        `ls -d /usr/local/lib 2>/dev/null` \
177                        `ls -d /usr/contrib/lib 2>/dev/null` \
178                        `ls -d /usr/lib 2>/dev/null` \
179                        ; do
180                    if test -f "$i/tkConfig.sh" ; then
181                        ac_cv_c_tkconfig=`(cd $i; pwd)`
182                        break
183                    fi
184                done
185            fi
186            # check in a few other private locations
187            if test x"${ac_cv_c_tkconfig}" = x ; then
188                for i in \
189                        ${srcdir}/../tk \
190                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
191                    if test -f "$i/unix/tkConfig.sh" ; then
192                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
193                        break
194                    fi
195                done
196            fi
197        ])
198        if test x"${ac_cv_c_tkconfig}" = x ; then
199            TK_BIN_DIR="# no Tk configs found"
200            AC_MSG_WARN("Cannot find Tk configuration definitions")
201            exit 0
202        else
203            no_tk=
204            TK_BIN_DIR=${ac_cv_c_tkconfig}
205            AC_MSG_RESULT([found $TK_BIN_DIR/tkConfig.sh])
206        fi
207    fi
208
209])
210
211#------------------------------------------------------------------------
212# TEA_LOAD_TCLCONFIG --
213#
214#       Load the tclConfig.sh file
215#
216# Arguments:
217#       
218#       Requires the following vars to be set:
219#               TCL_BIN_DIR
220#
221# Results:
222#
223#       Subst the following vars:
224#               TCL_BIN_DIR
225#               TCL_SRC_DIR
226#               TCL_LIB_FILE
227#
228#------------------------------------------------------------------------
229
230AC_DEFUN([TEA_LOAD_TCLCONFIG], [
231    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
232
233    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
234        AC_MSG_RESULT([loading])
235        . $TCL_BIN_DIR/tclConfig.sh
236    else
237        AC_MSG_RESULT([file not found])
238    fi
239
240    #
241    # If the TCL_BIN_DIR is the build directory (not the install directory),
242    # then set the common variable name to the value of the build variables.
243    # For example, the variable TCL_LIB_SPEC will be set to the value
244    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
245    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
246    # installed and uninstalled version of Tcl.
247    #
248
249    if test -f $TCL_BIN_DIR/Makefile ; then
250        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
251        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
252        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
253    fi
254
255    #
256    # eval is required to do the TCL_DBGX substitution
257    #
258
259    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
260    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
261    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
262
263    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
264    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
265    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
266
267    AC_SUBST(TCL_VERSION)
268    AC_SUBST(TCL_BIN_DIR)
269    AC_SUBST(TCL_SRC_DIR)
270
271    AC_SUBST(TCL_LIB_FILE)
272    AC_SUBST(TCL_LIB_FLAG)
273    AC_SUBST(TCL_LIB_SPEC)
274
275    AC_SUBST(TCL_STUB_LIB_FILE)
276    AC_SUBST(TCL_STUB_LIB_FLAG)
277    AC_SUBST(TCL_STUB_LIB_SPEC)
278
279    #AC_SUBST(TCL_DBGX)
280    AC_SUBST(TCL_LIBS)
281    AC_SUBST(TCL_DEFS)
282    AC_SUBST(TCL_EXTRA_CFLAGS)
283    AC_SUBST(TCL_LD_FLAGS)
284    AC_SUBST(TCL_SHLIB_LD_LIBS)
285    #AC_SUBST(TCL_BUILD_LIB_SPEC)
286    #AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
287])
288
289#------------------------------------------------------------------------
290# TEA_LOAD_TKCONFIG --
291#
292#       Load the tkConfig.sh file
293#
294# Arguments:
295#       
296#       Requires the following vars to be set:
297#               TK_BIN_DIR
298#
299# Results:
300#
301#       Sets the following vars that should be in tkConfig.sh:
302#               TK_BIN_DIR
303#------------------------------------------------------------------------
304
305AC_DEFUN([TEA_LOAD_TKCONFIG], [
306    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
307
308    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
309        AC_MSG_RESULT([loading])
310        . $TK_BIN_DIR/tkConfig.sh
311    else
312        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
313    fi
314
315    #
316    # If the TK_BIN_DIR is the build directory (not the install directory),
317    # then set the common variable name to the value of the build variables.
318    # For example, the variable TK_LIB_SPEC will be set to the value
319    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
320    # instead of TK_BUILD_LIB_SPEC since it will work with both an
321    # installed and uninstalled version of Tcl.
322    #
323
324    if test -f $TK_BIN_DIR/Makefile ; then
325        TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
326        TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
327        TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
328    fi
329
330    #
331    # eval is required to do the TK_DBGX substitution
332    #
333
334    eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
335    eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
336    eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
337
338    eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
339    eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
340    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
341
342    AC_SUBST(TK_VERSION)
343    AC_SUBST(TK_BIN_DIR)
344    AC_SUBST(TK_SRC_DIR)
345
346    AC_SUBST(TK_LIB_FILE)
347    AC_SUBST(TK_LIB_FLAG)
348    AC_SUBST(TK_LIB_SPEC)
349
350    AC_SUBST(TK_STUB_LIB_FILE)
351    AC_SUBST(TK_STUB_LIB_FLAG)
352    AC_SUBST(TK_STUB_LIB_SPEC)
353
354    AC_SUBST(TK_LIBS)
355    AC_SUBST(TK_XINCLUDES)
356])
357
358#------------------------------------------------------------------------
359# TEA_ENABLE_SHARED --
360#
361#       Allows the building of shared libraries
362#
363# Arguments:
364#       none
365#       
366# Results:
367#
368#       Adds the following arguments to configure:
369#               --enable-shared=yes|no
370#
371#       Defines the following vars:
372#               STATIC_BUILD    Used for building import/export libraries
373#                               on Windows.
374#
375#       Sets the following vars:
376#               SHARED_BUILD    Value of 1 or 0
377#------------------------------------------------------------------------
378
379AC_DEFUN([TEA_ENABLE_SHARED], [
380    AC_MSG_CHECKING([how to build libraries])
381    AC_ARG_ENABLE(shared,
382        [  --enable-shared         build and link with shared libraries [--enable-shared]],
383        [tcl_ok=$enableval], [tcl_ok=yes])
384
385    if test "${enable_shared+set}" = set; then
386        enableval="$enable_shared"
387        tcl_ok=$enableval
388    else
389        tcl_ok=yes
390    fi
391
392    if test "$tcl_ok" = "yes" ; then
393        AC_MSG_RESULT([shared])
394        SHARED_BUILD=1
395    else
396        AC_MSG_RESULT([static])
397        SHARED_BUILD=0
398        AC_DEFINE(STATIC_BUILD)
399    fi
400    AC_SUBST(SHARED_BUILD)
401])
402
403#------------------------------------------------------------------------
404# TEA_ENABLE_THREADS --
405#
406#       Specify if thread support should be enabled.  If "yes" is
407#       specified as an arg (optional), threads are enabled by default.
408#
409# Arguments:
410#       none
411#       
412# Results:
413#
414#       Adds the following arguments to configure:
415#               --enable-threads
416#
417#       Sets the following vars:
418#               THREADS_LIBS    Thread library(s)
419#
420#       Defines the following vars:
421#               TCL_THREADS
422#               _REENTRANT
423#
424#------------------------------------------------------------------------
425
426AC_DEFUN([TEA_ENABLE_THREADS], [
427    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
428        [tcl_ok=$enableval], [tcl_ok=$1])
429
430    if test "$tcl_ok" = "yes"; then
431        TCL_THREADS=1
432
433        if test "${TEA_PLATFORM}" != "windows" ; then
434            # We are always OK on Windows, so check what this platform wants.
435            AC_DEFINE(USE_THREAD_ALLOC)
436            AC_DEFINE(_REENTRANT)
437            AC_DEFINE(_THREAD_SAFE)
438            AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
439            if test "$tcl_ok" = "no"; then
440                # Check a little harder for __pthread_mutex_init in the
441                # same library, as some systems hide it there until
442                # pthread.h is defined.  We could alternatively do an
443                # AC_TRY_COMPILE with pthread.h, but that will work with
444                # libpthread really doesn't exist, like AIX 4.2.
445                # [Bug: 4359]
446                AC_CHECK_LIB(pthread, __pthread_mutex_init,
447                    tcl_ok=yes, tcl_ok=no)
448            fi
449           
450            if test "$tcl_ok" = "yes"; then
451                # The space is needed
452                THREADS_LIBS=" -lpthread"
453            else
454                AC_CHECK_LIB(pthreads, pthread_mutex_init,
455                    tcl_ok=yes, tcl_ok=no)
456                if test "$tcl_ok" = "yes"; then
457                    # The space is needed
458                    THREADS_LIBS=" -lpthreads"
459                else
460                    AC_CHECK_LIB(c, pthread_mutex_init,
461                        tcl_ok=yes, tcl_ok=no)
462                    if test "$tcl_ok" = "no"; then
463                        AC_CHECK_LIB(c_r, pthread_mutex_init,
464                            tcl_ok=yes, tcl_ok=no)
465                        if test "$tcl_ok" = "yes"; then
466                            # The space is needed
467                            THREADS_LIBS=" -pthread"
468                        else
469                            TCL_THREADS=0
470                            AC_MSG_WARN("Don t know how to find pthread lib on your system - thread support disabled")
471                        fi
472                    fi
473                fi
474            fi
475
476            # Does the pthread-implementation provide
477            # 'pthread_attr_setstacksize' ?
478
479            ac_saved_libs=$LIBS
480            LIBS="$LIBS $THREADS_LIBS"
481            AC_CHECK_FUNCS(pthread_attr_setstacksize)
482            LIBS=$ac_saved_libs
483            AC_CHECK_FUNCS(readdir_r)
484        fi
485    else
486        TCL_THREADS=0
487    fi
488    # Do checking message here to not mess up interleaved configure output
489    AC_MSG_CHECKING([for building with threads])
490    if test "${TCL_THREADS}" = "1"; then
491        AC_DEFINE(TCL_THREADS)
492        AC_MSG_RESULT([yes])
493    else
494        AC_MSG_RESULT([no (default)])
495    fi
496    # TCL_THREADS sanity checking.  See if our request for building with
497    # threads is the same as the way Tcl was built.  If not, warn the user.
498    case ${TCL_DEFS} in
499        *THREADS=1*)
500            if test "${TCL_THREADS}" = "0"; then
501                AC_MSG_WARN([
502    Building ${PACKAGE} without threads enabled, but building against a Tcl
503    that IS thread-enabled.])
504            fi
505            ;;
506        *)
507            if test "${TCL_THREADS}" = "1"; then
508                AC_MSG_WARN([
509    --enable-threads requested, but attempting building against a Tcl
510    that is NOT thread-enabled.])
511            fi
512            ;;
513    esac
514    AC_SUBST(TCL_THREADS)
515])
516
517#------------------------------------------------------------------------
518# TEA_ENABLE_SYMBOLS --
519#
520#       Specify if debugging symbols should be used
521#       Memory (TCL_MEM_DEBUG) debugging can also be enabled.
522#
523# Arguments:
524#       none
525#       
526#       Requires the following vars to be set:
527#               CFLAGS_DEBUG
528#               CFLAGS_OPTIMIZE
529#               LDFLAGS_DEBUG
530#               LDFLAGS_OPTIMIZE
531#       
532# Results:
533#
534#       Adds the following arguments to configure:
535#               --enable-symbols
536#
537#       Defines the following vars:
538#               CFLAGS_DEFAULT  Sets to CFLAGS_DEBUG if true
539#                               Sets to CFLAGS_OPTIMIZE if false
540#               LDFLAGS_DEFAULT Sets to LDFLAGS_DEBUG if true
541#                               Sets to LDFLAGS_OPTIMIZE if false
542#               DBGX            Debug library extension
543#
544#------------------------------------------------------------------------
545
546AC_DEFUN([TEA_ENABLE_SYMBOLS], [
547    dnl Make sure we are initialized
548    AC_REQUIRE([TEA_INIT])
549
550    if test "${TEA_PLATFORM}" = "windows" ; then
551        tcl_dbgx=d
552    else
553        tcl_dbgx=g
554    fi
555
556    AC_MSG_CHECKING([for build with symbols])
557    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
558    if test "$tcl_ok" = "no"; then
559        CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
560        LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
561        DBGX=""
562        TCL_DBGX=""
563        AC_MSG_RESULT([no])
564    else
565        CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
566        LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
567        DBGX=${tcl_dbgx}
568        TCL_DBGX=${tcl_dbgx}
569        if test "$tcl_ok" = "yes"; then
570            AC_MSG_RESULT([yes (standard debugging)])
571        fi
572    fi
573
574    AC_SUBST(TCL_DBGX)
575    AC_SUBST(CFLAGS_DEFAULT)
576    AC_SUBST(LDFLAGS_DEFAULT)
577
578    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
579        AC_DEFINE(TCL_MEM_DEBUG)
580    fi
581
582    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
583        if test "$tcl_ok" = "all"; then
584            AC_MSG_RESULT([enabled symbols mem debugging])
585        else
586            AC_MSG_RESULT([enabled $tcl_ok debugging])
587        fi
588    fi
589])
590
591#------------------------------------------------------------------------
592# TEA_ENABLE_LANGINFO --
593#
594#       Allows use of modern nl_langinfo check for better l10n.
595#       This is only relevant for Unix.
596#
597# Arguments:
598#       none
599#       
600# Results:
601#
602#       Adds the following arguments to configure:
603#               --enable-langinfo=yes|no (default is yes)
604#
605#       Defines the following vars:
606#               HAVE_LANGINFO   Triggers use of nl_langinfo if defined.
607#
608#------------------------------------------------------------------------
609
610AC_DEFUN([TEA_ENABLE_LANGINFO], [
611    AC_ARG_ENABLE(langinfo,
612        [  --enable-langinfo      use nl_langinfo if possible to determine
613                          encoding at startup, otherwise use old heuristic],
614        [langinfo_ok=$enableval], [langinfo_ok=yes])
615
616    HAVE_LANGINFO=0
617    if test "$langinfo_ok" = "yes"; then
618        if test "$langinfo_ok" = "yes"; then
619            AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
620        fi
621    fi
622    AC_MSG_CHECKING([whether to use nl_langinfo])
623    if test "$langinfo_ok" = "yes"; then
624        AC_TRY_COMPILE([#include <langinfo.h>],
625                [nl_langinfo(CODESET);],[langinfo_ok=yes],[langinfo_ok=no])
626        if test "$langinfo_ok" = "no"; then
627            langinfo_ok="no (could not compile with nl_langinfo)";
628        fi
629        if test "$langinfo_ok" = "yes"; then
630            AC_DEFINE(HAVE_LANGINFO)
631        fi
632    fi
633    AC_MSG_RESULT([$langinfo_ok])
634])
635
636#--------------------------------------------------------------------
637# TEA_CONFIG_CFLAGS
638#
639#       Try to determine the proper flags to pass to the compiler
640#       for building shared libraries and other such nonsense.
641#
642# Arguments:
643#       none
644#
645# Results:
646#
647#       Defines the following vars:
648#
649#       DL_OBJS -       Name of the object file that implements dynamic
650#                       loading for Tcl on this system.
651#       DL_LIBS -       Library file(s) to include in tclsh and other base
652#                       applications in order for the "load" command to work.
653#       LDFLAGS -      Flags to pass to the compiler when linking object
654#                       files into an executable application binary such
655#                       as tclsh.
656#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
657#                       that tell the run-time dynamic linker where to look
658#                       for shared libraries such as libtcl.so.  Depends on
659#                       the variable LIB_RUNTIME_DIR in the Makefile.
660#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
661#                       of a shared library (may request position-independent
662#                       code, among other things).
663#       SHLIB_LD -      Base command to use for combining object files
664#                       into a shared library.
665#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
666#                       creating shared libraries.  This symbol typically
667#                       goes at the end of the "ld" commands that build
668#                       shared libraries. The value of the symbol is
669#                       "${LIBS}" if all of the dependent libraries should
670#                       be specified when creating a shared library.  If
671#                       dependent libraries should not be specified (as on
672#                       SunOS 4.x, where they cause the link to fail, or in
673#                       general if Tcl and Tk aren't themselves shared
674#                       libraries), then this symbol has an empty string
675#                       as its value.
676#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
677#                       extensions.  An empty string means we don't know how
678#                       to use shared libraries on this platform.
679#       TCL_LIB_FILE -  Name of the file that contains the Tcl library, such
680#                       as libtcl7.8.so or libtcl7.8.a.
681#       TCL_LIB_SUFFIX -Specifies everything that comes after the "libtcl"
682#                       in the shared library name, using the $VERSION variable
683#                       to put the version in the right place.  This is used
684#                       by platforms that need non-standard library names.
685#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
686#                       to have a version after the .so, and ${VERSION}.a
687#                       on AIX, since the Tcl shared library needs to have
688#                       a .a extension whereas shared objects for loadable
689#                       extensions have a .so extension.  Defaults to
690#                       ${VERSION}${SHLIB_SUFFIX}.
691#       TCL_NEEDS_EXP_FILE -
692#                       1 means that an export file is needed to link to a
693#                       shared library.
694#       TCL_EXP_FILE -  The name of the installed export / import file which
695#                       should be used to link to the Tcl shared library.
696#                       Empty if Tcl is unshared.
697#       TCL_BUILD_EXP_FILE -
698#                       The name of the built export / import file which
699#                       should be used to link to the Tcl shared library.
700#                       Empty if Tcl is unshared.
701#       CFLAGS_DEBUG -
702#                       Flags used when running the compiler in debug mode
703#       CFLAGS_OPTIMIZE -
704#                       Flags used when running the compiler in optimize mode
705#       EXTRA_CFLAGS -
706#                       Extra CFLAGS to pass to the compiler
707#
708#       Subst's the following vars:
709#               DL_LIBS
710#               CFLAGS_DEBUG
711#               CFLAGS_OPTIMIZE
712#               CFLAGS_WARNING
713#
714#               STLIB_LD
715#               SHLIB_LD
716#               SHLIB_CFLAGS
717#               SHLIB_LDFLAGS
718#               LDFLAGS_DEBUG
719#               LDFLAGS_OPTIMIZE
720#--------------------------------------------------------------------
721
722AC_DEFUN([TEA_CONFIG_CFLAGS], [
723    dnl Make sure we are initialized
724    AC_REQUIRE([TEA_INIT])
725
726    # Step 0: Enable 64 bit support?
727
728    AC_MSG_CHECKING([if 64bit support is enabled])
729    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support (where applicable)], [do64bit=$enableval], [do64bit=no])
730    AC_MSG_RESULT([$do64bit])
731 
732    # Step 0.b: Enable Solaris 64 bit VIS support?
733
734    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
735    AC_ARG_ENABLE(64bit-vis,[  --enable-64bit-vis      enable 64bit Sparc VIS support], [do64bitVIS=$enableval], [do64bitVIS=no])
736    AC_MSG_RESULT([$do64bitVIS])
737
738    if test "$do64bitVIS" = "yes"; then
739        # Force 64bit on with VIS
740        do64bit=yes
741    fi
742
743    # Step 0.c: Cross-compiling options for Windows/CE builds?
744
745    if test "${TEA_PLATFORM}" = "windows" ; then
746        AC_MSG_CHECKING([if Windows/CE build is requested])
747        AC_ARG_ENABLE(wince,[  --enable-wince          enable Win/CE support (where applicable)], [doWince=$enableval], [doWince=no])
748        AC_MSG_RESULT($doWince)
749    fi
750
751    # Step 1: set the variable "system" to hold the name and version number
752    # for the system.  This can usually be done via the "uname" command, but
753    # there are a few systems, like Next, where this doesn't work.
754
755    AC_MSG_CHECKING([system version (for dynamic loading)])
756    if test -f /usr/lib/NextStep/software_version; then
757        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
758    else
759        system=`uname -s`-`uname -r`
760        if test "$?" -ne 0 ; then
761            AC_MSG_RESULT([unknown (can't find uname command)])
762            system=unknown
763        else
764            # Special check for weird MP-RAS system (uname returns weird
765            # results, and the version is kept in special file).
766       
767            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
768                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
769            fi
770            if test "`uname -s`" = "AIX" ; then
771                system=AIX-`uname -v`.`uname -r`
772            fi
773            if test "${TEA_PLATFORM}" = "windows" ; then
774                system=windows
775            fi
776            AC_MSG_RESULT([$system])
777        fi
778    fi
779
780    # Step 2: check for existence of -ldl library.  This is needed because
781    # Linux can use either -ldl or -ldld for dynamic loading.
782
783    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
784
785    # Step 3: set configuration options based on system name and version.
786
787    do64bit_ok=no
788    EXTRA_CFLAGS=""
789    TCL_EXPORT_FILE_SUFFIX=""
790    UNSHARED_LIB_SUFFIX=""
791    TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
792    ECHO_VERSION='`echo ${VERSION}`'
793    TCL_LIB_VERSIONS_OK=ok
794    CFLAGS_DEBUG=-g
795    CFLAGS_OPTIMIZE=-O
796    if test "$GCC" = "yes" ; then
797        CFLAGS_WARNING="-Wall -Wconversion -Wno-implicit-int"
798    else
799        CFLAGS_WARNING=""
800    fi
801    TCL_NEEDS_EXP_FILE=0
802    TCL_BUILD_EXP_FILE=""
803    TCL_EXP_FILE=""
804dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
805dnl AC_CHECK_TOOL(AR, ar, :)
806    AC_CHECK_PROG(AR, ar, ar)
807    STLIB_LD='${AR} cr'
808    case $system in
809        windows)
810            # This is a 2-stage check to make sure we have the 64-bit SDK
811            # We have to know where the SDK is installed.
812            if test "$do64bit" = "yes" ; then
813                if test "x${MSSDK}x" = "xx" ; then
814                    MSSDK="C:/Progra~1/Microsoft SDK"
815                fi
816                # In order to work in the tortured autoconf environment,
817                # we need to ensure that this path has no spaces
818                MSSDK=`cygpath -w -s "$MSSDK" | sed -e 's!\\\!/!g'`
819                if test ! -d "${MSSDK}/bin/win64" ; then
820                    AC_MSG_WARN("could not find 64-bit SDK to enable 64bit mode")
821                    do64bit="no"
822                else
823                    do64bit_ok="yes"
824                fi
825            fi
826
827            if test "$doWince" != "no" ; then
828                if test "$do64bit" = "yes" ; then
829                    AC_MSG_ERROR([Windows/CE and 64-bit builds incompatible])
830                fi
831                if test "$GCC" = "yes" ; then
832                    AC_MSG_ERROR([Windows/CE and GCC builds incompatible])
833                fi
834                TEA_PATH_CELIB
835                # set defaults
836                # Currently Tcl requires 300+
837                CEVERSION=300;    # could be 211 300 301 ...
838                TARGETCPU=ARM;    # could be ARM MIPS SH3 X86 ...
839                PLATFORM="Pocket PC 2002"
840                if test "$doWince" = "yes"; then
841                    doWince="300,ARM,ARM,Pocket PC 2002"
842                fi
843                eval `echo $doWince | awk -F "," '{ \
844                    if (length([$]1)) { printf "CEVERSION=%s\n", [$]1 }; \
845                    if (length([$]2)) { printf "TARGETCPU=%s\n", toupper([$]2) }; \
846                    if (length([$]3)) { printf "ARCH=%s\n", toupper([$]3) }; \
847                    if (length([$]4)) { printf "PLATFORM=%s\n", [$]4 }; \
848                    }'`
849                OSVERSION=WCE$CEVERSION;
850                if test "x${ARCH}" = "x" ; then
851                    ARCH=$TARGETCPU;  # could be ARM MIPS SH3 X86 X86EM ...
852                fi
853                if test "x${WCEROOT}" = "x" ; then
854                    WCEROOT="C:/Program Files/Microsoft eMbedded Tools"
855                fi
856                if test "x${SDKROOT}" = "x" ; then
857                    SDKROOT="C:/Windows CE Tools"
858                fi
859                # In order to work in the tortured autoconf environment,
860                # we need to ensure that this path has no spaces
861                WCEROOT=`cygpath -w -s "$WCEROOT" | sed -e 's!\\\!/!g'`
862                SDKROOT=`cygpath -w -s "$SDKROOT" | sed -e 's!\\\!/!g'`
863                CELIB_DIR=`cygpath -w -s "$CELIB_DIR" | sed -e 's!\\\!/!g'`
864                if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \
865                    -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
866                    AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]])
867                    doWince="no"
868                else
869                    CEINCLUDE=`cygpath -w -s "${SDKROOT}/${OSVERSION}/${PLATFORM}/include" | sed -e 's!\\\!/!g'`
870                    CELIBPATH=`cygpath -w -s "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" | sed -e 's!\\\!/!g'`
871                fi
872            fi
873
874            if test "$GCC" != "yes" ; then
875                if test "${SHARED_BUILD}" = "0" ; then
876                    runtime=-MT
877                else
878                    runtime=-MD
879                fi
880
881                if test "$do64bit" = "yes" ; then
882                    # All this magic is necessary for the Win64 SDK RC1 - hobbs
883                    export CC="${MSSDK}/Bin/Win64/cl.exe \
884                        -I${MSSDK}/Include/prerelease \
885                        -I${MSSDK}/Include/Win64/crt \
886                        -I${MSSDK}/Include"
887                    export RC="${MSSDK}/bin/rc.exe"
888                    export lflags="-MACHINE:IA64 -LIBPATH:${MSSDK}/Lib/IA64 \
889                        -LIBPATH:${MSSDK}/Lib/Prerelease/IA64"
890                    export STLIB_LD="${MSSDK}/bin/win64/lib.exe -nologo ${lflags}"
891                    export LINKBIN="${MSSDK}/bin/win64/link.exe ${lflags}"
892                    CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d"
893                    CFLAGS_OPTIMIZE="-nologo -O2 -Gs -W2 ${runtime}"
894                elif test "$doWince" != "no" ; then
895                    if test "${TARGETCPU}" = "X86"; then
896                        CC="${WCEROOT}/EVC/${OSVERSION}/bin/cl.exe -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
897                    else
898                        CC="${WCEROOT}/EVC/${OSVERSION}/bin/cl${TARGETCPU}.exe -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
899                    fi
900                    RC="${WCEROOT}/Common/EVC/bin/rc.exe"
901                    cpulower=`echo ${TARGETCPU} | awk '{print tolower([$]0)}'`
902                    defs="${TARGETCPU} _${TARGETCPU}_ ${cpulower} _${cpulower}_ POCKET_SIZE PALM_SIZE _MT _DLL _WINDOWS"
903                    for i in $defs ; do
904                        AC_DEFINE_UNQUOTED($i)
905                    done
906                    AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION)
907                    AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION)
908                    CFLAGS_DEBUG="-nologo -Zi -Od"
909                    CFLAGS_OPTIMIZE="-nologo -Ox"
910                    lflags="-MACHINE:${TARGETCPU} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,3.00"
911                    STLIB_LD="${WCEROOT}/EVC/${OSVERSION}/bin/lib.exe -nologo ${lflags}"
912                    LINKBIN="${WCEROOT}/EVC/${OSVERSION}/bin/link.exe ${lflags}"
913                else
914                    RC="rc"
915                    STLIB_LD="lib -nologo"
916                    LINKBIN="link -link50compat"
917                    CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d"
918                    CFLAGS_OPTIMIZE="-nologo -O2 -Gs -GD -W2 ${runtime}"
919                fi
920            fi
921
922            if test "$GCC" = "yes"; then
923                # mingw gcc mode
924                RC="windres"
925                CFLAGS_DEBUG="-g"
926                CFLAGS_OPTIMIZE="-O2"
927                SHLIB_LD="$CC -shared"
928                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
929                LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}"
930                LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}"
931            else
932                SHLIB_LD="${LINKBIN} -dll -nologo"
933                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.lib'
934                EXTRA_CFLAGS="-YX"
935                PATHTYPE=-w
936                # For information on what debugtype is most useful, see:
937                # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp
938                # This essentially turns it all on.
939                LDFLAGS_DEBUG="-debug:full -debugtype:both -warn:2"
940                LDFLAGS_OPTIMIZE="-release"
941                if test "$doWince" != "no" ; then
942                    LDFLAGS_CONSOLE="-link ${lflags}"
943                    LDFLAGS_WINDOW=${LDFLAGS_CONSOLE}
944                else
945                    LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
946                    LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
947                fi
948            fi
949
950            SHLIB_LD_LIBS='${LIBS}'
951            SHLIB_SUFFIX=".dll"
952            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.dll'
953
954            TCL_LIB_VERSIONS_OK=nodots
955            # Bogus to avoid getting this turned off
956            DL_OBJS="tclLoadNone.obj"
957            ;;
958        AIX-*)
959            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
960                # AIX requires the _r compiler when gcc isn't being used
961                if test "${CC}" != "cc_r" ; then
962                    CC=${CC}_r
963                fi
964                AC_MSG_RESULT([Using $CC for compiling with threads])
965            fi
966            LIBS="$LIBS -lc"
967            SHLIB_CFLAGS=""
968            SHLIB_SUFFIX=".so"
969            SHLIB_LD_LIBS='${LIBS}'
970
971            DL_OBJS="tclLoadDl.o"
972            LDFLAGS=""
973
974            # AIX v<=4.1 has some different flags than 4.2+
975            if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
976                #LIBOBJS="$LIBOBJS tclLoadAix.o"
977                AC_LIBOBJ([tclLoadAix])
978                DL_LIBS="-lld"
979            fi
980
981            # Check to enable 64-bit flags for compiler/linker on AIX 4+
982            if test "$do64bit" = "yes" -a "`uname -v`" -gt "3" ; then
983                if test "$GCC" = "yes" ; then
984                    AC_MSG_WARN("64bit mode not supported with GCC on $system")
985                else
986                    do64bit_ok=yes
987                    EXTRA_CFLAGS="-q64"
988                    LDFLAGS="-q64"
989                    RANLIB="${RANLIB} -X64"
990                    AR="${AR} -X64"
991                    SHLIB_LDFLAGS="-b64"
992                fi
993            fi
994
995            if test "`uname -m`" = "ia64" ; then
996                # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
997                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
998                # AIX-5 has dl* in libc.so
999                DL_LIBS=""
1000                if test "$GCC" = "yes" ; then
1001                    LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1002                else
1003                    LD_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
1004                fi
1005            else
1006                SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry ${SHLIB_LD_FLAGS}"
1007                DL_LIBS="-ldl"
1008                LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1009                TCL_NEEDS_EXP_FILE=1
1010                TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
1011            fi
1012
1013            # On AIX <=v4 systems, libbsd.a has to be linked in to support
1014            # non-blocking file IO.  This library has to be linked in after
1015            # the MATH_LIBS or it breaks the pow() function.  The way to
1016            # insure proper sequencing, is to add it to the tail of MATH_LIBS.
1017            # This library also supplies gettimeofday.
1018            #
1019            # AIX does not have a timezone field in struct tm. When the AIX
1020            # bsd library is used, the timezone global and the gettimeofday
1021            # methods are to be avoided for timezone deduction instead, we
1022            # deduce the timezone by comparing the localtime result on a
1023            # known GMT value.
1024
1025            AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
1026            if test $libbsd = yes; then
1027                MATH_LIBS="$MATH_LIBS -lbsd"
1028                AC_DEFINE(USE_DELTA_FOR_TZ)
1029            fi
1030            ;;
1031        BSD/OS-2.1*|BSD/OS-3*)
1032            SHLIB_CFLAGS=""
1033            SHLIB_LD="shlicc -r"
1034            SHLIB_LD_LIBS='${LIBS}'
1035            SHLIB_SUFFIX=".so"
1036            DL_OBJS="tclLoadDl.o"
1037            DL_LIBS="-ldl"
1038            LDFLAGS=""
1039            LD_SEARCH_FLAGS=""
1040            ;;
1041        BSD/OS-4.*)
1042            SHLIB_CFLAGS="-export-dynamic -fPIC"
1043            SHLIB_LD="cc -shared"
1044            SHLIB_LD_LIBS='${LIBS}'
1045            SHLIB_SUFFIX=".so"
1046            DL_OBJS="tclLoadDl.o"
1047            DL_LIBS="-ldl"
1048            LDFLAGS="-export-dynamic"
1049            LD_SEARCH_FLAGS=""
1050            ;;
1051        dgux*)
1052            SHLIB_CFLAGS="-K PIC"
1053            SHLIB_LD="cc -G"
1054            SHLIB_LD_LIBS=""
1055            SHLIB_SUFFIX=".so"
1056            DL_OBJS="tclLoadDl.o"
1057            DL_LIBS="-ldl"
1058            LDFLAGS=""
1059            LD_SEARCH_FLAGS=""
1060            ;;
1061        HP-UX-*.11.*)
1062            # Use updated header definitions where possible
1063            AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
1064
1065            SHLIB_SUFFIX=".sl"
1066            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1067            if test "$tcl_ok" = yes; then
1068                SHLIB_CFLAGS="+z"
1069                SHLIB_LD="ld -b"
1070                SHLIB_LD_LIBS='${LIBS}'
1071                DL_OBJS="tclLoadShl.o"
1072                DL_LIBS="-ldld"
1073                LDFLAGS="-Wl,-E"
1074                LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1075            fi
1076
1077            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
1078            #EXTRA_CFLAGS="+DAportable"
1079
1080            # Check to enable 64-bit flags for compiler/linker
1081            if test "$do64bit" = "yes" ; then
1082                if test "$GCC" = "yes" ; then
1083                    hpux_arch=`${CC} -dumpmachine`
1084                    case $hpux_arch in
1085                        hppa64*)
1086                            # 64-bit gcc in use.  Fix flags for GNU ld.
1087                            do64bit_ok=yes
1088                            SHLIB_LD="${CC} -shared"
1089                            SHLIB_LD_LIBS=""
1090                            LD_SEARCH_FLAGS=''
1091                            ;;
1092                        *)
1093                            AC_MSG_WARN("64bit mode not supported with GCC on $system")
1094                            ;;
1095                    esac
1096                else
1097                    do64bit_ok=yes
1098                    if test "`uname -m`" = "ia64" ; then
1099                        EXTRA_CFLAGS="+DD64"
1100                        LDFLAGS="+DD64 $LDFLAGS"
1101                    else
1102                        EXTRA_CFLAGS="+DA2.0W"
1103                        LDFLAGS="+DA2.0W $LDFLAGS"
1104                    fi
1105                fi
1106            fi
1107            ;;
1108        HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
1109            SHLIB_SUFFIX=".sl"
1110            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1111            if test "$tcl_ok" = yes; then
1112                SHLIB_CFLAGS="+z"
1113                SHLIB_LD="ld -b"
1114                SHLIB_LD_LIBS=""
1115                DL_OBJS="tclLoadShl.o"
1116                DL_LIBS="-ldld"
1117                LDFLAGS="-Wl,-E"
1118                LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1119            fi
1120            ;;
1121        IRIX-4.*)
1122            SHLIB_CFLAGS="-G 0"
1123            SHLIB_SUFFIX=".a"
1124            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1125            SHLIB_LD_LIBS='${LIBS}'
1126            DL_OBJS="tclLoadAout.o"
1127            DL_LIBS=""
1128            LDFLAGS="-Wl,-D,08000000"
1129            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1130            SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1131            ;;
1132        IRIX-5.*)
1133            SHLIB_CFLAGS=""
1134            SHLIB_LD="ld -shared -rdata_shared"
1135            SHLIB_LD_LIBS='${LIBS}'
1136            SHLIB_SUFFIX=".so"
1137            DL_OBJS="tclLoadDl.o"
1138            DL_LIBS=""
1139            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1140            EXTRA_CFLAGS=""
1141            LDFLAGS=""
1142            ;;
1143        IRIX-6.*|IRIX64-6.5*)
1144            SHLIB_CFLAGS=""
1145            SHLIB_LD="ld -n32 -shared -rdata_shared"
1146            SHLIB_LD_LIBS='${LIBS}'
1147            SHLIB_SUFFIX=".so"
1148            DL_OBJS="tclLoadDl.o"
1149            DL_LIBS=""
1150            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1151            if test "$GCC" = "yes" ; then
1152                EXTRA_CFLAGS="-mabi=n32"
1153                LDFLAGS="-mabi=n32"
1154            else
1155                case $system in
1156                    IRIX-6.3)
1157                        # Use to build 6.2 compatible binaries on 6.3.
1158                        EXTRA_CFLAGS="-n32 -D_OLD_TERMIOS"
1159                        ;;
1160                    *)
1161                        EXTRA_CFLAGS="-n32"
1162                        ;;
1163                esac
1164                LDFLAGS="-n32"
1165            fi
1166            ;;
1167        IRIX64-6.*)
1168            SHLIB_CFLAGS=""
1169            SHLIB_LD="ld -n32 -shared -rdata_shared"
1170            SHLIB_LD_LIBS='${LIBS}'
1171            SHLIB_SUFFIX=".so"
1172            DL_OBJS="tclLoadDl.o"
1173            DL_LIBS=""
1174            LDFLAGS=""
1175            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1176
1177            # Check to enable 64-bit flags for compiler/linker
1178
1179            if test "$do64bit" = "yes" ; then
1180                if test "$GCC" = "yes" ; then
1181                    AC_MSG_WARN([64bit mode not supported by gcc])
1182                else
1183                    do64bit_ok=yes
1184                    SHLIB_LD="ld -64 -shared -rdata_shared"
1185                    EXTRA_CFLAGS="-64"
1186                    LDFLAGS="-64"
1187                fi
1188            fi
1189            ;;
1190        Linux*)
1191            SHLIB_CFLAGS="-fPIC"
1192            SHLIB_LD_LIBS='${LIBS}'
1193            SHLIB_SUFFIX=".so"
1194
1195            # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
1196            # when you inline the string and math operations.  Turn this off to
1197            # get rid of the warnings.
1198
1199            #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
1200
1201            if test "$have_dl" = yes; then
1202                SHLIB_LD="${CC} -shared"
1203                DL_OBJS="tclLoadDl.o"
1204                DL_LIBS="-ldl"
1205                LDFLAGS="-rdynamic"
1206                LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1207            else
1208                AC_CHECK_HEADER(dld.h, [
1209                    SHLIB_LD="ld -shared"
1210                    DL_OBJS="tclLoadDld.o"
1211                    DL_LIBS="-ldld"
1212                    LDFLAGS=""
1213                    LD_SEARCH_FLAGS=""])
1214            fi
1215            if test "`uname -m`" = "alpha" ; then
1216                EXTRA_CFLAGS="-mieee"
1217            fi
1218
1219            # The combo of gcc + glibc has a bug related
1220            # to inlining of functions like strtod(). The
1221            # -fno-builtin flag should address this problem
1222            # but it does not work. The -fno-inline flag
1223            # is kind of overkill but it works.
1224            # Disable inlining only when one of the
1225            # files in compat/*.c is being linked in.
1226            if test x"${USE_COMPAT}" != x ; then
1227                EXTRA_CFLAGS="${EXTRA_CFLAGS} -fno-inline"
1228            fi
1229
1230            ;;
1231        GNU*)
1232            SHLIB_CFLAGS="-fPIC"
1233            SHLIB_LD_LIBS='${LIBS}'
1234            SHLIB_SUFFIX=".so"
1235
1236            if test "$have_dl" = yes; then
1237                SHLIB_LD="${CC} -shared"
1238                DL_OBJS=""
1239                DL_LIBS="-ldl"
1240                LDFLAGS="-rdynamic"
1241                LD_SEARCH_FLAGS=""
1242            else
1243                AC_CHECK_HEADER(dld.h, [
1244                    SHLIB_LD="ld -shared"
1245                    DL_OBJS=""
1246                    DL_LIBS="-ldld"
1247                    LDFLAGS=""
1248                    LD_SEARCH_FLAGS=""])
1249            fi
1250            if test "`uname -m`" = "alpha" ; then
1251                EXTRA_CFLAGS="-mieee"
1252            fi
1253            ;;
1254        MP-RAS-02*)
1255            SHLIB_CFLAGS="-K PIC"
1256            SHLIB_LD="cc -G"
1257            SHLIB_LD_LIBS=""
1258            SHLIB_SUFFIX=".so"
1259            DL_OBJS="tclLoadDl.o"
1260            DL_LIBS="-ldl"
1261            LDFLAGS=""
1262            LD_SEARCH_FLAGS=""
1263            ;;
1264        MP-RAS-*)
1265            SHLIB_CFLAGS="-K PIC"
1266            SHLIB_LD="cc -G"
1267            SHLIB_LD_LIBS=""
1268            SHLIB_SUFFIX=".so"
1269            DL_OBJS="tclLoadDl.o"
1270            DL_LIBS="-ldl"
1271            LDFLAGS="-Wl,-Bexport"
1272            LD_SEARCH_FLAGS=""
1273            ;;
1274        NetBSD-*|FreeBSD-[[1-2]].*|OpenBSD-*)
1275            # Not available on all versions:  check for include file.
1276            AC_CHECK_HEADER(dlfcn.h, [
1277                # NetBSD/SPARC needs -fPIC, -fpic will not do.
1278                SHLIB_CFLAGS="-fPIC"
1279                SHLIB_LD="ld -Bshareable -x"
1280                SHLIB_LD_LIBS=""
1281                SHLIB_SUFFIX=".so"
1282                DL_OBJS="tclLoadDl.o"
1283                DL_LIBS=""
1284                LDFLAGS=""
1285                LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1286                AC_MSG_CHECKING([for ELF])
1287                AC_EGREP_CPP(yes, [
1288#ifdef __ELF__
1289        yes
1290#endif
1291                ],
1292                    AC_MSG_RESULT([yes])
1293                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so',
1294                    AC_MSG_RESULT([no])
1295                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1296                )
1297            ], [
1298                SHLIB_CFLAGS=""
1299                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
1300                SHLIB_LD_LIBS='${LIBS}'
1301                SHLIB_SUFFIX=".a"
1302                DL_OBJS="tclLoadAout.o"
1303                DL_LIBS=""
1304                LDFLAGS=""
1305                LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1306                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1307            ])
1308
1309            # FreeBSD doesn't handle version numbers with dots.
1310
1311            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1312            TCL_LIB_VERSIONS_OK=nodots
1313            ;;
1314        FreeBSD-*)
1315            # FreeBSD 3.* and greater have ELF.
1316            SHLIB_CFLAGS="-fPIC"
1317            SHLIB_LD="ld -Bshareable -x"
1318            SHLIB_LD_LIBS='${LIBS}'
1319            SHLIB_SUFFIX=".so"
1320            DL_OBJS="tclLoadDl.o"
1321            DL_LIBS=""
1322            LDFLAGS="-export-dynamic"
1323            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1324            if test "${TCL_THREADS}" = "1" ; then
1325                # The -pthread needs to go in the CFLAGS, not LIBS
1326                LIBS=`echo $LIBS | sed s/-pthread//`
1327                EXTRA_CFLAGS="-pthread"
1328                LDFLAGS="$LDFLAGS -pthread"
1329            fi
1330            case $system in
1331            FreeBSD-3.*)
1332                # FreeBSD-3 doesn't handle version numbers with dots.
1333                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1334                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
1335                TCL_LIB_VERSIONS_OK=nodots
1336                ;;
1337            esac
1338            ;;
1339        Rhapsody-*|Darwin-*)
1340            SHLIB_CFLAGS="-fno-common"
1341            SHLIB_LD="cc -dynamiclib \${LDFLAGS}"
1342            TCL_SHLIB_LD_EXTRAS="-compatibility_version ${TCL_MAJOR_VERSION} -current_version \${VERSION} -install_name \${LIB_RUNTIME_DIR}/\${TCL_LIB_FILE} -prebind -seg1addr 0xa000000"
1343            SHLIB_LD_LIBS='${LIBS}'
1344            SHLIB_SUFFIX=".dylib"
1345            DL_OBJS="tclLoadDyld.o"
1346            DL_LIBS=""
1347            LDFLAGS="-prebind"
1348            LD_SEARCH_FLAGS=""
1349            CFLAGS_OPTIMIZE="-O3"
1350            EXTRA_CFLAGS="-arch ppc -pipe"
1351            ;;
1352        NEXTSTEP-*)
1353            SHLIB_CFLAGS=""
1354            SHLIB_LD="cc -nostdlib -r"
1355            SHLIB_LD_LIBS=""
1356            SHLIB_SUFFIX=".so"
1357            DL_OBJS="tclLoadNext.o"
1358            DL_LIBS=""
1359            LDFLAGS=""
1360            LD_SEARCH_FLAGS=""
1361            ;;
1362        OS/390-*)
1363            CFLAGS_OPTIMIZE=""      # Optimizer is buggy
1364            AC_DEFINE(_OE_SOCKETS)  # needed in sys/socket.h
1365            ;;     
1366        OSF1-1.0|OSF1-1.1|OSF1-1.2)
1367            # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
1368            SHLIB_CFLAGS=""
1369            # Hack: make package name same as library name
1370            SHLIB_LD='ld -R -export $@:'
1371            SHLIB_LD_LIBS=""
1372            SHLIB_SUFFIX=".so"
1373            DL_OBJS="tclLoadOSF.o"
1374            DL_LIBS=""
1375            LDFLAGS=""
1376            LD_SEARCH_FLAGS=""
1377            ;;
1378        OSF1-1.*)
1379            # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
1380            SHLIB_CFLAGS="-fPIC"
1381            if test "$SHARED_BUILD" = "1" ; then
1382                SHLIB_LD="ld -shared"
1383            else
1384                SHLIB_LD="ld -non_shared"
1385            fi
1386            SHLIB_LD_LIBS=""
1387            SHLIB_SUFFIX=".so"
1388            DL_OBJS="tclLoadDl.o"
1389            DL_LIBS=""
1390            LDFLAGS=""
1391            LD_SEARCH_FLAGS=""
1392            ;;
1393        OSF1-V*)
1394            # Digital OSF/1
1395            SHLIB_CFLAGS=""
1396            if test "$SHARED_BUILD" = "1" ; then
1397                SHLIB_LD='ld -shared -expect_unresolved "*"'
1398            else
1399                SHLIB_LD='ld -non_shared -expect_unresolved "*"'
1400            fi
1401            SHLIB_LD_LIBS=""
1402            SHLIB_SUFFIX=".so"
1403            DL_OBJS="tclLoadDl.o"
1404            DL_LIBS=""
1405            LDFLAGS=""
1406            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1407            if test "$GCC" != "yes" ; then
1408                EXTRA_CFLAGS="-DHAVE_TZSET -std1"
1409            fi
1410            # see pthread_intro(3) for pthread support on osf1, k.furukawa
1411            if test "${TCL_THREADS}" = "1" ; then
1412                EXTRA_CFLAGS="${EXTRA_CFLAGS} -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
1413                EXTRA_CFLAGS="${EXTRA_CFLAGS} -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
1414                LIBS=`echo $LIBS | sed s/-lpthreads//`
1415                if test "$GCC" = "yes" ; then
1416                    LIBS="$LIBS -lpthread -lmach -lexc"
1417                else
1418                    EXTRA_CFLAGS="${EXTRA_CFLAGS} -pthread"
1419                    LDFLAGS="-pthread"
1420                fi
1421            fi
1422
1423            ;;
1424        QNX-6*)
1425            # QNX RTP
1426            # This may work for all QNX, but it was only reported for v6.
1427            SHLIB_CFLAGS="-fPIC"
1428            SHLIB_LD="ld -Bshareable -x"
1429            SHLIB_LD_LIBS=""
1430            SHLIB_SUFFIX=".so"
1431            DL_OBJS="tclLoadDl.o"
1432            # dlopen is in -lc on QNX
1433            DL_LIBS=""
1434            LDFLAGS=""
1435            LD_SEARCH_FLAGS=""
1436            ;;
1437        RISCos-*)
1438            SHLIB_CFLAGS="-G 0"
1439            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1440            SHLIB_LD_LIBS='${LIBS}'
1441            SHLIB_SUFFIX=".a"
1442            DL_OBJS="tclLoadAout.o"
1443            DL_LIBS=""
1444            LDFLAGS="-Wl,-D,08000000"
1445            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1446            ;;
1447        SCO_SV-3.2*)
1448            # Note, dlopen is available only on SCO 3.2.5 and greater. However,
1449            # this test works, since "uname -s" was non-standard in 3.2.4 and
1450            # below.
1451            if test "$GCC" = "yes" ; then
1452                SHLIB_CFLAGS="-fPIC -melf"
1453                LDFLAGS="-melf -Wl,-Bexport"
1454            else
1455                SHLIB_CFLAGS="-Kpic -belf"
1456                LDFLAGS="-belf -Wl,-Bexport"
1457            fi
1458            SHLIB_LD="ld -G"
1459            SHLIB_LD_LIBS=""
1460            SHLIB_SUFFIX=".so"
1461            DL_OBJS="tclLoadDl.o"
1462            DL_LIBS=""
1463            LD_SEARCH_FLAGS=""
1464            ;;
1465        SINIX*5.4*)
1466            SHLIB_CFLAGS="-K PIC"
1467            SHLIB_LD="cc -G"
1468            SHLIB_LD_LIBS=""
1469            SHLIB_SUFFIX=".so"
1470            DL_OBJS="tclLoadDl.o"
1471            DL_LIBS="-ldl"
1472            LDFLAGS=""
1473            LD_SEARCH_FLAGS=""
1474            ;;
1475        SunOS-4*)
1476            SHLIB_CFLAGS="-PIC"
1477            SHLIB_LD="ld"
1478            SHLIB_LD_LIBS=""
1479            SHLIB_SUFFIX=".so"
1480            DL_OBJS="tclLoadDl.o"
1481            DL_LIBS="-ldl"
1482            LDFLAGS=""
1483            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1484
1485            # SunOS can't handle version numbers with dots in them in library
1486            # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
1487            # requires an extra version number at the end of .so file names.
1488            # So, the library has to have a name like libtcl75.so.1.0
1489
1490            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1491            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1492            TCL_LIB_VERSIONS_OK=nodots
1493            ;;
1494        SunOS-5.[[0-6]]*)
1495
1496            # Note: If _REENTRANT isn't defined, then Solaris
1497            # won't define thread-safe library routines.
1498
1499            AC_DEFINE(_REENTRANT)
1500            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1501
1502            SHLIB_CFLAGS="-KPIC"
1503
1504            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1505            # symbols when dynamically loaded into tclsh.
1506
1507            SHLIB_LD_LIBS='${LIBS}'
1508            SHLIB_SUFFIX=".so"
1509            DL_OBJS="tclLoadDl.o"
1510            DL_LIBS="-ldl"
1511            LDFLAGS=""
1512            if test "$GCC" = "yes" ; then
1513                SHLIB_LD="$CC -shared"
1514                LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1515            else
1516                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1517                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1518            fi
1519            ;;
1520        SunOS-5*)
1521
1522            # Note: If _REENTRANT isn't defined, then Solaris
1523            # won't define thread-safe library routines.
1524
1525            AC_DEFINE(_REENTRANT)
1526            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1527
1528            SHLIB_CFLAGS="-KPIC"
1529            LDFLAGS=""
1530   
1531            # Check to enable 64-bit flags for compiler/linker
1532            if test "$do64bit" = "yes" ; then
1533                arch=`isainfo`
1534                if test "$arch" = "sparcv9 sparc" ; then
1535                        if test "$GCC" = "yes" ; then
1536                            AC_MSG_WARN("64bit mode not supported with GCC on $system")
1537                        else
1538                            do64bit_ok=yes
1539                            if test "$do64bitVIS" = "yes" ; then
1540                                EXTRA_CFLAGS="-xarch=v9a"
1541                                LDFLAGS="-xarch=v9a"
1542                            else
1543                                EXTRA_CFLAGS="-xarch=v9"
1544                                LDFLAGS="-xarch=v9"
1545                            fi
1546                        fi
1547                else
1548                    AC_MSG_WARN("64bit mode only supported sparcv9 system")
1549                fi
1550            fi
1551           
1552            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1553            # symbols when dynamically loaded into tclsh.
1554
1555            SHLIB_LD_LIBS='${LIBS}'
1556            SHLIB_SUFFIX=".so"
1557            DL_OBJS="tclLoadDl.o"
1558            DL_LIBS="-ldl"
1559            if test "$GCC" = "yes" ; then
1560                SHLIB_LD="$CC -shared"
1561                LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1562            else
1563                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1564                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1565            fi
1566            ;;
1567        ULTRIX-4.*)
1568            SHLIB_CFLAGS="-G 0"
1569            SHLIB_SUFFIX=".a"
1570            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1571            SHLIB_LD_LIBS='${LIBS}'
1572            DL_OBJS="tclLoadAout.o"
1573            DL_LIBS=""
1574            LDFLAGS="-Wl,-D,08000000"
1575            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1576            if test "$GCC" != "yes" ; then
1577                EXTRA_CFLAGS="-DHAVE_TZSET -std1"
1578            fi
1579            ;;
1580        UNIX_SV* | UnixWare-5*)
1581            SHLIB_CFLAGS="-KPIC"
1582            SHLIB_LD="cc -G"
1583            SHLIB_LD_LIBS=""
1584            SHLIB_SUFFIX=".so"
1585            DL_OBJS="tclLoadDl.o"
1586            DL_LIBS="-ldl"
1587            # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
1588            # that don't grok the -Bexport option.  Test that it does.
1589            hold_ldflags=$LDFLAGS
1590            AC_MSG_CHECKING([for ld accepts -Bexport flag])
1591            LDFLAGS="${LDFLAGS} -Wl,-Bexport"
1592            AC_TRY_LINK(, [int i;], found=yes, found=no)
1593            LDFLAGS=$hold_ldflags
1594            AC_MSG_RESULT([$found])
1595            if test $found = yes; then
1596            LDFLAGS="-Wl,-Bexport"
1597            else
1598            LDFLAGS=""
1599            fi
1600            LD_SEARCH_FLAGS=""
1601            ;;
1602    esac
1603
1604    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
1605    AC_MSG_WARN("64bit support being disabled -- don\'t know magic for this platform")
1606    fi
1607
1608    # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
1609    # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
1610    # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
1611    # to determine which of several header files defines the a.out file
1612    # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
1613    # support only a file format that is more or less version-7-compatible.
1614    # In particular,
1615    #   - a.out files must begin with `struct exec'.
1616    #   - the N_TXTOFF on the `struct exec' must compute the seek address
1617    #     of the text segment
1618    #   - The `struct exec' must contain a_magic, a_text, a_data, a_bss
1619    #     and a_entry fields.
1620    # The following compilation should succeed if and only if either sys/exec.h
1621    # or a.out.h is usable for the purpose.
1622    #
1623    # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
1624    # `struct exec' includes a second header that contains information that
1625    # duplicates the v7 fields that are needed.
1626
1627    if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
1628        AC_MSG_CHECKING([sys/exec.h])
1629        AC_TRY_COMPILE([#include <sys/exec.h>],[
1630            struct exec foo;
1631            unsigned long seek;
1632            int flag;
1633#if defined(__mips) || defined(mips)
1634            seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1635#else
1636            seek = N_TXTOFF (foo);
1637#endif
1638            flag = (foo.a_magic == OMAGIC);
1639            return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1640    ], tcl_ok=usable, tcl_ok=unusable)
1641        AC_MSG_RESULT([$tcl_ok])
1642        if test $tcl_ok = usable; then
1643            AC_DEFINE(USE_SYS_EXEC_H)
1644        else
1645            AC_MSG_CHECKING([a.out.h])
1646            AC_TRY_COMPILE([#include <a.out.h>],[
1647                struct exec foo;
1648                unsigned long seek;
1649                int flag;
1650#if defined(__mips) || defined(mips)
1651                seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1652#else
1653                seek = N_TXTOFF (foo);
1654#endif
1655                flag = (foo.a_magic == OMAGIC);
1656                return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1657            ], tcl_ok=usable, tcl_ok=unusable)
1658            AC_MSG_RESULT([$tcl_ok])
1659            if test $tcl_ok = usable; then
1660                AC_DEFINE(USE_A_OUT_H)
1661            else
1662                AC_MSG_CHECKING([sys/exec_aout.h])
1663                AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
1664                    struct exec foo;
1665                    unsigned long seek;
1666                    int flag;
1667#if defined(__mips) || defined(mips)
1668                    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1669#else
1670                    seek = N_TXTOFF (foo);
1671#endif
1672                    flag = (foo.a_midmag == OMAGIC);
1673                    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1674                ], tcl_ok=usable, tcl_ok=unusable)
1675                AC_MSG_RESULT([$tcl_ok])
1676                if test $tcl_ok = usable; then
1677                    AC_DEFINE(USE_SYS_EXEC_AOUT_H)
1678                else
1679                    DL_OBJS=""
1680                fi
1681            fi
1682        fi
1683    fi
1684
1685    # Step 5: disable dynamic loading if requested via a command-line switch.
1686
1687    AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
1688        [tcl_ok=$enableval], [tcl_ok=yes])
1689    if test "$tcl_ok" = "no"; then
1690        DL_OBJS=""
1691    fi
1692
1693    if test "x$DL_OBJS" != "x" ; then
1694        BUILD_DLTEST="\$(DLTEST_TARGETS)"
1695    else
1696        echo "Can't figure out how to do dynamic loading or shared libraries"
1697        echo "on this system."
1698        SHLIB_CFLAGS=""
1699        SHLIB_LD=""
1700        SHLIB_SUFFIX=""
1701        DL_OBJS="tclLoadNone.o"
1702        DL_LIBS=""
1703        LDFLAGS=""
1704        LD_SEARCH_FLAGS=""
1705        BUILD_DLTEST=""
1706    fi
1707
1708    # If we're running gcc, then change the C flags for compiling shared
1709    # libraries to the right flags for gcc, instead of those for the
1710    # standard manufacturer compiler.
1711
1712    if test "$DL_OBJS" != "tclLoadNone.o" ; then
1713        if test "$GCC" = "yes" ; then
1714            case $system in
1715                AIX-*)
1716                    ;;
1717                BSD/OS*)
1718                    ;;
1719                IRIX*)
1720                    ;;
1721                NetBSD-*|FreeBSD-*|OpenBSD-*)
1722                    ;;
1723                Rhapsody-*|Darwin-*)
1724                    ;;
1725                RISCos-*)
1726                    ;;
1727                SCO_SV-3.2*)
1728                    ;;
1729                ULTRIX-4.*)
1730                    ;;
1731                windows)
1732                    ;;
1733                *)
1734                    SHLIB_CFLAGS="-fPIC"
1735                    ;;
1736            esac
1737        fi
1738    fi
1739
1740    if test "$SHARED_LIB_SUFFIX" = "" ; then
1741        SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
1742    fi
1743    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
1744        UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1745    fi
1746
1747    AC_SUBST(DL_LIBS)
1748    AC_SUBST(CFLAGS_DEBUG)
1749    AC_SUBST(CFLAGS_OPTIMIZE)
1750    AC_SUBST(CFLAGS_WARNING)
1751    AC_SUBST(EXTRA_CFLAGS)
1752
1753    SHLIB_LDFLAGS='$(LDFLAGS_DEFAULT)'
1754    AC_SUBST(STLIB_LD)
1755    AC_SUBST(SHLIB_LD)
1756    AC_SUBST(SHLIB_CFLAGS)
1757    AC_SUBST(SHLIB_LDFLAGS)
1758    AC_SUBST(SHLIB_LD_LIBS)
1759    AC_SUBST(LDFLAGS_DEBUG)
1760    AC_SUBST(LDFLAGS_OPTIMIZE)
1761])
1762
1763#--------------------------------------------------------------------
1764# TEA_SERIAL_PORT
1765#
1766#       Determine which interface to use to talk to the serial port.
1767#       Note that #include lines must begin in leftmost column for
1768#       some compilers to recognize them as preprocessor directives,
1769#       and some build environments have stdin not pointing at a
1770#       pseudo-terminal (usually /dev/null instead.)
1771#
1772# Arguments:
1773#       none
1774#       
1775# Results:
1776#
1777#       Defines only one of the following vars:
1778#               HAVE_SYS_MODEM_H
1779#               USE_TERMIOS
1780#               USE_TERMIO
1781#               USE_SGTTY
1782#
1783#--------------------------------------------------------------------
1784
1785AC_DEFUN([TEA_SERIAL_PORT], [
1786    AC_CHECK_HEADERS(sys/modem.h)
1787    AC_MSG_CHECKING([termios vs. termio vs. sgtty])
1788    AC_CACHE_VAL(tcl_cv_api_serial, [
1789    AC_TRY_RUN([
1790#include <termios.h>
1791
1792int main() {
1793    struct termios t;
1794    if (tcgetattr(0, &t) == 0) {
1795        cfsetospeed(&t, 0);
1796        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
1797        return 0;
1798    }
1799    return 1;
1800}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
1801    if test $tcl_cv_api_serial = no ; then
1802        AC_TRY_RUN([
1803#include <termio.h>
1804
1805int main() {
1806    struct termio t;
1807    if (ioctl(0, TCGETA, &t) == 0) {
1808        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
1809        return 0;
1810    }
1811    return 1;
1812}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
1813    fi
1814    if test $tcl_cv_api_serial = no ; then
1815        AC_TRY_RUN([
1816#include <sgtty.h>
1817
1818int main() {
1819    struct sgttyb t;
1820    if (ioctl(0, TIOCGETP, &t) == 0) {
1821        t.sg_ospeed = 0;
1822        t.sg_flags |= ODDP | EVENP | RAW;
1823        return 0;
1824    }
1825    return 1;
1826}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
1827    fi
1828    if test $tcl_cv_api_serial = no ; then
1829        AC_TRY_RUN([
1830#include <termios.h>
1831#include <errno.h>
1832
1833int main() {
1834    struct termios t;
1835    if (tcgetattr(0, &t) == 0
1836        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
1837        cfsetospeed(&t, 0);
1838        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
1839        return 0;
1840    }
1841    return 1;
1842}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
1843    fi
1844    if test $tcl_cv_api_serial = no; then
1845        AC_TRY_RUN([
1846#include <termio.h>
1847#include <errno.h>
1848
1849int main() {
1850    struct termio t;
1851    if (ioctl(0, TCGETA, &t) == 0
1852        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
1853        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
1854        return 0;
1855    }
1856    return 1;
1857    }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
1858    fi
1859    if test $tcl_cv_api_serial = no; then
1860        AC_TRY_RUN([
1861#include <sgtty.h>
1862#include <errno.h>
1863
1864int main() {
1865    struct sgttyb t;
1866    if (ioctl(0, TIOCGETP, &t) == 0
1867        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
1868        t.sg_ospeed = 0;
1869        t.sg_flags |= ODDP | EVENP | RAW;
1870        return 0;
1871    }
1872    return 1;
1873}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
1874    fi])
1875    case $tcl_cv_api_serial in
1876        termios) AC_DEFINE(USE_TERMIOS);;
1877        termio)  AC_DEFINE(USE_TERMIO);;
1878        sgtty)   AC_DEFINE(USE_SGTTY);;
1879    esac
1880    AC_MSG_RESULT([$tcl_cv_api_serial])
1881])
1882
1883#--------------------------------------------------------------------
1884# TEA_MISSING_POSIX_HEADERS
1885#
1886#       Supply substitutes for missing POSIX header files.  Special
1887#       notes:
1888#           - stdlib.h doesn't define strtol, strtoul, or
1889#             strtod insome versions of SunOS
1890#           - some versions of string.h don't declare procedures such
1891#             as strstr
1892#
1893# Arguments:
1894#       none
1895#       
1896# Results:
1897#
1898#       Defines some of the following vars:
1899#               NO_DIRENT_H
1900#               NO_ERRNO_H
1901#               NO_VALUES_H
1902#               NO_LIMITS_H
1903#               NO_STDLIB_H
1904#               NO_STRING_H
1905#               NO_SYS_WAIT_H
1906#               NO_DLFCN_H
1907#               HAVE_UNISTD_H
1908#               HAVE_SYS_PARAM_H
1909#
1910#               HAVE_STRING_H ?
1911#
1912#--------------------------------------------------------------------
1913
1914AC_DEFUN([TEA_MISSING_POSIX_HEADERS], [
1915    AC_MSG_CHECKING([dirent.h])
1916    AC_TRY_LINK([#include <sys/types.h>
1917#include <dirent.h>], [
1918#ifndef _POSIX_SOURCE
1919#   ifdef __Lynx__
1920        /*
1921         * Generate compilation error to make the test fail:  Lynx headers
1922         * are only valid if really in the POSIX environment.
1923         */
1924
1925        missing_procedure();
1926#   endif
1927#endif
1928DIR *d;
1929struct dirent *entryPtr;
1930char *p;
1931d = opendir("foobar");
1932entryPtr = readdir(d);
1933p = entryPtr->d_name;
1934closedir(d);
1935], tcl_ok=yes, tcl_ok=no)
1936
1937    if test $tcl_ok = no; then
1938        AC_DEFINE(NO_DIRENT_H)
1939    fi
1940
1941    AC_MSG_RESULT([$tcl_ok])
1942    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H)])
1943    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H)])
1944    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H)])
1945    AC_CHECK_HEADER(limits.h, , [AC_DEFINE(NO_LIMITS_H)])
1946    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
1947    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
1948    AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
1949    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
1950    if test $tcl_ok = 0; then
1951        AC_DEFINE(NO_STDLIB_H)
1952    fi
1953    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
1954    AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
1955    AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
1956
1957    # See also memmove check below for a place where NO_STRING_H can be
1958    # set and why.
1959
1960    if test $tcl_ok = 0; then
1961        AC_DEFINE(NO_STRING_H)
1962    fi
1963
1964    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H)])
1965    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H)])
1966
1967    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
1968
1969    AC_HAVE_HEADERS(unistd.h sys/param.h)
1970
1971])
1972
1973#--------------------------------------------------------------------
1974# TEA_PATH_X
1975#
1976#       Locate the X11 header files and the X11 library archive.  Try
1977#       the ac_path_x macro first, but if it doesn't find the X stuff
1978#       (e.g. because there's no xmkmf program) then check through
1979#       a list of possible directories.  Under some conditions the
1980#       autoconf macro will return an include directory that contains
1981#       no include files, so double-check its result just to be safe.
1982#
1983#       This should be called after TEA_CONFIG_CFLAGS as setting the
1984#       LIBS line can confuse some configure macro magic.
1985#
1986# Arguments:
1987#       none
1988#       
1989# Results:
1990#
1991#       Sets the following vars:
1992#               XINCLUDES
1993#               XLIBSW
1994#               LIBS (appends to)
1995#
1996#--------------------------------------------------------------------
1997
1998AC_DEFUN([TEA_PATH_X], [
1999    if test "${TEA_PLATFORM}" = "unix" ; then
2000        TEA_PATH_UNIX_X
2001    fi
2002])
2003
2004AC_DEFUN([TEA_PATH_UNIX_X], [
2005    AC_PATH_X
2006    not_really_there=""
2007    if test "$no_x" = ""; then
2008        if test "$x_includes" = ""; then
2009            AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
2010        else
2011            if test ! -r $x_includes/X11/Intrinsic.h; then
2012                not_really_there="yes"
2013            fi
2014        fi
2015    fi
2016    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
2017        AC_MSG_CHECKING([for X11 header files])
2018        XINCLUDES="# no special path needed"
2019        AC_TRY_CPP([#include <X11/Intrinsic.h>], , XINCLUDES="nope")
2020        if test "$XINCLUDES" = nope; then
2021            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"
2022            for i in $dirs ; do
2023                if test -r $i/X11/Intrinsic.h; then
2024                    AC_MSG_RESULT([$i])
2025                    XINCLUDES=" -I$i"
2026                    break
2027                fi
2028            done
2029        fi
2030    else
2031        if test "$x_includes" != ""; then
2032            XINCLUDES=-I$x_includes
2033        else
2034            XINCLUDES="# no special path needed"
2035        fi
2036    fi
2037    if test "$XINCLUDES" = nope; then
2038        AC_MSG_RESULT([could not find any!])
2039        XINCLUDES="# no include files found"
2040    fi
2041
2042    if test "$no_x" = yes; then
2043        AC_MSG_CHECKING([for X11 libraries])
2044        XLIBSW=nope
2045        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"
2046        for i in $dirs ; do
2047            if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
2048                AC_MSG_RESULT([$i])
2049                XLIBSW="-L$i -lX11"
2050                x_libraries="$i"
2051                break
2052            fi
2053        done
2054    else
2055        if test "$x_libraries" = ""; then
2056            XLIBSW=-lX11
2057        else
2058            XLIBSW="-L$x_libraries -lX11"
2059        fi
2060    fi
2061    if test "$XLIBSW" = nope ; then
2062        AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
2063    fi
2064    if test "$XLIBSW" = nope ; then
2065        AC_MSG_RESULT([could not find any!  Using -lX11.])
2066        XLIBSW=-lX11
2067    fi
2068    if test x"${XLIBSW}" != x ; then
2069        LIBS="${LIBS} ${XLIBSW}"
2070    fi
2071])
2072
2073#--------------------------------------------------------------------
2074# TEA_BLOCKING_STYLE
2075#
2076#       The statements below check for systems where POSIX-style
2077#       non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
2078#       On these systems (mostly older ones), use the old BSD-style
2079#       FIONBIO approach instead.
2080#
2081# Arguments:
2082#       none
2083#       
2084# Results:
2085#
2086#       Defines some of the following vars:
2087#               HAVE_SYS_IOCTL_H
2088#               HAVE_SYS_FILIO_H
2089#               USE_FIONBIO
2090#               O_NONBLOCK
2091#
2092#--------------------------------------------------------------------
2093
2094AC_DEFUN([TEA_BLOCKING_STYLE], [
2095    AC_CHECK_HEADERS(sys/ioctl.h)
2096    AC_CHECK_HEADERS(sys/filio.h)
2097    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
2098    if test -f /usr/lib/NextStep/software_version; then
2099        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
2100    else
2101        system=`uname -s`-`uname -r`
2102        if test "$?" -ne 0 ; then
2103            system=unknown
2104        else
2105            # Special check for weird MP-RAS system (uname returns weird
2106            # results, and the version is kept in special file).
2107       
2108            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
2109                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
2110            fi
2111            if test "`uname -s`" = "AIX" ; then
2112                system=AIX-`uname -v`.`uname -r`
2113            fi
2114        fi
2115    fi
2116    case $system in
2117        # There used to be code here to use FIONBIO under AIX.  However, it
2118        # was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
2119        # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
2120        # code (JO, 5/31/97).
2121
2122        OSF*)
2123            AC_DEFINE(USE_FIONBIO)
2124            AC_MSG_RESULT([FIONBIO])
2125            ;;
2126        SunOS-4*)
2127            AC_DEFINE(USE_FIONBIO)
2128            AC_MSG_RESULT([FIONBIO])
2129            ;;
2130        ULTRIX-4.*)
2131            AC_DEFINE(USE_FIONBIO)
2132            AC_MSG_RESULT([FIONBIO])
2133            ;;
2134        *)
2135            AC_MSG_RESULT([O_NONBLOCK])
2136            ;;
2137    esac
2138])
2139
2140#--------------------------------------------------------------------
2141# TEA_TIME_HANLDER
2142#
2143#       Checks how the system deals with time.h, what time structures
2144#       are used on the system, and what fields the structures have.
2145#
2146# Arguments:
2147#       none
2148#       
2149# Results:
2150#
2151#       Defines some of the following vars:
2152#               USE_DELTA_FOR_TZ
2153#               HAVE_TM_GMTOFF
2154#               HAVE_TM_TZADJ
2155#               HAVE_TIMEZONE_VAR
2156#
2157#--------------------------------------------------------------------
2158
2159AC_DEFUN([TEA_TIME_HANDLER], [
2160    AC_CHECK_HEADERS(sys/time.h)
2161    AC_HEADER_TIME
2162    AC_STRUCT_TIMEZONE
2163
2164    AC_CHECK_FUNCS(gmtime_r localtime_r)
2165
2166    AC_MSG_CHECKING([tm_tzadj in struct tm])
2167    AC_CACHE_VAL(tcl_cv_member_tm_tzadj,
2168        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
2169            tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no))
2170    AC_MSG_RESULT([$tcl_cv_member_tm_tzadj])
2171    if test $tcl_cv_member_tm_tzadj = yes ; then
2172        AC_DEFINE(HAVE_TM_TZADJ)
2173    fi
2174
2175    AC_MSG_CHECKING([tm_gmtoff in struct tm])
2176    AC_CACHE_VAL(tcl_cv_member_tm_gmtoff,
2177        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
2178            tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no))
2179    AC_MSG_RESULT([$tcl_cv_member_tm_gmtoff])
2180    if test $tcl_cv_member_tm_gmtoff = yes ; then
2181        AC_DEFINE(HAVE_TM_GMTOFF)
2182    fi
2183
2184    #
2185    # Its important to include time.h in this check, as some systems
2186    # (like convex) have timezone functions, etc.
2187    #
2188    AC_MSG_CHECKING([long timezone variable])
2189    AC_CACHE_VAL(tcl_cv_var_timezone,
2190        AC_TRY_COMPILE([#include <time.h>],
2191            [extern long timezone;
2192            timezone += 1;
2193            exit (0);],
2194            tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no))
2195    AC_MSG_RESULT([$tcl_cv_timezone_long])
2196    if test $tcl_cv_timezone_long = yes ; then
2197        AC_DEFINE(HAVE_TIMEZONE_VAR)
2198    else
2199        #
2200        # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
2201        #
2202        AC_MSG_CHECKING([time_t timezone variable])
2203        AC_CACHE_VAL(tcl_cv_timezone_time,
2204            AC_TRY_COMPILE([#include <time.h>],
2205                [extern time_t timezone;
2206                timezone += 1;
2207                exit (0);],
2208                tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no))
2209        AC_MSG_RESULT([$tcl_cv_timezone_time])
2210        if test $tcl_cv_timezone_time = yes ; then
2211            AC_DEFINE(HAVE_TIMEZONE_VAR)
2212        fi
2213    fi
2214])
2215
2216#--------------------------------------------------------------------
2217# TEA_BUGGY_STRTOD
2218#
2219#       Under Solaris 2.4, strtod returns the wrong value for the
2220#       terminating character under some conditions.  Check for this
2221#       and if the problem exists use a substitute procedure
2222#       "fixstrtod" (provided by Tcl) that corrects the error.
2223#       Also, on Compaq's Tru64 Unix 5.0,
2224#       strtod(" ") returns 0.0 instead of a failure to convert.
2225#
2226# Arguments:
2227#       none
2228#       
2229# Results:
2230#
2231#       Might defines some of the following vars:
2232#               strtod (=fixstrtod)
2233#
2234#--------------------------------------------------------------------
2235
2236AC_DEFUN([TEA_BUGGY_STRTOD], [
2237    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
2238    if test "$tcl_strtod" = 1; then
2239        AC_MSG_CHECKING([for Solaris2.4/Tru64 strtod bugs])
2240        AC_TRY_RUN([
2241            extern double strtod();
2242            int main()
2243            {
2244                char *string = "NaN", *spaceString = " ";
2245                char *term;
2246                double value;
2247                value = strtod(string, &term);
2248                if ((term != string) && (term[-1] == 0)) {
2249                    exit(1);
2250                }
2251                value = strtod(spaceString, &term);
2252                if (term == (spaceString+1)) {
2253                    exit(1);
2254                }
2255                exit(0);
2256            }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
2257        if test "$tcl_ok" = 1; then
2258            AC_MSG_RESULT([ok])
2259        else
2260            AC_MSG_RESULT([buggy])
2261            #LIBOBJS="$LIBOBJS fixstrtod.o"
2262            AC_LIBOBJ([fixstrtod])
2263            USE_COMPAT=1
2264            AC_DEFINE(strtod, fixstrtod)
2265        fi
2266    fi
2267])
2268
2269#--------------------------------------------------------------------
2270# TEA_TCL_LINK_LIBS
2271#
2272#       Search for the libraries needed to link the Tcl shell.
2273#       Things like the math library (-lm) and socket stuff (-lsocket vs.
2274#       -lnsl) are dealt with here.
2275#
2276# Arguments:
2277#       Requires the following vars to be set in the Makefile:
2278#               DL_LIBS
2279#               LIBS
2280#               MATH_LIBS
2281#       
2282# Results:
2283#
2284#       Subst's the following var:
2285#               TCL_LIBS
2286#               MATH_LIBS
2287#
2288#       Might append to the following vars:
2289#               LIBS
2290#
2291#       Might define the following vars:
2292#               HAVE_NET_ERRNO_H
2293#
2294#--------------------------------------------------------------------
2295
2296AC_DEFUN([TEA_TCL_LINK_LIBS], [
2297    #--------------------------------------------------------------------
2298    # On a few very rare systems, all of the libm.a stuff is
2299    # already in libc.a.  Set compiler flags accordingly.
2300    # Also, Linux requires the "ieee" library for math to work
2301    # right (and it must appear before "-lm").
2302    #--------------------------------------------------------------------
2303
2304    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
2305    AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
2306
2307    #--------------------------------------------------------------------
2308    # Interactive UNIX requires -linet instead of -lsocket, plus it
2309    # needs net/errno.h to define the socket-related error codes.
2310    #--------------------------------------------------------------------
2311
2312    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
2313    AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))
2314
2315    #--------------------------------------------------------------------
2316    #   Check for the existence of the -lsocket and -lnsl libraries.
2317    #   The order here is important, so that they end up in the right
2318    #   order in the command line generated by make.  Here are some
2319    #   special considerations:
2320    #   1. Use "connect" and "accept" to check for -lsocket, and
2321    #      "gethostbyname" to check for -lnsl.
2322    #   2. Use each function name only once:  can't redo a check because
2323    #      autoconf caches the results of the last check and won't redo it.
2324    #   3. Use -lnsl and -lsocket only if they supply procedures that
2325    #      aren't already present in the normal libraries.  This is because
2326    #      IRIX 5.2 has libraries, but they aren't needed and they're
2327    #      bogus:  they goof up name resolution if used.
2328    #   4. On some SVR4 systems, can't use -lsocket without -lnsl too.
2329    #      To get around this problem, check for both libraries together
2330    #      if -lsocket doesn't work by itself.
2331    #--------------------------------------------------------------------
2332
2333    tcl_checkBoth=0
2334    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
2335    if test "$tcl_checkSocket" = 1; then
2336        AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
2337            LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
2338    fi
2339    if test "$tcl_checkBoth" = 1; then
2340        tk_oldLibs=$LIBS
2341        LIBS="$LIBS -lsocket -lnsl"
2342        AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
2343    fi
2344    AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
2345            [LIBS="$LIBS -lnsl"])])
2346   
2347    # Don't perform the eval of the libraries here because DL_LIBS
2348    # won't be set until we call TEA_CONFIG_CFLAGS
2349
2350    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
2351    AC_SUBST(TCL_LIBS)
2352    AC_SUBST(MATH_LIBS)
2353])
2354
2355#--------------------------------------------------------------------
2356# TEA_TCL_EARLY_FLAGS
2357#
2358#       Check for what flags are needed to be passed so the correct OS
2359#       features are available.
2360#
2361# Arguments:
2362#       None
2363#       
2364# Results:
2365#
2366#       Might define the following vars:
2367#               _ISOC99_SOURCE
2368#               _LARGEFILE64_SOURCE
2369#
2370#--------------------------------------------------------------------
2371
2372AC_DEFUN([TEA_TCL_EARLY_FLAG],[
2373    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
2374        AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
2375            AC_TRY_COMPILE([[#define ]$1[ 1
2376]$2], $3,
2377                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
2378                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
2379    if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
2380        AC_DEFINE($1)
2381        tcl_flags="$tcl_flags $1"
2382    fi
2383])
2384
2385AC_DEFUN([TEA_TCL_EARLY_FLAGS],[
2386    AC_MSG_CHECKING([for required early compiler flags])
2387    tcl_flags=""
2388    TEA_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
2389        [char *p = (char *)strtoll; char *q = (char *)strtoull;])
2390    TEA_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
2391        [struct stat64 buf; int i = stat64("/", &buf);])
2392    if test "x${tcl_flags}" = "x" ; then
2393        AC_MSG_RESULT([none])
2394    else
2395        AC_MSG_RESULT([${tcl_flags}])
2396    fi
2397])
2398
2399#--------------------------------------------------------------------
2400# TEA_TCL_64BIT_FLAGS
2401#
2402#       Check for what is defined in the way of 64-bit features.
2403#
2404# Arguments:
2405#       None
2406#       
2407# Results:
2408#
2409#       Might define the following vars:
2410#               TCL_WIDE_INT_IS_LONG
2411#               TCL_WIDE_INT_TYPE
2412#               HAVE_STRUCT_DIRENT64
2413#               HAVE_STRUCT_STAT64
2414#               HAVE_TYPE_OFF64_T
2415#
2416#--------------------------------------------------------------------
2417
2418AC_DEFUN([TEA_TCL_64BIT_FLAGS], [
2419    AC_MSG_CHECKING([for 64-bit integer type])
2420    AC_CACHE_VAL(tcl_cv_type_64bit,[
2421        AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
2422           tcl_cv_type_64bit=__int64,tcl_cv_type_64bit=none
2423           AC_TRY_RUN([#include <unistd.h>
2424                int main() {exit(!(sizeof(long long) > sizeof(long)));}
2425                ], tcl_cv_type_64bit="long long"))])
2426    if test "${tcl_cv_type_64bit}" = none ; then
2427        AC_MSG_RESULT([using long])
2428    elif test "${tcl_cv_type_64bit}" = "__int64" ; then
2429        # We actually want to use the default tcl.h checks in this
2430        # case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER*
2431        AC_MSG_RESULT([using Tcl header defaults])
2432    else
2433        AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit})
2434        AC_MSG_RESULT([${tcl_cv_type_64bit}])
2435
2436        # Now check for auxiliary declarations
2437        AC_MSG_CHECKING([for struct dirent64])
2438        AC_CACHE_VAL(tcl_cv_struct_dirent64,[
2439            AC_TRY_COMPILE([#include <sys/types.h>
2440#include <sys/dirent.h>],[struct dirent64 p;],
2441                tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
2442        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
2443            AC_DEFINE(HAVE_STRUCT_DIRENT64)
2444        fi
2445        AC_MSG_RESULT([${tcl_cv_struct_dirent64}])
2446
2447        AC_MSG_CHECKING([for struct stat64])
2448        AC_CACHE_VAL(tcl_cv_struct_stat64,[
2449            AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
2450],
2451                tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
2452        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
2453            AC_DEFINE(HAVE_STRUCT_STAT64)
2454        fi
2455        AC_MSG_RESULT([${tcl_cv_struct_stat64}])
2456
2457        AC_MSG_CHECKING([for off64_t])
2458        AC_CACHE_VAL(tcl_cv_type_off64_t,[
2459            AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
2460],
2461                tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
2462        if test "x${tcl_cv_type_off64_t}" = "xyes" ; then
2463            AC_DEFINE(HAVE_TYPE_OFF64_T)
2464        fi
2465        AC_MSG_RESULT([${tcl_cv_type_off64_t}])
2466    fi
2467])
2468
2469##
2470## Here ends the standard Tcl configuration bits and starts the
2471## TEA specific functions
2472##
2473
2474#------------------------------------------------------------------------
2475# TEA_INIT --
2476#
2477#       Init various Tcl Extension Architecture (TEA) variables.
2478#       This should be the first called TEA_* macro.
2479#
2480# Arguments:
2481#       none
2482#
2483# Results:
2484#
2485#       Defines and substs the following vars:
2486#               CYGPATH
2487#               EXEEXT
2488#       Defines only:
2489#               TEA_INITED
2490#               TEA_PLATFORM (windows or unix)
2491#
2492# "cygpath" is used on windows to generate native path names for include
2493# files. These variables should only be used with the compiler and linker
2494# since they generate native path names.
2495#
2496# EXEEXT
2497#       Select the executable extension based on the host type.  This
2498#       is a lightweight replacement for AC_EXEEXT that doesn't require
2499#       a compiler.
2500#------------------------------------------------------------------------
2501
2502AC_DEFUN([TEA_INIT], [
2503    AC_MSG_CHECKING([for correct TEA configuration])
2504    if test x"${PACKAGE}" = x ; then
2505        AC_MSG_ERROR([
2506The PACKAGE variable must be defined by your TEA configure.in])
2507    fi
2508    AC_MSG_RESULT([ok])
2509    case "`uname -s`" in
2510        *win32*|*WIN32*|*CYGWIN_NT*|*CYGWIN_9*|*CYGWIN_ME*|*MINGW32_*)
2511            AC_CHECK_PROG(CYGPATH, cygpath, cygpath -w, echo)
2512            EXEEXT=".exe"
2513            TEA_PLATFORM="windows"
2514            ;;
2515        *)
2516            CYGPATH=echo
2517            EXEEXT=""
2518            TEA_PLATFORM="unix"
2519            ;;
2520    esac
2521
2522    # Check if exec_prefix is set. If not use fall back to prefix
2523    if test x$exec_prefix = xNONE ; then exec_prefix=$prefix ; fi
2524
2525    AC_SUBST(EXEEXT)
2526    AC_SUBST(CYGPATH)
2527])
2528
2529#------------------------------------------------------------------------
2530# TEA_PREFIX --
2531#
2532#       Handle the --prefix=... option by defaulting to what Tcl gave
2533#
2534# Arguments:
2535#       none
2536#
2537# Results:
2538#
2539#       If --prefix or --exec-prefix was not specified, $prefix and
2540#       $exec_prefix will be set to the values given to Tcl when it was
2541#       configured.
2542#------------------------------------------------------------------------
2543AC_DEFUN([TEA_PREFIX], [
2544    # Should be AC_MSG_NOTICE, but that requires autoconf 2.50
2545    if test "${prefix}" = "NONE"; then
2546        prefix_default=yes
2547        if test x"${TCL_PREFIX}" != x; then
2548            AC_MSG_WARN([--prefix defaulting to TCL_PREFIX ${TCL_PREFIX}])
2549            prefix=${TCL_PREFIX}
2550        else
2551            prefix=/usr/local
2552        fi
2553    fi
2554    if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" ; then
2555        if test x"${TCL_EXEC_PREFIX}" != x; then
2556            AC_MSG_WARN([--exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}])
2557            exec_prefix=${TCL_EXEC_PREFIX}
2558        else
2559            exec_prefix=$prefix
2560        fi
2561    fi
2562])
2563
2564#------------------------------------------------------------------------
2565# TEA_SETUP_COMPILER --
2566#
2567#       Do compiler checks the way we want.  This is just a replacement
2568#       for AC_PROG_CC in TEA configure.in files to make them cleaner.
2569#
2570# Arguments:
2571#       none
2572#
2573# Results:
2574#
2575#       Sets up CC var and other standard bits we need to make executables.
2576#------------------------------------------------------------------------
2577AC_DEFUN([TEA_SETUP_COMPILER_CC], [
2578    # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE)
2579    # in this macro, they need to go into TEA_SETUP_COMPILER_FLAGS instead.
2580
2581    # If the user did not set CFLAGS, set it now to keep
2582    # the AC_PROG_CC macro from adding "-g -O2".
2583    if test "${CFLAGS+set}" != "set" ; then
2584        CFLAGS=""
2585    fi
2586
2587    AC_PROG_CC
2588    AC_PROG_CPP
2589
2590    AC_PROG_INSTALL
2591
2592    #--------------------------------------------------------------------
2593    # Checks to see if the make program sets the $MAKE variable.
2594    #--------------------------------------------------------------------
2595
2596    AC_PROG_MAKE_SET
2597
2598    #--------------------------------------------------------------------
2599    # Find ranlib
2600    #--------------------------------------------------------------------
2601
2602    AC_PROG_RANLIB
2603
2604    #--------------------------------------------------------------------
2605    # Determines the correct binary file extension (.o, .obj, .exe etc.)
2606    #--------------------------------------------------------------------
2607
2608    AC_OBJEXT
2609    AC_EXEEXT
2610])
2611
2612#------------------------------------------------------------------------
2613# TEA_SETUP_COMPILER --
2614#
2615#       Do compiler checks that use the compiler.  This must go after
2616#       TEA_SETUP_COMPILER_CC, which does the actual compiler check.
2617#
2618# Arguments:
2619#       none
2620#
2621# Results:
2622#
2623#       Sets up CC var and other standard bits we need to make executables.
2624#------------------------------------------------------------------------
2625AC_DEFUN([TEA_SETUP_COMPILER], [
2626    # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here.
2627    AC_REQUIRE([TEA_SETUP_COMPILER_CC])
2628
2629    #------------------------------------------------------------------------
2630    # If we're using GCC, see if the compiler understands -pipe. If so, use it.
2631    # It makes compiling go faster.  (This is only a performance feature.)
2632    #------------------------------------------------------------------------
2633
2634    if test -z "$no_pipe" -a -n "$GCC"; then
2635        AC_MSG_CHECKING([if the compiler understands -pipe])
2636        OLDCC="$CC"
2637        CC="$CC -pipe"
2638        AC_TRY_COMPILE(,, AC_MSG_RESULT([yes]), CC="$OLDCC"
2639            AC_MSG_RESULT([no]))
2640    fi
2641
2642    #--------------------------------------------------------------------
2643    # Common compiler flag setup
2644    #--------------------------------------------------------------------
2645
2646    TEA_TCL_EARLY_FLAGS
2647    TEA_TCL_64BIT_FLAGS
2648    AC_C_BIGENDIAN
2649    if test "${TEA_PLATFORM}" = "unix" ; then
2650        TEA_TCL_LINK_LIBS
2651        TEA_MISSING_POSIX_HEADERS
2652        TEA_BUGGY_STRTOD
2653    fi
2654])
2655
2656#------------------------------------------------------------------------
2657# TEA_MAKE_LIB --
2658#
2659#       Generate a line that can be used to build a shared/unshared library
2660#       in a platform independent manner.
2661#
2662# Arguments:
2663#       none
2664#
2665#       Requires:
2666#
2667# Results:
2668#
2669#       Defines the following vars:
2670#       CFLAGS -        Done late here to note disturb other AC macros
2671#       MAKE_LIB -      Command to execute to build the Tcl library;
2672#                       differs depending on whether or not Tcl is being
2673#                       compiled as a shared library.
2674#       MAKE_SHARED_LIB Makefile rule for building a shared library
2675#       MAKE_STATIC_LIB Makefile rule for building a static library
2676#       MAKE_STUB_LIB   Makefile rule for building a stub library
2677#------------------------------------------------------------------------
2678
2679AC_DEFUN([TEA_MAKE_LIB], [
2680    if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then
2681        MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(\[$](PACKAGE)_OBJECTS)"
2682        MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS} \$(LDFLAGS) -out:\[$]@ \$(\[$](PACKAGE)_OBJECTS)"
2683        MAKE_STUB_LIB="\${STLIB_LD} -out:\[$]@ \$(\[$](PACKAGE)stub_OBJECTS)"
2684    else
2685        MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(\[$](PACKAGE)_OBJECTS)"
2686        MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(\[$](PACKAGE)_OBJECTS) \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS}"
2687        MAKE_STUB_LIB="\${STLIB_LD} \[$]@ \$(\[$](PACKAGE)stub_OBJECTS)"
2688    fi
2689
2690    if test "${SHARED_BUILD}" = "1" ; then
2691        MAKE_LIB="${MAKE_SHARED_LIB} "
2692    else
2693        MAKE_LIB="${MAKE_STATIC_LIB} "
2694    fi
2695
2696    #--------------------------------------------------------------------
2697    # Shared libraries and static libraries have different names.
2698    # Use the double eval to make sure the ${DBGX} in the suffix is
2699    # substituted.
2700    #--------------------------------------------------------------------
2701
2702    if test "${TEA_PLATFORM}" = "windows" ; then
2703        if test "${SHARED_BUILD}" = "1" ; then
2704            # We force the unresolved linking of symbols that are really in
2705            # the private libraries of Tcl and Tk.
2706            SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\""
2707            if test x"${TK_BIN_DIR}" != x ; then
2708                SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\""
2709            fi
2710            eval eval "${PACKAGE}_LIB_FILE=${PACKAGE}${SHARED_LIB_SUFFIX}"
2711            RANLIB=:
2712        else
2713            eval eval "${PACKAGE}_LIB_FILE=${PACKAGE}${UNSHARED_LIB_SUFFIX}"
2714        fi
2715        # Some packages build there own stubs libraries
2716        eval eval "${PACKAGE}stub_LIB_FILE=${PACKAGE}stub${UNSHARED_LIB_SUFFIX}"
2717    else
2718        if test "${SHARED_BUILD}" = "1" ; then
2719            SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}"
2720            if test x"${TK_BIN_DIR}" != x ; then
2721                SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}"
2722            fi
2723            eval eval "${PACKAGE}_LIB_FILE=lib${PACKAGE}${SHARED_LIB_SUFFIX}"
2724            RANLIB=:
2725        else
2726            eval eval "${PACKAGE}_LIB_FILE=lib${PACKAGE}${UNSHARED_LIB_SUFFIX}"
2727        fi
2728        # Some packages build there own stubs libraries
2729        eval eval "${PACKAGE}stub_LIB_FILE=lib${PACKAGE}stub${UNSHARED_LIB_SUFFIX}"
2730    fi
2731
2732    # These are escaped so that only CFLAGS is picked up at configure time.
2733    # The other values will be substituted at make time.
2734    CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}"
2735    if test "${SHARED_BUILD}" = "1" ; then
2736        CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}"
2737    fi
2738
2739    AC_SUBST(MAKE_LIB)
2740    AC_SUBST(MAKE_SHARED_LIB)
2741    AC_SUBST(MAKE_STATIC_LIB)
2742    AC_SUBST(MAKE_STUB_LIB)
2743])
2744
2745#------------------------------------------------------------------------
2746# TEA_LIB_SPEC --
2747#
2748#       Compute the name of an existing object library located in libdir
2749#       from the given base name and produce the appropriate linker flags.
2750#
2751# Arguments:
2752#       basename        The base name of the library without version
2753#                       numbers, extensions, or "lib" prefixes.
2754#       extra_dir       Extra directory in which to search for the
2755#                       library.  This location is used first, then
2756#                       $prefix/$exec-prefix, then some defaults.
2757#
2758# Requires:
2759#       TEA_INIT and TEA_PREFIX must be called first.
2760#
2761# Results:
2762#
2763#       Defines the following vars:
2764#               ${basename}_LIB_NAME    The computed library name.
2765#               ${basename}_LIB_SPEC    The computed linker flags.
2766#------------------------------------------------------------------------
2767
2768AC_DEFUN([TEA_LIB_SPEC], [
2769    AC_MSG_CHECKING([for $1 library])
2770
2771    # Look in exec-prefix for the library (defined by TEA_PREFIX).
2772
2773    tea_lib_name_dir="${exec_prefix}/lib"
2774
2775    # Or in a user-specified location.
2776
2777    if test x"$2" != x ; then
2778        tea_extra_lib_dir=$2
2779    else
2780        tea_extra_lib_dir=NONE
2781    fi
2782
2783    for i in \
2784            `ls -dr ${tea_extra_lib_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
2785            `ls -dr ${tea_extra_lib_dir}/lib$1[[0-9]]* 2>/dev/null ` \
2786            `ls -dr ${tea_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
2787            `ls -dr ${tea_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
2788            `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
2789            `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
2790            `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
2791            `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
2792        if test -f "$i" ; then
2793            tea_lib_name_dir=`dirname $i`
2794            $1_LIB_NAME=`basename $i`
2795            $1_LIB_PATH_NAME=$i
2796            break
2797        fi
2798    done
2799
2800    if test "${TEA_PLATFORM}" = "windows"; then
2801        $1_LIB_SPEC=\"`${CYGPATH} ${$1_LIB_PATH_NAME} 2>/dev/null`\"
2802    else
2803        # Strip off the leading "lib" and trailing ".a" or ".so"
2804
2805        tea_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//' -e 's/\.so.*//'`
2806        $1_LIB_SPEC="-L${tea_lib_name_dir} -l${tea_lib_name_lib}"
2807    fi
2808
2809    if test "x${$1_LIB_NAME}" = x ; then
2810        AC_MSG_ERROR([not found])
2811    else
2812        AC_MSG_RESULT([${$1_LIB_SPEC}])
2813    fi
2814])
2815
2816#------------------------------------------------------------------------
2817# TEA_PRIVATE_TCL_HEADERS --
2818#
2819#       Locate the private Tcl include files
2820#
2821# Arguments:
2822#
2823#       Requires:
2824#               TCL_SRC_DIR     Assumes that TEA_LOAD_TCLCONFIG has
2825#                                already been called.
2826#
2827# Results:
2828#
2829#       Substs the following vars:
2830#               TCL_TOP_DIR_NATIVE
2831#               TCL_GENERIC_DIR_NATIVE
2832#               TCL_UNIX_DIR_NATIVE
2833#               TCL_WIN_DIR_NATIVE
2834#               TCL_BMAP_DIR_NATIVE
2835#               TCL_TOOL_DIR_NATIVE
2836#               TCL_PLATFORM_DIR_NATIVE
2837#               TCL_BIN_DIR_NATIVE
2838#               TCL_INCLUDES
2839#------------------------------------------------------------------------
2840
2841AC_DEFUN([TEA_PRIVATE_TCL_HEADERS], [
2842    AC_MSG_CHECKING([for Tcl private include files])
2843
2844    if test "${TEA_PLATFORM}" = "windows"; then
2845        TCL_TOP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}`\"
2846        TCL_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/generic`\"
2847        TCL_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/unix`\"
2848        TCL_WIN_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/win`\"
2849        TCL_BMAP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/bitmaps`\"
2850        TCL_TOOL_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/tools`\"
2851        TCL_COMPAT_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/compat`\"
2852        TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
2853    else
2854        TCL_TOP_DIR_NATIVE='$(TCL_SRC_DIR)'
2855        TCL_GENERIC_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/generic'
2856        TCL_UNIX_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/unix'
2857        TCL_WIN_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/win'
2858        TCL_BMAP_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/bitmaps'
2859        TCL_TOOL_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/tools'
2860        TCL_COMPAT_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/compat'
2861        TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
2862    fi
2863
2864    AC_SUBST(TCL_TOP_DIR_NATIVE)
2865    AC_SUBST(TCL_GENERIC_DIR_NATIVE)
2866    AC_SUBST(TCL_UNIX_DIR_NATIVE)
2867    AC_SUBST(TCL_WIN_DIR_NATIVE)
2868    AC_SUBST(TCL_BMAP_DIR_NATIVE)
2869    AC_SUBST(TCL_TOOL_DIR_NATIVE)
2870    AC_SUBST(TCL_PLATFORM_DIR_NATIVE)
2871
2872    TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
2873    AC_SUBST(TCL_INCLUDES)
2874    AC_MSG_RESULT([Using srcdir found in tclConfig.sh: ${TCL_SRC_DIR}])
2875])
2876
2877#------------------------------------------------------------------------
2878# TEA_PUBLIC_TCL_HEADERS --
2879#
2880#       Locate the installed public Tcl header files
2881#
2882# Arguments:
2883#       None.
2884#
2885# Requires:
2886#       CYGPATH must be set
2887#
2888# Results:
2889#
2890#       Adds a --with-tclinclude switch to configure.
2891#       Result is cached.
2892#
2893#       Substs the following vars:
2894#               TCL_INCLUDES
2895#------------------------------------------------------------------------
2896
2897AC_DEFUN([TEA_PUBLIC_TCL_HEADERS], [
2898    AC_MSG_CHECKING([for Tcl public headers])
2899
2900    AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory containing the public Tcl header files], with_tclinclude=${withval})
2901
2902    AC_CACHE_VAL(ac_cv_c_tclh, [
2903        # Use the value from --with-tclinclude, if it was given
2904
2905        if test x"${with_tclinclude}" != x ; then
2906            if test -f "${with_tclinclude}/tcl.h" ; then
2907                ac_cv_c_tclh=${with_tclinclude}
2908            else
2909                AC_MSG_ERROR([${with_tclinclude} directory does not contain tcl.h])
2910            fi
2911        else
2912            # Check order: pkg --prefix location, Tcl's --prefix location,
2913            # directory of tclConfig.sh, and Tcl source directory.
2914            # Looking in the source dir is not ideal, but OK.
2915
2916            eval "temp_includedir=${includedir}"
2917            list="`ls -d ${temp_includedir}      2>/dev/null` \
2918                `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
2919                `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null` \
2920                `ls -d ${TCL_SRC_DIR}/generic    2>/dev/null`"
2921            if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
2922                list="$list /usr/local/include /usr/include"
2923            fi
2924            for i in $list ; do
2925                if test -f "$i/tcl.h" ; then
2926                    ac_cv_c_tclh=$i
2927                    break
2928                fi
2929            done
2930        fi
2931    ])
2932
2933    # Print a message based on how we determined the include path
2934
2935    if test x"${ac_cv_c_tclh}" = x ; then
2936        AC_MSG_ERROR([tcl.h not found.  Please specify its location with --with-tclinclude])
2937    else
2938        AC_MSG_RESULT([${ac_cv_c_tclh}])
2939    fi
2940
2941    # Convert to a native path and substitute into the output files.
2942
2943    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
2944
2945    TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
2946
2947    AC_SUBST(TCL_INCLUDES)
2948])
2949
2950#------------------------------------------------------------------------
2951# TEA_PRIVATE_TK_HEADERS --
2952#
2953#       Locate the private Tk include files
2954#
2955# Arguments:
2956#
2957#       Requires:
2958#               TK_SRC_DIR      Assumes that TEA_LOAD_TKCONFIG has
2959#                                already been called.
2960#
2961# Results:
2962#
2963#       Substs the following vars:
2964#               TK_INCLUDES
2965#------------------------------------------------------------------------
2966
2967AC_DEFUN([TEA_PRIVATE_TK_HEADERS], [
2968    AC_MSG_CHECKING([for Tk private include files])
2969
2970    if test "${TEA_PLATFORM}" = "windows"; then
2971        TK_TOP_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}`\"
2972        TK_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/unix`\"
2973        TK_WIN_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/win`\"
2974        TK_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/generic`\"
2975        TK_XLIB_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/xlib`\"
2976        TK_PLATFORM_DIR_NATIVE=${TK_WIN_DIR_NATIVE}
2977
2978        TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE} -I${TK_XLIB_DIR_NATIVE}"
2979    else
2980        TK_TOP_DIR_NATIVE='$(TK_SRC_DIR)'
2981        TK_GENERIC_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/generic'
2982        TK_UNIX_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/unix'
2983        TK_WIN_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/win'
2984        TK_PLATFORM_DIR_NATIVE=${TK_UNIX_DIR_NATIVE}
2985
2986        TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
2987    fi
2988
2989    AC_SUBST(TK_TOP_DIR_NATIVE)
2990    AC_SUBST(TK_UNIX_DIR_NATIVE)
2991    AC_SUBST(TK_WIN_DIR_NATIVE)
2992    AC_SUBST(TK_GENERIC_DIR_NATIVE)
2993    AC_SUBST(TK_XLIB_DIR_NATIVE)
2994    AC_SUBST(TK_PLATFORM_DIR_NATIVE)
2995
2996    AC_SUBST(TK_INCLUDES)
2997    AC_MSG_RESULT([Using srcdir found in tkConfig.sh: ${TK_SRC_DIR}])
2998])
2999
3000#------------------------------------------------------------------------
3001# TEA_PUBLIC_TK_HEADERS --
3002#
3003#       Locate the installed public Tk header files
3004#
3005# Arguments:
3006#       None.
3007#
3008# Requires:
3009#       CYGPATH must be set
3010#
3011# Results:
3012#
3013#       Adds a --with-tkinclude switch to configure.
3014#       Result is cached.
3015#
3016#       Substs the following vars:
3017#               TK_INCLUDES
3018#------------------------------------------------------------------------
3019
3020AC_DEFUN([TEA_PUBLIC_TK_HEADERS], [
3021    AC_MSG_CHECKING([for Tk public headers])
3022
3023    AC_ARG_WITH(tkinclude, [  --with-tkinclude      directory containing the public Tk header files.], with_tkinclude=${withval})
3024
3025    AC_CACHE_VAL(ac_cv_c_tkh, [
3026        # Use the value from --with-tkinclude, if it was given
3027
3028        if test x"${with_tkinclude}" != x ; then
3029            if test -f "${with_tkinclude}/tk.h" ; then
3030                ac_cv_c_tkh=${with_tkinclude}
3031            else
3032                AC_MSG_ERROR([${with_tkinclude} directory does not contain tk.h])
3033            fi
3034        else
3035            # Check order: pkg --prefix location, Tcl's --prefix location,
3036            # directory of tclConfig.sh, and Tcl source directory.
3037            # Looking in the source dir is not ideal, but OK.
3038
3039            eval "temp_includedir=${includedir}"
3040            list="`ls -d ${temp_includedir}      2>/dev/null` \
3041                `ls -d ${TK_PREFIX}/include      2>/dev/null` \
3042                `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
3043                `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null` \
3044                `ls -d ${TK_SRC_DIR}/generic     2>/dev/null`"
3045            if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
3046                list="$list /usr/local/include /usr/include"
3047            fi
3048            for i in $list ; do
3049                if test -f "$i/tk.h" ; then
3050                    ac_cv_c_tkh=$i
3051                    break
3052                fi
3053            done
3054        fi
3055    ])
3056
3057    # Print a message based on how we determined the include path
3058
3059    if test x"${ac_cv_c_tkh}" = x ; then
3060        AC_MSG_ERROR([tk.h not found.  Please specify its location with --with-tkinclude])
3061    else
3062        AC_MSG_RESULT([${ac_cv_c_tkh}])
3063    fi
3064
3065    # Convert to a native path and substitute into the output files.
3066
3067    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}`
3068
3069    TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
3070
3071    AC_SUBST(TK_INCLUDES)
3072
3073    if test "${TEA_PLATFORM}" = "windows" ; then
3074        # On Windows, we need the X compat headers
3075        AC_MSG_CHECKING([for X11 header files])
3076        if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then
3077            INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`"
3078            TK_XINCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
3079            AC_SUBST(TK_XINCLUDES)
3080        fi
3081        AC_MSG_RESULT([${INCLUDE_DIR_NATIVE}])
3082    fi
3083])
3084
3085#------------------------------------------------------------------------
3086# TEA_PROG_TCLSH
3087#       Locate a tclsh shell in the following directories:
3088#               ${TCL_BIN_DIR}          ${TCL_BIN_DIR}/../bin
3089#               ${exec_prefix}/bin      ${prefix}/bin
3090#               ${PATH}
3091#
3092# Arguments
3093#       none
3094#
3095# Results
3096#       Subst's the following values:
3097#               TCLSH_PROG
3098#------------------------------------------------------------------------
3099
3100AC_DEFUN([TEA_PROG_TCLSH], [
3101    AC_MSG_CHECKING([for tclsh])
3102
3103    AC_CACHE_VAL(ac_cv_path_tclsh, [
3104        if test "x${CELIB_DIR}" != "x" ; then
3105            # If CELIB_DIR is defined, assume Windows/CE target is requested
3106            # which means target tclsh cannot be run (cross-compile)
3107            search_path=`echo ${PATH} | sed -e 's/:/ /g'`
3108        else
3109            search_path=`echo ${TCL_BIN_DIR}:${TCL_BIN_DIR}/../bin:${exec_prefix}/bin:${prefix}/bin:${PATH} | sed -e 's/:/ /g'`
3110        fi
3111        for dir in $search_path ; do
3112            for j in `ls -r $dir/tclsh[[8-9]]*${EXEEXT} 2> /dev/null` \
3113                    `ls -r $dir/tclsh*${EXEEXT} 2> /dev/null` ; do
3114                if test x"$ac_cv_path_tclsh" = x ; then
3115                    if test -f "$j" ; then
3116                        ac_cv_path_tclsh=$j
3117                        break
3118                    fi
3119                fi
3120            done
3121        done
3122    ])
3123
3124    if test -f "$ac_cv_path_tclsh" ; then
3125        TCLSH_PROG=$ac_cv_path_tclsh
3126        AC_MSG_RESULT([$TCLSH_PROG])
3127    else
3128        AC_MSG_ERROR([No tclsh found in PATH:  $search_path])
3129    fi
3130    AC_SUBST(TCLSH_PROG)
3131])
3132
3133#------------------------------------------------------------------------
3134# TEA_PROG_WISH
3135#       Locate a wish shell in the following directories:
3136#               ${TK_BIN_DIR}           ${TK_BIN_DIR}/../bin
3137#               ${TCL_BIN_DIR}          ${TCL_BIN_DIR}/../bin
3138#               ${exec_prefix}/bin      ${prefix}/bin
3139#               ${PATH}
3140#
3141# Arguments
3142#       none
3143#
3144# Results
3145#       Subst's the following values:
3146#               WISH_PROG
3147#------------------------------------------------------------------------
3148
3149AC_DEFUN([TEA_PROG_WISH], [
3150    AC_MSG_CHECKING([for wish])
3151
3152    AC_CACHE_VAL(ac_cv_path_wish, [
3153        if test "x${CELIB_DIR}" != "x" ; then
3154            # If CELIB_DIR is defined, assume Windows/CE target is requested
3155            # which means target wish cannot be run (cross-compile)
3156            search_path=`echo ${PATH} | sed -e 's/:/ /g'`
3157        else
3158            search_path=`echo ${TK_BIN_DIR}:${TK_BIN_DIR}/../bin:${TCL_BIN_DIR}:${TCL_BIN_DIR}/../bin:${exec_prefix}/bin:${prefix}/bin:${PATH} | sed -e 's/:/ /g'`
3159        fi
3160        for dir in $search_path ; do
3161            for j in `ls -r $dir/wish[[8-9]]*${EXEEXT} 2> /dev/null` \
3162                    `ls -r $dir/wish*${EXEEXT} 2> /dev/null` ; do
3163                if test x"$ac_cv_path_wish" = x ; then
3164                    if test -f "$j" ; then
3165                        ac_cv_path_wish=$j
3166                        break
3167                    fi
3168                fi
3169            done
3170        done
3171    ])
3172
3173    if test -f "$ac_cv_path_wish" ; then
3174        WISH_PROG=$ac_cv_path_wish
3175        AC_MSG_RESULT([$WISH_PROG])
3176    else
3177        AC_MSG_ERROR([No wish found in PATH:  $search_path])
3178    fi
3179    AC_SUBST(WISH_PROG)
3180])
3181
3182#------------------------------------------------------------------------
3183# TEA_PATH_CONFIG --
3184#
3185#       Locate the ${1}Config.sh file and perform a sanity check on
3186#       the ${1} compile flags.  These are used by packages like
3187#       [incr Tk] that load *Config.sh files from more than Tcl and Tk.
3188#
3189# Arguments:
3190#       none
3191#
3192# Results:
3193#
3194#       Adds the following arguments to configure:
3195#               --with-$1=...
3196#
3197#       Defines the following vars:
3198#               $1_BIN_DIR      Full path to the directory containing
3199#                               the $1Config.sh file
3200#------------------------------------------------------------------------
3201
3202AC_DEFUN([TEA_PATH_CONFIG], [
3203    #
3204    # Ok, lets find the $1 configuration
3205    # First, look for one uninstalled.
3206    # the alternative search directory is invoked by --with-$1
3207    #
3208
3209    if test x"${no_$1}" = x ; then
3210        # we reset no_$1 in case something fails here
3211        no_$1=true
3212        AC_ARG_WITH($1, [  --with-$1              directory containing $1 configuration ($1Config.sh)], with_$1config=${withval})
3213        AC_MSG_CHECKING([for $1 configuration])
3214        AC_CACHE_VAL(ac_cv_c_$1config,[
3215
3216            # First check to see if --with-$1 was specified.
3217            if test x"${with_$1config}" != x ; then
3218                if test -f "${with_$1config}/$1Config.sh" ; then
3219                    ac_cv_c_$1config=`(cd ${with_$1config}; pwd)`
3220                else
3221                    AC_MSG_ERROR([${with_$1config} directory doesn't contain $1Config.sh])
3222                fi
3223            fi
3224
3225            # then check for a private $1 installation
3226            if test x"${ac_cv_c_$1config}" = x ; then
3227                for i in \
3228                        ../$1 \
3229                        `ls -dr ../$1[[8-9]].[[0-9]]* 2>/dev/null` \
3230                        ../../$1 \
3231                        `ls -dr ../../$1[[8-9]].[[0-9]]* 2>/dev/null` \
3232                        ../../../$1 \
3233                        `ls -dr ../../../$1[[8-9]].[[0-9]]* 2>/dev/null` \
3234                        ${srcdir}/../$1 \
3235                        `ls -dr ${srcdir}/../$1[[8-9]].[[0-9]]* 2>/dev/null` \
3236                        ; do
3237                    if test -f "$i/$1Config.sh" ; then
3238                        ac_cv_c_$1config=`(cd $i; pwd)`
3239                        break
3240                    fi
3241                    if test -f "$i/unix/$1Config.sh" ; then
3242                        ac_cv_c_$1config=`(cd $i/unix; pwd)`
3243                        break
3244                    fi
3245                done
3246            fi
3247
3248            # check in a few common install locations
3249            if test x"${ac_cv_c_$1config}" = x ; then
3250                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
3251                        `ls -d ${prefix}/lib 2>/dev/null` \
3252                        `ls -d /usr/local/lib 2>/dev/null` \
3253                        `ls -d /usr/contrib/lib 2>/dev/null` \
3254                        `ls -d /usr/lib 2>/dev/null` \
3255                        ; do
3256                    if test -f "$i/$1Config.sh" ; then
3257                        ac_cv_c_$1config=`(cd $i; pwd)`
3258                        break
3259                    fi
3260                done
3261            fi
3262        ])
3263
3264        if test x"${ac_cv_c_$1config}" = x ; then
3265            $1_BIN_DIR="# no $1 configs found"
3266            AC_MSG_WARN("Cannot find $1 configuration definitions")
3267            exit 0
3268        else
3269            no_$1=
3270            $1_BIN_DIR=${ac_cv_c_$1config}
3271            AC_MSG_RESULT([found $$1_BIN_DIR/$1Config.sh])
3272        fi
3273    fi
3274])
3275
3276#------------------------------------------------------------------------
3277# TEA_LOAD_CONFIG --
3278#
3279#       Load the $1Config.sh file
3280#
3281# Arguments:
3282#       
3283#       Requires the following vars to be set:
3284#               $1_BIN_DIR
3285#
3286# Results:
3287#
3288#       Subst the following vars:
3289#               $1_SRC_DIR
3290#               $1_LIB_FILE
3291#               $1_LIB_SPEC
3292#
3293#------------------------------------------------------------------------
3294
3295AC_DEFUN([TEA_LOAD_CONFIG], [
3296    AC_MSG_CHECKING([for existence of ${$1_BIN_DIR}/$1Config.sh])
3297
3298    if test -f "${$1_BIN_DIR}/$1Config.sh" ; then
3299        AC_MSG_RESULT([loading])
3300        . ${$1_BIN_DIR}/$1Config.sh
3301    else
3302        AC_MSG_RESULT([file not found])
3303    fi
3304
3305    #
3306    # If the $1_BIN_DIR is the build directory (not the install directory),
3307    # then set the common variable name to the value of the build variables.
3308    # For example, the variable $1_LIB_SPEC will be set to the value
3309    # of $1_BUILD_LIB_SPEC. An extension should make use of $1_LIB_SPEC
3310    # instead of $1_BUILD_LIB_SPEC since it will work with both an
3311    # installed and uninstalled version of Tcl.
3312    #
3313
3314    if test -f ${$1_BIN_DIR}/Makefile ; then
3315        AC_MSG_WARN([Found Makefile - using build library specs for $1])
3316        $1_LIB_SPEC=${$1_BUILD_LIB_SPEC}
3317        $1_STUB_LIB_SPEC=${$1_BUILD_STUB_LIB_SPEC}
3318        $1_STUB_LIB_PATH=${$1_BUILD_STUB_LIB_PATH}
3319    fi
3320
3321    AC_SUBST($1_VERSION)
3322    AC_SUBST($1_SRC_DIR)
3323
3324    AC_SUBST($1_LIB_FILE)
3325    AC_SUBST($1_LIB_SPEC)
3326
3327    AC_SUBST($1_STUB_LIB_FILE)
3328    AC_SUBST($1_STUB_LIB_SPEC)
3329    AC_SUBST($1_STUB_LIB_PATH)
3330])
3331
3332#------------------------------------------------------------------------
3333# TEA_PATH_CELIB --
3334#
3335#       Locate Keuchel's celib emulation layer for targeting Win/CE
3336#
3337# Arguments:
3338#       none
3339#
3340# Results:
3341#
3342#       Adds the following arguments to configure:
3343#               --with-celib=...
3344#
3345#       Defines the following vars:
3346#               CELIB_DIR       Full path to the directory containing
3347#                               the include and platform lib files
3348#------------------------------------------------------------------------
3349
3350AC_DEFUN([TEA_PATH_CELIB], [
3351    # First, look for one uninstalled.
3352    # the alternative search directory is invoked by --with-celib
3353
3354    if test x"${no_celib}" = x ; then
3355        # we reset no_celib in case something fails here
3356        no_celib=true
3357        AC_ARG_WITH(celib,[  --with-celib=DIR        use Windows/CE support library from DIR], with_celibconfig=${withval})
3358        AC_MSG_CHECKING([for Windows/CE celib directory])
3359        AC_CACHE_VAL(ac_cv_c_celibconfig,[
3360            # First check to see if --with-celibconfig was specified.
3361            if test x"${with_celibconfig}" != x ; then
3362                if test -d "${with_celibconfig}/inc" ; then
3363                    ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)`
3364                else
3365                    AC_MSG_ERROR([${with_celibconfig} directory doesn't contain inc directory])
3366                fi
3367            fi
3368
3369            # then check for a celib library
3370            if test x"${ac_cv_c_celibconfig}" = x ; then
3371                for i in \
3372                        ../celib-palm-3.0 \
3373                        ../celib \
3374                        ../../celib-palm-3.0 \
3375                        ../../celib \
3376                        `ls -dr ../celib-*3.[[0-9]]* 2>/dev/null` \
3377                        ${srcdir}/../celib-palm-3.0 \
3378                        ${srcdir}/../celib \
3379                        `ls -dr ${srcdir}/../celib-*3.[[0-9]]* 2>/dev/null` \
3380                        ; do
3381                    if test -d "$i/inc" ; then
3382                        ac_cv_c_celibconfig=`(cd $i; pwd)`
3383                        break
3384                    fi
3385                done
3386            fi
3387        ])
3388        if test x"${ac_cv_c_celibconfig}" = x ; then
3389            CELIB_DIR="# no Celib configs found"
3390            AC_MSG_ERROR([Cannot find celib support library directory])
3391        else
3392            no_celib=
3393            CELIB_DIR=${ac_cv_c_celibconfig}
3394            AC_MSG_RESULT([found $CELIB_DIR])
3395        fi
3396    fi
3397])
Note: See TracBrowser for help on using the repository browser.