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