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