source: trunk/cf/tcl.m4 @ 6301

Last change on this file since 6301 was 3362, checked in by ldelgass, 12 years ago

Merge nanovis2 branch to trunk

File size: 96.7 KB
Line 
1#------------------------------------------------------------------------
2# SC_PATH_TCLCONFIG --
3#
4#       Locate the tclConfig.sh file and perform a sanity check on
5#       the Tcl compile flags
6#
7# Arguments:
8#       none
9#
10# Results:
11#
12#       Adds the following arguments to configure:
13#               --with-tcl=...
14#
15#       Defines the following vars:
16#               TCL_BIN_DIR     Full path to the directory containing
17#                               the tclConfig.sh file
18#------------------------------------------------------------------------
19
20AC_DEFUN([SC_PATH_TCLCONFIG], [
21    #
22    # Ok, lets find the tcl configuration
23    # First, look for one uninstalled.
24    # the alternative search directory is invoked by --with-tcl
25    #
26
27    if test x"${no_tcl}" = x ; then
28        # we reset no_tcl in case something fails here
29        no_tcl=true
30        AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
31        AC_MSG_CHECKING([for Tcl configuration])
32        AC_CACHE_VAL(ac_cv_c_tclconfig,[
33
34            # First check to see if --with-tcl was specified.
35            if test x"${with_tclconfig}" != x ; then
36                if test -f "${with_tclconfig}/tclConfig.sh" ; then
37                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
38                else
39                    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
40                fi
41            fi
42
43            # then check for a private Tcl installation
44            if test x"${ac_cv_c_tclconfig}" = x ; then
45                for i in \
46                        ../tcl \
47                        `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
48                        `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
49                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
50                        ../../tcl \
51                        `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
52                        `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
53                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
54                        ../../../tcl \
55                        `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
56                        `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
57                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
58                    if test -f "$i/unix/tclConfig.sh" ; then
59                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
60                        break
61                    fi
62                done
63            fi
64
65            # on Darwin, check in Framework installation locations
66            if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
67                for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
68                        `ls -d /Library/Frameworks 2>/dev/null` \
69                        `ls -d /Network/Library/Frameworks 2>/dev/null` \
70                        `ls -d /System/Library/Frameworks 2>/dev/null` \
71                        ; do
72                    if test -f "$i/Tcl.framework/tclConfig.sh" ; then
73                        ac_cv_c_tclconfig=`(cd $i/Tcl.framework; pwd)`
74                        break
75                    fi
76                done
77            fi
78
79            # check in a few common install locations
80            if test x"${ac_cv_c_tclconfig}" = x ; then
81                for i in `ls -d ${libdir} 2>/dev/null` \
82                        `ls -d ${exec_prefix}/lib 2>/dev/null` \
83                        `ls -d ${prefix}/lib 2>/dev/null` \
84                        `ls -d /usr/local/lib 2>/dev/null` \
85                        `ls -d /usr/contrib/lib 2>/dev/null` \
86                        `ls -d /usr/lib 2>/dev/null` \
87                        ; do
88                    if test -f "$i/tclConfig.sh" ; then
89                        ac_cv_c_tclconfig=`(cd $i; pwd)`
90                        break
91                    fi
92                done
93            fi
94
95            # check in a few other private locations
96            if test x"${ac_cv_c_tclconfig}" = x ; then
97                for i in \
98                        ${srcdir}/../tcl \
99                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
100                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
101                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
102                    if test -f "$i/unix/tclConfig.sh" ; then
103                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
104                    break
105                fi
106                done
107            fi
108        ])
109
110        if test x"${ac_cv_c_tclconfig}" = x ; then
111            TCL_BIN_DIR="# no Tcl configs found"
112            AC_MSG_WARN([Can't find Tcl configuration definitions])
113            exit 0
114        else
115            no_tcl=
116            TCL_BIN_DIR=${ac_cv_c_tclconfig}
117            AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
118        fi
119    fi
120])
121
122#------------------------------------------------------------------------
123# SC_PATH_TKCONFIG --
124#
125#       Locate the tkConfig.sh file
126#
127# Arguments:
128#       none
129#
130# Results:
131#
132#       Adds the following arguments to configure:
133#               --with-tk=...
134#
135#       Defines the following vars:
136#               TK_BIN_DIR      Full path to the directory containing
137#                               the tkConfig.sh file
138#------------------------------------------------------------------------
139
140AC_DEFUN([SC_PATH_TKCONFIG], [
141    #
142    # Ok, lets find the tk configuration
143    # First, look for one uninstalled.
144    # the alternative search directory is invoked by --with-tk
145    #
146
147    if test x"${no_tk}" = x ; then
148        # we reset no_tk in case something fails here
149        no_tk=true
150        AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
151        AC_MSG_CHECKING([for Tk configuration])
152        AC_CACHE_VAL(ac_cv_c_tkconfig,[
153
154            # First check to see if --with-tkconfig was specified.
155            if test x"${with_tkconfig}" != x ; then
156                if test -f "${with_tkconfig}/tkConfig.sh" ; then
157                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
158                else
159                    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
160                fi
161            fi
162
163            # then check for a private Tk library
164            if test x"${ac_cv_c_tkconfig}" = x ; then
165                for i in \
166                        ../tk \
167                        `ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
168                        `ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
169                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
170                        ../../tk \
171                        `ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
172                        `ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
173                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
174                        ../../../tk \
175                        `ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
176                        `ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
177                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
178                    if test -f "$i/unix/tkConfig.sh" ; then
179                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
180                        break
181                    fi
182                done
183            fi
184
185            # on Darwin, check in Framework installation locations
186            if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then
187                for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
188                        `ls -d /Library/Frameworks 2>/dev/null` \
189                        `ls -d /Network/Library/Frameworks 2>/dev/null` \
190                        `ls -d /System/Library/Frameworks 2>/dev/null` \
191                        ; do
192                    if test -f "$i/Tk.framework/tkConfig.sh" ; then
193                        ac_cv_c_tkconfig=`(cd $i/Tk.framework; pwd)`
194                        break
195                    fi
196                done
197            fi
198
199            # check in a few common install locations
200            if test x"${ac_cv_c_tkconfig}" = x ; then
201                for i in `ls -d ${libdir} 2>/dev/null` \
202                        `ls -d ${exec_prefix}/lib 2>/dev/null` \
203                        `ls -d ${prefix}/lib 2>/dev/null` \
204                        `ls -d /usr/local/lib 2>/dev/null` \
205                        `ls -d /usr/contrib/lib 2>/dev/null` \
206                        `ls -d /usr/lib 2>/dev/null` \
207                        ; do
208                    if test -f "$i/tkConfig.sh" ; then
209                        ac_cv_c_tkconfig=`(cd $i; pwd)`
210                        break
211                    fi
212                done
213            fi
214            # check in a few other private locations
215            if test x"${ac_cv_c_tkconfig}" = x ; then
216                for i in \
217                        ${srcdir}/../tk \
218                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
219                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
220                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
221                    if test -f "$i/unix/tkConfig.sh" ; then
222                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
223                        break
224                    fi
225                done
226            fi
227        ])
228
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# SC_LOAD_TCLCONFIG --
243#
244#       Load the tclConfig.sh file
245#
246# Arguments:
247#       
248#       Requires the following vars to be set:
249#               TCL_BIN_DIR
250#
251# Results:
252#
253#       Subst the following vars:
254#               TCL_BIN_DIR
255#               TCL_SRC_DIR
256#               TCL_LIB_FILE
257#
258#------------------------------------------------------------------------
259
260AC_DEFUN([SC_LOAD_TCLCONFIG], [
261    AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
262
263    if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
264        AC_MSG_RESULT([loading])
265        . ${TCL_BIN_DIR}/tclConfig.sh
266    else
267        AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
268    fi
269
270    # eval is required to do the TCL_DBGX substitution
271    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
272    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
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    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    elif test "`uname -s`" = "Darwin"; then
285        # If Tcl was built as a framework, attempt to use the libraries
286        # from the framework at the given location so that linking works
287        # against Tcl.framework installed in an arbitary location.
288        case ${TCL_DEFS} in
289            *TCL_FRAMEWORK*)
290                if test -f ${TCL_BIN_DIR}/${TCL_LIB_FILE}; then
291                    for i in "`cd ${TCL_BIN_DIR}; pwd`" \
292                             "`cd ${TCL_BIN_DIR}/../..; pwd`"; do
293                        if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
294                            TCL_LIB_SPEC="-F`dirname "$i"` -framework ${TCL_LIB_FILE}"
295                            break
296                        fi
297                    done
298                fi
299                if test -f ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}; then
300                    TCL_STUB_LIB_SPEC="-L${TCL_BIN_DIR} ${TCL_STUB_LIB_FLAG}"
301                    TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
302                fi
303                ;;
304        esac
305    fi
306
307    # eval is required to do the TCL_DBGX substitution
308    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
309    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
310    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
311    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
312
313    AC_SUBST(TCL_VERSION)
314    AC_SUBST(TCL_PATCH_LEVEL)
315    AC_SUBST(TCL_BIN_DIR)
316    AC_SUBST(TCL_SRC_DIR)
317
318    AC_SUBST(TCL_LIB_FILE)
319    AC_SUBST(TCL_LIB_FLAG)
320    AC_SUBST(TCL_LIB_SPEC)
321
322    AC_SUBST(TCL_STUB_LIB_FILE)
323    AC_SUBST(TCL_STUB_LIB_FLAG)
324    AC_SUBST(TCL_STUB_LIB_SPEC)
325])
326
327#------------------------------------------------------------------------
328# SC_LOAD_TKCONFIG --
329#
330#       Load the tkConfig.sh file
331#
332# Arguments:
333#       
334#       Requires the following vars to be set:
335#               TK_BIN_DIR
336#
337# Results:
338#
339#       Sets the following vars that should be in tkConfig.sh:
340#               TK_BIN_DIR
341#------------------------------------------------------------------------
342
343AC_DEFUN([SC_LOAD_TKCONFIG], [
344    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
345
346    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
347        AC_MSG_RESULT([loading])
348        . ${TK_BIN_DIR}/tkConfig.sh
349    else
350        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
351    fi
352
353    # eval is required to do the TK_DBGX substitution
354    eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
355    eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
356
357    # If the TK_BIN_DIR is the build directory (not the install directory),
358    # then set the common variable name to the value of the build variables.
359    # For example, the variable TK_LIB_SPEC will be set to the value
360    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
361    # instead of TK_BUILD_LIB_SPEC since it will work with both an
362    # installed and uninstalled version of Tcl.
363    if test -f ${TK_BIN_DIR}/Makefile ; then
364        TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
365        TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
366        TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
367    elif test "`uname -s`" = "Darwin"; then
368        # If Tk was built as a framework, attempt to use the libraries
369        # from the framework at the given location so that linking works
370        # against Tk.framework installed in an arbitary location.
371        case ${TK_DEFS} in
372            *TK_FRAMEWORK*)
373                if test -f ${TK_BIN_DIR}/${TK_LIB_FILE}; then
374                    for i in "`cd ${TK_BIN_DIR}; pwd`" \
375                             "`cd ${TK_BIN_DIR}/../..; pwd`"; do
376                        if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
377                            TK_LIB_SPEC="-F`dirname "$i"` -framework ${TK_LIB_FILE}"
378                            break
379                        fi
380                    done
381                fi
382                if test -f ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}; then
383                    TK_STUB_LIB_SPEC="-L${TK_BIN_DIR} ${TK_STUB_LIB_FLAG}"
384                    TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
385                fi
386                ;;
387        esac
388    fi
389
390    # eval is required to do the TK_DBGX substitution
391    eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
392    eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
393    eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
394    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
395
396    AC_SUBST(TK_VERSION)
397    AC_SUBST(TK_BIN_DIR)
398    AC_SUBST(TK_SRC_DIR)
399
400    AC_SUBST(TK_LIB_FILE)
401    AC_SUBST(TK_LIB_FLAG)
402    AC_SUBST(TK_LIB_SPEC)
403
404    AC_SUBST(TK_STUB_LIB_FILE)
405    AC_SUBST(TK_STUB_LIB_FLAG)
406    AC_SUBST(TK_STUB_LIB_SPEC)
407])
408
409#------------------------------------------------------------------------
410# SC_PROG_TCLSH
411#       Locate a tclsh shell installed on the system path. This macro
412#       will only find a Tcl shell that already exists on the system.
413#       It will not find a Tcl shell in the Tcl build directory or
414#       a Tcl shell that has been installed from the Tcl build directory.
415#       If a Tcl shell can't be located on the PATH, then TCLSH_PROG will
416#       be set to "". Extensions should take care not to create Makefile
417#       rules that are run by default and depend on TCLSH_PROG. An
418#       extension can't assume that an executable Tcl shell exists at
419#       build time.
420#
421# Arguments
422#       none
423#
424# Results
425#       Subst's the following values:
426#               TCLSH_PROG
427#------------------------------------------------------------------------
428
429AC_DEFUN([SC_PROG_TCLSH], [
430    AC_MSG_CHECKING([for tclsh])
431    AC_CACHE_VAL(ac_cv_path_tclsh, [
432        search_path=`echo ${PATH} | sed -e 's/:/ /g'`
433        for dir in $search_path ; do
434            for j in `ls -r $dir/tclsh[[8-9]]* 2> /dev/null` \
435                    `ls -r $dir/tclsh* 2> /dev/null` ; do
436                if test x"$ac_cv_path_tclsh" = x ; then
437                    if test -f "$j" ; then
438                        ac_cv_path_tclsh=$j
439                        break
440                    fi
441                fi
442            done
443        done
444    ])
445
446    if test -f "$ac_cv_path_tclsh" ; then
447        TCLSH_PROG="$ac_cv_path_tclsh"
448        AC_MSG_RESULT([$TCLSH_PROG])
449    else
450        # It is not an error if an installed version of Tcl can't be located.
451        TCLSH_PROG=""
452        AC_MSG_RESULT([No tclsh found on PATH])
453    fi
454    AC_SUBST(TCLSH_PROG)
455])
456
457#------------------------------------------------------------------------
458# SC_BUILD_TCLSH
459#       Determine the fully qualified path name of the tclsh executable
460#       in the Tcl build directory. This macro will correctly determine
461#       the name of the tclsh executable even if tclsh has not yet
462#       been built in the build directory. The build tclsh must be used
463#       when running tests from an extension build directory. It is not
464#       correct to use the TCLSH_PROG in cases like this.
465#
466# Arguments
467#       none
468#
469# Results
470#       Subst's the following values:
471#               BUILD_TCLSH
472#------------------------------------------------------------------------
473
474AC_DEFUN([SC_BUILD_TCLSH], [
475    AC_MSG_CHECKING([for tclsh in Tcl build directory])
476    BUILD_TCLSH=${TCL_BIN_DIR}/tclsh
477    AC_MSG_RESULT([$BUILD_TCLSH])
478    AC_SUBST(BUILD_TCLSH)
479])
480
481#------------------------------------------------------------------------
482# SC_ENABLE_SHARED --
483#
484#       Allows the building of shared libraries
485#
486# Arguments:
487#       none
488#       
489# Results:
490#
491#       Adds the following arguments to configure:
492#               --enable-shared=yes|no
493#
494#       Defines the following vars:
495#               STATIC_BUILD    Used for building import/export libraries
496#                               on Windows.
497#
498#       Sets the following vars:
499#               SHARED_BUILD    Value of 1 or 0
500#------------------------------------------------------------------------
501
502AC_DEFUN([SC_ENABLE_SHARED], [
503    AC_MSG_CHECKING([how to build libraries])
504    AC_ARG_ENABLE(shared,
505        [  --enable-shared         build and link with shared libraries [--enable-shared]],
506        [tcl_ok=$enableval], [tcl_ok=yes])
507
508    if test "${enable_shared+set}" = set; then
509        enableval="$enable_shared"
510        tcl_ok=$enableval
511    else
512        tcl_ok=yes
513    fi
514
515    if test "$tcl_ok" = "yes" ; then
516        AC_MSG_RESULT([shared])
517        SHARED_BUILD=1
518    else
519        AC_MSG_RESULT([static])
520        SHARED_BUILD=0
521        AC_DEFINE(STATIC_BUILD)
522    fi
523])
524
525#------------------------------------------------------------------------
526# SC_ENABLE_FRAMEWORK --
527#
528#       Allows the building of shared libraries into frameworks
529#
530# Arguments:
531#       none
532#       
533# Results:
534#
535#       Adds the following arguments to configure:
536#               --enable-framework=yes|no
537#
538#       Sets the following vars:
539#               FRAMEWORK_BUILD Value of 1 or 0
540#------------------------------------------------------------------------
541
542AC_DEFUN([SC_ENABLE_FRAMEWORK], [
543    if test "`uname -s`" = "Darwin" ; then
544        AC_MSG_CHECKING([how to package libraries])
545        AC_ARG_ENABLE(framework,
546            [  --enable-framework      package shared libraries in MacOSX frameworks [--disable-framework]],
547            [enable_framework=$enableval], [enable_framework=no])
548        if test $enable_framework = yes; then
549            if test $SHARED_BUILD = 0; then
550                AC_MSG_WARN([Frameworks can only be built if --enable-shared is yes])
551                enable_framework=no
552            fi
553            if test $tcl_corefoundation = no; then
554                AC_MSG_WARN([Frameworks can only be used when CoreFoundation is available])
555                enable_framework=no
556            fi
557        fi
558        if test $enable_framework = yes; then
559            AC_MSG_RESULT([framework])
560            FRAMEWORK_BUILD=1
561        else
562            if test $SHARED_BUILD = 1; then
563                AC_MSG_RESULT([shared library])
564            else
565                AC_MSG_RESULT([static library])
566            fi
567            FRAMEWORK_BUILD=0
568        fi
569    fi
570])
571
572#------------------------------------------------------------------------
573# SC_ENABLE_THREADS --
574#
575#       Specify if thread support should be enabled.  TCL_THREADS is
576#       checked so that if you are compiling an extension against a
577#       threaded core, your extension must be compiled threaded as well.
578#
579# Arguments:
580#       none
581#       
582# Results:
583#
584#       Adds the following arguments to configure:
585#               --enable-threads
586#
587#       Sets the following vars:
588#               THREADS_LIBS    Thread library(s)
589#
590#       Defines the following vars:
591#               TCL_THREADS
592#               _REENTRANT
593#               _THREAD_SAFE
594#
595#------------------------------------------------------------------------
596
597AC_DEFUN([SC_ENABLE_THREADS], [
598    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
599        [tcl_ok=$enableval], [tcl_ok=no])
600
601    if test "${TCL_THREADS}" = 1; then
602        tcl_threaded_core=1;
603    fi
604
605    if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
606        TCL_THREADS=1
607        # USE_THREAD_ALLOC tells us to try the special thread-based
608        # allocator that significantly reduces lock contention
609        AC_DEFINE(USE_THREAD_ALLOC)
610        AC_DEFINE(_REENTRANT)
611        if test "`uname -s`" = "SunOS" ; then
612            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
613        fi
614        AC_DEFINE(_THREAD_SAFE)
615        AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
616        if test "$tcl_ok" = "no"; then
617            # Check a little harder for __pthread_mutex_init in the same
618            # library, as some systems hide it there until pthread.h is
619            # defined.  We could alternatively do an AC_TRY_COMPILE with
620            # pthread.h, but that will work with libpthread really doesn't
621            # exist, like AIX 4.2.  [Bug: 4359]
622            AC_CHECK_LIB(pthread, __pthread_mutex_init,
623                tcl_ok=yes, tcl_ok=no)
624        fi
625
626        if test "$tcl_ok" = "yes"; then
627            # The space is needed
628            THREADS_LIBS=" -lpthread"
629        else
630            AC_CHECK_LIB(pthreads, pthread_mutex_init,
631                tcl_ok=yes, tcl_ok=no)
632            if test "$tcl_ok" = "yes"; then
633                # The space is needed
634                THREADS_LIBS=" -lpthreads"
635            else
636                AC_CHECK_LIB(c, pthread_mutex_init,
637                    tcl_ok=yes, tcl_ok=no)
638                if test "$tcl_ok" = "no"; then
639                    AC_CHECK_LIB(c_r, pthread_mutex_init,
640                        tcl_ok=yes, tcl_ok=no)
641                    if test "$tcl_ok" = "yes"; then
642                        # The space is needed
643                        THREADS_LIBS=" -pthread"
644                    else
645                        TCL_THREADS=0
646                        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...])
647                    fi
648                fi
649            fi
650        fi
651
652        # Does the pthread-implementation provide
653        # 'pthread_attr_setstacksize' ?
654
655        ac_saved_libs=$LIBS
656        LIBS="$LIBS $THREADS_LIBS"
657        AC_CHECK_FUNCS(pthread_attr_setstacksize)
658        AC_CHECK_FUNCS(pthread_atfork)
659        LIBS=$ac_saved_libs
660    else
661        TCL_THREADS=0
662    fi
663    # Do checking message here to not mess up interleaved configure output
664    AC_MSG_CHECKING([for building with threads])
665    if test "${TCL_THREADS}" = 1; then
666        AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
667        if test "${tcl_threaded_core}" = 1; then
668            AC_MSG_RESULT([yes (threaded core)])
669        else
670            AC_MSG_RESULT([yes])
671        fi
672    else
673        AC_MSG_RESULT([no (default)])
674    fi
675
676    AC_SUBST(TCL_THREADS)
677])
678
679#------------------------------------------------------------------------
680# SC_ENABLE_SYMBOLS --
681#
682#       Specify if debugging symbols should be used.
683#       Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
684#       can also be enabled.
685#
686# Arguments:
687#       none
688#       
689#       Requires the following vars to be set in the Makefile:
690#               CFLAGS_DEBUG
691#               CFLAGS_OPTIMIZE
692#               LDFLAGS_DEBUG
693#               LDFLAGS_OPTIMIZE
694#       
695# Results:
696#
697#       Adds the following arguments to configure:
698#               --enable-symbols
699#
700#       Defines the following vars:
701#               CFLAGS_DEFAULT  Sets to $(CFLAGS_DEBUG) if true
702#                               Sets to $(CFLAGS_OPTIMIZE) if false
703#               LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
704#                               Sets to $(LDFLAGS_OPTIMIZE) if false
705#               DBGX            Debug library extension
706#
707#------------------------------------------------------------------------
708
709AC_DEFUN([SC_ENABLE_SYMBOLS], [
710    AC_MSG_CHECKING([for build with symbols])
711    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
712# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
713    if test "$tcl_ok" = "no"; then
714        CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
715        LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
716        DBGX=""
717        AC_MSG_RESULT([no])
718    else
719        CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
720        LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
721        DBGX=g
722        if test "$tcl_ok" = "yes"; then
723            AC_MSG_RESULT([yes (standard debugging)])
724        fi
725    fi
726    AC_SUBST(CFLAGS_DEFAULT)
727    AC_SUBST(LDFLAGS_DEFAULT)
728
729    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
730        AC_DEFINE(TCL_MEM_DEBUG)
731    fi
732
733    if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
734        AC_DEFINE(TCL_COMPILE_DEBUG)
735        AC_DEFINE(TCL_COMPILE_STATS)
736    fi
737
738    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
739        if test "$tcl_ok" = "all"; then
740            AC_MSG_RESULT([enabled symbols mem compile debugging])
741        else
742            AC_MSG_RESULT([enabled $tcl_ok debugging])
743        fi
744    fi
745])
746
747#------------------------------------------------------------------------
748# SC_ENABLE_LANGINFO --
749#
750#       Allows use of modern nl_langinfo check for better l10n.
751#       This is only relevant for Unix.
752#
753# Arguments:
754#       none
755#       
756# Results:
757#
758#       Adds the following arguments to configure:
759#               --enable-langinfo=yes|no (default is yes)
760#
761#       Defines the following vars:
762#               HAVE_LANGINFO   Triggers use of nl_langinfo if defined.
763#
764#------------------------------------------------------------------------
765
766AC_DEFUN([SC_ENABLE_LANGINFO], [
767    AC_ARG_ENABLE(langinfo,
768        [  --enable-langinfo      use nl_langinfo if possible to determine
769                          encoding at startup, otherwise use old heuristic],
770        [langinfo_ok=$enableval], [langinfo_ok=yes])
771
772    HAVE_LANGINFO=0
773    if test "$langinfo_ok" = "yes"; then
774        AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
775    fi
776    AC_MSG_CHECKING([whether to use nl_langinfo])
777    if test "$langinfo_ok" = "yes"; then
778        AC_CACHE_VAL(tcl_cv_langinfo_h, [
779            AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
780                    [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no])])
781        AC_MSG_RESULT([$tcl_cv_langinfo_h])
782        if test $tcl_cv_langinfo_h = yes; then
783            AC_DEFINE(HAVE_LANGINFO)
784        fi
785    else
786        AC_MSG_RESULT([$langinfo_ok])
787    fi
788])
789
790#--------------------------------------------------------------------
791# SC_CONFIG_MANPAGES
792#       
793#       Decide whether to use symlinks for linking the manpages,
794#       whether to compress the manpages after installation, and
795#       whether to add a package name suffix to the installed
796#       manpages to avoidfile name clashes.
797#       If compression is enabled also find out what file name suffix
798#       the given compression program is using.
799#
800# Arguments:
801#       none
802#
803# Results:
804#
805#       Adds the following arguments to configure:
806#               --enable-man-symlinks
807#               --enable-man-compression=PROG
808#               --enable-man-suffix[=STRING]
809#
810#       Defines the following variable:
811#
812#       MAN_FLAGS -     The apropriate flags for installManPage
813#                       according to the user's selection.
814#
815#--------------------------------------------------------------------
816
817AC_DEFUN([SC_CONFIG_MANPAGES], [
818    AC_MSG_CHECKING([whether to use symlinks for manpages])
819    AC_ARG_ENABLE(man-symlinks,
820            [  --enable-man-symlinks   use symlinks for the manpages],
821        test "$enableval" != "no" && MAN_FLAGS="$MAN_FLAGS --symlinks",
822        enableval="no")
823    AC_MSG_RESULT([$enableval])
824
825    AC_MSG_CHECKING([whether to compress the manpages])
826    AC_ARG_ENABLE(man-compression,
827            [  --enable-man-compression=PROG
828                      compress the manpages with PROG],
829        [case $enableval in
830            yes) AC_MSG_ERROR([missing argument to --enable-man-compression]);;
831            no)  ;;
832            *)   MAN_FLAGS="$MAN_FLAGS --compress $enableval";;
833        esac],
834        enableval="no")
835    AC_MSG_RESULT([$enableval])
836    if test "$enableval" != "no"; then
837        AC_MSG_CHECKING([for compressed file suffix])
838        touch TeST
839        $enableval TeST
840        Z=`ls TeST* | sed 's/^....//'`
841        rm -f TeST*
842        MAN_FLAGS="$MAN_FLAGS --extension $Z"
843        AC_MSG_RESULT([$Z])
844    fi
845
846    AC_MSG_CHECKING([whether to add a package name suffix for the manpages])
847    AC_ARG_ENABLE(man-suffix,
848            [  --enable-man-suffix=STRING
849                      use STRING as a suffix to manpage file names
850                      (default: $1)],
851        [case $enableval in
852            yes) enableval="$1" MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
853            no)  ;;
854            *)   MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
855        esac],
856        enableval="no")
857    AC_MSG_RESULT([$enableval])
858
859    AC_SUBST(MAN_FLAGS)
860])
861
862#--------------------------------------------------------------------
863# SC_CONFIG_SYSTEM
864#
865#       Determine what the system is (some things cannot be easily checked
866#       on a feature-driven basis, alas). This can usually be done via the
867#       "uname" command, but there are a few systems, like Next, where
868#       this doesn't work.
869#
870# Arguments:
871#       none
872#
873# Results:
874#       Defines the following var:
875#
876#       system -        System/platform/version identification code.
877#
878#--------------------------------------------------------------------
879
880AC_DEFUN([SC_CONFIG_SYSTEM], [
881    AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
882        if test -f /usr/lib/NextStep/software_version; then
883            tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
884        else
885            tcl_cv_sys_version=`uname -s`-`uname -r`
886            if test "$?" -ne 0 ; then
887                AC_MSG_WARN([can't find uname command])
888                tcl_cv_sys_version=unknown
889            else
890                # Special check for weird MP-RAS system (uname returns weird
891                # results, and the version is kept in special file).
892
893                if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
894                    tcl_cv_sys_version=MP-RAS-`awk '{print $[3]}' /etc/.relid`
895                fi
896                if test "`uname -s`" = "AIX" ; then
897                    tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
898                fi
899            fi
900        fi
901    ])
902    system=$tcl_cv_sys_version
903])
904
905#--------------------------------------------------------------------
906# SC_CONFIG_CFLAGS
907#
908#       Try to determine the proper flags to pass to the compiler
909#       for building shared libraries and other such nonsense.
910#
911# Arguments:
912#       none
913#
914# Results:
915#
916#       Defines and substitutes the following vars:
917#
918#       DL_OBJS -       Name of the object file that implements dynamic
919#                       loading for Tcl on this system.
920#       DL_LIBS -       Library file(s) to include in tclsh and other base
921#                       applications in order for the "load" command to work.
922#       LDFLAGS -      Flags to pass to the compiler when linking object
923#                       files into an executable application binary such
924#                       as tclsh.
925#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
926#                       that tell the run-time dynamic linker where to look
927#                       for shared libraries such as libtcl.so.  Depends on
928#                       the variable LIB_RUNTIME_DIR in the Makefile. Could
929#                       be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
930#       CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
931#                       that tell the run-time dynamic linker where to look
932#                       for shared libraries such as libtcl.so.  Depends on
933#                       the variable LIB_RUNTIME_DIR in the Makefile.
934#       MAKE_LIB -      Command to execute to build the a library;
935#                       differs when building shared or static.
936#       MAKE_STUB_LIB -
937#                       Command to execute to build a stub library.
938#       INSTALL_LIB -   Command to execute to install a library;
939#                       differs when building shared or static.
940#       INSTALL_STUB_LIB -
941#                       Command to execute to install a stub library.
942#       STLIB_LD -      Base command to use for combining object files
943#                       into a static library.
944#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
945#                       of a shared library (may request position-independent
946#                       code, among other things).
947#       SHLIB_LD -      Base command to use for combining object files
948#                       into a shared library.
949#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
950#                       creating shared libraries.  This symbol typically
951#                       goes at the end of the "ld" commands that build
952#                       shared libraries. The value of the symbol is
953#                       "${LIBS}" if all of the dependent libraries should
954#                       be specified when creating a shared library.  If
955#                       dependent libraries should not be specified (as on
956#                       SunOS 4.x, where they cause the link to fail, or in
957#                       general if Tcl and Tk aren't themselves shared
958#                       libraries), then this symbol has an empty string
959#                       as its value.
960#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
961#                       extensions.  An empty string means we don't know how
962#                       to use shared libraries on this platform.
963# TCL_SHLIB_LD_EXTRAS - Additional element which are added to SHLIB_LD_LIBS
964#  TK_SHLIB_LD_EXTRAS   for the build of Tcl and Tk, but not recorded in the
965#                       tclConfig.sh, since they are only used for the build
966#                       of Tcl and Tk.
967#                       Examples: MacOS X records the library version and
968#                       compatibility version in the shared library.  But
969#                       of course the Tcl version of this is only used for Tcl.
970#       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
971#                       in a static or shared library name, using the $VERSION variable
972#                       to put the version in the right place.  This is used
973#                       by platforms that need non-standard library names.
974#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
975#                       to have a version after the .so, and ${VERSION}.a
976#                       on AIX, since a shared library needs to have
977#                       a .a extension whereas shared objects for loadable
978#                       extensions have a .so extension.  Defaults to
979#                       ${VERSION}${SHLIB_SUFFIX}.
980#       TCL_NEEDS_EXP_FILE -
981#                       1 means that an export file is needed to link to a
982#                       shared library.
983#       TCL_EXP_FILE -  The name of the installed export / import file which
984#                       should be used to link to the Tcl shared library.
985#                       Empty if Tcl is unshared.
986#       TCL_BUILD_EXP_FILE -
987#                       The name of the built export / import file which
988#                       should be used to link to the Tcl shared library.
989#                       Empty if Tcl is unshared.
990#       CFLAGS_DEBUG -
991#                       Flags used when running the compiler in debug mode
992#       CFLAGS_OPTIMIZE -
993#                       Flags used when running the compiler in optimize mode
994#       CFLAGS -        Additional CFLAGS added as necessary (usually 64-bit)
995#
996#--------------------------------------------------------------------
997
998AC_DEFUN([SC_CONFIG_CFLAGS], [
999
1000    # Step 0.a: Enable 64 bit support?
1001
1002    AC_MSG_CHECKING([if 64bit support is requested])
1003    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support (where applicable)],
1004        [do64bit=$enableval], [do64bit=no])
1005    AC_MSG_RESULT([$do64bit])
1006
1007    # Step 0.b: Enable Solaris 64 bit VIS support?
1008
1009    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
1010    AC_ARG_ENABLE(64bit-vis,[  --enable-64bit-vis      enable 64bit Sparc VIS support],
1011        [do64bitVIS=$enableval], [do64bitVIS=no])
1012    AC_MSG_RESULT([$do64bitVIS])
1013
1014    if test "$do64bitVIS" = "yes"; then
1015        # Force 64bit on with VIS
1016        do64bit=yes
1017    fi
1018
1019    # Step 1: set the variable "system" to hold the name and version number
1020    # for the system.
1021
1022    SC_CONFIG_SYSTEM
1023
1024    # Step 2: check for existence of -ldl library.  This is needed because
1025    # Linux can use either -ldl or -ldld for dynamic loading.
1026
1027    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
1028
1029    # Require ranlib early so we can override it in special cases below.
1030
1031    AC_REQUIRE([AC_PROG_RANLIB])
1032
1033    # Step 3: set configuration options based on system name and version.
1034
1035    do64bit_ok=no
1036    LDFLAGS_ORIG="$LDFLAGS"
1037    TCL_EXPORT_FILE_SUFFIX=""
1038    UNSHARED_LIB_SUFFIX=""
1039    TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
1040    ECHO_VERSION='`echo ${VERSION}`'
1041    TCL_LIB_VERSIONS_OK=ok
1042    CFLAGS_DEBUG=-g
1043    CFLAGS_OPTIMIZE=-O
1044    if test "$GCC" = "yes" ; then
1045        CFLAGS_WARNING="-Wall -Wno-implicit-int -fno-strict-aliasing"
1046    else
1047        CFLAGS_WARNING=""
1048    fi
1049    TCL_NEEDS_EXP_FILE=0
1050    TCL_BUILD_EXP_FILE=""
1051    TCL_EXP_FILE=""
1052dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
1053dnl AC_CHECK_TOOL(AR, ar)
1054    AC_CHECK_PROG(AR, ar, ar)
1055    if test "${AR}" = "" ; then
1056        AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
1057    fi
1058    STLIB_LD='${AR} cr'
1059    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
1060    PLAT_OBJS=""
1061    PLAT_SRCS=""
1062    case $system in
1063        AIX-*)
1064            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
1065                # AIX requires the _r compiler when gcc isn't being used
1066                case "${CC}" in
1067                    *_r)
1068                        # ok ...
1069                        ;;
1070                    *)
1071                        CC=${CC}_r
1072                        ;;
1073                esac
1074                AC_MSG_RESULT([Using $CC for compiling with threads])
1075            fi
1076            LIBS="$LIBS -lc"
1077            SHLIB_CFLAGS=""
1078            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1079            # symbols when dynamically loaded into tclsh.
1080            SHLIB_LD_LIBS='${LIBS}'
1081            SHLIB_SUFFIX=".so"
1082
1083            DL_OBJS="tclLoadDl.o"
1084            LD_LIBRARY_PATH_VAR="LIBPATH"
1085
1086            # Check to enable 64-bit flags for compiler/linker on AIX 4+
1087            if test "$do64bit" = "yes" -a "`uname -v`" -gt "3" ; then
1088                if test "$GCC" = "yes" ; then
1089                    AC_MSG_WARN([64bit mode not supported with GCC on $system])
1090                else
1091                    do64bit_ok=yes
1092                    CFLAGS="$CFLAGS -q64"
1093                    LDFLAGS="$LDFLAGS -q64"
1094                    RANLIB="${RANLIB} -X64"
1095                    AR="${AR} -X64"
1096                    SHLIB_LD_FLAGS="-b64"
1097                fi
1098            fi
1099
1100            if test "`uname -m`" = "ia64" ; then
1101                # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
1102                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1103                # AIX-5 has dl* in libc.so
1104                DL_LIBS=""
1105                if test "$GCC" = "yes" ; then
1106                    CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1107                else
1108                    CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
1109                fi
1110                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1111            else
1112                if test "$GCC" = "yes" ; then
1113                    SHLIB_LD="gcc -shared"
1114                else
1115                    SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
1116                fi
1117                SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix ${SHLIB_LD} ${SHLIB_LD_FLAGS}"
1118                DL_LIBS="-ldl"
1119                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1120                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1121                TCL_NEEDS_EXP_FILE=1
1122                TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
1123            fi
1124
1125            # AIX v<=4.1 has some different flags than 4.2+
1126            if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
1127                LIBOBJS="$LIBOBJS tclLoadAix.o"
1128                DL_LIBS="-lld"
1129            fi
1130
1131            # On AIX <=v4 systems, libbsd.a has to be linked in to support
1132            # non-blocking file IO.  This library has to be linked in after
1133            # the MATH_LIBS or it breaks the pow() function.  The way to
1134            # insure proper sequencing, is to add it to the tail of MATH_LIBS.
1135            # This library also supplies gettimeofday.
1136            #
1137            # AIX does not have a timezone field in struct tm. When the AIX
1138            # bsd library is used, the timezone global and the gettimeofday
1139            # methods are to be avoided for timezone deduction instead, we
1140            # deduce the timezone by comparing the localtime result on a
1141            # known GMT value.
1142
1143            AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
1144            if test $libbsd = yes; then
1145                MATH_LIBS="$MATH_LIBS -lbsd"
1146                AC_DEFINE(USE_DELTA_FOR_TZ)
1147            fi
1148            ;;
1149        BeOS*)
1150            SHLIB_CFLAGS="-fPIC"
1151            SHLIB_LD="${CC} -nostart"
1152            SHLIB_LD_LIBS='${LIBS}'
1153            SHLIB_SUFFIX=".so"
1154            DL_OBJS="tclLoadDl.o"
1155            DL_LIBS="-ldl"
1156
1157            #-----------------------------------------------------------
1158            # Check for inet_ntoa in -lbind, for BeOS (which also needs
1159            # -lsocket, even if the network functions are in -lnet which
1160            # is always linked to, for compatibility.
1161            #-----------------------------------------------------------
1162            AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"])
1163            ;;
1164        BSD/OS-2.1*|BSD/OS-3*)
1165            SHLIB_CFLAGS=""
1166            SHLIB_LD="shlicc -r"
1167            SHLIB_LD_LIBS='${LIBS}'
1168            SHLIB_SUFFIX=".so"
1169            DL_OBJS="tclLoadDl.o"
1170            DL_LIBS="-ldl"
1171            CC_SEARCH_FLAGS=""
1172            LD_SEARCH_FLAGS=""
1173            ;;
1174        BSD/OS-4.*)
1175            SHLIB_CFLAGS="-export-dynamic -fPIC"
1176            SHLIB_LD="cc -shared"
1177            SHLIB_LD_LIBS='${LIBS}'
1178            SHLIB_SUFFIX=".so"
1179            DL_OBJS="tclLoadDl.o"
1180            DL_LIBS="-ldl"
1181            LDFLAGS="$LDFLAGS -export-dynamic"
1182            CC_SEARCH_FLAGS=""
1183            LD_SEARCH_FLAGS=""
1184            ;;
1185        dgux*)
1186            SHLIB_CFLAGS="-K PIC"
1187            SHLIB_LD="cc -G"
1188            SHLIB_LD_LIBS=""
1189            SHLIB_SUFFIX=".so"
1190            DL_OBJS="tclLoadDl.o"
1191            DL_LIBS="-ldl"
1192            CC_SEARCH_FLAGS=""
1193            LD_SEARCH_FLAGS=""
1194            ;;
1195        HP-UX-*.11.*)
1196            # Use updated header definitions where possible
1197            AC_DEFINE(_XOPEN_SOURCE)          # Use the XOPEN network library
1198            AC_DEFINE(_XOPEN_SOURCE_EXTENDED) # Use the XOPEN network library
1199            LIBS="$LIBS -lxnet"               # Use the XOPEN network library
1200
1201            if test "`uname -m`" = "ia64" ; then
1202                SHLIB_SUFFIX=".so"
1203            else
1204                SHLIB_SUFFIX=".sl"
1205            fi
1206            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1207            if test "$tcl_ok" = yes; then
1208                SHLIB_CFLAGS="+z"
1209                SHLIB_LD="ld -b"
1210                SHLIB_LD_LIBS='${LIBS}'
1211                DL_OBJS="tclLoadShl.o"
1212                DL_LIBS="-ldld"
1213                LDFLAGS="$LDFLAGS -Wl,-E"
1214                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1215                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1216                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1217            fi
1218            if test "$GCC" = "yes" ; then
1219                SHLIB_LD="gcc -shared"
1220                SHLIB_LD_LIBS='${LIBS}'
1221                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1222            fi
1223
1224            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
1225            #CFLAGS="$CFLAGS +DAportable"
1226
1227            # Check to enable 64-bit flags for compiler/linker
1228            if test "$do64bit" = "yes" ; then
1229                if test "$GCC" = "yes" ; then
1230                    hpux_arch=`${CC} -dumpmachine`
1231                    case $hpux_arch in
1232                        hppa64*)
1233                            # 64-bit gcc in use.  Fix flags for GNU ld.
1234                            do64bit_ok=yes
1235                            SHLIB_LD="${CC} -shared"
1236                            SHLIB_LD_LIBS='${LIBS}'
1237                            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1238                            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1239                            ;;
1240                        *)
1241                            AC_MSG_WARN([64bit mode not supported with GCC on $system])
1242                            ;;
1243                    esac
1244                else
1245                    do64bit_ok=yes
1246                    CFLAGS="$CFLAGS +DD64"
1247                    LDFLAGS="$LDFLAGS +DD64"
1248                fi
1249            fi
1250            ;;
1251        HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
1252            SHLIB_SUFFIX=".sl"
1253            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1254            if test "$tcl_ok" = yes; then
1255                SHLIB_CFLAGS="+z"
1256                SHLIB_LD="ld -b"
1257                SHLIB_LD_LIBS=""
1258                DL_OBJS="tclLoadShl.o"
1259                DL_LIBS="-ldld"
1260                LDFLAGS="$LDFLAGS -Wl,-E"
1261                CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1262                LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1263                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1264            fi
1265            ;;
1266        IRIX-4.*)
1267            SHLIB_CFLAGS="-G 0"
1268            SHLIB_SUFFIX=".a"
1269            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1270            SHLIB_LD_LIBS='${LIBS}'
1271            DL_OBJS="tclLoadAout.o"
1272            DL_LIBS=""
1273            LDFLAGS="$LDFLAGS -Wl,-D,08000000"
1274            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1275            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1276            SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1277            ;;
1278        IRIX-5.*)
1279            SHLIB_CFLAGS=""
1280            SHLIB_LD="ld -shared -rdata_shared"
1281            SHLIB_LD_LIBS='${LIBS}'
1282            SHLIB_SUFFIX=".so"
1283            DL_OBJS="tclLoadDl.o"
1284            DL_LIBS=""
1285            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1286            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1287            ;;
1288        IRIX-6.*)
1289            SHLIB_CFLAGS=""
1290            SHLIB_LD="ld -n32 -shared -rdata_shared"
1291            SHLIB_LD_LIBS='${LIBS}'
1292            SHLIB_SUFFIX=".so"
1293            DL_OBJS="tclLoadDl.o"
1294            DL_LIBS=""
1295            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1296            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1297            if test "$GCC" = "yes" ; then
1298                CFLAGS="$CFLAGS -mabi=n32"
1299                LDFLAGS="$LDFLAGS -mabi=n32"
1300            else
1301                case $system in
1302                    IRIX-6.3)
1303                        # Use to build 6.2 compatible binaries on 6.3.
1304                        CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS"
1305                        ;;
1306                    *)
1307                        CFLAGS="$CFLAGS -n32"
1308                        ;;
1309                esac
1310                LDFLAGS="$LDFLAGS -n32"
1311            fi
1312            ;;
1313        IRIX64-6.*)
1314            SHLIB_CFLAGS=""
1315            SHLIB_LD="ld -n32 -shared -rdata_shared"
1316            SHLIB_LD_LIBS='${LIBS}'
1317            SHLIB_SUFFIX=".so"
1318            DL_OBJS="tclLoadDl.o"
1319            DL_LIBS=""
1320            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1321            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1322
1323            # Check to enable 64-bit flags for compiler/linker
1324
1325            if test "$do64bit" = "yes" ; then
1326                if test "$GCC" = "yes" ; then
1327                    AC_MSG_WARN([64bit mode not supported by gcc])
1328                else
1329                    do64bit_ok=yes
1330                    SHLIB_LD="ld -64 -shared -rdata_shared"
1331                    CFLAGS="$CFLAGS -64"
1332                    LDFLAGS="$LDFLAGS -64"
1333                fi
1334            fi
1335            ;;
1336        Linux*)
1337            SHLIB_CFLAGS="-fPIC"
1338            SHLIB_LD_LIBS='${LIBS}'
1339            SHLIB_SUFFIX=".so"
1340
1341            CFLAGS_OPTIMIZE=-O2
1342            # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
1343            # when you inline the string and math operations.  Turn this off to
1344            # get rid of the warnings.
1345            #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
1346
1347            if test "$have_dl" = yes; then
1348                SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
1349                DL_OBJS="tclLoadDl.o"
1350                DL_LIBS="-ldl"
1351                LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1352                CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1353                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1354            else
1355                AC_CHECK_HEADER(dld.h, [
1356                    SHLIB_LD="ld -shared"
1357                    DL_OBJS="tclLoadDld.o"
1358                    DL_LIBS="-ldld"
1359                    CC_SEARCH_FLAGS=""
1360                    LD_SEARCH_FLAGS=""])
1361            fi
1362            if test "`uname -m`" = "alpha" ; then
1363                CFLAGS="$CFLAGS -mieee"
1364            fi
1365            if test $do64bit = yes; then
1366                AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
1367                    hold_cflags=$CFLAGS
1368                    CFLAGS="$CFLAGS -m64"
1369                    AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no)
1370                    CFLAGS=$hold_cflags])
1371                if test $tcl_cv_cc_m64 = yes; then
1372                    CFLAGS="$CFLAGS -m64"
1373                    do64bit_ok=yes
1374                fi
1375            fi
1376
1377            # The combo of gcc + glibc has a bug related
1378            # to inlining of functions like strtod(). The
1379            # -fno-builtin flag should address this problem
1380            # but it does not work. The -fno-inline flag
1381            # is kind of overkill but it works.
1382            # Disable inlining only when one of the
1383            # files in compat/*.c is being linked in.
1384            if test x"${LIBOBJS}" != x ; then
1385                CFLAGS="$CFLAGS -fno-inline"
1386            fi
1387
1388            # XIM peeking works under XFree86.
1389            AC_DEFINE(PEEK_XCLOSEIM)
1390
1391            ;;
1392        GNU*)
1393            SHLIB_CFLAGS="-fPIC"
1394            SHLIB_LD_LIBS='${LIBS}'
1395            SHLIB_SUFFIX=".so"
1396
1397            if test "$have_dl" = yes; then
1398                SHLIB_LD="${CC} -shared"
1399                DL_OBJS=""
1400                DL_LIBS="-ldl"
1401                LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1402                CC_SEARCH_FLAGS=""
1403                LD_SEARCH_FLAGS=""
1404            else
1405                AC_CHECK_HEADER(dld.h, [
1406                    SHLIB_LD="ld -shared"
1407                    DL_OBJS=""
1408                    DL_LIBS="-ldld"
1409                    CC_SEARCH_FLAGS=""
1410                    LD_SEARCH_FLAGS=""])
1411            fi
1412            if test "`uname -m`" = "alpha" ; then
1413                CFLAGS="$CFLAGS -mieee"
1414            fi
1415            ;;
1416        Lynx*)
1417            SHLIB_CFLAGS="-fPIC"
1418            SHLIB_LD_LIBS='${LIBS}'
1419            SHLIB_SUFFIX=".so"
1420            CFLAGS_OPTIMIZE=-02
1421            SHLIB_LD="${CC} -shared "
1422            DL_OBJS="tclLoadDl.o"
1423            DL_LIBS="-mshared -ldl"
1424            LD_FLAGS="-Wl,--export-dynamic"
1425            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1426            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1427            ;;
1428        MP-RAS-02*)
1429            SHLIB_CFLAGS="-K PIC"
1430            SHLIB_LD="cc -G"
1431            SHLIB_LD_LIBS=""
1432            SHLIB_SUFFIX=".so"
1433            DL_OBJS="tclLoadDl.o"
1434            DL_LIBS="-ldl"
1435            CC_SEARCH_FLAGS=""
1436            LD_SEARCH_FLAGS=""
1437            ;;
1438        MP-RAS-*)
1439            SHLIB_CFLAGS="-K PIC"
1440            SHLIB_LD="cc -G"
1441            SHLIB_LD_LIBS=""
1442            SHLIB_SUFFIX=".so"
1443            DL_OBJS="tclLoadDl.o"
1444            DL_LIBS="-ldl"
1445            LDFLAGS="$LDFLAGS -Wl,-Bexport"
1446            CC_SEARCH_FLAGS=""
1447            LD_SEARCH_FLAGS=""
1448            ;;
1449        NetBSD-*|FreeBSD-[[1-2]].*)
1450            # Not available on all versions:  check for include file.
1451            AC_CHECK_HEADER(dlfcn.h, [
1452                # NetBSD/SPARC needs -fPIC, -fpic will not do.
1453                SHLIB_CFLAGS="-fPIC"
1454                SHLIB_LD="ld -Bshareable -x"
1455                SHLIB_LD_LIBS='${LIBS}'
1456                SHLIB_SUFFIX=".so"
1457                DL_OBJS="tclLoadDl.o"
1458                DL_LIBS=""
1459                CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1460                LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1461                AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
1462                    AC_EGREP_CPP(yes, [
1463#ifdef __ELF__
1464        yes
1465#endif
1466                    ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
1467                if test $tcl_cv_ld_elf = yes; then
1468                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
1469                else
1470                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1471                fi
1472            ], [
1473                SHLIB_CFLAGS=""
1474                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
1475                SHLIB_LD_LIBS='${LIBS}'
1476                SHLIB_SUFFIX=".a"
1477                DL_OBJS="tclLoadAout.o"
1478                DL_LIBS=""
1479                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1480                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1481                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1482            ])
1483
1484            # FreeBSD doesn't handle version numbers with dots.
1485
1486            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1487            TCL_LIB_VERSIONS_OK=nodots
1488            ;;
1489        OpenBSD-*)
1490            case `arch -s` in
1491            m88k|vax)
1492                SHLIB_CFLAGS=""
1493                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
1494                SHLIB_LD_LIBS='${LIBS}'
1495                SHLIB_SUFFIX=".a"
1496                DL_OBJS="tclLoadAout.o"
1497                DL_LIBS=""
1498                LDFLAGS=""
1499                CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1500                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1501                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1502                ;;
1503            *)
1504                # OpenBSD/SPARC[64] needs -fPIC, -fpic will not do.
1505                case `machine` in
1506                sparc|sparc64)
1507                    SHLIB_CFLAGS="-fPIC";;
1508                *)
1509                    SHLIB_CFLAGS="-fpic";;
1510                esac
1511                SHLIB_LD="${CC} -shared ${SHLIB_CFLAGS}"
1512                SHLIB_LD_LIBS='${LIBS}'
1513                SHLIB_SUFFIX=".so"
1514                DL_OBJS="tclLoadDl.o"
1515                DL_LIBS=""
1516                CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1517                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1518                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1519                AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
1520                    AC_EGREP_CPP(yes, [
1521#ifdef __ELF__
1522        yes
1523#endif
1524                    ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
1525                if test $tcl_cv_ld_elf = yes; then
1526                    LDFLAGS=-Wl,-export-dynamic
1527                else
1528                    LDFLAGS=""
1529                fi
1530                ;;
1531            esac
1532
1533            # OpenBSD doesn't do version numbers with dots.
1534            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1535            TCL_LIB_VERSIONS_OK=nodots
1536            ;;
1537        FreeBSD-*)
1538            # FreeBSD 3.* and greater have ELF.
1539            SHLIB_CFLAGS="-fPIC"
1540            SHLIB_LD="ld -Bshareable -x"
1541            SHLIB_LD_LIBS='${LIBS}'
1542            SHLIB_SUFFIX=".so"
1543            DL_OBJS="tclLoadDl.o"
1544            DL_LIBS=""
1545            LDFLAGS="$LDFLAGS -export-dynamic"
1546            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1547            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1548            if test "${TCL_THREADS}" = "1" ; then
1549                # The -pthread needs to go in the CFLAGS, not LIBS
1550                LIBS=`echo $LIBS | sed s/-pthread//`
1551                CFLAGS="$CFLAGS -pthread"
1552                LDFLAGS="$LDFLAGS -pthread"
1553            fi
1554            case $system in
1555            FreeBSD-3.*)
1556                # FreeBSD-3 doesn't handle version numbers with dots.
1557                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1558                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
1559                TCL_LIB_VERSIONS_OK=nodots
1560                ;;
1561            esac
1562            ;;
1563        Darwin-*)
1564            CFLAGS_OPTIMIZE="-Os"
1565            SHLIB_CFLAGS="-fno-common"
1566            # To avoid discrepancies between what headers configure sees during
1567            # preprocessing tests and compiling tests, move any -isysroot and
1568            # -mmacosx-version-min flags from CFLAGS to CPPFLAGS:
1569            CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \
1570                awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
1571                if ([$]i~/^(isysroot|mmacosx-version-min)/) print "-"[$]i}'`"
1572            CFLAGS="`echo " ${CFLAGS}" | \
1573                awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
1574                if (!([$]i~/^(isysroot|mmacosx-version-min)/)) print "-"[$]i}'`"
1575            if test $do64bit = yes; then
1576                case `arch` in
1577                    ppc)
1578                        AC_CACHE_CHECK([if compiler accepts -arch ppc64 flag],
1579                                tcl_cv_cc_arch_ppc64, [
1580                            hold_cflags=$CFLAGS
1581                            CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1582                            AC_TRY_LINK(,, tcl_cv_cc_arch_ppc64=yes,
1583                                    tcl_cv_cc_arch_ppc64=no)
1584                            CFLAGS=$hold_cflags])
1585                        if test $tcl_cv_cc_arch_ppc64 = yes; then
1586                            CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1587                            do64bit_ok=yes
1588                        fi;;
1589                    i386)
1590                        AC_CACHE_CHECK([if compiler accepts -arch x86_64 flag],
1591                                tcl_cv_cc_arch_x86_64, [
1592                            hold_cflags=$CFLAGS
1593                            CFLAGS="$CFLAGS -arch x86_64"
1594                            AC_TRY_LINK(,, tcl_cv_cc_arch_x86_64=yes,
1595                                    tcl_cv_cc_arch_x86_64=no)
1596                            CFLAGS=$hold_cflags])
1597                        if test $tcl_cv_cc_arch_x86_64 = yes; then
1598                            CFLAGS="$CFLAGS -arch x86_64"
1599                            do64bit_ok=yes
1600                        fi;;
1601                    *)
1602                        AC_MSG_WARN([Don't know how enable 64-bit on architecture `arch`]);;
1603                esac
1604            else
1605                # Check for combined 32-bit and 64-bit fat build
1606                echo "$CFLAGS " | grep -E -q -- '-arch (ppc64|x86_64) ' && \
1607                    echo "$CFLAGS " | grep -E -q -- '-arch (ppc|i386) ' && \
1608                    fat_32_64=yes
1609            fi
1610            SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS}'
1611            AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
1612                hold_ldflags=$LDFLAGS
1613                LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
1614                AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
1615                LDFLAGS=$hold_ldflags])
1616            if test $tcl_cv_ld_single_module = yes; then
1617                SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
1618            fi
1619            SHLIB_LD_LIBS='${LIBS}'
1620            SHLIB_SUFFIX=".dylib"
1621            DL_OBJS="tclLoadDyld.o"
1622            DL_LIBS=""
1623            # Don't use -prebind when building for Mac OS X 10.4 or later only:
1624            test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int([$]2)}'`" -lt 4 -a \
1625                "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int([$]2)}'`" -lt 4 && \
1626                LDFLAGS="$LDFLAGS -prebind"
1627            LDFLAGS="$LDFLAGS -headerpad_max_install_names"
1628            AC_CACHE_CHECK([if ld accepts -search_paths_first flag], tcl_cv_ld_search_paths_first, [
1629                hold_ldflags=$LDFLAGS
1630                LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1631                AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, tcl_cv_ld_search_paths_first=no)
1632                LDFLAGS=$hold_ldflags])
1633            if test $tcl_cv_ld_search_paths_first = yes; then
1634                LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1635            fi
1636            CC_SEARCH_FLAGS=""
1637            LD_SEARCH_FLAGS=""
1638            LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
1639            PLAT_OBJS=\$\(MAC\_OSX_OBJS\)
1640            PLAT_SRCS=\$\(MAC\_OSX_SRCS\)
1641            AC_MSG_CHECKING([whether to use CoreFoundation])
1642            AC_ARG_ENABLE(corefoundation, [  --enable-corefoundation use CoreFoundation API [--enable-corefoundation]],
1643                [tcl_corefoundation=$enableval], [tcl_corefoundation=yes])
1644            AC_MSG_RESULT([$tcl_corefoundation])
1645            if test $tcl_corefoundation = yes; then
1646                AC_CACHE_CHECK([for CoreFoundation.framework], tcl_cv_lib_corefoundation, [
1647                    hold_libs=$LIBS
1648                    if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do
1649                        # On Tiger there is no 64-bit CF, so remove 64-bit archs
1650                        # from CFLAGS et al. while testing for presence of CF.
1651                        # 64-bit CF is disabled in tclUnixPort.h if necessary.
1652                        eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
1653                    done; fi
1654                    LIBS="$LIBS -framework CoreFoundation"
1655                    AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
1656                        [CFBundleRef b = CFBundleGetMainBundle();],
1657                        tcl_cv_lib_corefoundation=yes, tcl_cv_lib_corefoundation=no)
1658                    if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do
1659                        eval $v'="$hold_'$v'"'
1660                    done; fi; LIBS=$hold_libs])
1661                if test $tcl_cv_lib_corefoundation = yes; then
1662                    LIBS="$LIBS -framework CoreFoundation"
1663                    AC_DEFINE(HAVE_COREFOUNDATION)
1664                else
1665                    tcl_corefoundation=no
1666                fi
1667                if test "$fat_32_64" = yes -a $tcl_corefoundation = yes; then
1668                    AC_CACHE_CHECK([for 64-bit CoreFoundation], tcl_cv_lib_corefoundation_64, [
1669                        for v in CFLAGS CPPFLAGS LDFLAGS; do
1670                            eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
1671                        done
1672                        AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
1673                            [CFBundleRef b = CFBundleGetMainBundle();],
1674                            tcl_cv_lib_corefoundation_64=yes, tcl_cv_lib_corefoundation_64=no)
1675                        for v in CFLAGS CPPFLAGS LDFLAGS; do
1676                            eval $v'="$hold_'$v'"'
1677                        done])
1678                    if test $tcl_cv_lib_corefoundation_64 = no; then
1679                        AC_DEFINE(NO_COREFOUNDATION_64)
1680                    fi
1681                fi
1682            fi
1683            AC_DEFINE(MAC_OSX_TCL)
1684            ;;
1685        NEXTSTEP-*)
1686            SHLIB_CFLAGS=""
1687            SHLIB_LD="cc -nostdlib -r"
1688            SHLIB_LD_LIBS=""
1689            SHLIB_SUFFIX=".so"
1690            DL_OBJS="tclLoadNext.o"
1691            DL_LIBS=""
1692            CC_SEARCH_FLAGS=""
1693            LD_SEARCH_FLAGS=""
1694            ;;
1695        OS/390-*)
1696            CFLAGS_OPTIMIZE=""          # Optimizer is buggy
1697            AC_DEFINE(_OE_SOCKETS)      # needed in sys/socket.h
1698            ;;     
1699        OSF1-1.0|OSF1-1.1|OSF1-1.2)
1700            # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
1701            SHLIB_CFLAGS=""
1702            # Hack: make package name same as library name
1703            SHLIB_LD='ld -R -export $@:'
1704            SHLIB_LD_LIBS=""
1705            SHLIB_SUFFIX=".so"
1706            DL_OBJS="tclLoadOSF.o"
1707            DL_LIBS=""
1708            CC_SEARCH_FLAGS=""
1709            LD_SEARCH_FLAGS=""
1710            ;;
1711        OSF1-1.*)
1712            # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
1713            SHLIB_CFLAGS="-fPIC"
1714            if test "$SHARED_BUILD" = "1" ; then
1715                SHLIB_LD="ld -shared"
1716            else
1717                SHLIB_LD="ld -non_shared"
1718            fi
1719            SHLIB_LD_LIBS=""
1720            SHLIB_SUFFIX=".so"
1721            DL_OBJS="tclLoadDl.o"
1722            DL_LIBS=""
1723            CC_SEARCH_FLAGS=""
1724            LD_SEARCH_FLAGS=""
1725            ;;
1726        OSF1-V*)
1727            # Digital OSF/1
1728            SHLIB_CFLAGS=""
1729            if test "$SHARED_BUILD" = "1" ; then
1730                SHLIB_LD='ld -shared -expect_unresolved "*"'
1731            else
1732                SHLIB_LD='ld -non_shared -expect_unresolved "*"'
1733            fi
1734            SHLIB_LD_LIBS=""
1735            SHLIB_SUFFIX=".so"
1736            DL_OBJS="tclLoadDl.o"
1737            DL_LIBS=""
1738            CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1739            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1740            if test "$GCC" = "yes" ; then
1741                CFLAGS="$CFLAGS -mieee"
1742            else
1743                CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"
1744            fi
1745            # see pthread_intro(3) for pthread support on osf1, k.furukawa
1746            if test "${TCL_THREADS}" = "1" ; then
1747                CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
1748                CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
1749                LIBS=`echo $LIBS | sed s/-lpthreads//`
1750                if test "$GCC" = "yes" ; then
1751                    LIBS="$LIBS -lpthread -lmach -lexc"
1752                else
1753                    CFLAGS="$CFLAGS -pthread"
1754                    LDFLAGS="$LDFLAGS -pthread"
1755                fi
1756            fi
1757
1758            ;;
1759        QNX-6*)
1760            # QNX RTP
1761            # This may work for all QNX, but it was only reported for v6.
1762            SHLIB_CFLAGS="-fPIC"
1763            SHLIB_LD="ld -Bshareable -x"
1764            SHLIB_LD_LIBS=""
1765            SHLIB_SUFFIX=".so"
1766            DL_OBJS="tclLoadDl.o"
1767            # dlopen is in -lc on QNX
1768            DL_LIBS=""
1769            CC_SEARCH_FLAGS=""
1770            LD_SEARCH_FLAGS=""
1771            ;;
1772        RISCos-*)
1773            SHLIB_CFLAGS="-G 0"
1774            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1775            SHLIB_LD_LIBS='${LIBS}'
1776            SHLIB_SUFFIX=".a"
1777            DL_OBJS="tclLoadAout.o"
1778            DL_LIBS=""
1779            LDFLAGS="$LDFLAGS -Wl,-D,08000000"
1780            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1781            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1782            ;;
1783        SCO_SV-3.2*)
1784            # Note, dlopen is available only on SCO 3.2.5 and greater. However,
1785            # this test works, since "uname -s" was non-standard in 3.2.4 and
1786            # below.
1787            if test "$GCC" = "yes" ; then
1788                SHLIB_CFLAGS="-fPIC -melf"
1789                LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
1790            else
1791                SHLIB_CFLAGS="-Kpic -belf"
1792                LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
1793            fi
1794            SHLIB_LD="ld -G"
1795            SHLIB_LD_LIBS=""
1796            SHLIB_SUFFIX=".so"
1797            DL_OBJS="tclLoadDl.o"
1798            DL_LIBS=""
1799            CC_SEARCH_FLAGS=""
1800            LD_SEARCH_FLAGS=""
1801            ;;
1802        SINIX*5.4*)
1803            SHLIB_CFLAGS="-K PIC"
1804            SHLIB_LD="cc -G"
1805            SHLIB_LD_LIBS=""
1806            SHLIB_SUFFIX=".so"
1807            DL_OBJS="tclLoadDl.o"
1808            DL_LIBS="-ldl"
1809            CC_SEARCH_FLAGS=""
1810            LD_SEARCH_FLAGS=""
1811            ;;
1812        SunOS-4*)
1813            SHLIB_CFLAGS="-PIC"
1814            SHLIB_LD="ld"
1815            SHLIB_LD_LIBS=""
1816            SHLIB_SUFFIX=".so"
1817            DL_OBJS="tclLoadDl.o"
1818            DL_LIBS="-ldl"
1819            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1820            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1821
1822            # SunOS can't handle version numbers with dots in them in library
1823            # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
1824            # requires an extra version number at the end of .so file names.
1825            # So, the library has to have a name like libtcl75.so.1.0
1826
1827            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1828            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1829            TCL_LIB_VERSIONS_OK=nodots
1830            ;;
1831        SunOS-5.[[0-6]])
1832            # Careful to not let 5.10+ fall into this case
1833
1834            # Note: If _REENTRANT isn't defined, then Solaris
1835            # won't define thread-safe library routines.
1836
1837            AC_DEFINE(_REENTRANT)
1838            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1839
1840            SHLIB_CFLAGS="-KPIC"
1841
1842            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1843            # symbols when dynamically loaded into tclsh.
1844
1845            SHLIB_LD_LIBS='${LIBS}'
1846            SHLIB_SUFFIX=".so"
1847            DL_OBJS="tclLoadDl.o"
1848            DL_LIBS="-ldl"
1849            if test "$GCC" = "yes" ; then
1850                SHLIB_LD="$CC -shared"
1851                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1852                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1853            else
1854                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1855                CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1856                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1857            fi
1858            ;;
1859        SunOS-5*)
1860            # Note: If _REENTRANT isn't defined, then Solaris
1861            # won't define thread-safe library routines.
1862
1863            AC_DEFINE(_REENTRANT)
1864            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1865
1866            SHLIB_CFLAGS="-KPIC"
1867
1868            # Check to enable 64-bit flags for compiler/linker
1869            if test "$do64bit" = "yes" ; then
1870                arch=`isainfo`
1871                if test "$arch" = "sparcv9 sparc" ; then
1872                        if test "$GCC" = "yes" ; then
1873                            if test "`gcc -dumpversion | awk -F. '{print [$]1}'`" -lt "3" ; then
1874                                AC_MSG_WARN([64bit mode not supported with GCC < 3.2 on $system])
1875                            else
1876                                do64bit_ok=yes
1877                                CFLAGS="$CFLAGS -m64 -mcpu=v9"
1878                                LDFLAGS="$LDFLAGS -m64 -mcpu=v9"
1879                                SHLIB_CFLAGS="-fPIC"
1880                            fi
1881                        else
1882                            do64bit_ok=yes
1883                            if test "$do64bitVIS" = "yes" ; then
1884                                CFLAGS="$CFLAGS -xarch=v9a"
1885                                LDFLAGS="$LDFLAGS -xarch=v9a"
1886                            else
1887                                CFLAGS="$CFLAGS -xarch=v9"
1888                                LDFLAGS="$LDFLAGS -xarch=v9"
1889                            fi
1890                            # Solaris 64 uses this as well
1891                            #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
1892                        fi
1893                elif test "$arch" = "amd64 i386" ; then
1894                    if test "$GCC" = "yes" ; then
1895                        AC_MSG_WARN([64bit mode not supported with GCC on $system])
1896                    else
1897                        do64bit_ok=yes
1898                        CFLAGS="$CFLAGS -xarch=amd64"
1899                        LDFLAGS="$LDFLAGS -xarch=amd64"
1900                    fi
1901                else
1902                    AC_MSG_WARN([64bit mode not supported for $arch])
1903                fi
1904            fi
1905           
1906            # Note: need the LIBS below, otherwise Tk won't find Tcl's
1907            # symbols when dynamically loaded into tclsh.
1908
1909            SHLIB_LD_LIBS='${LIBS}'
1910            SHLIB_SUFFIX=".so"
1911            DL_OBJS="tclLoadDl.o"
1912            DL_LIBS="-ldl"
1913            if test "$GCC" = "yes" ; then
1914                SHLIB_LD="$CC -shared"
1915                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1916                LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1917                if test "$do64bit_ok" = "yes" ; then
1918                    # We need to specify -static-libgcc or we need to
1919                    # add the path to the sparv9 libgcc.
1920                    SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
1921                    # for finding sparcv9 libgcc, get the regular libgcc
1922                    # path, remove so name and append 'sparcv9'
1923                    #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..."
1924                    #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir"
1925                fi
1926            else
1927                case $system in
1928                    SunOS-5.[[1-9]][[0-9]]*)
1929                        SHLIB_LD='${CC} -G -z text ${LDFLAGS}';;
1930                    *)
1931                        SHLIB_LD="/usr/ccs/bin/ld -G -z text";;
1932                esac
1933                CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1934                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1935            fi
1936            ;;
1937        ULTRIX-4.*)
1938            SHLIB_CFLAGS="-G 0"
1939            SHLIB_SUFFIX=".a"
1940            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1941            SHLIB_LD_LIBS='${LIBS}'
1942            DL_OBJS="tclLoadAout.o"
1943            DL_LIBS=""
1944            LDFLAGS="$LDFLAGS -Wl,-D,08000000"
1945            CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1946            LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1947            if test "$GCC" != "yes" ; then
1948                CFLAGS="$CFLAGS -DHAVE_TZSET -std1"
1949            fi
1950            ;;
1951        UNIX_SV* | UnixWare-5*)
1952            SHLIB_CFLAGS="-KPIC"
1953            SHLIB_LD="cc -G"
1954            SHLIB_LD_LIBS=""
1955            SHLIB_SUFFIX=".so"
1956            DL_OBJS="tclLoadDl.o"
1957            DL_LIBS="-ldl"
1958            # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
1959            # that don't grok the -Bexport option.  Test that it does.
1960            AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [
1961                hold_ldflags=$LDFLAGS
1962                LDFLAGS="$LDFLAGS -Wl,-Bexport"
1963                AC_TRY_LINK(, [int i;], tcl_cv_ld_Bexport=yes, tcl_cv_ld_Bexport=no)
1964                LDFLAGS=$hold_ldflags])
1965            if test $tcl_cv_ld_Bexport = yes; then
1966                LDFLAGS="$LDFLAGS -Wl,-Bexport"
1967            fi
1968            CC_SEARCH_FLAGS=""
1969            LD_SEARCH_FLAGS=""
1970            ;;
1971    esac
1972
1973    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
1974        AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform])
1975    fi
1976
1977dnl # Add any CPPFLAGS set in the environment to our CFLAGS, but delay doing so
1978dnl # until the end of configure, as configure's compile and link tests use
1979dnl # both CPPFLAGS and CFLAGS (unlike our compile and link) but configure's
1980dnl # preprocessing tests use only CPPFLAGS.
1981    SC_CONFIG_COMMANDS_PRE([CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""])
1982
1983    # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
1984    # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
1985    # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
1986    # to determine which of several header files defines the a.out file
1987    # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
1988    # support only a file format that is more or less version-7-compatible.
1989    # In particular,
1990    #   - a.out files must begin with `struct exec'.
1991    #   - the N_TXTOFF on the `struct exec' must compute the seek address
1992    #     of the text segment
1993    #   - The `struct exec' must contain a_magic, a_text, a_data, a_bss
1994    #     and a_entry fields.
1995    # The following compilation should succeed if and only if either sys/exec.h
1996    # or a.out.h is usable for the purpose.
1997    #
1998    # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
1999    # `struct exec' includes a second header that contains information that
2000    # duplicates the v7 fields that are needed.
2001
2002    if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
2003        AC_CACHE_CHECK([sys/exec.h], tcl_cv_sysexec_h, [
2004        AC_TRY_COMPILE([#include <sys/exec.h>],[
2005            struct exec foo;
2006            unsigned long seek;
2007            int flag;
2008#if defined(__mips) || defined(mips)
2009            seek = N_TXTOFF (foo.ex_f, foo.ex_o);
2010#else
2011            seek = N_TXTOFF (foo);
2012#endif
2013            flag = (foo.a_magic == OMAGIC);
2014            return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
2015    ], tcl_cv_sysexec_h=usable, tcl_cv_sysexec_h=unusable)])
2016        if test $tcl_cv_sysexec_h = usable; then
2017            AC_DEFINE(USE_SYS_EXEC_H)
2018        else
2019            AC_CACHE_CHECK([a.out.h], tcl_cv_aout_h, [
2020            AC_TRY_COMPILE([#include <a.out.h>],[
2021                struct exec foo;
2022                unsigned long seek;
2023                int flag;
2024#if defined(__mips) || defined(mips)
2025                seek = N_TXTOFF (foo.ex_f, foo.ex_o);
2026#else
2027                seek = N_TXTOFF (foo);
2028#endif
2029                flag = (foo.a_magic == OMAGIC);
2030                return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
2031            ], tcl_cv_aout_h=usable, tcl_cv_aout_h=unusable)])
2032            if test $tcl_cv_aout_h = usable; then
2033                AC_DEFINE(USE_A_OUT_H)
2034            else
2035                AC_CACHE_CHECK([sys/exec_aout.h], tcl_cv_sysexecaout_h, [
2036                AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
2037                    struct exec foo;
2038                    unsigned long seek;
2039                    int flag;
2040#if defined(__mips) || defined(mips)
2041                    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
2042#else
2043                    seek = N_TXTOFF (foo);
2044#endif
2045                    flag = (foo.a_midmag == OMAGIC);
2046                    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
2047                ], tcl_cv_sysexecaout_h=usable, tcl_cv_sysexecaout_h=unusable)])
2048                if test $tcl_cv_sysexecaout_h = usable; then
2049                    AC_DEFINE(USE_SYS_EXEC_AOUT_H)
2050                else
2051                    DL_OBJS=""
2052                fi
2053            fi
2054        fi
2055    fi
2056
2057    # Step 5: disable dynamic loading if requested via a command-line switch.
2058
2059    AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
2060        [tcl_ok=$enableval], [tcl_ok=yes])
2061    if test "$tcl_ok" = "no"; then
2062        DL_OBJS=""
2063    fi
2064
2065    if test "x$DL_OBJS" != "x" ; then
2066        BUILD_DLTEST="\$(DLTEST_TARGETS)"
2067    else
2068        echo "Can't figure out how to do dynamic loading or shared libraries"
2069        echo "on this system."
2070        SHLIB_CFLAGS=""
2071        SHLIB_LD=""
2072        SHLIB_SUFFIX=""
2073        DL_OBJS="tclLoadNone.o"
2074        DL_LIBS=""
2075        LDFLAGS="$LDFLAGS_ORIG"
2076        CC_SEARCH_FLAGS=""
2077        LD_SEARCH_FLAGS=""
2078        BUILD_DLTEST=""
2079    fi
2080
2081    # If we're running gcc, then change the C flags for compiling shared
2082    # libraries to the right flags for gcc, instead of those for the
2083    # standard manufacturer compiler.
2084
2085    if test "$DL_OBJS" != "tclLoadNone.o" ; then
2086        if test "$GCC" = "yes" ; then
2087            case $system in
2088                AIX-*)
2089                    ;;
2090                BSD/OS*)
2091                    ;;
2092                IRIX*)
2093                    ;;
2094                NetBSD-*|FreeBSD-*|OpenBSD-*)
2095                    ;;
2096                Darwin-*)
2097                    ;;
2098                RISCos-*)
2099                    ;;
2100                SCO_SV-3.2*)
2101                    ;;
2102                ULTRIX-4.*)
2103                    ;;
2104                *)
2105                    SHLIB_CFLAGS="-fPIC"
2106                    ;;
2107            esac
2108        fi
2109    fi
2110
2111    if test "$SHARED_LIB_SUFFIX" = "" ; then
2112        SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
2113    fi
2114    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
2115        UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
2116    fi
2117
2118    if test "${SHARED_BUILD}" = "1" && test "${SHLIB_SUFFIX}" != "" ; then
2119        LIB_SUFFIX=${SHARED_LIB_SUFFIX}
2120        MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
2121        INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
2122    else
2123        LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}
2124
2125        if test "$RANLIB" = "" ; then
2126            MAKE_LIB='$(STLIB_LD) [$]@ ${OBJS}'
2127            INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
2128        else
2129            MAKE_LIB='${STLIB_LD} [$]@ ${OBJS} ; ${RANLIB} [$]@'
2130            INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(LIB_FILE))'
2131        fi
2132
2133dnl        Not at all clear what this was doing in Tcl's configure.in
2134dnl        or why it was needed was needed. In any event, this sort of
2135dnl        things needs to be done in the big loop above.
2136dnl        REMOVE THIS BLOCK LATER! (mdejong)
2137dnl        case $system in
2138dnl            BSD/OS*)
2139dnl                ;;
2140dnl            AIX-[[1-4]].*)
2141dnl                ;;
2142dnl            *)
2143dnl                SHLIB_LD_LIBS=""
2144dnl                ;;
2145dnl        esac
2146    fi
2147
2148
2149    # Stub lib does not depend on shared/static configuration
2150    if test "$RANLIB" = "" ; then
2151        MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS}'
2152        INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE)'
2153    else
2154        MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS} ; ${RANLIB} [$]@'
2155        INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(STUB_LIB_FILE))'
2156    fi
2157
2158
2159    AC_SUBST(DL_LIBS)
2160
2161    AC_SUBST(DL_OBJS)
2162    AC_SUBST(PLAT_OBJS)
2163    AC_SUBST(PLAT_SRCS)
2164    AC_SUBST(CFLAGS)
2165    AC_SUBST(CFLAGS_DEBUG)
2166    AC_SUBST(CFLAGS_OPTIMIZE)
2167    AC_SUBST(CFLAGS_WARNING)
2168
2169    AC_SUBST(LDFLAGS)
2170    AC_SUBST(LDFLAGS_DEBUG)
2171    AC_SUBST(LDFLAGS_OPTIMIZE)
2172    AC_SUBST(CC_SEARCH_FLAGS)
2173    AC_SUBST(LD_SEARCH_FLAGS)
2174
2175    AC_SUBST(STLIB_LD)
2176    AC_SUBST(SHLIB_LD)
2177    AC_SUBST(TCL_SHLIB_LD_EXTRAS)
2178    AC_SUBST(TK_SHLIB_LD_EXTRAS)
2179    AC_SUBST(SHLIB_LD_LIBS)
2180    AC_SUBST(SHLIB_CFLAGS)
2181    AC_SUBST(SHLIB_SUFFIX)
2182
2183    AC_SUBST(MAKE_LIB)
2184    AC_SUBST(MAKE_STUB_LIB)
2185    AC_SUBST(INSTALL_LIB)
2186    AC_SUBST(INSTALL_STUB_LIB)
2187    AC_SUBST(RANLIB)
2188])
2189
2190#--------------------------------------------------------------------
2191# SC_SERIAL_PORT
2192#
2193#       Determine which interface to use to talk to the serial port.
2194#       Note that #include lines must begin in leftmost column for
2195#       some compilers to recognize them as preprocessor directives,
2196#       and some build environments have stdin not pointing at a
2197#       pseudo-terminal (usually /dev/null instead.)
2198#
2199# Arguments:
2200#       none
2201#       
2202# Results:
2203#
2204#       Defines only one of the following vars:
2205#               HAVE_SYS_MODEM_H
2206#               USE_TERMIOS
2207#               USE_TERMIO
2208#               USE_SGTTY
2209#
2210#--------------------------------------------------------------------
2211
2212AC_DEFUN([SC_SERIAL_PORT], [
2213    AC_CHECK_HEADERS(sys/modem.h)
2214    AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
2215    AC_TRY_RUN([
2216#include <termios.h>
2217
2218int main() {
2219    struct termios t;
2220    if (tcgetattr(0, &t) == 0) {
2221        cfsetospeed(&t, 0);
2222        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2223        return 0;
2224    }
2225    return 1;
2226}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2227    if test $tcl_cv_api_serial = no ; then
2228        AC_TRY_RUN([
2229#include <termio.h>
2230
2231int main() {
2232    struct termio t;
2233    if (ioctl(0, TCGETA, &t) == 0) {
2234        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2235        return 0;
2236    }
2237    return 1;
2238}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2239    fi
2240    if test $tcl_cv_api_serial = no ; then
2241        AC_TRY_RUN([
2242#include <sgtty.h>
2243
2244int main() {
2245    struct sgttyb t;
2246    if (ioctl(0, TIOCGETP, &t) == 0) {
2247        t.sg_ospeed = 0;
2248        t.sg_flags |= ODDP | EVENP | RAW;
2249        return 0;
2250    }
2251    return 1;
2252}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2253    fi
2254    if test $tcl_cv_api_serial = no ; then
2255        AC_TRY_RUN([
2256#include <termios.h>
2257#include <errno.h>
2258
2259int main() {
2260    struct termios t;
2261    if (tcgetattr(0, &t) == 0
2262        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2263        cfsetospeed(&t, 0);
2264        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2265        return 0;
2266    }
2267    return 1;
2268}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2269    fi
2270    if test $tcl_cv_api_serial = no; then
2271        AC_TRY_RUN([
2272#include <termio.h>
2273#include <errno.h>
2274
2275int main() {
2276    struct termio t;
2277    if (ioctl(0, TCGETA, &t) == 0
2278        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2279        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2280        return 0;
2281    }
2282    return 1;
2283    }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2284    fi
2285    if test $tcl_cv_api_serial = no; then
2286        AC_TRY_RUN([
2287#include <sgtty.h>
2288#include <errno.h>
2289
2290int main() {
2291    struct sgttyb t;
2292    if (ioctl(0, TIOCGETP, &t) == 0
2293        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2294        t.sg_ospeed = 0;
2295        t.sg_flags |= ODDP | EVENP | RAW;
2296        return 0;
2297    }
2298    return 1;
2299}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
2300    fi])
2301    case $tcl_cv_api_serial in
2302        termios) AC_DEFINE(USE_TERMIOS);;
2303        termio)  AC_DEFINE(USE_TERMIO);;
2304        sgtty)   AC_DEFINE(USE_SGTTY);;
2305    esac
2306])
2307
2308#--------------------------------------------------------------------
2309# SC_MISSING_POSIX_HEADERS
2310#
2311#       Supply substitutes for missing POSIX header files.  Special
2312#       notes:
2313#           - stdlib.h doesn't define strtol, strtoul, or
2314#             strtod insome versions of SunOS
2315#           - some versions of string.h don't declare procedures such
2316#             as strstr
2317#
2318# Arguments:
2319#       none
2320#       
2321# Results:
2322#
2323#       Defines some of the following vars:
2324#               NO_DIRENT_H
2325#               NO_ERRNO_H
2326#               NO_VALUES_H
2327#               HAVE_LIMITS_H or NO_LIMITS_H
2328#               NO_STDLIB_H
2329#               NO_STRING_H
2330#               NO_SYS_WAIT_H
2331#               NO_DLFCN_H
2332#               HAVE_UNISTD_H
2333#               HAVE_SYS_PARAM_H
2334#
2335#               HAVE_STRING_H ?
2336#
2337#--------------------------------------------------------------------
2338
2339AC_DEFUN([SC_MISSING_POSIX_HEADERS], [
2340    AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [
2341    AC_TRY_LINK([#include <sys/types.h>
2342#include <dirent.h>], [
2343#ifndef _POSIX_SOURCE
2344#   ifdef __Lynx__
2345        /*
2346         * Generate compilation error to make the test fail:  Lynx headers
2347         * are only valid if really in the POSIX environment.
2348         */
2349
2350        missing_procedure();
2351#   endif
2352#endif
2353DIR *d;
2354struct dirent *entryPtr;
2355char *p;
2356d = opendir("foobar");
2357entryPtr = readdir(d);
2358p = entryPtr->d_name;
2359closedir(d);
2360], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no)])
2361
2362    if test $tcl_cv_dirent_h = no; then
2363        AC_DEFINE(NO_DIRENT_H)
2364    fi
2365
2366    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H)])
2367    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H)])
2368    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H)])
2369    AC_CHECK_HEADER(limits.h,
2370        [AC_DEFINE(HAVE_LIMITS_H)], [AC_DEFINE(NO_LIMITS_H)])
2371    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
2372    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
2373    AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
2374    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
2375    if test $tcl_ok = 0; then
2376        AC_DEFINE(NO_STDLIB_H)
2377    fi
2378    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
2379    AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
2380    AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
2381
2382    # See also memmove check below for a place where NO_STRING_H can be
2383    # set and why.
2384
2385    if test $tcl_ok = 0; then
2386        AC_DEFINE(NO_STRING_H)
2387    fi
2388
2389    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H)])
2390    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H)])
2391
2392    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
2393    AC_HAVE_HEADERS(unistd.h sys/param.h)
2394])
2395
2396#--------------------------------------------------------------------
2397# SC_PATH_X
2398#
2399#       Locate the X11 header files and the X11 library archive.  Try
2400#       the ac_path_x macro first, but if it doesn't find the X stuff
2401#       (e.g. because there's no xmkmf program) then check through
2402#       a list of possible directories.  Under some conditions the
2403#       autoconf macro will return an include directory that contains
2404#       no include files, so double-check its result just to be safe.
2405#
2406# Arguments:
2407#       none
2408#       
2409# Results:
2410#
2411#       Sets the the following vars:
2412#               XINCLUDES
2413#               XLIBSW
2414#
2415#--------------------------------------------------------------------
2416
2417AC_DEFUN([SC_PATH_X], [
2418    AC_PATH_X
2419    not_really_there=""
2420    if test "$no_x" = ""; then
2421        if test "$x_includes" = ""; then
2422            AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
2423        else
2424            if test ! -r $x_includes/X11/Intrinsic.h; then
2425                not_really_there="yes"
2426            fi
2427        fi
2428    fi
2429    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
2430        AC_MSG_CHECKING([for X11 header files])
2431        found_xincludes="no"
2432        AC_TRY_CPP([#include <X11/Intrinsic.h>], found_xincludes="yes", found_xincludes="no")
2433        if test "$found_xincludes" = "no"; then
2434            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"
2435            for i in $dirs ; do
2436                if test -r $i/X11/Intrinsic.h; then
2437                    AC_MSG_RESULT([$i])
2438                    XINCLUDES=" -I$i"
2439                    found_xincludes="yes"
2440                    break
2441                fi
2442            done
2443        fi
2444    else
2445        if test "$x_includes" != ""; then
2446            XINCLUDES="-I$x_includes"
2447            found_xincludes="yes"
2448        fi
2449    fi
2450    if test found_xincludes = "no"; then
2451        AC_MSG_RESULT([couldn't find any!])
2452    fi
2453
2454    if test "$no_x" = yes; then
2455        AC_MSG_CHECKING([for X11 libraries])
2456        XLIBSW=nope
2457        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"
2458        for i in $dirs ; do
2459            if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
2460                AC_MSG_RESULT([$i])
2461                XLIBSW="-L$i -lX11"
2462                x_libraries="$i"
2463                break
2464            fi
2465        done
2466    else
2467        if test "$x_libraries" = ""; then
2468            XLIBSW=-lX11
2469        else
2470            XLIBSW="-L$x_libraries -lX11"
2471        fi
2472    fi
2473    if test "$XLIBSW" = nope ; then
2474        AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
2475    fi
2476    if test "$XLIBSW" = nope ; then
2477        AC_MSG_RESULT([could not find any!  Using -lX11.])
2478        XLIBSW=-lX11
2479    fi
2480])
2481
2482#--------------------------------------------------------------------
2483# SC_BLOCKING_STYLE
2484#
2485#       The statements below check for systems where POSIX-style
2486#       non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
2487#       On these systems (mostly older ones), use the old BSD-style
2488#       FIONBIO approach instead.
2489#
2490# Arguments:
2491#       none
2492#       
2493# Results:
2494#
2495#       Defines some of the following vars:
2496#               HAVE_SYS_IOCTL_H
2497#               HAVE_SYS_FILIO_H
2498#               USE_FIONBIO
2499#               O_NONBLOCK
2500#
2501#--------------------------------------------------------------------
2502
2503AC_DEFUN([SC_BLOCKING_STYLE], [
2504    AC_CHECK_HEADERS(sys/ioctl.h)
2505    AC_CHECK_HEADERS(sys/filio.h)
2506    SC_CONFIG_SYSTEM
2507    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
2508    case $system in
2509        # There used to be code here to use FIONBIO under AIX.  However, it
2510        # was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
2511        # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
2512        # code (JO, 5/31/97).
2513
2514        OSF*)
2515            AC_DEFINE(USE_FIONBIO)
2516            AC_MSG_RESULT([FIONBIO])
2517            ;;
2518        SunOS-4*)
2519            AC_DEFINE(USE_FIONBIO)
2520            AC_MSG_RESULT([FIONBIO])
2521            ;;
2522        ULTRIX-4.*)
2523            AC_DEFINE(USE_FIONBIO)
2524            AC_MSG_RESULT([FIONBIO])
2525            ;;
2526        *)
2527            AC_MSG_RESULT([O_NONBLOCK])
2528            ;;
2529    esac
2530])
2531
2532#--------------------------------------------------------------------
2533# SC_TIME_HANLDER
2534#
2535#       Checks how the system deals with time.h, what time structures
2536#       are used on the system, and what fields the structures have.
2537#
2538# Arguments:
2539#       none
2540#       
2541# Results:
2542#
2543#       Defines some of the following vars:
2544#               USE_DELTA_FOR_TZ
2545#               HAVE_TM_GMTOFF
2546#               HAVE_TM_TZADJ
2547#               HAVE_TIMEZONE_VAR
2548#
2549#--------------------------------------------------------------------
2550
2551AC_DEFUN([SC_TIME_HANDLER], [
2552    AC_CHECK_HEADERS(sys/time.h)
2553    AC_HEADER_TIME
2554    AC_STRUCT_TIMEZONE
2555
2556    AC_CHECK_FUNCS(gmtime_r localtime_r)
2557
2558    AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [
2559        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
2560            tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no)])
2561    if test $tcl_cv_member_tm_tzadj = yes ; then
2562        AC_DEFINE(HAVE_TM_TZADJ)
2563    fi
2564
2565    AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
2566        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
2567            tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)])
2568    if test $tcl_cv_member_tm_gmtoff = yes ; then
2569        AC_DEFINE(HAVE_TM_GMTOFF)
2570    fi
2571
2572    #
2573    # Its important to include time.h in this check, as some systems
2574    # (like convex) have timezone functions, etc.
2575    #
2576    AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [
2577        AC_TRY_COMPILE([#include <time.h>],
2578            [extern long timezone;
2579            timezone += 1;
2580            exit (0);],
2581            tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no)])
2582    if test $tcl_cv_timezone_long = yes ; then
2583        AC_DEFINE(HAVE_TIMEZONE_VAR)
2584    else
2585        #
2586        # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
2587        #
2588        AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [
2589            AC_TRY_COMPILE([#include <time.h>],
2590                [extern time_t timezone;
2591                timezone += 1;
2592                exit (0);],
2593                tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no)])
2594        if test $tcl_cv_timezone_time = yes ; then
2595            AC_DEFINE(HAVE_TIMEZONE_VAR)
2596        fi
2597    fi
2598])
2599
2600#--------------------------------------------------------------------
2601# SC_BUGGY_STRTOD
2602#
2603#       Under Solaris 2.4, strtod returns the wrong value for the
2604#       terminating character under some conditions.  Check for this
2605#       and if the problem exists use a substitute procedure
2606#       "fixstrtod" (provided by Tcl) that corrects the error.
2607#       Also, on Compaq's Tru64 Unix 5.0,
2608#       strtod(" ") returns 0.0 instead of a failure to convert.
2609#
2610# Arguments:
2611#       none
2612#       
2613# Results:
2614#
2615#       Might defines some of the following vars:
2616#               strtod (=fixstrtod)
2617#
2618#--------------------------------------------------------------------
2619
2620AC_DEFUN([SC_BUGGY_STRTOD], [
2621    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
2622    if test "$tcl_strtod" = 1; then
2623        AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[
2624            AC_TRY_RUN([
2625                extern double strtod();
2626                int main() {
2627                    char *infString="Inf", *nanString="NaN", *spaceString=" ";
2628                    char *term;
2629                    double value;
2630                    value = strtod(infString, &term);
2631                    if ((term != infString) && (term[-1] == 0)) {
2632                        exit(1);
2633                    }
2634                    value = strtod(nanString, &term);
2635                    if ((term != nanString) && (term[-1] == 0)) {
2636                        exit(1);
2637                    }
2638                    value = strtod(spaceString, &term);
2639                    if (term == (spaceString+1)) {
2640                        exit(1);
2641                    }
2642                    exit(0);
2643                }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy,
2644                    tcl_cv_strtod_buggy=buggy)])
2645        if test "$tcl_cv_strtod_buggy" = buggy; then
2646            LIBOBJS="$LIBOBJS fixstrtod.o"
2647            AC_DEFINE(strtod, fixstrtod)
2648        fi
2649    fi
2650])
2651
2652#--------------------------------------------------------------------
2653# SC_TCL_LINK_LIBS
2654#
2655#       Search for the libraries needed to link the Tcl shell.
2656#       Things like the math library (-lm) and socket stuff (-lsocket vs.
2657#       -lnsl) are dealt with here.
2658#
2659# Arguments:
2660#       Requires the following vars to be set in the Makefile:
2661#               DL_LIBS
2662#               LIBS
2663#               MATH_LIBS
2664#       
2665# Results:
2666#
2667#       Subst's the following var:
2668#               TCL_LIBS
2669#               MATH_LIBS
2670#
2671#       Might append to the following vars:
2672#               LIBS
2673#
2674#       Might define the following vars:
2675#               HAVE_NET_ERRNO_H
2676#
2677#--------------------------------------------------------------------
2678
2679AC_DEFUN([SC_TCL_LINK_LIBS], [
2680    #--------------------------------------------------------------------
2681    # On a few very rare systems, all of the libm.a stuff is
2682    # already in libc.a.  Set compiler flags accordingly.
2683    # Also, Linux requires the "ieee" library for math to work
2684    # right (and it must appear before "-lm").
2685    #--------------------------------------------------------------------
2686
2687    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
2688    AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
2689
2690    #--------------------------------------------------------------------
2691    # Interactive UNIX requires -linet instead of -lsocket, plus it
2692    # needs net/errno.h to define the socket-related error codes.
2693    #--------------------------------------------------------------------
2694
2695    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
2696    AC_CHECK_HEADER(net/errno.h, [AC_DEFINE(HAVE_NET_ERRNO_H)])
2697
2698    #--------------------------------------------------------------------
2699    #   Check for the existence of the -lsocket and -lnsl libraries.
2700    #   The order here is important, so that they end up in the right
2701    #   order in the command line generated by make.  Here are some
2702    #   special considerations:
2703    #   1. Use "connect" and "accept" to check for -lsocket, and
2704    #      "gethostbyname" to check for -lnsl.
2705    #   2. Use each function name only once:  can't redo a check because
2706    #      autoconf caches the results of the last check and won't redo it.
2707    #   3. Use -lnsl and -lsocket only if they supply procedures that
2708    #      aren't already present in the normal libraries.  This is because
2709    #      IRIX 5.2 has libraries, but they aren't needed and they're
2710    #      bogus:  they goof up name resolution if used.
2711    #   4. On some SVR4 systems, can't use -lsocket without -lnsl too.
2712    #      To get around this problem, check for both libraries together
2713    #      if -lsocket doesn't work by itself.
2714    #--------------------------------------------------------------------
2715
2716    tcl_checkBoth=0
2717    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
2718    if test "$tcl_checkSocket" = 1; then
2719        AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
2720            LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
2721    fi
2722    if test "$tcl_checkBoth" = 1; then
2723        tk_oldLibs=$LIBS
2724        LIBS="$LIBS -lsocket -lnsl"
2725        AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
2726    fi
2727    AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
2728            [LIBS="$LIBS -lnsl"])])
2729   
2730    # Don't perform the eval of the libraries here because DL_LIBS
2731    # won't be set until we call SC_CONFIG_CFLAGS
2732
2733    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
2734    AC_SUBST(TCL_LIBS)
2735    AC_SUBST(MATH_LIBS)
2736])
2737
2738#--------------------------------------------------------------------
2739# SC_TCL_EARLY_FLAGS
2740#
2741#       Check for what flags are needed to be passed so the correct OS
2742#       features are available.
2743#
2744# Arguments:
2745#       None
2746#       
2747# Results:
2748#
2749#       Might define the following vars:
2750#               _ISOC99_SOURCE
2751#               _LARGEFILE64_SOURCE
2752#               _LARGEFILE_SOURCE64
2753#
2754#--------------------------------------------------------------------
2755
2756AC_DEFUN([SC_TCL_EARLY_FLAG],[
2757    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
2758        AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
2759            AC_TRY_COMPILE([[#define ]$1[ 1
2760]$2], $3,
2761                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
2762                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
2763    if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
2764        AC_DEFINE($1)
2765        tcl_flags="$tcl_flags $1"
2766    fi
2767])
2768
2769AC_DEFUN([SC_TCL_EARLY_FLAGS],[
2770    AC_MSG_CHECKING([for required early compiler flags])
2771    tcl_flags=""
2772    SC_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
2773        [char *p = (char *)strtoll; char *q = (char *)strtoull;])
2774    SC_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
2775        [struct stat64 buf; int i = stat64("/", &buf);])
2776    SC_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
2777        [char *p = (char *)open64;])
2778    if test "x${tcl_flags}" = "x" ; then
2779        AC_MSG_RESULT([none])
2780    else
2781        AC_MSG_RESULT([${tcl_flags}])
2782    fi
2783])
2784
2785#--------------------------------------------------------------------
2786# SC_TCL_64BIT_FLAGS
2787#
2788#       Check for what is defined in the way of 64-bit features.
2789#
2790# Arguments:
2791#       None
2792#       
2793# Results:
2794#
2795#       Might define the following vars:
2796#               TCL_WIDE_INT_IS_LONG
2797#               TCL_WIDE_INT_TYPE
2798#               HAVE_STRUCT_DIRENT64
2799#               HAVE_STRUCT_STAT64
2800#               HAVE_TYPE_OFF64_T
2801#
2802#--------------------------------------------------------------------
2803
2804AC_DEFUN([SC_TCL_64BIT_FLAGS], [
2805    AC_MSG_CHECKING([for 64-bit integer type])
2806    AC_CACHE_VAL(tcl_cv_type_64bit,[
2807        tcl_cv_type_64bit=none
2808        # See if the compiler knows natively about __int64
2809        AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
2810            tcl_type_64bit=__int64, tcl_type_64bit="long long")
2811        # See if we should use long anyway  Note that we substitute in the
2812        # type that is our current guess for a 64-bit type inside this check
2813        # program, so it should be modified only carefully...
2814        AC_TRY_COMPILE(,[switch (0) {
2815            case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ;
2816        }],tcl_cv_type_64bit=${tcl_type_64bit})])
2817    if test "${tcl_cv_type_64bit}" = none ; then
2818        AC_DEFINE(TCL_WIDE_INT_IS_LONG)
2819        AC_MSG_RESULT([using long])
2820    else
2821        AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit})
2822        AC_MSG_RESULT([${tcl_cv_type_64bit}])
2823
2824        # Now check for auxiliary declarations
2825        AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
2826            AC_TRY_COMPILE([#include <sys/types.h>
2827#include <sys/dirent.h>],[struct dirent64 p;],
2828                tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
2829        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
2830            AC_DEFINE(HAVE_STRUCT_DIRENT64)
2831        fi
2832
2833        AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[
2834            AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
2835],
2836                tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
2837        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
2838            AC_DEFINE(HAVE_STRUCT_STAT64)
2839        fi
2840
2841        AC_CHECK_FUNCS(open64 lseek64)
2842        AC_MSG_CHECKING([for off64_t])
2843        AC_CACHE_VAL(tcl_cv_type_off64_t,[
2844            AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
2845],
2846                tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
2847        dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the
2848        dnl functions lseek64 and open64 are defined.
2849        if test "x${tcl_cv_type_off64_t}" = "xyes" && \
2850                test "x${ac_cv_func_lseek64}" = "xyes" && \
2851                test "x${ac_cv_func_open64}" = "xyes" ; then
2852            AC_DEFINE(HAVE_TYPE_OFF64_T)
2853            AC_MSG_RESULT([yes])
2854        else
2855            AC_MSG_RESULT([no])
2856        fi
2857    fi
2858])
2859
2860#--------------------------------------------------------------------
2861# SC_TCL_GETHOSTBYADDR_R
2862#
2863#       Check if we have MT-safe variant of gethostbyaddr().
2864#
2865# Arguments:
2866#       None
2867#       
2868# Results:
2869#
2870#       Might define the following vars:
2871#               HAVE_GETHOSTBYADDR_R
2872#               HAVE_GETHOSTBYADDR_R_7
2873#               HAVE_GETHOSTBYADDR_R_8
2874#
2875#--------------------------------------------------------------------
2876
2877AC_DEFUN([SC_TCL_GETHOSTBYADDR_R], [AC_CHECK_FUNC(gethostbyaddr_r, [
2878    AC_CACHE_CHECK([for gethostbyaddr_r with 7 args], tcl_cv_api_gethostbyaddr_r_7, [
2879    AC_TRY_COMPILE([
2880        #include <netdb.h>
2881    ], [
2882        char *addr;
2883        int length;
2884        int type;
2885        struct hostent *result;
2886        char buffer[2048];
2887        int buflen = 2048;
2888        int h_errnop;
2889
2890        (void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
2891                               &h_errnop);
2892    ], tcl_cv_api_gethostbyaddr_r_7=yes, tcl_cv_api_gethostbyaddr_r_7=no)])
2893    tcl_ok=$tcl_cv_api_gethostbyaddr_r_7
2894    if test "$tcl_ok" = yes; then
2895        AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
2896    else
2897        AC_CACHE_CHECK([for gethostbyaddr_r with 8 args], tcl_cv_api_gethostbyaddr_r_8, [
2898        AC_TRY_COMPILE([
2899            #include <netdb.h>
2900        ], [
2901            char *addr;
2902            int length;
2903            int type;
2904            struct hostent *result, *resultp;
2905            char buffer[2048];
2906            int buflen = 2048;
2907            int h_errnop;
2908
2909            (void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
2910                                   &resultp, &h_errnop);
2911        ], tcl_cv_api_gethostbyaddr_r_8=yes, tcl_cv_api_gethostbyaddr_r_8=no)])
2912        tcl_ok=$tcl_cv_api_gethostbyaddr_r_8
2913        if test "$tcl_ok" = yes; then
2914            AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
2915        fi
2916    fi
2917    if test "$tcl_ok" = yes; then
2918        AC_DEFINE(HAVE_GETHOSTBYADDR_R)
2919    fi
2920])])
2921
2922#--------------------------------------------------------------------
2923# SC_TCL_GETHOSTBYNAME_R
2924#
2925#       Check to see what variant of gethostbyname_r() we have.
2926#       Based on David Arnold's example from the comp.programming.threads
2927#       FAQ Q213
2928#
2929# Arguments:
2930#       None
2931#       
2932# Results:
2933#
2934#       Might define the following vars:
2935#               HAVE_GETHOSTBYADDR_R
2936#               HAVE_GETHOSTBYADDR_R_3
2937#               HAVE_GETHOSTBYADDR_R_5
2938#               HAVE_GETHOSTBYADDR_R_6
2939#
2940#--------------------------------------------------------------------
2941
2942AC_DEFUN([SC_TCL_GETHOSTBYNAME_R], [AC_CHECK_FUNC(gethostbyname_r, [
2943    AC_CACHE_CHECK([for gethostbyname_r with 6 args], tcl_cv_api_gethostbyname_r_6, [
2944    AC_TRY_COMPILE([
2945        #include <netdb.h>
2946    ], [
2947        char *name;
2948        struct hostent *he, *res;
2949        char buffer[2048];
2950        int buflen = 2048;
2951        int h_errnop;
2952
2953        (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop);
2954    ], tcl_cv_api_gethostbyname_r_6=yes, tcl_cv_api_gethostbyname_r_6=no)])
2955    tcl_ok=$tcl_cv_api_gethostbyname_r_6
2956    if test "$tcl_ok" = yes; then
2957        AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
2958    else
2959        AC_CACHE_CHECK([for gethostbyname_r with 5 args], tcl_cv_api_gethostbyname_r_5, [
2960        AC_TRY_COMPILE([
2961            #include <netdb.h>
2962        ], [
2963            char *name;
2964            struct hostent *he;
2965            char buffer[2048];
2966            int buflen = 2048;
2967            int h_errnop;
2968
2969            (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop);
2970        ], tcl_cv_api_gethostbyname_r_5=yes, tcl_cv_api_gethostbyname_r_5=no)])
2971        tcl_ok=$tcl_cv_api_gethostbyname_r_5
2972        if test "$tcl_ok" = yes; then
2973            AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
2974        else
2975            AC_CACHE_CHECK([for gethostbyname_r with 3 args], tcl_cv_api_gethostbyname_r_3, [
2976            AC_TRY_COMPILE([
2977                #include <netdb.h>
2978            ], [
2979                char *name;
2980                struct hostent *he;
2981                struct hostent_data data;
2982
2983                (void) gethostbyname_r(name, he, &data);
2984            ], tcl_cv_api_gethostbyname_r_3=yes, tcl_cv_api_gethostbyname_r_3=no)])
2985            tcl_ok=$tcl_cv_api_gethostbyname_r_3
2986            if test "$tcl_ok" = yes; then
2987                AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
2988            fi
2989        fi
2990    fi
2991    if test "$tcl_ok" = yes; then
2992        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2993    fi
2994])])
2995
2996#--------------------------------------------------------------------
2997# SC_TCL_GETPWUID_R
2998#
2999#       Check if we have MT-safe variant of getpwuid() and if yes,
3000#       which one exactly.
3001#
3002# Arguments:
3003#       None
3004#       
3005# Results:
3006#
3007#       Might define the following vars:
3008#               HAVE_GETPWUID_R
3009#               HAVE_GETPWUID_R_4
3010#               HAVE_GETPWUID_R_5
3011#
3012#--------------------------------------------------------------------
3013
3014AC_DEFUN([SC_TCL_GETPWUID_R], [AC_CHECK_FUNC(getpwuid_r, [
3015    AC_CACHE_CHECK([for getpwuid_r with 5 args], tcl_cv_api_getpwuid_r_5, [
3016    AC_TRY_COMPILE([
3017        #include <sys/types.h>
3018        #include <pwd.h>
3019    ], [
3020        uid_t uid;
3021        struct passwd pw, *pwp;
3022        char buf[512];
3023        int buflen = 512;
3024
3025        (void) getpwuid_r(uid, &pw, buf, buflen, &pwp);
3026    ], tcl_cv_api_getpwuid_r_5=yes, tcl_cv_api_getpwuid_r_5=no)])
3027    tcl_ok=$tcl_cv_api_getpwuid_r_5
3028    if test "$tcl_ok" = yes; then
3029        AC_DEFINE(HAVE_GETPWUID_R_5)
3030    else
3031        AC_CACHE_CHECK([for getpwuid_r with 4 args], tcl_cv_api_getpwuid_r_4, [
3032        AC_TRY_COMPILE([
3033            #include <sys/types.h>
3034            #include <pwd.h>
3035        ], [
3036            uid_t uid;
3037            struct passwd pw;
3038            char buf[512];
3039            int buflen = 512;
3040
3041            (void)getpwnam_r(uid, &pw, buf, buflen);
3042        ], tcl_cv_api_getpwuid_r_4=yes, tcl_cv_api_getpwuid_r_4=no)])
3043        tcl_ok=$tcl_cv_api_getpwuid_r_4
3044        if test "$tcl_ok" = yes; then
3045            AC_DEFINE(HAVE_GETPWUID_R_4)
3046        fi
3047    fi
3048    if test "$tcl_ok" = yes; then
3049        AC_DEFINE(HAVE_GETPWUID_R)
3050    fi
3051])])
3052
3053#--------------------------------------------------------------------
3054# SC_TCL_GETPWNAM_R
3055#
3056#       Check if we have MT-safe variant of getpwnam() and if yes,
3057#       which one exactly.
3058#
3059# Arguments:
3060#       None
3061#       
3062# Results:
3063#
3064#       Might define the following vars:
3065#               HAVE_GETPWNAM_R
3066#               HAVE_GETPWNAM_R_4
3067#               HAVE_GETPWNAM_R_5
3068#
3069#--------------------------------------------------------------------
3070
3071AC_DEFUN([SC_TCL_GETPWNAM_R], [AC_CHECK_FUNC(getpwnam_r, [
3072    AC_CACHE_CHECK([for getpwnam_r with 5 args], tcl_cv_api_getpwnam_r_5, [
3073    AC_TRY_COMPILE([
3074        #include <sys/types.h>
3075        #include <pwd.h>
3076    ], [
3077        char *name;
3078        struct passwd pw, *pwp;
3079        char buf[512];
3080        int buflen = 512;
3081
3082        (void) getpwnam_r(name, &pw, buf, buflen, &pwp);
3083    ], tcl_cv_api_getpwnam_r_5=yes, tcl_cv_api_getpwnam_r_5=no)])
3084    tcl_ok=$tcl_cv_api_getpwnam_r_5
3085    if test "$tcl_ok" = yes; then
3086        AC_DEFINE(HAVE_GETPWNAM_R_5)
3087    else
3088        AC_CACHE_CHECK([for getpwnam_r with 4 args], tcl_cv_api_getpwnam_r_4, [
3089        AC_TRY_COMPILE([
3090            #include <sys/types.h>
3091            #include <pwd.h>
3092        ], [
3093            char *name;
3094            struct passwd pw;
3095            char buf[512];
3096            int buflen = 512;
3097
3098            (void)getpwnam_r(name, &pw, buf, buflen);
3099        ], tcl_cv_api_getpwnam_r_4=yes, tcl_cv_api_getpwnam_r_4=no)])
3100        tcl_ok=$tcl_cv_api_getpwnam_r_4
3101        if test "$tcl_ok" = yes; then
3102            AC_DEFINE(HAVE_GETPWNAM_R_4)
3103        fi
3104    fi
3105    if test "$tcl_ok" = yes; then
3106        AC_DEFINE(HAVE_GETPWNAM_R)
3107    fi
3108])])
3109
3110#--------------------------------------------------------------------
3111# SC_TCL_GETGRGID_R
3112#
3113#       Check if we have MT-safe variant of getgrgid() and if yes,
3114#       which one exactly.
3115#
3116# Arguments:
3117#       None
3118#       
3119# Results:
3120#
3121#       Might define the following vars:
3122#               HAVE_GETGRGID_R
3123#               HAVE_GETGRGID_R_4
3124#               HAVE_GETGRGID_R_5
3125#
3126#--------------------------------------------------------------------
3127
3128AC_DEFUN([SC_TCL_GETGRGID_R], [AC_CHECK_FUNC(getgrgid_r, [
3129    AC_CACHE_CHECK([for getgrgid_r with 5 args], tcl_cv_api_getgrgid_r_5, [
3130    AC_TRY_COMPILE([
3131        #include <sys/types.h>
3132        #include <grp.h>
3133    ], [
3134        gid_t gid;
3135        struct group gr, *grp;
3136        char buf[512];
3137        int buflen = 512;
3138
3139        (void) getgrgid_r(gid, &gr, buf, buflen, &grp);
3140    ], tcl_cv_api_getgrgid_r_5=yes, tcl_cv_api_getgrgid_r_5=no)])
3141    tcl_ok=$tcl_cv_api_getgrgid_r_5
3142    if test "$tcl_ok" = yes; then
3143        AC_DEFINE(HAVE_GETGRGID_R_5)
3144    else
3145        AC_CACHE_CHECK([for getgrgid_r with 4 args], tcl_cv_api_getgrgid_r_4, [
3146        AC_TRY_COMPILE([
3147            #include <sys/types.h>
3148            #include <grp.h>
3149        ], [
3150            gid_t gid;
3151            struct group gr;
3152            char buf[512];
3153            int buflen = 512;
3154
3155            (void)getgrgid_r(gid, &gr, buf, buflen);
3156        ], tcl_cv_api_getgrgid_r_4=yes, tcl_cv_api_getgrgid_r_4=no)])
3157        tcl_ok=$tcl_cv_api_getgrgid_r_4
3158        if test "$tcl_ok" = yes; then
3159            AC_DEFINE(HAVE_GETGRGID_R_4)
3160        fi
3161    fi
3162    if test "$tcl_ok" = yes; then
3163        AC_DEFINE(HAVE_GETGRGID_R)
3164    fi
3165])])
3166
3167#--------------------------------------------------------------------
3168# SC_TCL_GETGRNAM_R
3169#
3170#       Check if we have MT-safe variant of getgrnam() and if yes,
3171#       which one exactly.
3172#
3173# Arguments:
3174#       None
3175#       
3176# Results:
3177#
3178#       Might define the following vars:
3179#               HAVE_GETGRNAM_R
3180#               HAVE_GETGRNAM_R_4
3181#               HAVE_GETGRNAM_R_5
3182#
3183#--------------------------------------------------------------------
3184
3185AC_DEFUN([SC_TCL_GETGRNAM_R], [AC_CHECK_FUNC(getgrnam_r, [
3186    AC_CACHE_CHECK([for getgrnam_r with 5 args], tcl_cv_api_getgrnam_r_5, [
3187    AC_TRY_COMPILE([
3188        #include <sys/types.h>
3189        #include <grp.h>
3190    ], [
3191        char *name;
3192        struct group gr, *grp;
3193        char buf[512];
3194        int buflen = 512;
3195
3196        (void) getgrnam_r(name, &gr, buf, buflen, &grp);
3197    ], tcl_cv_api_getgrnam_r_5=yes, tcl_cv_api_getgrnam_r_5=no)])
3198    tcl_ok=$tcl_cv_api_getgrnam_r_5
3199    if test "$tcl_ok" = yes; then
3200        AC_DEFINE(HAVE_GETGRNAM_R_5)
3201    else
3202        AC_CACHE_CHECK([for getgrnam_r with 4 args], tcl_cv_api_getgrnam_r_4, [
3203        AC_TRY_COMPILE([
3204            #include <sys/types.h>
3205            #include <grp.h>
3206        ], [
3207            char *name;
3208            struct group gr;
3209            char buf[512];
3210            int buflen = 512;
3211
3212            (void)getgrnam_r(name, &gr, buf, buflen);
3213        ], tcl_cv_api_getgrnam_r_4=yes, tcl_cv_api_getgrnam_r_4=no)])
3214        tcl_ok=$tcl_cv_api_getgrnam_r_4
3215        if test "$tcl_ok" = yes; then
3216            AC_DEFINE(HAVE_GETGRNAM_R_4)
3217        fi
3218    fi
3219    if test "$tcl_ok" = yes; then
3220        AC_DEFINE(HAVE_GETGRNAM_R)
3221    fi
3222])])
3223
3224#--------------------------------------------------------------------
3225# SC_CONFIG_COMMANDS_PRE(CMDS)
3226#
3227#       Replacement for autoconf 2.5x AC_COMMANDS_PRE:
3228#               Commands to run right before config.status is
3229#               created. Accumulates.
3230#
3231#       Requires presence of SC_OUTPUT_COMMANDS_PRE at the end
3232#       of configure.in (right before AC_OUTPUT).
3233#
3234#--------------------------------------------------------------------
3235
3236AC_DEFUN([SC_CONFIG_COMMANDS_PRE], [
3237    define([SC_OUTPUT_COMMANDS_PRE], defn([SC_OUTPUT_COMMANDS_PRE])[$1
3238])])
3239AC_DEFUN([SC_OUTPUT_COMMANDS_PRE])
3240
Note: See TracBrowser for help on using the repository browser.