Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

root/branches/dp2mp-move/base/tcl.m4

Revision 19376, 76.0 KB (checked in by yeled@…, 2 years ago)

add svn:keywords Id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1# This file is based on the tcl.m4 file distributed with Tcl 8.4
2# Portions Copyright (2003) Apple Computer, Inc.
3#
4# Copyright and License for this file, copied verbatim from the official
5# Tcl distribution, follows:
6#
7# This software is copyrighted by the Regents of the University of
8# California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState
9# Corporation and other parties.  The following terms apply to all files
10# associated with the software unless explicitly disclaimed in
11# individual files.
12#
13# The authors hereby grant permission to use, copy, modify, distribute,
14# and license this software and its documentation for any purpose, provided
15# that existing copyright notices are retained in all copies and that this
16# notice is included verbatim in any distributions. No written agreement,
17# license, or royalty fee is required for any of the authorized uses.
18# Modifications to this software may be copyrighted by their authors
19# and need not follow the licensing terms described here, provided that
20# the new terms are clearly indicated on the first page of each file where
21# they apply.
22
23# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
24# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
25# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
26# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
27# POSSIBILITY OF SUCH DAMAGE.
28#
29# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
30# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
31# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
32# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
33# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
34# MODIFICATIONS.
35#
36# GOVERNMENT USE: If you are acquiring this software on behalf of the
37# U.S. government, the Government shall have only "Restricted Rights"
38# in the software and related documentation as defined in the Federal
39# Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
40# are acquiring the software on behalf of the Department of Defense, the
41# software shall be classified as "Commercial Computer Software" and the
42# Government shall have only "Restricted Rights" as defined in Clause
43# 252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
44# authors grant the U.S. Government and others acting in its behalf
45# permission to use and distribute the software in accordance with the
46# terms specified in this license.
47#
48#------------------------------------------------------------------------
49# SC_PATH_TCLCONFIG --
50#
51#       Locate the tclConfig.sh file and perform a sanity check on
52#       the Tcl compile flags
53#
54# Arguments:
55#       none
56#
57# Results:
58#
59#       Adds the following arguments to configure:
60#               --with-tcl=...
61#
62#       Defines the following vars:
63#               TCL_BIN_DIR     Full path to the directory containing
64#                               the tclConfig.sh file
65#------------------------------------------------------------------------
66
67AC_DEFUN(SC_PATH_TCLCONFIG, [
68    #
69    # Ok, lets find the tcl configuration
70    # First, look for one uninstalled.
71    # the alternative search directory is invoked by --with-tcl
72    #
73
74    if test x"${no_tcl}" = x ; then
75        # we reset no_tcl in case something fails here
76        no_tcl=true
77        AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
78        AC_MSG_CHECKING([for Tcl configuration])
79        AC_CACHE_VAL(ac_cv_c_tclconfig,[
80
81            # First check to see if --with-tcl was specified.
82            if test x"${with_tclconfig}" != x ; then
83                if test -f "${with_tclconfig}/tclConfig.sh" ; then
84                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
85                else
86                    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
87                fi
88            fi
89
90            # then check for a private Tcl installation
91            if test x"${ac_cv_c_tclconfig}" = x ; then
92                for i in \
93                        ../tcl \
94                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
95                        ../../tcl \
96                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
97                        ../../../tcl \
98                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
99                    if test -f "$i/unix/tclConfig.sh" ; then
100                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
101                        break
102                    fi
103                done
104            fi
105
106            # check in a few common install locations
107            if test x"${ac_cv_c_tclconfig}" = x ; then
108                for i in `ls -d ${libdir} 2>/dev/null` \
109                        `ls -d /usr/local/lib 2>/dev/null` \
110                        `ls -d /usr/contrib/lib 2>/dev/null` \
111                        `ls -d /usr/lib 2>/dev/null` \
112                        `ls -d /usr/pkg/lib 2>/dev/null` \
113                        `ls -d /System/Library/Tcl/8.3 2>/dev/null` \
114                        `ls -d /usr/local/lib/tcl8.4 2>/dev/null` \
115                        `ls -d /usr/local/lib/tcl8.3 2>/dev/null` \
116                        `ls -d /usr/lib/tcl8.4 2>/dev/null` \
117                        `ls -d /usr/lib/tcl8.3 2>/dev/null` \
118                        ; do
119                    if test -f "$i/tclConfig.sh" ; then
120                        ac_cv_c_tclconfig=`(cd $i; pwd)`
121                        break
122                    fi
123                done
124            fi
125
126            # check in a few other private locations
127            if test x"${ac_cv_c_tclconfig}" = x ; then
128                for i in \
129                        ${srcdir}/../tcl \
130                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
131                    if test -f "$i/unix/tclConfig.sh" ; then
132                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
133                    break
134                fi
135                done
136            fi
137        ])
138
139        if test x"${ac_cv_c_tclconfig}" = x ; then
140            TCL_BIN_DIR="# no Tcl configs found"
141            AC_MSG_ERROR(Can't find Tcl configuration definitions)
142        else
143            no_tcl=
144            TCL_BIN_DIR=${ac_cv_c_tclconfig}
145            AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
146        fi
147    fi
148])
149
150#------------------------------------------------------------------------
151# SC_PATH_TKCONFIG --
152#
153#       Locate the tkConfig.sh file
154#
155# Arguments:
156#       none
157#
158# Results:
159#
160#       Adds the following arguments to configure:
161#               --with-tk=...
162#
163#       Defines the following vars:
164#               TK_BIN_DIR      Full path to the directory containing
165#                               the tkConfig.sh file
166#------------------------------------------------------------------------
167
168AC_DEFUN(SC_PATH_TKCONFIG, [
169    #
170    # Ok, lets find the tk configuration
171    # First, look for one uninstalled.
172    # the alternative search directory is invoked by --with-tk
173    #
174
175    if test x"${no_tk}" = x ; then
176        # we reset no_tk in case something fails here
177        no_tk=true
178        AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
179        AC_MSG_CHECKING([for Tk configuration])
180        AC_CACHE_VAL(ac_cv_c_tkconfig,[
181
182            # First check to see if --with-tkconfig was specified.
183            if test x"${with_tkconfig}" != x ; then
184                if test -f "${with_tkconfig}/tkConfig.sh" ; then
185                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
186                else
187                    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
188                fi
189            fi
190
191            # then check for a private Tk library
192            if test x"${ac_cv_c_tkconfig}" = x ; then
193                for i in \
194                        ../tk \
195                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
196                        ../../tk \
197                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
198                        ../../../tk \
199                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
200                    if test -f "$i/unix/tkConfig.sh" ; then
201                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
202                        break
203                    fi
204                done
205            fi
206            # check in a few common install locations
207            if test x"${ac_cv_c_tkconfig}" = x ; then
208                for i in `ls -d ${libdir} 2>/dev/null` \
209                        `ls -d /usr/local/lib 2>/dev/null` \
210                        `ls -d /usr/contrib/lib 2>/dev/null` \
211                        `ls -d /usr/lib 2>/dev/null` \
212                        ; do
213                    if test -f "$i/tkConfig.sh" ; then
214                        ac_cv_c_tkconfig=`(cd $i; pwd)`
215                        break
216                    fi
217                done
218            fi
219            # check in a few other private locations
220            if test x"${ac_cv_c_tkconfig}" = x ; then
221                for i in \
222                        ${srcdir}/../tk \
223                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
224                    if test -f "$i/unix/tkConfig.sh" ; then
225                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
226                        break
227                    fi
228                done
229            fi
230        ])
231        if test x"${ac_cv_c_tkconfig}" = x ; then
232            TK_BIN_DIR="# no Tk configs found"
233            AC_MSG_WARN(Can't find Tk configuration definitions)
234            exit 0
235        else
236            no_tk=
237            TK_BIN_DIR=${ac_cv_c_tkconfig}
238            AC_MSG_RESULT(found $TK_BIN_DIR/tkConfig.sh)
239        fi
240    fi
241
242])
243
244#------------------------------------------------------------------------
245# SC_LOAD_TCLCONFIG --
246#
247#       Load the tclConfig.sh file
248#
249# Arguments:
250#       
251#       Requires the following vars to be set:
252#               TCL_BIN_DIR
253#
254# Results:
255#
256#       Subst the following vars:
257#               TCL_BIN_DIR
258#               TCL_SRC_DIR
259#               TCL_LIB_FILE
260#
261#------------------------------------------------------------------------
262
263AC_DEFUN(SC_LOAD_TCLCONFIG, [
264    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
265
266    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
267        AC_MSG_RESULT([loading])
268        . $TCL_BIN_DIR/tclConfig.sh
269    else
270        AC_MSG_RESULT([file not found])
271    fi
272
273    #
274    # If the TCL_BIN_DIR is the build directory (not the install directory),
275    # then set the common variable name to the value of the build variables.
276    # For example, the variable TCL_LIB_SPEC will be set to the value
277    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
278    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
279    # installed and uninstalled version of Tcl.
280    #
281
282    if test -f $TCL_BIN_DIR/Makefile ; then
283        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
284        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
285        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
286    fi
287
288    #
289    # eval is required to do the TCL_DBGX substitution
290    #
291
292    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
293    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
294    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
295
296    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
297    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
298    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
299
300    AC_SUBST(TCL_VERSION)
301    AC_SUBST(TCL_BIN_DIR)
302    AC_SUBST(TCL_SRC_DIR)
303
304    AC_SUBST(TCL_LIB_FILE)
305    AC_SUBST(TCL_LIB_FLAG)
306    AC_SUBST(TCL_LIB_SPEC)
307
308    AC_SUBST(TCL_STUB_LIB_FILE)
309    AC_SUBST(TCL_STUB_LIB_FLAG)
310    AC_SUBST(TCL_STUB_LIB_SPEC)
311])
312
313#------------------------------------------------------------------------
314# SC_LOAD_TKCONFIG --
315#
316#       Load the tkConfig.sh file
317#
318# Arguments:
319#       
320#       Requires the following vars to be set:
321#               TK_BIN_DIR
322#
323# Results:
324#
325#       Sets the following vars that should be in tkConfig.sh:
326#               TK_BIN_DIR
327#------------------------------------------------------------------------
328
329AC_DEFUN(SC_LOAD_TKCONFIG, [
330    AC_MSG_CHECKING([for existence of $TK_BIN_DIR/tkConfig.sh])
331
332    if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
333        AC_MSG_RESULT([loading])
334        . $TK_BIN_DIR/tkConfig.sh
335    else
336        AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
337    fi
338
339    AC_SUBST(TK_VERSION)
340    AC_SUBST(TK_BIN_DIR)
341    AC_SUBST(TK_SRC_DIR)
342    AC_SUBST(TK_LIB_FILE)
343])
344
345#------------------------------------------------------------------------
346# SC_ENABLE_SHARED --
347#
348#       Allows the building of shared libraries
349#
350# Arguments:
351#       none
352#       
353# Results:
354#
355#       Adds the following arguments to configure:
356#               --enable-shared=yes|no
357#
358#       Defines the following vars:
359#               STATIC_BUILD    Used for building import/export libraries
360#                               on Windows.
361#
362#       Sets the following vars:
363#               SHARED_BUILD    Value of 1 or 0
364#------------------------------------------------------------------------
365
366AC_DEFUN(SC_ENABLE_SHARED, [
367    AC_MSG_CHECKING([how to build libraries])
368    AC_ARG_ENABLE(shared,
369        [  --enable-shared         build and link with shared libraries [--enable-shared]],
370        [tcl_ok=$enableval], [tcl_ok=yes])
371
372    if test "${enable_shared+set}" = set; then
373        enableval="$enable_shared"
374        tcl_ok=$enableval
375    else
376        tcl_ok=yes
377    fi
378
379    if test "$tcl_ok" = "yes" ; then
380        AC_MSG_RESULT([shared])
381        SHARED_BUILD=1
382    else
383        AC_MSG_RESULT([static])
384        SHARED_BUILD=0
385        AC_DEFINE([STATIC_BUILD], [1], [Define to 1 if static build is requested])
386    fi
387])
388
389#------------------------------------------------------------------------
390# SC_ENABLE_FRAMEWORK --
391#
392#       Allows the building of shared libraries into frameworks
393#
394# Arguments:
395#       none
396#       
397# Results:
398#
399#       Adds the following arguments to configure:
400#               --enable-framework=yes|no
401#
402#       Sets the following vars:
403#               FRAMEWORK_BUILD Value of 1 or 0
404#------------------------------------------------------------------------
405
406AC_DEFUN(SC_ENABLE_FRAMEWORK, [
407    AC_MSG_CHECKING([how to package libraries])
408    AC_ARG_ENABLE(framework,
409        [  --enable-framework      package shared libraries in frameworks [--disable-framework]],
410        [tcl_ok=$enableval], [tcl_ok=no])
411
412    if test "${enable_framework+set}" = set; then
413        enableval="$enable_framework"
414        tcl_ok=$enableval
415    else
416        tcl_ok=no
417    fi
418
419    if test "$tcl_ok" = "yes" ; then
420        AC_MSG_RESULT([framework])
421        FRAMEWORK_BUILD=1
422        if test "${SHARED_BUILD}" = "0" ; then
423            AC_MSG_WARN("Frameworks can only be built if --enable-shared is yes")
424            FRAMEWORK_BUILD=0
425        fi
426    else
427        AC_MSG_RESULT([standard shared library])
428        FRAMEWORK_BUILD=0
429    fi
430])
431
432#------------------------------------------------------------------------
433# SC_ENABLE_THREADS --
434#
435#       Specify if thread support should be enabled
436#
437# Arguments:
438#       none
439#       
440# Results:
441#
442#       Adds the following arguments to configure:
443#               --enable-threads
444#
445#       Sets the following vars:
446#               THREADS_LIBS    Thread library(s)
447#
448#       Defines the following vars:
449#               TCL_THREADS
450#               _REENTRANT
451#               _THREAD_SAFE
452#
453#------------------------------------------------------------------------
454
455AC_DEFUN(SC_ENABLE_THREADS, [
456    AC_MSG_CHECKING(for building with threads)
457    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
458        [tcl_ok=$enableval], [tcl_ok=no])
459
460    if test "$tcl_ok" = "yes"; then
461        AC_MSG_RESULT(yes)
462        TCL_THREADS=1
463        AC_DEFINE(TCL_THREADS)
464        # USE_THREAD_ALLOC tells us to try the special thread-based
465        # allocator that significantly reduces lock contention
466        AC_DEFINE(USE_THREAD_ALLOC)
467        AC_DEFINE(_REENTRANT)
468        AC_DEFINE(_THREAD_SAFE)
469        AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
470        if test "$tcl_ok" = "no"; then
471            # Check a little harder for __pthread_mutex_init in the same
472            # library, as some systems hide it there until pthread.h is
473            # defined.  We could alternatively do an AC_TRY_COMPILE with
474            # pthread.h, but that will work with libpthread really doesn't
475            # exist, like AIX 4.2.  [Bug: 4359]
476            AC_CHECK_LIB(pthread,__pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
477        fi
478
479        if test "$tcl_ok" = "yes"; then
480            # The space is needed
481            THREADS_LIBS=" -lpthread"
482        else
483            AC_CHECK_LIB(pthreads,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
484            if test "$tcl_ok" = "yes"; then
485                # The space is needed
486                THREADS_LIBS=" -lpthreads"
487            else
488                AC_CHECK_LIB(c,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
489                if test "$tcl_ok" = "no"; then
490                    AC_CHECK_LIB(c_r,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
491                    if test "$tcl_ok" = "yes"; then
492                        # The space is needed
493                        THREADS_LIBS=" -pthread"
494                    else
495                        TCL_THREADS=0
496                        AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")
497                    fi
498                fi
499            fi
500        fi
501
502        # Does the pthread-implementation provide
503        # 'pthread_attr_setstacksize' ?
504
505        ac_saved_libs=$LIBS
506        LIBS="$LIBS $THREADS_LIBS"
507        AC_CHECK_FUNCS(pthread_attr_setstacksize)
508        LIBS=$ac_saved_libs
509        AC_CHECK_FUNCS(readdir_r)
510    else
511        TCL_THREADS=0
512        AC_MSG_RESULT([no (default)])
513    fi
514    AC_SUBST(TCL_THREADS)
515])
516
517#------------------------------------------------------------------------
518# SC_ENABLE_SYMBOLS --
519#
520#       Specify if debugging symbols should be used.
521#       Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
522#       can also be enabled.
523#
524# Arguments:
525#       none
526#       
527#       Requires the following vars to be set in the Makefile:
528#               CFLAGS_DEBUG
529#               CFLAGS_OPTIMIZE
530#               LDFLAGS_DEBUG
531#               LDFLAGS_OPTIMIZE
532#       
533# Results:
534#
535#       Adds the following arguments to configure:
536#               --enable-symbols
537#
538#       Defines the following vars:
539#               CFLAGS_DEFAULT  Sets to $(CFLAGS_DEBUG) if true
540#                               Sets to $(CFLAGS_OPTIMIZE) if false
541#               LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
542#                               Sets to $(LDFLAGS_OPTIMIZE) if false
543#               DBGX            Debug library extension
544#
545#------------------------------------------------------------------------
546
547AC_DEFUN(SC_ENABLE_SYMBOLS, [
548    AC_MSG_CHECKING([for build with symbols])
549    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
550# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
551    if test "$tcl_ok" = "no"; then
552        CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
553        LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
554        DBGX=""
555        AC_MSG_RESULT([no])
556    else
557        CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
558        LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
559        DBGX=g
560        if test "$tcl_ok" = "yes"; then
561            AC_MSG_RESULT([yes (standard debugging)])
562        fi
563    fi
564    AC_SUBST(CFLAGS_DEFAULT)
565    AC_SUBST(LDFLAGS_DEFAULT)
566
567    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
568        AC_DEFINE(TCL_MEM_DEBUG)
569    fi
570
571    if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
572        AC_DEFINE(TCL_COMPILE_DEBUG)
573        AC_DEFINE(TCL_COMPILE_STATS)
574    fi
575
576    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
577        if test "$tcl_ok" = "all"; then
578            AC_MSG_RESULT([enabled symbols mem compile debugging])
579        else
580            AC_MSG_RESULT([enabled $tcl_ok debugging])
581        fi
582    fi
583])
584
585#------------------------------------------------------------------------
586# SC_ENABLE_LANGINFO --
587#
588#       Allows use of modern nl_langinfo check for better l10n.
589#       This is only relevant for Unix.
590#
591# Arguments:
592#       none
593#       
594# Results:
595#
596#       Adds the following arguments to configure:
597#               --enable-langinfo=yes|no (default is yes)
598#
599#       Defines the following vars:
600#               HAVE_LANGINFO   Triggers use of nl_langinfo if defined.
601#
602#------------------------------------------------------------------------
603
604AC_DEFUN(SC_ENABLE_LANGINFO, [
605    AC_ARG_ENABLE(langinfo,
606        [  --enable-langinfo      use nl_langinfo if possible to determine
607                          encoding at startup, otherwise use old heuristic],
608        [langinfo_ok=$enableval], [langinfo_ok=yes])
609
610    HAVE_LANGINFO=0
611    if test "$langinfo_ok" = "yes"; then
612        if test "$langinfo_ok" = "yes"; then
613            AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
614        fi
615    fi
616    AC_MSG_CHECKING([whether to use nl_langinfo])
617    if test "$langinfo_ok" = "yes"; then
618        AC_TRY_COMPILE([#include <langinfo.h>],
619                [nl_langinfo(CODESET);],[langinfo_ok=yes],[langinfo_ok=no])
620        if test "$langinfo_ok" = "no"; then
621            langinfo_ok="no (could not compile with nl_langinfo)";
622        fi
623        if test "$langinfo_ok" = "yes"; then
624            AC_DEFINE(HAVE_LANGINFO)
625        fi
626    fi
627    AC_MSG_RESULT([$langinfo_ok])
628])
629
630#--------------------------------------------------------------------
631# SC_CONFIG_MANPAGES
632#       
633#       Decide whether to use symlinks for linking the manpages and
634#       whether to compress the manpages after installation.
635#
636# Arguments:
637#       none
638#
639# Results:
640#
641#       Adds the following arguments to configure:
642#               --enable-man-symlinks
643#               --enable-man-compression=PROG
644#
645#       Defines the following variable:
646#
647#       MKLINKS_FLAGS -         The apropriate flags for mkLinks
648#                               according to the user's selection.
649#
650#--------------------------------------------------------------------
651AC_DEFUN(SC_CONFIG_MANPAGES, [
652
653        AC_MSG_CHECKING([whether to use symlinks for manpages])
654        AC_ARG_ENABLE(man-symlinks,
655                [  --enable-man-symlinks   use symlinks for the manpages],
656                test "$enableval" != "no" && MKLINKS_FLAGS="$MKLINKS_FLAGS --symlinks",
657                enableval="no")
658        AC_MSG_RESULT([$enableval])
659
660        AC_MSG_CHECKING([compression for manpages])
661        AC_ARG_ENABLE(man-compression,
662                [  --enable-man-compression=PROG
663                          compress the manpages with PROG],
664                test "$enableval" = "yes" && echo && AC_MSG_ERROR([missing argument to --enable-man-compression])
665                test "$enableval" != "no" && MKLINKS_FLAGS="$MKLINKS_FLAGS --compress $enableval",
666                enableval="no")
667        AC_MSG_RESULT([$enableval])
668
669        AC_SUBST(MKLINKS_FLAGS)
670])
671
672#--------------------------------------------------------------------
673# SC_CONFIG_CFLAGS
674#
675#       Try to determine the proper flags to pass to the compiler
676#       for building shared libraries and other such nonsense.
677#
678# Arguments:
679#       none
680#
681# Results:
682#
683#       Defines and substitutes the following vars:
684#
685#       DL_OBJS -       Name of the object file that implements dynamic
686#                       loading for Tcl on this system.
687#       DL_LIBS -       Library file(s) to include in tclsh and other base
688#                       applications in order for the "load" command to work.
689#       LDFLAGS -      Flags to pass to the compiler when linking object
690#                       files into an executable application binary such
691#                       as tclsh.
692#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
693#                       that tell the run-time dynamic linker where to look
694#                       for shared libraries such as libtcl.so.  Depends on
695#                       the variable LIB_RUNTIME_DIR in the Makefile. Could
696#                       be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
697#       CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
698#                       that tell the run-time dynamic linker where to look
699#                       for shared libraries such as libtcl.so.  Depends on
700#                       the variable LIB_RUNTIME_DIR in the Makefile.
701#       MAKE_LIB -      Command to execute to build the a library;
702#                       differs when building shared or static.
703#       MAKE_STUB_LIB -
704#                       Command to execute to build a stub library.
705#       INSTALL_LIB -   Command to execute to install a library;
706#                       differs when building shared or static.
707#       INSTALL_STUB_LIB -
708#                       Command to execute to install a stub library.
709#       STLIB_LD -      Base command to use for combining object files
710#                       into a static library.
711#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
712#                       of a shared library (may request position-independent
713#                       code, among other things).
714#       SHLIB_LD -      Base command to use for combining object files
715#                       into a shared library.
716#       SHLIB_LD_FLAGS -Flags to pass when building a shared library. This
717#                       differes from the SHLIB_CFLAGS as it is not used
718#                       when building object files or executables.
719#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
720#                       creating shared libraries.  This symbol typically
721#                       goes at the end of the "ld" commands that build
722#                       shared libraries. The value of the symbol is
723#                       "${LIBS}" if all of the dependent libraries should
724#                       be specified when creating a shared library.  If
725#                       dependent libraries should not be specified (as on
726#                       SunOS 4.x, where they cause the link to fail, or in
727#                       general if Tcl and Tk aren't themselves shared
728#                       libraries), then this symbol has an empty string
729#                       as its value.
730#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
731#                       extensions.  An empty string means we don't know how
732#                       to use shared libraries on this platform.
733# TCL_SHLIB_LD_EXTRAS - Additional element which are added to SHLIB_LD_LIBS
734#  TK_SHLIB_LD_EXTRAS   for the build of Tcl and Tk, but not recorded in the
735#                       tclConfig.sh, since they are only used for the build
736#                       of Tcl and Tk.
737#                       Examples: MacOS X records the library version and
738#                       compatibility version in the shared library.  But
739#                       of course the Tcl version of this is only used for Tcl.
740#       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
741#                       in a static or shared library name, using the $VERSION variable
742#                       to put the version in the right place.  This is used
743#                       by platforms that need non-standard library names.
744#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
745#                       to have a version after the .so, and ${VERSION}.a
746#                       on AIX, since a shared library needs to have
747#                       a .a extension whereas shared objects for loadable
748#                       extensions have a .so extension.  Defaults to
749#                       ${VERSION}${SHLIB_SUFFIX}.
750#       TCL_NEEDS_EXP_FILE -
751#                       1 means that an export file is needed to link to a
752#                       shared library.
753#       TCL_EXP_FILE -  The name of the installed export / import file which
754#                       should be used to link to the Tcl shared library.
755#                       Empty if Tcl is unshared.
756#       TCL_BUILD_EXP_FILE -
757#                       The name of the built export / import file which
758#                       should be used to link to the Tcl shared library.
759#                       Empty if Tcl is unshared.
760#       CFLAGS_DEBUG -
761#                       Flags used when running the compiler in debug mode
762#       CFLAGS_OPTIMIZE -
763#                       Flags used when running the compiler in optimize mode
764#       EXTRA_CFLAGS
765#
766#--------------------------------------------------------------------
767
768AC_DEFUN(SC_CONFIG_CFLAGS, [
769
770    # Step 0.a: Enable 64 bit support?
771
772    AC_MSG_CHECKING([if 64bit support is requested])
773    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support (where applicable)],,enableval="no")
774
775    if test "$enableval" = "yes"; then
776        do64bit=yes
777    else
778        do64bit=no
779    fi
780    AC_MSG_RESULT($do64bit)
781
782    # Step 0.b: Enable Solaris 64 bit VIS support?
783
784    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
785    AC_ARG_ENABLE(64bit-vis,[  --enable-64bit-vis      enable 64bit Sparc VIS support],,enableval="no")
786
787    if test "$enableval" = "yes"; then
788        # Force 64bit on with VIS
789        do64bit=yes
790        do64bitVIS=yes
791    else
792        do64bitVIS=no
793    fi
794    AC_MSG_RESULT($do64bitVIS)
795
796    # Step 1: set the variable "system" to hold the name and version number
797    # for the system.  This can usually be done via the "uname" command, but
798    # there are a few systems, like Next, where this doesn't work.
799
800    AC_MSG_CHECKING([system version (for dynamic loading)])
801    if test -f /usr/lib/NextStep/software_version; then
802        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
803    else
804        system=`uname -s`-`uname -r`
805        if test "$?" -ne 0 ; then
806            AC_MSG_RESULT([unknown (can't find uname command)])
807            system=unknown
808        else
809            # Special check for weird MP-RAS system (uname returns weird
810            # results, and the version is kept in special file).
811       
812            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
813                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
814            fi
815            if test "`uname -s`" = "AIX" ; then
816                system=AIX-`uname -v`.`uname -r`
817            fi
818            AC_MSG_RESULT($system)
819        fi
820    fi
821
822    # Step 2: check for existence of -ldl library.  This is needed because
823    # Linux can use either -ldl or -ldld for dynamic loading.
824
825    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
826
827    # Require ranlib early so we can override it in special cases below.
828
829    AC_REQUIRE([AC_PROG_RANLIB])
830
831    # Step 3: set configuration options based on system name and version.
832
833    do64bit_ok=no
834    EXTRA_CFLAGS=""
835    TCL_EXPORT_FILE_SUFFIX=""
836    UNSHARED_LIB_SUFFIX=""
837    TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
838    ECHO_VERSION='`echo ${VERSION}`'
839    TCL_LIB_VERSIONS_OK=ok
840    CFLAGS_DEBUG=-g
841    CFLAGS_OPTIMIZE=-O
842    if test "$GCC" = "yes" ; then
843        CFLAGS_WARNING="-Wall -Wconversion -Wno-implicit-int"
844    else
845        CFLAGS_WARNING=""
846    fi
847    TCL_NEEDS_EXP_FILE=0
848    TCL_BUILD_EXP_FILE=""
849    TCL_EXP_FILE=""
850dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
851dnl AC_CHECK_TOOL(AR, ar)
852    AC_CHECK_PROG(AR, ar, ar)
853    if test "${AR}" = "" ; then
854        AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
855    fi
856    STLIB_LD='${AR} cr'
857    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
858    PLAT_OBJS=""
859    case $system in
860        AIX-5.*)
861            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
862                # AIX requires the _r compiler when gcc isn't being used
863                if test "${CC}" != "cc_r" ; then
864                    CC=${CC}_r
865                fi
866                AC_MSG_RESULT(Using $CC for compiling with threads)
867            fi
868            LIBS="$LIBS -lc"
869            # AIX-5 uses ELF style dynamic libraries
870            SHLIB_CFLAGS=""
871            SHLIB_LD_LIBS='${LIBS}'
872            SHLIB_SUFFIX=".so"
873            if test "`uname -m`" = "ia64" ; then
874                # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
875                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
876                # AIX-5 has dl* in libc.so
877                DL_LIBS=""
878                if test "$GCC" = "yes" ; then
879                    CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
880                else
881                    CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
882                fi
883                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
884            else
885                SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
886                DL_LIBS="-ldl"
887                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
888                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
889                TCL_NEEDS_EXP_FILE=1
890                TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
891            fi
892
893            # Note: need the LIBS below, otherwise Tk won't find Tcl's
894            # symbols when dynamically loaded into tclsh.
895
896            DL_OBJS="tclLoadDl.o"
897            LDFLAGS=""
898
899            LD_LIBRARY_PATH_VAR="LIBPATH"
900
901            # Check to enable 64-bit flags for compiler/linker
902            if test "$do64bit" = "yes" ; then
903                if test "$GCC" = "yes" ; then
904                    AC_MSG_WARN("64bit mode not supported with GCC on $system")
905                else
906                    do64bit_ok=yes
907                    EXTRA_CFLAGS="-q64"
908                    LDFLAGS="-q64"
909                    RANLIB="${RANLIB} -X64"
910                    AR="${AR} -X64"
911                    SHLIB_LD_FLAGS="-b64"
912                fi
913            fi
914            ;;
915        AIX-*)
916            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
917                # AIX requires the _r compiler when gcc isn't being used
918                if test "${CC}" != "cc_r" ; then
919                    CC=${CC}_r
920                fi
921                AC_MSG_RESULT(Using $CC for compiling with threads)
922            fi
923            LIBS="$LIBS -lc"
924            SHLIB_CFLAGS=""
925            SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
926            SHLIB_LD_LIBS='${LIBS}'
927            SHLIB_SUFFIX=".so"
928            DL_OBJS="tclLoadDl.o"
929            DL_LIBS="-ldl"
930            LDFLAGS=""
931            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
932            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
933            LD_LIBRARY_PATH_VAR="LIBPATH"
934            TCL_NEEDS_EXP_FILE=1
935            TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
936
937            # AIX v<=4.1 has some different flags than 4.2+
938            if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
939                LIBOBJS="$LIBOBJS tclLoadAix.o"
940                DL_LIBS="-lld"
941            fi
942
943            # On AIX <=v4 systems, libbsd.a has to be linked in to support
944            # non-blocking file IO.  This library has to be linked in after
945            # the MATH_LIBS or it breaks the pow() function.  The way to
946            # insure proper sequencing, is to add it to the tail of MATH_LIBS.
947            # This library also supplies gettimeofday.
948            #
949            # AIX does not have a timezone field in struct tm. When the AIX
950            # bsd library is used, the timezone global and the gettimeofday
951            # methods are to be avoided for timezone deduction instead, we
952            # deduce the timezone by comparing the localtime result on a
953            # known GMT value.
954
955            AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
956            if test $libbsd = yes; then
957                MATH_LIBS="$MATH_LIBS -lbsd"
958                AC_DEFINE(USE_DELTA_FOR_TZ)
959            fi
960
961            # Check to enable 64-bit flags for compiler/linker
962            if test "$do64bit" = "yes" ; then
963                if test "$GCC" = "yes" ; then
964                    AC_MSG_WARN("64bit mode not supported with GCC on $system")
965                else
966                    do64bit_ok=yes
967                    EXTRA_CFLAGS="-q64"
968                    LDFLAGS="-q64"
969                    RANLIB="${RANLIB} -X64"
970                    AR="${AR} -X64"
971                    SHLIB_LD_FLAGS="-b64"
972                fi
973            fi
974            ;;
975        BSD/OS-2.1*|BSD/OS-3*)
976            SHLIB_CFLAGS=""
977            SHLIB_LD="shlicc -r"
978            SHLIB_LD_LIBS='${LIBS}'
979            SHLIB_SUFFIX=".so"
980            DL_OBJS="tclLoadDl.o"
981            DL_LIBS="-ldl"
982            LDFLAGS=""
983            CC_SEARCH_FLAGS=""
984            LD_SEARCH_FLAGS=""
985            ;;
986        BSD/OS-4.*)
987            SHLIB_CFLAGS="-export-dynamic -fPIC"
988            SHLIB_LD="cc -shared"
989            SHLIB_LD_LIBS='${LIBS}'
990            SHLIB_SUFFIX=".so"
991            DL_OBJS="tclLoadDl.o"
992            DL_LIBS="-ldl"
993            LDFLAGS="-export-dynamic"
994            CC_SEARCH_FLAGS=""
995            LD_SEARCH_FLAGS=""
996            ;;
997        dgux*)
998            SHLIB_CFLAGS="-K PIC"
999            SHLIB_LD="cc -G"
1000            SHLIB_LD_LIBS=""
1001            SHLIB_SUFFIX=".so"
1002            DL_OBJS="tclLoadDl.o"
1003            DL_LIBS="-ldl"
1004            LDFLAGS=""
1005            CC_SEARCH_FLAGS=""
1006            LD_SEARCH_FLAGS=""
1007            ;;
1008        HP-UX-*.11.*)
1009            # Use updated header definitions where possible
1010            AC_DEFINE(_XOPEN_SOURCE)          # Use the XOPEN network library
1011            AC_DEFINE(_XOPEN_SOURCE_EXTENDED) # Use the XOPEN network library
1012            LIBS="$LIBS -lxnet"               # Use the XOPEN network library
1013
1014            SHLIB_SUFFIX=".sl"
1015            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1016            if test "$tcl_ok" = yes; then
1017                SHLIB_CFLAGS="+z"
1018                SHLIB_LD="ld -b"
1019                SHLIB_LD_LIBS='${LIBS}'
1020                DL_OBJS="tclLoadShl.o"
1021                DL_LIBS="-ldld"
1022                LDFLAGS="-Wl,-E"
1023                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1024                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1025                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1026            fi
1027
1028            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
1029            #EXTRA_CFLAGS="+DAportable"
1030
1031            # Check to enable 64-bit flags for compiler/linker
1032            if test "$do64bit" = "yes" ; then
1033                if test "$GCC" = "yes" ; then
1034                    hpux_arch=`gcc -dumpmachine`
1035                    case $hpux_arch in
1036                        hppa64*)
1037                            # 64-bit gcc in use.  Fix flags for GNU ld.
1038                            do64bit_ok=yes
1039                            SHLIB_LD="gcc -shared"
1040                            SHLIB_LD_LIBS=""
1041                            LD_SEARCH_FLAGS=''
1042                            CC_SEARCH_FLAGS=''
1043                            ;;
1044                        *)
1045                            AC_MSG_WARN("64bit mode not supported with GCC on $system")
1046                            ;;
1047                    esac
1048                else
1049                    do64bit_ok=yes
1050                    if test "`uname -m`" = "ia64" ; then
1051                        EXTRA_CFLAGS="+DD64"
1052                        LDFLAGS="+DD64 $LDFLAGS"
1053                    else
1054                        EXTRA_CFLAGS="+DA2.0W"
1055                        LDFLAGS="+DA2.0W $LDFLAGS"
1056                    fi
1057                fi
1058            fi
1059            ;;
1060        HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
1061            SHLIB_SUFFIX=".sl"
1062            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1063            if test "$tcl_ok" = yes; then
1064                SHLIB_CFLAGS="+z"
1065                SHLIB_LD="ld -b"
1066                SHLIB_LD_LIBS=""
1067                DL_OBJS="tclLoadShl.o"
1068                DL_LIBS="-ldld"
1069                LDFLAGS="-Wl,-E"
1070                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1071                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1072                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1073            fi
1074            ;;
1075        IRIX-4.*)
1076            SHLIB_CFLAGS="-G 0"
1077            SHLIB_SUFFIX=".a"
1078            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1079            SHLIB_LD_LIBS='${LIBS}'
1080            DL_OBJS="tclLoadAout.o"
1081            DL_LIBS=""
1082            LDFLAGS="-Wl,-D,08000000"
1083            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1084            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1085            SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1086            ;;
1087        IRIX-5.*)
1088            SHLIB_CFLAGS=""
1089            SHLIB_LD="ld -shared -rdata_shared"
1090            SHLIB_LD_LIBS='${LIBS}'
1091            SHLIB_SUFFIX=".so"
1092            DL_OBJS="tclLoadDl.o"
1093            DL_LIBS=""
1094            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1095            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1096            EXTRA_CFLAGS=""
1097            LDFLAGS=""
1098            ;;
1099        IRIX-6.*|IRIX64-6.5*)
1100            SHLIB_CFLAGS=""
1101            SHLIB_LD="ld -n32 -shared -rdata_shared"
1102            SHLIB_LD_LIBS='${LIBS}'
1103            SHLIB_SUFFIX=".so"
1104            DL_OBJS="tclLoadDl.o"
1105            DL_LIBS=""
1106            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1107            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1108            if test "$GCC" = "yes" ; then
1109                EXTRA_CFLAGS="-mabi=n32"
1110                LDFLAGS="-mabi=n32"
1111            else
1112                case $system in
1113                    IRIX-6.3)
1114                        # Use to build 6.2 compatible binaries on 6.3.