source: trunk/base/tcl.m4 @ 2803

Last change on this file since 2803 was 2803, checked in by ssen, 17 years ago

Use the full form of AC_DEFINE for STATIC_BUILD to make autoheader
happy

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