source: trunk/base/tcl.m4 @ 6320

Last change on this file since 6320 was 6320, checked in by landonf (Landon Fuller), 16 years ago

Replace incorrect usage of AC_MSG_WARN with AC_MSG_ERROR

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