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

Last change on this file since 112684 was 101415, checked in by larryv@…, 8 years ago

base: Check for user-installed tcl8.6 (#37583).

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