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