]> git.sven.stormbind.net Git - sven/tclcurl.git/blob - tclconfig/tcl.m4
releasing package tclcurl version 7.22.0+hg20160822-2
[sven/tclcurl.git] / tclconfig / tcl.m4
1 # tcl.m4 --
2 #
3 #       This file provides a set of autoconf macros to help TEA-enable
4 #       a Tcl extension.
5 #
6 # Copyright (c) 1999-2000 Ajuba Solutions.
7 # Copyright (c) 2002-2005 ActiveState Corporation.
8 #
9 # See the file "license.terms" for information on usage and redistribution
10 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 #
12 # RCS: @(#) $Id: tcl.m4,v 1.135 2009/04/28 00:40:24 hobbs Exp $
13
14 AC_PREREQ(2.57)
15
16 dnl TEA extensions pass us the version of TEA they think they
17 dnl are compatible with (must be set in TEA_INIT below)
18 dnl TEA_VERSION="3.7"
19
20 # Possible values for key variables defined:
21 #
22 # TEA_WINDOWINGSYSTEM - win32 aqua x11 (mirrors 'tk windowingsystem')
23 # TEA_PLATFORM        - windows unix
24 #
25
26 #------------------------------------------------------------------------
27 # TEA_PATH_TCLCONFIG --
28 #
29 #       Locate the tclConfig.sh file and perform a sanity check on
30 #       the Tcl compile flags
31 #
32 # Arguments:
33 #       none
34 #
35 # Results:
36 #
37 #       Adds the following arguments to configure:
38 #               --with-tcl=...
39 #
40 #       Defines the following vars:
41 #               TCL_BIN_DIR     Full path to the directory containing
42 #                               the tclConfig.sh file
43 #------------------------------------------------------------------------
44
45 AC_DEFUN([TEA_PATH_TCLCONFIG], [
46     dnl TEA specific: Make sure we are initialized
47     AC_REQUIRE([TEA_INIT])
48     #
49     # Ok, lets find the tcl configuration
50     # First, look for one uninstalled.
51     # the alternative search directory is invoked by --with-tcl
52     #
53
54     if test x"${no_tcl}" = x ; then
55         # we reset no_tcl in case something fails here
56         no_tcl=true
57         AC_ARG_WITH(tcl,
58             AC_HELP_STRING([--with-tcl],
59                 [directory containing tcl configuration (tclConfig.sh)]),
60             with_tclconfig=${withval})
61         AC_MSG_CHECKING([for Tcl configuration])
62         AC_CACHE_VAL(ac_cv_c_tclconfig,[
63
64             # First check to see if --with-tcl was specified.
65             if test x"${with_tclconfig}" != x ; then
66                 case ${with_tclconfig} in
67                     */tclConfig.sh )
68                         if test -f ${with_tclconfig}; then
69                             AC_MSG_WARN([--with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself])
70                             with_tclconfig=`echo ${with_tclconfig} | sed 's!/tclConfig\.sh$!!'`
71                         fi ;;
72                 esac
73                 if test -f "${with_tclconfig}/tclConfig.sh" ; then
74                     ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
75                 else
76                     AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
77                 fi
78             fi
79
80             # then check for a private Tcl installation
81             if test x"${ac_cv_c_tclconfig}" = x ; then
82                 for i in \
83                         ../tcl \
84                         `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
85                         `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
86                         `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
87                         ../../tcl \
88                         `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
89                         `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
90                         `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
91                         ../../../tcl \
92                         `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
93                         `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
94                         `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
95                     if test "${TEA_PLATFORM}" = "windows" \
96                             -a -f "$i/win/tclConfig.sh" ; then
97                         ac_cv_c_tclconfig=`(cd $i/win; pwd)`
98                         break
99                     fi
100                     if test -f "$i/unix/tclConfig.sh" ; then
101                         ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
102                         break
103                     fi
104                 done
105             fi
106
107             # on Darwin, check in Framework installation locations
108             if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
109                 for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
110                         `ls -d /Library/Frameworks 2>/dev/null` \
111                         `ls -d /Network/Library/Frameworks 2>/dev/null` \
112                         `ls -d /System/Library/Frameworks 2>/dev/null` \
113                         ; do
114                     if test -f "$i/Tcl.framework/tclConfig.sh" ; then
115                         ac_cv_c_tclconfig=`(cd $i/Tcl.framework; pwd)`
116                         break
117                     fi
118                 done
119             fi
120
121             # TEA specific: on Windows, check in common installation locations
122             if test "${TEA_PLATFORM}" = "windows" \
123                 -a x"${ac_cv_c_tclconfig}" = x ; then
124                 for i in `ls -d C:/Tcl/lib 2>/dev/null` \
125                         `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
126                         ; do
127                     if test -f "$i/tclConfig.sh" ; then
128                         ac_cv_c_tclconfig=`(cd $i; pwd)`
129                         break
130                     fi
131                 done
132             fi
133
134             # check in a few common install locations
135             if test x"${ac_cv_c_tclconfig}" = x ; then
136                 for i in `ls -d ${libdir} 2>/dev/null` \
137                         `ls -d ${exec_prefix}/lib 2>/dev/null` \
138                         `ls -d ${prefix}/lib 2>/dev/null` \
139                         `ls -d /usr/local/lib 2>/dev/null` \
140                         `ls -d /usr/contrib/lib 2>/dev/null` \
141                         `ls -d /usr/lib 2>/dev/null` \
142                         ; do
143                     if test -f "$i/tclConfig.sh" ; then
144                         ac_cv_c_tclconfig=`(cd $i; pwd)`
145                         break
146                     fi
147                 done
148             fi
149
150             # check in a few other private locations
151             if test x"${ac_cv_c_tclconfig}" = x ; then
152                 for i in \
153                         ${srcdir}/../tcl \
154                         `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
155                         `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
156                         `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
157                     if test "${TEA_PLATFORM}" = "windows" \
158                             -a -f "$i/win/tclConfig.sh" ; then
159                         ac_cv_c_tclconfig=`(cd $i/win; pwd)`
160                         break
161                     fi
162                     if test -f "$i/unix/tclConfig.sh" ; then
163                     ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
164                     break
165                 fi
166                 done
167             fi
168         ])
169
170         if test x"${ac_cv_c_tclconfig}" = x ; then
171             TCL_BIN_DIR="# no Tcl configs found"
172             AC_MSG_ERROR([Can't find Tcl configuration definitions])
173         else
174             no_tcl=
175             TCL_BIN_DIR=${ac_cv_c_tclconfig}
176             AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
177         fi
178     fi
179 ])
180
181 #------------------------------------------------------------------------
182 # TEA_PATH_TKCONFIG --
183 #
184 #       Locate the tkConfig.sh file
185 #
186 # Arguments:
187 #       none
188 #
189 # Results:
190 #
191 #       Adds the following arguments to configure:
192 #               --with-tk=...
193 #
194 #       Defines the following vars:
195 #               TK_BIN_DIR      Full path to the directory containing
196 #                               the tkConfig.sh file
197 #------------------------------------------------------------------------
198
199 AC_DEFUN([TEA_PATH_TKCONFIG], [
200     #
201     # Ok, lets find the tk configuration
202     # First, look for one uninstalled.
203     # the alternative search directory is invoked by --with-tk
204     #
205
206     if test x"${no_tk}" = x ; then
207         # we reset no_tk in case something fails here
208         no_tk=true
209         AC_ARG_WITH(tk,
210             AC_HELP_STRING([--with-tk],
211                 [directory containing tk configuration (tkConfig.sh)]),
212             with_tkconfig=${withval})
213         AC_MSG_CHECKING([for Tk configuration])
214         AC_CACHE_VAL(ac_cv_c_tkconfig,[
215
216             # First check to see if --with-tkconfig was specified.
217             if test x"${with_tkconfig}" != x ; then
218                 case ${with_tkconfig} in
219                     */tkConfig.sh )
220                         if test -f ${with_tkconfig}; then
221                             AC_MSG_WARN([--with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself])
222                             with_tkconfig=`echo ${with_tkconfig} | sed 's!/tkConfig\.sh$!!'`
223                         fi ;;
224                 esac
225                 if test -f "${with_tkconfig}/tkConfig.sh" ; then
226                     ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
227                 else
228                     AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
229                 fi
230             fi
231
232             # then check for a private Tk library
233             if test x"${ac_cv_c_tkconfig}" = x ; then
234                 for i in \
235                         ../tk \
236                         `ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
237                         `ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
238                         `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
239                         ../../tk \
240                         `ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
241                         `ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
242                         `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
243                         ../../../tk \
244                         `ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
245                         `ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
246                         `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
247                     if test "${TEA_PLATFORM}" = "windows" \
248                             -a -f "$i/win/tkConfig.sh" ; then
249                         ac_cv_c_tkconfig=`(cd $i/win; pwd)`
250                         break
251                     fi
252                     if test -f "$i/unix/tkConfig.sh" ; then
253                         ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
254                         break
255                     fi
256                 done
257             fi
258
259             # on Darwin, check in Framework installation locations
260             if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then
261                 for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
262                         `ls -d /Library/Frameworks 2>/dev/null` \
263                         `ls -d /Network/Library/Frameworks 2>/dev/null` \
264                         `ls -d /System/Library/Frameworks 2>/dev/null` \
265                         ; do
266                     if test -f "$i/Tk.framework/tkConfig.sh" ; then
267                         ac_cv_c_tkconfig=`(cd $i/Tk.framework; pwd)`
268                         break
269                     fi
270                 done
271             fi
272
273             # check in a few common install locations
274             if test x"${ac_cv_c_tkconfig}" = x ; then
275                 for i in `ls -d ${libdir} 2>/dev/null` \
276                         `ls -d ${exec_prefix}/lib 2>/dev/null` \
277                         `ls -d ${prefix}/lib 2>/dev/null` \
278                         `ls -d /usr/local/lib 2>/dev/null` \
279                         `ls -d /usr/contrib/lib 2>/dev/null` \
280                         `ls -d /usr/lib 2>/dev/null` \
281                         ; do
282                     if test -f "$i/tkConfig.sh" ; then
283                         ac_cv_c_tkconfig=`(cd $i; pwd)`
284                         break
285                     fi
286                 done
287             fi
288
289             # TEA specific: on Windows, check in common installation locations
290             if test "${TEA_PLATFORM}" = "windows" \
291                 -a x"${ac_cv_c_tkconfig}" = x ; then
292                 for i in `ls -d C:/Tcl/lib 2>/dev/null` \
293                         `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
294                         ; do
295                     if test -f "$i/tkConfig.sh" ; then
296                         ac_cv_c_tkconfig=`(cd $i; pwd)`
297                         break
298                     fi
299                 done
300             fi
301
302             # check in a few other private locations
303             if test x"${ac_cv_c_tkconfig}" = x ; then
304                 for i in \
305                         ${srcdir}/../tk \
306                         `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
307                         `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
308                         `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
309                     if test "${TEA_PLATFORM}" = "windows" \
310                             -a -f "$i/win/tkConfig.sh" ; then
311                         ac_cv_c_tkconfig=`(cd $i/win; pwd)`
312                         break
313                     fi
314                     if test -f "$i/unix/tkConfig.sh" ; then
315                         ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
316                         break
317                     fi
318                 done
319             fi
320         ])
321
322         if test x"${ac_cv_c_tkconfig}" = x ; then
323             TK_BIN_DIR="# no Tk configs found"
324             AC_MSG_ERROR([Can't find Tk configuration definitions])
325         else
326             no_tk=
327             TK_BIN_DIR=${ac_cv_c_tkconfig}
328             AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
329         fi
330     fi
331 ])
332
333 #------------------------------------------------------------------------
334 # TEA_LOAD_TCLCONFIG --
335 #
336 #       Load the tclConfig.sh file
337 #
338 # Arguments:
339 #
340 #       Requires the following vars to be set:
341 #               TCL_BIN_DIR
342 #
343 # Results:
344 #
345 #       Subst the following vars:
346 #               TCL_BIN_DIR
347 #               TCL_SRC_DIR
348 #               TCL_LIB_FILE
349 #
350 #------------------------------------------------------------------------
351
352 AC_DEFUN([TEA_LOAD_TCLCONFIG], [
353     AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
354
355     if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
356         AC_MSG_RESULT([loading])
357         . "${TCL_BIN_DIR}/tclConfig.sh"
358     else
359         AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
360     fi
361
362     # eval is required to do the TCL_DBGX substitution
363     eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
364     eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
365
366     # If the TCL_BIN_DIR is the build directory (not the install directory),
367     # then set the common variable name to the value of the build variables.
368     # For example, the variable TCL_LIB_SPEC will be set to the value
369     # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
370     # instead of TCL_BUILD_LIB_SPEC since it will work with both an
371     # installed and uninstalled version of Tcl.
372     if test -f "${TCL_BIN_DIR}/Makefile" ; then
373         TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
374         TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
375         TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
376     elif test "`uname -s`" = "Darwin"; then
377         # If Tcl was built as a framework, attempt to use the libraries
378         # from the framework at the given location so that linking works
379         # against Tcl.framework installed in an arbitrary location.
380         case ${TCL_DEFS} in
381             *TCL_FRAMEWORK*)
382                 if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then
383                     for i in "`cd ${TCL_BIN_DIR}; pwd`" \
384                              "`cd ${TCL_BIN_DIR}/../..; pwd`"; do
385                         if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
386                             TCL_LIB_SPEC="-F`dirname "$i"` -framework ${TCL_LIB_FILE}"
387                             break
388                         fi
389                     done
390                 fi
391                 if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then
392                     TCL_STUB_LIB_SPEC="-L${TCL_BIN_DIR} ${TCL_STUB_LIB_FLAG}"
393                     TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
394                 fi
395                 ;;
396         esac
397     fi
398
399     # eval is required to do the TCL_DBGX substitution
400     eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
401     eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
402     eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
403     eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
404
405     AC_SUBST(TCL_VERSION)
406     AC_SUBST(TCL_BIN_DIR)
407     AC_SUBST(TCL_SRC_DIR)
408
409     AC_SUBST(TCL_LIB_FILE)
410     AC_SUBST(TCL_LIB_FLAG)
411     AC_SUBST(TCL_LIB_SPEC)
412
413     AC_SUBST(TCL_STUB_LIB_FILE)
414     AC_SUBST(TCL_STUB_LIB_FLAG)
415     AC_SUBST(TCL_STUB_LIB_SPEC)
416
417     # TEA specific:
418     AC_SUBST(TCL_LIBS)
419     AC_SUBST(TCL_DEFS)
420     AC_SUBST(TCL_EXTRA_CFLAGS)
421     AC_SUBST(TCL_LD_FLAGS)
422     AC_SUBST(TCL_SHLIB_LD_LIBS)
423 ])
424
425 #------------------------------------------------------------------------
426 # TEA_LOAD_TKCONFIG --
427 #
428 #       Load the tkConfig.sh file
429 #
430 # Arguments:
431 #
432 #       Requires the following vars to be set:
433 #               TK_BIN_DIR
434 #
435 # Results:
436 #
437 #       Sets the following vars that should be in tkConfig.sh:
438 #               TK_BIN_DIR
439 #------------------------------------------------------------------------
440
441 AC_DEFUN([TEA_LOAD_TKCONFIG], [
442     AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
443
444     if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
445         AC_MSG_RESULT([loading])
446         . "${TK_BIN_DIR}/tkConfig.sh"
447     else
448         AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
449     fi
450
451     # eval is required to do the TK_DBGX substitution
452     eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
453     eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
454
455     # If the TK_BIN_DIR is the build directory (not the install directory),
456     # then set the common variable name to the value of the build variables.
457     # For example, the variable TK_LIB_SPEC will be set to the value
458     # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
459     # instead of TK_BUILD_LIB_SPEC since it will work with both an
460     # installed and uninstalled version of Tcl.
461     if test -f "${TK_BIN_DIR}/Makefile" ; then
462         TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
463         TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
464         TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
465     elif test "`uname -s`" = "Darwin"; then
466         # If Tk was built as a framework, attempt to use the libraries
467         # from the framework at the given location so that linking works
468         # against Tk.framework installed in an arbitrary location.
469         case ${TK_DEFS} in
470             *TK_FRAMEWORK*)
471                 if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then
472                     for i in "`cd ${TK_BIN_DIR}; pwd`" \
473                              "`cd ${TK_BIN_DIR}/../..; pwd`"; do
474                         if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
475                             TK_LIB_SPEC="-F`dirname "$i"` -framework ${TK_LIB_FILE}"
476                             break
477                         fi
478                     done
479                 fi
480                 if test -f "${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"; then
481                     TK_STUB_LIB_SPEC="-L${TK_BIN_DIR} ${TK_STUB_LIB_FLAG}"
482                     TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
483                 fi
484                 ;;
485         esac
486     fi
487
488     # eval is required to do the TK_DBGX substitution
489     eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
490     eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
491     eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
492     eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
493
494     # TEA specific: Ensure windowingsystem is defined
495     if test "${TEA_PLATFORM}" = "unix" ; then
496         case ${TK_DEFS} in
497             *MAC_OSX_TK*)
498                 AC_DEFINE(MAC_OSX_TK, 1, [Are we building against Mac OS X TkAqua?])
499                 TEA_WINDOWINGSYSTEM="aqua"
500                 ;;
501             *)
502                 TEA_WINDOWINGSYSTEM="x11"
503                 ;;
504         esac
505     elif test "${TEA_PLATFORM}" = "windows" ; then
506         TEA_WINDOWINGSYSTEM="win32"
507     fi
508
509     AC_SUBST(TK_VERSION)
510     AC_SUBST(TK_BIN_DIR)
511     AC_SUBST(TK_SRC_DIR)
512
513     AC_SUBST(TK_LIB_FILE)
514     AC_SUBST(TK_LIB_FLAG)
515     AC_SUBST(TK_LIB_SPEC)
516
517     AC_SUBST(TK_STUB_LIB_FILE)
518     AC_SUBST(TK_STUB_LIB_FLAG)
519     AC_SUBST(TK_STUB_LIB_SPEC)
520
521     # TEA specific:
522     AC_SUBST(TK_LIBS)
523     AC_SUBST(TK_XINCLUDES)
524 ])
525
526 #------------------------------------------------------------------------
527 # TEA_PROG_TCLSH
528 #       Determine the fully qualified path name of the tclsh executable
529 #       in the Tcl build directory or the tclsh installed in a bin
530 #       directory. This macro will correctly determine the name
531 #       of the tclsh executable even if tclsh has not yet been
532 #       built in the build directory. The tclsh found is always
533 #       associated with a tclConfig.sh file. This tclsh should be used
534 #       only for running extension test cases. It should never be
535 #       or generation of files (like pkgIndex.tcl) at build time.
536 #
537 # Arguments
538 #       none
539 #
540 # Results
541 #       Subst's the following values:
542 #               TCLSH_PROG
543 #------------------------------------------------------------------------
544
545 AC_DEFUN([TEA_PROG_TCLSH], [
546     AC_MSG_CHECKING([for tclsh])
547     if test -f "${TCL_BIN_DIR}/Makefile" ; then
548         # tclConfig.sh is in Tcl build directory
549         if test "${TEA_PLATFORM}" = "windows"; then
550             TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
551         else
552             TCLSH_PROG="${TCL_BIN_DIR}/tclsh"
553         fi
554     else
555         # tclConfig.sh is in install location
556         if test "${TEA_PLATFORM}" = "windows"; then
557             TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
558         else
559             TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}"
560         fi
561         list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \
562               `ls -d ${TCL_BIN_DIR}/..     2>/dev/null` \
563               `ls -d ${TCL_PREFIX}/bin     2>/dev/null`"
564         for i in $list ; do
565             if test -f "$i/${TCLSH_PROG}" ; then
566                 REAL_TCL_BIN_DIR="`cd "$i"; pwd`/"
567                 break
568             fi
569         done
570         TCLSH_PROG="${REAL_TCL_BIN_DIR}${TCLSH_PROG}"
571     fi
572     AC_MSG_RESULT([${TCLSH_PROG}])
573     AC_SUBST(TCLSH_PROG)
574 ])
575
576 #------------------------------------------------------------------------
577 # TEA_PROG_WISH
578 #       Determine the fully qualified path name of the wish executable
579 #       in the Tk build directory or the wish installed in a bin
580 #       directory. This macro will correctly determine the name
581 #       of the wish executable even if wish has not yet been
582 #       built in the build directory. The wish found is always
583 #       associated with a tkConfig.sh file. This wish should be used
584 #       only for running extension test cases. It should never be
585 #       or generation of files (like pkgIndex.tcl) at build time.
586 #
587 # Arguments
588 #       none
589 #
590 # Results
591 #       Subst's the following values:
592 #               WISH_PROG
593 #------------------------------------------------------------------------
594
595 AC_DEFUN([TEA_PROG_WISH], [
596     AC_MSG_CHECKING([for wish])
597     if test -f "${TK_BIN_DIR}/Makefile" ; then
598         # tkConfig.sh is in Tk build directory
599         if test "${TEA_PLATFORM}" = "windows"; then
600             WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}"
601         else
602             WISH_PROG="${TK_BIN_DIR}/wish"
603         fi
604     else
605         # tkConfig.sh is in install location
606         if test "${TEA_PLATFORM}" = "windows"; then
607             WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}"
608         else
609             WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_DBGX}"
610         fi
611         list="`ls -d ${TK_BIN_DIR}/../bin 2>/dev/null` \
612               `ls -d ${TK_BIN_DIR}/..     2>/dev/null` \
613               `ls -d ${TK_PREFIX}/bin     2>/dev/null`"
614         for i in $list ; do
615             if test -f "$i/${WISH_PROG}" ; then
616                 REAL_TK_BIN_DIR="`cd "$i"; pwd`/"
617                 break
618             fi
619         done
620         WISH_PROG="${REAL_TK_BIN_DIR}${WISH_PROG}"
621     fi
622     AC_MSG_RESULT([${WISH_PROG}])
623     AC_SUBST(WISH_PROG)
624 ])
625
626 #------------------------------------------------------------------------
627 # TEA_ENABLE_SHARED --
628 #
629 #       Allows the building of shared libraries
630 #
631 # Arguments:
632 #       none
633 #       
634 # Results:
635 #
636 #       Adds the following arguments to configure:
637 #               --enable-shared=yes|no
638 #
639 #       Defines the following vars:
640 #               STATIC_BUILD    Used for building import/export libraries
641 #                               on Windows.
642 #
643 #       Sets the following vars:
644 #               SHARED_BUILD    Value of 1 or 0
645 #------------------------------------------------------------------------
646
647 AC_DEFUN([TEA_ENABLE_SHARED], [
648     AC_MSG_CHECKING([how to build libraries])
649     AC_ARG_ENABLE(shared,
650         AC_HELP_STRING([--enable-shared],
651             [build and link with shared libraries (default: on)]),
652         [tcl_ok=$enableval], [tcl_ok=yes])
653
654     if test "${enable_shared+set}" = set; then
655         enableval="$enable_shared"
656         tcl_ok=$enableval
657     else
658         tcl_ok=yes
659     fi
660
661     if test "$tcl_ok" = "yes" ; then
662         AC_MSG_RESULT([shared])
663         SHARED_BUILD=1
664     else
665         AC_MSG_RESULT([static])
666         SHARED_BUILD=0
667         AC_DEFINE(STATIC_BUILD, 1, [Is this a static build?])
668     fi
669     AC_SUBST(SHARED_BUILD)
670 ])
671
672 #------------------------------------------------------------------------
673 # TEA_ENABLE_THREADS --
674 #
675 #       Specify if thread support should be enabled.  If "yes" is specified
676 #       as an arg (optional), threads are enabled by default, "no" means
677 #       threads are disabled.  "yes" is the default.
678 #
679 #       TCL_THREADS is checked so that if you are compiling an extension
680 #       against a threaded core, your extension must be compiled threaded
681 #       as well.
682 #
683 #       Note that it is legal to have a thread enabled extension run in a
684 #       threaded or non-threaded Tcl core, but a non-threaded extension may
685 #       only run in a non-threaded Tcl core.
686 #
687 # Arguments:
688 #       none
689 #       
690 # Results:
691 #
692 #       Adds the following arguments to configure:
693 #               --enable-threads
694 #
695 #       Sets the following vars:
696 #               THREADS_LIBS    Thread library(s)
697 #
698 #       Defines the following vars:
699 #               TCL_THREADS
700 #               _REENTRANT
701 #               _THREAD_SAFE
702 #
703 #------------------------------------------------------------------------
704
705 AC_DEFUN([TEA_ENABLE_THREADS], [
706     AC_ARG_ENABLE(threads,
707         AC_HELP_STRING([--enable-threads],
708             [build with threads]),
709         [tcl_ok=$enableval], [tcl_ok=yes])
710
711     if test "${enable_threads+set}" = set; then
712         enableval="$enable_threads"
713         tcl_ok=$enableval
714     else
715         tcl_ok=yes
716     fi
717
718     if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
719         TCL_THREADS=1
720
721         if test "${TEA_PLATFORM}" != "windows" ; then
722             # We are always OK on Windows, so check what this platform wants:
723
724             # USE_THREAD_ALLOC tells us to try the special thread-based
725             # allocator that significantly reduces lock contention
726             AC_DEFINE(USE_THREAD_ALLOC, 1,
727                 [Do we want to use the threaded memory allocator?])
728             AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
729             if test "`uname -s`" = "SunOS" ; then
730                 AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
731                         [Do we really want to follow the standard? Yes we do!])
732             fi
733             AC_DEFINE(_THREAD_SAFE, 1, [Do we want the thread-safe OS API?])
734             AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
735             if test "$tcl_ok" = "no"; then
736                 # Check a little harder for __pthread_mutex_init in the same
737                 # library, as some systems hide it there until pthread.h is
738                 # defined.  We could alternatively do an AC_TRY_COMPILE with
739                 # pthread.h, but that will work with libpthread really doesn't
740                 # exist, like AIX 4.2.  [Bug: 4359]
741                 AC_CHECK_LIB(pthread, __pthread_mutex_init,
742                     tcl_ok=yes, tcl_ok=no)
743             fi
744
745             if test "$tcl_ok" = "yes"; then
746                 # The space is needed
747                 THREADS_LIBS=" -lpthread"
748             else
749                 AC_CHECK_LIB(pthreads, pthread_mutex_init,
750                     tcl_ok=yes, tcl_ok=no)
751                 if test "$tcl_ok" = "yes"; then
752                     # The space is needed
753                     THREADS_LIBS=" -lpthreads"
754                 else
755                     AC_CHECK_LIB(c, pthread_mutex_init,
756                         tcl_ok=yes, tcl_ok=no)
757                     if test "$tcl_ok" = "no"; then
758                         AC_CHECK_LIB(c_r, pthread_mutex_init,
759                             tcl_ok=yes, tcl_ok=no)
760                         if test "$tcl_ok" = "yes"; then
761                             # The space is needed
762                             THREADS_LIBS=" -pthread"
763                         else
764                             TCL_THREADS=0
765                             AC_MSG_WARN([Do not know how to find pthread lib on your system - thread support disabled])
766                         fi
767                     fi
768                 fi
769             fi
770         fi
771     else
772         TCL_THREADS=0
773     fi
774     # Do checking message here to not mess up interleaved configure output
775     AC_MSG_CHECKING([for building with threads])
776     if test "${TCL_THREADS}" = 1; then
777         AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
778         AC_MSG_RESULT([yes (default)])
779     else
780         AC_MSG_RESULT([no])
781     fi
782     # TCL_THREADS sanity checking.  See if our request for building with
783     # threads is the same as the way Tcl was built.  If not, warn the user.
784     case ${TCL_DEFS} in
785         *THREADS=1*)
786             if test "${TCL_THREADS}" = "0"; then
787                 AC_MSG_WARN([
788     Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
789     that IS thread-enabled.  It is recommended to use --enable-threads.])
790             fi
791             ;;
792         *)
793             if test "${TCL_THREADS}" = "1"; then
794                 AC_MSG_WARN([
795     --enable-threads requested, but building against a Tcl that is NOT
796     thread-enabled.  This is an OK configuration that will also run in
797     a thread-enabled core.])
798             fi
799             ;;
800     esac
801     AC_SUBST(TCL_THREADS)
802 ])
803
804 #------------------------------------------------------------------------
805 # TEA_ENABLE_SYMBOLS --
806 #
807 #       Specify if debugging symbols should be used.
808 #       Memory (TCL_MEM_DEBUG) debugging can also be enabled.
809 #
810 # Arguments:
811 #       none
812 #
813 #       TEA varies from core Tcl in that C|LDFLAGS_DEFAULT receives
814 #       the value of C|LDFLAGS_OPTIMIZE|DEBUG already substituted.
815 #       Requires the following vars to be set in the Makefile:
816 #               CFLAGS_DEFAULT
817 #               LDFLAGS_DEFAULT
818 #
819 # Results:
820 #
821 #       Adds the following arguments to configure:
822 #               --enable-symbols
823 #
824 #       Defines the following vars:
825 #               CFLAGS_DEFAULT  Sets to $(CFLAGS_DEBUG) if true
826 #                               Sets to $(CFLAGS_OPTIMIZE) if false
827 #               LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
828 #                               Sets to $(LDFLAGS_OPTIMIZE) if false
829 #               DBGX            Formerly used as debug library extension;
830 #                               always blank now.
831 #
832 #------------------------------------------------------------------------
833
834 AC_DEFUN([TEA_ENABLE_SYMBOLS], [
835     dnl TEA specific: Make sure we are initialized
836     AC_REQUIRE([TEA_CONFIG_CFLAGS])
837     AC_MSG_CHECKING([for build with symbols])
838     AC_ARG_ENABLE(symbols,
839         AC_HELP_STRING([--enable-symbols],
840             [build with debugging symbols (default: off)]),
841         [tcl_ok=$enableval], [tcl_ok=no])
842     DBGX=""
843     if test "$tcl_ok" = "no"; then
844         CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
845         LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
846         AC_MSG_RESULT([no])
847     else
848         CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
849         LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
850         if test "$tcl_ok" = "yes"; then
851             AC_MSG_RESULT([yes (standard debugging)])
852         fi
853     fi
854     # TEA specific:
855     if test "${TEA_PLATFORM}" != "windows" ; then
856         LDFLAGS_DEFAULT="${LDFLAGS}"
857     fi
858     AC_SUBST(CFLAGS_DEFAULT)
859     AC_SUBST(LDFLAGS_DEFAULT)
860     AC_SUBST(TCL_DBGX)
861
862     if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
863         AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?])
864     fi
865
866     if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
867         if test "$tcl_ok" = "all"; then
868             AC_MSG_RESULT([enabled symbols mem debugging])
869         else
870             AC_MSG_RESULT([enabled $tcl_ok debugging])
871         fi
872     fi
873 ])
874
875 #------------------------------------------------------------------------
876 # TEA_ENABLE_LANGINFO --
877 #
878 #       Allows use of modern nl_langinfo check for better l10n.
879 #       This is only relevant for Unix.
880 #
881 # Arguments:
882 #       none
883 #
884 # Results:
885 #
886 #       Adds the following arguments to configure:
887 #               --enable-langinfo=yes|no (default is yes)
888 #
889 #       Defines the following vars:
890 #               HAVE_LANGINFO   Triggers use of nl_langinfo if defined.
891 #
892 #------------------------------------------------------------------------
893
894 AC_DEFUN([TEA_ENABLE_LANGINFO], [
895     AC_ARG_ENABLE(langinfo,
896         AC_HELP_STRING([--enable-langinfo],
897             [use nl_langinfo if possible to determine encoding at startup, otherwise use old heuristic (default: on)]),
898         [langinfo_ok=$enableval], [langinfo_ok=yes])
899
900     HAVE_LANGINFO=0
901     if test "$langinfo_ok" = "yes"; then
902         AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
903     fi
904     AC_MSG_CHECKING([whether to use nl_langinfo])
905     if test "$langinfo_ok" = "yes"; then
906         AC_CACHE_VAL(tcl_cv_langinfo_h, [
907             AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
908                     [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no])])
909         AC_MSG_RESULT([$tcl_cv_langinfo_h])
910         if test $tcl_cv_langinfo_h = yes; then
911             AC_DEFINE(HAVE_LANGINFO, 1, [Do we have nl_langinfo()?])
912         fi
913     else
914         AC_MSG_RESULT([$langinfo_ok])
915     fi
916 ])
917
918 #--------------------------------------------------------------------
919 # TEA_CONFIG_SYSTEM
920 #
921 #       Determine what the system is (some things cannot be easily checked
922 #       on a feature-driven basis, alas). This can usually be done via the
923 #       "uname" command, but there are a few systems, like Next, where
924 #       this doesn't work.
925 #
926 # Arguments:
927 #       none
928 #
929 # Results:
930 #       Defines the following var:
931 #
932 #       system -        System/platform/version identification code.
933 #
934 #--------------------------------------------------------------------
935
936 AC_DEFUN([TEA_CONFIG_SYSTEM], [
937     AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
938         # TEA specific:
939         if test "${TEA_PLATFORM}" = "windows" ; then
940             tcl_cv_sys_version=windows
941         elif test -f /usr/lib/NextStep/software_version; then
942             tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
943         else
944             tcl_cv_sys_version=`uname -s`-`uname -r`
945             if test "$?" -ne 0 ; then
946                 AC_MSG_WARN([can't find uname command])
947                 tcl_cv_sys_version=unknown
948             else
949                 # Special check for weird MP-RAS system (uname returns weird
950                 # results, and the version is kept in special file).
951
952                 if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
953                     tcl_cv_sys_version=MP-RAS-`awk '{print $[3]}' /etc/.relid`
954                 fi
955                 if test "`uname -s`" = "AIX" ; then
956                     tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
957                 fi
958             fi
959         fi
960     ])
961     system=$tcl_cv_sys_version
962 ])
963
964 #--------------------------------------------------------------------
965 # TEA_CONFIG_CFLAGS
966 #
967 #       Try to determine the proper flags to pass to the compiler
968 #       for building shared libraries and other such nonsense.
969 #
970 # Arguments:
971 #       none
972 #
973 # Results:
974 #
975 #       Defines and substitutes the following vars:
976 #
977 #       DL_OBJS -       Name of the object file that implements dynamic
978 #                       loading for Tcl on this system.
979 #       DL_LIBS -       Library file(s) to include in tclsh and other base
980 #                       applications in order for the "load" command to work.
981 #       LDFLAGS -      Flags to pass to the compiler when linking object
982 #                       files into an executable application binary such
983 #                       as tclsh.
984 #       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
985 #                       that tell the run-time dynamic linker where to look
986 #                       for shared libraries such as libtcl.so.  Depends on
987 #                       the variable LIB_RUNTIME_DIR in the Makefile. Could
988 #                       be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
989 #       CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
990 #                       that tell the run-time dynamic linker where to look
991 #                       for shared libraries such as libtcl.so.  Depends on
992 #                       the variable LIB_RUNTIME_DIR in the Makefile.
993 #       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
994 #                       of a shared library (may request position-independent
995 #                       code, among other things).
996 #       SHLIB_LD -      Base command to use for combining object files
997 #                       into a shared library.
998 #       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
999 #                       creating shared libraries.  This symbol typically
1000 #                       goes at the end of the "ld" commands that build
1001 #                       shared libraries. The value of the symbol is
1002 #                       "${LIBS}" if all of the dependent libraries should
1003 #                       be specified when creating a shared library.  If
1004 #                       dependent libraries should not be specified (as on
1005 #                       SunOS 4.x, where they cause the link to fail, or in
1006 #                       general if Tcl and Tk aren't themselves shared
1007 #                       libraries), then this symbol has an empty string
1008 #                       as its value.
1009 #       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
1010 #                       extensions.  An empty string means we don't know how
1011 #                       to use shared libraries on this platform.
1012 #       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
1013 #                       in a static or shared library name, using the $VERSION variable
1014 #                       to put the version in the right place.  This is used
1015 #                       by platforms that need non-standard library names.
1016 #                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
1017 #                       to have a version after the .so, and ${VERSION}.a
1018 #                       on AIX, since a shared library needs to have
1019 #                       a .a extension whereas shared objects for loadable
1020 #                       extensions have a .so extension.  Defaults to
1021 #                       ${VERSION}${SHLIB_SUFFIX}.
1022 #       TCL_NEEDS_EXP_FILE -
1023 #                       1 means that an export file is needed to link to a
1024 #                       shared library.
1025 #       TCL_EXP_FILE -  The name of the installed export / import file which
1026 #                       should be used to link to the Tcl shared library.
1027 #                       Empty if Tcl is unshared.
1028 #       TCL_BUILD_EXP_FILE -
1029 #                       The name of the built export / import file which
1030 #                       should be used to link to the Tcl shared library.
1031 #                       Empty if Tcl is unshared.
1032 #       CFLAGS_DEBUG -
1033 #                       Flags used when running the compiler in debug mode
1034 #       CFLAGS_OPTIMIZE -
1035 #                       Flags used when running the compiler in optimize mode
1036 #       CFLAGS -        Additional CFLAGS added as necessary (usually 64-bit)
1037 #
1038 #--------------------------------------------------------------------
1039
1040 AC_DEFUN([TEA_CONFIG_CFLAGS], [
1041     dnl TEA specific: Make sure we are initialized
1042     AC_REQUIRE([TEA_INIT])
1043
1044     # Step 0.a: Enable 64 bit support?
1045
1046     AC_MSG_CHECKING([if 64bit support is requested])
1047     AC_ARG_ENABLE(64bit,
1048         AC_HELP_STRING([--enable-64bit],
1049             [enable 64bit support (default: off)]),
1050         [do64bit=$enableval], [do64bit=no])
1051     AC_MSG_RESULT([$do64bit])
1052
1053     # Step 0.b: Enable Solaris 64 bit VIS support?
1054
1055     AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
1056     AC_ARG_ENABLE(64bit-vis,
1057         AC_HELP_STRING([--enable-64bit-vis],
1058             [enable 64bit Sparc VIS support (default: off)]),
1059         [do64bitVIS=$enableval], [do64bitVIS=no])
1060     AC_MSG_RESULT([$do64bitVIS])
1061     # Force 64bit on with VIS
1062     AS_IF([test "$do64bitVIS" = "yes"], [do64bit=yes])
1063
1064     # Step 0.c: Check if visibility support is available. Do this here so
1065     # that platform specific alternatives can be used below if this fails.
1066
1067     AC_CACHE_CHECK([if compiler supports visibility "hidden"],
1068         tcl_cv_cc_visibility_hidden, [
1069         hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
1070         AC_TRY_LINK([
1071             extern __attribute__((__visibility__("hidden"))) void f(void);
1072             void f(void) {}], [f();], tcl_cv_cc_visibility_hidden=yes,
1073             tcl_cv_cc_visibility_hidden=no)
1074         CFLAGS=$hold_cflags])
1075     AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [
1076         AC_DEFINE(MODULE_SCOPE,
1077             [extern __attribute__((__visibility__("hidden")))],
1078             [Compiler support for module scope symbols])
1079     ])
1080
1081     # Step 0.d: Disable -rpath support?
1082
1083     AC_MSG_CHECKING([if rpath support is requested])
1084     AC_ARG_ENABLE(rpath,
1085         AC_HELP_STRING([--disable-rpath],
1086             [disable rpath support (default: on)]),
1087         [doRpath=$enableval], [doRpath=yes])
1088     AC_MSG_RESULT([$doRpath])
1089
1090     # TEA specific: Cross-compiling options for Windows/CE builds?
1091
1092     AS_IF([test "${TEA_PLATFORM}" = windows], [
1093         AC_MSG_CHECKING([if Windows/CE build is requested])
1094         AC_ARG_ENABLE(wince,
1095             AC_HELP_STRING([--enable-wince],
1096                 [enable Win/CE support (where applicable)]),
1097             [doWince=$enableval], [doWince=no])
1098         AC_MSG_RESULT([$doWince])
1099     ])
1100
1101     # Step 1: set the variable "system" to hold the name and version number
1102     # for the system.
1103
1104     TEA_CONFIG_SYSTEM
1105
1106     # Step 2: check for existence of -ldl library.  This is needed because
1107     # Linux can use either -ldl or -ldld for dynamic loading.
1108
1109     AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
1110
1111     # Require ranlib early so we can override it in special cases below.
1112
1113     AC_REQUIRE([AC_PROG_RANLIB])
1114
1115     # Step 3: set configuration options based on system name and version.
1116     # This is similar to Tcl's unix/tcl.m4 except that we've added a
1117     # "windows" case.
1118
1119     do64bit_ok=no
1120     LDFLAGS_ORIG="$LDFLAGS"
1121     # When ld needs options to work in 64-bit mode, put them in
1122     # LDFLAGS_ARCH so they eventually end up in LDFLAGS even if [load]
1123     # is disabled by the user. [Bug 1016796]
1124     LDFLAGS_ARCH=""
1125     TCL_EXPORT_FILE_SUFFIX=""
1126     UNSHARED_LIB_SUFFIX=""
1127     # TEA specific: use PACKAGE_VERSION instead of VERSION
1128     TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`'
1129     ECHO_VERSION='`echo ${PACKAGE_VERSION}`'
1130     TCL_LIB_VERSIONS_OK=ok
1131     CFLAGS_DEBUG=-g
1132     CFLAGS_OPTIMIZE=-O
1133     AS_IF([test "$GCC" = yes], [
1134         # TEA specific:
1135         CFLAGS_OPTIMIZE=-O2
1136         CFLAGS_WARNING="-Wall"
1137     ], [CFLAGS_WARNING=""])
1138     TCL_NEEDS_EXP_FILE=0
1139     TCL_BUILD_EXP_FILE=""
1140     TCL_EXP_FILE=""
1141 dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
1142 dnl AC_CHECK_TOOL(AR, ar)
1143     AC_CHECK_PROG(AR, ar, ar)
1144     STLIB_LD='${AR} cr'
1145     LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
1146     AS_IF([test "x$SHLIB_VERSION" = x],[SHLIB_VERSION="1.0"])
1147     case $system in
1148         # TEA specific:
1149         windows)
1150             # This is a 2-stage check to make sure we have the 64-bit SDK
1151             # We have to know where the SDK is installed.
1152             # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
1153             # MACHINE is IX86 for LINK, but this is used by the manifest,
1154             # which requires x86|amd64|ia64.
1155             MACHINE="X86"
1156             if test "$do64bit" != "no" ; then
1157                 if test "x${MSSDK}x" = "xx" ; then
1158                     MSSDK="C:/Progra~1/Microsoft Platform SDK"
1159                 fi
1160                 MSSDK=`echo "$MSSDK" | sed -e  's!\\\!/!g'`
1161                 PATH64=""
1162                 case "$do64bit" in
1163                     amd64|x64|yes)
1164                         MACHINE="AMD64" ; # default to AMD64 64-bit build
1165                         PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
1166                         ;;
1167                     ia64)
1168                         MACHINE="IA64"
1169                         PATH64="${MSSDK}/Bin/Win64"
1170                         ;;
1171                 esac
1172                 if test ! -d "${PATH64}" ; then
1173                     AC_MSG_WARN([Could not find 64-bit $MACHINE SDK to enable 64bit mode])
1174                     AC_MSG_WARN([Ensure latest Platform SDK is installed])
1175                     do64bit="no"
1176                 else
1177                     AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
1178                     do64bit_ok="yes"
1179                 fi
1180             fi
1181
1182             if test "$doWince" != "no" ; then
1183                 if test "$do64bit" != "no" ; then
1184                     AC_MSG_ERROR([Windows/CE and 64-bit builds incompatible])
1185                 fi
1186                 if test "$GCC" = "yes" ; then
1187                     AC_MSG_ERROR([Windows/CE and GCC builds incompatible])
1188                 fi
1189                 TEA_PATH_CELIB
1190                 # Set defaults for common evc4/PPC2003 setup
1191                 # Currently Tcl requires 300+, possibly 420+ for sockets
1192                 CEVERSION=420;          # could be 211 300 301 400 420 ...
1193                 TARGETCPU=ARMV4;        # could be ARMV4 ARM MIPS SH3 X86 ...
1194                 ARCH=ARM;               # could be ARM MIPS X86EM ...
1195                 PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002"
1196                 if test "$doWince" != "yes"; then
1197                     # If !yes then the user specified something
1198                     # Reset ARCH to allow user to skip specifying it
1199                     ARCH=
1200                     eval `echo $doWince | awk -F, '{ \
1201             if (length([$]1)) { printf "CEVERSION=\"%s\"\n", [$]1; \
1202             if ([$]1 < 400)   { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \
1203             if (length([$]2)) { printf "TARGETCPU=\"%s\"\n", toupper([$]2) }; \
1204             if (length([$]3)) { printf "ARCH=\"%s\"\n", toupper([$]3) }; \
1205             if (length([$]4)) { printf "PLATFORM=\"%s\"\n", [$]4 }; \
1206                     }'`
1207                     if test "x${ARCH}" = "x" ; then
1208                         ARCH=$TARGETCPU;
1209                     fi
1210                 fi
1211                 OSVERSION=WCE$CEVERSION;
1212                 if test "x${WCEROOT}" = "x" ; then
1213                         WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0"
1214                     if test ! -d "${WCEROOT}" ; then
1215                         WCEROOT="C:/Program Files/Microsoft eMbedded Tools"
1216                     fi
1217                 fi
1218                 if test "x${SDKROOT}" = "x" ; then
1219                     SDKROOT="C:/Program Files/Windows CE Tools"
1220                     if test ! -d "${SDKROOT}" ; then
1221                         SDKROOT="C:/Windows CE Tools"
1222                     fi
1223                 fi
1224                 WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'`
1225                 SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'`
1226                 if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \
1227                     -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
1228                     AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]])
1229                     doWince="no"
1230                 else
1231                     # We could PATH_NOSPACE these, but that's not important,
1232                     # as long as we quote them when used.
1233                     CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include"
1234                     if test -d "${CEINCLUDE}/${TARGETCPU}" ; then
1235                         CEINCLUDE="${CEINCLUDE}/${TARGETCPU}"
1236                     fi
1237                     CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"
1238                 fi
1239             fi
1240
1241             if test "$GCC" != "yes" ; then
1242                 if test "${SHARED_BUILD}" = "0" ; then
1243                     runtime=-MT
1244                 else
1245                     runtime=-MD
1246                 fi
1247
1248                 if test "$do64bit" != "no" ; then
1249                     # All this magic is necessary for the Win64 SDK RC1 - hobbs
1250                     CC="\"${PATH64}/cl.exe\""
1251                     CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\""
1252                     RC="\"${MSSDK}/bin/rc.exe\""
1253                     lflags="-nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
1254                     LINKBIN="\"${PATH64}/link.exe\""
1255                     CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d"
1256                     CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}"
1257                     # Avoid 'unresolved external symbol __security_cookie'
1258                     # errors, c.f. http://support.microsoft.com/?id=894573
1259                     TEA_ADD_LIBS([bufferoverflowU.lib])
1260                 elif test "$doWince" != "no" ; then
1261                     CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin"
1262                     if test "${TARGETCPU}" = "X86"; then
1263                         CC="\"${CEBINROOT}/cl.exe\""
1264                     else
1265                         CC="\"${CEBINROOT}/cl${ARCH}.exe\""
1266                     fi
1267                     CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
1268                     RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
1269                     arch=`echo ${ARCH} | awk '{print tolower([$]0)}'`
1270                     defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS"
1271                     if test "${SHARED_BUILD}" = "1" ; then
1272                         # Static CE builds require static celib as well
1273                         defs="${defs} _DLL"
1274                     fi
1275                     for i in $defs ; do
1276                         AC_DEFINE_UNQUOTED($i, 1, [WinCE def ]$i)
1277                     done
1278                     AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION, [_WIN32_WCE version])
1279                     AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION, [UNDER_CE version])
1280                     CFLAGS_DEBUG="-nologo -Zi -Od"
1281                     CFLAGS_OPTIMIZE="-nologo -Ox"
1282                     lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'`
1283                     lflags="-MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo"
1284                     LINKBIN="\"${CEBINROOT}/link.exe\""
1285                     AC_SUBST(CELIB_DIR)
1286                 else
1287                     RC="rc"
1288                     lflags="-nologo"
1289                     LINKBIN="link"
1290                     CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d"
1291                     CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}"
1292                 fi
1293             fi
1294
1295             if test "$GCC" = "yes"; then
1296                 # mingw gcc mode
1297                 RC="windres"
1298                 CFLAGS_DEBUG="-g"
1299                 CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
1300                 SHLIB_LD="$CC -shared"
1301                 UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1302                 LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}"
1303                 LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}"
1304             else
1305                 SHLIB_LD="${LINKBIN} -dll ${lflags}"
1306                 # link -lib only works when -lib is the first arg
1307                 STLIB_LD="${LINKBIN} -lib ${lflags}"
1308                 UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.lib'
1309                 PATHTYPE=-w
1310                 # For information on what debugtype is most useful, see:
1311                 # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp
1312                 # and also
1313                 # http://msdn2.microsoft.com/en-us/library/y0zzbyt4%28VS.80%29.aspx
1314                 # This essentially turns it all on.
1315                 LDFLAGS_DEBUG="-debug -debugtype:cv"
1316                 LDFLAGS_OPTIMIZE="-release"
1317                 if test "$doWince" != "no" ; then
1318                     LDFLAGS_CONSOLE="-link ${lflags}"
1319                     LDFLAGS_WINDOW=${LDFLAGS_CONSOLE}
1320                 else
1321                     LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
1322                     LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
1323                 fi
1324             fi
1325
1326             SHLIB_LD_LIBS='${LIBS}'
1327             SHLIB_SUFFIX=".dll"
1328             SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll'
1329
1330             TCL_LIB_VERSIONS_OK=nodots
1331             # Bogus to avoid getting this turned off
1332             DL_OBJS="tclLoadNone.obj"
1333             ;;
1334         AIX-*)
1335             AS_IF([test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"], [
1336                 # AIX requires the _r compiler when gcc isn't being used
1337                 case "${CC}" in
1338                     *_r|*_r\ *)
1339                         # ok ...
1340                         ;;
1341                     *)
1342                         # Make sure only first arg gets _r
1343                         CC=`echo "$CC" | sed -e 's/^\([[^ ]]*\)/\1_r/'`
1344                         ;;
1345                 esac
1346                 AC_MSG_RESULT([Using $CC for compiling with threads])
1347             ])
1348             LIBS="$LIBS -lc"
1349             SHLIB_CFLAGS=""
1350             SHLIB_LD_LIBS='${LIBS}'
1351             SHLIB_SUFFIX=".so"
1352
1353             DL_OBJS="tclLoadDl.o"
1354             LD_LIBRARY_PATH_VAR="LIBPATH"
1355
1356             # Check to enable 64-bit flags for compiler/linker on AIX 4+
1357             AS_IF([test "$do64bit" = yes -a "`uname -v`" -gt 3], [
1358                 AS_IF([test "$GCC" = yes], [
1359                     AC_MSG_WARN([64bit mode not supported with GCC on $system])
1360                 ], [
1361                     do64bit_ok=yes
1362                     CFLAGS="$CFLAGS -q64"
1363                     LDFLAGS_ARCH="-q64"
1364                     RANLIB="${RANLIB} -X64"
1365                     AR="${AR} -X64"
1366                     SHLIB_LD_FLAGS="-b64"
1367                 ])
1368             ])
1369
1370             AS_IF([test "`uname -m`" = ia64], [
1371                 # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
1372                 SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1373                 # AIX-5 has dl* in libc.so
1374                 DL_LIBS=""
1375                 AS_IF([test "$GCC" = yes], [
1376                     CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1377                 ], [
1378                     CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
1379                 ])
1380                 LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1381             ], [
1382                 AS_IF([test "$GCC" = yes], [SHLIB_LD='${CC} -shared'], [
1383                     SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
1384                 ])
1385                 SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix ${SHLIB_LD} ${SHLIB_LD_FLAGS}"
1386                 DL_LIBS="-ldl"
1387                 CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1388                 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1389                 TCL_NEEDS_EXP_FILE=1
1390                 # TEA specific: use PACKAGE_VERSION instead of VERSION
1391                 TCL_EXPORT_FILE_SUFFIX='${PACKAGE_VERSION}.exp'
1392             ])
1393
1394             # AIX v<=4.1 has some different flags than 4.2+
1395             AS_IF([test "$system" = "AIX-4.1" -o "`uname -v`" -lt 4], [
1396                 AC_LIBOBJ([tclLoadAix])
1397                 DL_LIBS="-lld"
1398             ])
1399
1400             # On AIX <=v4 systems, libbsd.a has to be linked in to support
1401             # non-blocking file IO.  This library has to be linked in after
1402             # the MATH_LIBS or it breaks the pow() function.  The way to
1403             # insure proper sequencing, is to add it to the tail of MATH_LIBS.
1404             # This library also supplies gettimeofday.
1405             #
1406             # AIX does not have a timezone field in struct tm. When the AIX
1407             # bsd library is used, the timezone global and the gettimeofday
1408             # methods are to be avoided for timezone deduction instead, we
1409             # deduce the timezone by comparing the localtime result on a
1410             # known GMT value.
1411
1412             AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
1413             AS_IF([test $libbsd = yes], [
1414                 MATH_LIBS="$MATH_LIBS -lbsd"
1415                 AC_DEFINE(USE_DELTA_FOR_TZ, 1, [Do we need a special AIX hack for timezones?])
1416             ])
1417             ;;
1418         BeOS*)
1419             SHLIB_CFLAGS="-fPIC"
1420             SHLIB_LD='${CC} -nostart'
1421             SHLIB_LD_LIBS='${LIBS}'
1422             SHLIB_SUFFIX=".so"
1423             DL_OBJS="tclLoadDl.o"
1424             DL_LIBS="-ldl"
1425
1426             #-----------------------------------------------------------
1427             # Check for inet_ntoa in -lbind, for BeOS (which also needs
1428             # -lsocket, even if the network functions are in -lnet which
1429             # is always linked to, for compatibility.
1430             #-----------------------------------------------------------
1431             AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"])
1432             ;;
1433         BSD/OS-2.1*|BSD/OS-3*)
1434             SHLIB_CFLAGS=""
1435             SHLIB_LD="shlicc -r"
1436             SHLIB_LD_LIBS='${LIBS}'
1437             SHLIB_SUFFIX=".so"
1438             DL_OBJS="tclLoadDl.o"
1439             DL_LIBS="-ldl"
1440             CC_SEARCH_FLAGS=""
1441             LD_SEARCH_FLAGS=""
1442             ;;
1443         BSD/OS-4.*)
1444             SHLIB_CFLAGS="-export-dynamic -fPIC"
1445             SHLIB_LD='${CC} -shared'
1446             SHLIB_LD_LIBS='${LIBS}'
1447             SHLIB_SUFFIX=".so"
1448             DL_OBJS="tclLoadDl.o"
1449             DL_LIBS="-ldl"
1450             LDFLAGS="$LDFLAGS -export-dynamic"
1451             CC_SEARCH_FLAGS=""
1452             LD_SEARCH_FLAGS=""
1453             ;;
1454         dgux*)
1455             SHLIB_CFLAGS="-K PIC"
1456             SHLIB_LD='${CC} -G'
1457             SHLIB_LD_LIBS=""
1458             SHLIB_SUFFIX=".so"
1459             DL_OBJS="tclLoadDl.o"
1460             DL_LIBS="-ldl"
1461             CC_SEARCH_FLAGS=""
1462             LD_SEARCH_FLAGS=""
1463             ;;
1464         HP-UX-*.11.*)
1465             # Use updated header definitions where possible
1466             AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Do we want to use the XOPEN network library?])
1467             # TEA specific: Needed by Tcl, but not most extensions
1468             #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?])
1469             #LIBS="$LIBS -lxnet"               # Use the XOPEN network library
1470
1471             AS_IF([test "`uname -m`" = ia64], [
1472                 SHLIB_SUFFIX=".so"
1473                 # Use newer C++ library for C++ extensions
1474                 #if test "$GCC" != "yes" ; then
1475                 #   CPPFLAGS="-AA"
1476                 #fi
1477             ], [
1478                 SHLIB_SUFFIX=".sl"
1479             ])
1480             AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1481             AS_IF([test "$tcl_ok" = yes], [
1482                 SHLIB_LD_LIBS='${LIBS}'
1483                 DL_OBJS="tclLoadShl.o"
1484                 DL_LIBS="-ldld"
1485                 LDFLAGS="$LDFLAGS -E"
1486                 CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1487                 LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1488                 LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1489             ])
1490             AS_IF([test "$GCC" = yes], [
1491                 SHLIB_LD='${CC} -shared'
1492                 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1493             ], [
1494                 CFLAGS="$CFLAGS -z"
1495                 # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
1496                 #CFLAGS="$CFLAGS +DAportable"
1497                 SHLIB_CFLAGS="+z"
1498                 SHLIB_LD="ld -b"
1499             ])
1500
1501             # Check to enable 64-bit flags for compiler/linker
1502             AS_IF([test "$do64bit" = "yes"], [
1503                 AS_IF([test "$GCC" = yes], [
1504                     case `${CC} -dumpmachine` in
1505                         hppa64*)
1506                             # 64-bit gcc in use.  Fix flags for GNU ld.
1507                             do64bit_ok=yes
1508                             SHLIB_LD='${CC} -shared'
1509                             SHLIB_LD_LIBS='${LIBS}'
1510                             AS_IF([test $doRpath = yes], [
1511                                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1512                             LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1513                             ;;
1514                         *)
1515                             AC_MSG_WARN([64bit mode not supported with GCC on $system])
1516                             ;;
1517                     esac
1518                 ], [
1519                     do64bit_ok=yes
1520                     CFLAGS="$CFLAGS +DD64"
1521                     LDFLAGS_ARCH="+DD64"
1522                 ])
1523             ]) ;;
1524         HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
1525             SHLIB_SUFFIX=".sl"
1526             AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1527             AS_IF([test "$tcl_ok" = yes], [
1528                 SHLIB_CFLAGS="+z"
1529                 SHLIB_LD="ld -b"
1530                 SHLIB_LD_LIBS=""
1531                 DL_OBJS="tclLoadShl.o"
1532                 DL_LIBS="-ldld"
1533                 LDFLAGS="$LDFLAGS -Wl,-E"
1534                 CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1535                 LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1536                 LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1537             ]) ;;
1538         IRIX-5.*)
1539             SHLIB_CFLAGS=""
1540             SHLIB_LD="ld -shared -rdata_shared"
1541             SHLIB_LD_LIBS='${LIBS}'
1542             SHLIB_SUFFIX=".so"
1543             DL_OBJS="tclLoadDl.o"
1544             DL_LIBS=""
1545             AS_IF([test $doRpath = yes], [
1546                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1547                 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
1548             ;;
1549         IRIX-6.*)
1550             SHLIB_CFLAGS=""
1551             SHLIB_LD="ld -n32 -shared -rdata_shared"
1552             SHLIB_LD_LIBS='${LIBS}'
1553             SHLIB_SUFFIX=".so"
1554             DL_OBJS="tclLoadDl.o"
1555             DL_LIBS=""
1556             AS_IF([test $doRpath = yes], [
1557                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1558                 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
1559             AS_IF([test "$GCC" = yes], [
1560                 CFLAGS="$CFLAGS -mabi=n32"
1561                 LDFLAGS="$LDFLAGS -mabi=n32"
1562             ], [
1563                 case $system in
1564                     IRIX-6.3)
1565                         # Use to build 6.2 compatible binaries on 6.3.
1566                         CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS"
1567                         ;;
1568                     *)
1569                         CFLAGS="$CFLAGS -n32"
1570                         ;;
1571                 esac
1572                 LDFLAGS="$LDFLAGS -n32"
1573             ])
1574             ;;
1575         IRIX64-6.*)
1576             SHLIB_CFLAGS=""
1577             SHLIB_LD="ld -n32 -shared -rdata_shared"
1578             SHLIB_LD_LIBS='${LIBS}'
1579             SHLIB_SUFFIX=".so"
1580             DL_OBJS="tclLoadDl.o"
1581             DL_LIBS=""
1582             AS_IF([test $doRpath = yes], [
1583                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1584                 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
1585
1586             # Check to enable 64-bit flags for compiler/linker
1587
1588             AS_IF([test "$do64bit" = yes], [
1589                 AS_IF([test "$GCC" = yes], [
1590                     AC_MSG_WARN([64bit mode not supported by gcc])
1591                 ], [
1592                     do64bit_ok=yes
1593                     SHLIB_LD="ld -64 -shared -rdata_shared"
1594                     CFLAGS="$CFLAGS -64"
1595                     LDFLAGS_ARCH="-64"
1596                 ])
1597             ])
1598             ;;
1599         Linux*)
1600             SHLIB_CFLAGS="-fPIC"
1601             SHLIB_LD_LIBS='${LIBS}'
1602             SHLIB_SUFFIX=".so"
1603
1604             # TEA specific:
1605             CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
1606             # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
1607             # when you inline the string and math operations.  Turn this off to
1608             # get rid of the warnings.
1609             #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
1610
1611             # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
1612             SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS_DEFAULT}'
1613             DL_OBJS="tclLoadDl.o"
1614             DL_LIBS="-ldl"
1615             LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1616             AS_IF([test $doRpath = yes], [
1617                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1618             LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1619             AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"])
1620             AS_IF([test $do64bit = yes], [
1621                 AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
1622                     hold_cflags=$CFLAGS
1623                     CFLAGS="$CFLAGS -m64"
1624                     AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no)
1625                     CFLAGS=$hold_cflags])
1626                 AS_IF([test $tcl_cv_cc_m64 = yes], [
1627                     CFLAGS="$CFLAGS -m64"
1628                     do64bit_ok=yes
1629                 ])
1630            ])
1631
1632             # The combo of gcc + glibc has a bug related to inlining of
1633             # functions like strtod(). The -fno-builtin flag should address
1634             # this problem but it does not work. The -fno-inline flag is kind
1635             # of overkill but it works. Disable inlining only when one of the
1636             # files in compat/*.c is being linked in.
1637
1638             AS_IF([test x"${USE_COMPAT}" != x],[CFLAGS="$CFLAGS -fno-inline"])
1639
1640             ;;
1641         GNU*)
1642             SHLIB_CFLAGS="-fPIC"
1643             SHLIB_LD_LIBS='${LIBS}'
1644             SHLIB_SUFFIX=".so"
1645
1646             SHLIB_LD='${CC} -shared'
1647             DL_OBJS=""
1648             DL_LIBS="-ldl"
1649             LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1650             CC_SEARCH_FLAGS=""
1651             LD_SEARCH_FLAGS=""
1652             AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"])
1653             ;;
1654         Lynx*)
1655             SHLIB_CFLAGS="-fPIC"
1656             SHLIB_LD_LIBS='${LIBS}'
1657             SHLIB_SUFFIX=".so"
1658             CFLAGS_OPTIMIZE=-02
1659             SHLIB_LD='${CC} -shared'
1660             DL_OBJS="tclLoadDl.o"
1661             DL_LIBS="-mshared -ldl"
1662             LD_FLAGS="-Wl,--export-dynamic"
1663             AS_IF([test $doRpath = yes], [
1664                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1665                 LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1666             ;;
1667         MP-RAS-02*)
1668             SHLIB_CFLAGS="-K PIC"
1669             SHLIB_LD='${CC} -G'
1670             SHLIB_LD_LIBS=""
1671             SHLIB_SUFFIX=".so"
1672             DL_OBJS="tclLoadDl.o"
1673             DL_LIBS="-ldl"
1674             CC_SEARCH_FLAGS=""
1675             LD_SEARCH_FLAGS=""
1676             ;;
1677         MP-RAS-*)
1678             SHLIB_CFLAGS="-K PIC"
1679             SHLIB_LD='${CC} -G'
1680             SHLIB_LD_LIBS=""
1681             SHLIB_SUFFIX=".so"
1682             DL_OBJS="tclLoadDl.o"
1683             DL_LIBS="-ldl"
1684             LDFLAGS="$LDFLAGS -Wl,-Bexport"
1685             CC_SEARCH_FLAGS=""
1686             LD_SEARCH_FLAGS=""
1687             ;;
1688         NetBSD-1.*|FreeBSD-[[1-2]].*)
1689             SHLIB_CFLAGS="-fPIC"
1690             SHLIB_LD="ld -Bshareable -x"
1691             SHLIB_LD_LIBS='${LIBS}'
1692             SHLIB_SUFFIX=".so"
1693             DL_OBJS="tclLoadDl.o"
1694             DL_LIBS=""
1695             AS_IF([test $doRpath = yes], [
1696                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1697                 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
1698             AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
1699                 AC_EGREP_CPP(yes, [
1700 #ifdef __ELF__
1701         yes
1702 #endif
1703                 ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
1704             AS_IF([test $tcl_cv_ld_elf = yes], [
1705                 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
1706             ], [
1707                 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
1708             ])
1709
1710             # Ancient FreeBSD doesn't handle version numbers with dots.
1711
1712             UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1713             TCL_LIB_VERSIONS_OK=nodots
1714             ;;
1715         OpenBSD-*)
1716             SHLIB_CFLAGS="-fPIC"
1717             SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
1718             SHLIB_LD_LIBS='${LIBS}'
1719             SHLIB_SUFFIX=".so"
1720             DL_OBJS="tclLoadDl.o"
1721             DL_LIBS=""
1722             AS_IF([test $doRpath = yes], [
1723                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1724             LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1725             SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
1726             AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
1727                 AC_EGREP_CPP(yes, [
1728 #ifdef __ELF__
1729         yes
1730 #endif
1731                 ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
1732             AS_IF([test $tcl_cv_ld_elf = yes], [
1733                 LDFLAGS=-Wl,-export-dynamic
1734             ], [LDFLAGS=""])
1735
1736             # OpenBSD doesn't do version numbers with dots.
1737             UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1738             TCL_LIB_VERSIONS_OK=nodots
1739             ;;
1740         NetBSD-*|FreeBSD-*)
1741             # FreeBSD 3.* and greater have ELF.
1742             # NetBSD 2.* has ELF and can use 'cc -shared' to build shared libs
1743             SHLIB_CFLAGS="-fPIC"
1744             SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
1745             SHLIB_LD_LIBS='${LIBS}'
1746             SHLIB_SUFFIX=".so"
1747             DL_OBJS="tclLoadDl.o"
1748             DL_LIBS=""
1749             LDFLAGS="$LDFLAGS -export-dynamic"
1750             AS_IF([test $doRpath = yes], [
1751                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1752             LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1753             AS_IF([test "${TCL_THREADS}" = "1"], [
1754                 # The -pthread needs to go in the CFLAGS, not LIBS
1755                 LIBS=`echo $LIBS | sed s/-pthread//`
1756                 CFLAGS="$CFLAGS -pthread"
1757                 LDFLAGS="$LDFLAGS -pthread"
1758             ])
1759             case $system in
1760             FreeBSD-3.*)
1761                 # FreeBSD-3 doesn't handle version numbers with dots.
1762                 UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1763                 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
1764                 TCL_LIB_VERSIONS_OK=nodots
1765                 ;;
1766             esac
1767             ;;
1768         Darwin-*)
1769             CFLAGS_OPTIMIZE="-Os"
1770             SHLIB_CFLAGS="-fno-common"
1771             # To avoid discrepancies between what headers configure sees during
1772             # preprocessing tests and compiling tests, move any -isysroot and
1773             # -mmacosx-version-min flags from CFLAGS to CPPFLAGS:
1774             CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \
1775                 awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
1776                 if ([$]i~/^(isysroot|mmacosx-version-min)/) print "-"[$]i}'`"
1777             CFLAGS="`echo " ${CFLAGS}" | \
1778                 awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
1779                 if (!([$]i~/^(isysroot|mmacosx-version-min)/)) print "-"[$]i}'`"
1780             AS_IF([test $do64bit = yes], [
1781                 case `arch` in
1782                     ppc)
1783                         AC_CACHE_CHECK([if compiler accepts -arch ppc64 flag],
1784                                 tcl_cv_cc_arch_ppc64, [
1785                             hold_cflags=$CFLAGS
1786                             CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1787                             AC_TRY_LINK(,, tcl_cv_cc_arch_ppc64=yes,
1788                                     tcl_cv_cc_arch_ppc64=no)
1789                             CFLAGS=$hold_cflags])
1790                         AS_IF([test $tcl_cv_cc_arch_ppc64 = yes], [
1791                             CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1792                             do64bit_ok=yes
1793                         ]);;
1794                     i386)
1795                         AC_CACHE_CHECK([if compiler accepts -arch x86_64 flag],
1796                                 tcl_cv_cc_arch_x86_64, [
1797                             hold_cflags=$CFLAGS
1798                             CFLAGS="$CFLAGS -arch x86_64"
1799                             AC_TRY_LINK(,, tcl_cv_cc_arch_x86_64=yes,
1800                                     tcl_cv_cc_arch_x86_64=no)
1801                             CFLAGS=$hold_cflags])
1802                         AS_IF([test $tcl_cv_cc_arch_x86_64 = yes], [
1803                             CFLAGS="$CFLAGS -arch x86_64"
1804                             do64bit_ok=yes
1805                         ]);;
1806                     *)
1807                         AC_MSG_WARN([Don't know how enable 64-bit on architecture `arch`]);;
1808                 esac
1809             ], [
1810                 # Check for combined 32-bit and 64-bit fat build
1811                 AS_IF([echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64) ' \
1812                     && echo "$CFLAGS " |grep -E -q -- '-arch (ppc|i386) '], [
1813                     fat_32_64=yes])
1814             ])
1815             # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
1816             SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}'
1817             AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
1818                 hold_ldflags=$LDFLAGS
1819                 LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
1820                 AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
1821                 LDFLAGS=$hold_ldflags])
1822             AS_IF([test $tcl_cv_ld_single_module = yes], [
1823                 SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
1824             ])
1825             # TEA specific: link shlib with current and compatiblity version flags
1826             vers=`echo ${PACKAGE_VERSION} | sed -e 's/^\([[0-9]]\{1,5\}\)\(\(\.[[0-9]]\{1,3\}\)\{0,2\}\).*$/\1\2/p' -e d`
1827             SHLIB_LD="${SHLIB_LD} -current_version ${vers:-0} -compatibility_version ${vers:-0}"
1828             SHLIB_LD_LIBS='${LIBS}'
1829             SHLIB_SUFFIX=".dylib"
1830             DL_OBJS="tclLoadDyld.o"
1831             DL_LIBS=""
1832             # Don't use -prebind when building for Mac OS X 10.4 or later only:
1833             AS_IF([test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int([$]2)}'`" -lt 4 -a \
1834                 "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int([$]2)}'`" -lt 4], [
1835                 LDFLAGS="$LDFLAGS -prebind"])
1836             LDFLAGS="$LDFLAGS -headerpad_max_install_names"
1837             AC_CACHE_CHECK([if ld accepts -search_paths_first flag],
1838                     tcl_cv_ld_search_paths_first, [
1839                 hold_ldflags=$LDFLAGS
1840                 LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1841                 AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes,
1842                         tcl_cv_ld_search_paths_first=no)
1843                 LDFLAGS=$hold_ldflags])
1844             AS_IF([test $tcl_cv_ld_search_paths_first = yes], [
1845                 LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1846             ])
1847             AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [
1848                 AC_DEFINE(MODULE_SCOPE, [__private_extern__],
1849                     [Compiler support for module scope symbols])
1850             ])
1851             CC_SEARCH_FLAGS=""
1852             LD_SEARCH_FLAGS=""
1853             LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
1854             # TEA specific: for combined 32 & 64 bit fat builds of Tk
1855             # extensions, verify that 64-bit build is possible.
1856             AS_IF([test "$fat_32_64" = yes && test -n "${TK_BIN_DIR}"], [
1857                 AS_IF([test "${TEA_WINDOWINGSYSTEM}" = x11], [
1858                     AC_CACHE_CHECK([for 64-bit X11], tcl_cv_lib_x11_64, [
1859                         for v in CFLAGS CPPFLAGS LDFLAGS; do
1860                             eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
1861                         done
1862                         CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include"
1863                         LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
1864                         AC_TRY_LINK([#include <X11/Xlib.h>], [XrmInitialize();],
1865                             tcl_cv_lib_x11_64=yes, tcl_cv_lib_x11_64=no)
1866                         for v in CFLAGS CPPFLAGS LDFLAGS; do
1867                             eval $v'="$hold_'$v'"'
1868                         done])
1869                 ])
1870                 AS_IF([test "${TEA_WINDOWINGSYSTEM}" = aqua], [
1871                     AC_CACHE_CHECK([for 64-bit Tk], tcl_cv_lib_tk_64, [
1872                         for v in CFLAGS CPPFLAGS LDFLAGS; do
1873                             eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
1874                         done
1875                         CPPFLAGS="$CPPFLAGS -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 ${TCL_INCLUDES} ${TK_INCLUDES}"
1876                         LDFLAGS="$LDFLAGS ${TCL_STUB_LIB_SPEC} ${TK_STUB_LIB_SPEC}"
1877                         AC_TRY_LINK([#include <tk.h>], [Tk_InitStubs(NULL, "", 0);],
1878                             tcl_cv_lib_tk_64=yes, tcl_cv_lib_tk_64=no)
1879                         for v in CFLAGS CPPFLAGS LDFLAGS; do
1880                             eval $v'="$hold_'$v'"'
1881                         done])
1882                 ])
1883                 # remove 64-bit arch flags from CFLAGS et al. if configuration
1884                 # does not support 64-bit.
1885                 AS_IF([test "$tcl_cv_lib_tk_64" = no -o "$tcl_cv_lib_x11_64" = no], [
1886                     AC_MSG_NOTICE([Removing 64-bit architectures from compiler & linker flags])
1887                     for v in CFLAGS CPPFLAGS LDFLAGS; do
1888                         eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
1889                     done])
1890             ])
1891             ;;
1892         NEXTSTEP-*)
1893             SHLIB_CFLAGS=""
1894             SHLIB_LD='${CC} -nostdlib -r'
1895             SHLIB_LD_LIBS=""
1896             SHLIB_SUFFIX=".so"
1897             DL_OBJS="tclLoadNext.o"
1898             DL_LIBS=""
1899             CC_SEARCH_FLAGS=""
1900             LD_SEARCH_FLAGS=""
1901             ;;
1902         OS/390-*)
1903             CFLAGS_OPTIMIZE=""          # Optimizer is buggy
1904             AC_DEFINE(_OE_SOCKETS, 1,   # needed in sys/socket.h
1905                 [Should OS/390 do the right thing with sockets?])
1906             ;;
1907         OSF1-1.0|OSF1-1.1|OSF1-1.2)
1908             # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
1909             SHLIB_CFLAGS=""
1910             # Hack: make package name same as library name
1911             SHLIB_LD='ld -R -export $@:'
1912             SHLIB_LD_LIBS=""
1913             SHLIB_SUFFIX=".so"
1914             DL_OBJS="tclLoadOSF.o"
1915             DL_LIBS=""
1916             CC_SEARCH_FLAGS=""
1917             LD_SEARCH_FLAGS=""
1918             ;;
1919         OSF1-1.*)
1920             # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
1921             SHLIB_CFLAGS="-fPIC"
1922             AS_IF([test "$SHARED_BUILD" = 1], [SHLIB_LD="ld -shared"], [
1923                 SHLIB_LD="ld -non_shared"
1924             ])
1925             SHLIB_LD_LIBS=""
1926             SHLIB_SUFFIX=".so"
1927             DL_OBJS="tclLoadDl.o"
1928             DL_LIBS=""
1929             CC_SEARCH_FLAGS=""
1930             LD_SEARCH_FLAGS=""
1931             ;;
1932         OSF1-V*)
1933             # Digital OSF/1
1934             SHLIB_CFLAGS=""
1935             AS_IF([test "$SHARED_BUILD" = 1], [
1936                 SHLIB_LD='ld -shared -expect_unresolved "*"'
1937             ], [
1938                 SHLIB_LD='ld -non_shared -expect_unresolved "*"'
1939             ])
1940             SHLIB_LD_LIBS=""
1941             SHLIB_SUFFIX=".so"
1942             DL_OBJS="tclLoadDl.o"
1943             DL_LIBS=""
1944             AS_IF([test $doRpath = yes], [
1945                 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1946                 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
1947             AS_IF([test "$GCC" = yes], [CFLAGS="$CFLAGS -mieee"], [
1948                 CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"])
1949             # see pthread_intro(3) for pthread support on osf1, k.furukawa
1950             AS_IF([test "${TCL_THREADS}" = 1], [
1951                 CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
1952                 CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
1953                 LIBS=`echo $LIBS | sed s/-lpthreads//`
1954                 AS_IF([test "$GCC" = yes], [
1955                     LIBS="$LIBS -lpthread -lmach -lexc"
1956                 ], [
1957                     CFLAGS="$CFLAGS -pthread"
1958                     LDFLAGS="$LDFLAGS -pthread"
1959                 ])
1960             ])
1961             ;;
1962         QNX-6*)
1963             # QNX RTP
1964             # This may work for all QNX, but it was only reported for v6.
1965             SHLIB_CFLAGS="-fPIC"
1966             SHLIB_LD="ld -Bshareable -x"
1967             SHLIB_LD_LIBS=""
1968             SHLIB_SUFFIX=".so"
1969             DL_OBJS="tclLoadDl.o"
1970             # dlopen is in -lc on QNX
1971             DL_LIBS=""
1972             CC_SEARCH_FLAGS=""
1973             LD_SEARCH_FLAGS=""
1974             ;;
1975         SCO_SV-3.2*)
1976             # Note, dlopen is available only on SCO 3.2.5 and greater. However,
1977             # this test works, since "uname -s" was non-standard in 3.2.4 and
1978             # below.
1979             AS_IF([test "$GCC" = yes], [
1980                 SHLIB_CFLAGS="-fPIC -melf"
1981                 LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
1982             ], [
1983                 SHLIB_CFLAGS="-Kpic -belf"
1984                 LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
1985             ])
1986             SHLIB_LD="ld -G"
1987             SHLIB_LD_LIBS=""
1988             SHLIB_SUFFIX=".so"
1989             DL_OBJS="tclLoadDl.o"
1990             DL_LIBS=""
1991             CC_SEARCH_FLAGS=""
1992             LD_SEARCH_FLAGS=""
1993             ;;
1994         SINIX*5.4*)
1995             SHLIB_CFLAGS="-K PIC"
1996             SHLIB_LD='${CC} -G'
1997             SHLIB_LD_LIBS=""
1998             SHLIB_SUFFIX=".so"
1999             DL_OBJS="tclLoadDl.o"
2000             DL_LIBS="-ldl"
2001             CC_SEARCH_FLAGS=""
2002             LD_SEARCH_FLAGS=""
2003             ;;
2004         SunOS-4*)
2005             SHLIB_CFLAGS="-PIC"
2006             SHLIB_LD="ld"
2007             SHLIB_LD_LIBS=""
2008             SHLIB_SUFFIX=".so"
2009             DL_OBJS="tclLoadDl.o"
2010             DL_LIBS="-ldl"
2011             CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
2012             LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
2013
2014             # SunOS can't handle version numbers with dots in them in library
2015             # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
2016             # requires an extra version number at the end of .so file names.
2017             # So, the library has to have a name like libtcl75.so.1.0
2018
2019             SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
2020             UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
2021             TCL_LIB_VERSIONS_OK=nodots
2022             ;;
2023         SunOS-5.[[0-6]])
2024             # Careful to not let 5.10+ fall into this case
2025
2026             # Note: If _REENTRANT isn't defined, then Solaris
2027             # won't define thread-safe library routines.
2028
2029             AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
2030             AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
2031                 [Do we really want to follow the standard? Yes we do!])
2032
2033             SHLIB_CFLAGS="-KPIC"
2034
2035             # Note: need the LIBS below, otherwise Tk won't find Tcl's
2036             # symbols when dynamically loaded into tclsh.
2037
2038             SHLIB_LD_LIBS='${LIBS}'
2039             SHLIB_SUFFIX=".so"
2040             DL_OBJS="tclLoadDl.o"
2041             DL_LIBS="-ldl"
2042             AS_IF([test "$GCC" = yes], [
2043                 SHLIB_LD='${CC} -shared'
2044                 CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
2045                 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
2046             ], [
2047                 SHLIB_LD="/usr/ccs/bin/ld -G -z text"
2048                 CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
2049                 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
2050             ])
2051             ;;
2052         SunOS-5*)
2053             # Note: If _REENTRANT isn't defined, then Solaris
2054             # won't define thread-safe library routines.
2055
2056             AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
2057             AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
2058                 [Do we really want to follow the standard? Yes we do!])
2059
2060             SHLIB_CFLAGS="-KPIC"
2061
2062             # Check to enable 64-bit flags for compiler/linker
2063             AS_IF([test "$do64bit" = yes], [
2064                 arch=`isainfo`
2065                 AS_IF([test "$arch" = "sparcv9 sparc"], [
2066                     AS_IF([test "$GCC" = yes], [
2067                         AS_IF([test "`${CC} -dumpversion | awk -F. '{print [$]1}'`" -lt 3], [
2068                             AC_MSG_WARN([64bit mode not supported with GCC < 3.2 on $system])
2069                         ], [
2070                             do64bit_ok=yes
2071                             CFLAGS="$CFLAGS -m64 -mcpu=v9"
2072                             LDFLAGS="$LDFLAGS -m64 -mcpu=v9"
2073                             SHLIB_CFLAGS="-fPIC"
2074                         ])
2075                     ], [
2076                         do64bit_ok=yes
2077                         AS_IF([test "$do64bitVIS" = yes], [
2078                             CFLAGS="$CFLAGS -xarch=v9a"
2079                             LDFLAGS_ARCH="-xarch=v9a"
2080                         ], [
2081                             CFLAGS="$CFLAGS -xarch=v9"
2082                             LDFLAGS_ARCH="-xarch=v9"
2083                         ])
2084                         # Solaris 64 uses this as well
2085                         #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
2086                     ])
2087                 ], [AS_IF([test "$arch" = "amd64 i386"], [
2088                     AS_IF([test "$GCC" = yes], [
2089                         case $system in
2090                             SunOS-5.1[[1-9]]*|SunOS-5.[[2-9]][[0-9]]*)
2091                                 do64bit_ok=yes
2092                                 CFLAGS="$CFLAGS -m64"
2093                                 LDFLAGS="$LDFLAGS -m64";;
2094                             *)
2095                                 AC_MSG_WARN([64bit mode not supported with GCC on $system]);;
2096                         esac
2097                     ], [
2098                         do64bit_ok=yes
2099                         case $system in
2100                             SunOS-5.1[[1-9]]*|SunOS-5.[[2-9]][[0-9]]*)
2101                                 CFLAGS="$CFLAGS -m64"
2102                                 LDFLAGS="$LDFLAGS -m64";;
2103                             *)
2104                                 CFLAGS="$CFLAGS -xarch=amd64"
2105                                 LDFLAGS="$LDFLAGS -xarch=amd64";;
2106                         esac
2107                     ])
2108                 ], [AC_MSG_WARN([64bit mode not supported for $arch])])])
2109             ])
2110
2111             # Note: need the LIBS below, otherwise Tk won't find Tcl's
2112             # symbols when dynamically loaded into tclsh.
2113
2114             SHLIB_LD_LIBS='${LIBS}'
2115             SHLIB_SUFFIX=".so"
2116             DL_OBJS="tclLoadDl.o"
2117             DL_LIBS="-ldl"
2118             AS_IF([test "$GCC" = yes], [
2119                 SHLIB_LD='${CC} -shared'
2120                 CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
2121                 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
2122                 AS_IF([test "$do64bit_ok" = yes], [
2123                     AS_IF([test "$arch" = "sparcv9 sparc"], [
2124                         # We need to specify -static-libgcc or we need to
2125                         # add the path to the sparv9 libgcc.
2126                         # JH: static-libgcc is necessary for core Tcl, but may
2127                         # not be necessary for extensions.
2128                         SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
2129                         # for finding sparcv9 libgcc, get the regular libgcc
2130                         # path, remove so name and append 'sparcv9'
2131                         #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..."
2132                         #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir"
2133                     ], [AS_IF([test "$arch" = "amd64 i386"], [
2134                         # JH: static-libgcc is necessary for core Tcl, but may
2135                         # not be necessary for extensions.
2136                         SHLIB_LD="$SHLIB_LD -m64 -static-libgcc"
2137                     ])])
2138                 ])
2139             ], [
2140                 case $system in
2141                     SunOS-5.[[1-9]][[0-9]]*)
2142                         # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
2143                         SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';;
2144                     *)
2145                         SHLIB_LD='/usr/ccs/bin/ld -G -z text';;
2146                 esac
2147                 CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
2148                 LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
2149             ])
2150             ;;
2151         UNIX_SV* | UnixWare-5*)
2152             SHLIB_CFLAGS="-KPIC"
2153             SHLIB_LD='${CC} -G'
2154             SHLIB_LD_LIBS=""
2155             SHLIB_SUFFIX=".so"
2156             DL_OBJS="tclLoadDl.o"
2157             DL_LIBS="-ldl"
2158             # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
2159             # that don't grok the -Bexport option.  Test that it does.
2160             AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [
2161                 hold_ldflags=$LDFLAGS
2162                 LDFLAGS="$LDFLAGS -Wl,-Bexport"
2163                 AC_TRY_LINK(, [int i;], tcl_cv_ld_Bexport=yes, tcl_cv_ld_Bexport=no)
2164                 LDFLAGS=$hold_ldflags])
2165             AS_IF([test $tcl_cv_ld_Bexport = yes], [
2166                 LDFLAGS="$LDFLAGS -Wl,-Bexport"
2167             ])
2168             CC_SEARCH_FLAGS=""
2169             LD_SEARCH_FLAGS=""
2170             ;;
2171     esac
2172
2173     AS_IF([test "$do64bit" = yes -a "$do64bit_ok" = no], [
2174         AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform])
2175     ])
2176
2177 dnl # Add any CPPFLAGS set in the environment to our CFLAGS, but delay doing so
2178 dnl # until the end of configure, as configure's compile and link tests use
2179 dnl # both CPPFLAGS and CFLAGS (unlike our compile and link) but configure's
2180 dnl # preprocessing tests use only CPPFLAGS.
2181     AC_CONFIG_COMMANDS_PRE([CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""])
2182
2183     # Step 4: disable dynamic loading if requested via a command-line switch.
2184
2185     AC_ARG_ENABLE(load,
2186         AC_HELP_STRING([--enable-load],
2187             [allow dynamic loading and "load" command (default: on)]),
2188         [tcl_ok=$enableval], [tcl_ok=yes])
2189     AS_IF([test "$tcl_ok" = no], [DL_OBJS=""])
2190
2191     AS_IF([test "x$DL_OBJS" != x], [BUILD_DLTEST="\$(DLTEST_TARGETS)"], [
2192         AC_MSG_WARN([Can't figure out how to do dynamic loading or shared libraries on this system.])
2193         SHLIB_CFLAGS=""
2194         SHLIB_LD=""
2195         SHLIB_SUFFIX=""
2196         DL_OBJS="tclLoadNone.o"
2197         DL_LIBS=""
2198         LDFLAGS="$LDFLAGS_ORIG"
2199         CC_SEARCH_FLAGS=""
2200         LD_SEARCH_FLAGS=""
2201         BUILD_DLTEST=""
2202     ])
2203     LDFLAGS="$LDFLAGS $LDFLAGS_ARCH"
2204
2205     # If we're running gcc, then change the C flags for compiling shared
2206     # libraries to the right flags for gcc, instead of those for the
2207     # standard manufacturer compiler.
2208
2209     AS_IF([test "$DL_OBJS" != "tclLoadNone.o" -a "$GCC" = yes], [
2210         case $system in
2211             AIX-*) ;;
2212             BSD/OS*) ;;
2213             IRIX*) ;;
2214             NetBSD-*|FreeBSD-*) ;;
2215             Darwin-*) ;;
2216             SCO_SV-3.2*) ;;
2217             windows) ;;
2218             *) SHLIB_CFLAGS="-fPIC" ;;
2219         esac])
2220
2221     AS_IF([test "$SHARED_LIB_SUFFIX" = ""], [
2222         # TEA specific: use PACKAGE_VERSION instead of VERSION
2223         SHARED_LIB_SUFFIX='${PACKAGE_VERSION}${SHLIB_SUFFIX}'])
2224     AS_IF([test "$UNSHARED_LIB_SUFFIX" = ""], [
2225         # TEA specific: use PACKAGE_VERSION instead of VERSION
2226         UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}.a'])
2227
2228     AC_SUBST(DL_LIBS)
2229
2230     AC_SUBST(CFLAGS_DEBUG)
2231     AC_SUBST(CFLAGS_OPTIMIZE)
2232     AC_SUBST(CFLAGS_WARNING)
2233
2234     AC_SUBST(STLIB_LD)
2235     AC_SUBST(SHLIB_LD)
2236
2237     AC_SUBST(SHLIB_LD_LIBS)
2238     AC_SUBST(SHLIB_CFLAGS)
2239
2240     AC_SUBST(LD_LIBRARY_PATH_VAR)
2241
2242     # These must be called after we do the basic CFLAGS checks and
2243     # verify any possible 64-bit or similar switches are necessary
2244     TEA_TCL_EARLY_FLAGS
2245     TEA_TCL_64BIT_FLAGS
2246 ])
2247
2248 #--------------------------------------------------------------------
2249 # TEA_SERIAL_PORT
2250 #
2251 #       Determine which interface to use to talk to the serial port.
2252 #       Note that #include lines must begin in leftmost column for
2253 #       some compilers to recognize them as preprocessor directives,
2254 #       and some build environments have stdin not pointing at a
2255 #       pseudo-terminal (usually /dev/null instead.)
2256 #
2257 # Arguments:
2258 #       none
2259 #
2260 # Results:
2261 #
2262 #       Defines only one of the following vars:
2263 #               HAVE_SYS_MODEM_H
2264 #               USE_TERMIOS
2265 #               USE_TERMIO
2266 #               USE_SGTTY
2267 #
2268 #--------------------------------------------------------------------
2269
2270 AC_DEFUN([TEA_SERIAL_PORT], [
2271     AC_CHECK_HEADERS(sys/modem.h)
2272     AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
2273     AC_TRY_RUN([
2274 #include <termios.h>
2275
2276 int main() {
2277     struct termios t;
2278     if (tcgetattr(0, &t) == 0) {
2279         cfsetospeed(&t, 0);
2280         t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2281         return 0;
2282     }
2283     return 1;
2284 }], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2285     if test $tcl_cv_api_serial = no ; then
2286         AC_TRY_RUN([
2287 #include <termio.h>
2288
2289 int main() {
2290     struct termio t;
2291     if (ioctl(0, TCGETA, &t) == 0) {
2292         t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2293         return 0;
2294     }
2295     return 1;
2296 }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2297     fi
2298     if test $tcl_cv_api_serial = no ; then
2299         AC_TRY_RUN([
2300 #include <sgtty.h>
2301
2302 int main() {
2303     struct sgttyb t;
2304     if (ioctl(0, TIOCGETP, &t) == 0) {
2305         t.sg_ospeed = 0;
2306         t.sg_flags |= ODDP | EVENP | RAW;
2307         return 0;
2308     }
2309     return 1;
2310 }], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2311     fi
2312     if test $tcl_cv_api_serial = no ; then
2313         AC_TRY_RUN([
2314 #include <termios.h>
2315 #include <errno.h>
2316
2317 int main() {
2318     struct termios t;
2319     if (tcgetattr(0, &t) == 0
2320         || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2321         cfsetospeed(&t, 0);
2322         t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2323         return 0;
2324     }
2325     return 1;
2326 }], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2327     fi
2328     if test $tcl_cv_api_serial = no; then
2329         AC_TRY_RUN([
2330 #include <termio.h>
2331 #include <errno.h>
2332
2333 int main() {
2334     struct termio t;
2335     if (ioctl(0, TCGETA, &t) == 0
2336         || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2337         t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2338         return 0;
2339     }
2340     return 1;
2341     }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2342     fi
2343     if test $tcl_cv_api_serial = no; then
2344         AC_TRY_RUN([
2345 #include <sgtty.h>
2346 #include <errno.h>
2347
2348 int main() {
2349     struct sgttyb t;
2350     if (ioctl(0, TIOCGETP, &t) == 0
2351         || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2352         t.sg_ospeed = 0;
2353         t.sg_flags |= ODDP | EVENP | RAW;
2354         return 0;
2355     }
2356     return 1;
2357 }], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
2358     fi])
2359     case $tcl_cv_api_serial in
2360         termios) AC_DEFINE(USE_TERMIOS, 1, [Use the termios API for serial lines]);;
2361         termio)  AC_DEFINE(USE_TERMIO, 1, [Use the termio API for serial lines]);;
2362         sgtty)   AC_DEFINE(USE_SGTTY, 1, [Use the sgtty API for serial lines]);;
2363     esac
2364 ])
2365
2366 #--------------------------------------------------------------------
2367 # TEA_MISSING_POSIX_HEADERS
2368 #
2369 #       Supply substitutes for missing POSIX header files.  Special
2370 #       notes:
2371 #           - stdlib.h doesn't define strtol, strtoul, or
2372 #             strtod in some versions of SunOS
2373 #           - some versions of string.h don't declare procedures such
2374 #             as strstr
2375 #
2376 # Arguments:
2377 #       none
2378 #
2379 # Results:
2380 #
2381 #       Defines some of the following vars:
2382 #               NO_DIRENT_H
2383 #               NO_ERRNO_H
2384 #               NO_VALUES_H
2385 #               HAVE_LIMITS_H or NO_LIMITS_H
2386 #               NO_STDLIB_H
2387 #               NO_STRING_H
2388 #               NO_SYS_WAIT_H
2389 #               NO_DLFCN_H
2390 #               HAVE_SYS_PARAM_H
2391 #
2392 #               HAVE_STRING_H ?
2393 #
2394 # tkUnixPort.h checks for HAVE_LIMITS_H, so do both HAVE and
2395 # CHECK on limits.h
2396 #--------------------------------------------------------------------
2397
2398 AC_DEFUN([TEA_MISSING_POSIX_HEADERS], [
2399     AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [
2400     AC_TRY_LINK([#include <sys/types.h>
2401 #include <dirent.h>], [
2402 #ifndef _POSIX_SOURCE
2403 #   ifdef __Lynx__
2404         /*
2405          * Generate compilation error to make the test fail:  Lynx headers
2406          * are only valid if really in the POSIX environment.
2407          */
2408
2409         missing_procedure();
2410 #   endif
2411 #endif
2412 DIR *d;
2413 struct dirent *entryPtr;
2414 char *p;
2415 d = opendir("foobar");
2416 entryPtr = readdir(d);
2417 p = entryPtr->d_name;
2418 closedir(d);
2419 ], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no)])
2420
2421     if test $tcl_cv_dirent_h = no; then
2422         AC_DEFINE(NO_DIRENT_H, 1, [Do we have <dirent.h>?])
2423     fi
2424
2425     # TEA specific:
2426     AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H, 1, [Do we have <errno.h>?])])
2427     AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H, 1, [Do we have <float.h>?])])
2428     AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H, 1, [Do we have <values.h>?])])
2429     AC_CHECK_HEADER(limits.h,
2430         [AC_DEFINE(HAVE_LIMITS_H, 1, [Do we have <limits.h>?])],
2431         [AC_DEFINE(NO_LIMITS_H, 1, [Do we have <limits.h>?])])
2432     AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
2433     AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
2434     AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
2435     AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
2436     if test $tcl_ok = 0; then
2437         AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?])
2438     fi
2439     AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
2440     AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
2441     AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
2442
2443     # See also memmove check below for a place where NO_STRING_H can be
2444     # set and why.
2445
2446     if test $tcl_ok = 0; then
2447         AC_DEFINE(NO_STRING_H, 1, [Do we have <string.h>?])
2448     fi
2449
2450     AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H, 1, [Do we have <sys/wait.h>?])])
2451     AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H, 1, [Do we have <dlfcn.h>?])])
2452
2453     # OS/390 lacks sys/param.h (and doesn't need it, by chance).
2454     AC_HAVE_HEADERS(sys/param.h)
2455 ])
2456
2457 #--------------------------------------------------------------------
2458 # TEA_PATH_X
2459 #
2460 #       Locate the X11 header files and the X11 library archive.  Try
2461 #       the ac_path_x macro first, but if it doesn't find the X stuff
2462 #       (e.g. because there's no xmkmf program) then check through
2463 #       a list of possible directories.  Under some conditions the
2464 #       autoconf macro will return an include directory that contains
2465 #       no include files, so double-check its result just to be safe.
2466 #
2467 #       This should be called after TEA_CONFIG_CFLAGS as setting the
2468 #       LIBS line can confuse some configure macro magic.
2469 #
2470 # Arguments:
2471 #       none
2472 #
2473 # Results:
2474 #
2475 #       Sets the following vars:
2476 #               XINCLUDES
2477 #               XLIBSW
2478 #               PKG_LIBS (appends to)
2479 #
2480 #--------------------------------------------------------------------
2481
2482 AC_DEFUN([TEA_PATH_X], [
2483     if test "${TEA_WINDOWINGSYSTEM}" = "x11" ; then
2484         TEA_PATH_UNIX_X
2485     fi
2486 ])
2487
2488 AC_DEFUN([TEA_PATH_UNIX_X], [
2489     AC_PATH_X
2490     not_really_there=""
2491     if test "$no_x" = ""; then
2492         if test "$x_includes" = ""; then
2493             AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
2494         else
2495             if test ! -r $x_includes/X11/Intrinsic.h; then
2496                 not_really_there="yes"
2497             fi
2498         fi
2499     fi
2500     if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
2501         AC_MSG_CHECKING([for X11 header files])
2502         found_xincludes="no"
2503         AC_TRY_CPP([#include <X11/Intrinsic.h>], found_xincludes="yes", found_xincludes="no")
2504         if test "$found_xincludes" = "no"; then
2505             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"
2506             for i in $dirs ; do
2507                 if test -r $i/X11/Intrinsic.h; then
2508                     AC_MSG_RESULT([$i])
2509                     XINCLUDES=" -I$i"
2510                     found_xincludes="yes"
2511                     break
2512                 fi
2513             done
2514         fi
2515     else
2516         if test "$x_includes" != ""; then
2517             XINCLUDES="-I$x_includes"
2518             found_xincludes="yes"
2519         fi
2520     fi
2521     if test found_xincludes = "no"; then
2522         AC_MSG_RESULT([couldn't find any!])
2523     fi
2524
2525     if test "$no_x" = yes; then
2526         AC_MSG_CHECKING([for X11 libraries])
2527         XLIBSW=nope
2528         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"
2529         for i in $dirs ; do
2530             if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl -o -r $i/libX11.dylib; then
2531                 AC_MSG_RESULT([$i])
2532                 XLIBSW="-L$i -lX11"
2533                 x_libraries="$i"
2534                 break
2535             fi
2536         done
2537     else
2538         if test "$x_libraries" = ""; then
2539             XLIBSW=-lX11
2540         else
2541             XLIBSW="-L$x_libraries -lX11"
2542         fi
2543     fi
2544     if test "$XLIBSW" = nope ; then
2545         AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
2546     fi
2547     if test "$XLIBSW" = nope ; then
2548         AC_MSG_RESULT([could not find any!  Using -lX11.])
2549         XLIBSW=-lX11
2550     fi
2551     # TEA specific:
2552     if test x"${XLIBSW}" != x ; then
2553         PKG_LIBS="${PKG_LIBS} ${XLIBSW}"
2554     fi
2555 ])
2556
2557 #--------------------------------------------------------------------
2558 # TEA_BLOCKING_STYLE
2559 #
2560 #       The statements below check for systems where POSIX-style
2561 #       non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
2562 #       On these systems (mostly older ones), use the old BSD-style
2563 #       FIONBIO approach instead.
2564 #
2565 # Arguments:
2566 #       none
2567 #
2568 # Results:
2569 #
2570 #       Defines some of the following vars:
2571 #               HAVE_SYS_IOCTL_H
2572 #               HAVE_SYS_FILIO_H
2573 #               USE_FIONBIO
2574 #               O_NONBLOCK
2575 #
2576 #--------------------------------------------------------------------
2577
2578 AC_DEFUN([TEA_BLOCKING_STYLE], [
2579     AC_CHECK_HEADERS(sys/ioctl.h)
2580     AC_CHECK_HEADERS(sys/filio.h)
2581     TEA_CONFIG_SYSTEM
2582     AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
2583     case $system in
2584         # There used to be code here to use FIONBIO under AIX.  However, it
2585         # was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
2586         # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
2587         # code (JO, 5/31/97).
2588
2589         OSF*)
2590             AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
2591             AC_MSG_RESULT([FIONBIO])
2592             ;;
2593         SunOS-4*)
2594             AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
2595             AC_MSG_RESULT([FIONBIO])
2596             ;;
2597         *)
2598             AC_MSG_RESULT([O_NONBLOCK])
2599             ;;
2600     esac
2601 ])
2602
2603 #--------------------------------------------------------------------
2604 # TEA_TIME_HANDLER
2605 #
2606 #       Checks how the system deals with time.h, what time structures
2607 #       are used on the system, and what fields the structures have.
2608 #
2609 # Arguments:
2610 #       none
2611 #
2612 # Results:
2613 #
2614 #       Defines some of the following vars:
2615 #               USE_DELTA_FOR_TZ
2616 #               HAVE_TM_GMTOFF
2617 #               HAVE_TM_TZADJ
2618 #               HAVE_TIMEZONE_VAR
2619 #
2620 #--------------------------------------------------------------------
2621
2622 AC_DEFUN([TEA_TIME_HANDLER], [
2623     AC_CHECK_HEADERS(sys/time.h)
2624     AC_HEADER_TIME
2625     AC_STRUCT_TIMEZONE
2626
2627     AC_CHECK_FUNCS(gmtime_r localtime_r)
2628
2629     AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [
2630         AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
2631             tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no)])
2632     if test $tcl_cv_member_tm_tzadj = yes ; then
2633         AC_DEFINE(HAVE_TM_TZADJ, 1, [Should we use the tm_tzadj field of struct tm?])
2634     fi
2635
2636     AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
2637         AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
2638             tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)])
2639     if test $tcl_cv_member_tm_gmtoff = yes ; then
2640         AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?])
2641     fi
2642
2643     #
2644     # Its important to include time.h in this check, as some systems
2645     # (like convex) have timezone functions, etc.
2646     #
2647     AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [
2648         AC_TRY_COMPILE([#include <time.h>],
2649             [extern long timezone;
2650             timezone += 1;
2651             exit (0);],
2652             tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no)])
2653     if test $tcl_cv_timezone_long = yes ; then
2654         AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
2655     else
2656         #
2657         # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
2658         #
2659         AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [
2660             AC_TRY_COMPILE([#include <time.h>],
2661                 [extern time_t timezone;
2662                 timezone += 1;
2663                 exit (0);],
2664                 tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no)])
2665         if test $tcl_cv_timezone_time = yes ; then
2666             AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
2667         fi
2668     fi
2669 ])
2670
2671 #--------------------------------------------------------------------
2672 # TEA_BUGGY_STRTOD
2673 #
2674 #       Under Solaris 2.4, strtod returns the wrong value for the
2675 #       terminating character under some conditions.  Check for this
2676 #       and if the problem exists use a substitute procedure
2677 #       "fixstrtod" (provided by Tcl) that corrects the error.
2678 #       Also, on Compaq's Tru64 Unix 5.0,
2679 #       strtod(" ") returns 0.0 instead of a failure to convert.
2680 #
2681 # Arguments:
2682 #       none
2683 #
2684 # Results:
2685 #
2686 #       Might defines some of the following vars:
2687 #               strtod (=fixstrtod)
2688 #
2689 #--------------------------------------------------------------------
2690
2691 AC_DEFUN([TEA_BUGGY_STRTOD], [
2692     AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
2693     if test "$tcl_strtod" = 1; then
2694         AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[
2695             AC_TRY_RUN([
2696                 extern double strtod();
2697                 int main() {
2698                     char *infString="Inf", *nanString="NaN", *spaceString=" ";
2699                     char *term;
2700                     double value;
2701                     value = strtod(infString, &term);
2702                     if ((term != infString) && (term[-1] == 0)) {
2703                         exit(1);
2704                     }
2705                     value = strtod(nanString, &term);
2706                     if ((term != nanString) && (term[-1] == 0)) {
2707                         exit(1);
2708                     }
2709                     value = strtod(spaceString, &term);
2710                     if (term == (spaceString+1)) {
2711                         exit(1);
2712                     }
2713                     exit(0);
2714                 }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy,
2715                     tcl_cv_strtod_buggy=buggy)])
2716         if test "$tcl_cv_strtod_buggy" = buggy; then
2717             AC_LIBOBJ([fixstrtod])
2718             USE_COMPAT=1
2719             AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?])
2720         fi
2721     fi
2722 ])
2723
2724 #--------------------------------------------------------------------
2725 # TEA_TCL_LINK_LIBS
2726 #
2727 #       Search for the libraries needed to link the Tcl shell.
2728 #       Things like the math library (-lm) and socket stuff (-lsocket vs.
2729 #       -lnsl) are dealt with here.
2730 #
2731 # Arguments:
2732 #       Requires the following vars to be set in the Makefile:
2733 #               DL_LIBS
2734 #               LIBS
2735 #               MATH_LIBS
2736 #
2737 # Results:
2738 #
2739 #       Subst's the following var:
2740 #               TCL_LIBS
2741 #               MATH_LIBS
2742 #
2743 #       Might append to the following vars:
2744 #               LIBS
2745 #
2746 #       Might define the following vars:
2747 #               HAVE_NET_ERRNO_H
2748 #
2749 #--------------------------------------------------------------------
2750
2751 AC_DEFUN([TEA_TCL_LINK_LIBS], [
2752     #--------------------------------------------------------------------
2753     # On a few very rare systems, all of the libm.a stuff is
2754     # already in libc.a.  Set compiler flags accordingly.
2755     # Also, Linux requires the "ieee" library for math to work
2756     # right (and it must appear before "-lm").
2757     #--------------------------------------------------------------------
2758
2759     AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
2760     AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
2761
2762     #--------------------------------------------------------------------
2763     # Interactive UNIX requires -linet instead of -lsocket, plus it
2764     # needs net/errno.h to define the socket-related error codes.
2765     #--------------------------------------------------------------------
2766
2767     AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
2768     AC_CHECK_HEADER(net/errno.h, [
2769         AC_DEFINE(HAVE_NET_ERRNO_H, 1, [Do we have <net/errno.h>?])])
2770
2771     #--------------------------------------------------------------------
2772     #   Check for the existence of the -lsocket and -lnsl libraries.
2773     #   The order here is important, so that they end up in the right
2774     #   order in the command line generated by make.  Here are some
2775     #   special considerations:
2776     #   1. Use "connect" and "accept" to check for -lsocket, and
2777     #      "gethostbyname" to check for -lnsl.
2778     #   2. Use each function name only once:  can't redo a check because
2779     #      autoconf caches the results of the last check and won't redo it.
2780     #   3. Use -lnsl and -lsocket only if they supply procedures that
2781     #      aren't already present in the normal libraries.  This is because
2782     #      IRIX 5.2 has libraries, but they aren't needed and they're
2783     #      bogus:  they goof up name resolution if used.
2784     #   4. On some SVR4 systems, can't use -lsocket without -lnsl too.
2785     #      To get around this problem, check for both libraries together
2786     #      if -lsocket doesn't work by itself.
2787     #--------------------------------------------------------------------
2788
2789     tcl_checkBoth=0
2790     AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
2791     if test "$tcl_checkSocket" = 1; then
2792         AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
2793             LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
2794     fi
2795     if test "$tcl_checkBoth" = 1; then
2796         tk_oldLibs=$LIBS
2797         LIBS="$LIBS -lsocket -lnsl"
2798         AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
2799     fi
2800     AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
2801             [LIBS="$LIBS -lnsl"])])
2802
2803     # TEA specific: Don't perform the eval of the libraries here because
2804     # DL_LIBS won't be set until we call TEA_CONFIG_CFLAGS
2805
2806     TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
2807     AC_SUBST(TCL_LIBS)
2808     AC_SUBST(MATH_LIBS)
2809 ])
2810
2811 #--------------------------------------------------------------------
2812 # TEA_TCL_EARLY_FLAGS
2813 #
2814 #       Check for what flags are needed to be passed so the correct OS
2815 #       features are available.
2816 #
2817 # Arguments:
2818 #       None
2819 #
2820 # Results:
2821 #
2822 #       Might define the following vars:
2823 #               _ISOC99_SOURCE
2824 #               _LARGEFILE64_SOURCE
2825 #               _LARGEFILE_SOURCE64
2826 #
2827 #--------------------------------------------------------------------
2828
2829 AC_DEFUN([TEA_TCL_EARLY_FLAG],[
2830     AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
2831         AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
2832             AC_TRY_COMPILE([[#define ]$1[ 1
2833 ]$2], $3,
2834                 [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
2835                 [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
2836     if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
2837         AC_DEFINE($1, 1, [Add the ]$1[ flag when building])
2838         tcl_flags="$tcl_flags $1"
2839     fi
2840 ])
2841
2842 AC_DEFUN([TEA_TCL_EARLY_FLAGS],[
2843     AC_MSG_CHECKING([for required early compiler flags])
2844     tcl_flags=""
2845     TEA_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
2846         [char *p = (char *)strtoll; char *q = (char *)strtoull;])
2847     TEA_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
2848         [struct stat64 buf; int i = stat64("/", &buf);])
2849     TEA_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
2850         [char *p = (char *)open64;])
2851     if test "x${tcl_flags}" = "x" ; then
2852         AC_MSG_RESULT([none])
2853     else
2854         AC_MSG_RESULT([${tcl_flags}])
2855     fi
2856 ])
2857
2858 #--------------------------------------------------------------------
2859 # TEA_TCL_64BIT_FLAGS
2860 #
2861 #       Check for what is defined in the way of 64-bit features.
2862 #
2863 # Arguments:
2864 #       None
2865 #
2866 # Results:
2867 #
2868 #       Might define the following vars:
2869 #               TCL_WIDE_INT_IS_LONG
2870 #               TCL_WIDE_INT_TYPE
2871 #               HAVE_STRUCT_DIRENT64
2872 #               HAVE_STRUCT_STAT64
2873 #               HAVE_TYPE_OFF64_T
2874 #
2875 #--------------------------------------------------------------------
2876
2877 AC_DEFUN([TEA_TCL_64BIT_FLAGS], [
2878     AC_MSG_CHECKING([for 64-bit integer type])
2879     AC_CACHE_VAL(tcl_cv_type_64bit,[
2880         tcl_cv_type_64bit=none
2881         # See if the compiler knows natively about __int64
2882         AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
2883             tcl_type_64bit=__int64, tcl_type_64bit="long long")
2884         # See if we should use long anyway  Note that we substitute in the
2885         # type that is our current guess for a 64-bit type inside this check
2886         # program, so it should be modified only carefully...
2887         AC_TRY_COMPILE(,[switch (0) { 
2888             case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ; 
2889         }],tcl_cv_type_64bit=${tcl_type_64bit})])
2890     if test "${tcl_cv_type_64bit}" = none ; then
2891         AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Are wide integers to be implemented with C 'long's?])
2892         AC_MSG_RESULT([using long])
2893     elif test "${tcl_cv_type_64bit}" = "__int64" \
2894                 -a "${TEA_PLATFORM}" = "windows" ; then
2895         # TEA specific: We actually want to use the default tcl.h checks in
2896         # this case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER*
2897         AC_MSG_RESULT([using Tcl header defaults])
2898     else
2899         AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit},
2900             [What type should be used to define wide integers?])
2901         AC_MSG_RESULT([${tcl_cv_type_64bit}])
2902
2903         # Now check for auxiliary declarations
2904         AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
2905             AC_TRY_COMPILE([#include <sys/types.h>
2906 #include <sys/dirent.h>],[struct dirent64 p;],
2907                 tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
2908         if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
2909             AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?])
2910         fi
2911
2912         AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[
2913             AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
2914 ],
2915                 tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
2916         if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
2917             AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in <sys/stat.h>?])
2918         fi
2919
2920         AC_CHECK_FUNCS(open64 lseek64)
2921         AC_MSG_CHECKING([for off64_t])
2922         AC_CACHE_VAL(tcl_cv_type_off64_t,[
2923             AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
2924 ],
2925                 tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
2926         dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the
2927         dnl functions lseek64 and open64 are defined.
2928         if test "x${tcl_cv_type_off64_t}" = "xyes" && \
2929                 test "x${ac_cv_func_lseek64}" = "xyes" && \
2930                 test "x${ac_cv_func_open64}" = "xyes" ; then
2931             AC_DEFINE(HAVE_TYPE_OFF64_T, 1, [Is off64_t in <sys/types.h>?])
2932             AC_MSG_RESULT([yes])
2933         else
2934             AC_MSG_RESULT([no])
2935         fi
2936     fi
2937 ])
2938
2939 ##
2940 ## Here ends the standard Tcl configuration bits and starts the
2941 ## TEA specific functions
2942 ##
2943
2944 #------------------------------------------------------------------------
2945 # TEA_INIT --
2946 #
2947 #       Init various Tcl Extension Architecture (TEA) variables.
2948 #       This should be the first called TEA_* macro.
2949 #
2950 # Arguments:
2951 #       none
2952 #
2953 # Results:
2954 #
2955 #       Defines and substs the following vars:
2956 #               CYGPATH
2957 #               EXEEXT
2958 #       Defines only:
2959 #               TEA_VERSION
2960 #               TEA_INITED
2961 #               TEA_PLATFORM (windows or unix)
2962 #
2963 # "cygpath" is used on windows to generate native path names for include
2964 # files. These variables should only be used with the compiler and linker
2965 # since they generate native path names.
2966 #
2967 # EXEEXT
2968 #       Select the executable extension based on the host type.  This
2969 #       is a lightweight replacement for AC_EXEEXT that doesn't require
2970 #       a compiler.
2971 #------------------------------------------------------------------------
2972
2973 AC_DEFUN([TEA_INIT], [
2974     # TEA extensions pass this us the version of TEA they think they
2975     # are compatible with.
2976     TEA_VERSION="3.7"
2977
2978     AC_MSG_CHECKING([for correct TEA configuration])
2979     if test x"${PACKAGE_NAME}" = x ; then
2980         AC_MSG_ERROR([
2981 The PACKAGE_NAME variable must be defined by your TEA configure.in])
2982     fi
2983     if test x"$1" = x ; then
2984         AC_MSG_ERROR([
2985 TEA version not specified.])
2986     elif test "$1" != "${TEA_VERSION}" ; then
2987         AC_MSG_RESULT([warning: requested TEA version "$1", have "${TEA_VERSION}"])
2988     else
2989         AC_MSG_RESULT([ok (TEA ${TEA_VERSION})])
2990     fi
2991     case "`uname -s`" in
2992         *win32*|*WIN32*|*CYGWIN_NT*|*CYGWIN_9*|*CYGWIN_ME*|*MINGW32_*)
2993             AC_CHECK_PROG(CYGPATH, cygpath, cygpath -w, echo)
2994             EXEEXT=".exe"
2995             TEA_PLATFORM="windows"
2996             ;;
2997         *)
2998             CYGPATH=echo
2999             EXEEXT=""
3000             TEA_PLATFORM="unix"
3001             ;;
3002     esac
3003
3004     # Check if exec_prefix is set. If not use fall back to prefix.
3005     # Note when adjusted, so that TEA_PREFIX can correct for this.
3006     # This is needed for recursive configures, since autoconf propagates
3007     # $prefix, but not $exec_prefix (doh!).
3008     if test x$exec_prefix = xNONE ; then
3009         exec_prefix_default=yes
3010         exec_prefix=$prefix
3011     fi
3012
3013     AC_SUBST(EXEEXT)
3014     AC_SUBST(CYGPATH)
3015
3016     # This package name must be replaced statically for AC_SUBST to work
3017     AC_SUBST(PKG_LIB_FILE)
3018     # Substitute STUB_LIB_FILE in case package creates a stub library too.
3019     AC_SUBST(PKG_STUB_LIB_FILE)
3020
3021     # We AC_SUBST these here to ensure they are subst'ed,
3022     # in case the user doesn't call TEA_ADD_...
3023     AC_SUBST(PKG_STUB_SOURCES)
3024     AC_SUBST(PKG_STUB_OBJECTS)
3025     AC_SUBST(PKG_TCL_SOURCES)
3026     AC_SUBST(PKG_HEADERS)
3027     AC_SUBST(PKG_INCLUDES)
3028     AC_SUBST(PKG_LIBS)
3029     AC_SUBST(PKG_CFLAGS)
3030 ])
3031
3032 #------------------------------------------------------------------------
3033 # TEA_ADD_SOURCES --
3034 #
3035 #       Specify one or more source files.  Users should check for
3036 #       the right platform before adding to their list.
3037 #       It is not important to specify the directory, as long as it is
3038 #       in the generic, win or unix subdirectory of $(srcdir).
3039 #
3040 # Arguments:
3041 #       one or more file names
3042 #
3043 # Results:
3044 #
3045 #       Defines and substs the following vars:
3046 #               PKG_SOURCES
3047 #               PKG_OBJECTS
3048 #------------------------------------------------------------------------
3049 AC_DEFUN([TEA_ADD_SOURCES], [
3050     vars="$@"
3051     for i in $vars; do
3052         case $i in
3053             [\$]*)
3054                 # allow $-var names
3055                 PKG_SOURCES="$PKG_SOURCES $i"
3056                 PKG_OBJECTS="$PKG_OBJECTS $i"
3057                 ;;
3058             *)
3059                 # check for existence - allows for generic/win/unix VPATH
3060                 # To add more dirs here (like 'src'), you have to update VPATH
3061                 # in Makefile.in as well
3062                 if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
3063                     -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
3064                     ; then
3065                     AC_MSG_ERROR([could not find source file '$i'])
3066                 fi
3067                 PKG_SOURCES="$PKG_SOURCES $i"
3068                 # this assumes it is in a VPATH dir
3069                 i=`basename $i`
3070                 # handle user calling this before or after TEA_SETUP_COMPILER
3071                 if test x"${OBJEXT}" != x ; then
3072                     j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
3073                 else
3074                     j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
3075                 fi
3076                 PKG_OBJECTS="$PKG_OBJECTS $j"
3077                 ;;
3078         esac
3079     done
3080     AC_SUBST(PKG_SOURCES)
3081     AC_SUBST(PKG_OBJECTS)
3082 ])
3083
3084 #------------------------------------------------------------------------
3085 # TEA_ADD_STUB_SOURCES --
3086 #
3087 #       Specify one or more source files.  Users should check for
3088 #       the right platform before adding to their list.
3089 #       It is not important to specify the directory, as long as it is
3090 #       in the generic, win or unix subdirectory of $(srcdir).
3091 #
3092 # Arguments:
3093 #       one or more file names
3094 #
3095 # Results:
3096 #
3097 #       Defines and substs the following vars:
3098 #               PKG_STUB_SOURCES
3099 #               PKG_STUB_OBJECTS
3100 #------------------------------------------------------------------------
3101 AC_DEFUN([TEA_ADD_STUB_SOURCES], [
3102     vars="$@"
3103     for i in $vars; do
3104         # check for existence - allows for generic/win/unix VPATH
3105         if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
3106             -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
3107             ; then
3108             AC_MSG_ERROR([could not find stub source file '$i'])
3109         fi
3110         PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i"
3111         # this assumes it is in a VPATH dir
3112         i=`basename $i`
3113         # handle user calling this before or after TEA_SETUP_COMPILER
3114         if test x"${OBJEXT}" != x ; then
3115             j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
3116         else
3117             j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
3118         fi
3119         PKG_STUB_OBJECTS="$PKG_STUB_OBJECTS $j"
3120     done
3121     AC_SUBST(PKG_STUB_SOURCES)
3122     AC_SUBST(PKG_STUB_OBJECTS)
3123 ])
3124
3125 #------------------------------------------------------------------------
3126 # TEA_ADD_TCL_SOURCES --
3127 #
3128 #       Specify one or more Tcl source files.  These should be platform
3129 #       independent runtime files.
3130 #
3131 # Arguments:
3132 #       one or more file names
3133 #
3134 # Results:
3135 #
3136 #       Defines and substs the following vars:
3137 #               PKG_TCL_SOURCES
3138 #------------------------------------------------------------------------
3139 AC_DEFUN([TEA_ADD_TCL_SOURCES], [
3140     vars="$@"
3141     for i in $vars; do
3142         # check for existence, be strict because it is installed
3143         if test ! -f "${srcdir}/$i" ; then
3144             AC_MSG_ERROR([could not find tcl source file '${srcdir}/$i'])
3145         fi
3146         PKG_TCL_SOURCES="$PKG_TCL_SOURCES $i"
3147     done
3148     AC_SUBST(PKG_TCL_SOURCES)
3149 ])
3150
3151 #------------------------------------------------------------------------
3152 # TEA_ADD_HEADERS --
3153 #
3154 #       Specify one or more source headers.  Users should check for
3155 #       the right platform before adding to their list.
3156 #
3157 # Arguments:
3158 #       one or more file names
3159 #
3160 # Results:
3161 #
3162 #       Defines and substs the following vars:
3163 #               PKG_HEADERS
3164 #------------------------------------------------------------------------
3165 AC_DEFUN([TEA_ADD_HEADERS], [
3166     vars="$@"
3167     for i in $vars; do
3168         # check for existence, be strict because it is installed
3169         if test ! -f "${srcdir}/$i" ; then
3170             AC_MSG_ERROR([could not find header file '${srcdir}/$i'])
3171         fi
3172         PKG_HEADERS="$PKG_HEADERS $i"
3173     done
3174     AC_SUBST(PKG_HEADERS)
3175 ])
3176
3177 #------------------------------------------------------------------------
3178 # TEA_ADD_INCLUDES --
3179 #
3180 #       Specify one or more include dirs.  Users should check for
3181 #       the right platform before adding to their list.
3182 #
3183 # Arguments:
3184 #       one or more file names
3185 #
3186 # Results:
3187 #
3188 #       Defines and substs the following vars:
3189 #               PKG_INCLUDES
3190 #------------------------------------------------------------------------
3191 AC_DEFUN([TEA_ADD_INCLUDES], [
3192     vars="$@"
3193     for i in $vars; do
3194         PKG_INCLUDES="$PKG_INCLUDES $i"
3195     done
3196     AC_SUBST(PKG_INCLUDES)
3197 ])
3198
3199 #------------------------------------------------------------------------
3200 # TEA_ADD_LIBS --
3201 #
3202 #       Specify one or more libraries.  Users should check for
3203 #       the right platform before adding to their list.  For Windows,
3204 #       libraries provided in "foo.lib" format will be converted to
3205 #       "-lfoo" when using GCC (mingw).
3206 #
3207 # Arguments:
3208 #       one or more file names
3209 #
3210 # Results:
3211 #
3212 #       Defines and substs the following vars:
3213 #               PKG_LIBS
3214 #------------------------------------------------------------------------
3215 AC_DEFUN([TEA_ADD_LIBS], [
3216     vars="$@"
3217     for i in $vars; do
3218         if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
3219             # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
3220             i=`echo "$i" | sed -e 's/^\([[^-]].*\)\.lib[$]/-l\1/i'`
3221         fi
3222         PKG_LIBS="$PKG_LIBS $i"
3223     done
3224     AC_SUBST(PKG_LIBS)
3225 ])
3226
3227 #------------------------------------------------------------------------
3228 # TEA_ADD_CFLAGS --
3229 #
3230 #       Specify one or more CFLAGS.  Users should check for
3231 #       the right platform before adding to their list.
3232 #
3233 # Arguments:
3234 #       one or more file names
3235 #
3236 # Results:
3237 #
3238 #       Defines and substs the following vars:
3239 #               PKG_CFLAGS
3240 #------------------------------------------------------------------------
3241 AC_DEFUN([TEA_ADD_CFLAGS], [
3242     PKG_CFLAGS="$PKG_CFLAGS $@"
3243     AC_SUBST(PKG_CFLAGS)
3244 ])
3245
3246 #------------------------------------------------------------------------
3247 # TEA_PREFIX --
3248 #
3249 #       Handle the --prefix=... option by defaulting to what Tcl gave
3250 #
3251 # Arguments:
3252 #       none
3253 #
3254 # Results:
3255 #
3256 #       If --prefix or --exec-prefix was not specified, $prefix and
3257 #       $exec_prefix will be set to the values given to Tcl when it was
3258 #       configured.
3259 #------------------------------------------------------------------------
3260 AC_DEFUN([TEA_PREFIX], [
3261     if test "${prefix}" = "NONE"; then
3262         prefix_default=yes
3263         if test x"${TCL_PREFIX}" != x; then
3264             AC_MSG_NOTICE([--prefix defaulting to TCL_PREFIX ${TCL_PREFIX}])
3265             prefix=${TCL_PREFIX}
3266         else
3267             AC_MSG_NOTICE([--prefix defaulting to /usr/local])
3268             prefix=/usr/local
3269         fi
3270     fi
3271     if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" \
3272         -o x"${exec_prefix_default}" = x"yes" ; then
3273         if test x"${TCL_EXEC_PREFIX}" != x; then
3274             AC_MSG_NOTICE([--exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}])
3275             exec_prefix=${TCL_EXEC_PREFIX}
3276         else
3277             AC_MSG_NOTICE([--exec-prefix defaulting to ${prefix}])
3278             exec_prefix=$prefix
3279         fi
3280     fi
3281 ])
3282
3283 #------------------------------------------------------------------------
3284 # TEA_SETUP_COMPILER_CC --
3285 #
3286 #       Do compiler checks the way we want.  This is just a replacement
3287 #       for AC_PROG_CC in TEA configure.in files to make them cleaner.
3288 #
3289 # Arguments:
3290 #       none
3291 #
3292 # Results:
3293 #
3294 #       Sets up CC var and other standard bits we need to make executables.
3295 #------------------------------------------------------------------------
3296 AC_DEFUN([TEA_SETUP_COMPILER_CC], [
3297     # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE)
3298     # in this macro, they need to go into TEA_SETUP_COMPILER instead.
3299
3300     # If the user did not set CFLAGS, set it now to keep
3301     # the AC_PROG_CC macro from adding "-g -O2".
3302     if test "${CFLAGS+set}" != "set" ; then
3303         CFLAGS=""
3304     fi
3305
3306     AC_PROG_CC
3307     AC_PROG_CPP
3308
3309     AC_PROG_INSTALL
3310
3311     #--------------------------------------------------------------------
3312     # Checks to see if the make program sets the $MAKE variable.
3313     #--------------------------------------------------------------------
3314
3315     AC_PROG_MAKE_SET
3316
3317     #--------------------------------------------------------------------
3318     # Find ranlib
3319     #--------------------------------------------------------------------
3320
3321     AC_PROG_RANLIB
3322
3323     #--------------------------------------------------------------------
3324     # Determines the correct binary file extension (.o, .obj, .exe etc.)
3325     #--------------------------------------------------------------------
3326
3327     AC_OBJEXT
3328     AC_EXEEXT
3329 ])
3330
3331 #------------------------------------------------------------------------
3332 # TEA_SETUP_COMPILER --
3333 #
3334 #       Do compiler checks that use the compiler.  This must go after
3335 #       TEA_SETUP_COMPILER_CC, which does the actual compiler check.
3336 #
3337 # Arguments:
3338 #       none
3339 #
3340 # Results:
3341 #
3342 #       Sets up CC var and other standard bits we need to make executables.
3343 #------------------------------------------------------------------------
3344 AC_DEFUN([TEA_SETUP_COMPILER], [
3345     # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here.
3346     AC_REQUIRE([TEA_SETUP_COMPILER_CC])
3347
3348     #------------------------------------------------------------------------
3349     # If we're using GCC, see if the compiler understands -pipe. If so, use it.
3350     # It makes compiling go faster.  (This is only a performance feature.)
3351     #------------------------------------------------------------------------
3352
3353     if test -z "$no_pipe" -a -n "$GCC"; then
3354         AC_CACHE_CHECK([if the compiler understands -pipe],
3355             tcl_cv_cc_pipe, [
3356             hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe"
3357             AC_TRY_COMPILE(,, tcl_cv_cc_pipe=yes, tcl_cv_cc_pipe=no)
3358             CFLAGS=$hold_cflags])
3359         if test $tcl_cv_cc_pipe = yes; then
3360             CFLAGS="$CFLAGS -pipe"
3361         fi
3362     fi
3363
3364     #--------------------------------------------------------------------
3365     # Common compiler flag setup
3366     #--------------------------------------------------------------------
3367
3368     AC_C_BIGENDIAN
3369     if test "${TEA_PLATFORM}" = "unix" ; then
3370         TEA_TCL_LINK_LIBS
3371         TEA_MISSING_POSIX_HEADERS
3372         # Let the user call this, because if it triggers, they will
3373         # need a compat/strtod.c that is correct.  Users can also
3374         # use Tcl_GetDouble(FromObj) instead.
3375         #TEA_BUGGY_STRTOD
3376     fi
3377 ])
3378
3379 #------------------------------------------------------------------------
3380 # TEA_MAKE_LIB --
3381 #
3382 #       Generate a line that can be used to build a shared/unshared library
3383 #       in a platform independent manner.
3384 #
3385 # Arguments:
3386 #       none
3387 #
3388 #       Requires:
3389 #
3390 # Results:
3391 #
3392 #       Defines the following vars:
3393 #       CFLAGS -        Done late here to note disturb other AC macros
3394 #       MAKE_LIB -      Command to execute to build the Tcl library;
3395 #                       differs depending on whether or not Tcl is being
3396 #                       compiled as a shared library.
3397 #       MAKE_SHARED_LIB Makefile rule for building a shared library
3398 #       MAKE_STATIC_LIB Makefile rule for building a static library
3399 #       MAKE_STUB_LIB   Makefile rule for building a stub library
3400 #------------------------------------------------------------------------
3401
3402 AC_DEFUN([TEA_MAKE_LIB], [
3403     if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then
3404         MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_OBJECTS)"
3405         MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\[$]@ \$(PKG_OBJECTS)"
3406         MAKE_STUB_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_STUB_OBJECTS)"
3407     else
3408         MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(PKG_OBJECTS)"
3409         MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}"
3410         MAKE_STUB_LIB="\${STLIB_LD} \[$]@ \$(PKG_STUB_OBJECTS)"
3411     fi
3412
3413     if test "${SHARED_BUILD}" = "1" ; then
3414         MAKE_LIB="${MAKE_SHARED_LIB} "
3415     else
3416         MAKE_LIB="${MAKE_STATIC_LIB} "
3417     fi
3418
3419     #--------------------------------------------------------------------
3420     # Shared libraries and static libraries have different names.
3421     # Use the double eval to make sure any variables in the suffix is
3422     # substituted. (@@@ Might not be necessary anymore)
3423     #--------------------------------------------------------------------
3424
3425     if test "${TEA_PLATFORM}" = "windows" ; then
3426         if test "${SHARED_BUILD}" = "1" ; then
3427             # We force the unresolved linking of symbols that are really in
3428             # the private libraries of Tcl and Tk.
3429             SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\""
3430             if test x"${TK_BIN_DIR}" != x ; then
3431                 SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\""
3432             fi
3433             eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
3434         else
3435             eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
3436         fi
3437         # Some packages build their own stubs libraries
3438         eval eval "PKG_STUB_LIB_FILE=${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
3439         if test "$GCC" = "yes"; then
3440             PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE}
3441         fi
3442         # These aren't needed on Windows (either MSVC or gcc)
3443         RANLIB=:
3444         RANLIB_STUB=:
3445     else
3446         RANLIB_STUB="${RANLIB}"
3447         if test "${SHARED_BUILD}" = "1" ; then
3448             SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}"
3449             if test x"${TK_BIN_DIR}" != x ; then
3450                 SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}"
3451             fi
3452             eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
3453             RANLIB=:
3454         else
3455             eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
3456         fi
3457         # Some packages build their own stubs libraries
3458         eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
3459     fi
3460
3461     # These are escaped so that only CFLAGS is picked up at configure time.
3462     # The other values will be substituted at make time.
3463     CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}"
3464     if test "${SHARED_BUILD}" = "1" ; then
3465         CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}"
3466     fi
3467
3468     AC_SUBST(MAKE_LIB)
3469     AC_SUBST(MAKE_SHARED_LIB)
3470     AC_SUBST(MAKE_STATIC_LIB)
3471     AC_SUBST(MAKE_STUB_LIB)
3472     AC_SUBST(RANLIB_STUB)
3473 ])
3474
3475 #------------------------------------------------------------------------
3476 # TEA_LIB_SPEC --
3477 #
3478 #       Compute the name of an existing object library located in libdir
3479 #       from the given base name and produce the appropriate linker flags.
3480 #
3481 # Arguments:
3482 #       basename        The base name of the library without version
3483 #                       numbers, extensions, or "lib" prefixes.
3484 #       extra_dir       Extra directory in which to search for the
3485 #                       library.  This location is used first, then
3486 #                       $prefix/$exec-prefix, then some defaults.
3487 #
3488 # Requires:
3489 #       TEA_INIT and TEA_PREFIX must be called first.
3490 #
3491 # Results:
3492 #
3493 #       Defines the following vars:
3494 #               ${basename}_LIB_NAME    The computed library name.
3495 #               ${basename}_LIB_SPEC    The computed linker flags.
3496 #------------------------------------------------------------------------
3497
3498 AC_DEFUN([TEA_LIB_SPEC], [
3499     AC_MSG_CHECKING([for $1 library])
3500
3501     # Look in exec-prefix for the library (defined by TEA_PREFIX).
3502
3503     tea_lib_name_dir="${exec_prefix}/lib"
3504
3505     # Or in a user-specified location.
3506
3507     if test x"$2" != x ; then
3508         tea_extra_lib_dir=$2
3509     else
3510         tea_extra_lib_dir=NONE
3511     fi
3512
3513     for i in \
3514             `ls -dr ${tea_extra_lib_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
3515             `ls -dr ${tea_extra_lib_dir}/lib$1[[0-9]]* 2>/dev/null ` \
3516             `ls -dr ${tea_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
3517             `ls -dr ${tea_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
3518             `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
3519             `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
3520             `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
3521             `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
3522         if test -f "$i" ; then
3523             tea_lib_name_dir=`dirname $i`
3524             $1_LIB_NAME=`basename $i`
3525             $1_LIB_PATH_NAME=$i
3526             break
3527         fi
3528     done
3529
3530     if test "${TEA_PLATFORM}" = "windows"; then
3531         $1_LIB_SPEC=\"`${CYGPATH} ${$1_LIB_PATH_NAME} 2>/dev/null`\"
3532     else
3533         # Strip off the leading "lib" and trailing ".a" or ".so"
3534
3535         tea_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//' -e 's/\.so.*//'`
3536         $1_LIB_SPEC="-L${tea_lib_name_dir} -l${tea_lib_name_lib}"
3537     fi
3538
3539     if test "x${$1_LIB_NAME}" = x ; then
3540         AC_MSG_ERROR([not found])
3541     else
3542         AC_MSG_RESULT([${$1_LIB_SPEC}])
3543     fi
3544 ])
3545
3546 #------------------------------------------------------------------------
3547 # TEA_PRIVATE_TCL_HEADERS --
3548 #
3549 #       Locate the private Tcl include files
3550 #
3551 # Arguments:
3552 #
3553 #       Requires:
3554 #               TCL_SRC_DIR     Assumes that TEA_LOAD_TCLCONFIG has
3555 #                               already been called.
3556 #
3557 # Results:
3558 #
3559 #       Substs the following vars:
3560 #               TCL_TOP_DIR_NATIVE
3561 #               TCL_INCLUDES
3562 #------------------------------------------------------------------------
3563
3564 AC_DEFUN([TEA_PRIVATE_TCL_HEADERS], [
3565     # Allow for --with-tclinclude to take effect and define ${ac_cv_c_tclh}
3566     AC_REQUIRE([TEA_PUBLIC_TCL_HEADERS])
3567     AC_MSG_CHECKING([for Tcl private include files])
3568
3569     TCL_SRC_DIR_NATIVE=`${CYGPATH} ${TCL_SRC_DIR}`
3570     TCL_TOP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}\"
3571
3572     # Check to see if tcl<Plat>Port.h isn't already with the public headers
3573     # Don't look for tclInt.h because that resides with tcl.h in the core
3574     # sources, but the <plat>Port headers are in a different directory
3575     if test "${TEA_PLATFORM}" = "windows" -a \
3576         -f "${ac_cv_c_tclh}/tclWinPort.h"; then
3577         result="private headers found with public headers"
3578     elif test "${TEA_PLATFORM}" = "unix" -a \
3579         -f "${ac_cv_c_tclh}/tclUnixPort.h"; then
3580         result="private headers found with public headers"
3581     else
3582         TCL_GENERIC_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/generic\"
3583         if test "${TEA_PLATFORM}" = "windows"; then
3584             TCL_PLATFORM_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/win\"
3585         else
3586             TCL_PLATFORM_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/unix\"
3587         fi
3588         # Overwrite the previous TCL_INCLUDES as this should capture both
3589         # public and private headers in the same set.
3590         # We want to ensure these are substituted so as not to require
3591         # any *_NATIVE vars be defined in the Makefile
3592         TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
3593         if test "`uname -s`" = "Darwin"; then
3594             # If Tcl was built as a framework, attempt to use
3595             # the framework's Headers and PrivateHeaders directories
3596             case ${TCL_DEFS} in
3597                 *TCL_FRAMEWORK*)
3598                     if test -d "${TCL_BIN_DIR}/Headers" -a \
3599                             -d "${TCL_BIN_DIR}/PrivateHeaders"; then
3600                         TCL_INCLUDES="-I\"${TCL_BIN_DIR}/Headers\" -I\"${TCL_BIN_DIR}/PrivateHeaders\" ${TCL_INCLUDES}"
3601                     else
3602                         TCL_INCLUDES="${TCL_INCLUDES} ${TCL_INCLUDE_SPEC} `echo "${TCL_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`"
3603                     fi
3604                     ;;
3605             esac
3606             result="Using ${TCL_INCLUDES}"
3607         else
3608             if test ! -f "${TCL_SRC_DIR}/generic/tclInt.h" ; then
3609                 AC_MSG_ERROR([Cannot find private header tclInt.h in ${TCL_SRC_DIR}])
3610             fi
3611             result="Using srcdir found in tclConfig.sh: ${TCL_SRC_DIR}"
3612         fi
3613     fi
3614
3615     AC_SUBST(TCL_TOP_DIR_NATIVE)
3616
3617     AC_SUBST(TCL_INCLUDES)
3618     AC_MSG_RESULT([${result}])
3619 ])
3620
3621 #------------------------------------------------------------------------
3622 # TEA_PUBLIC_TCL_HEADERS --
3623 #
3624 #       Locate the installed public Tcl header files
3625 #
3626 # Arguments:
3627 #       None.
3628 #
3629 # Requires:
3630 #       CYGPATH must be set
3631 #
3632 # Results:
3633 #
3634 #       Adds a --with-tclinclude switch to configure.
3635 #       Result is cached.
3636 #
3637 #       Substs the following vars:
3638 #               TCL_INCLUDES
3639 #------------------------------------------------------------------------
3640
3641 AC_DEFUN([TEA_PUBLIC_TCL_HEADERS], [
3642     AC_MSG_CHECKING([for Tcl public headers])
3643
3644     AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory containing the public Tcl header files], with_tclinclude=${withval})
3645
3646     AC_CACHE_VAL(ac_cv_c_tclh, [
3647         # Use the value from --with-tclinclude, if it was given
3648
3649         if test x"${with_tclinclude}" != x ; then
3650             if test -f "${with_tclinclude}/tcl.h" ; then
3651                 ac_cv_c_tclh=${with_tclinclude}
3652             else
3653                 AC_MSG_ERROR([${with_tclinclude} directory does not contain tcl.h])
3654             fi
3655         else
3656             list=""
3657             if test "`uname -s`" = "Darwin"; then
3658                 # If Tcl was built as a framework, attempt to use
3659                 # the framework's Headers directory
3660                 case ${TCL_DEFS} in
3661                     *TCL_FRAMEWORK*)
3662                         list="`ls -d ${TCL_BIN_DIR}/Headers 2>/dev/null`"
3663                         ;;
3664                 esac
3665             fi
3666
3667             # Look in the source dir only if Tcl is not installed,
3668             # and in that situation, look there before installed locations.
3669             if test -f "${TCL_BIN_DIR}/Makefile" ; then
3670                 list="$list `ls -d ${TCL_SRC_DIR}/generic 2>/dev/null`"
3671             fi
3672
3673             # Check order: pkg --prefix location, Tcl's --prefix location,
3674             # relative to directory of tclConfig.sh.
3675
3676             eval "temp_includedir=${includedir}"
3677             list="$list \
3678                 `ls -d ${temp_includedir}        2>/dev/null` \
3679                 `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
3680                 `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
3681             if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
3682                 list="$list /usr/local/include /usr/include"
3683                 if test x"${TCL_INCLUDE_SPEC}" != x ; then
3684                     d=`echo "${TCL_INCLUDE_SPEC}" | sed -e 's/^-I//'`
3685                     list="$list `ls -d ${d} 2>/dev/null`"
3686                 fi
3687             fi
3688             for i in $list ; do
3689                 if test -f "$i/tcl.h" ; then
3690                     ac_cv_c_tclh=$i
3691                     break
3692                 fi
3693             done
3694         fi
3695     ])
3696
3697     # Print a message based on how we determined the include path
3698
3699     if test x"${ac_cv_c_tclh}" = x ; then
3700         AC_MSG_ERROR([tcl.h not found.  Please specify its location with --with-tclinclude])
3701     else
3702         AC_MSG_RESULT([${ac_cv_c_tclh}])
3703     fi
3704
3705     # Convert to a native path and substitute into the output files.
3706
3707     INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
3708
3709     TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
3710
3711     AC_SUBST(TCL_INCLUDES)
3712 ])
3713
3714 #------------------------------------------------------------------------
3715 # TEA_PRIVATE_TK_HEADERS --
3716 #
3717 #       Locate the private Tk include files
3718 #
3719 # Arguments:
3720 #
3721 #       Requires:
3722 #               TK_SRC_DIR      Assumes that TEA_LOAD_TKCONFIG has
3723 #                                already been called.
3724 #
3725 # Results:
3726 #
3727 #       Substs the following vars:
3728 #               TK_INCLUDES
3729 #------------------------------------------------------------------------
3730
3731 AC_DEFUN([TEA_PRIVATE_TK_HEADERS], [
3732     # Allow for --with-tkinclude to take effect and define ${ac_cv_c_tkh}
3733     AC_REQUIRE([TEA_PUBLIC_TK_HEADERS])
3734     AC_MSG_CHECKING([for Tk private include files])
3735
3736     TK_SRC_DIR_NATIVE=`${CYGPATH} ${TK_SRC_DIR}`
3737     TK_TOP_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}\"
3738
3739     # Check to see if tk<Plat>Port.h isn't already with the public headers
3740     # Don't look for tkInt.h because that resides with tk.h in the core
3741     # sources, but the <plat>Port headers are in a different directory
3742     if test "${TEA_PLATFORM}" = "windows" -a \
3743         -f "${ac_cv_c_tkh}/tkWinPort.h"; then
3744         result="private headers found with public headers"
3745     elif test "${TEA_PLATFORM}" = "unix" -a \
3746         -f "${ac_cv_c_tkh}/tkUnixPort.h"; then
3747         result="private headers found with public headers"
3748     else
3749         TK_GENERIC_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/generic\"
3750         TK_XLIB_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/xlib\"
3751         if test "${TEA_PLATFORM}" = "windows"; then
3752             TK_PLATFORM_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/win\"
3753         else
3754             TK_PLATFORM_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/unix\"
3755         fi
3756         # Overwrite the previous TK_INCLUDES as this should capture both
3757         # public and private headers in the same set.
3758         # We want to ensure these are substituted so as not to require
3759         # any *_NATIVE vars be defined in the Makefile
3760         TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
3761         # Detect and add ttk subdir
3762         if test -d "${TK_SRC_DIR}/generic/ttk"; then
3763            TK_INCLUDES="${TK_INCLUDES} -I\"${TK_SRC_DIR_NATIVE}/generic/ttk\""
3764         fi
3765         if test "${TEA_WINDOWINGSYSTEM}" != "x11"; then
3766            TK_INCLUDES="${TK_INCLUDES} -I\"${TK_XLIB_DIR_NATIVE}\""
3767         fi
3768         if test "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
3769            TK_INCLUDES="${TK_INCLUDES} -I\"${TK_SRC_DIR_NATIVE}/macosx\""
3770         fi
3771         if test "`uname -s`" = "Darwin"; then
3772             # If Tk was built as a framework, attempt to use
3773             # the framework's Headers and PrivateHeaders directories
3774             case ${TK_DEFS} in
3775                 *TK_FRAMEWORK*)
3776                         if test -d "${TK_BIN_DIR}/Headers" -a \
3777                                 -d "${TK_BIN_DIR}/PrivateHeaders"; then
3778                             TK_INCLUDES="-I\"${TK_BIN_DIR}/Headers\" -I\"${TK_BIN_DIR}/PrivateHeaders\" ${TK_INCLUDES}"
3779                         else
3780                             TK_INCLUDES="${TK_INCLUDES} ${TK_INCLUDE_SPEC} `echo "${TK_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`"
3781                         fi
3782                         ;;
3783             esac
3784             result="Using ${TK_INCLUDES}"
3785         else
3786             if test ! -f "${TK_SRC_DIR}/generic/tkInt.h" ; then
3787                AC_MSG_ERROR([Cannot find private header tkInt.h in ${TK_SRC_DIR}])
3788             fi
3789             result="Using srcdir found in tkConfig.sh: ${TK_SRC_DIR}"
3790         fi
3791     fi
3792
3793     AC_SUBST(TK_TOP_DIR_NATIVE)
3794     AC_SUBST(TK_XLIB_DIR_NATIVE)
3795
3796     AC_SUBST(TK_INCLUDES)
3797     AC_MSG_RESULT([${result}])
3798 ])
3799
3800 #------------------------------------------------------------------------
3801 # TEA_PUBLIC_TK_HEADERS --
3802 #
3803 #       Locate the installed public Tk header files
3804 #
3805 # Arguments:
3806 #       None.
3807 #
3808 # Requires:
3809 #       CYGPATH must be set
3810 #
3811 # Results:
3812 #
3813 #       Adds a --with-tkinclude switch to configure.
3814 #       Result is cached.
3815 #
3816 #       Substs the following vars:
3817 #               TK_INCLUDES
3818 #------------------------------------------------------------------------
3819
3820 AC_DEFUN([TEA_PUBLIC_TK_HEADERS], [
3821     AC_MSG_CHECKING([for Tk public headers])
3822
3823     AC_ARG_WITH(tkinclude, [  --with-tkinclude        directory containing the public Tk header files], with_tkinclude=${withval})
3824
3825     AC_CACHE_VAL(ac_cv_c_tkh, [
3826         # Use the value from --with-tkinclude, if it was given
3827
3828         if test x"${with_tkinclude}" != x ; then
3829             if test -f "${with_tkinclude}/tk.h" ; then
3830                 ac_cv_c_tkh=${with_tkinclude}
3831             else
3832                 AC_MSG_ERROR([${with_tkinclude} directory does not contain tk.h])
3833             fi
3834         else
3835             list=""
3836             if test "`uname -s`" = "Darwin"; then
3837                 # If Tk was built as a framework, attempt to use
3838                 # the framework's Headers directory.
3839                 case ${TK_DEFS} in
3840                     *TK_FRAMEWORK*)
3841                         list="`ls -d ${TK_BIN_DIR}/Headers 2>/dev/null`"
3842                         ;;
3843                 esac
3844             fi
3845
3846             # Look in the source dir only if Tk is not installed,
3847             # and in that situation, look there before installed locations.
3848             if test -f "${TK_BIN_DIR}/Makefile" ; then
3849                 list="$list `ls -d ${TK_SRC_DIR}/generic 2>/dev/null`"
3850             fi
3851
3852             # Check order: pkg --prefix location, Tk's --prefix location,
3853             # relative to directory of tkConfig.sh, Tcl's --prefix location,
3854             # relative to directory of tclConfig.sh.
3855
3856             eval "temp_includedir=${includedir}"
3857             list="$list \
3858                 `ls -d ${temp_includedir}        2>/dev/null` \
3859                 `ls -d ${TK_PREFIX}/include      2>/dev/null` \
3860                 `ls -d ${TK_BIN_DIR}/../include  2>/dev/null` \
3861                 `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
3862                 `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
3863             if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
3864                 list="$list /usr/local/include /usr/include"
3865                 if test x"${TK_INCLUDE_SPEC}" != x ; then
3866                     d=`echo "${TK_INCLUDE_SPEC}" | sed -e 's/^-I//'`
3867                     list="$list `ls -d ${d} 2>/dev/null`"
3868                 fi
3869             fi
3870             for i in $list ; do
3871                 if test -f "$i/tk.h" ; then
3872                     ac_cv_c_tkh=$i
3873                     break
3874                 fi
3875             done
3876         fi
3877     ])
3878
3879     # Print a message based on how we determined the include path
3880
3881     if test x"${ac_cv_c_tkh}" = x ; then
3882         AC_MSG_ERROR([tk.h not found.  Please specify its location with --with-tkinclude])
3883     else
3884         AC_MSG_RESULT([${ac_cv_c_tkh}])
3885     fi
3886
3887     # Convert to a native path and substitute into the output files.
3888
3889     INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}`
3890
3891     TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
3892
3893     AC_SUBST(TK_INCLUDES)
3894
3895     if test "${TEA_WINDOWINGSYSTEM}" != "x11"; then
3896         # On Windows and Aqua, we need the X compat headers
3897         AC_MSG_CHECKING([for X11 header files])
3898         if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then
3899             INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`"
3900             TK_XINCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
3901             AC_SUBST(TK_XINCLUDES)
3902         fi
3903         AC_MSG_RESULT([${INCLUDE_DIR_NATIVE}])
3904     fi
3905 ])
3906
3907 #------------------------------------------------------------------------
3908 # TEA_PATH_CONFIG --
3909 #
3910 #       Locate the ${1}Config.sh file and perform a sanity check on
3911 #       the ${1} compile flags.  These are used by packages like
3912 #       [incr Tk] that load *Config.sh files from more than Tcl and Tk.
3913 #
3914 # Arguments:
3915 #       none
3916 #
3917 # Results:
3918 #
3919 #       Adds the following arguments to configure:
3920 #               --with-$1=...
3921 #
3922 #       Defines the following vars:
3923 #               $1_BIN_DIR      Full path to the directory containing
3924 #                               the $1Config.sh file
3925 #------------------------------------------------------------------------
3926
3927 AC_DEFUN([TEA_PATH_CONFIG], [
3928     #
3929     # Ok, lets find the $1 configuration
3930     # First, look for one uninstalled.
3931     # the alternative search directory is invoked by --with-$1
3932     #
3933
3934     if test x"${no_$1}" = x ; then
3935         # we reset no_$1 in case something fails here
3936         no_$1=true
3937         AC_ARG_WITH($1, [  --with-$1              directory containing $1 configuration ($1Config.sh)], with_$1config=${withval})
3938         AC_MSG_CHECKING([for $1 configuration])
3939         AC_CACHE_VAL(ac_cv_c_$1config,[
3940
3941             # First check to see if --with-$1 was specified.
3942             if test x"${with_$1config}" != x ; then
3943                 case ${with_$1config} in
3944                     */$1Config.sh )
3945                         if test -f ${with_$1config}; then
3946                             AC_MSG_WARN([--with-$1 argument should refer to directory containing $1Config.sh, not to $1Config.sh itself])
3947                             with_$1config=`echo ${with_$1config} | sed 's!/$1Config\.sh$!!'`
3948                         fi;;
3949                 esac
3950                 if test -f "${with_$1config}/$1Config.sh" ; then
3951                     ac_cv_c_$1config=`(cd ${with_$1config}; pwd)`
3952                 else
3953                     AC_MSG_ERROR([${with_$1config} directory doesn't contain $1Config.sh])
3954                 fi
3955             fi
3956
3957             # then check for a private $1 installation
3958             if test x"${ac_cv_c_$1config}" = x ; then
3959                 for i in \
3960                         ../$1 \
3961                         `ls -dr ../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
3962                         `ls -dr ../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
3963                         `ls -dr ../$1*[[0-9]].[[0-9]] 2>/dev/null` \
3964                         `ls -dr ../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
3965                         ../../$1 \
3966                         `ls -dr ../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
3967                         `ls -dr ../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
3968                         `ls -dr ../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
3969                         `ls -dr ../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
3970                         ../../../$1 \
3971                         `ls -dr ../../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
3972                         `ls -dr ../../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
3973                         `ls -dr ../../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
3974                         `ls -dr ../../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
3975                         ${srcdir}/../$1 \
3976                         `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
3977                         `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
3978                         `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]] 2>/dev/null` \
3979                         `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
3980                         ; do
3981                     if test -f "$i/$1Config.sh" ; then
3982                         ac_cv_c_$1config=`(cd $i; pwd)`
3983                         break
3984                     fi
3985                     if test -f "$i/unix/$1Config.sh" ; then
3986                         ac_cv_c_$1config=`(cd $i/unix; pwd)`
3987                         break
3988                     fi
3989                 done
3990             fi
3991
3992             # check in a few common install locations
3993             if test x"${ac_cv_c_$1config}" = x ; then
3994                 for i in `ls -d ${libdir} 2>/dev/null` \
3995                         `ls -d ${exec_prefix}/lib 2>/dev/null` \
3996                         `ls -d ${prefix}/lib 2>/dev/null` \
3997                         `ls -d /usr/local/lib 2>/dev/null` \
3998                         `ls -d /usr/contrib/lib 2>/dev/null` \
3999                         `ls -d /usr/lib 2>/dev/null` \
4000                         ; do
4001                     if test -f "$i/$1Config.sh" ; then
4002                         ac_cv_c_$1config=`(cd $i; pwd)`
4003                         break
4004                     fi
4005                 done
4006             fi
4007         ])
4008
4009         if test x"${ac_cv_c_$1config}" = x ; then
4010             $1_BIN_DIR="# no $1 configs found"
4011             AC_MSG_WARN([Cannot find $1 configuration definitions])
4012             exit 0
4013         else
4014             no_$1=
4015             $1_BIN_DIR=${ac_cv_c_$1config}
4016             AC_MSG_RESULT([found $$1_BIN_DIR/$1Config.sh])
4017         fi
4018     fi
4019 ])
4020
4021 #------------------------------------------------------------------------
4022 # TEA_LOAD_CONFIG --
4023 #
4024 #       Load the $1Config.sh file
4025 #
4026 # Arguments:
4027 #
4028 #       Requires the following vars to be set:
4029 #               $1_BIN_DIR
4030 #
4031 # Results:
4032 #
4033 #       Subst the following vars:
4034 #               $1_SRC_DIR
4035 #               $1_LIB_FILE
4036 #               $1_LIB_SPEC
4037 #
4038 #------------------------------------------------------------------------
4039
4040 AC_DEFUN([TEA_LOAD_CONFIG], [
4041     AC_MSG_CHECKING([for existence of ${$1_BIN_DIR}/$1Config.sh])
4042
4043     if test -f "${$1_BIN_DIR}/$1Config.sh" ; then
4044         AC_MSG_RESULT([loading])
4045         . "${$1_BIN_DIR}/$1Config.sh"
4046     else
4047         AC_MSG_RESULT([file not found])
4048     fi
4049
4050     #
4051     # If the $1_BIN_DIR is the build directory (not the install directory),
4052     # then set the common variable name to the value of the build variables.
4053     # For example, the variable $1_LIB_SPEC will be set to the value
4054     # of $1_BUILD_LIB_SPEC. An extension should make use of $1_LIB_SPEC
4055     # instead of $1_BUILD_LIB_SPEC since it will work with both an
4056     # installed and uninstalled version of Tcl.
4057     #
4058
4059     if test -f "${$1_BIN_DIR}/Makefile" ; then
4060         AC_MSG_WARN([Found Makefile - using build library specs for $1])
4061         $1_LIB_SPEC=${$1_BUILD_LIB_SPEC}
4062         $1_STUB_LIB_SPEC=${$1_BUILD_STUB_LIB_SPEC}
4063         $1_STUB_LIB_PATH=${$1_BUILD_STUB_LIB_PATH}
4064     fi
4065
4066     AC_SUBST($1_VERSION)
4067     AC_SUBST($1_BIN_DIR)
4068     AC_SUBST($1_SRC_DIR)
4069
4070     AC_SUBST($1_LIB_FILE)
4071     AC_SUBST($1_LIB_SPEC)
4072
4073     AC_SUBST($1_STUB_LIB_FILE)
4074     AC_SUBST($1_STUB_LIB_SPEC)
4075     AC_SUBST($1_STUB_LIB_PATH)
4076 ])
4077
4078 #------------------------------------------------------------------------
4079 # TEA_PATH_CELIB --
4080 #
4081 #       Locate Keuchel's celib emulation layer for targeting Win/CE
4082 #
4083 # Arguments:
4084 #       none
4085 #
4086 # Results:
4087 #
4088 #       Adds the following arguments to configure:
4089 #               --with-celib=...
4090 #
4091 #       Defines the following vars:
4092 #               CELIB_DIR       Full path to the directory containing
4093 #                               the include and platform lib files
4094 #------------------------------------------------------------------------
4095
4096 AC_DEFUN([TEA_PATH_CELIB], [
4097     # First, look for one uninstalled.
4098     # the alternative search directory is invoked by --with-celib
4099
4100     if test x"${no_celib}" = x ; then
4101         # we reset no_celib in case something fails here
4102         no_celib=true
4103         AC_ARG_WITH(celib,[  --with-celib=DIR        use Windows/CE support library from DIR], with_celibconfig=${withval})
4104         AC_MSG_CHECKING([for Windows/CE celib directory])
4105         AC_CACHE_VAL(ac_cv_c_celibconfig,[
4106             # First check to see if --with-celibconfig was specified.
4107             if test x"${with_celibconfig}" != x ; then
4108                 if test -d "${with_celibconfig}/inc" ; then
4109                     ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)`
4110                 else
4111                     AC_MSG_ERROR([${with_celibconfig} directory doesn't contain inc directory])
4112                 fi
4113             fi
4114
4115             # then check for a celib library
4116             if test x"${ac_cv_c_celibconfig}" = x ; then
4117                 for i in \
4118                         ../celib-palm-3.0 \
4119                         ../celib \
4120                         ../../celib-palm-3.0 \
4121                         ../../celib \
4122                         `ls -dr ../celib-*3.[[0-9]]* 2>/dev/null` \
4123                         ${srcdir}/../celib-palm-3.0 \
4124                         ${srcdir}/../celib \
4125                         `ls -dr ${srcdir}/../celib-*3.[[0-9]]* 2>/dev/null` \
4126                         ; do
4127                     if test -d "$i/inc" ; then
4128                         ac_cv_c_celibconfig=`(cd $i; pwd)`
4129                         break
4130                     fi
4131                 done
4132             fi
4133         ])
4134         if test x"${ac_cv_c_celibconfig}" = x ; then
4135             AC_MSG_ERROR([Cannot find celib support library directory])
4136         else
4137             no_celib=
4138             CELIB_DIR=${ac_cv_c_celibconfig}
4139             CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'`
4140             AC_MSG_RESULT([found $CELIB_DIR])
4141         fi
4142     fi
4143 ])
4144
4145
4146 # Local Variables:
4147 # mode: autoconf
4148 # End: