source: trunk/base/m4/tcl.m4 @ 140641

Last change on this file since 140641 was 118473, checked in by jmr@…, 6 years ago

revert r101415, base does not yet work with tcl 8.6 (#37583)

  • Property svn:eol-style set to native
File size: 76.0 KB
Line 
1# This file is based on the tcl.m4 file distributed with Tcl 8.4
2# Portions Copyright (2003) Apple Inc.
3#
4# Copyright and License for this file, copied verbatim from the official
5# Tcl distribution, follows:
6#
7# This software is copyrighted by the Regents of the University of
8# California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState
9# Corporation and other parties.  The following terms apply to all files
10# associated with the software unless explicitly disclaimed in
11# individual files.
12#
13# The authors hereby grant permission to use, copy, modify, distribute,
14# and license this software and its documentation for any purpose, provided
15# that existing copyright notices are retained in all copies and that this
16# notice is included verbatim in any distributions. No written agreement,
17# license, or royalty fee is required for any of the authorized uses.
18# Modifications to this software may be copyrighted by their authors
19# and need not follow the licensing terms described here, provided that
20# the new terms are clearly indicated on the first page of each file where
21# they apply.
22
23# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
24# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
25# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
26# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
27# POSSIBILITY OF SUCH DAMAGE.
28#
29# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
30# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
31# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
32# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
33# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
34# MODIFICATIONS.
35#
36# GOVERNMENT USE: If you are acquiring this software on behalf of the
37# U.S. government, the Government shall have only "Restricted Rights"
38# in the software and related documentation as defined in the Federal
39# Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
40# are acquiring the software on behalf of the Department of Defense, the
41# software shall be classified as "Commercial Computer Software" and the
42# Government shall have only "Restricted Rights" as defined in Clause
43# 252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
44# authors grant the U.S. Government and others acting in its behalf
45# permission to use and distribute the software in accordance with the
46# terms specified in this license.
47#
48#------------------------------------------------------------------------
49# SC_PATH_TCLCONFIG --
50#
51#       Locate the tclConfig.sh file and perform a sanity check on
52#       the Tcl compile flags
53#
54# Arguments:
55#       none
56#
57# Results:
58#
59#       Adds the following arguments to configure:
60#               --with-tcl=...
61#
62#       Defines the following vars:
63#               TCL_BIN_DIR     Full path to the directory containing
64#                               the tclConfig.sh file
65#------------------------------------------------------------------------
66
67AC_DEFUN(SC_PATH_TCLCONFIG, [
68    #
69    # Ok, lets find the tcl configuration
70    # First, look for one uninstalled.
71    # the alternative search directory is invoked by --with-tcl
72    #
73
74    if test x"${no_tcl}" = x ; then
75        # we reset no_tcl in case something fails here
76        no_tcl=true
77        AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
78        AC_MSG_CHECKING([for Tcl configuration])
79        AC_CACHE_VAL(ac_cv_c_tclconfig,[
80
81            # First check to see if --with-tcl was specified.
82            if test x"${with_tclconfig}" != x ; then
83                if test -f "${with_tclconfig}/tclConfig.sh" ; then
84                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
85                else
86                    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
87                fi
88            fi
89
90            # then check for a private Tcl installation
91            if test x"${ac_cv_c_tclconfig}" = x ; then
92                for i in \
93                        ../tcl \
94                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
95                        ../../tcl \
96                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
97                        ../../../tcl \
98                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
99                    if test -f "$i/unix/tclConfig.sh" ; then
100                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
101                        break
102                    fi
103                done
104            fi
105
106            # check in a few common install locations
107            if test x"${ac_cv_c_tclconfig}" = x ; then
108                for i in `ls -d ${libdir} 2>/dev/null` \
109                        `ls -d /usr/lib 2>/dev/null` \
110                        `ls -d /usr/local/lib 2>/dev/null` \
111                        `ls -d /usr/contrib/lib 2>/dev/null` \
112                        `ls -d /usr/pkg/lib 2>/dev/null` \
113                        `ls -d /usr/local/lib/tcl8.5 2>/dev/null` \
114                        `ls -d /usr/local/lib/tcl8.4 2>/dev/null` \
115                        `ls -d /usr/lib/tcl8.5 2>/dev/null` \
116                        `ls -d /usr/lib/tcl8.4 2>/dev/null` \
117                        ; do
118                    if test -f "$i/tclConfig.sh" ; then
119                        ac_cv_c_tclconfig=`(cd $i; pwd)`
120                        break
121                    fi
122                done
123            fi
124
125            # check in a few other private locations
126            if test x"${ac_cv_c_tclconfig}" = x ; then
127                for i in \
128                        ${srcdir}/../tcl \
129                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
130                    if test -f "$i/unix/tclConfig.sh" ; then
131                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
132                    break
133                fi
134                done
135            fi
136        ])
137
138        if test x"${ac_cv_c_tclconfig}" = x ; then
139            TCL_BIN_DIR="# no Tcl configs found"
140            AC_MSG_ERROR(Can't find Tcl configuration definitions)
141        else
142            no_tcl=
143            TCL_BIN_DIR=${ac_cv_c_tclconfig}
144            AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
145        fi
146    fi
147])
148
149#------------------------------------------------------------------------
150# SC_PATH_TKCONFIG --
151#
152#       Locate the tkConfig.sh file
153#
154# Arguments:
155#       none
156#
157# Results:
158#
159#       Adds the following arguments to configure:
160#               --with-tk=...
161#
162#       Defines the following vars:
163#               TK_BIN_DIR      Full path to the directory containing
164#                               the tkConfig.sh file
165#------------------------------------------------------------------------
166
167AC_DEFUN(SC_PATH_TKCONFIG, [
168    #
169    # Ok, lets find the tk configuration
170    # First, look for one uninstalled.
171    # the alternative search directory is invoked by --with-tk
172    #
173
174    if test x"${no_tk}" = x ; then
175        # we reset no_tk in case something fails here
176        no_tk=true
177        AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
178        AC_MSG_CHECKING([for Tk configuration])
179        AC_CACHE_VAL(ac_cv_c_tkconfig,[
180
181            # First check to see if --with-tkconfig was specified.
182            if test x"${with_tkconfig}" != x ; then
183                if test -f "${with_tkconfig}/tkConfig.sh" ; then
184                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
185                else
186                    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
187                fi
188            fi
189
190            # then check for a private Tk library
191            if test x"${ac_cv_c_tkconfig}" = x ; then
192                for i in \
193                        ../tk \
194                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
195                        ../../tk \
196                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
197                        ../../../tk \
198                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
199                    if test -f "$i/unix/tkConfig.sh" ; then
200                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
201                        break
202                    fi
203                done
204            fi
205            # check in a few common install locations
206            if test x"${ac_cv_c_tkconfig}" = x ; then
207                for i in `ls -d ${libdir} 2>/dev/null` \
208                        `ls -d /usr/local/lib 2>/dev/null` \
209                        `ls -d /usr/contrib/lib 2>/dev/null` \
210                        `ls -d /usr/lib 2>/dev/null` \
211                        ; do
212                    if test -f "$i/tkConfig.sh" ; then
213                        ac_cv_c_tkconfig=`(cd $i; pwd)`
214                        break
215                    fi
216                done
217            fi
218            # check in a few other private locations
219            if test x"${ac_cv_c_tkconfig}" = x ; then
220                for i in \
221                        ${srcdir}/../tk \
222                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
223                    if test -f "$i/unix/tkConfig.sh" ; then
224                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
225                        break
226                    fi
227                done
228            fi
229        ])
230        if test x"${ac_cv_c_tkconfig}" = x ; then
231            TK_BIN_DIR="# no Tk configs found"
232            AC_MSG_WARN(Can't find Tk configuration definitions)
233            exit 0
234        else
235            no_tk=
236            TK_BIN_DIR=${ac_cv_c_tkconfig}
237            AC_MSG_RESULT(found $TK_BIN_DIR/tkConfig.sh)
238        fi
239    fi
240
241])
242
243#------------------------------------------------------------------------
244# SC_LOAD_TCLCONFIG --
245#
246#       Load the tclConfig.sh file
247#
248# Arguments:
249#       
250#       Requires the following vars to be set:
251#               TCL_BIN_DIR
252#
253# Results:
254#
255#       Subst the following vars:
256#               TCL_BIN_DIR
257#               TCL_SRC_DIR
258#               TCL_LIB_FILE
259#
260#------------------------------------------------------------------------
261
262AC_DEFUN(SC_LOAD_TCLCONFIG, [
263    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
264
265    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
266        AC_MSG_RESULT([loading])
267        . $TCL_BIN_DIR/tclConfig.sh
268    else
269        AC_MSG_RESULT([file not found])
270    fi
271
272    #
273    # If the TCL_BIN_DIR is the build directory (not the install directory),
274    # then set the common variable name to the value of the build variables.
275    # For example, the variable TCL_LIB_SPEC will be set to the value
276    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
277    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
278    # installed and uninstalled version of Tcl.
279    #
280
281    if test -f $TCL_BIN_DIR/Makefile ; then
282        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
283        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
284        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
285    fi
286
287    #
288    # eval is required to do the TCL_DBGX substitution
289    #
290
291    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
292    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
293    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
294
295    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
296    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
297    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
298
299    AC_SUBST(TCL_VERSION)
300    AC_SUBST(TCL_BIN_DIR)
301    AC_SUBST(TCL_SRC_DIR)
302
303    AC_SUBST(TCL_LIB_FILE)
304    AC_SUBST(TCL_LIB_FLAG)
305    AC_SUBST(TCL_LIB_SPEC)
306
307    AC_SUBST(TCL_STUB_LIB_FILE)
308    AC_SUBST(TCL_STUB_LIB_FLAG)
309    AC_SUBST(TCL_STUB_LIB_SPEC)
310])
311
312#------------------------------------------------------------------------
313# SC_LOAD_TKCONFIG --
314#
315#       Load the tkConfig.sh file
316#
317# Arguments:
318#       
319#       Requires the following vars to be set:
320#               TK_BIN_DIR
321#
322# Results:
323#
324#       Sets the following vars that should be in tkConfig.sh:
325#               TK_BIN_DIR
326#------------------------------------------------------------------------
327
328AC_DEFUN(SC_LOAD_TKCONFIG, [
329    AC_MSG_CHECKING([for existence of $TK_BIN_DIR/tkConfig.sh])
330
331    if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
332        AC_MSG_RESULT([loading])
333        . $TK_BIN_DIR/tkConfig.sh
334    else
335        AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
336    fi
337
338    AC_SUBST(TK_VERSION)
339    AC_SUBST(TK_BIN_DIR)
340    AC_SUBST(TK_SRC_DIR)
341    AC_SUBST(TK_LIB_FILE)
342])
343
344#------------------------------------------------------------------------
345# SC_ENABLE_SHARED --
346#
347#       Allows the building of shared libraries
348#
349# Arguments:
350#       none
351#       
352# Results:
353#
354#       Adds the following arguments to configure:
355#               --enable-shared=yes|no
356#
357#       Defines the following vars:
358#               STATIC_BUILD    Used for building import/export libraries
359#                               on Windows.
360#
361#       Sets the following vars:
362#               SHARED_BUILD    Value of 1 or 0
363#------------------------------------------------------------------------
364
365AC_DEFUN(SC_ENABLE_SHARED, [
366    AC_MSG_CHECKING([how to build libraries])
367    AC_ARG_ENABLE(shared,
368        [  --enable-shared         build and link with shared libraries [--enable-shared]],
369        [tcl_ok=$enableval], [tcl_ok=yes])
370
371    if test "${enable_shared+set}" = set; then
372        enableval="$enable_shared"
373        tcl_ok=$enableval
374    else
375        tcl_ok=yes
376    fi
377
378    if test "$tcl_ok" = "yes" ; then
379        AC_MSG_RESULT([shared])
380        SHARED_BUILD=1
381    else
382        AC_MSG_RESULT([static])
383        SHARED_BUILD=0
384        AC_DEFINE([STATIC_BUILD], [1], [Define to 1 if static build is requested])
385    fi
386])
387
388#------------------------------------------------------------------------
389# SC_ENABLE_FRAMEWORK --
390#
391#       Allows the building of shared libraries into frameworks
392#
393# Arguments:
394#       none
395#       
396# Results:
397#
398#       Adds the following arguments to configure:
399#               --enable-framework=yes|no
400#
401#       Sets the following vars:
402#               FRAMEWORK_BUILD Value of 1 or 0
403#------------------------------------------------------------------------
404
405AC_DEFUN(SC_ENABLE_FRAMEWORK, [
406    AC_MSG_CHECKING([how to package libraries])
407    AC_ARG_ENABLE(framework,
408        [  --enable-framework      package shared libraries in frameworks [--disable-framework]],
409        [tcl_ok=$enableval], [tcl_ok=no])
410
411    if test "${enable_framework+set}" = set; then
412        enableval="$enable_framework"
413        tcl_ok=$enableval
414    else
415        tcl_ok=no
416    fi
417
418    if test "$tcl_ok" = "yes" ; then
419        AC_MSG_RESULT([framework])
420        FRAMEWORK_BUILD=1
421        if test "${SHARED_BUILD}" = "0" ; then
422            AC_MSG_WARN("Frameworks can only be built if --enable-shared is yes")
423            FRAMEWORK_BUILD=0
424        fi
425    else
426        AC_MSG_RESULT([standard shared library])
427        FRAMEWORK_BUILD=0
428    fi
429])
430
431#------------------------------------------------------------------------
432# SC_ENABLE_THREADS --
433#
434#       Specify if thread support should be enabled
435#
436# Arguments:
437#       none
438#       
439# Results:
440#
441#       Adds the following arguments to configure:
442#               --enable-threads
443#
444#       Sets the following vars:
445#               THREADS_LIBS    Thread library(s)
446#
447#       Defines the following vars:
448#               TCL_THREADS
449#               _REENTRANT
450#               _THREAD_SAFE
451#
452#------------------------------------------------------------------------
453
454AC_DEFUN(SC_ENABLE_THREADS, [
455    AC_MSG_CHECKING(for building with threads)
456    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
457        [tcl_ok=$enableval], [tcl_ok=no])
458
459    if test "$tcl_ok" = "yes"; then
460        AC_MSG_RESULT(yes)
461        TCL_THREADS=1
462        AC_DEFINE(TCL_THREADS)
463        # USE_THREAD_ALLOC tells us to try the special thread-based
464        # allocator that significantly reduces lock contention
465        AC_DEFINE(USE_THREAD_ALLOC)
466        AC_DEFINE(_REENTRANT)
467        AC_DEFINE(_THREAD_SAFE)
468        AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
469        if test "$tcl_ok" = "no"; then
470            # Check a little harder for __pthread_mutex_init in the same
471            # library, as some systems hide it there until pthread.h is
472            # defined.  We could alternatively do an AC_TRY_COMPILE with
473            # pthread.h, but that will work with libpthread really doesn't
474            # exist, like AIX 4.2.  [Bug: 4359]
475            AC_CHECK_LIB(pthread,__pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
476        fi
477
478        if test "$tcl_ok" = "yes"; then
479            # The space is needed
480            THREADS_LIBS=" -lpthread"
481        else
482            AC_CHECK_LIB(pthreads,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
483            if test "$tcl_ok" = "yes"; then
484                # The space is needed
485                THREADS_LIBS=" -lpthreads"
486            else
487                AC_CHECK_LIB(c,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
488                if test "$tcl_ok" = "no"; then
489                    AC_CHECK_LIB(c_r,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
490                    if test "$tcl_ok" = "yes"; then
491                        # The space is needed
492                        THREADS_LIBS=" -pthread"
493                    else
494                        TCL_THREADS=0
495                        AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")
496                    fi
497                fi
498            fi
499        fi
500
501        # Does the pthread-implementation provide
502        # 'pthread_attr_setstacksize' ?
503
504        ac_saved_libs=$LIBS
505        LIBS="$LIBS $THREADS_LIBS"
506        AC_CHECK_FUNCS(pthread_attr_setstacksize)
507        LIBS=$ac_saved_libs
508        AC_CHECK_FUNCS(readdir_r)
509    else
510        TCL_THREADS=0
511        AC_MSG_RESULT([no (default)])
512    fi
513    AC_SUBST(TCL_THREADS)
514])
515
516#------------------------------------------------------------------------
517# SC_ENABLE_SYMBOLS --
518#
519#       Specify if debugging symbols should be used.
520#       Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
521#       can also be enabled.
522#
523# Arguments:
524#       none
525#       
526#       Requires the following vars to be set in the Makefile:
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(SC_ENABLE_SYMBOLS, [
547    AC_MSG_CHECKING([for build with symbols])
548    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
549# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
550    if test "$tcl_ok" = "no"; then
551        CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
552        LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
553        DBGX=""
554        AC_MSG_RESULT([no])
555    else
556        CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
557        LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
558        DBGX=g
559        if test "$tcl_ok" = "yes"; then
560            AC_MSG_RESULT([yes (standard debugging)])
561        fi
562    fi
563    AC_SUBST(CFLAGS_DEFAULT)
564    AC_SUBST(LDFLAGS_DEFAULT)
565
566    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
567        AC_DEFINE(TCL_MEM_DEBUG)
568    fi
569
570    if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
571        AC_DEFINE(TCL_COMPILE_DEBUG)
572        AC_DEFINE(TCL_COMPILE_STATS)
573    fi
574
575    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
576        if test "$tcl_ok" = "all"; then
577            AC_MSG_RESULT([enabled symbols mem compile debugging])
578        else
579            AC_MSG_RESULT([enabled $tcl_ok debugging])
580        fi
581    fi
582])
583
584#------------------------------------------------------------------------
585# SC_ENABLE_LANGINFO --
586#
587#       Allows use of modern nl_langinfo check for better l10n.
588#       This is only relevant for Unix.
589#
590# Arguments:
591#       none
592#       
593# Results:
594#
595#       Adds the following arguments to configure:
596#               --enable-langinfo=yes|no (default is yes)
597#
598#       Defines the following vars:
599#               HAVE_LANGINFO   Triggers use of nl_langinfo if defined.
600#
601#------------------------------------------------------------------------
602
603AC_DEFUN(SC_ENABLE_LANGINFO, [
604    AC_ARG_ENABLE(langinfo,
605        [  --enable-langinfo      use nl_langinfo if possible to determine
606                          encoding at startup, otherwise use old heuristic],
607        [langinfo_ok=$enableval], [langinfo_ok=yes])
608
609    HAVE_LANGINFO=0
610    if test "$langinfo_ok" = "yes"; then
611        if test "$langinfo_ok" = "yes"; then
612            AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
613        fi
614    fi
615    AC_MSG_CHECKING([whether to use nl_langinfo])
616    if test "$langinfo_ok" = "yes"; then
617        AC_TRY_COMPILE([#include <langinfo.h>],
618                [nl_langinfo(CODESET);],[langinfo_ok=yes],[langinfo_ok=no])
619        if test "$langinfo_ok" = "no"; then
620            langinfo_ok="no (could not compile with nl_langinfo)";
621        fi
622        if test "$langinfo_ok" = "yes"; then
623            AC_DEFINE(HAVE_LANGINFO)
624        fi
625    fi
626    AC_MSG_RESULT([$langinfo_ok])
627])
628
629#--------------------------------------------------------------------
630# SC_CONFIG_MANPAGES
631#       
632#       Decide whether to use symlinks for linking the manpages and
633#       whether to compress the manpages after installation.
634#
635# Arguments:
636#       none
637#
638# Results:
639#
640#       Adds the following arguments to configure:
641#               --enable-man-symlinks
642#               --enable-man-compression=PROG
643#
644#       Defines the following variable:
645#
646#       MKLINKS_FLAGS -         The apropriate flags for mkLinks
647#                               according to the user's selection.
648#
649#--------------------------------------------------------------------
650AC_DEFUN(SC_CONFIG_MANPAGES, [
651
652        AC_MSG_CHECKING([whether to use symlinks for manpages])
653        AC_ARG_ENABLE(man-symlinks,
654                [  --enable-man-symlinks   use symlinks for the manpages],
655                test "$enableval" != "no" && MKLINKS_FLAGS="$MKLINKS_FLAGS --symlinks",
656                enableval="no")
657        AC_MSG_RESULT([$enableval])
658
659        AC_MSG_CHECKING([compression for manpages])
660        AC_ARG_ENABLE(man-compression,
661                [  --enable-man-compression=PROG
662                          compress the manpages with PROG],
663                test "$enableval" = "yes" && echo && AC_MSG_ERROR([missing argument to --enable-man-compression])
664                test "$enableval" != "no" && MKLINKS_FLAGS="$MKLINKS_FLAGS --compress $enableval",
665                enableval="no")
666        AC_MSG_RESULT([$enableval])
667
668        AC_SUBST(MKLINKS_FLAGS)
669])
670
671#--------------------------------------------------------------------
672# SC_CONFIG_CFLAGS
673#
674#       Try to determine the proper flags to pass to the compiler
675#       for building shared libraries and other such nonsense.
676#
677# Arguments:
678#       none
679#
680# Results:
681#
682#       Defines and substitutes the following vars:
683#
684#       DL_OBJS -       Name of the object file that implements dynamic
685#                       loading for Tcl on this system.
686#       DL_LIBS -       Library file(s) to include in tclsh and other base
687#                       applications in order for the "load" command to work.
688#       LDFLAGS -      Flags to pass to the compiler when linking object
689#                       files into an executable application binary such
690#                       as tclsh.
691#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
692#                       that tell the run-time dynamic linker where to look
693#                       for shared libraries such as libtcl.so.  Depends on
694#                       the variable LIB_RUNTIME_DIR in the Makefile. Could
695#                       be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
696#       CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
697#                       that tell the run-time dynamic linker where to look
698#                       for shared libraries such as libtcl.so.  Depends on
699#                       the variable LIB_RUNTIME_DIR in the Makefile.
700#       MAKE_LIB -      Command to execute to build the a library;
701#                       differs when building shared or static.
702#       MAKE_STUB_LIB -
703#                       Command to execute to build a stub library.
704#       INSTALL_LIB -   Command to execute to install a library;
705#                       differs when building shared or static.
706#       INSTALL_STUB_LIB -
707#                       Command to execute to install a stub library.
708#       STLIB_LD -      Base command to use for combining object files
709#                       into a static library.
710#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
711#                       of a shared library (may request position-independent
712#                       code, among other things).
713#       SHLIB_LD -      Base command to use for combining object files
714#                       into a shared library.
715#       SHLIB_LD_FLAGS -Flags to pass when building a shared library. This
716#                       differes from the SHLIB_CFLAGS as it is not used
717#                       when building object files or executables.
718#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
719#                       creating shared libraries.  This symbol typically
720#                       goes at the end of the "ld" commands that build
721#                       shared libraries. The value of the symbol is
722#                       "${LIBS}" if all of the dependent libraries should
723#                       be specified when creating a shared library.  If
724#                       dependent libraries should not be specified (as on
725#                       SunOS 4.x, where they cause the link to fail, or in
726#                       general if Tcl and Tk aren't themselves shared
727#                       libraries), then this symbol has an empty string
728#                       as its value.
729#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
730#                       extensions.  An empty string means we don't know how
731#                       to use shared libraries on this platform.
732# TCL_SHLIB_LD_EXTRAS - Additional element which are added to SHLIB_LD_LIBS
733#  TK_SHLIB_LD_EXTRAS   for the build of Tcl and Tk, but not recorded in the
734#                       tclConfig.sh, since they are only used for the build
735#                       of Tcl and Tk.
736#                       Examples: MacOS X records the library version and
737#                       compatibility version in the shared library.  But
738#                       of course the Tcl version of this is only used for Tcl.
739#       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
740#                       in a static or shared library name, using the $VERSION variable
741#                       to put the version in the right place.  This is used
742#                       by platforms that need non-standard library names.
743#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
744#                       to have a version after the .so, and ${VERSION}.a
745#                       on AIX, since a shared library needs to have
746#                       a .a extension whereas shared objects for loadable
747#                       extensions have a .so extension.  Defaults to
748#                       ${VERSION}${SHLIB_SUFFIX}.
749#       TCL_NEEDS_EXP_FILE -
750#                       1 means that an export file is needed to link to a
751#                       shared library.
752#       TCL_EXP_FILE -  The name of the installed export / import file which
753#                       should be used to link to the Tcl shared library.
754#                       Empty if Tcl is unshared.
755#       TCL_BUILD_EXP_FILE -
756#                       The name of the built export / import file which
757#                       should be used to link to the Tcl shared library.
758#                       Empty if Tcl is unshared.
759#       CFLAGS_DEBUG -
760#                       Flags used when running the compiler in debug mode
761#       CFLAGS_OPTIMIZE -
762#                       Flags used when running the compiler in optimize mode
763#       EXTRA_CFLAGS
764#
765#--------------------------------------------------------------------
766
767AC_DEFUN(SC_CONFIG_CFLAGS, [
768
769    # Step 0.a: Enable 64 bit support?
770
771    AC_MSG_CHECKING([if 64bit support is requested])
772    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support (where applicable)],,enableval="no")
773
774    if test "$enableval" = "yes"; then
775        do64bit=yes
776    else
777        do64bit=no
778    fi
779    AC_MSG_RESULT($do64bit)
780
781    # Step 0.b: Enable Solaris 64 bit VIS support?
782
783    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
784    AC_ARG_ENABLE(64bit-vis,[  --enable-64bit-vis      enable 64bit Sparc VIS support],,enableval="no")
785
786    if test "$enableval" = "yes"; then
787        # Force 64bit on with VIS
788        do64bit=yes
789        do64bitVIS=yes
790    else
791        do64bitVIS=no
792    fi
793    AC_MSG_RESULT($do64bitVIS)
794
795    # Step 1: set the variable "system" to hold the name and version number
796    # for the system.  This can usually be done via the "uname" command, but
797    # there are a few systems, like Next, where this doesn't work.
798
799    AC_MSG_CHECKING([system version (for dynamic loading)])
800    if test -f /usr/lib/NextStep/software_version; then
801        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
802    else
803        system=`uname -s`-`uname -r`
804        if test "$?" -ne 0 ; then
805            AC_MSG_RESULT([unknown (can't find uname command)])
806            system=unknown
807        else
808            # Special check for weird MP-RAS system (uname returns weird
809            # results, and the version is kept in special file).
810       
811            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
812                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
813            fi
814            if test "`uname -s`" = "AIX" ; then
815                system=AIX-`uname -v`.`uname -r`
816            fi
817            AC_MSG_RESULT($system)
818        fi
819    fi
820
821    # Step 2: check for existence of -ldl library.  This is needed because
822    # Linux can use either -ldl or -ldld for dynamic loading.
823
824    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
825
826    # Require ranlib early so we can override it in special cases below.
827
828    AC_REQUIRE([AC_PROG_RANLIB])
829
830    # Step 3: set configuration options based on system name and version.
831
832    do64bit_ok=no
833    EXTRA_CFLAGS=""
834    TCL_EXPORT_FILE_SUFFIX=""
835    UNSHARED_LIB_SUFFIX=""
836    TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
837    ECHO_VERSION='`echo ${VERSION}`'
838    TCL_LIB_VERSIONS_OK=ok
839    CFLAGS_DEBUG=-g
840    CFLAGS_OPTIMIZE=-O
841    if test "$GCC" = "yes" ; then
842        CFLAGS_WARNING="-Wall -Wconversion -Wno-implicit-int"
843    else
844        CFLAGS_WARNING=""
845    fi
846    TCL_NEEDS_EXP_FILE=0
847    TCL_BUILD_EXP_FILE=""
848    TCL_EXP_FILE=""
849dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
850dnl AC_CHECK_TOOL(AR, ar)
851    AC_CHECK_PROG(AR, ar, ar)
852    if test "${AR}" = "" ; then
853        AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
854    fi
855    STLIB_LD='${AR} cr'
856    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
857    PLAT_OBJS=""
858    case $system in
859        AIX-5.*)
860            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
861                # AIX requires the _r compiler when gcc isn't being used
862                if test "${CC}" != "cc_r" ; then
863                    CC=${CC}_r
864                fi
865                AC_MSG_RESULT(Using $CC for compiling with threads)
866            fi
867            LIBS="$LIBS -lc"
868            # AIX-5 uses ELF style dynamic libraries
869            SHLIB_CFLAGS=""
870            SHLIB_LD_LIBS='${LIBS}'
871            SHLIB_SUFFIX=".so"
872            if test "`uname -m`" = "ia64" ; then
873                # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
874                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
875                # AIX-5 has dl* in libc.so
876                DL_LIBS=""
877                if test "$GCC" = "yes" ; then
878                    CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
879                else
880                    CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
881                fi
882                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
883            else
884                SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
885                DL_LIBS="-ldl"
886                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
887                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
888                TCL_NEEDS_EXP_FILE=1
889                TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
890            fi
891
892            # Note: need the LIBS below, otherwise Tk won't find Tcl's
893            # symbols when dynamically loaded into tclsh.
894
895            DL_OBJS="tclLoadDl.o"
896            LDFLAGS=""
897
898            LD_LIBRARY_PATH_VAR="LIBPATH"
899
900            # Check to enable 64-bit flags for compiler/linker
901            if test "$do64bit" = "yes" ; then
902                if test "$GCC" = "yes" ; then
903                    AC_MSG_WARN("64bit mode not supported with GCC on $system")
904                else
905                    do64bit_ok=yes
906                    EXTRA_CFLAGS="-q64"
907                    LDFLAGS="-q64"
908                    RANLIB="${RANLIB} -X64"
909                    AR="${AR} -X64"
910                    SHLIB_LD_FLAGS="-b64"
911                fi
912            fi
913            ;;
914        AIX-*)
915            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
916                # AIX requires the _r compiler when gcc isn't being used
917                if test "${CC}" != "cc_r" ; then
918                    CC=${CC}_r
919                fi
920                AC_MSG_RESULT(Using $CC for compiling with threads)
921            fi
922            LIBS="$LIBS -lc"
923            SHLIB_CFLAGS=""
924            SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
925            SHLIB_LD_LIBS='${LIBS}'
926            SHLIB_SUFFIX=".so"
927            DL_OBJS="tclLoadDl.o"
928            DL_LIBS="-ldl"
929            LDFLAGS=""
930            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
931            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
932            LD_LIBRARY_PATH_VAR="LIBPATH"
933            TCL_NEEDS_EXP_FILE=1
934            TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
935
936            # AIX v<=4.1 has some different flags than 4.2+
937            if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
938                LIBOBJS="$LIBOBJS tclLoadAix.o"
939                DL_LIBS="-lld"
940            fi
941
942            # On AIX <=v4 systems, libbsd.a has to be linked in to support
943            # non-blocking file IO.  This library has to be linked in after
944            # the MATH_LIBS or it breaks the pow() function.  The way to
945            # insure proper sequencing, is to add it to the tail of MATH_LIBS.
946            # This library also supplies gettimeofday.
947            #
948            # AIX does not have a timezone field in struct tm. When the AIX
949            # bsd library is used, the timezone global and the gettimeofday
950            # methods are to be avoided for timezone deduction instead, we
951            # deduce the timezone by comparing the localtime result on a
952            # known GMT value.
953
954            AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
955            if test $libbsd = yes; then
956                MATH_LIBS="$MATH_LIBS -lbsd"
957                AC_DEFINE(USE_DELTA_FOR_TZ)
958            fi
959
960            # Check to enable 64-bit flags for compiler/linker
961            if test "$do64bit" = "yes" ; then
962                if test "$GCC" = "yes" ; then
963                    AC_MSG_WARN("64bit mode not supported with GCC on $system")
964                else
965                    do64bit_ok=yes
966                    EXTRA_CFLAGS="-q64"
967                    LDFLAGS="-q64"
968                    RANLIB="${RANLIB} -X64"
969                    AR="${AR} -X64"
970                    SHLIB_LD_FLAGS="-b64"
971                fi
972            fi
973            ;;
974        BSD/OS-2.1*|BSD/OS-3*)
975            SHLIB_CFLAGS=""
976            SHLIB_LD="shlicc -r"
977            SHLIB_LD_LIBS='${LIBS}'
978            SHLIB_SUFFIX=".so"
979            DL_OBJS="tclLoadDl.o"
980            DL_LIBS="-ldl"
981            LDFLAGS=""
982            CC_SEARCH_FLAGS=""
983            LD_SEARCH_FLAGS=""
984            ;;
985        BSD/OS-4.*)
986            SHLIB_CFLAGS="-export-dynamic -fPIC"
987            SHLIB_LD="cc -shared"
988            SHLIB_LD_LIBS='${LIBS}'
989            SHLIB_SUFFIX=".so"
990            DL_OBJS="tclLoadDl.o"
991            DL_LIBS="-ldl"
992            LDFLAGS="-export-dynamic"
993            CC_SEARCH_FLAGS=""
994            LD_SEARCH_FLAGS=""
995            ;;
996        dgux*)
997            SHLIB_CFLAGS="-K PIC"
998            SHLIB_LD="cc -G"
999            SHLIB_LD_LIBS=""
1000            SHLIB_SUFFIX=".so"
1001            DL_OBJS="tclLoadDl.o"
1002            DL_LIBS="-ldl"
1003            LDFLAGS=""
1004            CC_SEARCH_FLAGS=""
1005            LD_SEARCH_FLAGS=""
1006            ;;
1007        HP-UX-*.11.*)
1008            # Use updated header definitions where possible
1009            AC_DEFINE(_XOPEN_SOURCE)          # Use the XOPEN network library
1010            AC_DEFINE(_XOPEN_SOURCE_EXTENDED) # Use the XOPEN network library
1011            LIBS="$LIBS -lxnet"               # Use the XOPEN network library
1012
1013            SHLIB_SUFFIX=".sl"
1014            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1015            if test "$tcl_ok" = yes; then
1016                SHLIB_CFLAGS="+z"
1017                SHLIB_LD="ld -b"
1018                SHLIB_LD_LIBS='${LIBS}'
1019                DL_OBJS="tclLoadShl.o"
1020                DL_LIBS="-ldld"
1021                LDFLAGS="-Wl,-E"
1022                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1023                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1024                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1025            fi
1026
1027            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
1028            #EXTRA_CFLAGS="+DAportable"
1029
1030            # Check to enable 64-bit flags for compiler/linker
1031            if test "$do64bit" = "yes" ; then
1032                if test "$GCC" = "yes" ; then
1033                    hpux_arch=`gcc -dumpmachine`
1034                    case $hpux_arch in
1035                        hppa64*)
1036                            # 64-bit gcc in use.  Fix flags for GNU ld.
1037                            do64bit_ok=yes
1038                            SHLIB_LD="gcc -shared"
1039                            SHLIB_LD_LIBS=""
1040                            LD_SEARCH_FLAGS=''
1041                            CC_SEARCH_FLAGS=''
1042                            ;;
1043                        *)
1044                            AC_MSG_WARN("64bit mode not supported with GCC on $system")
1045                            ;;
1046                    esac
1047                else
1048                    do64bit_ok=yes
1049                    if test "`uname -m`" = "ia64" ; then
1050                        EXTRA_CFLAGS="+DD64"
1051                        LDFLAGS="+DD64 $LDFLAGS"
1052                    else
1053                        EXTRA_CFLAGS="+DA2.0W"
1054                        LDFLAGS="+DA2.0W $LDFLAGS"
1055                    fi
1056                fi
1057            fi
1058            ;;
1059        HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
1060            SHLIB_SUFFIX=".sl"
1061            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1062            if test "$tcl_ok" = yes; then
1063                SHLIB_CFLAGS="+z"
1064                SHLIB_LD="ld -b"
1065                SHLIB_LD_LIBS=""
1066                DL_OBJS="tclLoadShl.o"
1067                DL_LIBS="-ldld"
1068                LDFLAGS="-Wl,-E"
1069                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1070                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1071                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1072            fi
1073            ;;
1074        IRIX-4.*)
1075            SHLIB_CFLAGS="-G 0"
1076            SHLIB_SUFFIX=".a"
1077            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1078            SHLIB_LD_LIBS='${LIBS}'
1079            DL_OBJS="tclLoadAout.o"
1080            DL_LIBS=""
1081            LDFLAGS="-Wl,-D,08000000"
1082            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1083            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1084            SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1085            ;;
1086        IRIX-5.*)
1087            SHLIB_CFLAGS=""
1088            SHLIB_LD="ld -shared -rdata_shared"
1089            SHLIB_LD_LIBS='${LIBS}'
1090            SHLIB_SUFFIX=".so"
1091            DL_OBJS="tclLoadDl.o"
1092            DL_LIBS=""
1093            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1094            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1095            EXTRA_CFLAGS=""
1096            LDFLAGS=""
1097            ;;
1098        IRIX-6.*|IRIX64-6.5*)
1099            SHLIB_CFLAGS=""
1100            SHLIB_LD="ld -n32 -shared -rdata_shared"
1101            SHLIB_LD_LIBS='${LIBS}'
1102            SHLIB_SUFFIX=".so"
1103            DL_OBJS="tclLoadDl.o"
1104            DL_LIBS=""
1105            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1106            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1107            if test "$GCC" = "yes" ; then
1108                EXTRA_CFLAGS="-mabi=n32"
1109                LDFLAGS="-mabi=n32"
1110            else
1111                case $system in
1112                    IRIX-6.3)
1113                        # Use to build 6.2 compatible binaries on 6.3.
1114                        EXTRA_CFLAGS="-n32 -D_OLD_TERMIOS"
1115                        ;;
1116                    *)
1117                        EXTRA_CFLAGS="-n32"
1118                        ;;
1119                esac
1120                LDFLAGS="-n32"
1121            fi
1122            ;;
1123        IRIX64-6.*)
1124            SHLIB_CFLAGS=""
1125            SHLIB_LD="ld -n32 -shared -rdata_shared"
1126            SHLIB_LD_LIBS='${LIBS}'
1127            SHLIB_SUFFIX=".so"
1128            DL_OBJS="tclLoadDl.o"
1129            DL_LIBS=""
1130            LDFLAGS=""
1131            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1132            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1133
1134            # Check to enable 64-bit flags for compiler/linker
1135
1136            if test "$do64bit" = "yes" ; then
1137                if test "$GCC" = "yes" ; then
1138                    AC_MSG_WARN([64bit mode not supported by gcc])
1139                else
1140                    do64bit_ok=yes
1141                    SHLIB_LD="ld -64 -shared -rdata_shared"
1142                    EXTRA_CFLAGS="-64"
1143                    LDFLAGS="-64"
1144                fi
1145            fi
1146            ;;
1147        Linux*)
1148            SHLIB_CFLAGS="-fPIC"
1149            SHLIB_LD_LIBS='${LIBS}'
1150            SHLIB_SUFFIX=".so"
1151
1152            # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
1153            # when you inline the string and math operations.  Turn this off to
1154            # get rid of the warnings.
1155
1156            CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
1157
1158            if test "$have_dl" = yes; then
1159                SHLIB_LD="${CC} -shared"
1160                DL_OBJS="tclLoadDl.o"
1161                DL_LIBS="-ldl"
1162                LDFLAGS="-rdynamic"
1163                CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1164                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1165            else
1166                AC_CHECK_HEADER(dld.h, [
1167                    SHLIB_LD="ld -shared"
1168                    DL_OBJS="tclLoadDld.o"
1169                    DL_LIBS="-ldld"
1170                    LDFLAGS=""
1171                    CC_SEARCH_FLAGS=""
1172                    LD_SEARCH_FLAGS=""])
1173            fi
1174            if test "`uname -m`" = "alpha" ; then
1175                EXTRA_CFLAGS="-mieee"
1176            fi
1177
1178            # The combo of gcc + glibc has a bug related
1179            # to inlining of functions like strtod(). The
1180            # -fno-builtin flag should address this problem
1181            # but it does not work. The -fno-inline flag
1182            # is kind of overkill but it works.
1183            # Disable inlining only when one of the
1184            # files in compat/*.c is being linked in.
1185            if test x"${LIBOBJS}" != x ; then
1186                EXTRA_CFLAGS="${EXTRA_CFLAGS} -fno-inline"
1187            fi
1188
1189            # XIM peeking works under XFree86.
1190            AC_DEFINE(PEEK_XCLOSEIM)
1191
1192            ;;
1193        GNU*)
1194            SHLIB_CFLAGS="-fPIC"
1195            SHLIB_LD_LIBS='${LIBS}'
1196            SHLIB_SUFFIX=".so"
1197
1198            if test "$have_dl" = yes; then
1199                SHLIB_LD="${CC} -shared"
1200                DL_OBJS=""
1201                DL_LIBS="-ldl"
1202                LDFLAGS="-rdynamic"
1203                CC_SEARCH_FLAGS=""
1204                LD_SEARCH_FLAGS=""
1205            else
1206                AC_CHECK_HEADER(dld.h, [
1207                    SHLIB_LD="ld -shared"
1208                    DL_OBJS=""
1209                    DL_LIBS="-ldld"
1210                    LDFLAGS=""
1211                    CC_SEARCH_FLAGS=""
1212                    LD_SEARCH_FLAGS=""])
1213            fi
1214            if test "`uname -m`" = "alpha" ; then
1215                EXTRA_CFLAGS="-mieee"
1216            fi
1217            ;;
1218        MP-RAS-02*)
1219            SHLIB_CFLAGS="-K PIC"
1220            SHLIB_LD="cc -G"
1221            SHLIB_LD_LIBS=""
1222            SHLIB_SUFFIX=".so"
1223            DL_OBJS="tclLoadDl.o"
1224            DL_LIBS="-ldl"
1225            LDFLAGS=""
1226            CC_SEARCH_FLAGS=""
1227            LD_SEARCH_FLAGS=""
1228            ;;
1229        MP-RAS-*)
1230            SHLIB_CFLAGS="-K PIC"
1231            SHLIB_LD="cc -G"
1232            SHLIB_LD_LIBS=""
1233            SHLIB_SUFFIX=".so"
1234            DL_OBJS="tclLoadDl.o"
1235            DL_LIBS="-ldl"
1236            LDFLAGS="-Wl,-Bexport"
1237            CC_SEARCH_FLAGS=""
1238            LD_SEARCH_FLAGS=""
1239            ;;
1240        NetBSD-*|FreeBSD-[[1-2]].*|OpenBSD-*)
1241            # Not available on all versions:  check for include file.
1242            AC_CHECK_HEADER(dlfcn.h, [
1243                # NetBSD/SPARC needs -fPIC, -fpic will not do.
1244                SHLIB_CFLAGS="-fPIC"
1245                SHLIB_LD="ld -Bshareable -x"
1246                SHLIB_LD_LIBS=""
1247                SHLIB_SUFFIX=".so"
1248                DL_OBJS="tclLoadDl.o"
1249                DL_LIBS=""
1250                LDFLAGS=""
1251                CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1252                LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1253                AC_MSG_CHECKING(for ELF)
1254                AC_EGREP_CPP(yes, [
1255#ifdef __ELF__
1256        yes
1257#endif
1258                ],
1259                    AC_MSG_RESULT(yes)
1260                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so',
1261                    AC_MSG_RESULT(no)
1262                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1263                )
1264            ], [
1265                SHLIB_CFLAGS=""
1266                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
1267                SHLIB_LD_LIBS='${LIBS}'
1268                SHLIB_SUFFIX=".a"
1269                DL_OBJS="tclLoadAout.o"
1270                DL_LIBS=""
1271                LDFLAGS=""
1272                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1273                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1274                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1275            ])
1276
1277            # FreeBSD doesn't handle version numbers with dots.
1278
1279            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1280            TCL_LIB_VERSIONS_OK=nodots
1281            ;;
1282        FreeBSD-*)
1283            # FreeBSD 3.* and greater have ELF.
1284            SHLIB_CFLAGS="-fPIC"
1285            SHLIB_LD="ld -Bshareable -x"
1286            SHLIB_LD_LIBS='${LIBS}'
1287            SHLIB_SUFFIX=".so"
1288            DL_OBJS="tclLoadDl.o"
1289            DL_LIBS=""
1290            LDFLAGS="-export-dynamic"
1291            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1292            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1293            if test "${TCL_THREADS}" = "1" ; then
1294                # The -pthread needs to go in the CFLAGS, not LIBS
1295                LIBS=`echo $LIBS | sed s/-pthread//`
1296                EXTRA_CFLAGS="-pthread"
1297                LDFLAGS="$LDFLAGS -pthread"
1298            fi
1299            case $system in
1300            FreeBSD-3.*)
1301                # FreeBSD-3 doesn't handle version numbers with dots.
1302                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1303                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
1304                TCL_LIB_VERSIONS_OK=nodots
1305                ;;
1306            esac
1307            ;;
1308        Rhapsody-*|Darwin-*)
1309            SHLIB_CFLAGS="-fno-common"
1310            SHLIB_LD="cc -dynamiclib \${LDFLAGS}"
1311            TCL_SHLIB_LD_EXTRAS="-compatibility_version ${TCL_VERSION} -current_version \${VERSION} -install_name \${DYLIB_INSTALL_DIR}/\${TCL_LIB_FILE} -prebind -seg1addr 0xa000000"
1312            TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version \${VERSION} -install_name \${DYLIB_INSTALL_DIR}/\${TK_LIB_FILE} -prebind -seg1addr 0xb000000"
1313            SHLIB_LD_LIBS='${LIBS}'
1314            SHLIB_SUFFIX=".dylib"
1315            DL_OBJS="tclLoadDyld.o"
1316            PLAT_OBJS="tclMacOSXBundle.o"
1317            DL_LIBS=""
1318            LDFLAGS="-prebind"
1319            CC_SEARCH_FLAGS=""
1320            LD_SEARCH_FLAGS=""
1321            CFLAGS_OPTIMIZE="-Os"
1322            LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
1323            # for compatibility with autoconf vers 2.13 :
1324            HACK=""
1325            EXTRA_CFLAGS="-DMA${HACK}C_OSX_TCL -DHAVE_CFBUNDLE -DUSE_VFORK -DTCL_DEFAULT_ENCODING=\\\"utf-8\\\""
1326            LIBS="$LIBS -framework CoreFoundation"
1327            ;;
1328        NEXTSTEP-*)
1329            SHLIB_CFLAGS=""
1330            SHLIB_LD="cc -nostdlib -r"
1331            SHLIB_LD_LIBS=""
1332            SHLIB_SUFFIX=".so"
1333            DL_OBJS="tclLoadNext.o"
1334            DL_LIBS=""
1335            LDFLAGS=""
1336            CC_SEARCH_FLAGS=""
1337            LD_SEARCH_FLAGS=""
1338            ;;
1339        OS/390-*)
1340            CFLAGS_OPTIMIZE=""      # Optimizer is buggy
1341            AC_DEFINE(_OE_SOCKETS)  # needed in sys/socket.h
1342            ;;     
1343        OSF1-1.0|OSF1-1.1|OSF1-1.2)
1344            # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
1345            SHLIB_CFLAGS=""
1346            # Hack: make package name same as library name
1347            SHLIB_LD='ld -R -export $@:'
1348            SHLIB_LD_LIBS=""
1349            SHLIB_SUFFIX=".so"
1350            DL_OBJS="tclLoadOSF.o"
1351            DL_LIBS=""
1352            LDFLAGS=""
1353            CC_SEARCH_FLAGS=""
1354            LD_SEARCH_FLAGS=""
1355            ;;
1356        OSF1-1.*)
1357            # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
1358            SHLIB_CFLAGS="-fPIC"
1359            if test "$SHARED_BUILD" = "1" ; then
1360                SHLIB_LD="ld -shared"
1361            else
1362                SHLIB_LD="ld -non_shared"
1363            fi
1364            SHLIB_LD_LIBS=""
1365            SHLIB_SUFFIX=".so"
1366            DL_OBJS="tclLoadDl.o"
1367            DL_LIBS=""
1368            LDFLAGS=""
1369            CC_SEARCH_FLAGS=""
1370            LD_SEARCH_FLAGS=""
1371            ;;
1372        OSF1-V*)
1373            # Digital OSF/1
1374            SHLIB_CFLAGS=""
1375            if test "$SHARED_BUILD" = "1" ; then
1376                SHLIB_LD='ld -shared -expect_unresolved "*"'
1377            else
1378                SHLIB_LD='ld -non_shared -expect_unresolved "*"'
1379            fi
1380            SHLIB_LD_LIBS=""
1381            SHLIB_SUFFIX=".so"
1382            DL_OBJS="tclLoadDl.o"
1383            DL_LIBS=""
1384            LDFLAGS=""
1385            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1386            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1387            if test "$GCC" != "yes" ; then
1388                EXTRA_CFLAGS="-DHAVE_TZSET -std1"
1389            fi
1390            # see pthread_intro(3) for pthread support on osf1, k.furukawa
1391            if test "${TCL_THREADS}" = "1" ; then
1392                EXTRA_CFLAGS="${EXTRA_CFLAGS} -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
1393                EXTRA_CFLAGS="${EXTRA_CFLAGS} -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
1394                LIBS=`echo $LIBS | sed s/-lpthreads//`
1395                if test "$GCC" = "yes" ; then
1396                    LIBS="$LIBS -lpthread -lmach -lexc"
1397                else
1398                    EXTRA_CFLAGS="${EXTRA_CFLAGS} -pthread"
1399                    LDFLAGS="-pthread"
1400                fi
1401            fi
1402
1403            ;;
1404        QNX-6*)
1405            # QNX RTP
1406            # This may work for all QNX, but it was only reported for v6.
1407            SHLIB_CFLAGS="-fPIC"
1408            SHLIB_LD="ld -Bshareable -x"
1409            SHLIB_LD_LIBS=""
1410            SHLIB_SUFFIX=".so"
1411            DL_OBJS="tclLoadDl.o"
1412            # dlopen is in -lc on QNX
1413            DL_LIBS=""
1414            LDFLAGS=""
1415            CC_SEARCH_FLAGS=""
1416            LD_SEARCH_FLAGS=""
1417            ;;
1418        RISCos-*)
1419            SHLIB_CFLAGS="-G 0"
1420            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1421            SHLIB_LD_LIBS='${LIBS}'
1422            SHLIB_SUFFIX=".a"
1423            DL_OBJS="tclLoadAout.o"
1424            DL_LIBS=""
1425            LDFLAGS="-Wl,-D,08000000"
1426            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1427            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1428            ;;
1429        SCO_SV-3.2*)
1430            # Note, dlopen is available only on SCO 3.2.5 and greater. However,
1431            # this test works, since "uname -s" was non-standard in 3.2.4 and
1432            # below.
1433            if test "$GCC" = "yes" ; then
1434                SHLIB_CFLAGS="-fPIC -melf"
1435                LDFLAGS="-melf -Wl,-Bexport"
1436            else
1437                SHLIB_CFLAGS="-Kpic -belf"
1438                LDFLAGS="-belf -Wl,-Bexport"
1439            fi
1440            SHLIB_LD="ld -G"
1441            SHLIB_LD_LIBS=""
1442            SHLIB_SUFFIX=".so"
1443            DL_OBJS="tclLoadDl.o"
1444            DL_LIBS=""
1445            CC_SEARCH_FLAGS=""
1446            LD_SEARCH_FLAGS=""
1447            ;;
1448        SINIX*5.4*)
1449            SHLIB_CFLAGS="-K PIC"
1450            SHLIB_LD="cc -G"
1451            SHLIB_LD_LIBS=""
1452            SHLIB_SUFFIX=".so"
1453            DL_OBJS="tclLoadDl.o"
1454            DL_LIBS="-ldl"
1455            LDFLAGS=""
1456            CC_SEARCH_FLAGS=""
1457            LD_SEARCH_FLAGS=""
1458            ;;
1459        SunOS-4*)
1460            SHLIB_CFLAGS="-PIC"
1461            SHLIB_LD="ld"
1462            SHLIB_LD_LIBS=""
1463            SHLIB_SUFFIX=".so"
1464            DL_OBJS="tclLoadDl.o"
1465            DL_LIBS="-ldl"
1466            LDFLAGS=""
1467            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1468            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1469
1470            # SunOS can't handle version numbers with dots in them in library
1471            # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
1472            # requires an extra version number at the end of .so file names.
1473            # So, the library has to have a name like libtcl75.so.1.0
1474
1475            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1476            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1477            TCL_LIB_VERSIONS_OK=nodots
1478            ;;
1479        SunOS-5.[[0-6]]*)
1480
1481            # Note: If _REENTRANT isn't defined, then Solaris
1482            # won't define thread-safe library routines.
1483
1484            AC_DEFINE(_REENTRANT)
1485            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1486
1487            SHLIB_CFLAGS="-KPIC"
1488
1489            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1490            # symbols when dynamically loaded into tclsh.
1491
1492            SHLIB_LD_LIBS='${LIBS}'
1493            SHLIB_SUFFIX=".so"
1494            DL_OBJS="tclLoadDl.o"
1495            DL_LIBS="-ldl"
1496            LDFLAGS=""
1497            if test "$GCC" = "yes" ; then
1498                SHLIB_LD="$CC -shared"
1499                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1500                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1501            else
1502                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1503                CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1504                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1505            fi
1506            ;;
1507        SunOS-5*)
1508
1509            # Note: If _REENTRANT isn't defined, then Solaris
1510            # won't define thread-safe library routines.
1511
1512            AC_DEFINE(_REENTRANT)
1513            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1514
1515            SHLIB_CFLAGS="-KPIC"
1516            LDFLAGS=""
1517   
1518            # Check to enable 64-bit flags for compiler/linker
1519            if test "$do64bit" = "yes" ; then
1520                arch=`isainfo`
1521                if test "$arch" = "sparcv9 sparc" ; then
1522                        if test "$GCC" = "yes" ; then
1523                            AC_MSG_WARN("64bit mode not supported with GCC on $system")
1524                        else
1525                            do64bit_ok=yes
1526                            if test "$do64bitVIS" = "yes" ; then
1527                                EXTRA_CFLAGS="-xarch=v9a"
1528                                LDFLAGS="-xarch=v9a"
1529                            else
1530                                EXTRA_CFLAGS="-xarch=v9"
1531                                LDFLAGS="-xarch=v9"
1532                            fi
1533                        fi
1534                else
1535                    AC_MSG_WARN("64bit mode only supported sparcv9 system")
1536                fi
1537            fi
1538           
1539            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1540            # symbols when dynamically loaded into tclsh.
1541
1542            SHLIB_LD_LIBS='${LIBS}'
1543            SHLIB_SUFFIX=".so"
1544            DL_OBJS="tclLoadDl.o"
1545            DL_LIBS="-ldl"
1546            if test "$GCC" = "yes" ; then
1547                SHLIB_LD="$CC -shared"
1548                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1549                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1550            else
1551                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1552                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1553                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1554            fi
1555            ;;
1556        ULTRIX-4.*)
1557            SHLIB_CFLAGS="-G 0"
1558            SHLIB_SUFFIX=".a"
1559            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1560            SHLIB_LD_LIBS='${LIBS}'
1561            DL_OBJS="tclLoadAout.o"
1562            DL_LIBS=""
1563            LDFLAGS="-Wl,-D,08000000"
1564            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1565            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1566            if test "$GCC" != "yes" ; then
1567                EXTRA_CFLAGS="-DHAVE_TZSET -std1"
1568            fi
1569            ;;
1570        UNIX_SV* | UnixWare-5*)
1571            SHLIB_CFLAGS="-KPIC"
1572            SHLIB_LD="cc -G"
1573            SHLIB_LD_LIBS=""
1574            SHLIB_SUFFIX=".so"
1575            DL_OBJS="tclLoadDl.o"
1576            DL_LIBS="-ldl"
1577            # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
1578            # that don't grok the -Bexport option.  Test that it does.
1579            hold_ldflags=$LDFLAGS
1580            AC_MSG_CHECKING(for ld accepts -Bexport flag)
1581            LDFLAGS="${LDFLAGS} -Wl,-Bexport"
1582            AC_TRY_LINK(, [int i;], found=yes, found=no)
1583            LDFLAGS=$hold_ldflags
1584            AC_MSG_RESULT($found)
1585            if test $found = yes; then
1586            LDFLAGS="-Wl,-Bexport"
1587            else
1588            LDFLAGS=""
1589            fi
1590            CC_SEARCH_FLAGS=""
1591            LD_SEARCH_FLAGS=""
1592            ;;
1593    esac
1594
1595    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
1596    AC_MSG_WARN("64bit support being disabled -- don\'t know magic for this platform")
1597    fi
1598
1599    # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
1600    # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
1601    # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
1602    # to determine which of several header files defines the a.out file
1603    # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
1604    # support only a file format that is more or less version-7-compatible.
1605    # In particular,
1606    #   - a.out files must begin with `struct exec'.
1607    #   - the N_TXTOFF on the `struct exec' must compute the seek address
1608    #     of the text segment
1609    #   - The `struct exec' must contain a_magic, a_text, a_data, a_bss
1610    #     and a_entry fields.
1611    # The following compilation should succeed if and only if either sys/exec.h
1612    # or a.out.h is usable for the purpose.
1613    #
1614    # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
1615    # `struct exec' includes a second header that contains information that
1616    # duplicates the v7 fields that are needed.
1617
1618    if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
1619        AC_MSG_CHECKING(sys/exec.h)
1620        AC_TRY_COMPILE([#include <sys/exec.h>],[
1621            struct exec foo;
1622            unsigned long seek;
1623            int flag;
1624#if defined(__mips) || defined(mips)
1625            seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1626#else
1627            seek = N_TXTOFF (foo);
1628#endif
1629            flag = (foo.a_magic == OMAGIC);
1630            return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1631    ], tcl_ok=usable, tcl_ok=unusable)
1632        AC_MSG_RESULT($tcl_ok)
1633        if test $tcl_ok = usable; then
1634            AC_DEFINE(USE_SYS_EXEC_H)
1635        else
1636            AC_MSG_CHECKING(a.out.h)
1637            AC_TRY_COMPILE([#include <a.out.h>],[
1638                struct exec foo;
1639                unsigned long seek;
1640                int flag;
1641#if defined(__mips) || defined(mips)
1642                seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1643#else
1644                seek = N_TXTOFF (foo);
1645#endif
1646                flag = (foo.a_magic == OMAGIC);
1647                return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1648            ], tcl_ok=usable, tcl_ok=unusable)
1649            AC_MSG_RESULT($tcl_ok)
1650            if test $tcl_ok = usable; then
1651                AC_DEFINE(USE_A_OUT_H)
1652            else
1653                AC_MSG_CHECKING(sys/exec_aout.h)
1654                AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
1655                    struct exec foo;
1656                    unsigned long seek;
1657                    int flag;
1658#if defined(__mips) || defined(mips)
1659                    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1660#else
1661                    seek = N_TXTOFF (foo);
1662#endif
1663                    flag = (foo.a_midmag == OMAGIC);
1664                    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1665                ], tcl_ok=usable, tcl_ok=unusable)
1666                AC_MSG_RESULT($tcl_ok)
1667                if test $tcl_ok = usable; then
1668                    AC_DEFINE(USE_SYS_EXEC_AOUT_H)
1669                else
1670                    DL_OBJS=""
1671                fi
1672            fi
1673        fi
1674    fi
1675
1676    # Step 5: disable dynamic loading if requested via a command-line switch.
1677
1678    AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
1679        [tcl_ok=$enableval], [tcl_ok=yes])
1680    if test "$tcl_ok" = "no"; then
1681        DL_OBJS=""
1682    fi
1683
1684    if test "x$DL_OBJS" != "x" ; then
1685        BUILD_DLTEST="\$(DLTEST_TARGETS)"
1686    else
1687        echo "Can't figure out how to do dynamic loading or shared libraries"
1688        echo "on this system."
1689        SHLIB_CFLAGS=""
1690        SHLIB_LD=""
1691        SHLIB_SUFFIX=""
1692        DL_OBJS="tclLoadNone.o"
1693        DL_LIBS=""
1694        LDFLAGS=""
1695        CC_SEARCH_FLAGS=""
1696        LD_SEARCH_FLAGS=""
1697        BUILD_DLTEST=""
1698    fi
1699
1700    # If we're running gcc, then change the C flags for compiling shared
1701    # libraries to the right flags for gcc, instead of those for the
1702    # standard manufacturer compiler.
1703
1704    if test "$DL_OBJS" != "tclLoadNone.o" ; then
1705        if test "$GCC" = "yes" ; then
1706            case $system in
1707                AIX-*)
1708                    ;;
1709                BSD/OS*)
1710                    ;;
1711                IRIX*)
1712                    ;;
1713                NetBSD-*|FreeBSD-*|OpenBSD-*)
1714                    ;;
1715                Rhapsody-*|Darwin-*)
1716                    ;;
1717                RISCos-*)
1718                    ;;
1719                SCO_SV-3.2*)
1720                    ;;
1721                ULTRIX-4.*)
1722                    ;;
1723                *)
1724                    SHLIB_CFLAGS="-fPIC"
1725                    ;;
1726            esac
1727        fi
1728    fi
1729
1730    if test "$SHARED_LIB_SUFFIX" = "" ; then
1731        SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
1732    fi
1733    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
1734        UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1735    fi
1736
1737    if test "${SHARED_BUILD}" = "1" && test "${SHLIB_SUFFIX}" != "" ; then
1738        LIB_SUFFIX=${SHARED_LIB_SUFFIX}
1739        MAKE_LIB='${SHLIB_LD} -o [$]@ ${SHLIB_LD_FLAGS} ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
1740        INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
1741    else
1742        LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}
1743
1744        if test "$RANLIB" = "" ; then
1745            MAKE_LIB='$(STLIB_LD) [$]@ ${OBJS}'
1746            INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
1747        else
1748            MAKE_LIB='${STLIB_LD} [$]@ ${OBJS} ; ${RANLIB} [$]@'
1749            INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(LIB_FILE))'
1750        fi
1751
1752dnl        Not at all clear what this was doing in Tcl's configure.in
1753dnl        or why it was needed was needed. In any event, this sort of
1754dnl        things needs to be done in the big loop above.
1755dnl        REMOVE THIS BLOCK LATER! (mdejong)
1756dnl        case $system in
1757dnl            BSD/OS*)
1758dnl                ;;
1759dnl            AIX-[[1-4]].*)
1760dnl                ;;
1761dnl            *)
1762dnl                SHLIB_LD_LIBS=""
1763dnl                ;;
1764dnl        esac
1765    fi
1766
1767
1768    # Stub lib does not depend on shared/static configuration
1769    if test "$RANLIB" = "" ; then
1770        MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS}'
1771        INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE)'
1772    else
1773        MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS} ; ${RANLIB} [$]@'
1774        INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(STUB_LIB_FILE))'
1775    fi
1776
1777
1778    AC_SUBST(DL_LIBS)
1779
1780    AC_SUBST(DL_OBJS)
1781    AC_SUBST(PLAT_OBJS)
1782    AC_SUBST(CFLAGS)
1783    AC_SUBST(CFLAGS_DEBUG)
1784    AC_SUBST(CFLAGS_OPTIMIZE)
1785    AC_SUBST(CFLAGS_WARNING)
1786    AC_SUBST(EXTRA_CFLAGS)
1787
1788    AC_SUBST(LDFLAGS)
1789    AC_SUBST(LDFLAGS_DEBUG)
1790    AC_SUBST(LDFLAGS_OPTIMIZE)
1791    AC_SUBST(CC_SEARCH_FLAGS)
1792    AC_SUBST(LD_SEARCH_FLAGS)
1793
1794    AC_SUBST(STLIB_LD)
1795    AC_SUBST(SHLIB_LD)
1796    AC_SUBST(TCL_SHLIB_LD_EXTRAS)
1797    AC_SUBST(TK_SHLIB_LD_EXTRAS)
1798    AC_SUBST(SHLIB_LD_FLAGS)
1799    AC_SUBST(SHLIB_LD_LIBS)
1800    AC_SUBST(SHLIB_CFLAGS)
1801    AC_SUBST(SHLIB_SUFFIX)
1802
1803    AC_SUBST(MAKE_LIB)
1804    AC_SUBST(MAKE_STUB_LIB)
1805    AC_SUBST(INSTALL_LIB)
1806    AC_SUBST(INSTALL_STUB_LIB)
1807    AC_SUBST(RANLIB)
1808])
1809
1810#--------------------------------------------------------------------
1811# SC_SERIAL_PORT
1812#
1813#       Determine which interface to use to talk to the serial port.
1814#       Note that #include lines must begin in leftmost column for
1815#       some compilers to recognize them as preprocessor directives,
1816#       and some build environments have stdin not pointing at a
1817#       pseudo-terminal (usually /dev/null instead.)
1818#
1819# Arguments:
1820#       none
1821#       
1822# Results:
1823#
1824#       Defines only one of the following vars:
1825#               HAVE_SYS_MODEM_H
1826#               USE_TERMIOS
1827#               USE_TERMIO
1828#               USE_SGTTY
1829#
1830#--------------------------------------------------------------------
1831
1832AC_DEFUN(SC_SERIAL_PORT, [
1833    AC_CHECK_HEADERS(sys/modem.h)
1834    AC_MSG_CHECKING([termios vs. termio vs. sgtty])
1835    AC_CACHE_VAL(tcl_cv_api_serial, [
1836    AC_TRY_RUN([
1837#include <termios.h>
1838
1839int main() {
1840    struct termios t;
1841    if (tcgetattr(0, &t) == 0) {
1842        cfsetospeed(&t, 0);
1843        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
1844        return 0;
1845    }
1846    return 1;
1847}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
1848    if test $tcl_cv_api_serial = no ; then
1849        AC_TRY_RUN([
1850#include <termio.h>
1851
1852int main() {
1853    struct termio t;
1854    if (ioctl(0, TCGETA, &t) == 0) {
1855        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
1856        return 0;
1857    }
1858    return 1;
1859}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
1860    fi
1861    if test $tcl_cv_api_serial = no ; then
1862        AC_TRY_RUN([
1863#include <sgtty.h>
1864
1865int main() {
1866    struct sgttyb t;
1867    if (ioctl(0, TIOCGETP, &t) == 0) {
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=no, tcl_cv_api_serial=no)
1874    fi
1875    if test $tcl_cv_api_serial = no ; then
1876        AC_TRY_RUN([
1877#include <termios.h>
1878#include <errno.h>
1879
1880int main() {
1881    struct termios t;
1882    if (tcgetattr(0, &t) == 0
1883        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
1884        cfsetospeed(&t, 0);
1885        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
1886        return 0;
1887    }
1888    return 1;
1889}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
1890    fi
1891    if test $tcl_cv_api_serial = no; then
1892        AC_TRY_RUN([
1893#include <termio.h>
1894#include <errno.h>
1895
1896int main() {
1897    struct termio t;
1898    if (ioctl(0, TCGETA, &t) == 0
1899        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
1900        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
1901        return 0;
1902    }
1903    return 1;
1904    }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
1905    fi
1906    if test $tcl_cv_api_serial = no; then
1907        AC_TRY_RUN([
1908#include <sgtty.h>
1909#include <errno.h>
1910
1911int main() {
1912    struct sgttyb t;
1913    if (ioctl(0, TIOCGETP, &t) == 0
1914        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
1915        t.sg_ospeed = 0;
1916        t.sg_flags |= ODDP | EVENP | RAW;
1917        return 0;
1918    }
1919    return 1;
1920}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
1921    fi])
1922    case $tcl_cv_api_serial in
1923        termios) AC_DEFINE(USE_TERMIOS);;
1924        termio)  AC_DEFINE(USE_TERMIO);;
1925        sgtty)   AC_DEFINE(USE_SGTTY);;
1926    esac
1927    AC_MSG_RESULT($tcl_cv_api_serial)
1928])
1929
1930#--------------------------------------------------------------------
1931# SC_MISSING_POSIX_HEADERS
1932#
1933#       Supply substitutes for missing POSIX header files.  Special
1934#       notes:
1935#           - stdlib.h doesn't define strtol, strtoul, or
1936#             strtod insome versions of SunOS
1937#           - some versions of string.h don't declare procedures such
1938#             as strstr
1939#
1940# Arguments:
1941#       none
1942#       
1943# Results:
1944#
1945#       Defines some of the following vars:
1946#               NO_DIRENT_H
1947#               NO_ERRNO_H
1948#               NO_VALUES_H
1949#               NO_LIMITS_H
1950#               NO_STDLIB_H
1951#               NO_STRING_H
1952#               NO_SYS_WAIT_H
1953#               NO_DLFCN_H
1954#               HAVE_UNISTD_H
1955#               HAVE_SYS_PARAM_H
1956#
1957#               HAVE_STRING_H ?
1958#
1959#--------------------------------------------------------------------
1960
1961AC_DEFUN(SC_MISSING_POSIX_HEADERS, [
1962    AC_MSG_CHECKING(dirent.h)
1963    AC_TRY_LINK([#include <sys/types.h>
1964#include <dirent.h>], [
1965#ifndef _POSIX_SOURCE
1966#   ifdef __Lynx__
1967        /*
1968         * Generate compilation error to make the test fail:  Lynx headers
1969         * are only valid if really in the POSIX environment.
1970         */
1971
1972        missing_procedure();
1973#   endif
1974#endif
1975DIR *d;
1976struct dirent *entryPtr;
1977char *p;
1978d = opendir("foobar");
1979entryPtr = readdir(d);
1980p = entryPtr->d_name;
1981closedir(d);
1982], tcl_ok=yes, tcl_ok=no)
1983
1984    if test $tcl_ok = no; then
1985        AC_DEFINE(NO_DIRENT_H)
1986    fi
1987
1988    AC_MSG_RESULT($tcl_ok)
1989    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H)])
1990    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H)])
1991    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H)])
1992    AC_CHECK_HEADER(limits.h, , [AC_DEFINE(NO_LIMITS_H)])
1993    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
1994    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
1995    AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
1996    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
1997    if test $tcl_ok = 0; then
1998        AC_DEFINE(NO_STDLIB_H)
1999    fi
2000    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
2001    AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
2002    AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
2003
2004    # See also memmove check below for a place where NO_STRING_H can be
2005    # set and why.
2006
2007    if test $tcl_ok = 0; then
2008        AC_DEFINE(NO_STRING_H)
2009    fi
2010
2011    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H)])
2012    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H)])
2013
2014    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
2015
2016    AC_HAVE_HEADERS(unistd.h sys/param.h)
2017
2018])
2019
2020#--------------------------------------------------------------------
2021# SC_PATH_X
2022#
2023#       Locate the X11 header files and the X11 library archive.  Try
2024#       the ac_path_x macro first, but if it doesn't find the X stuff
2025#       (e.g. because there's no xmkmf program) then check through
2026#       a list of possible directories.  Under some conditions the
2027#       autoconf macro will return an include directory that contains
2028#       no include files, so double-check its result just to be safe.
2029#
2030# Arguments:
2031#       none
2032#       
2033# Results:
2034#
2035#       Sets the following vars:
2036#               XINCLUDES
2037#               XLIBSW
2038#
2039#--------------------------------------------------------------------
2040
2041AC_DEFUN(SC_PATH_X, [
2042    AC_PATH_X
2043    not_really_there=""
2044    if test "$no_x" = ""; then
2045        if test "$x_includes" = ""; then
2046            AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
2047        else
2048            if test ! -r $x_includes/X11/Intrinsic.h; then
2049                not_really_there="yes"
2050            fi
2051        fi
2052    fi
2053    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
2054        AC_MSG_CHECKING(for X11 header files)
2055        found_xincludes="no"
2056        AC_TRY_CPP([#include <X11/Intrinsic.h>], found_xincludes="yes", found_xincludes="no")
2057        if test "$found_xincludes" = "no"; then
2058            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"
2059            for i in $dirs ; do
2060                if test -r $i/X11/Intrinsic.h; then
2061                    AC_MSG_RESULT($i)
2062                    XINCLUDES=" -I$i"
2063                    found_xincludes="yes"
2064                    break
2065                fi
2066            done
2067        fi
2068    else
2069        if test "$x_includes" != ""; then
2070            XINCLUDES="-I$x_includes"
2071            found_xincludes="yes"
2072        fi
2073    fi
2074    if test found_xincludes = "no"; then
2075        AC_MSG_RESULT(couldn't find any!)
2076    fi
2077
2078    if test "$no_x" = yes; then
2079        AC_MSG_CHECKING(for X11 libraries)
2080        XLIBSW=nope
2081        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"
2082        for i in $dirs ; do
2083            if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
2084                AC_MSG_RESULT($i)
2085                XLIBSW="-L$i -lX11"
2086                x_libraries="$i"
2087                break
2088            fi
2089        done
2090    else
2091        if test "$x_libraries" = ""; then
2092            XLIBSW=-lX11
2093        else
2094            XLIBSW="-L$x_libraries -lX11"
2095        fi
2096    fi
2097    if test "$XLIBSW" = nope ; then
2098        AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
2099    fi
2100    if test "$XLIBSW" = nope ; then
2101        AC_MSG_RESULT(couldn't find any!  Using -lX11.)
2102        XLIBSW=-lX11
2103    fi
2104])
2105#--------------------------------------------------------------------
2106# SC_BLOCKING_STYLE
2107#
2108#       The statements below check for systems where POSIX-style
2109#       non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
2110#       On these systems (mostly older ones), use the old BSD-style
2111#       FIONBIO approach instead.
2112#
2113# Arguments:
2114#       none
2115#       
2116# Results:
2117#
2118#       Defines some of the following vars:
2119#               HAVE_SYS_IOCTL_H
2120#               HAVE_SYS_FILIO_H
2121#               USE_FIONBIO
2122#               O_NONBLOCK
2123#
2124#--------------------------------------------------------------------
2125
2126AC_DEFUN(SC_BLOCKING_STYLE, [
2127    AC_CHECK_HEADERS(sys/ioctl.h)
2128    AC_CHECK_HEADERS(sys/filio.h)
2129    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
2130    if test -f /usr/lib/NextStep/software_version; then
2131        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
2132    else
2133        system=`uname -s`-`uname -r`
2134        if test "$?" -ne 0 ; then
2135            system=unknown
2136        else
2137            # Special check for weird MP-RAS system (uname returns weird
2138            # results, and the version is kept in special file).
2139       
2140            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
2141                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
2142            fi
2143            if test "`uname -s`" = "AIX" ; then
2144                system=AIX-`uname -v`.`uname -r`
2145            fi
2146        fi
2147    fi
2148    case $system in
2149        # There used to be code here to use FIONBIO under AIX.  However, it
2150        # was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
2151        # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
2152        # code (JO, 5/31/97).
2153
2154        OSF*)
2155            AC_DEFINE(USE_FIONBIO)
2156            AC_MSG_RESULT(FIONBIO)
2157            ;;
2158        SunOS-4*)
2159            AC_DEFINE(USE_FIONBIO)
2160            AC_MSG_RESULT(FIONBIO)
2161            ;;
2162        ULTRIX-4.*)
2163            AC_DEFINE(USE_FIONBIO)
2164            AC_MSG_RESULT(FIONBIO)
2165            ;;
2166        *)
2167            AC_MSG_RESULT(O_NONBLOCK)
2168            ;;
2169    esac
2170])
2171
2172#--------------------------------------------------------------------
2173# SC_TIME_HANLDER
2174#
2175#       Checks how the system deals with time.h, what time structures
2176#       are used on the system, and what fields the structures have.
2177#
2178# Arguments:
2179#       none
2180#       
2181# Results:
2182#
2183#       Defines some of the following vars:
2184#               USE_DELTA_FOR_TZ
2185#               HAVE_TM_GMTOFF
2186#               HAVE_TM_TZADJ
2187#               HAVE_TIMEZONE_VAR
2188#
2189#--------------------------------------------------------------------
2190
2191AC_DEFUN(SC_TIME_HANDLER, [
2192    AC_CHECK_HEADERS(sys/time.h)
2193    AC_HEADER_TIME
2194    AC_STRUCT_TIMEZONE
2195
2196    AC_CHECK_FUNCS(gmtime_r localtime_r)
2197
2198    AC_MSG_CHECKING([tm_tzadj in struct tm])
2199    AC_CACHE_VAL(tcl_cv_member_tm_tzadj,
2200        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
2201            tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no))
2202    AC_MSG_RESULT($tcl_cv_member_tm_tzadj)
2203    if test $tcl_cv_member_tm_tzadj = yes ; then
2204        AC_DEFINE(HAVE_TM_TZADJ)
2205    fi
2206
2207    AC_MSG_CHECKING([tm_gmtoff in struct tm])
2208    AC_CACHE_VAL(tcl_cv_member_tm_gmtoff,
2209        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
2210            tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no))
2211    AC_MSG_RESULT($tcl_cv_member_tm_gmtoff)
2212    if test $tcl_cv_member_tm_gmtoff = yes ; then
2213        AC_DEFINE(HAVE_TM_GMTOFF)
2214    fi
2215
2216    #
2217    # Its important to include time.h in this check, as some systems
2218    # (like convex) have timezone functions, etc.
2219    #
2220    AC_MSG_CHECKING([long timezone variable])
2221    AC_CACHE_VAL(tcl_cv_var_timezone,
2222        AC_TRY_COMPILE([#include <time.h>],
2223            [extern long timezone;
2224            timezone += 1;
2225            exit (0);],
2226            tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no))
2227    AC_MSG_RESULT($tcl_cv_timezone_long)
2228    if test $tcl_cv_timezone_long = yes ; then
2229        AC_DEFINE(HAVE_TIMEZONE_VAR)
2230    else
2231        #
2232        # On some systems (e.g. IRIX 6.2), timezone is a time_t and not a long.
2233        #
2234        AC_MSG_CHECKING([time_t timezone variable])
2235        AC_CACHE_VAL(tcl_cv_timezone_time,
2236            AC_TRY_COMPILE([#include <time.h>],
2237                [extern time_t timezone;
2238                timezone += 1;
2239                exit (0);],
2240                tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no))
2241        AC_MSG_RESULT($tcl_cv_timezone_time)
2242        if test $tcl_cv_timezone_time = yes ; then
2243            AC_DEFINE(HAVE_TIMEZONE_VAR)
2244        fi
2245    fi
2246])
2247
2248#--------------------------------------------------------------------
2249# SC_BUGGY_STRTOD
2250#
2251#       Under Solaris 2.4, strtod returns the wrong value for the
2252#       terminating character under some conditions.  Check for this
2253#       and if the problem exists use a substitute procedure
2254#       "fixstrtod" (provided by Tcl) that corrects the error.
2255#       Also, on Compaq's Tru64 Unix 5.0,
2256#       strtod(" ") returns 0.0 instead of a failure to convert.
2257#
2258# Arguments:
2259#       none
2260#       
2261# Results:
2262#
2263#       Might defines some of the following vars:
2264#               strtod (=fixstrtod)
2265#
2266#--------------------------------------------------------------------
2267
2268AC_DEFUN(SC_BUGGY_STRTOD, [
2269    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
2270    if test "$tcl_strtod" = 1; then
2271        AC_MSG_CHECKING([for Solaris2.4/Tru64 strtod bugs])
2272        AC_CACHE_VAL(tcl_cv_strtod_buggy,[
2273            AC_TRY_RUN([
2274                extern double strtod();
2275                int main() {
2276                    char *infString="Inf", *nanString="NaN", *spaceString=" ";
2277                    char *term;
2278                    double value;
2279                    value = strtod(infString, &term);
2280                    if ((term != infString) && (term[-1] == 0)) {
2281                        exit(1);
2282                    }
2283                    value = strtod(nanString, &term);
2284                    if ((term != nanString) && (term[-1] == 0)) {
2285                        exit(1);
2286                    }
2287                    value = strtod(spaceString, &term);
2288                    if (term == (spaceString+1)) {
2289                        exit(1);
2290                    }
2291                    exit(0);
2292                }], tcl_cv_strtod_buggy=1, tcl_cv_strtod_buggy=0, tcl_cv_strtod_buggy=0)])
2293        if test "$tcl_cv_strtod_buggy" = 1; then
2294            AC_MSG_RESULT(ok)
2295        else
2296            AC_MSG_RESULT(buggy)
2297            LIBOBJS="$LIBOBJS fixstrtod.o"
2298            AC_DEFINE(strtod, fixstrtod)
2299        fi
2300    fi
2301])
2302
2303#--------------------------------------------------------------------
2304# SC_TCL_LINK_LIBS
2305#
2306#       Search for the libraries needed to link the Tcl shell.
2307#       Things like the math library (-lm) and socket stuff (-lsocket vs.
2308#       -lnsl) are dealt with here.
2309#
2310# Arguments:
2311#       Requires the following vars to be set in the Makefile:
2312#               DL_LIBS
2313#               LIBS
2314#               MATH_LIBS
2315#       
2316# Results:
2317#
2318#       Subst's the following var:
2319#               TCL_LIBS
2320#               MATH_LIBS
2321#
2322#       Might append to the following vars:
2323#               LIBS
2324#
2325#       Might define the following vars:
2326#               HAVE_NET_ERRNO_H
2327#
2328#--------------------------------------------------------------------
2329
2330AC_DEFUN(SC_TCL_LINK_LIBS, [
2331    #--------------------------------------------------------------------
2332    # On a few very rare systems, all of the libm.a stuff is
2333    # already in libc.a.  Set compiler flags accordingly.
2334    # Also, Linux requires the "ieee" library for math to work
2335    # right (and it must appear before "-lm").
2336    #--------------------------------------------------------------------
2337
2338    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
2339    AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
2340
2341    #--------------------------------------------------------------------
2342    # Interactive UNIX requires -linet instead of -lsocket, plus it
2343    # needs net/errno.h to define the socket-related error codes.
2344    #--------------------------------------------------------------------
2345
2346    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
2347    AC_CHECK_HEADER(net/errno.h, [AC_DEFINE(HAVE_NET_ERRNO_H)])
2348
2349    #--------------------------------------------------------------------
2350    #   Check for the existence of the -lsocket and -lnsl libraries.
2351    #   The order here is important, so that they end up in the right
2352    #   order in the command line generated by make.  Here are some
2353    #   special considerations:
2354    #   1. Use "connect" and "accept" to check for -lsocket, and
2355    #      "gethostbyname" to check for -lnsl.
2356    #   2. Use each function name only once:  can't redo a check because
2357    #      autoconf caches the results of the last check and won't redo it.
2358    #   3. Use -lnsl and -lsocket only if they supply procedures that
2359    #      aren't already present in the normal libraries.  This is because
2360    #      IRIX 5.2 has libraries, but they aren't needed and they're
2361    #      bogus:  they goof up name resolution if used.
2362    #   4. On some SVR4 systems, can't use -lsocket without -lnsl too.
2363    #      To get around this problem, check for both libraries together
2364    #      if -lsocket doesn't work by itself.
2365    #--------------------------------------------------------------------
2366
2367    tcl_checkBoth=0
2368    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
2369    if test "$tcl_checkSocket" = 1; then
2370        AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
2371            LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
2372    fi
2373    if test "$tcl_checkBoth" = 1; then
2374        tk_oldLibs=$LIBS
2375        LIBS="$LIBS -lsocket -lnsl"
2376        AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
2377    fi
2378    AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
2379            [LIBS="$LIBS -lnsl"])])
2380   
2381    # Don't perform the eval of the libraries here because DL_LIBS
2382    # won't be set until we call SC_CONFIG_CFLAGS
2383
2384    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
2385    AC_SUBST(TCL_LIBS)
2386    AC_SUBST(MATH_LIBS)
2387])
2388
2389#--------------------------------------------------------------------
2390# SC_TCL_EARLY_FLAGS
2391#
2392#       Check for what flags are needed to be passed so the correct OS
2393#       features are available.
2394#
2395# Arguments:
2396#       None
2397#       
2398# Results:
2399#
2400#       Might define the following vars:
2401#               _ISOC99_SOURCE
2402#               _LARGEFILE64_SOURCE
2403#
2404#--------------------------------------------------------------------
2405
2406AC_DEFUN(SC_TCL_EARLY_FLAG,[
2407    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
2408        AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
2409            AC_TRY_COMPILE([[#define ]$1[ 1
2410]$2], $3,
2411                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
2412                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
2413    if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
2414        AC_DEFINE($1)
2415        tcl_flags="$tcl_flags $1"
2416    fi])
2417
2418AC_DEFUN(SC_TCL_EARLY_FLAGS,[
2419    AC_MSG_CHECKING([for required early compiler flags])
2420    tcl_flags=""
2421    SC_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
2422        [char *p = (char *)strtoll; char *q = (char *)strtoull;])
2423    SC_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
2424        [struct stat64 buf; int i = stat64("/", &buf);])
2425    if test "x${tcl_flags}" = "x" ; then
2426        AC_MSG_RESULT(none)
2427    else
2428        AC_MSG_RESULT(${tcl_flags})
2429    fi])
2430
2431#--------------------------------------------------------------------
2432# SC_TCL_64BIT_FLAGS
2433#
2434#       Check for what is defined in the way of 64-bit features.
2435#
2436# Arguments:
2437#       None
2438#       
2439# Results:
2440#
2441#       Might define the following vars:
2442#               TCL_WIDE_INT_IS_LONG
2443#               TCL_WIDE_INT_TYPE
2444#               HAVE_STRUCT_DIRENT64
2445#               HAVE_STRUCT_STAT64
2446#               HAVE_TYPE_OFF64_T
2447#
2448#--------------------------------------------------------------------
2449
2450AC_DEFUN(SC_TCL_64BIT_FLAGS, [
2451    AC_MSG_CHECKING([for 64-bit integer type])
2452    AC_CACHE_VAL(tcl_cv_type_64bit,[
2453        tcl_cv_type_64bit=none
2454        # See if the compiler knows natively about __int64
2455        AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
2456            tcl_type_64bit=__int64, tcl_type_64bit="long long")
2457        # See if we should use long anyway  Note that we substitute in the
2458        # type that is our current guess for a 64-bit type inside this check
2459        # program, so it should be modified only carefully...
2460        AC_TRY_RUN([#include <unistd.h>
2461            int main() {exit(!(sizeof(]${tcl_type_64bit}[) > sizeof(long)));}
2462            ], tcl_cv_type_64bit=${tcl_type_64bit},:,:)])
2463    if test "${tcl_cv_type_64bit}" = none ; then
2464        AC_DEFINE(TCL_WIDE_INT_IS_LONG)
2465        AC_MSG_RESULT(using long)
2466    else
2467        AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit})
2468        AC_MSG_RESULT(${tcl_cv_type_64bit})
2469
2470        # Now check for auxiliary declarations
2471        AC_MSG_CHECKING([for struct dirent64])
2472        AC_CACHE_VAL(tcl_cv_struct_dirent64,[
2473            AC_TRY_COMPILE([#include <sys/types.h>
2474#include <sys/dirent.h>],[struct dirent64 p;],
2475                tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
2476        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
2477            AC_DEFINE(HAVE_STRUCT_DIRENT64)
2478        fi
2479        AC_MSG_RESULT(${tcl_cv_struct_dirent64})
2480
2481        AC_MSG_CHECKING([for struct stat64])
2482        AC_CACHE_VAL(tcl_cv_struct_stat64,[
2483            AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
2484],
2485                tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
2486        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
2487            AC_DEFINE(HAVE_STRUCT_STAT64)
2488        fi
2489        AC_MSG_RESULT(${tcl_cv_struct_stat64})
2490
2491        AC_MSG_CHECKING([for off64_t])
2492        AC_CACHE_VAL(tcl_cv_type_off64_t,[
2493            AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
2494],
2495                tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
2496        if test "x${tcl_cv_type_off64_t}" = "xyes" ; then
2497            AC_DEFINE(HAVE_TYPE_OFF64_T)
2498        fi
2499        AC_MSG_RESULT(${tcl_cv_type_off64_t})
2500    fi])
2501
2502#------------------------------------------------------------------------
2503# SC_PUBLIC_TCL_HEADERS --
2504#
2505#       Locate the installed public Tcl header files
2506#
2507# Arguments:
2508#       None.
2509#
2510# Requires:
2511#       CYGPATH must be set
2512#       TCL_VERSION must be set
2513#
2514# Results:
2515#
2516#       Adds a --with-tclinclude switch to configure.
2517#       Result is cached.
2518#
2519#       Substs the following vars:
2520#               TCL_INCLUDES
2521#------------------------------------------------------------------------
2522
2523AC_DEFUN(SC_PUBLIC_TCL_HEADERS, [
2524    AC_MSG_CHECKING(for Tcl public headers)
2525
2526    AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory containing the public Tcl header files.], with_tclinclude=${withval})
2527
2528    if test x"${with_tclinclude}" != x ; then
2529        if test -f "${with_tclinclude}/tcl.h" ; then
2530            ac_cv_c_tclh=${with_tclinclude}
2531        else
2532            AC_MSG_ERROR([${with_tclinclude} directory does not contain Tcl public header file tcl.h])
2533        fi
2534    else
2535        AC_CACHE_VAL(ac_cv_c_tclh, [
2536            # Use the value from --with-tclinclude, if it was given
2537
2538            if test x"${with_tclinclude}" != x ; then
2539                ac_cv_c_tclh=${with_tclinclude}
2540            else
2541                # Do NOT check in $includedir, we need to prevent automatic
2542                # location of Tcl headers in $prefix/include unless explicitly
2543                # specified with the --with-tclinclude option. But go ahead and
2544                # check some other possible local system locations.
2545
2546                for i in \
2547                        /usr/include /usr/local/include /usr/local/include/tcl${TCL_VERSION} /usr/include/tcl${TCL_VERSION}; do
2548                    if test -f "$i/tcl.h" ; then
2549                        ac_cv_c_tclh=$i
2550                        break
2551                    fi
2552                done
2553            fi
2554        ])
2555    fi
2556
2557    # Print a message based on how we determined the include path
2558
2559    if test x"${ac_cv_c_tclh}" = x ; then
2560        AC_MSG_ERROR(tcl.h not found.  Please specify its location with --with-tclinclude)
2561    else
2562        AC_MSG_RESULT(${ac_cv_c_tclh})
2563    fi
2564
2565    # Convert to a native path and substitute into the output files.
2566
2567    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
2568
2569    TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
2570
2571    AC_SUBST(TCL_INCLUDES)
2572])
Note: See TracBrowser for help on using the repository browser.