xref: /freebsd/contrib/sqlite3/tea/tclconfig/tcl.m4 (revision 0078721898754f6e71063e1f566c8671288a2218)
1076b9443SCy Schubert# tcl.m4 --
2076b9443SCy Schubert#
3076b9443SCy Schubert#	This file provides a set of autoconf macros to help TEA-enable
4076b9443SCy Schubert#	a Tcl extension.
5076b9443SCy Schubert#
6076b9443SCy Schubert# Copyright (c) 1999-2000 Ajuba Solutions.
7076b9443SCy Schubert# Copyright (c) 2002-2005 ActiveState Corporation.
8076b9443SCy Schubert#
9076b9443SCy Schubert# See the file "license.terms" for information on usage and redistribution
10076b9443SCy Schubert# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11076b9443SCy Schubert
12*00787218SCy SchubertAC_PREREQ([2.69])
13076b9443SCy Schubert
14076b9443SCy Schubert# Possible values for key variables defined:
15076b9443SCy Schubert#
16076b9443SCy Schubert# TEA_WINDOWINGSYSTEM - win32 aqua x11 (mirrors 'tk windowingsystem')
17076b9443SCy Schubert# TEA_PLATFORM        - windows unix
18*00787218SCy Schubert# TEA_TK_EXTENSION    - True if this is a Tk extension
19076b9443SCy Schubert#
20076b9443SCy Schubert
21076b9443SCy Schubert#------------------------------------------------------------------------
22076b9443SCy Schubert# TEA_PATH_TCLCONFIG --
23076b9443SCy Schubert#
24076b9443SCy Schubert#	Locate the tclConfig.sh file and perform a sanity check on
25076b9443SCy Schubert#	the Tcl compile flags
26076b9443SCy Schubert#
27076b9443SCy Schubert# Arguments:
28076b9443SCy Schubert#	none
29076b9443SCy Schubert#
30076b9443SCy Schubert# Results:
31076b9443SCy Schubert#
32076b9443SCy Schubert#	Adds the following arguments to configure:
33076b9443SCy Schubert#		--with-tcl=...
34076b9443SCy Schubert#
35076b9443SCy Schubert#	Defines the following vars:
36076b9443SCy Schubert#		TCL_BIN_DIR	Full path to the directory containing
37076b9443SCy Schubert#				the tclConfig.sh file
38076b9443SCy Schubert#------------------------------------------------------------------------
39076b9443SCy Schubert
40076b9443SCy SchubertAC_DEFUN([TEA_PATH_TCLCONFIG], [
41076b9443SCy Schubert    dnl TEA specific: Make sure we are initialized
42076b9443SCy Schubert    AC_REQUIRE([TEA_INIT])
43076b9443SCy Schubert    #
44076b9443SCy Schubert    # Ok, lets find the tcl configuration
45076b9443SCy Schubert    # First, look for one uninstalled.
46076b9443SCy Schubert    # the alternative search directory is invoked by --with-tcl
47076b9443SCy Schubert    #
48076b9443SCy Schubert
49076b9443SCy Schubert    if test x"${no_tcl}" = x ; then
50076b9443SCy Schubert	# we reset no_tcl in case something fails here
51076b9443SCy Schubert	no_tcl=true
52076b9443SCy Schubert	AC_ARG_WITH(tcl,
53*00787218SCy Schubert	    AS_HELP_STRING([--with-tcl],
54076b9443SCy Schubert		[directory containing tcl configuration (tclConfig.sh)]),
55*00787218SCy Schubert	    [with_tclconfig="${withval}"])
56076b9443SCy Schubert	AC_MSG_CHECKING([for Tcl configuration])
57076b9443SCy Schubert	AC_CACHE_VAL(ac_cv_c_tclconfig,[
58076b9443SCy Schubert
59076b9443SCy Schubert	    # First check to see if --with-tcl was specified.
60076b9443SCy Schubert	    if test x"${with_tclconfig}" != x ; then
61076b9443SCy Schubert		case "${with_tclconfig}" in
62076b9443SCy Schubert		    */tclConfig.sh )
63076b9443SCy Schubert			if test -f "${with_tclconfig}"; then
64076b9443SCy Schubert			    AC_MSG_WARN([--with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself])
65076b9443SCy Schubert			    with_tclconfig="`echo "${with_tclconfig}" | sed 's!/tclConfig\.sh$!!'`"
66076b9443SCy Schubert			fi ;;
67076b9443SCy Schubert		esac
68076b9443SCy Schubert		if test -f "${with_tclconfig}/tclConfig.sh" ; then
69076b9443SCy Schubert		    ac_cv_c_tclconfig="`(cd "${with_tclconfig}"; pwd)`"
70076b9443SCy Schubert		else
71076b9443SCy Schubert		    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
72076b9443SCy Schubert		fi
73076b9443SCy Schubert	    fi
74076b9443SCy Schubert
75076b9443SCy Schubert	    # then check for a private Tcl installation
76076b9443SCy Schubert	    if test x"${ac_cv_c_tclconfig}" = x ; then
77076b9443SCy Schubert		for i in \
78076b9443SCy Schubert			../tcl \
79076b9443SCy Schubert			`ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
80076b9443SCy Schubert			`ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
81076b9443SCy Schubert			`ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
82076b9443SCy Schubert			../../tcl \
83076b9443SCy Schubert			`ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
84076b9443SCy Schubert			`ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
85076b9443SCy Schubert			`ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
86076b9443SCy Schubert			../../../tcl \
87076b9443SCy Schubert			`ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
88076b9443SCy Schubert			`ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
89076b9443SCy Schubert			`ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
90076b9443SCy Schubert		    if test "${TEA_PLATFORM}" = "windows" \
91076b9443SCy Schubert			    -a -f "$i/win/tclConfig.sh" ; then
92076b9443SCy Schubert			ac_cv_c_tclconfig="`(cd $i/win; pwd)`"
93076b9443SCy Schubert			break
94076b9443SCy Schubert		    fi
95076b9443SCy Schubert		    if test -f "$i/unix/tclConfig.sh" ; then
96076b9443SCy Schubert			ac_cv_c_tclconfig="`(cd $i/unix; pwd)`"
97076b9443SCy Schubert			break
98076b9443SCy Schubert		    fi
99076b9443SCy Schubert		done
100076b9443SCy Schubert	    fi
101076b9443SCy Schubert
102076b9443SCy Schubert	    # on Darwin, check in Framework installation locations
103076b9443SCy Schubert	    if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
104076b9443SCy Schubert		for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
105076b9443SCy Schubert			`ls -d /Library/Frameworks 2>/dev/null` \
106076b9443SCy Schubert			`ls -d /Network/Library/Frameworks 2>/dev/null` \
107*00787218SCy Schubert			`ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks/Tcl.framework 2>/dev/null` \
108*00787218SCy Schubert			`ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Network/Library/Frameworks/Tcl.framework 2>/dev/null` \
109*00787218SCy Schubert			`ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework 2>/dev/null` \
110076b9443SCy Schubert			; do
111076b9443SCy Schubert		    if test -f "$i/Tcl.framework/tclConfig.sh" ; then
112076b9443SCy Schubert			ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`"
113076b9443SCy Schubert			break
114076b9443SCy Schubert		    fi
115076b9443SCy Schubert		done
116076b9443SCy Schubert	    fi
117076b9443SCy Schubert
118076b9443SCy Schubert	    # TEA specific: on Windows, check in common installation locations
119076b9443SCy Schubert	    if test "${TEA_PLATFORM}" = "windows" \
120076b9443SCy Schubert		-a x"${ac_cv_c_tclconfig}" = x ; then
121076b9443SCy Schubert		for i in `ls -d C:/Tcl/lib 2>/dev/null` \
122076b9443SCy Schubert			`ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
123076b9443SCy Schubert			; do
124076b9443SCy Schubert		    if test -f "$i/tclConfig.sh" ; then
125076b9443SCy Schubert			ac_cv_c_tclconfig="`(cd $i; pwd)`"
126076b9443SCy Schubert			break
127076b9443SCy Schubert		    fi
128076b9443SCy Schubert		done
129076b9443SCy Schubert	    fi
130076b9443SCy Schubert
131076b9443SCy Schubert	    # check in a few common install locations
132076b9443SCy Schubert	    if test x"${ac_cv_c_tclconfig}" = x ; then
133076b9443SCy Schubert		for i in `ls -d ${libdir} 2>/dev/null` \
134076b9443SCy Schubert			`ls -d ${exec_prefix}/lib 2>/dev/null` \
135076b9443SCy Schubert			`ls -d ${prefix}/lib 2>/dev/null` \
136076b9443SCy Schubert			`ls -d /usr/local/lib 2>/dev/null` \
137076b9443SCy Schubert			`ls -d /usr/contrib/lib 2>/dev/null` \
138*00787218SCy Schubert			`ls -d /usr/pkg/lib 2>/dev/null` \
139076b9443SCy Schubert			`ls -d /usr/lib 2>/dev/null` \
140076b9443SCy Schubert			`ls -d /usr/lib64 2>/dev/null` \
141076b9443SCy Schubert			`ls -d /usr/lib/tcl8.6 2>/dev/null` \
142076b9443SCy Schubert			`ls -d /usr/lib/tcl8.5 2>/dev/null` \
143*00787218SCy Schubert			`ls -d /usr/local/lib/tcl8.6 2>/dev/null` \
144*00787218SCy Schubert			`ls -d /usr/local/lib/tcl8.5 2>/dev/null` \
145*00787218SCy Schubert			`ls -d /usr/local/lib/tcl/tcl8.6 2>/dev/null` \
146*00787218SCy Schubert			`ls -d /usr/local/lib/tcl/tcl8.5 2>/dev/null` \
147076b9443SCy Schubert			; do
148076b9443SCy Schubert		    if test -f "$i/tclConfig.sh" ; then
149076b9443SCy Schubert			ac_cv_c_tclconfig="`(cd $i; pwd)`"
150076b9443SCy Schubert			break
151076b9443SCy Schubert		    fi
152076b9443SCy Schubert		done
153076b9443SCy Schubert	    fi
154076b9443SCy Schubert
155076b9443SCy Schubert	    # check in a few other private locations
156076b9443SCy Schubert	    if test x"${ac_cv_c_tclconfig}" = x ; then
157076b9443SCy Schubert		for i in \
158076b9443SCy Schubert			${srcdir}/../tcl \
159076b9443SCy Schubert			`ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
160076b9443SCy Schubert			`ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
161076b9443SCy Schubert			`ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
162076b9443SCy Schubert		    if test "${TEA_PLATFORM}" = "windows" \
163076b9443SCy Schubert			    -a -f "$i/win/tclConfig.sh" ; then
164076b9443SCy Schubert			ac_cv_c_tclconfig="`(cd $i/win; pwd)`"
165076b9443SCy Schubert			break
166076b9443SCy Schubert		    fi
167076b9443SCy Schubert		    if test -f "$i/unix/tclConfig.sh" ; then
168076b9443SCy Schubert			ac_cv_c_tclconfig="`(cd $i/unix; pwd)`"
169076b9443SCy Schubert			break
170076b9443SCy Schubert		    fi
171076b9443SCy Schubert		done
172076b9443SCy Schubert	    fi
173076b9443SCy Schubert	])
174076b9443SCy Schubert
175076b9443SCy Schubert	if test x"${ac_cv_c_tclconfig}" = x ; then
176076b9443SCy Schubert	    TCL_BIN_DIR="# no Tcl configs found"
177076b9443SCy Schubert	    AC_MSG_ERROR([Can't find Tcl configuration definitions. Use --with-tcl to specify a directory containing tclConfig.sh])
178076b9443SCy Schubert	else
179076b9443SCy Schubert	    no_tcl=
180076b9443SCy Schubert	    TCL_BIN_DIR="${ac_cv_c_tclconfig}"
181076b9443SCy Schubert	    AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
182076b9443SCy Schubert	fi
183076b9443SCy Schubert    fi
184076b9443SCy Schubert])
185076b9443SCy Schubert
186076b9443SCy Schubert#------------------------------------------------------------------------
187076b9443SCy Schubert# TEA_PATH_TKCONFIG --
188076b9443SCy Schubert#
189076b9443SCy Schubert#	Locate the tkConfig.sh file
190076b9443SCy Schubert#
191076b9443SCy Schubert# Arguments:
192076b9443SCy Schubert#	none
193076b9443SCy Schubert#
194076b9443SCy Schubert# Results:
195076b9443SCy Schubert#
196076b9443SCy Schubert#	Adds the following arguments to configure:
197076b9443SCy Schubert#		--with-tk=...
198076b9443SCy Schubert#
199076b9443SCy Schubert#	Defines the following vars:
200076b9443SCy Schubert#		TK_BIN_DIR	Full path to the directory containing
201076b9443SCy Schubert#				the tkConfig.sh file
202076b9443SCy Schubert#------------------------------------------------------------------------
203076b9443SCy Schubert
204076b9443SCy SchubertAC_DEFUN([TEA_PATH_TKCONFIG], [
205076b9443SCy Schubert    #
206076b9443SCy Schubert    # Ok, lets find the tk configuration
207076b9443SCy Schubert    # First, look for one uninstalled.
208076b9443SCy Schubert    # the alternative search directory is invoked by --with-tk
209076b9443SCy Schubert    #
210076b9443SCy Schubert
211076b9443SCy Schubert    if test x"${no_tk}" = x ; then
212076b9443SCy Schubert	# we reset no_tk in case something fails here
213076b9443SCy Schubert	no_tk=true
214076b9443SCy Schubert	AC_ARG_WITH(tk,
215*00787218SCy Schubert	    AS_HELP_STRING([--with-tk],
216076b9443SCy Schubert		[directory containing tk configuration (tkConfig.sh)]),
217*00787218SCy Schubert	    [with_tkconfig="${withval}"])
218076b9443SCy Schubert	AC_MSG_CHECKING([for Tk configuration])
219076b9443SCy Schubert	AC_CACHE_VAL(ac_cv_c_tkconfig,[
220076b9443SCy Schubert
221076b9443SCy Schubert	    # First check to see if --with-tkconfig was specified.
222076b9443SCy Schubert	    if test x"${with_tkconfig}" != x ; then
223076b9443SCy Schubert		case "${with_tkconfig}" in
224076b9443SCy Schubert		    */tkConfig.sh )
225076b9443SCy Schubert			if test -f "${with_tkconfig}"; then
226076b9443SCy Schubert			    AC_MSG_WARN([--with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself])
227076b9443SCy Schubert			    with_tkconfig="`echo "${with_tkconfig}" | sed 's!/tkConfig\.sh$!!'`"
228076b9443SCy Schubert			fi ;;
229076b9443SCy Schubert		esac
230076b9443SCy Schubert		if test -f "${with_tkconfig}/tkConfig.sh" ; then
231076b9443SCy Schubert		    ac_cv_c_tkconfig="`(cd "${with_tkconfig}"; pwd)`"
232076b9443SCy Schubert		else
233076b9443SCy Schubert		    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
234076b9443SCy Schubert		fi
235076b9443SCy Schubert	    fi
236076b9443SCy Schubert
237076b9443SCy Schubert	    # then check for a private Tk library
238076b9443SCy Schubert	    if test x"${ac_cv_c_tkconfig}" = x ; then
239076b9443SCy Schubert		for i in \
240076b9443SCy Schubert			../tk \
241076b9443SCy Schubert			`ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
242076b9443SCy Schubert			`ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
243076b9443SCy Schubert			`ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
244076b9443SCy Schubert			../../tk \
245076b9443SCy Schubert			`ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
246076b9443SCy Schubert			`ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
247076b9443SCy Schubert			`ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
248076b9443SCy Schubert			../../../tk \
249076b9443SCy Schubert			`ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
250076b9443SCy Schubert			`ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
251076b9443SCy Schubert			`ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
252076b9443SCy Schubert		    if test "${TEA_PLATFORM}" = "windows" \
253076b9443SCy Schubert			    -a -f "$i/win/tkConfig.sh" ; then
254076b9443SCy Schubert			ac_cv_c_tkconfig="`(cd $i/win; pwd)`"
255076b9443SCy Schubert			break
256076b9443SCy Schubert		    fi
257076b9443SCy Schubert		    if test -f "$i/unix/tkConfig.sh" ; then
258076b9443SCy Schubert			ac_cv_c_tkconfig="`(cd $i/unix; pwd)`"
259076b9443SCy Schubert			break
260076b9443SCy Schubert		    fi
261076b9443SCy Schubert		done
262076b9443SCy Schubert	    fi
263076b9443SCy Schubert
264076b9443SCy Schubert	    # on Darwin, check in Framework installation locations
265076b9443SCy Schubert	    if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then
266076b9443SCy Schubert		for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
267076b9443SCy Schubert			`ls -d /Library/Frameworks 2>/dev/null` \
268076b9443SCy Schubert			`ls -d /Network/Library/Frameworks 2>/dev/null` \
269076b9443SCy Schubert			; do
270076b9443SCy Schubert		    if test -f "$i/Tk.framework/tkConfig.sh" ; then
271076b9443SCy Schubert			ac_cv_c_tkconfig="`(cd $i/Tk.framework; pwd)`"
272076b9443SCy Schubert			break
273076b9443SCy Schubert		    fi
274076b9443SCy Schubert		done
275076b9443SCy Schubert	    fi
276076b9443SCy Schubert
277076b9443SCy Schubert	    # check in a few common install locations
278076b9443SCy Schubert	    if test x"${ac_cv_c_tkconfig}" = x ; then
279076b9443SCy Schubert		for i in `ls -d ${libdir} 2>/dev/null` \
280076b9443SCy Schubert			`ls -d ${exec_prefix}/lib 2>/dev/null` \
281076b9443SCy Schubert			`ls -d ${prefix}/lib 2>/dev/null` \
282076b9443SCy Schubert			`ls -d /usr/local/lib 2>/dev/null` \
283076b9443SCy Schubert			`ls -d /usr/contrib/lib 2>/dev/null` \
284*00787218SCy Schubert			`ls -d /usr/pkg/lib 2>/dev/null` \
285*00787218SCy Schubert			`ls -d /usr/lib/tk8.6 2>/dev/null` \
286*00787218SCy Schubert			`ls -d /usr/lib/tk8.5 2>/dev/null` \
287076b9443SCy Schubert			`ls -d /usr/lib 2>/dev/null` \
288076b9443SCy Schubert			`ls -d /usr/lib64 2>/dev/null` \
289*00787218SCy Schubert			`ls -d /usr/local/lib/tk8.6 2>/dev/null` \
290*00787218SCy Schubert			`ls -d /usr/local/lib/tk8.5 2>/dev/null` \
291*00787218SCy Schubert			`ls -d /usr/local/lib/tcl/tk8.6 2>/dev/null` \
292*00787218SCy Schubert			`ls -d /usr/local/lib/tcl/tk8.5 2>/dev/null` \
293076b9443SCy Schubert			; do
294076b9443SCy Schubert		    if test -f "$i/tkConfig.sh" ; then
295076b9443SCy Schubert			ac_cv_c_tkconfig="`(cd $i; pwd)`"
296076b9443SCy Schubert			break
297076b9443SCy Schubert		    fi
298076b9443SCy Schubert		done
299076b9443SCy Schubert	    fi
300076b9443SCy Schubert
301076b9443SCy Schubert	    # TEA specific: on Windows, check in common installation locations
302076b9443SCy Schubert	    if test "${TEA_PLATFORM}" = "windows" \
303076b9443SCy Schubert		-a x"${ac_cv_c_tkconfig}" = x ; then
304076b9443SCy Schubert		for i in `ls -d C:/Tcl/lib 2>/dev/null` \
305076b9443SCy Schubert			`ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
306076b9443SCy Schubert			; do
307076b9443SCy Schubert		    if test -f "$i/tkConfig.sh" ; then
308076b9443SCy Schubert			ac_cv_c_tkconfig="`(cd $i; pwd)`"
309076b9443SCy Schubert			break
310076b9443SCy Schubert		    fi
311076b9443SCy Schubert		done
312076b9443SCy Schubert	    fi
313076b9443SCy Schubert
314076b9443SCy Schubert	    # check in a few other private locations
315076b9443SCy Schubert	    if test x"${ac_cv_c_tkconfig}" = x ; then
316076b9443SCy Schubert		for i in \
317076b9443SCy Schubert			${srcdir}/../tk \
318076b9443SCy Schubert			`ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
319076b9443SCy Schubert			`ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
320076b9443SCy Schubert			`ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
321076b9443SCy Schubert		    if test "${TEA_PLATFORM}" = "windows" \
322076b9443SCy Schubert			    -a -f "$i/win/tkConfig.sh" ; then
323076b9443SCy Schubert			ac_cv_c_tkconfig="`(cd $i/win; pwd)`"
324076b9443SCy Schubert			break
325076b9443SCy Schubert		    fi
326076b9443SCy Schubert		    if test -f "$i/unix/tkConfig.sh" ; then
327076b9443SCy Schubert			ac_cv_c_tkconfig="`(cd $i/unix; pwd)`"
328076b9443SCy Schubert			break
329076b9443SCy Schubert		    fi
330076b9443SCy Schubert		done
331076b9443SCy Schubert	    fi
332076b9443SCy Schubert	])
333076b9443SCy Schubert
334076b9443SCy Schubert	if test x"${ac_cv_c_tkconfig}" = x ; then
335076b9443SCy Schubert	    TK_BIN_DIR="# no Tk configs found"
336076b9443SCy Schubert	    AC_MSG_ERROR([Can't find Tk configuration definitions. Use --with-tk to specify a directory containing tkConfig.sh])
337076b9443SCy Schubert	else
338076b9443SCy Schubert	    no_tk=
339076b9443SCy Schubert	    TK_BIN_DIR="${ac_cv_c_tkconfig}"
340076b9443SCy Schubert	    AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
341076b9443SCy Schubert	fi
342076b9443SCy Schubert    fi
343076b9443SCy Schubert])
344076b9443SCy Schubert
345076b9443SCy Schubert#------------------------------------------------------------------------
346076b9443SCy Schubert# TEA_LOAD_TCLCONFIG --
347076b9443SCy Schubert#
348076b9443SCy Schubert#	Load the tclConfig.sh file
349076b9443SCy Schubert#
350076b9443SCy Schubert# Arguments:
351076b9443SCy Schubert#
352076b9443SCy Schubert#	Requires the following vars to be set:
353076b9443SCy Schubert#		TCL_BIN_DIR
354076b9443SCy Schubert#
355076b9443SCy Schubert# Results:
356076b9443SCy Schubert#
357076b9443SCy Schubert#	Substitutes the following vars:
358076b9443SCy Schubert#		TCL_BIN_DIR
359076b9443SCy Schubert#		TCL_SRC_DIR
360076b9443SCy Schubert#		TCL_LIB_FILE
361*00787218SCy Schubert#		TCL_ZIP_FILE
362*00787218SCy Schubert#		TCL_ZIPFS_SUPPORT
363076b9443SCy Schubert#------------------------------------------------------------------------
364076b9443SCy Schubert
365076b9443SCy SchubertAC_DEFUN([TEA_LOAD_TCLCONFIG], [
366076b9443SCy Schubert    AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
367076b9443SCy Schubert
368076b9443SCy Schubert    if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
369076b9443SCy Schubert        AC_MSG_RESULT([loading])
370076b9443SCy Schubert	. "${TCL_BIN_DIR}/tclConfig.sh"
371076b9443SCy Schubert    else
372076b9443SCy Schubert        AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
373076b9443SCy Schubert    fi
374076b9443SCy Schubert
375076b9443SCy Schubert    # If the TCL_BIN_DIR is the build directory (not the install directory),
376076b9443SCy Schubert    # then set the common variable name to the value of the build variables.
377076b9443SCy Schubert    # For example, the variable TCL_LIB_SPEC will be set to the value
378076b9443SCy Schubert    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
379076b9443SCy Schubert    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
380076b9443SCy Schubert    # installed and uninstalled version of Tcl.
381076b9443SCy Schubert    if test -f "${TCL_BIN_DIR}/Makefile" ; then
382076b9443SCy Schubert        TCL_LIB_SPEC="${TCL_BUILD_LIB_SPEC}"
383076b9443SCy Schubert        TCL_STUB_LIB_SPEC="${TCL_BUILD_STUB_LIB_SPEC}"
384076b9443SCy Schubert        TCL_STUB_LIB_PATH="${TCL_BUILD_STUB_LIB_PATH}"
385076b9443SCy Schubert    elif test "`uname -s`" = "Darwin"; then
386076b9443SCy Schubert	# If Tcl was built as a framework, attempt to use the libraries
387076b9443SCy Schubert	# from the framework at the given location so that linking works
388076b9443SCy Schubert	# against Tcl.framework installed in an arbitrary location.
389076b9443SCy Schubert	case ${TCL_DEFS} in
390076b9443SCy Schubert	    *TCL_FRAMEWORK*)
391076b9443SCy Schubert		if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then
392076b9443SCy Schubert		    for i in "`cd "${TCL_BIN_DIR}"; pwd`" \
393076b9443SCy Schubert			     "`cd "${TCL_BIN_DIR}"/../..; pwd`"; do
394076b9443SCy Schubert			if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
395076b9443SCy Schubert			    TCL_LIB_SPEC="-F`dirname "$i" | sed -e 's/ /\\\\ /g'` -framework ${TCL_LIB_FILE}"
396076b9443SCy Schubert			    break
397076b9443SCy Schubert			fi
398076b9443SCy Schubert		    done
399076b9443SCy Schubert		fi
400076b9443SCy Schubert		if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then
401076b9443SCy Schubert		    TCL_STUB_LIB_SPEC="-L`echo "${TCL_BIN_DIR}"  | sed -e 's/ /\\\\ /g'` ${TCL_STUB_LIB_FLAG}"
402076b9443SCy Schubert		    TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
403076b9443SCy Schubert		fi
404076b9443SCy Schubert		;;
405076b9443SCy Schubert	esac
406076b9443SCy Schubert    fi
407076b9443SCy Schubert
408076b9443SCy Schubert    AC_SUBST(TCL_VERSION)
409076b9443SCy Schubert    AC_SUBST(TCL_PATCH_LEVEL)
410076b9443SCy Schubert    AC_SUBST(TCL_BIN_DIR)
411076b9443SCy Schubert    AC_SUBST(TCL_SRC_DIR)
412076b9443SCy Schubert
413076b9443SCy Schubert    AC_SUBST(TCL_LIB_FILE)
414076b9443SCy Schubert    AC_SUBST(TCL_LIB_FLAG)
415076b9443SCy Schubert    AC_SUBST(TCL_LIB_SPEC)
416076b9443SCy Schubert
417076b9443SCy Schubert    AC_SUBST(TCL_STUB_LIB_FILE)
418076b9443SCy Schubert    AC_SUBST(TCL_STUB_LIB_FLAG)
419076b9443SCy Schubert    AC_SUBST(TCL_STUB_LIB_SPEC)
420076b9443SCy Schubert
421076b9443SCy Schubert    AC_MSG_CHECKING([platform])
422076b9443SCy Schubert    hold_cc=$CC; CC="$TCL_CC"
423*00787218SCy Schubert    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
424076b9443SCy Schubert	    #ifdef _WIN32
425076b9443SCy Schubert		#error win32
426076b9443SCy Schubert	    #endif
427*00787218SCy Schubert	]])],[
428*00787218SCy Schubert	    # first test we've already retrieved platform (cross-compile), fallback to unix otherwise:
429*00787218SCy Schubert	    TEA_PLATFORM="${TEA_PLATFORM-unix}"
430*00787218SCy Schubert	    CYGPATH=echo
431*00787218SCy Schubert	],[
432076b9443SCy Schubert	    TEA_PLATFORM="windows"
433*00787218SCy Schubert	    AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo)
434*00787218SCy Schubert    ])
435076b9443SCy Schubert    CC=$hold_cc
436076b9443SCy Schubert    AC_MSG_RESULT($TEA_PLATFORM)
437076b9443SCy Schubert
438076b9443SCy Schubert    # The BUILD_$pkg is to define the correct extern storage class
439076b9443SCy Schubert    # handling when making this package
440076b9443SCy Schubert    AC_DEFINE_UNQUOTED(BUILD_${PACKAGE_NAME}, [],
441076b9443SCy Schubert	    [Building extension source?])
442076b9443SCy Schubert    # Do this here as we have fully defined TEA_PLATFORM now
443076b9443SCy Schubert    if test "${TEA_PLATFORM}" = "windows" ; then
444076b9443SCy Schubert	EXEEXT=".exe"
445076b9443SCy Schubert	CLEANFILES="$CLEANFILES *.lib *.dll *.pdb *.exp"
446076b9443SCy Schubert    fi
447076b9443SCy Schubert
448076b9443SCy Schubert    # TEA specific:
449076b9443SCy Schubert    AC_SUBST(CLEANFILES)
450076b9443SCy Schubert    AC_SUBST(TCL_LIBS)
451076b9443SCy Schubert    AC_SUBST(TCL_DEFS)
452076b9443SCy Schubert    AC_SUBST(TCL_EXTRA_CFLAGS)
453076b9443SCy Schubert    AC_SUBST(TCL_LD_FLAGS)
454076b9443SCy Schubert    AC_SUBST(TCL_SHLIB_LD_LIBS)
455076b9443SCy Schubert])
456076b9443SCy Schubert
457076b9443SCy Schubert#------------------------------------------------------------------------
458076b9443SCy Schubert# TEA_LOAD_TKCONFIG --
459076b9443SCy Schubert#
460076b9443SCy Schubert#	Load the tkConfig.sh file
461076b9443SCy Schubert#
462076b9443SCy Schubert# Arguments:
463076b9443SCy Schubert#
464076b9443SCy Schubert#	Requires the following vars to be set:
465076b9443SCy Schubert#		TK_BIN_DIR
466076b9443SCy Schubert#
467076b9443SCy Schubert# Results:
468076b9443SCy Schubert#
469076b9443SCy Schubert#	Sets the following vars that should be in tkConfig.sh:
470076b9443SCy Schubert#		TK_BIN_DIR
471076b9443SCy Schubert#------------------------------------------------------------------------
472076b9443SCy Schubert
473076b9443SCy SchubertAC_DEFUN([TEA_LOAD_TKCONFIG], [
474076b9443SCy Schubert    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
475076b9443SCy Schubert
476076b9443SCy Schubert    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
477076b9443SCy Schubert        AC_MSG_RESULT([loading])
478076b9443SCy Schubert	. "${TK_BIN_DIR}/tkConfig.sh"
479076b9443SCy Schubert    else
480076b9443SCy Schubert        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
481076b9443SCy Schubert    fi
482076b9443SCy Schubert
483076b9443SCy Schubert    # If the TK_BIN_DIR is the build directory (not the install directory),
484076b9443SCy Schubert    # then set the common variable name to the value of the build variables.
485076b9443SCy Schubert    # For example, the variable TK_LIB_SPEC will be set to the value
486076b9443SCy Schubert    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
487076b9443SCy Schubert    # instead of TK_BUILD_LIB_SPEC since it will work with both an
488076b9443SCy Schubert    # installed and uninstalled version of Tcl.
489076b9443SCy Schubert    if test -f "${TK_BIN_DIR}/Makefile" ; then
490076b9443SCy Schubert        TK_LIB_SPEC="${TK_BUILD_LIB_SPEC}"
491076b9443SCy Schubert        TK_STUB_LIB_SPEC="${TK_BUILD_STUB_LIB_SPEC}"
492076b9443SCy Schubert        TK_STUB_LIB_PATH="${TK_BUILD_STUB_LIB_PATH}"
493076b9443SCy Schubert    elif test "`uname -s`" = "Darwin"; then
494076b9443SCy Schubert	# If Tk was built as a framework, attempt to use the libraries
495076b9443SCy Schubert	# from the framework at the given location so that linking works
496076b9443SCy Schubert	# against Tk.framework installed in an arbitrary location.
497076b9443SCy Schubert	case ${TK_DEFS} in
498076b9443SCy Schubert	    *TK_FRAMEWORK*)
499076b9443SCy Schubert		if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then
500076b9443SCy Schubert		    for i in "`cd "${TK_BIN_DIR}"; pwd`" \
501076b9443SCy Schubert			     "`cd "${TK_BIN_DIR}"/../..; pwd`"; do
502076b9443SCy Schubert			if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
503076b9443SCy Schubert			    TK_LIB_SPEC="-F`dirname "$i" | sed -e 's/ /\\\\ /g'` -framework ${TK_LIB_FILE}"
504076b9443SCy Schubert			    break
505076b9443SCy Schubert			fi
506076b9443SCy Schubert		    done
507076b9443SCy Schubert		fi
508076b9443SCy Schubert		if test -f "${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"; then
509076b9443SCy Schubert		    TK_STUB_LIB_SPEC="-L` echo "${TK_BIN_DIR}"  | sed -e 's/ /\\\\ /g'` ${TK_STUB_LIB_FLAG}"
510076b9443SCy Schubert		    TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
511076b9443SCy Schubert		fi
512076b9443SCy Schubert		;;
513076b9443SCy Schubert	esac
514076b9443SCy Schubert    fi
515076b9443SCy Schubert
516076b9443SCy Schubert    # TEA specific: Ensure windowingsystem is defined
517076b9443SCy Schubert    if test "${TEA_PLATFORM}" = "unix" ; then
518076b9443SCy Schubert	case ${TK_DEFS} in
519076b9443SCy Schubert	    *MAC_OSX_TK*)
520076b9443SCy Schubert		AC_DEFINE(MAC_OSX_TK, 1, [Are we building against Mac OS X TkAqua?])
521076b9443SCy Schubert		TEA_WINDOWINGSYSTEM="aqua"
522076b9443SCy Schubert		;;
523076b9443SCy Schubert	    *)
524076b9443SCy Schubert		TEA_WINDOWINGSYSTEM="x11"
525076b9443SCy Schubert		;;
526076b9443SCy Schubert	esac
527076b9443SCy Schubert    elif test "${TEA_PLATFORM}" = "windows" ; then
528076b9443SCy Schubert	TEA_WINDOWINGSYSTEM="win32"
529076b9443SCy Schubert    fi
530076b9443SCy Schubert
531076b9443SCy Schubert    AC_SUBST(TK_VERSION)
532076b9443SCy Schubert    AC_SUBST(TK_BIN_DIR)
533076b9443SCy Schubert    AC_SUBST(TK_SRC_DIR)
534076b9443SCy Schubert
535076b9443SCy Schubert    AC_SUBST(TK_LIB_FILE)
536076b9443SCy Schubert    AC_SUBST(TK_LIB_FLAG)
537076b9443SCy Schubert    AC_SUBST(TK_LIB_SPEC)
538076b9443SCy Schubert
539076b9443SCy Schubert    AC_SUBST(TK_STUB_LIB_FILE)
540076b9443SCy Schubert    AC_SUBST(TK_STUB_LIB_FLAG)
541076b9443SCy Schubert    AC_SUBST(TK_STUB_LIB_SPEC)
542076b9443SCy Schubert
543076b9443SCy Schubert    # TEA specific:
544076b9443SCy Schubert    AC_SUBST(TK_LIBS)
545076b9443SCy Schubert    AC_SUBST(TK_XINCLUDES)
546076b9443SCy Schubert])
547076b9443SCy Schubert
548076b9443SCy Schubert#------------------------------------------------------------------------
549076b9443SCy Schubert# TEA_PROG_TCLSH
550076b9443SCy Schubert#	Determine the fully qualified path name of the tclsh executable
551076b9443SCy Schubert#	in the Tcl build directory or the tclsh installed in a bin
552076b9443SCy Schubert#	directory. This macro will correctly determine the name
553076b9443SCy Schubert#	of the tclsh executable even if tclsh has not yet been
554076b9443SCy Schubert#	built in the build directory. The tclsh found is always
555076b9443SCy Schubert#	associated with a tclConfig.sh file. This tclsh should be used
556076b9443SCy Schubert#	only for running extension test cases. It should never be
557076b9443SCy Schubert#	or generation of files (like pkgIndex.tcl) at build time.
558076b9443SCy Schubert#
559076b9443SCy Schubert# Arguments:
560076b9443SCy Schubert#	none
561076b9443SCy Schubert#
562076b9443SCy Schubert# Results:
563076b9443SCy Schubert#	Substitutes the following vars:
564076b9443SCy Schubert#		TCLSH_PROG
565076b9443SCy Schubert#------------------------------------------------------------------------
566076b9443SCy Schubert
567076b9443SCy SchubertAC_DEFUN([TEA_PROG_TCLSH], [
568076b9443SCy Schubert    AC_MSG_CHECKING([for tclsh])
569076b9443SCy Schubert    if test -f "${TCL_BIN_DIR}/Makefile" ; then
570076b9443SCy Schubert        # tclConfig.sh is in Tcl build directory
571076b9443SCy Schubert        if test "${TEA_PLATFORM}" = "windows"; then
572*00787218SCy Schubert          if test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" ; then
573*00787218SCy Schubert            TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}"
574*00787218SCy Schubert          elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}s${EXEEXT}" ; then
575*00787218SCy Schubert            TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}s${EXEEXT}"
576*00787218SCy Schubert          elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}t${EXEEXT}" ; then
577*00787218SCy Schubert            TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}t${EXEEXT}"
578*00787218SCy Schubert          elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}st${EXEEXT}" ; then
579*00787218SCy Schubert            TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}st${EXEEXT}"
580*00787218SCy Schubert          fi
581076b9443SCy Schubert        else
582076b9443SCy Schubert            TCLSH_PROG="${TCL_BIN_DIR}/tclsh"
583076b9443SCy Schubert        fi
584076b9443SCy Schubert    else
585076b9443SCy Schubert        # tclConfig.sh is in install location
586076b9443SCy Schubert        if test "${TEA_PLATFORM}" = "windows"; then
587*00787218SCy Schubert            TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}"
588076b9443SCy Schubert        else
589*00787218SCy Schubert            TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}"
590076b9443SCy Schubert        fi
591076b9443SCy Schubert        list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \
592076b9443SCy Schubert              `ls -d ${TCL_BIN_DIR}/..     2>/dev/null` \
593076b9443SCy Schubert              `ls -d ${TCL_PREFIX}/bin     2>/dev/null`"
594076b9443SCy Schubert        for i in $list ; do
595076b9443SCy Schubert            if test -f "$i/${TCLSH_PROG}" ; then
596076b9443SCy Schubert                REAL_TCL_BIN_DIR="`cd "$i"; pwd`/"
597076b9443SCy Schubert                break
598076b9443SCy Schubert            fi
599076b9443SCy Schubert        done
600076b9443SCy Schubert        TCLSH_PROG="${REAL_TCL_BIN_DIR}${TCLSH_PROG}"
601076b9443SCy Schubert    fi
602076b9443SCy Schubert    AC_MSG_RESULT([${TCLSH_PROG}])
603076b9443SCy Schubert    AC_SUBST(TCLSH_PROG)
604076b9443SCy Schubert])
605076b9443SCy Schubert
606076b9443SCy Schubert#------------------------------------------------------------------------
607076b9443SCy Schubert# TEA_PROG_WISH
608076b9443SCy Schubert#	Determine the fully qualified path name of the wish executable
609076b9443SCy Schubert#	in the Tk build directory or the wish installed in a bin
610076b9443SCy Schubert#	directory. This macro will correctly determine the name
611076b9443SCy Schubert#	of the wish executable even if wish has not yet been
612076b9443SCy Schubert#	built in the build directory. The wish found is always
613076b9443SCy Schubert#	associated with a tkConfig.sh file. This wish should be used
614076b9443SCy Schubert#	only for running extension test cases. It should never be
615076b9443SCy Schubert#	or generation of files (like pkgIndex.tcl) at build time.
616076b9443SCy Schubert#
617076b9443SCy Schubert# Arguments:
618076b9443SCy Schubert#	none
619076b9443SCy Schubert#
620076b9443SCy Schubert# Results:
621076b9443SCy Schubert#	Substitutes the following vars:
622076b9443SCy Schubert#		WISH_PROG
623076b9443SCy Schubert#------------------------------------------------------------------------
624076b9443SCy Schubert
625076b9443SCy SchubertAC_DEFUN([TEA_PROG_WISH], [
626076b9443SCy Schubert    AC_MSG_CHECKING([for wish])
627076b9443SCy Schubert    if test -f "${TK_BIN_DIR}/Makefile" ; then
628076b9443SCy Schubert        # tkConfig.sh is in Tk build directory
629076b9443SCy Schubert        if test "${TEA_PLATFORM}" = "windows"; then
630*00787218SCy Schubert          if test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${EXEEXT}" ; then
631*00787218SCy Schubert            WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${EXEEXT}"
632*00787218SCy Schubert          elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}s${EXEEXT}" ; then
633*00787218SCy Schubert            WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}$s{EXEEXT}"
634*00787218SCy Schubert          elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}t${EXEEXT}" ; then
635*00787218SCy Schubert            WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}t${EXEEXT}"
636*00787218SCy Schubert          elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}st${EXEEXT}" ; then
637*00787218SCy Schubert            WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}st${EXEEXT}"
638*00787218SCy Schubert          fi
639076b9443SCy Schubert        else
640076b9443SCy Schubert            WISH_PROG="${TK_BIN_DIR}/wish"
641076b9443SCy Schubert        fi
642076b9443SCy Schubert    else
643076b9443SCy Schubert        # tkConfig.sh is in install location
644076b9443SCy Schubert        if test "${TEA_PLATFORM}" = "windows"; then
645*00787218SCy Schubert            WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${EXEEXT}"
646076b9443SCy Schubert        else
647*00787218SCy Schubert            WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}"
648076b9443SCy Schubert        fi
649076b9443SCy Schubert        list="`ls -d ${TK_BIN_DIR}/../bin 2>/dev/null` \
650076b9443SCy Schubert              `ls -d ${TK_BIN_DIR}/..     2>/dev/null` \
651076b9443SCy Schubert              `ls -d ${TK_PREFIX}/bin     2>/dev/null`"
652076b9443SCy Schubert        for i in $list ; do
653076b9443SCy Schubert            if test -f "$i/${WISH_PROG}" ; then
654076b9443SCy Schubert                REAL_TK_BIN_DIR="`cd "$i"; pwd`/"
655076b9443SCy Schubert                break
656076b9443SCy Schubert            fi
657076b9443SCy Schubert        done
658076b9443SCy Schubert        WISH_PROG="${REAL_TK_BIN_DIR}${WISH_PROG}"
659076b9443SCy Schubert    fi
660076b9443SCy Schubert    AC_MSG_RESULT([${WISH_PROG}])
661076b9443SCy Schubert    AC_SUBST(WISH_PROG)
662076b9443SCy Schubert])
663076b9443SCy Schubert
664076b9443SCy Schubert#------------------------------------------------------------------------
665076b9443SCy Schubert# TEA_ENABLE_SHARED --
666076b9443SCy Schubert#
667076b9443SCy Schubert#	Allows the building of shared libraries
668076b9443SCy Schubert#
669076b9443SCy Schubert# Arguments:
670076b9443SCy Schubert#	none
671076b9443SCy Schubert#
672076b9443SCy Schubert# Results:
673076b9443SCy Schubert#
674076b9443SCy Schubert#	Adds the following arguments to configure:
675076b9443SCy Schubert#		--enable-shared=yes|no
676*00787218SCy Schubert#		--enable-stubs=yes|no
677076b9443SCy Schubert#
678076b9443SCy Schubert#	Defines the following vars:
679076b9443SCy Schubert#		STATIC_BUILD	Used for building import/export libraries
680076b9443SCy Schubert#				on Windows.
681076b9443SCy Schubert#
682076b9443SCy Schubert#	Sets the following vars:
683076b9443SCy Schubert#		SHARED_BUILD	Value of 1 or 0
684*00787218SCy Schubert#               STUBS_BUILD     Value if 1 or 0
685*00787218SCy Schubert#               USE_TCL_STUBS   Value true: if SHARED_BUILD or --enable-stubs
686*00787218SCy Schubert#               USE_TCLOO_STUBS Value true: if SHARED_BUILD or --enable-stubs
687*00787218SCy Schubert#               USE_TK_STUBS    Value true: if SHARED_BUILD or --enable-stubs
688*00787218SCy Schubert#                                AND TEA_WINDOWING_SYSTEM != ""
689076b9443SCy Schubert#------------------------------------------------------------------------
690076b9443SCy SchubertAC_DEFUN([TEA_ENABLE_SHARED], [
691076b9443SCy Schubert    AC_MSG_CHECKING([how to build libraries])
692076b9443SCy Schubert    AC_ARG_ENABLE(shared,
693*00787218SCy Schubert	AS_HELP_STRING([--enable-shared],
694076b9443SCy Schubert	    [build and link with shared libraries (default: on)]),
695*00787218SCy Schubert	[shared_ok=$enableval], [shared_ok=yes])
696076b9443SCy Schubert
697076b9443SCy Schubert    if test "${enable_shared+set}" = set; then
698076b9443SCy Schubert	enableval="$enable_shared"
699*00787218SCy Schubert	shared_ok=$enableval
700076b9443SCy Schubert    else
701*00787218SCy Schubert	shared_ok=yes
702076b9443SCy Schubert    fi
703076b9443SCy Schubert
704*00787218SCy Schubert    AC_ARG_ENABLE(stubs,
705*00787218SCy Schubert	AS_HELP_STRING([--enable-stubs],
706*00787218SCy Schubert	    [build and link with stub libraries. Always true for shared builds (default: on)]),
707*00787218SCy Schubert	[stubs_ok=$enableval], [stubs_ok=yes])
708*00787218SCy Schubert
709*00787218SCy Schubert    if test "${enable_stubs+set}" = set; then
710*00787218SCy Schubert	enableval="$enable_stubs"
711*00787218SCy Schubert	stubs_ok=$enableval
712*00787218SCy Schubert    else
713*00787218SCy Schubert	stubs_ok=yes
714*00787218SCy Schubert    fi
715*00787218SCy Schubert
716*00787218SCy Schubert    # Stubs are always enabled for shared builds
717*00787218SCy Schubert    if test "$shared_ok" = "yes" ; then
718076b9443SCy Schubert	AC_MSG_RESULT([shared])
719076b9443SCy Schubert	SHARED_BUILD=1
720*00787218SCy Schubert        STUBS_BUILD=1
721076b9443SCy Schubert    else
722076b9443SCy Schubert	AC_MSG_RESULT([static])
723076b9443SCy Schubert	SHARED_BUILD=0
724*00787218SCy Schubert	AC_DEFINE(STATIC_BUILD, 1, [This a static build])
725*00787218SCy Schubert        if test "$stubs_ok" = "yes" ; then
726*00787218SCy Schubert          STUBS_BUILD=1
727*00787218SCy Schubert        else
728*00787218SCy Schubert          STUBS_BUILD=0
729076b9443SCy Schubert        fi
730*00787218SCy Schubert    fi
731*00787218SCy Schubert    if test "${STUBS_BUILD}" = "1" ; then
732*00787218SCy Schubert      AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
733*00787218SCy Schubert      AC_DEFINE(USE_TCLOO_STUBS, 1, [Use TclOO stubs])
734*00787218SCy Schubert      if test "${TEA_WINDOWINGSYSTEM}" != ""; then
735*00787218SCy Schubert        AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs])
736*00787218SCy Schubert      fi
737*00787218SCy Schubert    fi
738*00787218SCy Schubert
739076b9443SCy Schubert    AC_SUBST(SHARED_BUILD)
740*00787218SCy Schubert    AC_SUBST(STUBS_BUILD)
741076b9443SCy Schubert])
742076b9443SCy Schubert
743076b9443SCy Schubert#------------------------------------------------------------------------
744076b9443SCy Schubert# TEA_ENABLE_THREADS --
745076b9443SCy Schubert#
746076b9443SCy Schubert#	Specify if thread support should be enabled.  If "yes" is specified
747076b9443SCy Schubert#	as an arg (optional), threads are enabled by default, "no" means
748076b9443SCy Schubert#	threads are disabled.  "yes" is the default.
749076b9443SCy Schubert#
750076b9443SCy Schubert#	TCL_THREADS is checked so that if you are compiling an extension
751076b9443SCy Schubert#	against a threaded core, your extension must be compiled threaded
752076b9443SCy Schubert#	as well.
753076b9443SCy Schubert#
754076b9443SCy Schubert#	Note that it is legal to have a thread enabled extension run in a
755076b9443SCy Schubert#	threaded or non-threaded Tcl core, but a non-threaded extension may
756076b9443SCy Schubert#	only run in a non-threaded Tcl core.
757076b9443SCy Schubert#
758076b9443SCy Schubert# Arguments:
759076b9443SCy Schubert#	none
760076b9443SCy Schubert#
761076b9443SCy Schubert# Results:
762076b9443SCy Schubert#
763076b9443SCy Schubert#	Adds the following arguments to configure:
764076b9443SCy Schubert#		--enable-threads
765076b9443SCy Schubert#
766076b9443SCy Schubert#	Sets the following vars:
767076b9443SCy Schubert#		THREADS_LIBS	Thread library(s)
768076b9443SCy Schubert#
769076b9443SCy Schubert#	Defines the following vars:
770076b9443SCy Schubert#		TCL_THREADS
771076b9443SCy Schubert#		_REENTRANT
772076b9443SCy Schubert#		_THREAD_SAFE
773076b9443SCy Schubert#------------------------------------------------------------------------
774076b9443SCy Schubert
775076b9443SCy SchubertAC_DEFUN([TEA_ENABLE_THREADS], [
776076b9443SCy Schubert    AC_ARG_ENABLE(threads,
777*00787218SCy Schubert	AS_HELP_STRING([--enable-threads],
778*00787218SCy Schubert	    [build with threads (default: on)]),
779076b9443SCy Schubert	[tcl_ok=$enableval], [tcl_ok=yes])
780076b9443SCy Schubert
781076b9443SCy Schubert    if test "${enable_threads+set}" = set; then
782076b9443SCy Schubert	enableval="$enable_threads"
783076b9443SCy Schubert	tcl_ok=$enableval
784076b9443SCy Schubert    else
785076b9443SCy Schubert	tcl_ok=yes
786076b9443SCy Schubert    fi
787076b9443SCy Schubert
788076b9443SCy Schubert    if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
789076b9443SCy Schubert	TCL_THREADS=1
790076b9443SCy Schubert
791076b9443SCy Schubert	if test "${TEA_PLATFORM}" != "windows" ; then
792076b9443SCy Schubert	    # We are always OK on Windows, so check what this platform wants:
793076b9443SCy Schubert
794076b9443SCy Schubert	    # USE_THREAD_ALLOC tells us to try the special thread-based
795076b9443SCy Schubert	    # allocator that significantly reduces lock contention
796076b9443SCy Schubert	    AC_DEFINE(USE_THREAD_ALLOC, 1,
797076b9443SCy Schubert		[Do we want to use the threaded memory allocator?])
798076b9443SCy Schubert	    AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
799076b9443SCy Schubert	    if test "`uname -s`" = "SunOS" ; then
800076b9443SCy Schubert		AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
801076b9443SCy Schubert			[Do we really want to follow the standard? Yes we do!])
802076b9443SCy Schubert	    fi
803076b9443SCy Schubert	    AC_DEFINE(_THREAD_SAFE, 1, [Do we want the thread-safe OS API?])
804076b9443SCy Schubert	    AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
805076b9443SCy Schubert	    if test "$tcl_ok" = "no"; then
806076b9443SCy Schubert		# Check a little harder for __pthread_mutex_init in the same
807076b9443SCy Schubert		# library, as some systems hide it there until pthread.h is
808076b9443SCy Schubert		# defined.  We could alternatively do an AC_TRY_COMPILE with
809076b9443SCy Schubert		# pthread.h, but that will work with libpthread really doesn't
810076b9443SCy Schubert		# exist, like AIX 4.2.  [Bug: 4359]
811076b9443SCy Schubert		AC_CHECK_LIB(pthread, __pthread_mutex_init,
812076b9443SCy Schubert		    tcl_ok=yes, tcl_ok=no)
813076b9443SCy Schubert	    fi
814076b9443SCy Schubert
815076b9443SCy Schubert	    if test "$tcl_ok" = "yes"; then
816076b9443SCy Schubert		# The space is needed
817076b9443SCy Schubert		THREADS_LIBS=" -lpthread"
818076b9443SCy Schubert	    else
819076b9443SCy Schubert		AC_CHECK_LIB(pthreads, pthread_mutex_init,
820076b9443SCy Schubert		    tcl_ok=yes, tcl_ok=no)
821076b9443SCy Schubert		if test "$tcl_ok" = "yes"; then
822076b9443SCy Schubert		    # The space is needed
823076b9443SCy Schubert		    THREADS_LIBS=" -lpthreads"
824076b9443SCy Schubert		else
825076b9443SCy Schubert		    AC_CHECK_LIB(c, pthread_mutex_init,
826076b9443SCy Schubert			tcl_ok=yes, tcl_ok=no)
827076b9443SCy Schubert		    if test "$tcl_ok" = "no"; then
828076b9443SCy Schubert			AC_CHECK_LIB(c_r, pthread_mutex_init,
829076b9443SCy Schubert			    tcl_ok=yes, tcl_ok=no)
830076b9443SCy Schubert			if test "$tcl_ok" = "yes"; then
831076b9443SCy Schubert			    # The space is needed
832076b9443SCy Schubert			    THREADS_LIBS=" -pthread"
833076b9443SCy Schubert			else
834076b9443SCy Schubert			    TCL_THREADS=0
835076b9443SCy Schubert			    AC_MSG_WARN([Do not know how to find pthread lib on your system - thread support disabled])
836076b9443SCy Schubert			fi
837076b9443SCy Schubert		    fi
838076b9443SCy Schubert		fi
839076b9443SCy Schubert	    fi
840076b9443SCy Schubert	fi
841076b9443SCy Schubert    else
842076b9443SCy Schubert	TCL_THREADS=0
843076b9443SCy Schubert    fi
844076b9443SCy Schubert    # Do checking message here to not mess up interleaved configure output
845076b9443SCy Schubert    AC_MSG_CHECKING([for building with threads])
846076b9443SCy Schubert    if test "${TCL_THREADS}" = 1; then
847076b9443SCy Schubert	AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
848076b9443SCy Schubert	AC_MSG_RESULT([yes (default)])
849076b9443SCy Schubert    else
850076b9443SCy Schubert	AC_MSG_RESULT([no])
851076b9443SCy Schubert    fi
852076b9443SCy Schubert    # TCL_THREADS sanity checking.  See if our request for building with
853076b9443SCy Schubert    # threads is the same as the way Tcl was built.  If not, warn the user.
854076b9443SCy Schubert    case ${TCL_DEFS} in
855076b9443SCy Schubert	*THREADS=1*)
856076b9443SCy Schubert	    if test "${TCL_THREADS}" = "0"; then
857076b9443SCy Schubert		AC_MSG_WARN([
858076b9443SCy Schubert    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
859076b9443SCy Schubert    that IS thread-enabled.  It is recommended to use --enable-threads.])
860076b9443SCy Schubert	    fi
861076b9443SCy Schubert	    ;;
862076b9443SCy Schubert    esac
863076b9443SCy Schubert    AC_SUBST(TCL_THREADS)
864076b9443SCy Schubert])
865076b9443SCy Schubert
866076b9443SCy Schubert#------------------------------------------------------------------------
867076b9443SCy Schubert# TEA_ENABLE_SYMBOLS --
868076b9443SCy Schubert#
869076b9443SCy Schubert#	Specify if debugging symbols should be used.
870076b9443SCy Schubert#	Memory (TCL_MEM_DEBUG) debugging can also be enabled.
871076b9443SCy Schubert#
872076b9443SCy Schubert# Arguments:
873076b9443SCy Schubert#	none
874076b9443SCy Schubert#
875076b9443SCy Schubert#	TEA varies from core Tcl in that C|LDFLAGS_DEFAULT receives
876076b9443SCy Schubert#	the value of C|LDFLAGS_OPTIMIZE|DEBUG already substituted.
877076b9443SCy Schubert#	Requires the following vars to be set in the Makefile:
878076b9443SCy Schubert#		CFLAGS_DEFAULT
879076b9443SCy Schubert#		LDFLAGS_DEFAULT
880076b9443SCy Schubert#
881076b9443SCy Schubert# Results:
882076b9443SCy Schubert#
883076b9443SCy Schubert#	Adds the following arguments to configure:
884076b9443SCy Schubert#		--enable-symbols
885076b9443SCy Schubert#
886076b9443SCy Schubert#	Defines the following vars:
887076b9443SCy Schubert#		CFLAGS_DEFAULT	Sets to $(CFLAGS_DEBUG) if true
888076b9443SCy Schubert#				Sets to "$(CFLAGS_OPTIMIZE) -DNDEBUG" if false
889076b9443SCy Schubert#		LDFLAGS_DEFAULT	Sets to $(LDFLAGS_DEBUG) if true
890076b9443SCy Schubert#				Sets to $(LDFLAGS_OPTIMIZE) if false
891076b9443SCy Schubert#------------------------------------------------------------------------
892076b9443SCy Schubert
893076b9443SCy SchubertAC_DEFUN([TEA_ENABLE_SYMBOLS], [
894076b9443SCy Schubert    dnl TEA specific: Make sure we are initialized
895076b9443SCy Schubert    AC_REQUIRE([TEA_CONFIG_CFLAGS])
896076b9443SCy Schubert    AC_MSG_CHECKING([for build with symbols])
897076b9443SCy Schubert    AC_ARG_ENABLE(symbols,
898*00787218SCy Schubert	AS_HELP_STRING([--enable-symbols],
899076b9443SCy Schubert	    [build with debugging symbols (default: off)]),
900076b9443SCy Schubert	[tcl_ok=$enableval], [tcl_ok=no])
901076b9443SCy Schubert    if test "$tcl_ok" = "no"; then
902076b9443SCy Schubert	CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE} -DNDEBUG"
903076b9443SCy Schubert	LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
904076b9443SCy Schubert	AC_MSG_RESULT([no])
905*00787218SCy Schubert	AC_DEFINE(TCL_CFG_OPTIMIZED, 1, [Is this an optimized build?])
906076b9443SCy Schubert    else
907076b9443SCy Schubert	CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
908076b9443SCy Schubert	LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
909076b9443SCy Schubert	if test "$tcl_ok" = "yes"; then
910076b9443SCy Schubert	    AC_MSG_RESULT([yes (standard debugging)])
911076b9443SCy Schubert	fi
912076b9443SCy Schubert    fi
913076b9443SCy Schubert    AC_SUBST(CFLAGS_DEFAULT)
914076b9443SCy Schubert    AC_SUBST(LDFLAGS_DEFAULT)
915076b9443SCy Schubert
916076b9443SCy Schubert    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
917076b9443SCy Schubert	AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?])
918076b9443SCy Schubert    fi
919076b9443SCy Schubert
920076b9443SCy Schubert    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
921076b9443SCy Schubert	if test "$tcl_ok" = "all"; then
922076b9443SCy Schubert	    AC_MSG_RESULT([enabled symbols mem debugging])
923076b9443SCy Schubert	else
924076b9443SCy Schubert	    AC_MSG_RESULT([enabled $tcl_ok debugging])
925076b9443SCy Schubert	fi
926076b9443SCy Schubert    fi
927076b9443SCy Schubert])
928076b9443SCy Schubert
929076b9443SCy Schubert#------------------------------------------------------------------------
930076b9443SCy Schubert# TEA_ENABLE_LANGINFO --
931076b9443SCy Schubert#
932076b9443SCy Schubert#	Allows use of modern nl_langinfo check for better l10n.
933076b9443SCy Schubert#	This is only relevant for Unix.
934076b9443SCy Schubert#
935076b9443SCy Schubert# Arguments:
936076b9443SCy Schubert#	none
937076b9443SCy Schubert#
938076b9443SCy Schubert# Results:
939076b9443SCy Schubert#
940076b9443SCy Schubert#	Adds the following arguments to configure:
941076b9443SCy Schubert#		--enable-langinfo=yes|no (default is yes)
942076b9443SCy Schubert#
943076b9443SCy Schubert#	Defines the following vars:
944076b9443SCy Schubert#		HAVE_LANGINFO	Triggers use of nl_langinfo if defined.
945076b9443SCy Schubert#------------------------------------------------------------------------
946076b9443SCy Schubert
947076b9443SCy SchubertAC_DEFUN([TEA_ENABLE_LANGINFO], [
948076b9443SCy Schubert    AC_ARG_ENABLE(langinfo,
949*00787218SCy Schubert	AS_HELP_STRING([--enable-langinfo],
950076b9443SCy Schubert	    [use nl_langinfo if possible to determine encoding at startup, otherwise use old heuristic (default: on)]),
951076b9443SCy Schubert	[langinfo_ok=$enableval], [langinfo_ok=yes])
952076b9443SCy Schubert
953076b9443SCy Schubert    HAVE_LANGINFO=0
954076b9443SCy Schubert    if test "$langinfo_ok" = "yes"; then
955076b9443SCy Schubert	AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
956076b9443SCy Schubert    fi
957076b9443SCy Schubert    AC_MSG_CHECKING([whether to use nl_langinfo])
958076b9443SCy Schubert    if test "$langinfo_ok" = "yes"; then
959076b9443SCy Schubert	AC_CACHE_VAL(tcl_cv_langinfo_h, [
960*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]], [[nl_langinfo(CODESET);]])],
961076b9443SCy Schubert		    [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no])])
962076b9443SCy Schubert	AC_MSG_RESULT([$tcl_cv_langinfo_h])
963076b9443SCy Schubert	if test $tcl_cv_langinfo_h = yes; then
964076b9443SCy Schubert	    AC_DEFINE(HAVE_LANGINFO, 1, [Do we have nl_langinfo()?])
965076b9443SCy Schubert	fi
966076b9443SCy Schubert    else
967076b9443SCy Schubert	AC_MSG_RESULT([$langinfo_ok])
968076b9443SCy Schubert    fi
969076b9443SCy Schubert])
970076b9443SCy Schubert
971076b9443SCy Schubert#--------------------------------------------------------------------
972076b9443SCy Schubert# TEA_CONFIG_SYSTEM
973076b9443SCy Schubert#
974076b9443SCy Schubert#	Determine what the system is (some things cannot be easily checked
975076b9443SCy Schubert#	on a feature-driven basis, alas). This can usually be done via the
976076b9443SCy Schubert#	"uname" command.
977076b9443SCy Schubert#
978076b9443SCy Schubert# Arguments:
979076b9443SCy Schubert#	none
980076b9443SCy Schubert#
981076b9443SCy Schubert# Results:
982076b9443SCy Schubert#	Defines the following var:
983076b9443SCy Schubert#
984076b9443SCy Schubert#	system -	System/platform/version identification code.
985*00787218SCy Schubert#
986076b9443SCy Schubert#--------------------------------------------------------------------
987076b9443SCy Schubert
988076b9443SCy SchubertAC_DEFUN([TEA_CONFIG_SYSTEM], [
989076b9443SCy Schubert    AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
990076b9443SCy Schubert	# TEA specific:
991076b9443SCy Schubert	if test "${TEA_PLATFORM}" = "windows" ; then
992076b9443SCy Schubert	    tcl_cv_sys_version=windows
993076b9443SCy Schubert	else
994076b9443SCy Schubert	    tcl_cv_sys_version=`uname -s`-`uname -r`
995076b9443SCy Schubert	    if test "$?" -ne 0 ; then
996076b9443SCy Schubert		AC_MSG_WARN([can't find uname command])
997076b9443SCy Schubert		tcl_cv_sys_version=unknown
998076b9443SCy Schubert	    else
999076b9443SCy Schubert		if test "`uname -s`" = "AIX" ; then
1000076b9443SCy Schubert		    tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
1001076b9443SCy Schubert		fi
1002*00787218SCy Schubert		if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then
1003*00787218SCy Schubert		    tcl_cv_sys_version=NetBSD-Debian
1004*00787218SCy Schubert		fi
1005076b9443SCy Schubert	    fi
1006076b9443SCy Schubert	fi
1007076b9443SCy Schubert    ])
1008076b9443SCy Schubert    system=$tcl_cv_sys_version
1009076b9443SCy Schubert])
1010076b9443SCy Schubert
1011076b9443SCy Schubert#--------------------------------------------------------------------
1012076b9443SCy Schubert# TEA_CONFIG_CFLAGS
1013076b9443SCy Schubert#
1014076b9443SCy Schubert#	Try to determine the proper flags to pass to the compiler
1015076b9443SCy Schubert#	for building shared libraries and other such nonsense.
1016076b9443SCy Schubert#
1017076b9443SCy Schubert# Arguments:
1018076b9443SCy Schubert#	none
1019076b9443SCy Schubert#
1020076b9443SCy Schubert# Results:
1021076b9443SCy Schubert#
1022076b9443SCy Schubert#	Defines and substitutes the following vars:
1023076b9443SCy Schubert#
1024076b9443SCy Schubert#	DL_OBJS, DL_LIBS - removed for TEA, only needed by core.
1025076b9443SCy Schubert#       LDFLAGS -      Flags to pass to the compiler when linking object
1026076b9443SCy Schubert#                       files into an executable application binary such
1027076b9443SCy Schubert#                       as tclsh.
1028076b9443SCy Schubert#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
1029076b9443SCy Schubert#                       that tell the run-time dynamic linker where to look
1030076b9443SCy Schubert#                       for shared libraries such as libtcl.so.  Depends on
1031076b9443SCy Schubert#                       the variable LIB_RUNTIME_DIR in the Makefile. Could
1032076b9443SCy Schubert#                       be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
1033076b9443SCy Schubert#       CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
1034076b9443SCy Schubert#                       that tell the run-time dynamic linker where to look
1035076b9443SCy Schubert#                       for shared libraries such as libtcl.so.  Depends on
1036076b9443SCy Schubert#                       the variable LIB_RUNTIME_DIR in the Makefile.
1037076b9443SCy Schubert#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
1038076b9443SCy Schubert#                       of a shared library (may request position-independent
1039076b9443SCy Schubert#                       code, among other things).
1040076b9443SCy Schubert#       SHLIB_LD -      Base command to use for combining object files
1041076b9443SCy Schubert#                       into a shared library.
1042076b9443SCy Schubert#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
1043076b9443SCy Schubert#                       creating shared libraries.  This symbol typically
1044076b9443SCy Schubert#                       goes at the end of the "ld" commands that build
1045076b9443SCy Schubert#                       shared libraries. The value of the symbol defaults to
1046076b9443SCy Schubert#                       "${LIBS}" if all of the dependent libraries should
1047076b9443SCy Schubert#                       be specified when creating a shared library.  If
1048076b9443SCy Schubert#                       dependent libraries should not be specified (as on
1049076b9443SCy Schubert#                       SunOS 4.x, where they cause the link to fail, or in
1050076b9443SCy Schubert#                       general if Tcl and Tk aren't themselves shared
1051076b9443SCy Schubert#                       libraries), then this symbol has an empty string
1052076b9443SCy Schubert#                       as its value.
1053076b9443SCy Schubert#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
1054076b9443SCy Schubert#                       extensions.  An empty string means we don't know how
1055076b9443SCy Schubert#                       to use shared libraries on this platform.
1056076b9443SCy Schubert#       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
1057076b9443SCy Schubert#                       in a static or shared library name, using the $PACKAGE_VERSION variable
1058076b9443SCy Schubert#                       to put the version in the right place.  This is used
1059076b9443SCy Schubert#                       by platforms that need non-standard library names.
1060076b9443SCy Schubert#                       Examples:  ${PACKAGE_VERSION}.so.1.1 on NetBSD, since it needs
1061076b9443SCy Schubert#                       to have a version after the .so, and ${PACKAGE_VERSION}.a
1062076b9443SCy Schubert#                       on AIX, since a shared library needs to have
1063076b9443SCy Schubert#                       a .a extension whereas shared objects for loadable
1064076b9443SCy Schubert#                       extensions have a .so extension.  Defaults to
1065076b9443SCy Schubert#                       ${PACKAGE_VERSION}${SHLIB_SUFFIX}.
1066076b9443SCy Schubert#	CFLAGS_DEBUG -
1067076b9443SCy Schubert#			Flags used when running the compiler in debug mode
1068076b9443SCy Schubert#	CFLAGS_OPTIMIZE -
1069076b9443SCy Schubert#			Flags used when running the compiler in optimize mode
1070076b9443SCy Schubert#	CFLAGS -	Additional CFLAGS added as necessary (usually 64-bit)
1071076b9443SCy Schubert#--------------------------------------------------------------------
1072076b9443SCy Schubert
1073076b9443SCy SchubertAC_DEFUN([TEA_CONFIG_CFLAGS], [
1074076b9443SCy Schubert    dnl TEA specific: Make sure we are initialized
1075076b9443SCy Schubert    AC_REQUIRE([TEA_INIT])
1076076b9443SCy Schubert
1077076b9443SCy Schubert    # Step 0.a: Enable 64 bit support?
1078076b9443SCy Schubert
1079076b9443SCy Schubert    AC_MSG_CHECKING([if 64bit support is requested])
1080076b9443SCy Schubert    AC_ARG_ENABLE(64bit,
1081*00787218SCy Schubert	AS_HELP_STRING([--enable-64bit],
1082076b9443SCy Schubert	    [enable 64bit support (default: off)]),
1083076b9443SCy Schubert	[do64bit=$enableval], [do64bit=no])
1084076b9443SCy Schubert    AC_MSG_RESULT([$do64bit])
1085076b9443SCy Schubert
1086076b9443SCy Schubert    # Step 0.b: Enable Solaris 64 bit VIS support?
1087076b9443SCy Schubert
1088076b9443SCy Schubert    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
1089076b9443SCy Schubert    AC_ARG_ENABLE(64bit-vis,
1090*00787218SCy Schubert	AS_HELP_STRING([--enable-64bit-vis],
1091076b9443SCy Schubert	    [enable 64bit Sparc VIS support (default: off)]),
1092076b9443SCy Schubert	[do64bitVIS=$enableval], [do64bitVIS=no])
1093076b9443SCy Schubert    AC_MSG_RESULT([$do64bitVIS])
1094076b9443SCy Schubert    # Force 64bit on with VIS
1095076b9443SCy Schubert    AS_IF([test "$do64bitVIS" = "yes"], [do64bit=yes])
1096076b9443SCy Schubert
1097076b9443SCy Schubert    # Step 0.c: Check if visibility support is available. Do this here so
1098076b9443SCy Schubert    # that platform specific alternatives can be used below if this fails.
1099076b9443SCy Schubert
1100076b9443SCy Schubert    AC_CACHE_CHECK([if compiler supports visibility "hidden"],
1101076b9443SCy Schubert	tcl_cv_cc_visibility_hidden, [
1102076b9443SCy Schubert	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
1103*00787218SCy Schubert	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1104076b9443SCy Schubert	    extern __attribute__((__visibility__("hidden"))) void f(void);
1105*00787218SCy Schubert	    void f(void) {}]], [[f();]])],[tcl_cv_cc_visibility_hidden=yes],
1106*00787218SCy Schubert	    [tcl_cv_cc_visibility_hidden=no])
1107076b9443SCy Schubert	CFLAGS=$hold_cflags])
1108076b9443SCy Schubert    AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [
1109076b9443SCy Schubert	AC_DEFINE(MODULE_SCOPE,
1110076b9443SCy Schubert	    [extern __attribute__((__visibility__("hidden")))],
1111076b9443SCy Schubert	    [Compiler support for module scope symbols])
1112076b9443SCy Schubert	AC_DEFINE(HAVE_HIDDEN, [1], [Compiler support for module scope symbols])
1113076b9443SCy Schubert    ])
1114076b9443SCy Schubert
1115076b9443SCy Schubert    # Step 0.d: Disable -rpath support?
1116076b9443SCy Schubert
1117076b9443SCy Schubert    AC_MSG_CHECKING([if rpath support is requested])
1118076b9443SCy Schubert    AC_ARG_ENABLE(rpath,
1119*00787218SCy Schubert	AS_HELP_STRING([--disable-rpath],
1120076b9443SCy Schubert	    [disable rpath support (default: on)]),
1121076b9443SCy Schubert	[doRpath=$enableval], [doRpath=yes])
1122076b9443SCy Schubert    AC_MSG_RESULT([$doRpath])
1123076b9443SCy Schubert
1124076b9443SCy Schubert    # Set the variable "system" to hold the name and version number
1125076b9443SCy Schubert    # for the system.
1126076b9443SCy Schubert
1127076b9443SCy Schubert    TEA_CONFIG_SYSTEM
1128076b9443SCy Schubert
1129076b9443SCy Schubert    # Require ranlib early so we can override it in special cases below.
1130076b9443SCy Schubert
1131076b9443SCy Schubert    AC_REQUIRE([AC_PROG_RANLIB])
1132076b9443SCy Schubert
1133076b9443SCy Schubert    # Set configuration options based on system name and version.
1134076b9443SCy Schubert    # This is similar to Tcl's unix/tcl.m4 except that we've added a
1135076b9443SCy Schubert    # "windows" case and removed some core-only vars.
1136076b9443SCy Schubert
1137076b9443SCy Schubert    do64bit_ok=no
1138076b9443SCy Schubert    # default to '{$LIBS}' and set to "" on per-platform necessary basis
1139076b9443SCy Schubert    SHLIB_LD_LIBS='${LIBS}'
1140076b9443SCy Schubert    # When ld needs options to work in 64-bit mode, put them in
1141076b9443SCy Schubert    # LDFLAGS_ARCH so they eventually end up in LDFLAGS even if [load]
1142076b9443SCy Schubert    # is disabled by the user. [Bug 1016796]
1143076b9443SCy Schubert    LDFLAGS_ARCH=""
1144076b9443SCy Schubert    UNSHARED_LIB_SUFFIX=""
1145076b9443SCy Schubert    # TEA specific: use PACKAGE_VERSION instead of VERSION
1146076b9443SCy Schubert    TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`'
1147076b9443SCy Schubert    ECHO_VERSION='`echo ${PACKAGE_VERSION}`'
1148076b9443SCy Schubert    TCL_LIB_VERSIONS_OK=ok
1149076b9443SCy Schubert    CFLAGS_DEBUG=-g
1150076b9443SCy Schubert    AS_IF([test "$GCC" = yes], [
1151076b9443SCy Schubert	CFLAGS_OPTIMIZE=-O2
1152076b9443SCy Schubert	CFLAGS_WARNING="-Wall"
1153076b9443SCy Schubert    ], [
1154076b9443SCy Schubert	CFLAGS_OPTIMIZE=-O
1155076b9443SCy Schubert	CFLAGS_WARNING=""
1156076b9443SCy Schubert    ])
1157076b9443SCy Schubert    AC_CHECK_TOOL(AR, ar)
1158076b9443SCy Schubert    STLIB_LD='${AR} cr'
1159076b9443SCy Schubert    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
1160*00787218SCy Schubert    AS_IF([test "x$SHLIB_VERSION" = x],[SHLIB_VERSION=""],[SHLIB_VERSION=".$SHLIB_VERSION"])
1161076b9443SCy Schubert    case $system in
1162076b9443SCy Schubert	# TEA specific:
1163076b9443SCy Schubert	windows)
1164076b9443SCy Schubert	    MACHINE="X86"
1165076b9443SCy Schubert	    if test "$do64bit" != "no" ; then
1166076b9443SCy Schubert		case "$do64bit" in
1167076b9443SCy Schubert		    amd64|x64|yes)
1168076b9443SCy Schubert			MACHINE="AMD64" ; # default to AMD64 64-bit build
1169*00787218SCy Schubert			;;
1170*00787218SCy Schubert		    arm64|aarch64)
1171*00787218SCy Schubert			MACHINE="ARM64"
1172076b9443SCy Schubert			;;
1173076b9443SCy Schubert		    ia64)
1174076b9443SCy Schubert			MACHINE="IA64"
1175076b9443SCy Schubert			;;
1176076b9443SCy Schubert		esac
1177076b9443SCy Schubert	    fi
1178076b9443SCy Schubert
1179076b9443SCy Schubert	    if test "$GCC" != "yes" ; then
1180076b9443SCy Schubert	        if test "${SHARED_BUILD}" = "0" ; then
1181076b9443SCy Schubert		    runtime=-MT
1182076b9443SCy Schubert	        else
1183076b9443SCy Schubert		    runtime=-MD
1184076b9443SCy Schubert	        fi
1185*00787218SCy Schubert	        case "x`echo \${VisualStudioVersion}`" in
1186*00787218SCy Schubert	            x1[[4-9]]*)
1187*00787218SCy Schubert		        lflags="${lflags} -nodefaultlib:libucrt.lib"
1188*00787218SCy Schubert		        TEA_ADD_LIBS([ucrt.lib])
1189*00787218SCy Schubert	            ;;
1190*00787218SCy Schubert	            *)
1191*00787218SCy Schubert	            ;;
1192*00787218SCy Schubert	        esac
1193076b9443SCy Schubert
1194076b9443SCy Schubert                if test "$do64bit" != "no" ; then
1195*00787218SCy Schubert		    CC="cl.exe"
1196*00787218SCy Schubert		    RC="rc.exe"
1197*00787218SCy Schubert		    lflags="${lflags} -nologo -MACHINE:${MACHINE} "
1198*00787218SCy Schubert		    LINKBIN="link.exe"
1199076b9443SCy Schubert		    CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d"
1200076b9443SCy Schubert		    CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}"
1201076b9443SCy Schubert		    # Avoid 'unresolved external symbol __security_cookie'
1202076b9443SCy Schubert		    # errors, c.f. http://support.microsoft.com/?id=894573
1203076b9443SCy Schubert		    TEA_ADD_LIBS([bufferoverflowU.lib])
1204076b9443SCy Schubert		else
1205076b9443SCy Schubert		    RC="rc"
1206*00787218SCy Schubert		    lflags="${lflags} -nologo"
1207076b9443SCy Schubert		    LINKBIN="link"
1208076b9443SCy Schubert		    CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d"
1209076b9443SCy Schubert		    CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}"
1210076b9443SCy Schubert		fi
1211076b9443SCy Schubert	    fi
1212076b9443SCy Schubert
1213076b9443SCy Schubert	    if test "$GCC" = "yes"; then
1214076b9443SCy Schubert		# mingw gcc mode
1215076b9443SCy Schubert		AC_CHECK_TOOL(RC, windres)
1216076b9443SCy Schubert		CFLAGS_DEBUG="-g"
1217076b9443SCy Schubert		CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
1218076b9443SCy Schubert		SHLIB_LD='${CC} -shared'
1219076b9443SCy Schubert		UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1220076b9443SCy Schubert		LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}"
1221076b9443SCy Schubert		LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}"
1222076b9443SCy Schubert
1223076b9443SCy Schubert		AC_CACHE_CHECK(for cross-compile version of gcc,
1224076b9443SCy Schubert			ac_cv_cross,
1225*00787218SCy Schubert			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1226076b9443SCy Schubert			    #ifdef _WIN32
1227076b9443SCy Schubert				#error cross-compiler
1228076b9443SCy Schubert			    #endif
1229*00787218SCy Schubert			]], [[]])],
1230*00787218SCy Schubert			[ac_cv_cross=yes],
1231*00787218SCy Schubert			[ac_cv_cross=no])
1232076b9443SCy Schubert		      )
1233076b9443SCy Schubert		      if test "$ac_cv_cross" = "yes"; then
1234076b9443SCy Schubert			case "$do64bit" in
1235076b9443SCy Schubert			    amd64|x64|yes)
1236*00787218SCy Schubert				CC="x86_64-w64-mingw32-${CC}"
1237076b9443SCy Schubert				LD="x86_64-w64-mingw32-ld"
1238076b9443SCy Schubert				AR="x86_64-w64-mingw32-ar"
1239076b9443SCy Schubert				RANLIB="x86_64-w64-mingw32-ranlib"
1240076b9443SCy Schubert				RC="x86_64-w64-mingw32-windres"
1241076b9443SCy Schubert			    ;;
1242*00787218SCy Schubert			    arm64|aarch64)
1243*00787218SCy Schubert				CC="aarch64-w64-mingw32-clang"
1244*00787218SCy Schubert				LD="aarch64-w64-mingw32-ld"
1245*00787218SCy Schubert				AR="aarch64-w64-mingw32-ar"
1246*00787218SCy Schubert				RANLIB="aarch64-w64-mingw32-ranlib"
1247*00787218SCy Schubert				RC="aarch64-w64-mingw32-windres"
1248*00787218SCy Schubert			    ;;
1249076b9443SCy Schubert			    *)
1250*00787218SCy Schubert				CC="i686-w64-mingw32-${CC}"
1251076b9443SCy Schubert				LD="i686-w64-mingw32-ld"
1252076b9443SCy Schubert				AR="i686-w64-mingw32-ar"
1253076b9443SCy Schubert				RANLIB="i686-w64-mingw32-ranlib"
1254076b9443SCy Schubert				RC="i686-w64-mingw32-windres"
1255076b9443SCy Schubert			    ;;
1256076b9443SCy Schubert			esac
1257076b9443SCy Schubert		fi
1258076b9443SCy Schubert
1259076b9443SCy Schubert	    else
1260076b9443SCy Schubert		SHLIB_LD="${LINKBIN} -dll ${lflags}"
1261076b9443SCy Schubert		# link -lib only works when -lib is the first arg
1262076b9443SCy Schubert		STLIB_LD="${LINKBIN} -lib ${lflags}"
1263076b9443SCy Schubert		UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.lib'
1264076b9443SCy Schubert		PATHTYPE=-w
1265076b9443SCy Schubert		# For information on what debugtype is most useful, see:
1266076b9443SCy Schubert		# http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp
1267076b9443SCy Schubert		# and also
1268076b9443SCy Schubert		# http://msdn2.microsoft.com/en-us/library/y0zzbyt4%28VS.80%29.aspx
1269076b9443SCy Schubert		# This essentially turns it all on.
1270076b9443SCy Schubert		LDFLAGS_DEBUG="-debug -debugtype:cv"
1271076b9443SCy Schubert		LDFLAGS_OPTIMIZE="-release"
1272076b9443SCy Schubert		LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
1273076b9443SCy Schubert		LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
1274076b9443SCy Schubert	    fi
1275076b9443SCy Schubert
1276076b9443SCy Schubert	    SHLIB_SUFFIX=".dll"
1277076b9443SCy Schubert	    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll'
1278076b9443SCy Schubert
1279076b9443SCy Schubert	    TCL_LIB_VERSIONS_OK=nodots
1280076b9443SCy Schubert    	    ;;
1281076b9443SCy Schubert	AIX-*)
1282*00787218SCy Schubert	    AS_IF([test "$GCC" != "yes"], [
1283076b9443SCy Schubert		# AIX requires the _r compiler when gcc isn't being used
1284076b9443SCy Schubert		case "${CC}" in
1285076b9443SCy Schubert		    *_r|*_r\ *)
1286076b9443SCy Schubert			# ok ...
1287076b9443SCy Schubert			;;
1288076b9443SCy Schubert		    *)
1289076b9443SCy Schubert			# Make sure only first arg gets _r
1290076b9443SCy Schubert		    	CC=`echo "$CC" | sed -e 's/^\([[^ ]]*\)/\1_r/'`
1291076b9443SCy Schubert			;;
1292076b9443SCy Schubert		esac
1293076b9443SCy Schubert		AC_MSG_RESULT([Using $CC for compiling with threads])
1294076b9443SCy Schubert	    ])
1295076b9443SCy Schubert	    LIBS="$LIBS -lc"
1296076b9443SCy Schubert	    SHLIB_CFLAGS=""
1297076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1298076b9443SCy Schubert
1299076b9443SCy Schubert	    LD_LIBRARY_PATH_VAR="LIBPATH"
1300076b9443SCy Schubert
1301076b9443SCy Schubert	    # Check to enable 64-bit flags for compiler/linker
1302076b9443SCy Schubert	    AS_IF([test "$do64bit" = yes], [
1303076b9443SCy Schubert		AS_IF([test "$GCC" = yes], [
1304076b9443SCy Schubert		    AC_MSG_WARN([64bit mode not supported with GCC on $system])
1305076b9443SCy Schubert		], [
1306076b9443SCy Schubert		    do64bit_ok=yes
1307076b9443SCy Schubert		    CFLAGS="$CFLAGS -q64"
1308076b9443SCy Schubert		    LDFLAGS_ARCH="-q64"
1309076b9443SCy Schubert		    RANLIB="${RANLIB} -X64"
1310076b9443SCy Schubert		    AR="${AR} -X64"
1311076b9443SCy Schubert		    SHLIB_LD_FLAGS="-b64"
1312076b9443SCy Schubert		])
1313076b9443SCy Schubert	    ])
1314076b9443SCy Schubert
1315076b9443SCy Schubert	    AS_IF([test "`uname -m`" = ia64], [
1316076b9443SCy Schubert		# AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
1317076b9443SCy Schubert		SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1318076b9443SCy Schubert		AS_IF([test "$GCC" = yes], [
1319*00787218SCy Schubert		    CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"'
1320076b9443SCy Schubert		], [
1321*00787218SCy Schubert		    CC_SEARCH_FLAGS='"-R${LIB_RUNTIME_DIR}"'
1322076b9443SCy Schubert		])
1323*00787218SCy Schubert		LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"'
1324076b9443SCy Schubert	    ], [
1325076b9443SCy Schubert		AS_IF([test "$GCC" = yes], [
1326076b9443SCy Schubert		    SHLIB_LD='${CC} -shared -Wl,-bexpall'
1327076b9443SCy Schubert		], [
1328076b9443SCy Schubert		    SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry"
1329076b9443SCy Schubert		    LDFLAGS="$LDFLAGS -brtl"
1330076b9443SCy Schubert		])
1331076b9443SCy Schubert		SHLIB_LD="${SHLIB_LD} ${SHLIB_LD_FLAGS}"
1332*00787218SCy Schubert		CC_SEARCH_FLAGS='"-L${LIB_RUNTIME_DIR}"'
1333076b9443SCy Schubert		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1334076b9443SCy Schubert	    ])
1335076b9443SCy Schubert	    ;;
1336076b9443SCy Schubert	BeOS*)
1337076b9443SCy Schubert	    SHLIB_CFLAGS="-fPIC"
1338076b9443SCy Schubert	    SHLIB_LD='${CC} -nostart'
1339076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1340076b9443SCy Schubert
1341076b9443SCy Schubert	    #-----------------------------------------------------------
1342076b9443SCy Schubert	    # Check for inet_ntoa in -lbind, for BeOS (which also needs
1343076b9443SCy Schubert	    # -lsocket, even if the network functions are in -lnet which
1344076b9443SCy Schubert	    # is always linked to, for compatibility.
1345076b9443SCy Schubert	    #-----------------------------------------------------------
1346076b9443SCy Schubert	    AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"])
1347076b9443SCy Schubert	    ;;
1348*00787218SCy Schubert	BSD/OS-2.1*|BSD/OS-3*)
1349*00787218SCy Schubert	    SHLIB_CFLAGS=""
1350*00787218SCy Schubert	    SHLIB_LD="shlicc -r"
1351*00787218SCy Schubert	    SHLIB_SUFFIX=".so"
1352*00787218SCy Schubert	    CC_SEARCH_FLAGS=""
1353*00787218SCy Schubert	    LD_SEARCH_FLAGS=""
1354*00787218SCy Schubert	    ;;
1355076b9443SCy Schubert	BSD/OS-4.*)
1356076b9443SCy Schubert	    SHLIB_CFLAGS="-export-dynamic -fPIC"
1357076b9443SCy Schubert	    SHLIB_LD='${CC} -shared'
1358076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1359076b9443SCy Schubert	    LDFLAGS="$LDFLAGS -export-dynamic"
1360076b9443SCy Schubert	    CC_SEARCH_FLAGS=""
1361076b9443SCy Schubert	    LD_SEARCH_FLAGS=""
1362076b9443SCy Schubert	    ;;
1363076b9443SCy Schubert	CYGWIN_*)
1364076b9443SCy Schubert	    SHLIB_CFLAGS=""
1365076b9443SCy Schubert	    SHLIB_LD='${CC} -shared'
1366076b9443SCy Schubert	    SHLIB_SUFFIX=".dll"
1367*00787218SCy Schubert	    SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$[@].a"
1368076b9443SCy Schubert	    EXEEXT=".exe"
1369076b9443SCy Schubert	    do64bit_ok=yes
1370076b9443SCy Schubert	    CC_SEARCH_FLAGS=""
1371076b9443SCy Schubert	    LD_SEARCH_FLAGS=""
1372076b9443SCy Schubert	    ;;
1373*00787218SCy Schubert	dgux*)
1374*00787218SCy Schubert	    SHLIB_CFLAGS="-K PIC"
1375*00787218SCy Schubert	    SHLIB_LD='${CC} -G'
1376*00787218SCy Schubert	    SHLIB_LD_LIBS=""
1377*00787218SCy Schubert	    SHLIB_SUFFIX=".so"
1378*00787218SCy Schubert	    CC_SEARCH_FLAGS=""
1379*00787218SCy Schubert	    LD_SEARCH_FLAGS=""
1380*00787218SCy Schubert	    ;;
1381076b9443SCy Schubert	Haiku*)
1382076b9443SCy Schubert	    LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1383076b9443SCy Schubert	    SHLIB_CFLAGS="-fPIC"
1384076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1385*00787218SCy Schubert	    SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
1386076b9443SCy Schubert	    AC_CHECK_LIB(network, inet_ntoa, [LIBS="$LIBS -lnetwork"])
1387076b9443SCy Schubert	    ;;
1388076b9443SCy Schubert	HP-UX-*.11.*)
1389076b9443SCy Schubert	    # Use updated header definitions where possible
1390076b9443SCy Schubert	    AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Do we want to use the XOPEN network library?])
1391076b9443SCy Schubert	    # TEA specific: Needed by Tcl, but not most extensions
1392076b9443SCy Schubert	    #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?])
1393076b9443SCy Schubert	    #LIBS="$LIBS -lxnet"               # Use the XOPEN network library
1394076b9443SCy Schubert
1395076b9443SCy Schubert	    AS_IF([test "`uname -m`" = ia64], [
1396076b9443SCy Schubert		SHLIB_SUFFIX=".so"
1397076b9443SCy Schubert	    ], [
1398076b9443SCy Schubert		SHLIB_SUFFIX=".sl"
1399076b9443SCy Schubert	    ])
1400076b9443SCy Schubert	    AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1401076b9443SCy Schubert	    AS_IF([test "$tcl_ok" = yes], [
1402*00787218SCy Schubert		SHLIB_CFLAGS="+z"
1403*00787218SCy Schubert		SHLIB_LD="ld -b"
1404076b9443SCy Schubert		LDFLAGS="$LDFLAGS -Wl,-E"
1405*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,+s,+b,${LIB_RUNTIME_DIR}:."'
1406*00787218SCy Schubert		LD_SEARCH_FLAGS='+s +b "${LIB_RUNTIME_DIR}:."'
1407076b9443SCy Schubert		LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1408076b9443SCy Schubert	    ])
1409076b9443SCy Schubert	    AS_IF([test "$GCC" = yes], [
1410076b9443SCy Schubert		SHLIB_LD='${CC} -shared'
1411076b9443SCy Schubert		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1412076b9443SCy Schubert	    ], [
1413076b9443SCy Schubert		CFLAGS="$CFLAGS -z"
1414076b9443SCy Schubert	    ])
1415076b9443SCy Schubert
1416076b9443SCy Schubert	    # Check to enable 64-bit flags for compiler/linker
1417076b9443SCy Schubert	    AS_IF([test "$do64bit" = "yes"], [
1418076b9443SCy Schubert		AS_IF([test "$GCC" = yes], [
1419076b9443SCy Schubert		    case `${CC} -dumpmachine` in
1420076b9443SCy Schubert			hppa64*)
1421076b9443SCy Schubert			    # 64-bit gcc in use.  Fix flags for GNU ld.
1422076b9443SCy Schubert			    do64bit_ok=yes
1423076b9443SCy Schubert			    SHLIB_LD='${CC} -shared'
1424076b9443SCy Schubert			    AS_IF([test $doRpath = yes], [
1425*00787218SCy Schubert				CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
1426076b9443SCy Schubert			    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1427076b9443SCy Schubert			    ;;
1428076b9443SCy Schubert			*)
1429076b9443SCy Schubert			    AC_MSG_WARN([64bit mode not supported with GCC on $system])
1430076b9443SCy Schubert			    ;;
1431076b9443SCy Schubert		    esac
1432076b9443SCy Schubert		], [
1433076b9443SCy Schubert		    do64bit_ok=yes
1434076b9443SCy Schubert		    CFLAGS="$CFLAGS +DD64"
1435076b9443SCy Schubert		    LDFLAGS_ARCH="+DD64"
1436076b9443SCy Schubert		])
1437076b9443SCy Schubert	    ]) ;;
1438*00787218SCy Schubert	HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
1439*00787218SCy Schubert	    SHLIB_SUFFIX=".sl"
1440*00787218SCy Schubert	    AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1441*00787218SCy Schubert	    AS_IF([test "$tcl_ok" = yes], [
1442*00787218SCy Schubert		SHLIB_CFLAGS="+z"
1443*00787218SCy Schubert		SHLIB_LD="ld -b"
1444*00787218SCy Schubert		SHLIB_LD_LIBS=""
1445*00787218SCy Schubert		LDFLAGS="$LDFLAGS -Wl,-E"
1446*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,+s,+b,${LIB_RUNTIME_DIR}:."'
1447*00787218SCy Schubert		LD_SEARCH_FLAGS='+s +b "${LIB_RUNTIME_DIR}:."'
1448*00787218SCy Schubert		LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1449*00787218SCy Schubert	    ]) ;;
1450*00787218SCy Schubert	IRIX-5.*)
1451*00787218SCy Schubert	    SHLIB_CFLAGS=""
1452*00787218SCy Schubert	    SHLIB_LD="ld -shared -rdata_shared"
1453*00787218SCy Schubert	    SHLIB_SUFFIX=".so"
1454*00787218SCy Schubert	    AC_LIBOBJ(mkstemp)
1455*00787218SCy Schubert	    AS_IF([test $doRpath = yes], [
1456*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
1457*00787218SCy Schubert		LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"'])
1458*00787218SCy Schubert	    ;;
1459076b9443SCy Schubert	IRIX-6.*)
1460076b9443SCy Schubert	    SHLIB_CFLAGS=""
1461076b9443SCy Schubert	    SHLIB_LD="ld -n32 -shared -rdata_shared"
1462076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1463076b9443SCy Schubert	    AS_IF([test $doRpath = yes], [
1464*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
1465*00787218SCy Schubert		LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"'])
1466076b9443SCy Schubert	    AS_IF([test "$GCC" = yes], [
1467076b9443SCy Schubert		CFLAGS="$CFLAGS -mabi=n32"
1468076b9443SCy Schubert		LDFLAGS="$LDFLAGS -mabi=n32"
1469076b9443SCy Schubert	    ], [
1470076b9443SCy Schubert		case $system in
1471076b9443SCy Schubert		    IRIX-6.3)
1472076b9443SCy Schubert			# Use to build 6.2 compatible binaries on 6.3.
1473076b9443SCy Schubert			CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS"
1474076b9443SCy Schubert			;;
1475076b9443SCy Schubert		    *)
1476076b9443SCy Schubert			CFLAGS="$CFLAGS -n32"
1477076b9443SCy Schubert			;;
1478076b9443SCy Schubert		esac
1479076b9443SCy Schubert		LDFLAGS="$LDFLAGS -n32"
1480076b9443SCy Schubert	    ])
1481076b9443SCy Schubert	    ;;
1482076b9443SCy Schubert	IRIX64-6.*)
1483076b9443SCy Schubert	    SHLIB_CFLAGS=""
1484076b9443SCy Schubert	    SHLIB_LD="ld -n32 -shared -rdata_shared"
1485076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1486076b9443SCy Schubert	    AS_IF([test $doRpath = yes], [
1487*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
1488*00787218SCy Schubert		LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"'])
1489076b9443SCy Schubert
1490076b9443SCy Schubert	    # Check to enable 64-bit flags for compiler/linker
1491076b9443SCy Schubert
1492076b9443SCy Schubert	    AS_IF([test "$do64bit" = yes], [
1493076b9443SCy Schubert	        AS_IF([test "$GCC" = yes], [
1494076b9443SCy Schubert	            AC_MSG_WARN([64bit mode not supported by gcc])
1495076b9443SCy Schubert	        ], [
1496076b9443SCy Schubert	            do64bit_ok=yes
1497076b9443SCy Schubert	            SHLIB_LD="ld -64 -shared -rdata_shared"
1498076b9443SCy Schubert	            CFLAGS="$CFLAGS -64"
1499076b9443SCy Schubert	            LDFLAGS_ARCH="-64"
1500076b9443SCy Schubert	        ])
1501076b9443SCy Schubert	    ])
1502076b9443SCy Schubert	    ;;
1503*00787218SCy Schubert	Linux*|GNU*|NetBSD-Debian|DragonFly-*|FreeBSD-*)
1504076b9443SCy Schubert	    SHLIB_CFLAGS="-fPIC"
1505076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1506076b9443SCy Schubert
1507076b9443SCy Schubert	    # TEA specific:
1508076b9443SCy Schubert	    CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
1509076b9443SCy Schubert
1510076b9443SCy Schubert	    # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
1511*00787218SCy Schubert	    SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS_DEFAULT} -shared'
1512076b9443SCy Schubert	    LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1513*00787218SCy Schubert
1514*00787218SCy Schubert	    case $system in
1515*00787218SCy Schubert	    DragonFly-*|FreeBSD-*)
1516*00787218SCy Schubert		AS_IF([test "${TCL_THREADS}" = "1"], [
1517*00787218SCy Schubert		    # The -pthread needs to go in the LDFLAGS, not LIBS
1518*00787218SCy Schubert		    LIBS=`echo $LIBS | sed s/-pthread//`
1519*00787218SCy Schubert		    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1520*00787218SCy Schubert		    LDFLAGS="$LDFLAGS $PTHREAD_LIBS"])
1521*00787218SCy Schubert	    ;;
1522*00787218SCy Schubert            esac
1523*00787218SCy Schubert
1524076b9443SCy Schubert	    AS_IF([test $doRpath = yes], [
1525*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
1526076b9443SCy Schubert	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1527076b9443SCy Schubert	    AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"])
1528076b9443SCy Schubert	    AS_IF([test $do64bit = yes], [
1529076b9443SCy Schubert		AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
1530076b9443SCy Schubert		    hold_cflags=$CFLAGS
1531076b9443SCy Schubert		    CFLAGS="$CFLAGS -m64"
1532*00787218SCy Schubert		    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1533*00787218SCy Schubert			    [tcl_cv_cc_m64=yes],[tcl_cv_cc_m64=no])
1534076b9443SCy Schubert		    CFLAGS=$hold_cflags])
1535076b9443SCy Schubert		AS_IF([test $tcl_cv_cc_m64 = yes], [
1536076b9443SCy Schubert		    CFLAGS="$CFLAGS -m64"
1537076b9443SCy Schubert		    do64bit_ok=yes
1538076b9443SCy Schubert		])
1539076b9443SCy Schubert	   ])
1540076b9443SCy Schubert
1541076b9443SCy Schubert	    # The combo of gcc + glibc has a bug related to inlining of
1542076b9443SCy Schubert	    # functions like strtod(). The -fno-builtin flag should address
1543076b9443SCy Schubert	    # this problem but it does not work. The -fno-inline flag is kind
1544076b9443SCy Schubert	    # of overkill but it works. Disable inlining only when one of the
1545076b9443SCy Schubert	    # files in compat/*.c is being linked in.
1546076b9443SCy Schubert
1547076b9443SCy Schubert	    AS_IF([test x"${USE_COMPAT}" != x],[CFLAGS="$CFLAGS -fno-inline"])
1548076b9443SCy Schubert	    ;;
1549076b9443SCy Schubert	Lynx*)
1550076b9443SCy Schubert	    SHLIB_CFLAGS="-fPIC"
1551076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1552076b9443SCy Schubert	    CFLAGS_OPTIMIZE=-02
1553076b9443SCy Schubert	    SHLIB_LD='${CC} -shared'
1554076b9443SCy Schubert	    LD_FLAGS="-Wl,--export-dynamic"
1555076b9443SCy Schubert	    AS_IF([test $doRpath = yes], [
1556*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
1557*00787218SCy Schubert		LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
1558076b9443SCy Schubert	    ;;
1559076b9443SCy Schubert	OpenBSD-*)
1560076b9443SCy Schubert	    arch=`arch -s`
1561076b9443SCy Schubert	    case "$arch" in
1562*00787218SCy Schubert	    alpha|sparc64)
1563*00787218SCy Schubert		SHLIB_CFLAGS="-fPIC"
1564076b9443SCy Schubert		;;
1565076b9443SCy Schubert	    *)
1566*00787218SCy Schubert		SHLIB_CFLAGS="-fpic"
1567*00787218SCy Schubert		;;
1568*00787218SCy Schubert	    esac
1569*00787218SCy Schubert	    SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
1570076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1571076b9443SCy Schubert	    AS_IF([test $doRpath = yes], [
1572*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
1573076b9443SCy Schubert	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1574*00787218SCy Schubert	    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}'
1575*00787218SCy Schubert	    LDFLAGS="$LDFLAGS -Wl,-export-dynamic"
1576076b9443SCy Schubert	    CFLAGS_OPTIMIZE="-O2"
1577076b9443SCy Schubert	    # On OpenBSD:	Compile with -pthread
1578076b9443SCy Schubert	    #		Don't link with -lpthread
1579076b9443SCy Schubert	    LIBS=`echo $LIBS | sed s/-lpthread//`
1580076b9443SCy Schubert	    CFLAGS="$CFLAGS -pthread"
1581076b9443SCy Schubert	    # OpenBSD doesn't do version numbers with dots.
1582076b9443SCy Schubert	    UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
1583076b9443SCy Schubert	    TCL_LIB_VERSIONS_OK=nodots
1584076b9443SCy Schubert	    ;;
1585076b9443SCy Schubert	NetBSD-*)
1586076b9443SCy Schubert	    # NetBSD has ELF and can use 'cc -shared' to build shared libs
1587076b9443SCy Schubert	    SHLIB_CFLAGS="-fPIC"
1588*00787218SCy Schubert	    SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
1589076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1590076b9443SCy Schubert	    LDFLAGS="$LDFLAGS -export-dynamic"
1591076b9443SCy Schubert	    AS_IF([test $doRpath = yes], [
1592*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
1593076b9443SCy Schubert	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1594076b9443SCy Schubert	    # The -pthread needs to go in the CFLAGS, not LIBS
1595076b9443SCy Schubert	    LIBS=`echo $LIBS | sed s/-pthread//`
1596076b9443SCy Schubert	    CFLAGS="$CFLAGS -pthread"
1597076b9443SCy Schubert	    LDFLAGS="$LDFLAGS -pthread"
1598076b9443SCy Schubert	    ;;
1599076b9443SCy Schubert	Darwin-*)
1600076b9443SCy Schubert	    CFLAGS_OPTIMIZE="-Os"
1601076b9443SCy Schubert	    SHLIB_CFLAGS="-fno-common"
1602076b9443SCy Schubert	    # To avoid discrepancies between what headers configure sees during
1603076b9443SCy Schubert	    # preprocessing tests and compiling tests, move any -isysroot and
1604076b9443SCy Schubert	    # -mmacosx-version-min flags from CFLAGS to CPPFLAGS:
1605076b9443SCy Schubert	    CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \
1606076b9443SCy Schubert		awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
1607076b9443SCy Schubert		if ([$]i~/^(isysroot|mmacosx-version-min)/) print "-"[$]i}'`"
1608076b9443SCy Schubert	    CFLAGS="`echo " ${CFLAGS}" | \
1609076b9443SCy Schubert		awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
1610076b9443SCy Schubert		if (!([$]i~/^(isysroot|mmacosx-version-min)/)) print "-"[$]i}'`"
1611076b9443SCy Schubert	    AS_IF([test $do64bit = yes], [
1612076b9443SCy Schubert		case `arch` in
1613076b9443SCy Schubert		    ppc)
1614076b9443SCy Schubert			AC_CACHE_CHECK([if compiler accepts -arch ppc64 flag],
1615076b9443SCy Schubert				tcl_cv_cc_arch_ppc64, [
1616076b9443SCy Schubert			    hold_cflags=$CFLAGS
1617076b9443SCy Schubert			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1618*00787218SCy Schubert			    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1619*00787218SCy Schubert				    [tcl_cv_cc_arch_ppc64=yes],[tcl_cv_cc_arch_ppc64=no])
1620076b9443SCy Schubert			    CFLAGS=$hold_cflags])
1621076b9443SCy Schubert			AS_IF([test $tcl_cv_cc_arch_ppc64 = yes], [
1622076b9443SCy Schubert			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1623076b9443SCy Schubert			    do64bit_ok=yes
1624076b9443SCy Schubert			]);;
1625076b9443SCy Schubert		    i386)
1626076b9443SCy Schubert			AC_CACHE_CHECK([if compiler accepts -arch x86_64 flag],
1627076b9443SCy Schubert				tcl_cv_cc_arch_x86_64, [
1628076b9443SCy Schubert			    hold_cflags=$CFLAGS
1629076b9443SCy Schubert			    CFLAGS="$CFLAGS -arch x86_64"
1630*00787218SCy Schubert			    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1631*00787218SCy Schubert				    [tcl_cv_cc_arch_x86_64=yes],[tcl_cv_cc_arch_x86_64=no])
1632076b9443SCy Schubert			    CFLAGS=$hold_cflags])
1633076b9443SCy Schubert			AS_IF([test $tcl_cv_cc_arch_x86_64 = yes], [
1634076b9443SCy Schubert			    CFLAGS="$CFLAGS -arch x86_64"
1635076b9443SCy Schubert			    do64bit_ok=yes
1636076b9443SCy Schubert			]);;
1637076b9443SCy Schubert		    *)
1638076b9443SCy Schubert			AC_MSG_WARN([Don't know how enable 64-bit on architecture `arch`]);;
1639076b9443SCy Schubert		esac
1640076b9443SCy Schubert	    ], [
1641076b9443SCy Schubert		# Check for combined 32-bit and 64-bit fat build
1642076b9443SCy Schubert		AS_IF([echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64) ' \
1643076b9443SCy Schubert		    && echo "$CFLAGS " |grep -E -q -- '-arch (ppc|i386) '], [
1644076b9443SCy Schubert		    fat_32_64=yes])
1645076b9443SCy Schubert	    ])
1646076b9443SCy Schubert	    # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
1647076b9443SCy Schubert	    SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}'
1648076b9443SCy Schubert	    AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
1649076b9443SCy Schubert		hold_ldflags=$LDFLAGS
1650076b9443SCy Schubert		LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
1651*00787218SCy Schubert		AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])],
1652*00787218SCy Schubert			[tcl_cv_ld_single_module=yes],[tcl_cv_ld_single_module=no])
1653076b9443SCy Schubert		LDFLAGS=$hold_ldflags])
1654076b9443SCy Schubert	    AS_IF([test $tcl_cv_ld_single_module = yes], [
1655076b9443SCy Schubert		SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
1656076b9443SCy Schubert	    ])
1657076b9443SCy Schubert	    # TEA specific: link shlib with current and compatibility version flags
1658076b9443SCy Schubert	    vers=`echo ${PACKAGE_VERSION} | sed -e 's/^\([[0-9]]\{1,5\}\)\(\(\.[[0-9]]\{1,3\}\)\{0,2\}\).*$/\1\2/p' -e d`
1659076b9443SCy Schubert	    SHLIB_LD="${SHLIB_LD} -current_version ${vers:-0} -compatibility_version ${vers:-0}"
1660076b9443SCy Schubert	    SHLIB_SUFFIX=".dylib"
1661076b9443SCy Schubert	    LDFLAGS="$LDFLAGS -headerpad_max_install_names"
1662076b9443SCy Schubert	    AC_CACHE_CHECK([if ld accepts -search_paths_first flag],
1663076b9443SCy Schubert		    tcl_cv_ld_search_paths_first, [
1664076b9443SCy Schubert		hold_ldflags=$LDFLAGS
1665076b9443SCy Schubert		LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1666*00787218SCy Schubert		AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])],
1667*00787218SCy Schubert			[tcl_cv_ld_search_paths_first=yes],[tcl_cv_ld_search_paths_first=no])
1668076b9443SCy Schubert		LDFLAGS=$hold_ldflags])
1669076b9443SCy Schubert	    AS_IF([test $tcl_cv_ld_search_paths_first = yes], [
1670076b9443SCy Schubert		LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1671076b9443SCy Schubert	    ])
1672076b9443SCy Schubert	    AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [
1673076b9443SCy Schubert		AC_DEFINE(MODULE_SCOPE, [__private_extern__],
1674076b9443SCy Schubert		    [Compiler support for module scope symbols])
1675076b9443SCy Schubert		tcl_cv_cc_visibility_hidden=yes
1676076b9443SCy Schubert	    ])
1677076b9443SCy Schubert	    CC_SEARCH_FLAGS=""
1678076b9443SCy Schubert	    LD_SEARCH_FLAGS=""
1679076b9443SCy Schubert	    LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
1680076b9443SCy Schubert	    # TEA specific: for combined 32 & 64 bit fat builds of Tk
1681076b9443SCy Schubert	    # extensions, verify that 64-bit build is possible.
1682076b9443SCy Schubert	    AS_IF([test "$fat_32_64" = yes && test -n "${TK_BIN_DIR}"], [
1683076b9443SCy Schubert		AS_IF([test "${TEA_WINDOWINGSYSTEM}" = x11], [
1684076b9443SCy Schubert		    AC_CACHE_CHECK([for 64-bit X11], tcl_cv_lib_x11_64, [
1685076b9443SCy Schubert			for v in CFLAGS CPPFLAGS LDFLAGS; do
1686076b9443SCy Schubert			    eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
1687076b9443SCy Schubert			done
1688076b9443SCy Schubert			CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include"
1689076b9443SCy Schubert			LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
1690*00787218SCy Schubert			AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[XrmInitialize();]])],
1691*00787218SCy Schubert			    [tcl_cv_lib_x11_64=yes],[tcl_cv_lib_x11_64=no])
1692076b9443SCy Schubert			for v in CFLAGS CPPFLAGS LDFLAGS; do
1693076b9443SCy Schubert			    eval $v'="$hold_'$v'"'
1694076b9443SCy Schubert			done])
1695076b9443SCy Schubert		])
1696076b9443SCy Schubert		AS_IF([test "${TEA_WINDOWINGSYSTEM}" = aqua], [
1697076b9443SCy Schubert		    AC_CACHE_CHECK([for 64-bit Tk], tcl_cv_lib_tk_64, [
1698076b9443SCy Schubert			for v in CFLAGS CPPFLAGS LDFLAGS; do
1699076b9443SCy Schubert			    eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
1700076b9443SCy Schubert			done
1701076b9443SCy Schubert			CPPFLAGS="$CPPFLAGS -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 ${TCL_INCLUDES} ${TK_INCLUDES}"
1702076b9443SCy Schubert			LDFLAGS="$LDFLAGS ${TCL_STUB_LIB_SPEC} ${TK_STUB_LIB_SPEC}"
1703*00787218SCy Schubert			AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <tk.h>]], [[Tk_InitStubs(NULL, "", 0);]])],
1704*00787218SCy Schubert			    [tcl_cv_lib_tk_64=yes],[tcl_cv_lib_tk_64=no])
1705076b9443SCy Schubert			for v in CFLAGS CPPFLAGS LDFLAGS; do
1706076b9443SCy Schubert			    eval $v'="$hold_'$v'"'
1707076b9443SCy Schubert			done])
1708076b9443SCy Schubert		])
1709076b9443SCy Schubert		# remove 64-bit arch flags from CFLAGS et al. if configuration
1710076b9443SCy Schubert		# does not support 64-bit.
1711076b9443SCy Schubert		AS_IF([test "$tcl_cv_lib_tk_64" = no -o "$tcl_cv_lib_x11_64" = no], [
1712076b9443SCy Schubert		    AC_MSG_NOTICE([Removing 64-bit architectures from compiler & linker flags])
1713076b9443SCy Schubert		    for v in CFLAGS CPPFLAGS LDFLAGS; do
1714076b9443SCy Schubert			eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
1715076b9443SCy Schubert		    done])
1716076b9443SCy Schubert	    ])
1717076b9443SCy Schubert	    ;;
1718076b9443SCy Schubert	OS/390-*)
1719076b9443SCy Schubert	    CFLAGS_OPTIMIZE=""		# Optimizer is buggy
1720076b9443SCy Schubert	    AC_DEFINE(_OE_SOCKETS, 1,	# needed in sys/socket.h
1721076b9443SCy Schubert		[Should OS/390 do the right thing with sockets?])
1722076b9443SCy Schubert	    ;;
1723076b9443SCy Schubert	OSF1-V*)
1724076b9443SCy Schubert	    # Digital OSF/1
1725076b9443SCy Schubert	    SHLIB_CFLAGS=""
1726076b9443SCy Schubert	    AS_IF([test "$SHARED_BUILD" = 1], [
1727076b9443SCy Schubert	        SHLIB_LD='ld -shared -expect_unresolved "*"'
1728076b9443SCy Schubert	    ], [
1729076b9443SCy Schubert	        SHLIB_LD='ld -non_shared -expect_unresolved "*"'
1730076b9443SCy Schubert	    ])
1731076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1732076b9443SCy Schubert	    AS_IF([test $doRpath = yes], [
1733*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
1734076b9443SCy Schubert		LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
1735076b9443SCy Schubert	    AS_IF([test "$GCC" = yes], [CFLAGS="$CFLAGS -mieee"], [
1736076b9443SCy Schubert		CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"])
1737076b9443SCy Schubert	    # see pthread_intro(3) for pthread support on osf1, k.furukawa
1738076b9443SCy Schubert	    CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
1739076b9443SCy Schubert	    CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
1740076b9443SCy Schubert	    LIBS=`echo $LIBS | sed s/-lpthreads//`
1741076b9443SCy Schubert	    AS_IF([test "$GCC" = yes], [
1742076b9443SCy Schubert		LIBS="$LIBS -lpthread -lmach -lexc"
1743076b9443SCy Schubert	    ], [
1744076b9443SCy Schubert		CFLAGS="$CFLAGS -pthread"
1745076b9443SCy Schubert		LDFLAGS="$LDFLAGS -pthread"
1746076b9443SCy Schubert	    ])
1747076b9443SCy Schubert	    ;;
1748076b9443SCy Schubert	QNX-6*)
1749076b9443SCy Schubert	    # QNX RTP
1750076b9443SCy Schubert	    # This may work for all QNX, but it was only reported for v6.
1751076b9443SCy Schubert	    SHLIB_CFLAGS="-fPIC"
1752076b9443SCy Schubert	    SHLIB_LD="ld -Bshareable -x"
1753076b9443SCy Schubert	    SHLIB_LD_LIBS=""
1754076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1755076b9443SCy Schubert	    CC_SEARCH_FLAGS=""
1756076b9443SCy Schubert	    LD_SEARCH_FLAGS=""
1757076b9443SCy Schubert	    ;;
1758076b9443SCy Schubert	SCO_SV-3.2*)
1759076b9443SCy Schubert	    AS_IF([test "$GCC" = yes], [
1760076b9443SCy Schubert		SHLIB_CFLAGS="-fPIC -melf"
1761076b9443SCy Schubert		LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
1762076b9443SCy Schubert	    ], [
1763076b9443SCy Schubert		SHLIB_CFLAGS="-Kpic -belf"
1764076b9443SCy Schubert		LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
1765076b9443SCy Schubert	    ])
1766076b9443SCy Schubert	    SHLIB_LD="ld -G"
1767076b9443SCy Schubert	    SHLIB_LD_LIBS=""
1768076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1769076b9443SCy Schubert	    CC_SEARCH_FLAGS=""
1770076b9443SCy Schubert	    LD_SEARCH_FLAGS=""
1771076b9443SCy Schubert	    ;;
1772076b9443SCy Schubert	SunOS-5.[[0-6]])
1773076b9443SCy Schubert	    # Careful to not let 5.10+ fall into this case
1774076b9443SCy Schubert
1775076b9443SCy Schubert	    # Note: If _REENTRANT isn't defined, then Solaris
1776076b9443SCy Schubert	    # won't define thread-safe library routines.
1777076b9443SCy Schubert
1778076b9443SCy Schubert	    AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
1779076b9443SCy Schubert	    AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
1780076b9443SCy Schubert		[Do we really want to follow the standard? Yes we do!])
1781076b9443SCy Schubert
1782076b9443SCy Schubert	    SHLIB_CFLAGS="-KPIC"
1783076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1784076b9443SCy Schubert	    AS_IF([test "$GCC" = yes], [
1785076b9443SCy Schubert		SHLIB_LD='${CC} -shared'
1786*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"'
1787076b9443SCy Schubert		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1788076b9443SCy Schubert	    ], [
1789076b9443SCy Schubert		SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1790*00787218SCy Schubert		CC_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"'
1791076b9443SCy Schubert		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1792076b9443SCy Schubert	    ])
1793076b9443SCy Schubert	    ;;
1794076b9443SCy Schubert	SunOS-5*)
1795076b9443SCy Schubert	    # Note: If _REENTRANT isn't defined, then Solaris
1796076b9443SCy Schubert	    # won't define thread-safe library routines.
1797076b9443SCy Schubert
1798076b9443SCy Schubert	    AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
1799076b9443SCy Schubert	    AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
1800076b9443SCy Schubert		[Do we really want to follow the standard? Yes we do!])
1801076b9443SCy Schubert
1802076b9443SCy Schubert	    SHLIB_CFLAGS="-KPIC"
1803076b9443SCy Schubert
1804076b9443SCy Schubert	    # Check to enable 64-bit flags for compiler/linker
1805076b9443SCy Schubert	    AS_IF([test "$do64bit" = yes], [
1806076b9443SCy Schubert		arch=`isainfo`
1807076b9443SCy Schubert		AS_IF([test "$arch" = "sparcv9 sparc"], [
1808076b9443SCy Schubert		    AS_IF([test "$GCC" = yes], [
1809076b9443SCy Schubert			AS_IF([test "`${CC} -dumpversion | awk -F. '{print [$]1}'`" -lt 3], [
1810076b9443SCy Schubert			    AC_MSG_WARN([64bit mode not supported with GCC < 3.2 on $system])
1811076b9443SCy Schubert			], [
1812076b9443SCy Schubert			    do64bit_ok=yes
1813076b9443SCy Schubert			    CFLAGS="$CFLAGS -m64 -mcpu=v9"
1814076b9443SCy Schubert			    LDFLAGS="$LDFLAGS -m64 -mcpu=v9"
1815076b9443SCy Schubert			    SHLIB_CFLAGS="-fPIC"
1816076b9443SCy Schubert			])
1817076b9443SCy Schubert		    ], [
1818076b9443SCy Schubert			do64bit_ok=yes
1819076b9443SCy Schubert			AS_IF([test "$do64bitVIS" = yes], [
1820076b9443SCy Schubert			    CFLAGS="$CFLAGS -xarch=v9a"
1821076b9443SCy Schubert			    LDFLAGS_ARCH="-xarch=v9a"
1822076b9443SCy Schubert			], [
1823076b9443SCy Schubert			    CFLAGS="$CFLAGS -xarch=v9"
1824076b9443SCy Schubert			    LDFLAGS_ARCH="-xarch=v9"
1825076b9443SCy Schubert			])
1826076b9443SCy Schubert			# Solaris 64 uses this as well
1827076b9443SCy Schubert			#LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
1828076b9443SCy Schubert		    ])
1829076b9443SCy Schubert		], [AS_IF([test "$arch" = "amd64 i386"], [
1830076b9443SCy Schubert		    AS_IF([test "$GCC" = yes], [
1831076b9443SCy Schubert			case $system in
1832076b9443SCy Schubert			    SunOS-5.1[[1-9]]*|SunOS-5.[[2-9]][[0-9]]*)
1833076b9443SCy Schubert				do64bit_ok=yes
1834076b9443SCy Schubert				CFLAGS="$CFLAGS -m64"
1835076b9443SCy Schubert				LDFLAGS="$LDFLAGS -m64";;
1836076b9443SCy Schubert			    *)
1837076b9443SCy Schubert				AC_MSG_WARN([64bit mode not supported with GCC on $system]);;
1838076b9443SCy Schubert			esac
1839076b9443SCy Schubert		    ], [
1840076b9443SCy Schubert			do64bit_ok=yes
1841076b9443SCy Schubert			case $system in
1842076b9443SCy Schubert			    SunOS-5.1[[1-9]]*|SunOS-5.[[2-9]][[0-9]]*)
1843076b9443SCy Schubert				CFLAGS="$CFLAGS -m64"
1844076b9443SCy Schubert				LDFLAGS="$LDFLAGS -m64";;
1845076b9443SCy Schubert			    *)
1846076b9443SCy Schubert				CFLAGS="$CFLAGS -xarch=amd64"
1847076b9443SCy Schubert				LDFLAGS="$LDFLAGS -xarch=amd64";;
1848076b9443SCy Schubert			esac
1849076b9443SCy Schubert		    ])
1850076b9443SCy Schubert		], [AC_MSG_WARN([64bit mode not supported for $arch])])])
1851076b9443SCy Schubert	    ])
1852076b9443SCy Schubert
1853076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1854076b9443SCy Schubert	    AS_IF([test "$GCC" = yes], [
1855076b9443SCy Schubert		SHLIB_LD='${CC} -shared'
1856*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"'
1857076b9443SCy Schubert		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1858076b9443SCy Schubert		AS_IF([test "$do64bit_ok" = yes], [
1859076b9443SCy Schubert		    AS_IF([test "$arch" = "sparcv9 sparc"], [
1860076b9443SCy Schubert			# We need to specify -static-libgcc or we need to
1861076b9443SCy Schubert			# add the path to the sparv9 libgcc.
1862076b9443SCy Schubert			# JH: static-libgcc is necessary for core Tcl, but may
1863076b9443SCy Schubert			# not be necessary for extensions.
1864076b9443SCy Schubert			SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
1865076b9443SCy Schubert			# for finding sparcv9 libgcc, get the regular libgcc
1866076b9443SCy Schubert			# path, remove so name and append 'sparcv9'
1867076b9443SCy Schubert			#v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..."
1868076b9443SCy Schubert			#CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir"
1869076b9443SCy Schubert		    ], [AS_IF([test "$arch" = "amd64 i386"], [
1870076b9443SCy Schubert			# JH: static-libgcc is necessary for core Tcl, but may
1871076b9443SCy Schubert			# not be necessary for extensions.
1872076b9443SCy Schubert			SHLIB_LD="$SHLIB_LD -m64 -static-libgcc"
1873076b9443SCy Schubert		    ])])
1874076b9443SCy Schubert		])
1875076b9443SCy Schubert	    ], [
1876076b9443SCy Schubert		case $system in
1877076b9443SCy Schubert		    SunOS-5.[[1-9]][[0-9]]*)
1878076b9443SCy Schubert			# TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
1879076b9443SCy Schubert			SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';;
1880076b9443SCy Schubert		    *)
1881076b9443SCy Schubert			SHLIB_LD='/usr/ccs/bin/ld -G -z text';;
1882076b9443SCy Schubert		esac
1883*00787218SCy Schubert		CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"'
1884*00787218SCy Schubert		LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"'
1885076b9443SCy Schubert	    ])
1886076b9443SCy Schubert	    ;;
1887076b9443SCy Schubert	UNIX_SV* | UnixWare-5*)
1888076b9443SCy Schubert	    SHLIB_CFLAGS="-KPIC"
1889076b9443SCy Schubert	    SHLIB_LD='${CC} -G'
1890076b9443SCy Schubert	    SHLIB_LD_LIBS=""
1891076b9443SCy Schubert	    SHLIB_SUFFIX=".so"
1892076b9443SCy Schubert	    # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
1893076b9443SCy Schubert	    # that don't grok the -Bexport option.  Test that it does.
1894076b9443SCy Schubert	    AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [
1895076b9443SCy Schubert		hold_ldflags=$LDFLAGS
1896076b9443SCy Schubert		LDFLAGS="$LDFLAGS -Wl,-Bexport"
1897*00787218SCy Schubert		AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])],
1898*00787218SCy Schubert			[tcl_cv_ld_Bexport=yes],[tcl_cv_ld_Bexport=no])
1899076b9443SCy Schubert	        LDFLAGS=$hold_ldflags])
1900076b9443SCy Schubert	    AS_IF([test $tcl_cv_ld_Bexport = yes], [
1901076b9443SCy Schubert		LDFLAGS="$LDFLAGS -Wl,-Bexport"
1902076b9443SCy Schubert	    ])
1903076b9443SCy Schubert	    CC_SEARCH_FLAGS=""
1904076b9443SCy Schubert	    LD_SEARCH_FLAGS=""
1905076b9443SCy Schubert	    ;;
1906076b9443SCy Schubert    esac
1907076b9443SCy Schubert
1908076b9443SCy Schubert    AS_IF([test "$do64bit" = yes -a "$do64bit_ok" = no], [
1909076b9443SCy Schubert	AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform])
1910076b9443SCy Schubert    ])
1911076b9443SCy Schubert
1912076b9443SCy Schubertdnl # Add any CPPFLAGS set in the environment to our CFLAGS, but delay doing so
1913076b9443SCy Schubertdnl # until the end of configure, as configure's compile and link tests use
1914076b9443SCy Schubertdnl # both CPPFLAGS and CFLAGS (unlike our compile and link) but configure's
1915076b9443SCy Schubertdnl # preprocessing tests use only CPPFLAGS.
1916076b9443SCy Schubert    AC_CONFIG_COMMANDS_PRE([CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""])
1917076b9443SCy Schubert
1918076b9443SCy Schubert    # Add in the arch flags late to ensure it wasn't removed.
1919076b9443SCy Schubert    # Not necessary in TEA, but this is aligned with core
1920076b9443SCy Schubert    LDFLAGS="$LDFLAGS $LDFLAGS_ARCH"
1921076b9443SCy Schubert
1922076b9443SCy Schubert    # If we're running gcc, then change the C flags for compiling shared
1923076b9443SCy Schubert    # libraries to the right flags for gcc, instead of those for the
1924076b9443SCy Schubert    # standard manufacturer compiler.
1925076b9443SCy Schubert
1926076b9443SCy Schubert    AS_IF([test "$GCC" = yes], [
1927076b9443SCy Schubert	case $system in
1928076b9443SCy Schubert	    AIX-*) ;;
1929076b9443SCy Schubert	    BSD/OS*) ;;
1930*00787218SCy Schubert	    CYGWIN_*|MINGW32_*|MINGW64_*|MSYS_*) ;;
1931076b9443SCy Schubert	    IRIX*) ;;
1932*00787218SCy Schubert	    NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;;
1933076b9443SCy Schubert	    Darwin-*) ;;
1934076b9443SCy Schubert	    SCO_SV-3.2*) ;;
1935076b9443SCy Schubert	    windows) ;;
1936076b9443SCy Schubert	    *) SHLIB_CFLAGS="-fPIC" ;;
1937076b9443SCy Schubert	esac])
1938076b9443SCy Schubert
1939076b9443SCy Schubert    AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [
1940076b9443SCy Schubert	AC_DEFINE(MODULE_SCOPE, [extern],
1941076b9443SCy Schubert	    [No Compiler support for module scope symbols])
1942076b9443SCy Schubert    ])
1943076b9443SCy Schubert
1944076b9443SCy Schubert    AS_IF([test "$SHARED_LIB_SUFFIX" = ""], [
1945076b9443SCy Schubert    # TEA specific: use PACKAGE_VERSION instead of VERSION
1946076b9443SCy Schubert    SHARED_LIB_SUFFIX='${PACKAGE_VERSION}${SHLIB_SUFFIX}'])
1947076b9443SCy Schubert    AS_IF([test "$UNSHARED_LIB_SUFFIX" = ""], [
1948076b9443SCy Schubert    # TEA specific: use PACKAGE_VERSION instead of VERSION
1949076b9443SCy Schubert    UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}.a'])
1950076b9443SCy Schubert
1951076b9443SCy Schubert    if test "${GCC}" = "yes" -a ${SHLIB_SUFFIX} = ".dll"; then
1952076b9443SCy Schubert	AC_CACHE_CHECK(for SEH support in compiler,
1953076b9443SCy Schubert	    tcl_cv_seh,
1954*00787218SCy Schubert	AC_RUN_IFELSE([AC_LANG_SOURCE([[
1955076b9443SCy Schubert#define WIN32_LEAN_AND_MEAN
1956076b9443SCy Schubert#include <windows.h>
1957076b9443SCy Schubert#undef WIN32_LEAN_AND_MEAN
1958076b9443SCy Schubert
1959076b9443SCy Schubert	    int main(int argc, char** argv) {
1960076b9443SCy Schubert		int a, b = 0;
1961076b9443SCy Schubert		__try {
1962076b9443SCy Schubert		    a = 666 / b;
1963076b9443SCy Schubert		}
1964076b9443SCy Schubert		__except (EXCEPTION_EXECUTE_HANDLER) {
1965076b9443SCy Schubert		    return 0;
1966076b9443SCy Schubert		}
1967076b9443SCy Schubert		return 1;
1968076b9443SCy Schubert	    }
1969*00787218SCy Schubert	]])],
1970*00787218SCy Schubert	    [tcl_cv_seh=yes],
1971*00787218SCy Schubert	    [tcl_cv_seh=no],
1972*00787218SCy Schubert	    [tcl_cv_seh=no])
1973076b9443SCy Schubert	)
1974076b9443SCy Schubert	if test "$tcl_cv_seh" = "no" ; then
1975076b9443SCy Schubert	    AC_DEFINE(HAVE_NO_SEH, 1,
1976076b9443SCy Schubert		    [Defined when mingw does not support SEH])
1977076b9443SCy Schubert	fi
1978076b9443SCy Schubert
1979076b9443SCy Schubert	#
1980076b9443SCy Schubert	# Check to see if the excpt.h include file provided contains the
1981076b9443SCy Schubert	# definition for EXCEPTION_DISPOSITION; if not, which is the case
1982076b9443SCy Schubert	# with Cygwin's version as of 2002-04-10, define it to be int,
1983076b9443SCy Schubert	# sufficient for getting the current code to work.
1984076b9443SCy Schubert	#
1985076b9443SCy Schubert	AC_CACHE_CHECK(for EXCEPTION_DISPOSITION support in include files,
1986076b9443SCy Schubert	    tcl_cv_eh_disposition,
1987*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1988076b9443SCy Schubert#	    define WIN32_LEAN_AND_MEAN
1989076b9443SCy Schubert#	    include <windows.h>
1990076b9443SCy Schubert#	    undef WIN32_LEAN_AND_MEAN
1991*00787218SCy Schubert	    ]], [[
1992076b9443SCy Schubert		EXCEPTION_DISPOSITION x;
1993*00787218SCy Schubert	    ]])],
1994*00787218SCy Schubert		[tcl_cv_eh_disposition=yes],
1995*00787218SCy Schubert		[tcl_cv_eh_disposition=no])
1996076b9443SCy Schubert	)
1997076b9443SCy Schubert	if test "$tcl_cv_eh_disposition" = "no" ; then
1998076b9443SCy Schubert	AC_DEFINE(EXCEPTION_DISPOSITION, int,
1999076b9443SCy Schubert		[Defined when cygwin/mingw does not support EXCEPTION DISPOSITION])
2000076b9443SCy Schubert	fi
2001076b9443SCy Schubert
2002076b9443SCy Schubert	# Check to see if winnt.h defines CHAR, SHORT, and LONG
2003076b9443SCy Schubert	# even if VOID has already been #defined. The win32api
2004076b9443SCy Schubert	# used by mingw and cygwin is known to do this.
2005076b9443SCy Schubert
2006076b9443SCy Schubert	AC_CACHE_CHECK(for winnt.h that ignores VOID define,
2007076b9443SCy Schubert	    tcl_cv_winnt_ignore_void,
2008*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2009076b9443SCy Schubert#define VOID void
2010076b9443SCy Schubert#define WIN32_LEAN_AND_MEAN
2011076b9443SCy Schubert#include <windows.h>
2012076b9443SCy Schubert#undef WIN32_LEAN_AND_MEAN
2013*00787218SCy Schubert	    ]], [[
2014076b9443SCy Schubert		CHAR c;
2015076b9443SCy Schubert		SHORT s;
2016076b9443SCy Schubert		LONG l;
2017*00787218SCy Schubert	    ]])],
2018*00787218SCy Schubert        [tcl_cv_winnt_ignore_void=yes],
2019*00787218SCy Schubert        [tcl_cv_winnt_ignore_void=no])
2020076b9443SCy Schubert	)
2021076b9443SCy Schubert	if test "$tcl_cv_winnt_ignore_void" = "yes" ; then
2022076b9443SCy Schubert	    AC_DEFINE(HAVE_WINNT_IGNORE_VOID, 1,
2023076b9443SCy Schubert		    [Defined when cygwin/mingw ignores VOID define in winnt.h])
2024076b9443SCy Schubert	fi
2025076b9443SCy Schubert    fi
2026076b9443SCy Schubert
2027076b9443SCy Schubert	# See if the compiler supports casting to a union type.
2028076b9443SCy Schubert	# This is used to stop gcc from printing a compiler
2029076b9443SCy Schubert	# warning when initializing a union member.
2030076b9443SCy Schubert
2031076b9443SCy Schubert	AC_CACHE_CHECK(for cast to union support,
2032076b9443SCy Schubert	    tcl_cv_cast_to_union,
2033*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2034076b9443SCy Schubert		  union foo { int i; double d; };
2035076b9443SCy Schubert		  union foo f = (union foo) (int) 0;
2036*00787218SCy Schubert	    ]])],
2037*00787218SCy Schubert	    [tcl_cv_cast_to_union=yes],
2038*00787218SCy Schubert	    [tcl_cv_cast_to_union=no])
2039076b9443SCy Schubert	)
2040076b9443SCy Schubert	if test "$tcl_cv_cast_to_union" = "yes"; then
2041076b9443SCy Schubert	    AC_DEFINE(HAVE_CAST_TO_UNION, 1,
2042076b9443SCy Schubert		    [Defined when compiler supports casting to union type.])
2043076b9443SCy Schubert	fi
2044076b9443SCy Schubert
2045*00787218SCy Schubert	AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have <stdbool.h>?])],)
2046*00787218SCy Schubert
2047076b9443SCy Schubert    AC_SUBST(CFLAGS_DEBUG)
2048076b9443SCy Schubert    AC_SUBST(CFLAGS_OPTIMIZE)
2049076b9443SCy Schubert    AC_SUBST(CFLAGS_WARNING)
2050*00787218SCy Schubert    AC_SUBST(LDFLAGS_DEBUG)
2051*00787218SCy Schubert    AC_SUBST(LDFLAGS_OPTIMIZE)
2052076b9443SCy Schubert
2053076b9443SCy Schubert    AC_SUBST(STLIB_LD)
2054076b9443SCy Schubert    AC_SUBST(SHLIB_LD)
2055076b9443SCy Schubert
2056076b9443SCy Schubert    AC_SUBST(SHLIB_LD_LIBS)
2057076b9443SCy Schubert    AC_SUBST(SHLIB_CFLAGS)
2058076b9443SCy Schubert
2059076b9443SCy Schubert    AC_SUBST(LD_LIBRARY_PATH_VAR)
2060076b9443SCy Schubert
2061076b9443SCy Schubert    # These must be called after we do the basic CFLAGS checks and
2062076b9443SCy Schubert    # verify any possible 64-bit or similar switches are necessary
2063076b9443SCy Schubert    TEA_TCL_EARLY_FLAGS
2064076b9443SCy Schubert    TEA_TCL_64BIT_FLAGS
2065076b9443SCy Schubert])
2066076b9443SCy Schubert
2067076b9443SCy Schubert#--------------------------------------------------------------------
2068076b9443SCy Schubert# TEA_SERIAL_PORT
2069076b9443SCy Schubert#
2070076b9443SCy Schubert#	Determine which interface to use to talk to the serial port.
2071076b9443SCy Schubert#	Note that #include lines must begin in leftmost column for
2072076b9443SCy Schubert#	some compilers to recognize them as preprocessor directives,
2073076b9443SCy Schubert#	and some build environments have stdin not pointing at a
2074076b9443SCy Schubert#	pseudo-terminal (usually /dev/null instead.)
2075076b9443SCy Schubert#
2076076b9443SCy Schubert# Arguments:
2077076b9443SCy Schubert#	none
2078076b9443SCy Schubert#
2079076b9443SCy Schubert# Results:
2080076b9443SCy Schubert#
2081076b9443SCy Schubert#	Defines only one of the following vars:
2082076b9443SCy Schubert#		HAVE_SYS_MODEM_H
2083076b9443SCy Schubert#		USE_TERMIOS
2084076b9443SCy Schubert#		USE_TERMIO
2085076b9443SCy Schubert#		USE_SGTTY
2086076b9443SCy Schubert#--------------------------------------------------------------------
2087076b9443SCy Schubert
2088076b9443SCy SchubertAC_DEFUN([TEA_SERIAL_PORT], [
2089076b9443SCy Schubert    AC_CHECK_HEADERS(sys/modem.h)
2090076b9443SCy Schubert    AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
2091*00787218SCy Schubert    AC_RUN_IFELSE([AC_LANG_SOURCE([[
2092076b9443SCy Schubert#include <termios.h>
2093076b9443SCy Schubert
2094076b9443SCy Schubertint main() {
2095076b9443SCy Schubert    struct termios t;
2096076b9443SCy Schubert    if (tcgetattr(0, &t) == 0) {
2097076b9443SCy Schubert	cfsetospeed(&t, 0);
2098076b9443SCy Schubert	t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2099076b9443SCy Schubert	return 0;
2100076b9443SCy Schubert    }
2101076b9443SCy Schubert    return 1;
2102*00787218SCy Schubert}]])],[tcl_cv_api_serial=termios],[tcl_cv_api_serial=no],[tcl_cv_api_serial=no])
2103076b9443SCy Schubert    if test $tcl_cv_api_serial = no ; then
2104*00787218SCy Schubert	AC_RUN_IFELSE([AC_LANG_SOURCE([[
2105076b9443SCy Schubert#include <termio.h>
2106076b9443SCy Schubert
2107076b9443SCy Schubertint main() {
2108076b9443SCy Schubert    struct termio t;
2109076b9443SCy Schubert    if (ioctl(0, TCGETA, &t) == 0) {
2110076b9443SCy Schubert	t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2111076b9443SCy Schubert	return 0;
2112076b9443SCy Schubert    }
2113076b9443SCy Schubert    return 1;
2114*00787218SCy Schubert}]])],[tcl_cv_api_serial=termio],[tcl_cv_api_serial=no],[tcl_cv_api_serial=no])
2115076b9443SCy Schubert    fi
2116076b9443SCy Schubert    if test $tcl_cv_api_serial = no ; then
2117*00787218SCy Schubert	AC_RUN_IFELSE([AC_LANG_SOURCE([[
2118076b9443SCy Schubert#include <sgtty.h>
2119076b9443SCy Schubert
2120076b9443SCy Schubertint main() {
2121076b9443SCy Schubert    struct sgttyb t;
2122076b9443SCy Schubert    if (ioctl(0, TIOCGETP, &t) == 0) {
2123076b9443SCy Schubert	t.sg_ospeed = 0;
2124076b9443SCy Schubert	t.sg_flags |= ODDP | EVENP | RAW;
2125076b9443SCy Schubert	return 0;
2126076b9443SCy Schubert    }
2127076b9443SCy Schubert    return 1;
2128*00787218SCy Schubert}]])],[tcl_cv_api_serial=sgtty],[tcl_cv_api_serial=no],[tcl_cv_api_serial=no])
2129076b9443SCy Schubert    fi
2130076b9443SCy Schubert    if test $tcl_cv_api_serial = no ; then
2131*00787218SCy Schubert	AC_RUN_IFELSE([AC_LANG_SOURCE([[
2132076b9443SCy Schubert#include <termios.h>
2133076b9443SCy Schubert#include <errno.h>
2134076b9443SCy Schubert
2135076b9443SCy Schubertint main() {
2136076b9443SCy Schubert    struct termios t;
2137076b9443SCy Schubert    if (tcgetattr(0, &t) == 0
2138076b9443SCy Schubert	|| errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2139076b9443SCy Schubert	cfsetospeed(&t, 0);
2140076b9443SCy Schubert	t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2141076b9443SCy Schubert	return 0;
2142076b9443SCy Schubert    }
2143076b9443SCy Schubert    return 1;
2144*00787218SCy Schubert}]])],[tcl_cv_api_serial=termios],[tcl_cv_api_serial=no],[tcl_cv_api_serial=no])
2145076b9443SCy Schubert    fi
2146076b9443SCy Schubert    if test $tcl_cv_api_serial = no; then
2147*00787218SCy Schubert	AC_RUN_IFELSE([AC_LANG_SOURCE([[
2148076b9443SCy Schubert#include <termio.h>
2149076b9443SCy Schubert#include <errno.h>
2150076b9443SCy Schubert
2151076b9443SCy Schubertint main() {
2152076b9443SCy Schubert    struct termio t;
2153076b9443SCy Schubert    if (ioctl(0, TCGETA, &t) == 0
2154076b9443SCy Schubert	|| errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2155076b9443SCy Schubert	t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2156076b9443SCy Schubert	return 0;
2157076b9443SCy Schubert    }
2158076b9443SCy Schubert    return 1;
2159*00787218SCy Schubert    }]])],[tcl_cv_api_serial=termio],[tcl_cv_api_serial=no],[tcl_cv_api_serial=no])
2160076b9443SCy Schubert    fi
2161076b9443SCy Schubert    if test $tcl_cv_api_serial = no; then
2162*00787218SCy Schubert	AC_RUN_IFELSE([AC_LANG_SOURCE([[
2163076b9443SCy Schubert#include <sgtty.h>
2164076b9443SCy Schubert#include <errno.h>
2165076b9443SCy Schubert
2166076b9443SCy Schubertint main() {
2167076b9443SCy Schubert    struct sgttyb t;
2168076b9443SCy Schubert    if (ioctl(0, TIOCGETP, &t) == 0
2169076b9443SCy Schubert	|| errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2170076b9443SCy Schubert	t.sg_ospeed = 0;
2171076b9443SCy Schubert	t.sg_flags |= ODDP | EVENP | RAW;
2172076b9443SCy Schubert	return 0;
2173076b9443SCy Schubert    }
2174076b9443SCy Schubert    return 1;
2175*00787218SCy Schubert}]])],[tcl_cv_api_serial=sgtty],[tcl_cv_api_serial=none],[tcl_cv_api_serial=none])
2176076b9443SCy Schubert    fi])
2177076b9443SCy Schubert    case $tcl_cv_api_serial in
2178076b9443SCy Schubert	termios) AC_DEFINE(USE_TERMIOS, 1, [Use the termios API for serial lines]);;
2179076b9443SCy Schubert	termio)  AC_DEFINE(USE_TERMIO, 1, [Use the termio API for serial lines]);;
2180076b9443SCy Schubert	sgtty)   AC_DEFINE(USE_SGTTY, 1, [Use the sgtty API for serial lines]);;
2181076b9443SCy Schubert    esac
2182076b9443SCy Schubert])
2183076b9443SCy Schubert
2184076b9443SCy Schubert#--------------------------------------------------------------------
2185076b9443SCy Schubert# TEA_PATH_X
2186076b9443SCy Schubert#
2187076b9443SCy Schubert#	Locate the X11 header files and the X11 library archive.  Try
2188076b9443SCy Schubert#	the ac_path_x macro first, but if it doesn't find the X stuff
2189076b9443SCy Schubert#	(e.g. because there's no xmkmf program) then check through
2190076b9443SCy Schubert#	a list of possible directories.  Under some conditions the
2191076b9443SCy Schubert#	autoconf macro will return an include directory that contains
2192076b9443SCy Schubert#	no include files, so double-check its result just to be safe.
2193076b9443SCy Schubert#
2194076b9443SCy Schubert#	This should be called after TEA_CONFIG_CFLAGS as setting the
2195076b9443SCy Schubert#	LIBS line can confuse some configure macro magic.
2196076b9443SCy Schubert#
2197076b9443SCy Schubert# Arguments:
2198076b9443SCy Schubert#	none
2199076b9443SCy Schubert#
2200076b9443SCy Schubert# Results:
2201076b9443SCy Schubert#
2202076b9443SCy Schubert#	Sets the following vars:
2203076b9443SCy Schubert#		XINCLUDES
2204076b9443SCy Schubert#		XLIBSW
2205076b9443SCy Schubert#		PKG_LIBS (appends to)
2206076b9443SCy Schubert#--------------------------------------------------------------------
2207076b9443SCy Schubert
2208076b9443SCy SchubertAC_DEFUN([TEA_PATH_X], [
2209076b9443SCy Schubert    if test "${TEA_WINDOWINGSYSTEM}" = "x11" ; then
2210076b9443SCy Schubert	TEA_PATH_UNIX_X
2211076b9443SCy Schubert    fi
2212076b9443SCy Schubert])
2213076b9443SCy Schubert
2214076b9443SCy SchubertAC_DEFUN([TEA_PATH_UNIX_X], [
2215076b9443SCy Schubert    AC_PATH_X
2216076b9443SCy Schubert    not_really_there=""
2217076b9443SCy Schubert    if test "$no_x" = ""; then
2218076b9443SCy Schubert	if test "$x_includes" = ""; then
2219*00787218SCy Schubert	    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <X11/Xlib.h>]])],[],[not_really_there="yes"])
2220076b9443SCy Schubert	else
2221076b9443SCy Schubert	    if test ! -r $x_includes/X11/Xlib.h; then
2222076b9443SCy Schubert		not_really_there="yes"
2223076b9443SCy Schubert	    fi
2224076b9443SCy Schubert	fi
2225076b9443SCy Schubert    fi
2226076b9443SCy Schubert    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
2227076b9443SCy Schubert	AC_MSG_CHECKING([for X11 header files])
2228076b9443SCy Schubert	found_xincludes="no"
2229*00787218SCy Schubert	AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <X11/Xlib.h>]])],[found_xincludes="yes"],[found_xincludes="no"])
2230076b9443SCy Schubert	if test "$found_xincludes" = "no"; then
2231076b9443SCy Schubert	    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"
2232076b9443SCy Schubert	    for i in $dirs ; do
2233076b9443SCy Schubert		if test -r $i/X11/Xlib.h; then
2234076b9443SCy Schubert		    AC_MSG_RESULT([$i])
2235076b9443SCy Schubert		    XINCLUDES=" -I$i"
2236076b9443SCy Schubert		    found_xincludes="yes"
2237076b9443SCy Schubert		    break
2238076b9443SCy Schubert		fi
2239076b9443SCy Schubert	    done
2240076b9443SCy Schubert	fi
2241076b9443SCy Schubert    else
2242076b9443SCy Schubert	if test "$x_includes" != ""; then
2243076b9443SCy Schubert	    XINCLUDES="-I$x_includes"
2244076b9443SCy Schubert	    found_xincludes="yes"
2245076b9443SCy Schubert	fi
2246076b9443SCy Schubert    fi
2247076b9443SCy Schubert    if test "$found_xincludes" = "no"; then
2248076b9443SCy Schubert	AC_MSG_RESULT([couldn't find any!])
2249076b9443SCy Schubert    fi
2250076b9443SCy Schubert
2251076b9443SCy Schubert    if test "$no_x" = yes; then
2252076b9443SCy Schubert	AC_MSG_CHECKING([for X11 libraries])
2253076b9443SCy Schubert	XLIBSW=nope
2254076b9443SCy Schubert	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"
2255076b9443SCy Schubert	for i in $dirs ; do
2256076b9443SCy Schubert	    if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl -o -r $i/libX11.dylib; then
2257076b9443SCy Schubert		AC_MSG_RESULT([$i])
2258076b9443SCy Schubert		XLIBSW="-L$i -lX11"
2259076b9443SCy Schubert		x_libraries="$i"
2260076b9443SCy Schubert		break
2261076b9443SCy Schubert	    fi
2262076b9443SCy Schubert	done
2263076b9443SCy Schubert    else
2264076b9443SCy Schubert	if test "$x_libraries" = ""; then
2265076b9443SCy Schubert	    XLIBSW=-lX11
2266076b9443SCy Schubert	else
2267076b9443SCy Schubert	    XLIBSW="-L$x_libraries -lX11"
2268076b9443SCy Schubert	fi
2269076b9443SCy Schubert    fi
2270076b9443SCy Schubert    if test "$XLIBSW" = nope ; then
2271076b9443SCy Schubert	AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
2272076b9443SCy Schubert    fi
2273076b9443SCy Schubert    if test "$XLIBSW" = nope ; then
2274076b9443SCy Schubert	AC_MSG_RESULT([could not find any!  Using -lX11.])
2275076b9443SCy Schubert	XLIBSW=-lX11
2276076b9443SCy Schubert    fi
2277076b9443SCy Schubert    # TEA specific:
2278076b9443SCy Schubert    if test x"${XLIBSW}" != x ; then
2279076b9443SCy Schubert	PKG_LIBS="${PKG_LIBS} ${XLIBSW}"
2280076b9443SCy Schubert    fi
2281076b9443SCy Schubert])
2282076b9443SCy Schubert
2283076b9443SCy Schubert#--------------------------------------------------------------------
2284076b9443SCy Schubert# TEA_BLOCKING_STYLE
2285076b9443SCy Schubert#
2286076b9443SCy Schubert#	The statements below check for systems where POSIX-style
2287076b9443SCy Schubert#	non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
2288076b9443SCy Schubert#	On these systems (mostly older ones), use the old BSD-style
2289076b9443SCy Schubert#	FIONBIO approach instead.
2290076b9443SCy Schubert#
2291076b9443SCy Schubert# Arguments:
2292076b9443SCy Schubert#	none
2293076b9443SCy Schubert#
2294076b9443SCy Schubert# Results:
2295076b9443SCy Schubert#
2296076b9443SCy Schubert#	Defines some of the following vars:
2297076b9443SCy Schubert#		HAVE_SYS_IOCTL_H
2298076b9443SCy Schubert#		HAVE_SYS_FILIO_H
2299076b9443SCy Schubert#		USE_FIONBIO
2300076b9443SCy Schubert#		O_NONBLOCK
2301076b9443SCy Schubert#--------------------------------------------------------------------
2302076b9443SCy Schubert
2303076b9443SCy SchubertAC_DEFUN([TEA_BLOCKING_STYLE], [
2304076b9443SCy Schubert    AC_CHECK_HEADERS(sys/ioctl.h)
2305076b9443SCy Schubert    AC_CHECK_HEADERS(sys/filio.h)
2306076b9443SCy Schubert    TEA_CONFIG_SYSTEM
2307076b9443SCy Schubert    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
2308076b9443SCy Schubert    case $system in
2309076b9443SCy Schubert	OSF*)
2310076b9443SCy Schubert	    AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
2311076b9443SCy Schubert	    AC_MSG_RESULT([FIONBIO])
2312076b9443SCy Schubert	    ;;
2313076b9443SCy Schubert	*)
2314076b9443SCy Schubert	    AC_MSG_RESULT([O_NONBLOCK])
2315076b9443SCy Schubert	    ;;
2316076b9443SCy Schubert    esac
2317076b9443SCy Schubert])
2318076b9443SCy Schubert
2319076b9443SCy Schubert#--------------------------------------------------------------------
2320076b9443SCy Schubert# TEA_TIME_HANDLER
2321076b9443SCy Schubert#
2322076b9443SCy Schubert#	Checks how the system deals with time.h, what time structures
2323076b9443SCy Schubert#	are used on the system, and what fields the structures have.
2324076b9443SCy Schubert#
2325076b9443SCy Schubert# Arguments:
2326076b9443SCy Schubert#	none
2327076b9443SCy Schubert#
2328076b9443SCy Schubert# Results:
2329076b9443SCy Schubert#
2330076b9443SCy Schubert#	Defines some of the following vars:
2331076b9443SCy Schubert#		USE_DELTA_FOR_TZ
2332076b9443SCy Schubert#		HAVE_TM_GMTOFF
2333076b9443SCy Schubert#		HAVE_TM_TZADJ
2334076b9443SCy Schubert#		HAVE_TIMEZONE_VAR
2335*00787218SCy Schubert#
2336076b9443SCy Schubert#--------------------------------------------------------------------
2337076b9443SCy Schubert
2338076b9443SCy SchubertAC_DEFUN([TEA_TIME_HANDLER], [
2339076b9443SCy Schubert    AC_CHECK_HEADERS(sys/time.h)
2340076b9443SCy Schubert    AC_HEADER_TIME
2341076b9443SCy Schubert    AC_STRUCT_TIMEZONE
2342076b9443SCy Schubert
2343*00787218SCy Schubert    AC_CHECK_FUNCS(gmtime_r localtime_r mktime)
2344076b9443SCy Schubert
2345076b9443SCy Schubert    AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [
2346*00787218SCy Schubert	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm tm; (void)tm.tm_tzadj;]])],
2347*00787218SCy Schubert	    [tcl_cv_member_tm_tzadj=yes],
2348*00787218SCy Schubert	    [tcl_cv_member_tm_tzadj=no])])
2349076b9443SCy Schubert    if test $tcl_cv_member_tm_tzadj = yes ; then
2350076b9443SCy Schubert	AC_DEFINE(HAVE_TM_TZADJ, 1, [Should we use the tm_tzadj field of struct tm?])
2351076b9443SCy Schubert    fi
2352076b9443SCy Schubert
2353076b9443SCy Schubert    AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
2354*00787218SCy Schubert	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm tm; (void)tm.tm_gmtoff;]])],
2355*00787218SCy Schubert	    [tcl_cv_member_tm_gmtoff=yes],
2356*00787218SCy Schubert	    [tcl_cv_member_tm_gmtoff=no])])
2357076b9443SCy Schubert    if test $tcl_cv_member_tm_gmtoff = yes ; then
2358076b9443SCy Schubert	AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?])
2359076b9443SCy Schubert    fi
2360076b9443SCy Schubert
2361076b9443SCy Schubert    #
2362076b9443SCy Schubert    # Its important to include time.h in this check, as some systems
2363076b9443SCy Schubert    # (like convex) have timezone functions, etc.
2364076b9443SCy Schubert    #
2365076b9443SCy Schubert    AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [
2366*00787218SCy Schubert	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>
2367*00787218SCy Schubert#include <stdlib.h>]],
2368*00787218SCy Schubert	[[extern long timezone;
2369076b9443SCy Schubert	    timezone += 1;
2370*00787218SCy Schubert	    exit (0);]])],
2371*00787218SCy Schubert	    [tcl_cv_timezone_long=yes], [tcl_cv_timezone_long=no])])
2372076b9443SCy Schubert    if test $tcl_cv_timezone_long = yes ; then
2373076b9443SCy Schubert	AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
2374076b9443SCy Schubert    else
2375076b9443SCy Schubert	#
2376076b9443SCy Schubert	# On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
2377076b9443SCy Schubert	#
2378076b9443SCy Schubert	AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [
2379*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>
2380*00787218SCy Schubert#include <stdlib.h>]],
2381*00787218SCy Schubert	    [[extern time_t timezone;
2382076b9443SCy Schubert		timezone += 1;
2383*00787218SCy Schubert		exit (0);]])],
2384*00787218SCy Schubert		[tcl_cv_timezone_time=yes], [tcl_cv_timezone_time=no])])
2385076b9443SCy Schubert	if test $tcl_cv_timezone_time = yes ; then
2386076b9443SCy Schubert	    AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
2387076b9443SCy Schubert	fi
2388076b9443SCy Schubert    fi
2389076b9443SCy Schubert])
2390076b9443SCy Schubert
2391076b9443SCy Schubert#--------------------------------------------------------------------
2392076b9443SCy Schubert# TEA_BUGGY_STRTOD
2393076b9443SCy Schubert#
2394076b9443SCy Schubert#	Under Solaris 2.4, strtod returns the wrong value for the
2395076b9443SCy Schubert#	terminating character under some conditions.  Check for this
2396076b9443SCy Schubert#	and if the problem exists use a substitute procedure
2397076b9443SCy Schubert#	"fixstrtod" (provided by Tcl) that corrects the error.
2398076b9443SCy Schubert#	Also, on Compaq's Tru64 Unix 5.0,
2399076b9443SCy Schubert#	strtod(" ") returns 0.0 instead of a failure to convert.
2400076b9443SCy Schubert#
2401076b9443SCy Schubert# Arguments:
2402076b9443SCy Schubert#	none
2403076b9443SCy Schubert#
2404076b9443SCy Schubert# Results:
2405076b9443SCy Schubert#
2406076b9443SCy Schubert#	Might defines some of the following vars:
2407076b9443SCy Schubert#		strtod (=fixstrtod)
2408076b9443SCy Schubert#--------------------------------------------------------------------
2409076b9443SCy Schubert
2410076b9443SCy SchubertAC_DEFUN([TEA_BUGGY_STRTOD], [
2411076b9443SCy Schubert    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
2412076b9443SCy Schubert    if test "$tcl_strtod" = 1; then
2413076b9443SCy Schubert	AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[
2414*00787218SCy Schubert	    AC_RUN_IFELSE([AC_LANG_SOURCE([[
2415*00787218SCy Schubert		#include <stdlib.h>
2416076b9443SCy Schubert		extern double strtod();
2417076b9443SCy Schubert		int main() {
2418076b9443SCy Schubert		    char *infString="Inf", *nanString="NaN", *spaceString=" ";
2419076b9443SCy Schubert		    char *term;
2420076b9443SCy Schubert		    double value;
2421076b9443SCy Schubert		    value = strtod(infString, &term);
2422076b9443SCy Schubert		    if ((term != infString) && (term[-1] == 0)) {
2423076b9443SCy Schubert			exit(1);
2424076b9443SCy Schubert		    }
2425076b9443SCy Schubert		    value = strtod(nanString, &term);
2426076b9443SCy Schubert		    if ((term != nanString) && (term[-1] == 0)) {
2427076b9443SCy Schubert			exit(1);
2428076b9443SCy Schubert		    }
2429076b9443SCy Schubert		    value = strtod(spaceString, &term);
2430076b9443SCy Schubert		    if (term == (spaceString+1)) {
2431076b9443SCy Schubert			exit(1);
2432076b9443SCy Schubert		    }
2433076b9443SCy Schubert		    exit(0);
2434*00787218SCy Schubert		}]])], [tcl_cv_strtod_buggy=ok], [tcl_cv_strtod_buggy=buggy],
2435*00787218SCy Schubert		    [tcl_cv_strtod_buggy=buggy])])
2436076b9443SCy Schubert	if test "$tcl_cv_strtod_buggy" = buggy; then
2437076b9443SCy Schubert	    AC_LIBOBJ([fixstrtod])
2438076b9443SCy Schubert	    USE_COMPAT=1
2439076b9443SCy Schubert	    AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?])
2440076b9443SCy Schubert	fi
2441076b9443SCy Schubert    fi
2442076b9443SCy Schubert])
2443076b9443SCy Schubert
2444076b9443SCy Schubert#--------------------------------------------------------------------
2445076b9443SCy Schubert# TEA_TCL_LINK_LIBS
2446076b9443SCy Schubert#
2447076b9443SCy Schubert#	Search for the libraries needed to link the Tcl shell.
2448*00787218SCy Schubert#	Things like the math library (-lm), socket stuff (-lsocket vs.
2449*00787218SCy Schubert#	-lnsl), zlib (-lz) and libtommath (-ltommath) are dealt with here.
2450076b9443SCy Schubert#
2451076b9443SCy Schubert# Arguments:
2452*00787218SCy Schubert#	None.
2453076b9443SCy Schubert#
2454076b9443SCy Schubert# Results:
2455076b9443SCy Schubert#
2456076b9443SCy Schubert#	Might append to the following vars:
2457076b9443SCy Schubert#		LIBS
2458*00787218SCy Schubert#		MATH_LIBS
2459076b9443SCy Schubert#
2460076b9443SCy Schubert#	Might define the following vars:
2461076b9443SCy Schubert#		HAVE_NET_ERRNO_H
2462*00787218SCy Schubert#
2463076b9443SCy Schubert#--------------------------------------------------------------------
2464076b9443SCy Schubert
2465076b9443SCy SchubertAC_DEFUN([TEA_TCL_LINK_LIBS], [
2466076b9443SCy Schubert    #--------------------------------------------------------------------
2467076b9443SCy Schubert    # On a few very rare systems, all of the libm.a stuff is
2468076b9443SCy Schubert    # already in libc.a.  Set compiler flags accordingly.
2469076b9443SCy Schubert    #--------------------------------------------------------------------
2470076b9443SCy Schubert
2471076b9443SCy Schubert    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
2472076b9443SCy Schubert
2473076b9443SCy Schubert    #--------------------------------------------------------------------
2474076b9443SCy Schubert    # Interactive UNIX requires -linet instead of -lsocket, plus it
2475076b9443SCy Schubert    # needs net/errno.h to define the socket-related error codes.
2476076b9443SCy Schubert    #--------------------------------------------------------------------
2477076b9443SCy Schubert
2478076b9443SCy Schubert    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
2479076b9443SCy Schubert    AC_CHECK_HEADER(net/errno.h, [
2480076b9443SCy Schubert	AC_DEFINE(HAVE_NET_ERRNO_H, 1, [Do we have <net/errno.h>?])])
2481076b9443SCy Schubert
2482076b9443SCy Schubert    #--------------------------------------------------------------------
2483076b9443SCy Schubert    #	Check for the existence of the -lsocket and -lnsl libraries.
2484076b9443SCy Schubert    #	The order here is important, so that they end up in the right
2485076b9443SCy Schubert    #	order in the command line generated by make.  Here are some
2486076b9443SCy Schubert    #	special considerations:
2487076b9443SCy Schubert    #	1. Use "connect" and "accept" to check for -lsocket, and
2488076b9443SCy Schubert    #	   "gethostbyname" to check for -lnsl.
2489076b9443SCy Schubert    #	2. Use each function name only once:  can't redo a check because
2490076b9443SCy Schubert    #	   autoconf caches the results of the last check and won't redo it.
2491076b9443SCy Schubert    #	3. Use -lnsl and -lsocket only if they supply procedures that
2492076b9443SCy Schubert    #	   aren't already present in the normal libraries.  This is because
2493076b9443SCy Schubert    #	   IRIX 5.2 has libraries, but they aren't needed and they're
2494076b9443SCy Schubert    #	   bogus:  they goof up name resolution if used.
2495076b9443SCy Schubert    #	4. On some SVR4 systems, can't use -lsocket without -lnsl too.
2496076b9443SCy Schubert    #	   To get around this problem, check for both libraries together
2497076b9443SCy Schubert    #	   if -lsocket doesn't work by itself.
2498076b9443SCy Schubert    #--------------------------------------------------------------------
2499076b9443SCy Schubert
2500076b9443SCy Schubert    tcl_checkBoth=0
2501076b9443SCy Schubert    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
2502076b9443SCy Schubert    if test "$tcl_checkSocket" = 1; then
2503076b9443SCy Schubert	AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
2504076b9443SCy Schubert	    LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
2505076b9443SCy Schubert    fi
2506076b9443SCy Schubert    if test "$tcl_checkBoth" = 1; then
2507076b9443SCy Schubert	tk_oldLibs=$LIBS
2508076b9443SCy Schubert	LIBS="$LIBS -lsocket -lnsl"
2509076b9443SCy Schubert	AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
2510076b9443SCy Schubert    fi
2511076b9443SCy Schubert    AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
2512076b9443SCy Schubert	    [LIBS="$LIBS -lnsl"])])
2513*00787218SCy Schubert    AC_CHECK_FUNC(mp_log_u32, , [AC_CHECK_LIB(tommath, mp_log_u32,
2514*00787218SCy Schubert	    [LIBS="$LIBS -ltommath"])])
2515*00787218SCy Schubert    AC_CHECK_FUNC(deflateSetHeader, , [AC_CHECK_LIB(z, deflateSetHeader,
2516*00787218SCy Schubert	    [LIBS="$LIBS -lz"])])
2517076b9443SCy Schubert])
2518076b9443SCy Schubert
2519076b9443SCy Schubert#--------------------------------------------------------------------
2520076b9443SCy Schubert# TEA_TCL_EARLY_FLAGS
2521076b9443SCy Schubert#
2522076b9443SCy Schubert#	Check for what flags are needed to be passed so the correct OS
2523076b9443SCy Schubert#	features are available.
2524076b9443SCy Schubert#
2525076b9443SCy Schubert# Arguments:
2526076b9443SCy Schubert#	None
2527076b9443SCy Schubert#
2528076b9443SCy Schubert# Results:
2529076b9443SCy Schubert#
2530076b9443SCy Schubert#	Might define the following vars:
2531076b9443SCy Schubert#		_ISOC99_SOURCE
2532076b9443SCy Schubert#		_LARGEFILE64_SOURCE
2533076b9443SCy Schubert#		_LARGEFILE_SOURCE64
2534*00787218SCy Schubert#
2535076b9443SCy Schubert#--------------------------------------------------------------------
2536076b9443SCy Schubert
2537076b9443SCy SchubertAC_DEFUN([TEA_TCL_EARLY_FLAG],[
2538076b9443SCy Schubert    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
2539*00787218SCy Schubert	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])],
2540*00787218SCy Schubert	    [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[[#define ]$1[ 1
2541*00787218SCy Schubert]$2]], [[$3]])],
2542076b9443SCy Schubert	[tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
2543*00787218SCy Schubert	[tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)]))
2544076b9443SCy Schubert    if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
2545076b9443SCy Schubert	AC_DEFINE($1, 1, [Add the ]$1[ flag when building])
2546076b9443SCy Schubert	tcl_flags="$tcl_flags $1"
2547076b9443SCy Schubert    fi
2548076b9443SCy Schubert])
2549076b9443SCy Schubert
2550076b9443SCy SchubertAC_DEFUN([TEA_TCL_EARLY_FLAGS],[
2551076b9443SCy Schubert    AC_MSG_CHECKING([for required early compiler flags])
2552076b9443SCy Schubert    tcl_flags=""
2553076b9443SCy Schubert    TEA_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
2554076b9443SCy Schubert	[char *p = (char *)strtoll; char *q = (char *)strtoull;])
2555076b9443SCy Schubert    TEA_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
2556076b9443SCy Schubert	[struct stat64 buf; int i = stat64("/", &buf);])
2557076b9443SCy Schubert    TEA_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
2558076b9443SCy Schubert	[char *p = (char *)open64;])
2559076b9443SCy Schubert    if test "x${tcl_flags}" = "x" ; then
2560076b9443SCy Schubert	AC_MSG_RESULT([none])
2561076b9443SCy Schubert    else
2562076b9443SCy Schubert	AC_MSG_RESULT([${tcl_flags}])
2563076b9443SCy Schubert    fi
2564076b9443SCy Schubert])
2565076b9443SCy Schubert
2566076b9443SCy Schubert#--------------------------------------------------------------------
2567076b9443SCy Schubert# TEA_TCL_64BIT_FLAGS
2568076b9443SCy Schubert#
2569076b9443SCy Schubert#	Check for what is defined in the way of 64-bit features.
2570076b9443SCy Schubert#
2571076b9443SCy Schubert# Arguments:
2572076b9443SCy Schubert#	None
2573076b9443SCy Schubert#
2574076b9443SCy Schubert# Results:
2575076b9443SCy Schubert#
2576076b9443SCy Schubert#	Might define the following vars:
2577076b9443SCy Schubert#		TCL_WIDE_INT_IS_LONG
2578076b9443SCy Schubert#		TCL_WIDE_INT_TYPE
2579*00787218SCy Schubert#		HAVE_STRUCT_DIRENT64, HAVE_DIR64
2580076b9443SCy Schubert#		HAVE_STRUCT_STAT64
2581076b9443SCy Schubert#		HAVE_TYPE_OFF64_T
2582*00787218SCy Schubert#
2583076b9443SCy Schubert#--------------------------------------------------------------------
2584076b9443SCy Schubert
2585076b9443SCy SchubertAC_DEFUN([TEA_TCL_64BIT_FLAGS], [
2586076b9443SCy Schubert    AC_MSG_CHECKING([for 64-bit integer type])
2587076b9443SCy Schubert    AC_CACHE_VAL(tcl_cv_type_64bit,[
2588076b9443SCy Schubert	tcl_cv_type_64bit=none
2589076b9443SCy Schubert	# See if the compiler knows natively about __int64
2590*00787218SCy Schubert	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[__int64 value = (__int64) 0;]])],
2591*00787218SCy Schubert	    [tcl_type_64bit=__int64],[tcl_type_64bit="long long"])
2592*00787218SCy Schubert	# See if we could use long anyway  Note that we substitute in the
2593076b9443SCy Schubert	# type that is our current guess for a 64-bit type inside this check
2594076b9443SCy Schubert	# program, so it should be modified only carefully...
2595*00787218SCy Schubert        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[switch (0) {
2596*00787218SCy Schubert            case 1: case (sizeof(${tcl_type_64bit})==sizeof(long)): ;
2597*00787218SCy Schubert        }]])],[tcl_cv_type_64bit=${tcl_type_64bit}],[])])
2598076b9443SCy Schubert    if test "${tcl_cv_type_64bit}" = none ; then
2599*00787218SCy Schubert	AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Do 'long' and 'long long' have the same size (64-bit)?])
2600*00787218SCy Schubert	AC_MSG_RESULT([yes])
2601076b9443SCy Schubert    elif test "${tcl_cv_type_64bit}" = "__int64" \
2602076b9443SCy Schubert		-a "${TEA_PLATFORM}" = "windows" ; then
2603076b9443SCy Schubert	# TEA specific: We actually want to use the default tcl.h checks in
2604076b9443SCy Schubert	# this case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER*
2605076b9443SCy Schubert	AC_MSG_RESULT([using Tcl header defaults])
2606076b9443SCy Schubert    else
2607076b9443SCy Schubert	AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit},
2608076b9443SCy Schubert	    [What type should be used to define wide integers?])
2609076b9443SCy Schubert	AC_MSG_RESULT([${tcl_cv_type_64bit}])
2610076b9443SCy Schubert
2611076b9443SCy Schubert	# Now check for auxiliary declarations
2612076b9443SCy Schubert	AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
2613*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
2614*00787218SCy Schubert#include <dirent.h>]], [[struct dirent64 p;]])],
2615*00787218SCy Schubert		[tcl_cv_struct_dirent64=yes],[tcl_cv_struct_dirent64=no])])
2616076b9443SCy Schubert	if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
2617076b9443SCy Schubert	    AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?])
2618076b9443SCy Schubert	fi
2619076b9443SCy Schubert
2620*00787218SCy Schubert	AC_CACHE_CHECK([for DIR64], tcl_cv_DIR64,[
2621*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
2622*00787218SCy Schubert#include <dirent.h>]], [[struct dirent64 *p; DIR64 d = opendir64(".");
2623*00787218SCy Schubert            p = readdir64(d); rewinddir64(d); closedir64(d);]])],
2624*00787218SCy Schubert		[tcl_cv_DIR64=yes], [tcl_cv_DIR64=no])])
2625*00787218SCy Schubert	if test "x${tcl_cv_DIR64}" = "xyes" ; then
2626*00787218SCy Schubert	    AC_DEFINE(HAVE_DIR64, 1, [Is 'DIR64' in <sys/types.h>?])
2627*00787218SCy Schubert	fi
2628*00787218SCy Schubert
2629076b9443SCy Schubert	AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[
2630*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[struct stat64 p;
2631*00787218SCy Schubert]])],
2632*00787218SCy Schubert		[tcl_cv_struct_stat64=yes], [tcl_cv_struct_stat64=no])])
2633076b9443SCy Schubert	if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
2634076b9443SCy Schubert	    AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in <sys/stat.h>?])
2635076b9443SCy Schubert	fi
2636076b9443SCy Schubert
2637076b9443SCy Schubert	AC_CHECK_FUNCS(open64 lseek64)
2638076b9443SCy Schubert	AC_MSG_CHECKING([for off64_t])
2639076b9443SCy Schubert	AC_CACHE_VAL(tcl_cv_type_off64_t,[
2640*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]], [[off64_t offset;
2641*00787218SCy Schubert]])],
2642*00787218SCy Schubert		[tcl_cv_type_off64_t=yes], [tcl_cv_type_off64_t=no])])
2643076b9443SCy Schubert	dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the
2644076b9443SCy Schubert	dnl functions lseek64 and open64 are defined.
2645076b9443SCy Schubert	if test "x${tcl_cv_type_off64_t}" = "xyes" && \
2646076b9443SCy Schubert	        test "x${ac_cv_func_lseek64}" = "xyes" && \
2647076b9443SCy Schubert	        test "x${ac_cv_func_open64}" = "xyes" ; then
2648076b9443SCy Schubert	    AC_DEFINE(HAVE_TYPE_OFF64_T, 1, [Is off64_t in <sys/types.h>?])
2649076b9443SCy Schubert	    AC_MSG_RESULT([yes])
2650076b9443SCy Schubert	else
2651076b9443SCy Schubert	    AC_MSG_RESULT([no])
2652076b9443SCy Schubert	fi
2653076b9443SCy Schubert    fi
2654076b9443SCy Schubert])
2655076b9443SCy Schubert
2656076b9443SCy Schubert##
2657076b9443SCy Schubert## Here ends the standard Tcl configuration bits and starts the
2658076b9443SCy Schubert## TEA specific functions
2659076b9443SCy Schubert##
2660076b9443SCy Schubert
2661076b9443SCy Schubert#------------------------------------------------------------------------
2662076b9443SCy Schubert# TEA_INIT --
2663076b9443SCy Schubert#
2664076b9443SCy Schubert#	Init various Tcl Extension Architecture (TEA) variables.
2665076b9443SCy Schubert#	This should be the first called TEA_* macro.
2666076b9443SCy Schubert#
2667076b9443SCy Schubert# Arguments:
2668076b9443SCy Schubert#	none
2669076b9443SCy Schubert#
2670076b9443SCy Schubert# Results:
2671076b9443SCy Schubert#
2672076b9443SCy Schubert#	Defines and substs the following vars:
2673076b9443SCy Schubert#		CYGPATH
2674076b9443SCy Schubert#		EXEEXT
2675076b9443SCy Schubert#	Defines only:
2676076b9443SCy Schubert#		TEA_VERSION
2677076b9443SCy Schubert#		TEA_INITED
2678076b9443SCy Schubert#		TEA_PLATFORM (windows or unix)
2679076b9443SCy Schubert#
2680076b9443SCy Schubert# "cygpath" is used on windows to generate native path names for include
2681076b9443SCy Schubert# files. These variables should only be used with the compiler and linker
2682076b9443SCy Schubert# since they generate native path names.
2683076b9443SCy Schubert#
2684076b9443SCy Schubert# EXEEXT
2685076b9443SCy Schubert#	Select the executable extension based on the host type.  This
2686076b9443SCy Schubert#	is a lightweight replacement for AC_EXEEXT that doesn't require
2687076b9443SCy Schubert#	a compiler.
2688076b9443SCy Schubert#------------------------------------------------------------------------
2689076b9443SCy Schubert
2690076b9443SCy SchubertAC_DEFUN([TEA_INIT], [
2691*00787218SCy Schubert    TEA_VERSION="3.13"
2692076b9443SCy Schubert
2693*00787218SCy Schubert    AC_MSG_CHECKING([TEA configuration])
2694076b9443SCy Schubert    if test x"${PACKAGE_NAME}" = x ; then
2695076b9443SCy Schubert	AC_MSG_ERROR([
2696*00787218SCy SchubertThe PACKAGE_NAME variable must be defined by your TEA configure.ac])
2697076b9443SCy Schubert    fi
2698076b9443SCy Schubert    AC_MSG_RESULT([ok (TEA ${TEA_VERSION})])
2699076b9443SCy Schubert
2700076b9443SCy Schubert    # If the user did not set CFLAGS, set it now to keep macros
2701076b9443SCy Schubert    # like AC_PROG_CC and AC_TRY_COMPILE from adding "-g -O2".
2702076b9443SCy Schubert    if test "${CFLAGS+set}" != "set" ; then
2703076b9443SCy Schubert	CFLAGS=""
2704076b9443SCy Schubert    fi
2705076b9443SCy Schubert
2706076b9443SCy Schubert    case "`uname -s`" in
2707*00787218SCy Schubert	*win32*|*WIN32*|*MINGW32_*|*MINGW64_*|*MSYS_*)
2708*00787218SCy Schubert	    AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo)
2709076b9443SCy Schubert	    EXEEXT=".exe"
2710076b9443SCy Schubert	    TEA_PLATFORM="windows"
2711076b9443SCy Schubert	    ;;
2712076b9443SCy Schubert	*CYGWIN_*)
2713076b9443SCy Schubert	    EXEEXT=".exe"
2714*00787218SCy Schubert	    # CYGPATH and TEA_PLATFORM are determined later in LOAD_TCLCONFIG
2715076b9443SCy Schubert	    ;;
2716076b9443SCy Schubert	*)
2717076b9443SCy Schubert	    CYGPATH=echo
2718076b9443SCy Schubert	    # Maybe we are cross-compiling....
2719076b9443SCy Schubert	    case ${host_alias} in
2720076b9443SCy Schubert		*mingw32*)
2721076b9443SCy Schubert		EXEEXT=".exe"
2722076b9443SCy Schubert		TEA_PLATFORM="windows"
2723076b9443SCy Schubert		;;
2724076b9443SCy Schubert	    *)
2725076b9443SCy Schubert		EXEEXT=""
2726076b9443SCy Schubert		TEA_PLATFORM="unix"
2727076b9443SCy Schubert		;;
2728076b9443SCy Schubert	    esac
2729076b9443SCy Schubert	    ;;
2730076b9443SCy Schubert    esac
2731076b9443SCy Schubert
2732076b9443SCy Schubert    # Check if exec_prefix is set. If not use fall back to prefix.
2733076b9443SCy Schubert    # Note when adjusted, so that TEA_PREFIX can correct for this.
2734076b9443SCy Schubert    # This is needed for recursive configures, since autoconf propagates
2735076b9443SCy Schubert    # $prefix, but not $exec_prefix (doh!).
2736076b9443SCy Schubert    if test x$exec_prefix = xNONE ; then
2737076b9443SCy Schubert	exec_prefix_default=yes
2738076b9443SCy Schubert	exec_prefix=$prefix
2739076b9443SCy Schubert    fi
2740076b9443SCy Schubert
2741076b9443SCy Schubert    AC_MSG_NOTICE([configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}])
2742076b9443SCy Schubert
2743076b9443SCy Schubert    AC_SUBST(EXEEXT)
2744076b9443SCy Schubert    AC_SUBST(CYGPATH)
2745076b9443SCy Schubert
2746076b9443SCy Schubert    # This package name must be replaced statically for AC_SUBST to work
2747076b9443SCy Schubert    AC_SUBST(PKG_LIB_FILE)
2748*00787218SCy Schubert    AC_SUBST(PKG_LIB_FILE8)
2749*00787218SCy Schubert    AC_SUBST(PKG_LIB_FILE9)
2750076b9443SCy Schubert    # Substitute STUB_LIB_FILE in case package creates a stub library too.
2751076b9443SCy Schubert    AC_SUBST(PKG_STUB_LIB_FILE)
2752076b9443SCy Schubert
2753076b9443SCy Schubert    # We AC_SUBST these here to ensure they are subst'ed,
2754076b9443SCy Schubert    # in case the user doesn't call TEA_ADD_...
2755076b9443SCy Schubert    AC_SUBST(PKG_STUB_SOURCES)
2756076b9443SCy Schubert    AC_SUBST(PKG_STUB_OBJECTS)
2757076b9443SCy Schubert    AC_SUBST(PKG_TCL_SOURCES)
2758076b9443SCy Schubert    AC_SUBST(PKG_HEADERS)
2759076b9443SCy Schubert    AC_SUBST(PKG_INCLUDES)
2760076b9443SCy Schubert    AC_SUBST(PKG_LIBS)
2761076b9443SCy Schubert    AC_SUBST(PKG_CFLAGS)
2762*00787218SCy Schubert
2763*00787218SCy Schubert    # Configure the installer.
2764*00787218SCy Schubert    TEA_INSTALLER
2765076b9443SCy Schubert])
2766076b9443SCy Schubert
2767076b9443SCy Schubert#------------------------------------------------------------------------
2768076b9443SCy Schubert# TEA_ADD_SOURCES --
2769076b9443SCy Schubert#
2770076b9443SCy Schubert#	Specify one or more source files.  Users should check for
2771076b9443SCy Schubert#	the right platform before adding to their list.
2772076b9443SCy Schubert#	It is not important to specify the directory, as long as it is
2773076b9443SCy Schubert#	in the generic, win or unix subdirectory of $(srcdir).
2774076b9443SCy Schubert#
2775076b9443SCy Schubert# Arguments:
2776076b9443SCy Schubert#	one or more file names
2777076b9443SCy Schubert#
2778076b9443SCy Schubert# Results:
2779076b9443SCy Schubert#
2780076b9443SCy Schubert#	Defines and substs the following vars:
2781076b9443SCy Schubert#		PKG_SOURCES
2782076b9443SCy Schubert#		PKG_OBJECTS
2783076b9443SCy Schubert#------------------------------------------------------------------------
2784076b9443SCy SchubertAC_DEFUN([TEA_ADD_SOURCES], [
2785076b9443SCy Schubert    vars="$@"
2786076b9443SCy Schubert    for i in $vars; do
2787076b9443SCy Schubert	case $i in
2788076b9443SCy Schubert	    [\$]*)
2789076b9443SCy Schubert		# allow $-var names
2790076b9443SCy Schubert		PKG_SOURCES="$PKG_SOURCES $i"
2791076b9443SCy Schubert		PKG_OBJECTS="$PKG_OBJECTS $i"
2792076b9443SCy Schubert		;;
2793076b9443SCy Schubert	    *)
2794076b9443SCy Schubert		# check for existence - allows for generic/win/unix VPATH
2795076b9443SCy Schubert		# To add more dirs here (like 'src'), you have to update VPATH
2796076b9443SCy Schubert		# in Makefile.in as well
2797076b9443SCy Schubert		if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
2798076b9443SCy Schubert		    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
2799076b9443SCy Schubert		    -a ! -f "${srcdir}/macosx/$i" \
2800076b9443SCy Schubert		    ; then
2801076b9443SCy Schubert		    AC_MSG_ERROR([could not find source file '$i'])
2802076b9443SCy Schubert		fi
2803076b9443SCy Schubert		PKG_SOURCES="$PKG_SOURCES $i"
2804076b9443SCy Schubert		# this assumes it is in a VPATH dir
2805076b9443SCy Schubert		i=`basename $i`
2806076b9443SCy Schubert		# handle user calling this before or after TEA_SETUP_COMPILER
2807076b9443SCy Schubert		if test x"${OBJEXT}" != x ; then
2808076b9443SCy Schubert		    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
2809076b9443SCy Schubert		else
2810076b9443SCy Schubert		    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
2811076b9443SCy Schubert		fi
2812076b9443SCy Schubert		PKG_OBJECTS="$PKG_OBJECTS $j"
2813076b9443SCy Schubert		;;
2814076b9443SCy Schubert	esac
2815076b9443SCy Schubert    done
2816076b9443SCy Schubert    AC_SUBST(PKG_SOURCES)
2817076b9443SCy Schubert    AC_SUBST(PKG_OBJECTS)
2818076b9443SCy Schubert])
2819076b9443SCy Schubert
2820076b9443SCy Schubert#------------------------------------------------------------------------
2821076b9443SCy Schubert# TEA_ADD_STUB_SOURCES --
2822076b9443SCy Schubert#
2823076b9443SCy Schubert#	Specify one or more source files.  Users should check for
2824076b9443SCy Schubert#	the right platform before adding to their list.
2825076b9443SCy Schubert#	It is not important to specify the directory, as long as it is
2826076b9443SCy Schubert#	in the generic, win or unix subdirectory of $(srcdir).
2827076b9443SCy Schubert#
2828076b9443SCy Schubert# Arguments:
2829076b9443SCy Schubert#	one or more file names
2830076b9443SCy Schubert#
2831076b9443SCy Schubert# Results:
2832076b9443SCy Schubert#
2833076b9443SCy Schubert#	Defines and substs the following vars:
2834076b9443SCy Schubert#		PKG_STUB_SOURCES
2835076b9443SCy Schubert#		PKG_STUB_OBJECTS
2836076b9443SCy Schubert#------------------------------------------------------------------------
2837076b9443SCy SchubertAC_DEFUN([TEA_ADD_STUB_SOURCES], [
2838076b9443SCy Schubert    vars="$@"
2839076b9443SCy Schubert    for i in $vars; do
2840076b9443SCy Schubert	# check for existence - allows for generic/win/unix VPATH
2841076b9443SCy Schubert	if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
2842076b9443SCy Schubert	    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
2843076b9443SCy Schubert	    -a ! -f "${srcdir}/macosx/$i" \
2844076b9443SCy Schubert	    ; then
2845076b9443SCy Schubert	    AC_MSG_ERROR([could not find stub source file '$i'])
2846076b9443SCy Schubert	fi
2847076b9443SCy Schubert	PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i"
2848076b9443SCy Schubert	# this assumes it is in a VPATH dir
2849076b9443SCy Schubert	i=`basename $i`
2850076b9443SCy Schubert	# handle user calling this before or after TEA_SETUP_COMPILER
2851076b9443SCy Schubert	if test x"${OBJEXT}" != x ; then
2852076b9443SCy Schubert	    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
2853076b9443SCy Schubert	else
2854076b9443SCy Schubert	    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
2855076b9443SCy Schubert	fi
2856076b9443SCy Schubert	PKG_STUB_OBJECTS="$PKG_STUB_OBJECTS $j"
2857076b9443SCy Schubert    done
2858076b9443SCy Schubert    AC_SUBST(PKG_STUB_SOURCES)
2859076b9443SCy Schubert    AC_SUBST(PKG_STUB_OBJECTS)
2860076b9443SCy Schubert])
2861076b9443SCy Schubert
2862076b9443SCy Schubert#------------------------------------------------------------------------
2863076b9443SCy Schubert# TEA_ADD_TCL_SOURCES --
2864076b9443SCy Schubert#
2865076b9443SCy Schubert#	Specify one or more Tcl source files.  These should be platform
2866076b9443SCy Schubert#	independent runtime files.
2867076b9443SCy Schubert#
2868076b9443SCy Schubert# Arguments:
2869076b9443SCy Schubert#	one or more file names
2870076b9443SCy Schubert#
2871076b9443SCy Schubert# Results:
2872076b9443SCy Schubert#
2873076b9443SCy Schubert#	Defines and substs the following vars:
2874076b9443SCy Schubert#		PKG_TCL_SOURCES
2875076b9443SCy Schubert#------------------------------------------------------------------------
2876076b9443SCy SchubertAC_DEFUN([TEA_ADD_TCL_SOURCES], [
2877076b9443SCy Schubert    vars="$@"
2878076b9443SCy Schubert    for i in $vars; do
2879076b9443SCy Schubert	# check for existence, be strict because it is installed
2880076b9443SCy Schubert	if test ! -f "${srcdir}/$i" ; then
2881076b9443SCy Schubert	    AC_MSG_ERROR([could not find tcl source file '${srcdir}/$i'])
2882076b9443SCy Schubert	fi
2883076b9443SCy Schubert	PKG_TCL_SOURCES="$PKG_TCL_SOURCES $i"
2884076b9443SCy Schubert    done
2885076b9443SCy Schubert    AC_SUBST(PKG_TCL_SOURCES)
2886076b9443SCy Schubert])
2887076b9443SCy Schubert
2888076b9443SCy Schubert#------------------------------------------------------------------------
2889076b9443SCy Schubert# TEA_ADD_HEADERS --
2890076b9443SCy Schubert#
2891076b9443SCy Schubert#	Specify one or more source headers.  Users should check for
2892076b9443SCy Schubert#	the right platform before adding to their list.
2893076b9443SCy Schubert#
2894076b9443SCy Schubert# Arguments:
2895076b9443SCy Schubert#	one or more file names
2896076b9443SCy Schubert#
2897076b9443SCy Schubert# Results:
2898076b9443SCy Schubert#
2899076b9443SCy Schubert#	Defines and substs the following vars:
2900076b9443SCy Schubert#		PKG_HEADERS
2901076b9443SCy Schubert#------------------------------------------------------------------------
2902076b9443SCy SchubertAC_DEFUN([TEA_ADD_HEADERS], [
2903076b9443SCy Schubert    vars="$@"
2904076b9443SCy Schubert    for i in $vars; do
2905076b9443SCy Schubert	# check for existence, be strict because it is installed
2906076b9443SCy Schubert	if test ! -f "${srcdir}/$i" ; then
2907076b9443SCy Schubert	    AC_MSG_ERROR([could not find header file '${srcdir}/$i'])
2908076b9443SCy Schubert	fi
2909076b9443SCy Schubert	PKG_HEADERS="$PKG_HEADERS $i"
2910076b9443SCy Schubert    done
2911076b9443SCy Schubert    AC_SUBST(PKG_HEADERS)
2912076b9443SCy Schubert])
2913076b9443SCy Schubert
2914076b9443SCy Schubert#------------------------------------------------------------------------
2915076b9443SCy Schubert# TEA_ADD_INCLUDES --
2916076b9443SCy Schubert#
2917076b9443SCy Schubert#	Specify one or more include dirs.  Users should check for
2918076b9443SCy Schubert#	the right platform before adding to their list.
2919076b9443SCy Schubert#
2920076b9443SCy Schubert# Arguments:
2921076b9443SCy Schubert#	one or more file names
2922076b9443SCy Schubert#
2923076b9443SCy Schubert# Results:
2924076b9443SCy Schubert#
2925076b9443SCy Schubert#	Defines and substs the following vars:
2926076b9443SCy Schubert#		PKG_INCLUDES
2927076b9443SCy Schubert#------------------------------------------------------------------------
2928076b9443SCy SchubertAC_DEFUN([TEA_ADD_INCLUDES], [
2929076b9443SCy Schubert    vars="$@"
2930076b9443SCy Schubert    for i in $vars; do
2931076b9443SCy Schubert	PKG_INCLUDES="$PKG_INCLUDES $i"
2932076b9443SCy Schubert    done
2933076b9443SCy Schubert    AC_SUBST(PKG_INCLUDES)
2934076b9443SCy Schubert])
2935076b9443SCy Schubert
2936076b9443SCy Schubert#------------------------------------------------------------------------
2937076b9443SCy Schubert# TEA_ADD_LIBS --
2938076b9443SCy Schubert#
2939076b9443SCy Schubert#	Specify one or more libraries.  Users should check for
2940076b9443SCy Schubert#	the right platform before adding to their list.  For Windows,
2941076b9443SCy Schubert#	libraries provided in "foo.lib" format will be converted to
2942076b9443SCy Schubert#	"-lfoo" when using GCC (mingw).
2943076b9443SCy Schubert#
2944076b9443SCy Schubert# Arguments:
2945076b9443SCy Schubert#	one or more file names
2946076b9443SCy Schubert#
2947076b9443SCy Schubert# Results:
2948076b9443SCy Schubert#
2949076b9443SCy Schubert#	Defines and substs the following vars:
2950076b9443SCy Schubert#		PKG_LIBS
2951076b9443SCy Schubert#------------------------------------------------------------------------
2952076b9443SCy SchubertAC_DEFUN([TEA_ADD_LIBS], [
2953076b9443SCy Schubert    vars="$@"
2954076b9443SCy Schubert    for i in $vars; do
2955076b9443SCy Schubert	if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
2956076b9443SCy Schubert	    # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
2957*00787218SCy Schubert	    i=`echo "$i" | sed -e 's/^\([[^-]].*\)\.[[lL]][[iI]][[bB]][$]/-l\1/'`
2958076b9443SCy Schubert	fi
2959076b9443SCy Schubert	PKG_LIBS="$PKG_LIBS $i"
2960076b9443SCy Schubert    done
2961076b9443SCy Schubert    AC_SUBST(PKG_LIBS)
2962076b9443SCy Schubert])
2963076b9443SCy Schubert
2964076b9443SCy Schubert#------------------------------------------------------------------------
2965076b9443SCy Schubert# TEA_ADD_CFLAGS --
2966076b9443SCy Schubert#
2967076b9443SCy Schubert#	Specify one or more CFLAGS.  Users should check for
2968076b9443SCy Schubert#	the right platform before adding to their list.
2969076b9443SCy Schubert#
2970076b9443SCy Schubert# Arguments:
2971076b9443SCy Schubert#	one or more file names
2972076b9443SCy Schubert#
2973076b9443SCy Schubert# Results:
2974076b9443SCy Schubert#
2975076b9443SCy Schubert#	Defines and substs the following vars:
2976076b9443SCy Schubert#		PKG_CFLAGS
2977076b9443SCy Schubert#------------------------------------------------------------------------
2978076b9443SCy SchubertAC_DEFUN([TEA_ADD_CFLAGS], [
2979076b9443SCy Schubert    PKG_CFLAGS="$PKG_CFLAGS $@"
2980076b9443SCy Schubert    AC_SUBST(PKG_CFLAGS)
2981076b9443SCy Schubert])
2982076b9443SCy Schubert
2983076b9443SCy Schubert#------------------------------------------------------------------------
2984076b9443SCy Schubert# TEA_ADD_CLEANFILES --
2985076b9443SCy Schubert#
2986076b9443SCy Schubert#	Specify one or more CLEANFILES.
2987076b9443SCy Schubert#
2988076b9443SCy Schubert# Arguments:
2989076b9443SCy Schubert#	one or more file names to clean target
2990076b9443SCy Schubert#
2991076b9443SCy Schubert# Results:
2992076b9443SCy Schubert#
2993076b9443SCy Schubert#	Appends to CLEANFILES, already defined for subst in LOAD_TCLCONFIG
2994076b9443SCy Schubert#------------------------------------------------------------------------
2995076b9443SCy SchubertAC_DEFUN([TEA_ADD_CLEANFILES], [
2996076b9443SCy Schubert    CLEANFILES="$CLEANFILES $@"
2997076b9443SCy Schubert])
2998076b9443SCy Schubert
2999076b9443SCy Schubert#------------------------------------------------------------------------
3000076b9443SCy Schubert# TEA_PREFIX --
3001076b9443SCy Schubert#
3002076b9443SCy Schubert#	Handle the --prefix=... option by defaulting to what Tcl gave
3003076b9443SCy Schubert#
3004076b9443SCy Schubert# Arguments:
3005076b9443SCy Schubert#	none
3006076b9443SCy Schubert#
3007076b9443SCy Schubert# Results:
3008076b9443SCy Schubert#
3009076b9443SCy Schubert#	If --prefix or --exec-prefix was not specified, $prefix and
3010076b9443SCy Schubert#	$exec_prefix will be set to the values given to Tcl when it was
3011076b9443SCy Schubert#	configured.
3012076b9443SCy Schubert#------------------------------------------------------------------------
3013076b9443SCy SchubertAC_DEFUN([TEA_PREFIX], [
3014076b9443SCy Schubert    if test "${prefix}" = "NONE"; then
3015076b9443SCy Schubert	prefix_default=yes
3016076b9443SCy Schubert	if test x"${TCL_PREFIX}" != x; then
3017076b9443SCy Schubert	    AC_MSG_NOTICE([--prefix defaulting to TCL_PREFIX ${TCL_PREFIX}])
3018076b9443SCy Schubert	    prefix=${TCL_PREFIX}
3019076b9443SCy Schubert	else
3020076b9443SCy Schubert	    AC_MSG_NOTICE([--prefix defaulting to /usr/local])
3021076b9443SCy Schubert	    prefix=/usr/local
3022076b9443SCy Schubert	fi
3023076b9443SCy Schubert    fi
3024076b9443SCy Schubert    if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" \
3025076b9443SCy Schubert	-o x"${exec_prefix_default}" = x"yes" ; then
3026076b9443SCy Schubert	if test x"${TCL_EXEC_PREFIX}" != x; then
3027076b9443SCy Schubert	    AC_MSG_NOTICE([--exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}])
3028076b9443SCy Schubert	    exec_prefix=${TCL_EXEC_PREFIX}
3029076b9443SCy Schubert	else
3030076b9443SCy Schubert	    AC_MSG_NOTICE([--exec-prefix defaulting to ${prefix}])
3031076b9443SCy Schubert	    exec_prefix=$prefix
3032076b9443SCy Schubert	fi
3033076b9443SCy Schubert    fi
3034076b9443SCy Schubert])
3035076b9443SCy Schubert
3036076b9443SCy Schubert#------------------------------------------------------------------------
3037076b9443SCy Schubert# TEA_SETUP_COMPILER_CC --
3038076b9443SCy Schubert#
3039076b9443SCy Schubert#	Do compiler checks the way we want.  This is just a replacement
3040*00787218SCy Schubert#	for AC_PROG_CC in TEA configure.ac files to make them cleaner.
3041076b9443SCy Schubert#
3042076b9443SCy Schubert# Arguments:
3043076b9443SCy Schubert#	none
3044076b9443SCy Schubert#
3045076b9443SCy Schubert# Results:
3046076b9443SCy Schubert#
3047076b9443SCy Schubert#	Sets up CC var and other standard bits we need to make executables.
3048076b9443SCy Schubert#------------------------------------------------------------------------
3049076b9443SCy SchubertAC_DEFUN([TEA_SETUP_COMPILER_CC], [
3050076b9443SCy Schubert    # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE)
3051076b9443SCy Schubert    # in this macro, they need to go into TEA_SETUP_COMPILER instead.
3052076b9443SCy Schubert
3053076b9443SCy Schubert    AC_PROG_CC
3054076b9443SCy Schubert    AC_PROG_CPP
3055076b9443SCy Schubert
3056076b9443SCy Schubert    #--------------------------------------------------------------------
3057076b9443SCy Schubert    # Checks to see if the make program sets the $MAKE variable.
3058076b9443SCy Schubert    #--------------------------------------------------------------------
3059076b9443SCy Schubert
3060076b9443SCy Schubert    AC_PROG_MAKE_SET
3061076b9443SCy Schubert
3062076b9443SCy Schubert    #--------------------------------------------------------------------
3063076b9443SCy Schubert    # Find ranlib
3064076b9443SCy Schubert    #--------------------------------------------------------------------
3065076b9443SCy Schubert
3066076b9443SCy Schubert    AC_CHECK_TOOL(RANLIB, ranlib)
3067076b9443SCy Schubert
3068076b9443SCy Schubert    #--------------------------------------------------------------------
3069076b9443SCy Schubert    # Determines the correct binary file extension (.o, .obj, .exe etc.)
3070076b9443SCy Schubert    #--------------------------------------------------------------------
3071076b9443SCy Schubert
3072076b9443SCy Schubert    AC_OBJEXT
3073076b9443SCy Schubert    AC_EXEEXT
3074076b9443SCy Schubert])
3075076b9443SCy Schubert
3076076b9443SCy Schubert#------------------------------------------------------------------------
3077076b9443SCy Schubert# TEA_SETUP_COMPILER --
3078076b9443SCy Schubert#
3079076b9443SCy Schubert#	Do compiler checks that use the compiler.  This must go after
3080076b9443SCy Schubert#	TEA_SETUP_COMPILER_CC, which does the actual compiler check.
3081076b9443SCy Schubert#
3082076b9443SCy Schubert# Arguments:
3083076b9443SCy Schubert#	none
3084076b9443SCy Schubert#
3085076b9443SCy Schubert# Results:
3086076b9443SCy Schubert#
3087076b9443SCy Schubert#	Sets up CC var and other standard bits we need to make executables.
3088076b9443SCy Schubert#------------------------------------------------------------------------
3089076b9443SCy SchubertAC_DEFUN([TEA_SETUP_COMPILER], [
3090076b9443SCy Schubert    # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here.
3091076b9443SCy Schubert    AC_REQUIRE([TEA_SETUP_COMPILER_CC])
3092076b9443SCy Schubert
3093076b9443SCy Schubert    #------------------------------------------------------------------------
3094076b9443SCy Schubert    # If we're using GCC, see if the compiler understands -pipe. If so, use it.
3095076b9443SCy Schubert    # It makes compiling go faster.  (This is only a performance feature.)
3096076b9443SCy Schubert    #------------------------------------------------------------------------
3097076b9443SCy Schubert
3098076b9443SCy Schubert    if test -z "$no_pipe" -a -n "$GCC"; then
3099076b9443SCy Schubert	AC_CACHE_CHECK([if the compiler understands -pipe],
3100076b9443SCy Schubert	    tcl_cv_cc_pipe, [
3101076b9443SCy Schubert	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe"
3102*00787218SCy Schubert	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[tcl_cv_cc_pipe=yes],[tcl_cv_cc_pipe=no])
3103076b9443SCy Schubert	    CFLAGS=$hold_cflags])
3104076b9443SCy Schubert	if test $tcl_cv_cc_pipe = yes; then
3105076b9443SCy Schubert	    CFLAGS="$CFLAGS -pipe"
3106076b9443SCy Schubert	fi
3107076b9443SCy Schubert    fi
3108076b9443SCy Schubert
3109076b9443SCy Schubert    #--------------------------------------------------------------------
3110076b9443SCy Schubert    # Common compiler flag setup
3111076b9443SCy Schubert    #--------------------------------------------------------------------
3112076b9443SCy Schubert
3113076b9443SCy Schubert    AC_C_BIGENDIAN
3114076b9443SCy Schubert])
3115076b9443SCy Schubert
3116076b9443SCy Schubert#------------------------------------------------------------------------
3117076b9443SCy Schubert# TEA_MAKE_LIB --
3118076b9443SCy Schubert#
3119076b9443SCy Schubert#	Generate a line that can be used to build a shared/unshared library
3120076b9443SCy Schubert#	in a platform independent manner.
3121076b9443SCy Schubert#
3122076b9443SCy Schubert# Arguments:
3123076b9443SCy Schubert#	none
3124076b9443SCy Schubert#
3125076b9443SCy Schubert#	Requires:
3126076b9443SCy Schubert#
3127076b9443SCy Schubert# Results:
3128076b9443SCy Schubert#
3129076b9443SCy Schubert#	Defines the following vars:
3130076b9443SCy Schubert#	CFLAGS -	Done late here to note disturb other AC macros
3131076b9443SCy Schubert#       MAKE_LIB -      Command to execute to build the Tcl library;
3132076b9443SCy Schubert#                       differs depending on whether or not Tcl is being
3133076b9443SCy Schubert#                       compiled as a shared library.
3134076b9443SCy Schubert#	MAKE_SHARED_LIB	Makefile rule for building a shared library
3135076b9443SCy Schubert#	MAKE_STATIC_LIB	Makefile rule for building a static library
3136076b9443SCy Schubert#	MAKE_STUB_LIB	Makefile rule for building a stub library
3137076b9443SCy Schubert#	VC_MANIFEST_EMBED_DLL Makefile rule for embedded VC manifest in DLL
3138076b9443SCy Schubert#	VC_MANIFEST_EMBED_EXE Makefile rule for embedded VC manifest in EXE
3139076b9443SCy Schubert#------------------------------------------------------------------------
3140076b9443SCy Schubert
3141076b9443SCy SchubertAC_DEFUN([TEA_MAKE_LIB], [
3142076b9443SCy Schubert    if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then
3143076b9443SCy Schubert	MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_OBJECTS)"
3144*00787218SCy Schubert	MAKE_SHARED_LIB="\${SHLIB_LD} \${LDFLAGS} \${LDFLAGS_DEFAULT} -out:\[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}"
3145076b9443SCy Schubert	AC_EGREP_CPP([manifest needed], [
3146076b9443SCy Schubert#if defined(_MSC_VER) && _MSC_VER >= 1400
3147076b9443SCy Schubertprint("manifest needed")
3148076b9443SCy Schubert#endif
3149076b9443SCy Schubert	], [
3150076b9443SCy Schubert	# Could do a CHECK_PROG for mt, but should always be with MSVC8+
3151076b9443SCy Schubert	VC_MANIFEST_EMBED_DLL="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest -outputresource:\[$]@\;2 ; fi"
3152076b9443SCy Schubert	VC_MANIFEST_EMBED_EXE="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest -outputresource:\[$]@\;1 ; fi"
3153076b9443SCy Schubert	MAKE_SHARED_LIB="${MAKE_SHARED_LIB} ; ${VC_MANIFEST_EMBED_DLL}"
3154076b9443SCy Schubert	TEA_ADD_CLEANFILES([*.manifest])
3155076b9443SCy Schubert	])
3156076b9443SCy Schubert	MAKE_STUB_LIB="\${STLIB_LD} -nodefaultlib -out:\[$]@ \$(PKG_STUB_OBJECTS)"
3157076b9443SCy Schubert    else
3158076b9443SCy Schubert	MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(PKG_OBJECTS)"
3159*00787218SCy Schubert	MAKE_SHARED_LIB="\${SHLIB_LD} \${LDFLAGS} \${LDFLAGS_DEFAULT} -o \[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}"
3160076b9443SCy Schubert	MAKE_STUB_LIB="\${STLIB_LD} \[$]@ \$(PKG_STUB_OBJECTS)"
3161076b9443SCy Schubert    fi
3162076b9443SCy Schubert
3163076b9443SCy Schubert    if test "${SHARED_BUILD}" = "1" ; then
3164076b9443SCy Schubert	MAKE_LIB="${MAKE_SHARED_LIB} "
3165076b9443SCy Schubert    else
3166076b9443SCy Schubert	MAKE_LIB="${MAKE_STATIC_LIB} "
3167076b9443SCy Schubert    fi
3168076b9443SCy Schubert
3169076b9443SCy Schubert    #--------------------------------------------------------------------
3170076b9443SCy Schubert    # Shared libraries and static libraries have different names.
3171076b9443SCy Schubert    # Use the double eval to make sure any variables in the suffix is
3172076b9443SCy Schubert    # substituted. (@@@ Might not be necessary anymore)
3173076b9443SCy Schubert    #--------------------------------------------------------------------
3174076b9443SCy Schubert
3175*00787218SCy Schubert    PACKAGE_LIB_PREFIX8="${PACKAGE_LIB_PREFIX}"
3176*00787218SCy Schubert    PACKAGE_LIB_PREFIX9="${PACKAGE_LIB_PREFIX}tcl9"
3177*00787218SCy Schubert    if test "${TCL_MAJOR_VERSION}" -gt 8 ; then
3178*00787218SCy Schubert	PACKAGE_LIB_PREFIX="${PACKAGE_LIB_PREFIX9}"
3179*00787218SCy Schubert    else
3180*00787218SCy Schubert	PACKAGE_LIB_PREFIX="${PACKAGE_LIB_PREFIX8}"
3181*00787218SCy Schubert    fi
3182076b9443SCy Schubert    if test "${TEA_PLATFORM}" = "windows" ; then
3183076b9443SCy Schubert	if test "${SHARED_BUILD}" = "1" ; then
3184076b9443SCy Schubert	    # We force the unresolved linking of symbols that are really in
3185076b9443SCy Schubert	    # the private libraries of Tcl and Tk.
3186076b9443SCy Schubert	    if test x"${TK_BIN_DIR}" != x ; then
3187076b9443SCy Schubert		SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\""
3188076b9443SCy Schubert	    fi
3189076b9443SCy Schubert	    SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\""
3190076b9443SCy Schubert	    if test "$GCC" = "yes"; then
3191076b9443SCy Schubert		SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -static-libgcc"
3192076b9443SCy Schubert	    fi
3193*00787218SCy Schubert	    eval eval "PKG_LIB_FILE8=${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
3194*00787218SCy Schubert	    eval eval "PKG_LIB_FILE9=${PACKAGE_LIB_PREFIX9}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
3195*00787218SCy Schubert	    eval eval "PKG_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
3196076b9443SCy Schubert	else
3197076b9443SCy Schubert	    if test "$GCC" = "yes"; then
3198*00787218SCy Schubert		PACKAGE_LIB_PREFIX=lib${PACKAGE_LIB_PREFIX}
3199076b9443SCy Schubert	    fi
3200*00787218SCy Schubert	    eval eval "PKG_LIB_FILE8=${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
3201*00787218SCy Schubert	    eval eval "PKG_LIB_FILE9=${PACKAGE_LIB_PREFIX9}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
3202*00787218SCy Schubert	    eval eval "PKG_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
3203076b9443SCy Schubert	fi
3204076b9443SCy Schubert	# Some packages build their own stubs libraries
3205*00787218SCy Schubert	eval eval "PKG_STUB_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
3206076b9443SCy Schubert	if test "$GCC" = "yes"; then
3207076b9443SCy Schubert	    PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE}
3208076b9443SCy Schubert	fi
3209076b9443SCy Schubert	# These aren't needed on Windows (either MSVC or gcc)
3210076b9443SCy Schubert	RANLIB=:
3211076b9443SCy Schubert	RANLIB_STUB=:
3212076b9443SCy Schubert    else
3213076b9443SCy Schubert	RANLIB_STUB="${RANLIB}"
3214076b9443SCy Schubert	if test "${SHARED_BUILD}" = "1" ; then
3215076b9443SCy Schubert	    SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}"
3216076b9443SCy Schubert	    if test x"${TK_BIN_DIR}" != x ; then
3217076b9443SCy Schubert		SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}"
3218076b9443SCy Schubert	    fi
3219*00787218SCy Schubert	    eval eval "PKG_LIB_FILE8=lib${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
3220*00787218SCy Schubert	    eval eval "PKG_LIB_FILE9=lib${PACKAGE_LIB_PREFIX9}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
3221*00787218SCy Schubert	    eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
3222076b9443SCy Schubert	    RANLIB=:
3223076b9443SCy Schubert	else
3224*00787218SCy Schubert	    eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
3225*00787218SCy Schubert	    eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX9}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
3226*00787218SCy Schubert	    eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
3227076b9443SCy Schubert	fi
3228076b9443SCy Schubert	# Some packages build their own stubs libraries
3229*00787218SCy Schubert	eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
3230076b9443SCy Schubert    fi
3231076b9443SCy Schubert
3232076b9443SCy Schubert    # These are escaped so that only CFLAGS is picked up at configure time.
3233076b9443SCy Schubert    # The other values will be substituted at make time.
3234076b9443SCy Schubert    CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}"
3235076b9443SCy Schubert    if test "${SHARED_BUILD}" = "1" ; then
3236076b9443SCy Schubert	CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}"
3237076b9443SCy Schubert    fi
3238076b9443SCy Schubert
3239076b9443SCy Schubert    AC_SUBST(MAKE_LIB)
3240076b9443SCy Schubert    AC_SUBST(MAKE_SHARED_LIB)
3241076b9443SCy Schubert    AC_SUBST(MAKE_STATIC_LIB)
3242076b9443SCy Schubert    AC_SUBST(MAKE_STUB_LIB)
3243076b9443SCy Schubert    AC_SUBST(RANLIB_STUB)
3244076b9443SCy Schubert    AC_SUBST(VC_MANIFEST_EMBED_DLL)
3245076b9443SCy Schubert    AC_SUBST(VC_MANIFEST_EMBED_EXE)
3246076b9443SCy Schubert])
3247076b9443SCy Schubert
3248076b9443SCy Schubert#------------------------------------------------------------------------
3249076b9443SCy Schubert# TEA_LIB_SPEC --
3250076b9443SCy Schubert#
3251076b9443SCy Schubert#	Compute the name of an existing object library located in libdir
3252076b9443SCy Schubert#	from the given base name and produce the appropriate linker flags.
3253076b9443SCy Schubert#
3254076b9443SCy Schubert# Arguments:
3255076b9443SCy Schubert#	basename	The base name of the library without version
3256076b9443SCy Schubert#			numbers, extensions, or "lib" prefixes.
3257076b9443SCy Schubert#	extra_dir	Extra directory in which to search for the
3258076b9443SCy Schubert#			library.  This location is used first, then
3259076b9443SCy Schubert#			$prefix/$exec-prefix, then some defaults.
3260076b9443SCy Schubert#
3261076b9443SCy Schubert# Requires:
3262076b9443SCy Schubert#	TEA_INIT and TEA_PREFIX must be called first.
3263076b9443SCy Schubert#
3264076b9443SCy Schubert# Results:
3265076b9443SCy Schubert#
3266076b9443SCy Schubert#	Defines the following vars:
3267076b9443SCy Schubert#		${basename}_LIB_NAME	The computed library name.
3268076b9443SCy Schubert#		${basename}_LIB_SPEC	The computed linker flags.
3269076b9443SCy Schubert#------------------------------------------------------------------------
3270076b9443SCy Schubert
3271076b9443SCy SchubertAC_DEFUN([TEA_LIB_SPEC], [
3272076b9443SCy Schubert    AC_MSG_CHECKING([for $1 library])
3273076b9443SCy Schubert
3274076b9443SCy Schubert    # Look in exec-prefix for the library (defined by TEA_PREFIX).
3275076b9443SCy Schubert
3276076b9443SCy Schubert    tea_lib_name_dir="${exec_prefix}/lib"
3277076b9443SCy Schubert
3278076b9443SCy Schubert    # Or in a user-specified location.
3279076b9443SCy Schubert
3280076b9443SCy Schubert    if test x"$2" != x ; then
3281076b9443SCy Schubert	tea_extra_lib_dir=$2
3282076b9443SCy Schubert    else
3283076b9443SCy Schubert	tea_extra_lib_dir=NONE
3284076b9443SCy Schubert    fi
3285076b9443SCy Schubert
3286076b9443SCy Schubert    for i in \
3287076b9443SCy Schubert	    `ls -dr ${tea_extra_lib_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
3288076b9443SCy Schubert	    `ls -dr ${tea_extra_lib_dir}/lib$1[[0-9]]* 2>/dev/null ` \
3289076b9443SCy Schubert	    `ls -dr ${tea_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
3290076b9443SCy Schubert	    `ls -dr ${tea_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
3291076b9443SCy Schubert	    `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
3292076b9443SCy Schubert	    `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
3293076b9443SCy Schubert	    `ls -dr /usr/lib64/$1[[0-9]]*.lib 2>/dev/null ` \
3294076b9443SCy Schubert	    `ls -dr /usr/lib64/lib$1[[0-9]]* 2>/dev/null ` \
3295076b9443SCy Schubert	    `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
3296076b9443SCy Schubert	    `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
3297076b9443SCy Schubert	if test -f "$i" ; then
3298076b9443SCy Schubert	    tea_lib_name_dir=`dirname $i`
3299076b9443SCy Schubert	    $1_LIB_NAME=`basename $i`
3300076b9443SCy Schubert	    $1_LIB_PATH_NAME=$i
3301076b9443SCy Schubert	    break
3302076b9443SCy Schubert	fi
3303076b9443SCy Schubert    done
3304076b9443SCy Schubert
3305076b9443SCy Schubert    if test "${TEA_PLATFORM}" = "windows"; then
3306076b9443SCy Schubert	$1_LIB_SPEC=\"`${CYGPATH} ${$1_LIB_PATH_NAME} 2>/dev/null`\"
3307076b9443SCy Schubert    else
3308076b9443SCy Schubert	# Strip off the leading "lib" and trailing ".a" or ".so"
3309076b9443SCy Schubert
3310076b9443SCy Schubert	tea_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//' -e 's/\.so.*//'`
3311076b9443SCy Schubert	$1_LIB_SPEC="-L${tea_lib_name_dir} -l${tea_lib_name_lib}"
3312076b9443SCy Schubert    fi
3313076b9443SCy Schubert
3314076b9443SCy Schubert    if test "x${$1_LIB_NAME}" = x ; then
3315076b9443SCy Schubert	AC_MSG_ERROR([not found])
3316076b9443SCy Schubert    else
3317076b9443SCy Schubert	AC_MSG_RESULT([${$1_LIB_SPEC}])
3318076b9443SCy Schubert    fi
3319076b9443SCy Schubert])
3320076b9443SCy Schubert
3321076b9443SCy Schubert#------------------------------------------------------------------------
3322076b9443SCy Schubert# TEA_PRIVATE_TCL_HEADERS --
3323076b9443SCy Schubert#
3324076b9443SCy Schubert#	Locate the private Tcl include files
3325076b9443SCy Schubert#
3326076b9443SCy Schubert# Arguments:
3327076b9443SCy Schubert#
3328076b9443SCy Schubert#	Requires:
3329076b9443SCy Schubert#		TCL_SRC_DIR	Assumes that TEA_LOAD_TCLCONFIG has
3330076b9443SCy Schubert#				already been called.
3331076b9443SCy Schubert#
3332076b9443SCy Schubert# Results:
3333076b9443SCy Schubert#
3334076b9443SCy Schubert#	Substitutes the following vars:
3335076b9443SCy Schubert#		TCL_TOP_DIR_NATIVE
3336076b9443SCy Schubert#		TCL_INCLUDES
3337076b9443SCy Schubert#------------------------------------------------------------------------
3338076b9443SCy Schubert
3339076b9443SCy SchubertAC_DEFUN([TEA_PRIVATE_TCL_HEADERS], [
3340076b9443SCy Schubert    # Allow for --with-tclinclude to take effect and define ${ac_cv_c_tclh}
3341076b9443SCy Schubert    AC_REQUIRE([TEA_PUBLIC_TCL_HEADERS])
3342076b9443SCy Schubert    AC_MSG_CHECKING([for Tcl private include files])
3343076b9443SCy Schubert
3344076b9443SCy Schubert    TCL_SRC_DIR_NATIVE=`${CYGPATH} ${TCL_SRC_DIR}`
3345076b9443SCy Schubert    TCL_TOP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}\"
3346076b9443SCy Schubert
3347076b9443SCy Schubert    # Check to see if tcl<Plat>Port.h isn't already with the public headers
3348076b9443SCy Schubert    # Don't look for tclInt.h because that resides with tcl.h in the core
3349076b9443SCy Schubert    # sources, but the <plat>Port headers are in a different directory
3350076b9443SCy Schubert    if test "${TEA_PLATFORM}" = "windows" -a \
3351076b9443SCy Schubert	-f "${ac_cv_c_tclh}/tclWinPort.h"; then
3352076b9443SCy Schubert	result="private headers found with public headers"
3353076b9443SCy Schubert    elif test "${TEA_PLATFORM}" = "unix" -a \
3354076b9443SCy Schubert	-f "${ac_cv_c_tclh}/tclUnixPort.h"; then
3355076b9443SCy Schubert	result="private headers found with public headers"
3356076b9443SCy Schubert    else
3357076b9443SCy Schubert	TCL_GENERIC_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/generic\"
3358076b9443SCy Schubert	if test "${TEA_PLATFORM}" = "windows"; then
3359076b9443SCy Schubert	    TCL_PLATFORM_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/win\"
3360076b9443SCy Schubert	else
3361076b9443SCy Schubert	    TCL_PLATFORM_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/unix\"
3362076b9443SCy Schubert	fi
3363076b9443SCy Schubert	# Overwrite the previous TCL_INCLUDES as this should capture both
3364076b9443SCy Schubert	# public and private headers in the same set.
3365076b9443SCy Schubert	# We want to ensure these are substituted so as not to require
3366076b9443SCy Schubert	# any *_NATIVE vars be defined in the Makefile
3367076b9443SCy Schubert	TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
3368076b9443SCy Schubert	if test "`uname -s`" = "Darwin"; then
3369076b9443SCy Schubert            # If Tcl was built as a framework, attempt to use
3370076b9443SCy Schubert            # the framework's Headers and PrivateHeaders directories
3371076b9443SCy Schubert            case ${TCL_DEFS} in
3372076b9443SCy Schubert	    	*TCL_FRAMEWORK*)
3373076b9443SCy Schubert		    if test -d "${TCL_BIN_DIR}/Headers" -a \
3374076b9443SCy Schubert			    -d "${TCL_BIN_DIR}/PrivateHeaders"; then
3375076b9443SCy Schubert			TCL_INCLUDES="-I\"${TCL_BIN_DIR}/Headers\" -I\"${TCL_BIN_DIR}/PrivateHeaders\" ${TCL_INCLUDES}"
3376076b9443SCy Schubert		    else
3377076b9443SCy Schubert			TCL_INCLUDES="${TCL_INCLUDES} ${TCL_INCLUDE_SPEC} `echo "${TCL_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`"
3378076b9443SCy Schubert		    fi
3379076b9443SCy Schubert	            ;;
3380076b9443SCy Schubert	    esac
3381076b9443SCy Schubert	    result="Using ${TCL_INCLUDES}"
3382076b9443SCy Schubert	else
3383076b9443SCy Schubert	    if test ! -f "${TCL_SRC_DIR}/generic/tclInt.h" ; then
3384076b9443SCy Schubert		AC_MSG_ERROR([Cannot find private header tclInt.h in ${TCL_SRC_DIR}])
3385076b9443SCy Schubert	    fi
3386076b9443SCy Schubert	    result="Using srcdir found in tclConfig.sh: ${TCL_SRC_DIR}"
3387076b9443SCy Schubert	fi
3388076b9443SCy Schubert    fi
3389076b9443SCy Schubert
3390076b9443SCy Schubert    AC_SUBST(TCL_TOP_DIR_NATIVE)
3391076b9443SCy Schubert
3392076b9443SCy Schubert    AC_SUBST(TCL_INCLUDES)
3393076b9443SCy Schubert    AC_MSG_RESULT([${result}])
3394076b9443SCy Schubert])
3395076b9443SCy Schubert
3396076b9443SCy Schubert#------------------------------------------------------------------------
3397076b9443SCy Schubert# TEA_PUBLIC_TCL_HEADERS --
3398076b9443SCy Schubert#
3399076b9443SCy Schubert#	Locate the installed public Tcl header files
3400076b9443SCy Schubert#
3401076b9443SCy Schubert# Arguments:
3402076b9443SCy Schubert#	None.
3403076b9443SCy Schubert#
3404076b9443SCy Schubert# Requires:
3405076b9443SCy Schubert#	CYGPATH must be set
3406076b9443SCy Schubert#
3407076b9443SCy Schubert# Results:
3408076b9443SCy Schubert#
3409076b9443SCy Schubert#	Adds a --with-tclinclude switch to configure.
3410076b9443SCy Schubert#	Result is cached.
3411076b9443SCy Schubert#
3412076b9443SCy Schubert#	Substitutes the following vars:
3413076b9443SCy Schubert#		TCL_INCLUDES
3414076b9443SCy Schubert#------------------------------------------------------------------------
3415076b9443SCy Schubert
3416076b9443SCy SchubertAC_DEFUN([TEA_PUBLIC_TCL_HEADERS], [
3417076b9443SCy Schubert    AC_MSG_CHECKING([for Tcl public headers])
3418076b9443SCy Schubert
3419076b9443SCy Schubert    AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory containing the public Tcl header files], with_tclinclude=${withval})
3420076b9443SCy Schubert
3421076b9443SCy Schubert    AC_CACHE_VAL(ac_cv_c_tclh, [
3422076b9443SCy Schubert	# Use the value from --with-tclinclude, if it was given
3423076b9443SCy Schubert
3424076b9443SCy Schubert	if test x"${with_tclinclude}" != x ; then
3425076b9443SCy Schubert	    if test -f "${with_tclinclude}/tcl.h" ; then
3426076b9443SCy Schubert		ac_cv_c_tclh=${with_tclinclude}
3427076b9443SCy Schubert	    else
3428076b9443SCy Schubert		AC_MSG_ERROR([${with_tclinclude} directory does not contain tcl.h])
3429076b9443SCy Schubert	    fi
3430076b9443SCy Schubert	else
3431076b9443SCy Schubert	    list=""
3432076b9443SCy Schubert	    if test "`uname -s`" = "Darwin"; then
3433076b9443SCy Schubert		# If Tcl was built as a framework, attempt to use
3434076b9443SCy Schubert		# the framework's Headers directory
3435076b9443SCy Schubert		case ${TCL_DEFS} in
3436076b9443SCy Schubert		    *TCL_FRAMEWORK*)
3437076b9443SCy Schubert			list="`ls -d ${TCL_BIN_DIR}/Headers 2>/dev/null`"
3438076b9443SCy Schubert			;;
3439076b9443SCy Schubert		esac
3440076b9443SCy Schubert	    fi
3441076b9443SCy Schubert
3442076b9443SCy Schubert	    # Look in the source dir only if Tcl is not installed,
3443076b9443SCy Schubert	    # and in that situation, look there before installed locations.
3444076b9443SCy Schubert	    if test -f "${TCL_BIN_DIR}/Makefile" ; then
3445076b9443SCy Schubert		list="$list `ls -d ${TCL_SRC_DIR}/generic 2>/dev/null`"
3446076b9443SCy Schubert	    fi
3447076b9443SCy Schubert
3448076b9443SCy Schubert	    # Check order: pkg --prefix location, Tcl's --prefix location,
3449076b9443SCy Schubert	    # relative to directory of tclConfig.sh.
3450076b9443SCy Schubert
3451076b9443SCy Schubert	    eval "temp_includedir=${includedir}"
3452076b9443SCy Schubert	    list="$list \
3453076b9443SCy Schubert		`ls -d ${temp_includedir}        2>/dev/null` \
3454076b9443SCy Schubert		`ls -d ${TCL_PREFIX}/include     2>/dev/null` \
3455076b9443SCy Schubert		`ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
3456076b9443SCy Schubert	    if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
3457076b9443SCy Schubert		list="$list /usr/local/include /usr/include"
3458076b9443SCy Schubert		if test x"${TCL_INCLUDE_SPEC}" != x ; then
3459076b9443SCy Schubert		    d=`echo "${TCL_INCLUDE_SPEC}" | sed -e 's/^-I//'`
3460076b9443SCy Schubert		    list="$list `ls -d ${d} 2>/dev/null`"
3461076b9443SCy Schubert		fi
3462076b9443SCy Schubert	    fi
3463076b9443SCy Schubert	    for i in $list ; do
3464076b9443SCy Schubert		if test -f "$i/tcl.h" ; then
3465076b9443SCy Schubert		    ac_cv_c_tclh=$i
3466076b9443SCy Schubert		    break
3467076b9443SCy Schubert		fi
3468076b9443SCy Schubert	    done
3469076b9443SCy Schubert	fi
3470076b9443SCy Schubert    ])
3471076b9443SCy Schubert
3472076b9443SCy Schubert    # Print a message based on how we determined the include path
3473076b9443SCy Schubert
3474076b9443SCy Schubert    if test x"${ac_cv_c_tclh}" = x ; then
3475076b9443SCy Schubert	AC_MSG_ERROR([tcl.h not found.  Please specify its location with --with-tclinclude])
3476076b9443SCy Schubert    else
3477076b9443SCy Schubert	AC_MSG_RESULT([${ac_cv_c_tclh}])
3478076b9443SCy Schubert    fi
3479076b9443SCy Schubert
3480076b9443SCy Schubert    # Convert to a native path and substitute into the output files.
3481076b9443SCy Schubert
3482076b9443SCy Schubert    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
3483076b9443SCy Schubert
3484076b9443SCy Schubert    TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
3485076b9443SCy Schubert
3486076b9443SCy Schubert    AC_SUBST(TCL_INCLUDES)
3487076b9443SCy Schubert])
3488076b9443SCy Schubert
3489076b9443SCy Schubert#------------------------------------------------------------------------
3490076b9443SCy Schubert# TEA_PRIVATE_TK_HEADERS --
3491076b9443SCy Schubert#
3492076b9443SCy Schubert#	Locate the private Tk include files
3493076b9443SCy Schubert#
3494076b9443SCy Schubert# Arguments:
3495076b9443SCy Schubert#
3496076b9443SCy Schubert#	Requires:
3497076b9443SCy Schubert#		TK_SRC_DIR	Assumes that TEA_LOAD_TKCONFIG has
3498076b9443SCy Schubert#				 already been called.
3499076b9443SCy Schubert#
3500076b9443SCy Schubert# Results:
3501076b9443SCy Schubert#
3502076b9443SCy Schubert#	Substitutes the following vars:
3503076b9443SCy Schubert#		TK_INCLUDES
3504076b9443SCy Schubert#------------------------------------------------------------------------
3505076b9443SCy Schubert
3506076b9443SCy SchubertAC_DEFUN([TEA_PRIVATE_TK_HEADERS], [
3507076b9443SCy Schubert    # Allow for --with-tkinclude to take effect and define ${ac_cv_c_tkh}
3508076b9443SCy Schubert    AC_REQUIRE([TEA_PUBLIC_TK_HEADERS])
3509076b9443SCy Schubert    AC_MSG_CHECKING([for Tk private include files])
3510076b9443SCy Schubert
3511076b9443SCy Schubert    TK_SRC_DIR_NATIVE=`${CYGPATH} ${TK_SRC_DIR}`
3512076b9443SCy Schubert    TK_TOP_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}\"
3513076b9443SCy Schubert
3514076b9443SCy Schubert    # Check to see if tk<Plat>Port.h isn't already with the public headers
3515076b9443SCy Schubert    # Don't look for tkInt.h because that resides with tk.h in the core
3516076b9443SCy Schubert    # sources, but the <plat>Port headers are in a different directory
3517076b9443SCy Schubert    if test "${TEA_PLATFORM}" = "windows" -a \
3518076b9443SCy Schubert	-f "${ac_cv_c_tkh}/tkWinPort.h"; then
3519076b9443SCy Schubert	result="private headers found with public headers"
3520076b9443SCy Schubert    elif test "${TEA_PLATFORM}" = "unix" -a \
3521076b9443SCy Schubert	-f "${ac_cv_c_tkh}/tkUnixPort.h"; then
3522076b9443SCy Schubert	result="private headers found with public headers"
3523076b9443SCy Schubert    else
3524076b9443SCy Schubert	TK_GENERIC_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/generic\"
3525076b9443SCy Schubert	TK_XLIB_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/xlib\"
3526076b9443SCy Schubert	if test "${TEA_PLATFORM}" = "windows"; then
3527076b9443SCy Schubert	    TK_PLATFORM_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/win\"
3528076b9443SCy Schubert	else
3529076b9443SCy Schubert	    TK_PLATFORM_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/unix\"
3530076b9443SCy Schubert	fi
3531076b9443SCy Schubert	# Overwrite the previous TK_INCLUDES as this should capture both
3532076b9443SCy Schubert	# public and private headers in the same set.
3533076b9443SCy Schubert	# We want to ensure these are substituted so as not to require
3534076b9443SCy Schubert	# any *_NATIVE vars be defined in the Makefile
3535076b9443SCy Schubert	TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
3536076b9443SCy Schubert	# Detect and add ttk subdir
3537076b9443SCy Schubert	if test -d "${TK_SRC_DIR}/generic/ttk"; then
3538076b9443SCy Schubert	   TK_INCLUDES="${TK_INCLUDES} -I\"${TK_SRC_DIR_NATIVE}/generic/ttk\""
3539076b9443SCy Schubert	fi
3540076b9443SCy Schubert	if test "${TEA_WINDOWINGSYSTEM}" != "x11"; then
3541076b9443SCy Schubert	   TK_INCLUDES="${TK_INCLUDES} -I\"${TK_XLIB_DIR_NATIVE}\""
3542076b9443SCy Schubert	fi
3543076b9443SCy Schubert	if test "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
3544076b9443SCy Schubert	   TK_INCLUDES="${TK_INCLUDES} -I\"${TK_SRC_DIR_NATIVE}/macosx\""
3545076b9443SCy Schubert	fi
3546076b9443SCy Schubert	if test "`uname -s`" = "Darwin"; then
3547076b9443SCy Schubert	    # If Tk was built as a framework, attempt to use
3548076b9443SCy Schubert	    # the framework's Headers and PrivateHeaders directories
3549076b9443SCy Schubert	    case ${TK_DEFS} in
3550076b9443SCy Schubert		*TK_FRAMEWORK*)
3551076b9443SCy Schubert			if test -d "${TK_BIN_DIR}/Headers" -a \
3552076b9443SCy Schubert				-d "${TK_BIN_DIR}/PrivateHeaders"; then
3553076b9443SCy Schubert			    TK_INCLUDES="-I\"${TK_BIN_DIR}/Headers\" -I\"${TK_BIN_DIR}/PrivateHeaders\" ${TK_INCLUDES}"
3554076b9443SCy Schubert			else
3555076b9443SCy Schubert			    TK_INCLUDES="${TK_INCLUDES} ${TK_INCLUDE_SPEC} `echo "${TK_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`"
3556076b9443SCy Schubert			fi
3557076b9443SCy Schubert			;;
3558076b9443SCy Schubert	    esac
3559076b9443SCy Schubert	    result="Using ${TK_INCLUDES}"
3560076b9443SCy Schubert	else
3561076b9443SCy Schubert	    if test ! -f "${TK_SRC_DIR}/generic/tkInt.h" ; then
3562076b9443SCy Schubert	       AC_MSG_ERROR([Cannot find private header tkInt.h in ${TK_SRC_DIR}])
3563076b9443SCy Schubert	    fi
3564076b9443SCy Schubert	    result="Using srcdir found in tkConfig.sh: ${TK_SRC_DIR}"
3565076b9443SCy Schubert	fi
3566076b9443SCy Schubert    fi
3567076b9443SCy Schubert
3568076b9443SCy Schubert    AC_SUBST(TK_TOP_DIR_NATIVE)
3569076b9443SCy Schubert    AC_SUBST(TK_XLIB_DIR_NATIVE)
3570076b9443SCy Schubert
3571076b9443SCy Schubert    AC_SUBST(TK_INCLUDES)
3572076b9443SCy Schubert    AC_MSG_RESULT([${result}])
3573076b9443SCy Schubert])
3574076b9443SCy Schubert
3575076b9443SCy Schubert#------------------------------------------------------------------------
3576076b9443SCy Schubert# TEA_PUBLIC_TK_HEADERS --
3577076b9443SCy Schubert#
3578076b9443SCy Schubert#	Locate the installed public Tk header files
3579076b9443SCy Schubert#
3580076b9443SCy Schubert# Arguments:
3581076b9443SCy Schubert#	None.
3582076b9443SCy Schubert#
3583076b9443SCy Schubert# Requires:
3584076b9443SCy Schubert#	CYGPATH must be set
3585076b9443SCy Schubert#
3586076b9443SCy Schubert# Results:
3587076b9443SCy Schubert#
3588076b9443SCy Schubert#	Adds a --with-tkinclude switch to configure.
3589076b9443SCy Schubert#	Result is cached.
3590076b9443SCy Schubert#
3591076b9443SCy Schubert#	Substitutes the following vars:
3592076b9443SCy Schubert#		TK_INCLUDES
3593076b9443SCy Schubert#------------------------------------------------------------------------
3594076b9443SCy Schubert
3595076b9443SCy SchubertAC_DEFUN([TEA_PUBLIC_TK_HEADERS], [
3596076b9443SCy Schubert    AC_MSG_CHECKING([for Tk public headers])
3597076b9443SCy Schubert
3598076b9443SCy Schubert    AC_ARG_WITH(tkinclude, [  --with-tkinclude        directory containing the public Tk header files], with_tkinclude=${withval})
3599076b9443SCy Schubert
3600076b9443SCy Schubert    AC_CACHE_VAL(ac_cv_c_tkh, [
3601076b9443SCy Schubert	# Use the value from --with-tkinclude, if it was given
3602076b9443SCy Schubert
3603076b9443SCy Schubert	if test x"${with_tkinclude}" != x ; then
3604076b9443SCy Schubert	    if test -f "${with_tkinclude}/tk.h" ; then
3605076b9443SCy Schubert		ac_cv_c_tkh=${with_tkinclude}
3606076b9443SCy Schubert	    else
3607076b9443SCy Schubert		AC_MSG_ERROR([${with_tkinclude} directory does not contain tk.h])
3608076b9443SCy Schubert	    fi
3609076b9443SCy Schubert	else
3610076b9443SCy Schubert	    list=""
3611076b9443SCy Schubert	    if test "`uname -s`" = "Darwin"; then
3612076b9443SCy Schubert		# If Tk was built as a framework, attempt to use
3613076b9443SCy Schubert		# the framework's Headers directory.
3614076b9443SCy Schubert		case ${TK_DEFS} in
3615076b9443SCy Schubert		    *TK_FRAMEWORK*)
3616076b9443SCy Schubert			list="`ls -d ${TK_BIN_DIR}/Headers 2>/dev/null`"
3617076b9443SCy Schubert			;;
3618076b9443SCy Schubert		esac
3619076b9443SCy Schubert	    fi
3620076b9443SCy Schubert
3621076b9443SCy Schubert	    # Look in the source dir only if Tk is not installed,
3622076b9443SCy Schubert	    # and in that situation, look there before installed locations.
3623076b9443SCy Schubert	    if test -f "${TK_BIN_DIR}/Makefile" ; then
3624076b9443SCy Schubert		list="$list `ls -d ${TK_SRC_DIR}/generic 2>/dev/null`"
3625076b9443SCy Schubert	    fi
3626076b9443SCy Schubert
3627076b9443SCy Schubert	    # Check order: pkg --prefix location, Tk's --prefix location,
3628076b9443SCy Schubert	    # relative to directory of tkConfig.sh, Tcl's --prefix location,
3629076b9443SCy Schubert	    # relative to directory of tclConfig.sh.
3630076b9443SCy Schubert
3631076b9443SCy Schubert	    eval "temp_includedir=${includedir}"
3632076b9443SCy Schubert	    list="$list \
3633076b9443SCy Schubert		`ls -d ${temp_includedir}        2>/dev/null` \
3634076b9443SCy Schubert		`ls -d ${TK_PREFIX}/include      2>/dev/null` \
3635076b9443SCy Schubert		`ls -d ${TK_BIN_DIR}/../include  2>/dev/null` \
3636076b9443SCy Schubert		`ls -d ${TCL_PREFIX}/include     2>/dev/null` \
3637076b9443SCy Schubert		`ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
3638076b9443SCy Schubert	    if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
3639076b9443SCy Schubert		list="$list /usr/local/include /usr/include"
3640076b9443SCy Schubert		if test x"${TK_INCLUDE_SPEC}" != x ; then
3641076b9443SCy Schubert		    d=`echo "${TK_INCLUDE_SPEC}" | sed -e 's/^-I//'`
3642076b9443SCy Schubert		    list="$list `ls -d ${d} 2>/dev/null`"
3643076b9443SCy Schubert		fi
3644076b9443SCy Schubert	    fi
3645076b9443SCy Schubert	    for i in $list ; do
3646076b9443SCy Schubert		if test -f "$i/tk.h" ; then
3647076b9443SCy Schubert		    ac_cv_c_tkh=$i
3648076b9443SCy Schubert		    break
3649076b9443SCy Schubert		fi
3650076b9443SCy Schubert	    done
3651076b9443SCy Schubert	fi
3652076b9443SCy Schubert    ])
3653076b9443SCy Schubert
3654076b9443SCy Schubert    # Print a message based on how we determined the include path
3655076b9443SCy Schubert
3656076b9443SCy Schubert    if test x"${ac_cv_c_tkh}" = x ; then
3657076b9443SCy Schubert	AC_MSG_ERROR([tk.h not found.  Please specify its location with --with-tkinclude])
3658076b9443SCy Schubert    else
3659076b9443SCy Schubert	AC_MSG_RESULT([${ac_cv_c_tkh}])
3660076b9443SCy Schubert    fi
3661076b9443SCy Schubert
3662076b9443SCy Schubert    # Convert to a native path and substitute into the output files.
3663076b9443SCy Schubert
3664076b9443SCy Schubert    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}`
3665076b9443SCy Schubert
3666076b9443SCy Schubert    TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
3667076b9443SCy Schubert
3668076b9443SCy Schubert    AC_SUBST(TK_INCLUDES)
3669076b9443SCy Schubert
3670076b9443SCy Schubert    if test "${TEA_WINDOWINGSYSTEM}" != "x11"; then
3671076b9443SCy Schubert	# On Windows and Aqua, we need the X compat headers
3672076b9443SCy Schubert	AC_MSG_CHECKING([for X11 header files])
3673076b9443SCy Schubert	if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then
3674076b9443SCy Schubert	    INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`"
3675076b9443SCy Schubert	    TK_XINCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
3676076b9443SCy Schubert	    AC_SUBST(TK_XINCLUDES)
3677076b9443SCy Schubert	fi
3678076b9443SCy Schubert	AC_MSG_RESULT([${INCLUDE_DIR_NATIVE}])
3679076b9443SCy Schubert    fi
3680076b9443SCy Schubert])
3681076b9443SCy Schubert
3682076b9443SCy Schubert#------------------------------------------------------------------------
3683076b9443SCy Schubert# TEA_PATH_CONFIG --
3684076b9443SCy Schubert#
3685076b9443SCy Schubert#	Locate the ${1}Config.sh file and perform a sanity check on
3686076b9443SCy Schubert#	the ${1} compile flags.  These are used by packages like
3687076b9443SCy Schubert#	[incr Tk] that load *Config.sh files from more than Tcl and Tk.
3688076b9443SCy Schubert#
3689076b9443SCy Schubert# Arguments:
3690076b9443SCy Schubert#	none
3691076b9443SCy Schubert#
3692076b9443SCy Schubert# Results:
3693076b9443SCy Schubert#
3694076b9443SCy Schubert#	Adds the following arguments to configure:
3695076b9443SCy Schubert#		--with-$1=...
3696076b9443SCy Schubert#
3697076b9443SCy Schubert#	Defines the following vars:
3698076b9443SCy Schubert#		$1_BIN_DIR	Full path to the directory containing
3699076b9443SCy Schubert#				the $1Config.sh file
3700076b9443SCy Schubert#------------------------------------------------------------------------
3701076b9443SCy Schubert
3702076b9443SCy SchubertAC_DEFUN([TEA_PATH_CONFIG], [
3703076b9443SCy Schubert    #
3704076b9443SCy Schubert    # Ok, lets find the $1 configuration
3705076b9443SCy Schubert    # First, look for one uninstalled.
3706076b9443SCy Schubert    # the alternative search directory is invoked by --with-$1
3707076b9443SCy Schubert    #
3708076b9443SCy Schubert
3709076b9443SCy Schubert    if test x"${no_$1}" = x ; then
3710076b9443SCy Schubert	# we reset no_$1 in case something fails here
3711076b9443SCy Schubert	no_$1=true
3712076b9443SCy Schubert	AC_ARG_WITH($1, [  --with-$1              directory containing $1 configuration ($1Config.sh)], with_$1config=${withval})
3713076b9443SCy Schubert	AC_MSG_CHECKING([for $1 configuration])
3714076b9443SCy Schubert	AC_CACHE_VAL(ac_cv_c_$1config,[
3715076b9443SCy Schubert
3716076b9443SCy Schubert	    # First check to see if --with-$1 was specified.
3717076b9443SCy Schubert	    if test x"${with_$1config}" != x ; then
3718076b9443SCy Schubert		case ${with_$1config} in
3719076b9443SCy Schubert		    */$1Config.sh )
3720076b9443SCy Schubert			if test -f ${with_$1config}; then
3721076b9443SCy Schubert			    AC_MSG_WARN([--with-$1 argument should refer to directory containing $1Config.sh, not to $1Config.sh itself])
3722076b9443SCy Schubert			    with_$1config=`echo ${with_$1config} | sed 's!/$1Config\.sh$!!'`
3723076b9443SCy Schubert			fi;;
3724076b9443SCy Schubert		esac
3725076b9443SCy Schubert		if test -f "${with_$1config}/$1Config.sh" ; then
3726076b9443SCy Schubert		    ac_cv_c_$1config=`(cd ${with_$1config}; pwd)`
3727076b9443SCy Schubert		else
3728076b9443SCy Schubert		    AC_MSG_ERROR([${with_$1config} directory doesn't contain $1Config.sh])
3729076b9443SCy Schubert		fi
3730076b9443SCy Schubert	    fi
3731076b9443SCy Schubert
3732076b9443SCy Schubert	    # then check for a private $1 installation
3733076b9443SCy Schubert	    if test x"${ac_cv_c_$1config}" = x ; then
3734076b9443SCy Schubert		for i in \
3735076b9443SCy Schubert			../$1 \
3736076b9443SCy Schubert			`ls -dr ../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
3737076b9443SCy Schubert			`ls -dr ../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
3738076b9443SCy Schubert			`ls -dr ../$1*[[0-9]].[[0-9]] 2>/dev/null` \
3739076b9443SCy Schubert			`ls -dr ../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
3740076b9443SCy Schubert			../../$1 \
3741076b9443SCy Schubert			`ls -dr ../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
3742076b9443SCy Schubert			`ls -dr ../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
3743076b9443SCy Schubert			`ls -dr ../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
3744076b9443SCy Schubert			`ls -dr ../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
3745076b9443SCy Schubert			../../../$1 \
3746076b9443SCy Schubert			`ls -dr ../../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
3747076b9443SCy Schubert			`ls -dr ../../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
3748076b9443SCy Schubert			`ls -dr ../../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
3749076b9443SCy Schubert			`ls -dr ../../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
3750076b9443SCy Schubert			${srcdir}/../$1 \
3751076b9443SCy Schubert			`ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
3752076b9443SCy Schubert			`ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
3753076b9443SCy Schubert			`ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]] 2>/dev/null` \
3754076b9443SCy Schubert			`ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
3755076b9443SCy Schubert			; do
3756076b9443SCy Schubert		    if test -f "$i/$1Config.sh" ; then
3757076b9443SCy Schubert			ac_cv_c_$1config=`(cd $i; pwd)`
3758076b9443SCy Schubert			break
3759076b9443SCy Schubert		    fi
3760076b9443SCy Schubert		    if test -f "$i/unix/$1Config.sh" ; then
3761076b9443SCy Schubert			ac_cv_c_$1config=`(cd $i/unix; pwd)`
3762076b9443SCy Schubert			break
3763076b9443SCy Schubert		    fi
3764076b9443SCy Schubert		done
3765076b9443SCy Schubert	    fi
3766076b9443SCy Schubert
3767076b9443SCy Schubert	    # check in a few common install locations
3768076b9443SCy Schubert	    if test x"${ac_cv_c_$1config}" = x ; then
3769076b9443SCy Schubert		for i in `ls -d ${libdir} 2>/dev/null` \
3770076b9443SCy Schubert			`ls -d ${exec_prefix}/lib 2>/dev/null` \
3771076b9443SCy Schubert			`ls -d ${prefix}/lib 2>/dev/null` \
3772076b9443SCy Schubert			`ls -d /usr/local/lib 2>/dev/null` \
3773076b9443SCy Schubert			`ls -d /usr/contrib/lib 2>/dev/null` \
3774*00787218SCy Schubert			`ls -d /usr/pkg/lib 2>/dev/null` \
3775076b9443SCy Schubert			`ls -d /usr/lib 2>/dev/null` \
3776076b9443SCy Schubert			`ls -d /usr/lib64 2>/dev/null` \
3777076b9443SCy Schubert			; do
3778076b9443SCy Schubert		    if test -f "$i/$1Config.sh" ; then
3779076b9443SCy Schubert			ac_cv_c_$1config=`(cd $i; pwd)`
3780076b9443SCy Schubert			break
3781076b9443SCy Schubert		    fi
3782076b9443SCy Schubert		done
3783076b9443SCy Schubert	    fi
3784076b9443SCy Schubert	])
3785076b9443SCy Schubert
3786076b9443SCy Schubert	if test x"${ac_cv_c_$1config}" = x ; then
3787076b9443SCy Schubert	    $1_BIN_DIR="# no $1 configs found"
3788076b9443SCy Schubert	    AC_MSG_WARN([Cannot find $1 configuration definitions])
3789076b9443SCy Schubert	    exit 0
3790076b9443SCy Schubert	else
3791076b9443SCy Schubert	    no_$1=
3792076b9443SCy Schubert	    $1_BIN_DIR=${ac_cv_c_$1config}
3793076b9443SCy Schubert	    AC_MSG_RESULT([found $$1_BIN_DIR/$1Config.sh])
3794076b9443SCy Schubert	fi
3795076b9443SCy Schubert    fi
3796076b9443SCy Schubert])
3797076b9443SCy Schubert
3798076b9443SCy Schubert#------------------------------------------------------------------------
3799076b9443SCy Schubert# TEA_LOAD_CONFIG --
3800076b9443SCy Schubert#
3801076b9443SCy Schubert#	Load the $1Config.sh file
3802076b9443SCy Schubert#
3803076b9443SCy Schubert# Arguments:
3804076b9443SCy Schubert#
3805076b9443SCy Schubert#	Requires the following vars to be set:
3806076b9443SCy Schubert#		$1_BIN_DIR
3807076b9443SCy Schubert#
3808076b9443SCy Schubert# Results:
3809076b9443SCy Schubert#
3810076b9443SCy Schubert#	Substitutes the following vars:
3811076b9443SCy Schubert#		$1_SRC_DIR
3812076b9443SCy Schubert#		$1_LIB_FILE
3813076b9443SCy Schubert#		$1_LIB_SPEC
3814076b9443SCy Schubert#------------------------------------------------------------------------
3815076b9443SCy Schubert
3816076b9443SCy SchubertAC_DEFUN([TEA_LOAD_CONFIG], [
3817076b9443SCy Schubert    AC_MSG_CHECKING([for existence of ${$1_BIN_DIR}/$1Config.sh])
3818076b9443SCy Schubert
3819076b9443SCy Schubert    if test -f "${$1_BIN_DIR}/$1Config.sh" ; then
3820076b9443SCy Schubert        AC_MSG_RESULT([loading])
3821076b9443SCy Schubert	. "${$1_BIN_DIR}/$1Config.sh"
3822076b9443SCy Schubert    else
3823076b9443SCy Schubert        AC_MSG_RESULT([file not found])
3824076b9443SCy Schubert    fi
3825076b9443SCy Schubert
3826076b9443SCy Schubert    #
3827076b9443SCy Schubert    # If the $1_BIN_DIR is the build directory (not the install directory),
3828076b9443SCy Schubert    # then set the common variable name to the value of the build variables.
3829076b9443SCy Schubert    # For example, the variable $1_LIB_SPEC will be set to the value
3830076b9443SCy Schubert    # of $1_BUILD_LIB_SPEC. An extension should make use of $1_LIB_SPEC
3831076b9443SCy Schubert    # instead of $1_BUILD_LIB_SPEC since it will work with both an
3832076b9443SCy Schubert    # installed and uninstalled version of Tcl.
3833076b9443SCy Schubert    #
3834076b9443SCy Schubert
3835076b9443SCy Schubert    if test -f "${$1_BIN_DIR}/Makefile" ; then
3836076b9443SCy Schubert	AC_MSG_WARN([Found Makefile - using build library specs for $1])
3837076b9443SCy Schubert        $1_LIB_SPEC=${$1_BUILD_LIB_SPEC}
3838076b9443SCy Schubert        $1_STUB_LIB_SPEC=${$1_BUILD_STUB_LIB_SPEC}
3839076b9443SCy Schubert        $1_STUB_LIB_PATH=${$1_BUILD_STUB_LIB_PATH}
3840076b9443SCy Schubert        $1_INCLUDE_SPEC=${$1_BUILD_INCLUDE_SPEC}
3841076b9443SCy Schubert        $1_LIBRARY_PATH=${$1_LIBRARY_PATH}
3842076b9443SCy Schubert    fi
3843076b9443SCy Schubert
3844076b9443SCy Schubert    AC_SUBST($1_VERSION)
3845076b9443SCy Schubert    AC_SUBST($1_BIN_DIR)
3846076b9443SCy Schubert    AC_SUBST($1_SRC_DIR)
3847076b9443SCy Schubert
3848076b9443SCy Schubert    AC_SUBST($1_LIB_FILE)
3849076b9443SCy Schubert    AC_SUBST($1_LIB_SPEC)
3850076b9443SCy Schubert
3851076b9443SCy Schubert    AC_SUBST($1_STUB_LIB_FILE)
3852076b9443SCy Schubert    AC_SUBST($1_STUB_LIB_SPEC)
3853076b9443SCy Schubert    AC_SUBST($1_STUB_LIB_PATH)
3854076b9443SCy Schubert
3855076b9443SCy Schubert    # Allow the caller to prevent this auto-check by specifying any 2nd arg
3856076b9443SCy Schubert    AS_IF([test "x$2" = x], [
3857076b9443SCy Schubert	# Check both upper and lower-case variants
3858076b9443SCy Schubert	# If a dev wanted non-stubs libs, this function could take an option
3859076b9443SCy Schubert	# to not use _STUB in the paths below
3860076b9443SCy Schubert	AS_IF([test "x${$1_STUB_LIB_SPEC}" = x],
3861076b9443SCy Schubert	    [TEA_LOAD_CONFIG_LIB(translit($1,[a-z],[A-Z])_STUB)],
3862076b9443SCy Schubert	    [TEA_LOAD_CONFIG_LIB($1_STUB)])
3863076b9443SCy Schubert    ])
3864076b9443SCy Schubert])
3865076b9443SCy Schubert
3866076b9443SCy Schubert#------------------------------------------------------------------------
3867076b9443SCy Schubert# TEA_LOAD_CONFIG_LIB --
3868076b9443SCy Schubert#
3869076b9443SCy Schubert#	Helper function to load correct library from another extension's
3870076b9443SCy Schubert#	${PACKAGE}Config.sh.
3871076b9443SCy Schubert#
3872076b9443SCy Schubert# Results:
3873076b9443SCy Schubert#	Adds to LIBS the appropriate extension library
3874076b9443SCy Schubert#------------------------------------------------------------------------
3875076b9443SCy SchubertAC_DEFUN([TEA_LOAD_CONFIG_LIB], [
3876076b9443SCy Schubert    AC_MSG_CHECKING([For $1 library for LIBS])
3877076b9443SCy Schubert    # This simplifies the use of stub libraries by automatically adding
3878076b9443SCy Schubert    # the stub lib to your path.  Normally this would add to SHLIB_LD_LIBS,
3879076b9443SCy Schubert    # but this is called before CONFIG_CFLAGS.  More importantly, this adds
3880076b9443SCy Schubert    # to PKG_LIBS, which becomes LIBS, and that is only used by SHLIB_LD.
3881076b9443SCy Schubert    if test "x${$1_LIB_SPEC}" != "x" ; then
3882076b9443SCy Schubert	if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes" ; then
3883076b9443SCy Schubert	    TEA_ADD_LIBS([\"`${CYGPATH} ${$1_LIB_PATH}`\"])
3884076b9443SCy Schubert	    AC_MSG_RESULT([using $1_LIB_PATH ${$1_LIB_PATH}])
3885076b9443SCy Schubert	else
3886076b9443SCy Schubert	    TEA_ADD_LIBS([${$1_LIB_SPEC}])
3887076b9443SCy Schubert	    AC_MSG_RESULT([using $1_LIB_SPEC ${$1_LIB_SPEC}])
3888076b9443SCy Schubert	fi
3889076b9443SCy Schubert    else
3890076b9443SCy Schubert	AC_MSG_RESULT([file not found])
3891076b9443SCy Schubert    fi
3892076b9443SCy Schubert])
3893076b9443SCy Schubert
3894076b9443SCy Schubert#------------------------------------------------------------------------
3895076b9443SCy Schubert# TEA_EXPORT_CONFIG --
3896076b9443SCy Schubert#
3897076b9443SCy Schubert#	Define the data to insert into the ${PACKAGE}Config.sh file
3898076b9443SCy Schubert#
3899076b9443SCy Schubert# Arguments:
3900076b9443SCy Schubert#
3901076b9443SCy Schubert#	Requires the following vars to be set:
3902076b9443SCy Schubert#		$1
3903076b9443SCy Schubert#
3904076b9443SCy Schubert# Results:
3905076b9443SCy Schubert#	Substitutes the following vars:
3906076b9443SCy Schubert#------------------------------------------------------------------------
3907076b9443SCy Schubert
3908076b9443SCy SchubertAC_DEFUN([TEA_EXPORT_CONFIG], [
3909076b9443SCy Schubert    #--------------------------------------------------------------------
3910076b9443SCy Schubert    # These are for $1Config.sh
3911076b9443SCy Schubert    #--------------------------------------------------------------------
3912076b9443SCy Schubert
3913076b9443SCy Schubert    # pkglibdir must be a fully qualified path and (not ${exec_prefix}/lib)
3914076b9443SCy Schubert    eval pkglibdir="[$]{libdir}/$1${PACKAGE_VERSION}"
3915076b9443SCy Schubert    if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
3916*00787218SCy Schubert	eval $1_LIB_FLAG="-l$1${PACKAGE_VERSION}"
3917*00787218SCy Schubert	eval $1_STUB_LIB_FLAG="-l$1stub${PACKAGE_VERSION}"
3918076b9443SCy Schubert    else
3919*00787218SCy Schubert	eval $1_LIB_FLAG="-l$1`echo ${PACKAGE_VERSION} | tr -d .`"
3920*00787218SCy Schubert	eval $1_STUB_LIB_FLAG="-l$1stub`echo ${PACKAGE_VERSION} | tr -d .`"
3921076b9443SCy Schubert    fi
3922*00787218SCy Schubert    $1_BUILD_LIB_SPEC="-L`$CYGPATH $(pwd)` ${$1_LIB_FLAG}"
3923*00787218SCy Schubert    $1_LIB_SPEC="-L`$CYGPATH ${pkglibdir}` ${$1_LIB_FLAG}"
3924*00787218SCy Schubert    $1_BUILD_STUB_LIB_SPEC="-L`$CYGPATH $(pwd)` [$]{$1_STUB_LIB_FLAG}"
3925*00787218SCy Schubert    $1_STUB_LIB_SPEC="-L`$CYGPATH ${pkglibdir}` [$]{$1_STUB_LIB_FLAG}"
3926*00787218SCy Schubert    $1_BUILD_STUB_LIB_PATH="`$CYGPATH $(pwd)`/[$]{PKG_STUB_LIB_FILE}"
3927*00787218SCy Schubert    $1_STUB_LIB_PATH="`$CYGPATH ${pkglibdir}`/[$]{PKG_STUB_LIB_FILE}"
3928076b9443SCy Schubert
3929076b9443SCy Schubert    AC_SUBST($1_BUILD_LIB_SPEC)
3930076b9443SCy Schubert    AC_SUBST($1_LIB_SPEC)
3931076b9443SCy Schubert    AC_SUBST($1_BUILD_STUB_LIB_SPEC)
3932076b9443SCy Schubert    AC_SUBST($1_STUB_LIB_SPEC)
3933076b9443SCy Schubert    AC_SUBST($1_BUILD_STUB_LIB_PATH)
3934076b9443SCy Schubert    AC_SUBST($1_STUB_LIB_PATH)
3935076b9443SCy Schubert
3936076b9443SCy Schubert    AC_SUBST(MAJOR_VERSION)
3937076b9443SCy Schubert    AC_SUBST(MINOR_VERSION)
3938076b9443SCy Schubert    AC_SUBST(PATCHLEVEL)
3939076b9443SCy Schubert])
3940076b9443SCy Schubert
3941076b9443SCy Schubert
3942076b9443SCy Schubert#------------------------------------------------------------------------
3943*00787218SCy Schubert# TEA_INSTALLER --
3944076b9443SCy Schubert#
3945*00787218SCy Schubert#	Configure the installer.
3946076b9443SCy Schubert#
3947076b9443SCy Schubert# Arguments:
3948076b9443SCy Schubert#	none
3949076b9443SCy Schubert#
3950076b9443SCy Schubert# Results:
3951*00787218SCy Schubert#	Substitutes the following vars:
3952*00787218SCy Schubert#		INSTALL
3953*00787218SCy Schubert#		INSTALL_DATA_DIR
3954*00787218SCy Schubert#		INSTALL_DATA
3955*00787218SCy Schubert#		INSTALL_PROGRAM
3956*00787218SCy Schubert#		INSTALL_SCRIPT
3957*00787218SCy Schubert#		INSTALL_LIBRARY
3958076b9443SCy Schubert#------------------------------------------------------------------------
3959076b9443SCy Schubert
3960*00787218SCy SchubertAC_DEFUN([TEA_INSTALLER], [
3961*00787218SCy Schubert    INSTALL='$(SHELL) $(srcdir)/tclconfig/install-sh -c'
3962*00787218SCy Schubert    INSTALL_DATA_DIR='${INSTALL} -d -m 755'
3963*00787218SCy Schubert    INSTALL_DATA='${INSTALL} -m 644'
3964*00787218SCy Schubert    INSTALL_PROGRAM='${INSTALL} -m 755'
3965*00787218SCy Schubert    INSTALL_SCRIPT='${INSTALL} -m 755'
3966076b9443SCy Schubert
3967*00787218SCy Schubert    TEA_CONFIG_SYSTEM
3968*00787218SCy Schubert    case $system in
3969*00787218SCy Schubert	HP-UX-*) INSTALL_LIBRARY='${INSTALL} -m 755' ;;
3970*00787218SCy Schubert	      *) INSTALL_LIBRARY='${INSTALL} -m 644' ;;
3971*00787218SCy Schubert    esac
3972076b9443SCy Schubert
3973*00787218SCy Schubert    AC_SUBST(INSTALL)
3974*00787218SCy Schubert    AC_SUBST(INSTALL_DATA_DIR)
3975*00787218SCy Schubert    AC_SUBST(INSTALL_DATA)
3976*00787218SCy Schubert    AC_SUBST(INSTALL_PROGRAM)
3977*00787218SCy Schubert    AC_SUBST(INSTALL_SCRIPT)
3978*00787218SCy Schubert    AC_SUBST(INSTALL_LIBRARY)
3979*00787218SCy Schubert])
3980*00787218SCy Schubert
3981*00787218SCy Schubert###
3982*00787218SCy Schubert# Tip 430 - ZipFS Modifications
3983*00787218SCy Schubert###
3984*00787218SCy Schubert#------------------------------------------------------------------------
3985*00787218SCy Schubert# TEA_ZIPFS_SUPPORT
3986*00787218SCy Schubert#	Locate a zip encoder installed on the system path, or none.
3987*00787218SCy Schubert#
3988*00787218SCy Schubert# Arguments:
3989*00787218SCy Schubert#	none
3990*00787218SCy Schubert#
3991*00787218SCy Schubert# Results:
3992*00787218SCy Schubert#	Substitutes the following vars:
3993*00787218SCy Schubert#       MACHER_PROG
3994*00787218SCy Schubert#       ZIP_PROG
3995*00787218SCy Schubert#       ZIP_PROG_OPTIONS
3996*00787218SCy Schubert#       ZIP_PROG_VFSSEARCH
3997*00787218SCy Schubert#       ZIP_INSTALL_OBJS
3998*00787218SCy Schubert#------------------------------------------------------------------------
3999*00787218SCy Schubert
4000*00787218SCy SchubertAC_DEFUN([TEA_ZIPFS_SUPPORT], [
4001*00787218SCy Schubert    MACHER_PROG=""
4002*00787218SCy Schubert    ZIP_PROG=""
4003*00787218SCy Schubert    ZIP_PROG_OPTIONS=""
4004*00787218SCy Schubert    ZIP_PROG_VFSSEARCH=""
4005*00787218SCy Schubert    ZIP_INSTALL_OBJS=""
4006*00787218SCy Schubert
4007*00787218SCy Schubert    AC_MSG_CHECKING([for macher])
4008*00787218SCy Schubert    AC_CACHE_VAL(ac_cv_path_macher, [
4009*00787218SCy Schubert    search_path=`echo ${PATH} | sed -e 's/:/ /g'`
4010*00787218SCy Schubert    for dir in $search_path ; do
4011*00787218SCy Schubert        for j in `ls -r $dir/macher 2> /dev/null` \
4012*00787218SCy Schubert            `ls -r $dir/macher 2> /dev/null` ; do
4013*00787218SCy Schubert        if test x"$ac_cv_path_macher" = x ; then
4014*00787218SCy Schubert            if test -f "$j" ; then
4015*00787218SCy Schubert            ac_cv_path_macher=$j
4016076b9443SCy Schubert            break
4017076b9443SCy Schubert            fi
4018*00787218SCy Schubert        fi
4019076b9443SCy Schubert        done
4020*00787218SCy Schubert    done
4021076b9443SCy Schubert    ])
4022*00787218SCy Schubert    if test -f "$ac_cv_path_macher" ; then
4023*00787218SCy Schubert        MACHER_PROG="$ac_cv_path_macher"
4024*00787218SCy Schubert        AC_MSG_RESULT([$MACHER_PROG])
4025*00787218SCy Schubert        AC_MSG_RESULT([Found macher in environment])
4026*00787218SCy Schubert    fi
4027*00787218SCy Schubert    AC_MSG_CHECKING([for zip])
4028*00787218SCy Schubert    AC_CACHE_VAL(ac_cv_path_zip, [
4029*00787218SCy Schubert    search_path=`echo ${PATH} | sed -e 's/:/ /g'`
4030*00787218SCy Schubert    for dir in $search_path ; do
4031*00787218SCy Schubert        for j in `ls -r $dir/zip 2> /dev/null` \
4032*00787218SCy Schubert            `ls -r $dir/zip 2> /dev/null` ; do
4033*00787218SCy Schubert        if test x"$ac_cv_path_zip" = x ; then
4034*00787218SCy Schubert            if test -f "$j" ; then
4035*00787218SCy Schubert            ac_cv_path_zip=$j
4036*00787218SCy Schubert            break
4037*00787218SCy Schubert            fi
4038*00787218SCy Schubert        fi
4039*00787218SCy Schubert        done
4040*00787218SCy Schubert    done
4041*00787218SCy Schubert    ])
4042*00787218SCy Schubert    if test -f "$ac_cv_path_zip" ; then
4043*00787218SCy Schubert        ZIP_PROG="$ac_cv_path_zip"
4044*00787218SCy Schubert        AC_MSG_RESULT([$ZIP_PROG])
4045*00787218SCy Schubert        ZIP_PROG_OPTIONS="-rq"
4046*00787218SCy Schubert        ZIP_PROG_VFSSEARCH="*"
4047*00787218SCy Schubert        AC_MSG_RESULT([Found INFO Zip in environment])
4048*00787218SCy Schubert        # Use standard arguments for zip
4049076b9443SCy Schubert    else
4050*00787218SCy Schubert        # It is not an error if an installed version of Zip can't be located.
4051*00787218SCy Schubert        # We can use the locally distributed minizip instead
4052*00787218SCy Schubert        ZIP_PROG="./minizip${EXEEXT_FOR_BUILD}"
4053*00787218SCy Schubert        ZIP_PROG_OPTIONS="-o -r"
4054*00787218SCy Schubert        ZIP_PROG_VFSSEARCH="*"
4055*00787218SCy Schubert        ZIP_INSTALL_OBJS="minizip${EXEEXT_FOR_BUILD}"
4056*00787218SCy Schubert        AC_MSG_RESULT([No zip found on PATH. Building minizip])
4057076b9443SCy Schubert    fi
4058*00787218SCy Schubert    AC_SUBST(MACHER_PROG)
4059*00787218SCy Schubert    AC_SUBST(ZIP_PROG)
4060*00787218SCy Schubert    AC_SUBST(ZIP_PROG_OPTIONS)
4061*00787218SCy Schubert    AC_SUBST(ZIP_PROG_VFSSEARCH)
4062*00787218SCy Schubert    AC_SUBST(ZIP_INSTALL_OBJS)
4063076b9443SCy Schubert])
4064*00787218SCy Schubert
4065076b9443SCy Schubert# Local Variables:
4066076b9443SCy Schubert# mode: autoconf
4067076b9443SCy Schubert# End: