source: trunk/base/tcl.m4 @ 17417

Last change on this file since 17417 was 9841, checked in by rshaw, 15 years ago

Fixes problem with configure finding binaries from ports that were installed
prior to re-installation of port code. Configure now properly ignores the DP
$prefix/bin and $prefix/sbin paths to prevent potential bootstrapping problems
and base/ update problems.

Reviewed by: landonf

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