Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/unix/tcl.m4 @ 25

Last change on this file since 25 was 25, checked in by landauf, 16 years ago

added tcl to libs

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