OSDN Git Service

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