OSDN Git Service

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