1*440a403fSchristos#------------------------------------------------------------------------
2*440a403fSchristos# SC_PATH_TCLCONFIG --
3*440a403fSchristos#
4*440a403fSchristos#	Locate the tclConfig.sh file and perform a sanity check on
5*440a403fSchristos#	the Tcl compile flags
6*440a403fSchristos#
7*440a403fSchristos# Arguments:
8*440a403fSchristos#	none
9*440a403fSchristos#
10*440a403fSchristos# Results:
11*440a403fSchristos#
12*440a403fSchristos#	Adds the following arguments to configure:
13*440a403fSchristos#		--with-tcl=...
14*440a403fSchristos#
15*440a403fSchristos#	Defines the following vars:
16*440a403fSchristos#		TCL_BIN_DIR	Full path to the directory containing
17*440a403fSchristos#				the tclConfig.sh file
18*440a403fSchristos#------------------------------------------------------------------------
19*440a403fSchristos
20*440a403fSchristosAC_DEFUN([SC_PATH_TCLCONFIG], [
21*440a403fSchristos    #
22*440a403fSchristos    # Ok, lets find the tcl configuration
23*440a403fSchristos    # First, look for one uninstalled.
24*440a403fSchristos    # the alternative search directory is invoked by --with-tcl
25*440a403fSchristos    #
26*440a403fSchristos
27*440a403fSchristos    if test x"${no_tcl}" = x ; then
28*440a403fSchristos	# we reset no_tcl in case something fails here
29*440a403fSchristos	no_tcl=true
30*440a403fSchristos	AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
31*440a403fSchristos	AC_MSG_CHECKING([for Tcl configuration])
32*440a403fSchristos	AC_CACHE_VAL(ac_cv_c_tclconfig,[
33*440a403fSchristos
34*440a403fSchristos	    # First check to see if --with-tcl was specified.
35*440a403fSchristos	    case "${host}" in
36*440a403fSchristos		*-*-cygwin*) platDir="win" ;;
37*440a403fSchristos		*) platDir="unix" ;;
38*440a403fSchristos	    esac
39*440a403fSchristos	    if test x"${with_tclconfig}" != x ; then
40*440a403fSchristos		if test -f "${with_tclconfig}/tclConfig.sh" ; then
41*440a403fSchristos		    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
42*440a403fSchristos		else
43*440a403fSchristos		    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
44*440a403fSchristos		fi
45*440a403fSchristos	    fi
46*440a403fSchristos
47*440a403fSchristos	    # then check for a private Tcl installation
48*440a403fSchristos	    if test x"${ac_cv_c_tclconfig}" = x ; then
49*440a403fSchristos		for i in \
50*440a403fSchristos			../tcl \
51*440a403fSchristos			`ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
52*440a403fSchristos			`ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
53*440a403fSchristos			`ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
54*440a403fSchristos			../../tcl \
55*440a403fSchristos			`ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
56*440a403fSchristos			`ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
57*440a403fSchristos			`ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
58*440a403fSchristos			../../../tcl \
59*440a403fSchristos			`ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
60*440a403fSchristos			`ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
61*440a403fSchristos			`ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
62*440a403fSchristos		    if test -f "$i/$platDir/tclConfig.sh" ; then
63*440a403fSchristos			ac_cv_c_tclconfig=`(cd $i/$platDir; pwd)`
64*440a403fSchristos			break
65*440a403fSchristos		    fi
66*440a403fSchristos		done
67*440a403fSchristos	    fi
68*440a403fSchristos
69*440a403fSchristos	    # on Darwin, check in Framework installation locations
70*440a403fSchristos	    if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
71*440a403fSchristos		for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
72*440a403fSchristos			`ls -d /Library/Frameworks 2>/dev/null` \
73*440a403fSchristos			`ls -d /Network/Library/Frameworks 2>/dev/null` \
74*440a403fSchristos			`ls -d /System/Library/Frameworks 2>/dev/null` \
75*440a403fSchristos			; do
76*440a403fSchristos		    if test -f "$i/Tcl.framework/tclConfig.sh" ; then
77*440a403fSchristos			ac_cv_c_tclconfig=`(cd $i/Tcl.framework; pwd)`
78*440a403fSchristos			break
79*440a403fSchristos		    fi
80*440a403fSchristos		done
81*440a403fSchristos	    fi
82*440a403fSchristos
83*440a403fSchristos	    # check in a few common install locations
84*440a403fSchristos	    if test x"${ac_cv_c_tclconfig}" = x ; then
85*440a403fSchristos		for i in `ls -d ${libdir} 2>/dev/null` \
86*440a403fSchristos			`ls -d ${exec_prefix}/lib 2>/dev/null` \
87*440a403fSchristos			`ls -d ${prefix}/lib 2>/dev/null` \
88*440a403fSchristos			`ls -d /usr/local/lib 2>/dev/null` \
89*440a403fSchristos			`ls -d /usr/contrib/lib 2>/dev/null` \
90*440a403fSchristos			`ls -d /usr/lib 2>/dev/null` \
91*440a403fSchristos			; do
92*440a403fSchristos		    if test -f "$i/tclConfig.sh" ; then
93*440a403fSchristos			ac_cv_c_tclconfig=`(cd $i; pwd)`
94*440a403fSchristos			break
95*440a403fSchristos		    fi
96*440a403fSchristos		done
97*440a403fSchristos	    fi
98*440a403fSchristos
99*440a403fSchristos	    # check in a few other private locations
100*440a403fSchristos	    if test x"${ac_cv_c_tclconfig}" = x ; then
101*440a403fSchristos		for i in \
102*440a403fSchristos			${srcdir}/../tcl \
103*440a403fSchristos			`ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
104*440a403fSchristos			`ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
105*440a403fSchristos			`ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
106*440a403fSchristos		    if test -f "$i/$platDir/tclConfig.sh" ; then
107*440a403fSchristos		    ac_cv_c_tclconfig=`(cd $i/$platDir; pwd)`
108*440a403fSchristos		    break
109*440a403fSchristos		fi
110*440a403fSchristos		done
111*440a403fSchristos	    fi
112*440a403fSchristos	])
113*440a403fSchristos
114*440a403fSchristos	if test x"${ac_cv_c_tclconfig}" = x ; then
115*440a403fSchristos	    TCL_BIN_DIR="# no Tcl configs found"
116*440a403fSchristos	    AC_MSG_WARN([Can't find Tcl configuration definitions])
117*440a403fSchristos	else
118*440a403fSchristos	    no_tcl=
119*440a403fSchristos	    TCL_BIN_DIR=${ac_cv_c_tclconfig}
120*440a403fSchristos	    AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
121*440a403fSchristos	fi
122*440a403fSchristos    fi
123*440a403fSchristos])
124*440a403fSchristos
125*440a403fSchristos#------------------------------------------------------------------------
126*440a403fSchristos# SC_PATH_TKCONFIG --
127*440a403fSchristos#
128*440a403fSchristos#	Locate the tkConfig.sh file
129*440a403fSchristos#
130*440a403fSchristos# Arguments:
131*440a403fSchristos#	none
132*440a403fSchristos#
133*440a403fSchristos# Results:
134*440a403fSchristos#
135*440a403fSchristos#	Adds the following arguments to configure:
136*440a403fSchristos#		--with-tk=...
137*440a403fSchristos#
138*440a403fSchristos#	Defines the following vars:
139*440a403fSchristos#		TK_BIN_DIR	Full path to the directory containing
140*440a403fSchristos#				the tkConfig.sh file
141*440a403fSchristos#------------------------------------------------------------------------
142*440a403fSchristos
143*440a403fSchristosAC_DEFUN([SC_PATH_TKCONFIG], [
144*440a403fSchristos    #
145*440a403fSchristos    # Ok, lets find the tk configuration
146*440a403fSchristos    # First, look for one uninstalled.
147*440a403fSchristos    # the alternative search directory is invoked by --with-tk
148*440a403fSchristos    #
149*440a403fSchristos
150*440a403fSchristos    if test x"${no_tk}" = x ; then
151*440a403fSchristos	# we reset no_tk in case something fails here
152*440a403fSchristos	no_tk=true
153*440a403fSchristos	AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
154*440a403fSchristos	AC_MSG_CHECKING([for Tk configuration])
155*440a403fSchristos	AC_CACHE_VAL(ac_cv_c_tkconfig,[
156*440a403fSchristos
157*440a403fSchristos	    # First check to see if --with-tkconfig was specified.
158*440a403fSchristos	    if test x"${with_tkconfig}" != x ; then
159*440a403fSchristos		if test -f "${with_tkconfig}/tkConfig.sh" ; then
160*440a403fSchristos		    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
161*440a403fSchristos		else
162*440a403fSchristos		    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
163*440a403fSchristos		fi
164*440a403fSchristos	    fi
165*440a403fSchristos
166*440a403fSchristos	    # then check for a private Tk library
167*440a403fSchristos	    case "${host}" in
168*440a403fSchristos		*-*-cygwin*) platDir="win" ;;
169*440a403fSchristos		*) platDir="unix" ;;
170*440a403fSchristos	    esac
171*440a403fSchristos	    if test x"${ac_cv_c_tkconfig}" = x ; then
172*440a403fSchristos		for i in \
173*440a403fSchristos			../tk \
174*440a403fSchristos			`ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
175*440a403fSchristos			`ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
176*440a403fSchristos			`ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
177*440a403fSchristos			../../tk \
178*440a403fSchristos			`ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
179*440a403fSchristos			`ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
180*440a403fSchristos			`ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
181*440a403fSchristos			../../../tk \
182*440a403fSchristos			`ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
183*440a403fSchristos			`ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
184*440a403fSchristos			`ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
185*440a403fSchristos		    if test -f "$i/$platDir/tkConfig.sh" ; then
186*440a403fSchristos			ac_cv_c_tkconfig=`(cd $i/$platDir; pwd)`
187*440a403fSchristos			break
188*440a403fSchristos		    fi
189*440a403fSchristos		done
190*440a403fSchristos	    fi
191*440a403fSchristos
192*440a403fSchristos	    # on Darwin, check in Framework installation locations
193*440a403fSchristos	    if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then
194*440a403fSchristos		for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
195*440a403fSchristos			`ls -d /Library/Frameworks 2>/dev/null` \
196*440a403fSchristos			`ls -d /Network/Library/Frameworks 2>/dev/null` \
197*440a403fSchristos			`ls -d /System/Library/Frameworks 2>/dev/null` \
198*440a403fSchristos			; do
199*440a403fSchristos		    if test -f "$i/Tk.framework/tkConfig.sh" ; then
200*440a403fSchristos			ac_cv_c_tkconfig=`(cd $i/Tk.framework; pwd)`
201*440a403fSchristos			break
202*440a403fSchristos		    fi
203*440a403fSchristos		done
204*440a403fSchristos	    fi
205*440a403fSchristos
206*440a403fSchristos	    # check in a few common install locations
207*440a403fSchristos	    if test x"${ac_cv_c_tkconfig}" = x ; then
208*440a403fSchristos		for i in `ls -d ${libdir} 2>/dev/null` \
209*440a403fSchristos			`ls -d ${exec_prefix}/lib 2>/dev/null` \
210*440a403fSchristos			`ls -d ${prefix}/lib 2>/dev/null` \
211*440a403fSchristos			`ls -d /usr/local/lib 2>/dev/null` \
212*440a403fSchristos			`ls -d /usr/contrib/lib 2>/dev/null` \
213*440a403fSchristos			`ls -d /usr/lib 2>/dev/null` \
214*440a403fSchristos			; do
215*440a403fSchristos		    if test -f "$i/tkConfig.sh" ; then
216*440a403fSchristos			ac_cv_c_tkconfig=`(cd $i; pwd)`
217*440a403fSchristos			break
218*440a403fSchristos		    fi
219*440a403fSchristos		done
220*440a403fSchristos	    fi
221*440a403fSchristos	    # check in a few other private locations
222*440a403fSchristos	    if test x"${ac_cv_c_tkconfig}" = x ; then
223*440a403fSchristos		for i in \
224*440a403fSchristos			${srcdir}/../tk \
225*440a403fSchristos			`ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
226*440a403fSchristos			`ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
227*440a403fSchristos			`ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
228*440a403fSchristos		    if test -f "$i/$platDir/tkConfig.sh" ; then
229*440a403fSchristos			ac_cv_c_tkconfig=`(cd $i/$platDir; pwd)`
230*440a403fSchristos			break
231*440a403fSchristos		    fi
232*440a403fSchristos		done
233*440a403fSchristos	    fi
234*440a403fSchristos	])
235*440a403fSchristos
236*440a403fSchristos	if test x"${ac_cv_c_tkconfig}" = x ; then
237*440a403fSchristos	    TK_BIN_DIR="# no Tk configs found"
238*440a403fSchristos	    AC_MSG_WARN([Can't find Tk configuration definitions])
239*440a403fSchristos	else
240*440a403fSchristos	    no_tk=
241*440a403fSchristos	    TK_BIN_DIR=${ac_cv_c_tkconfig}
242*440a403fSchristos	    AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
243*440a403fSchristos	fi
244*440a403fSchristos    fi
245*440a403fSchristos])
246*440a403fSchristos
247*440a403fSchristos#------------------------------------------------------------------------
248*440a403fSchristos# SC_LOAD_TCLCONFIG --
249*440a403fSchristos#
250*440a403fSchristos#	Load the tclConfig.sh file
251*440a403fSchristos#
252*440a403fSchristos# Arguments:
253*440a403fSchristos#
254*440a403fSchristos#	Requires the following vars to be set:
255*440a403fSchristos#		TCL_BIN_DIR
256*440a403fSchristos#
257*440a403fSchristos# Results:
258*440a403fSchristos#
259*440a403fSchristos#	Subst the following vars:
260*440a403fSchristos#		TCL_BIN_DIR
261*440a403fSchristos#		TCL_SRC_DIR
262*440a403fSchristos#		TCL_LIB_FILE
263*440a403fSchristos#
264*440a403fSchristos#------------------------------------------------------------------------
265*440a403fSchristos
266*440a403fSchristosAC_DEFUN([SC_LOAD_TCLCONFIG], [
267*440a403fSchristos    AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
268*440a403fSchristos
269*440a403fSchristos    if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
270*440a403fSchristos        AC_MSG_RESULT([loading])
271*440a403fSchristos	. ${TCL_BIN_DIR}/tclConfig.sh
272*440a403fSchristos    else
273*440a403fSchristos        AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
274*440a403fSchristos    fi
275*440a403fSchristos
276*440a403fSchristos    # eval is required to do the TCL_DBGX substitution
277*440a403fSchristos    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
278*440a403fSchristos    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
279*440a403fSchristos
280*440a403fSchristos    # If the TCL_BIN_DIR is the build directory (not the install directory),
281*440a403fSchristos    # then set the common variable name to the value of the build variables.
282*440a403fSchristos    # For example, the variable TCL_LIB_SPEC will be set to the value
283*440a403fSchristos    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
284*440a403fSchristos    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
285*440a403fSchristos    # installed and uninstalled version of Tcl.
286*440a403fSchristos    if test -f "${TCL_BIN_DIR}/Makefile" ; then
287*440a403fSchristos        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
288*440a403fSchristos        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
289*440a403fSchristos        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
290*440a403fSchristos    elif test "`uname -s`" = "Darwin"; then
291*440a403fSchristos	# If Tcl was built as a framework, attempt to use the libraries
292*440a403fSchristos	# from the framework at the given location so that linking works
293*440a403fSchristos	# against Tcl.framework installed in an arbitrary location.
294*440a403fSchristos	case ${TCL_DEFS} in
295*440a403fSchristos	    *TCL_FRAMEWORK*)
296*440a403fSchristos		if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then
297*440a403fSchristos		    for i in "`cd ${TCL_BIN_DIR}; pwd`" \
298*440a403fSchristos			     "`cd ${TCL_BIN_DIR}/../..; pwd`"; do
299*440a403fSchristos			if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
300*440a403fSchristos			    TCL_LIB_SPEC="-F`dirname "$i"` -framework ${TCL_LIB_FILE}"
301*440a403fSchristos			    break
302*440a403fSchristos			fi
303*440a403fSchristos		    done
304*440a403fSchristos		fi
305*440a403fSchristos		if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then
306*440a403fSchristos		    TCL_STUB_LIB_SPEC="-L${TCL_BIN_DIR} ${TCL_STUB_LIB_FLAG}"
307*440a403fSchristos		    TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
308*440a403fSchristos		fi
309*440a403fSchristos		;;
310*440a403fSchristos	esac
311*440a403fSchristos    fi
312*440a403fSchristos
313*440a403fSchristos    # eval is required to do the TCL_DBGX substitution
314*440a403fSchristos    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
315*440a403fSchristos    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
316*440a403fSchristos    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
317*440a403fSchristos    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
318*440a403fSchristos
319*440a403fSchristos    AC_SUBST(TCL_VERSION)
320*440a403fSchristos    AC_SUBST(TCL_PATCH_LEVEL)
321*440a403fSchristos    AC_SUBST(TCL_BIN_DIR)
322*440a403fSchristos    AC_SUBST(TCL_SRC_DIR)
323*440a403fSchristos
324*440a403fSchristos    AC_SUBST(TCL_LIB_FILE)
325*440a403fSchristos    AC_SUBST(TCL_LIB_FLAG)
326*440a403fSchristos    AC_SUBST(TCL_LIB_SPEC)
327*440a403fSchristos
328*440a403fSchristos    AC_SUBST(TCL_STUB_LIB_FILE)
329*440a403fSchristos    AC_SUBST(TCL_STUB_LIB_FLAG)
330*440a403fSchristos    AC_SUBST(TCL_STUB_LIB_SPEC)
331*440a403fSchristos])
332*440a403fSchristos
333*440a403fSchristos#------------------------------------------------------------------------
334*440a403fSchristos# SC_LOAD_TKCONFIG --
335*440a403fSchristos#
336*440a403fSchristos#	Load the tkConfig.sh file
337*440a403fSchristos#
338*440a403fSchristos# Arguments:
339*440a403fSchristos#
340*440a403fSchristos#	Requires the following vars to be set:
341*440a403fSchristos#		TK_BIN_DIR
342*440a403fSchristos#
343*440a403fSchristos# Results:
344*440a403fSchristos#
345*440a403fSchristos#	Sets the following vars that should be in tkConfig.sh:
346*440a403fSchristos#		TK_BIN_DIR
347*440a403fSchristos#------------------------------------------------------------------------
348*440a403fSchristos
349*440a403fSchristosAC_DEFUN([SC_LOAD_TKCONFIG], [
350*440a403fSchristos    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
351*440a403fSchristos
352*440a403fSchristos    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
353*440a403fSchristos        AC_MSG_RESULT([loading])
354*440a403fSchristos	. ${TK_BIN_DIR}/tkConfig.sh
355*440a403fSchristos    else
356*440a403fSchristos        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
357*440a403fSchristos    fi
358*440a403fSchristos
359*440a403fSchristos    # eval is required to do the TK_DBGX substitution
360*440a403fSchristos    eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
361*440a403fSchristos    eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
362*440a403fSchristos
363*440a403fSchristos    # If the TK_BIN_DIR is the build directory (not the install directory),
364*440a403fSchristos    # then set the common variable name to the value of the build variables.
365*440a403fSchristos    # For example, the variable TK_LIB_SPEC will be set to the value
366*440a403fSchristos    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
367*440a403fSchristos    # instead of TK_BUILD_LIB_SPEC since it will work with both an
368*440a403fSchristos    # installed and uninstalled version of Tcl.
369*440a403fSchristos    if test -f "${TK_BIN_DIR}/Makefile" ; then
370*440a403fSchristos        TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
371*440a403fSchristos        TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
372*440a403fSchristos        TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
373*440a403fSchristos    elif test "`uname -s`" = "Darwin"; then
374*440a403fSchristos	# If Tk was built as a framework, attempt to use the libraries
375*440a403fSchristos	# from the framework at the given location so that linking works
376*440a403fSchristos	# against Tk.framework installed in an arbitrary location.
377*440a403fSchristos	case ${TK_DEFS} in
378*440a403fSchristos	    *TK_FRAMEWORK*)
379*440a403fSchristos		if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then
380*440a403fSchristos		    for i in "`cd ${TK_BIN_DIR}; pwd`" \
381*440a403fSchristos			     "`cd ${TK_BIN_DIR}/../..; pwd`"; do
382*440a403fSchristos			if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
383*440a403fSchristos			    TK_LIB_SPEC="-F`dirname "$i"` -framework ${TK_LIB_FILE}"
384*440a403fSchristos			    break
385*440a403fSchristos			fi
386*440a403fSchristos		    done
387*440a403fSchristos		fi
388*440a403fSchristos		if test -f "${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"; then
389*440a403fSchristos		    TK_STUB_LIB_SPEC="-L${TK_BIN_DIR} ${TK_STUB_LIB_FLAG}"
390*440a403fSchristos		    TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
391*440a403fSchristos		fi
392*440a403fSchristos		;;
393*440a403fSchristos	esac
394*440a403fSchristos    fi
395*440a403fSchristos
396*440a403fSchristos    # eval is required to do the TK_DBGX substitution
397*440a403fSchristos    eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
398*440a403fSchristos    eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
399*440a403fSchristos    eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
400*440a403fSchristos    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
401*440a403fSchristos
402*440a403fSchristos    AC_SUBST(TK_VERSION)
403*440a403fSchristos    AC_SUBST(TK_BIN_DIR)
404*440a403fSchristos    AC_SUBST(TK_SRC_DIR)
405*440a403fSchristos
406*440a403fSchristos    AC_SUBST(TK_LIB_FILE)
407*440a403fSchristos    AC_SUBST(TK_LIB_FLAG)
408*440a403fSchristos    AC_SUBST(TK_LIB_SPEC)
409*440a403fSchristos
410*440a403fSchristos    AC_SUBST(TK_STUB_LIB_FILE)
411*440a403fSchristos    AC_SUBST(TK_STUB_LIB_FLAG)
412*440a403fSchristos    AC_SUBST(TK_STUB_LIB_SPEC)
413*440a403fSchristos])
414*440a403fSchristos
415*440a403fSchristos#------------------------------------------------------------------------
416*440a403fSchristos# SC_PROG_TCLSH
417*440a403fSchristos#	Locate a tclsh shell installed on the system path. This macro
418*440a403fSchristos#	will only find a Tcl shell that already exists on the system.
419*440a403fSchristos#	It will not find a Tcl shell in the Tcl build directory or
420*440a403fSchristos#	a Tcl shell that has been installed from the Tcl build directory.
421*440a403fSchristos#	If a Tcl shell can't be located on the PATH, then TCLSH_PROG will
422*440a403fSchristos#	be set to "". Extensions should take care not to create Makefile
423*440a403fSchristos#	rules that are run by default and depend on TCLSH_PROG. An
424*440a403fSchristos#	extension can't assume that an executable Tcl shell exists at
425*440a403fSchristos#	build time.
426*440a403fSchristos#
427*440a403fSchristos# Arguments
428*440a403fSchristos#	none
429*440a403fSchristos#
430*440a403fSchristos# Results
431*440a403fSchristos#	Subst's the following values:
432*440a403fSchristos#		TCLSH_PROG
433*440a403fSchristos#------------------------------------------------------------------------
434*440a403fSchristos
435*440a403fSchristosAC_DEFUN([SC_PROG_TCLSH], [
436*440a403fSchristos    AC_MSG_CHECKING([for tclsh])
437*440a403fSchristos    AC_CACHE_VAL(ac_cv_path_tclsh, [
438*440a403fSchristos	search_path=`echo ${PATH} | sed -e 's/:/ /g'`
439*440a403fSchristos	for dir in $search_path ; do
440*440a403fSchristos	    for j in `ls -r $dir/tclsh[[8-9]]* 2> /dev/null` \
441*440a403fSchristos		    `ls -r $dir/tclsh* 2> /dev/null` ; do
442*440a403fSchristos		if test x"$ac_cv_path_tclsh" = x ; then
443*440a403fSchristos		    if test -f "$j" ; then
444*440a403fSchristos			ac_cv_path_tclsh=$j
445*440a403fSchristos			break
446*440a403fSchristos		    fi
447*440a403fSchristos		fi
448*440a403fSchristos	    done
449*440a403fSchristos	done
450*440a403fSchristos    ])
451*440a403fSchristos
452*440a403fSchristos    if test -f "$ac_cv_path_tclsh" ; then
453*440a403fSchristos	TCLSH_PROG="$ac_cv_path_tclsh"
454*440a403fSchristos	AC_MSG_RESULT([$TCLSH_PROG])
455*440a403fSchristos    else
456*440a403fSchristos	# It is not an error if an installed version of Tcl can't be located.
457*440a403fSchristos	TCLSH_PROG=""
458*440a403fSchristos	AC_MSG_RESULT([No tclsh found on PATH])
459*440a403fSchristos    fi
460*440a403fSchristos    AC_SUBST(TCLSH_PROG)
461*440a403fSchristos])
462*440a403fSchristos
463*440a403fSchristos#------------------------------------------------------------------------
464*440a403fSchristos# SC_BUILD_TCLSH
465*440a403fSchristos#	Determine the fully qualified path name of the tclsh executable
466*440a403fSchristos#	in the Tcl build directory. This macro will correctly determine
467*440a403fSchristos#	the name of the tclsh executable even if tclsh has not yet
468*440a403fSchristos#	been built in the build directory. The build tclsh must be used
469*440a403fSchristos#	when running tests from an extension build directory. It is not
470*440a403fSchristos#	correct to use the TCLSH_PROG in cases like this.
471*440a403fSchristos#
472*440a403fSchristos# Arguments
473*440a403fSchristos#	none
474*440a403fSchristos#
475*440a403fSchristos# Results
476*440a403fSchristos#	Subst's the following values:
477*440a403fSchristos#		BUILD_TCLSH
478*440a403fSchristos#------------------------------------------------------------------------
479*440a403fSchristos
480*440a403fSchristosAC_DEFUN([SC_BUILD_TCLSH], [
481*440a403fSchristos    AC_MSG_CHECKING([for tclsh in Tcl build directory])
482*440a403fSchristos    BUILD_TCLSH=${TCL_BIN_DIR}/tclsh
483*440a403fSchristos    AC_MSG_RESULT([$BUILD_TCLSH])
484*440a403fSchristos    AC_SUBST(BUILD_TCLSH)
485*440a403fSchristos])
486*440a403fSchristos
487*440a403fSchristos#------------------------------------------------------------------------
488*440a403fSchristos# SC_ENABLE_SHARED --
489*440a403fSchristos#
490*440a403fSchristos#	Allows the building of shared libraries
491*440a403fSchristos#
492*440a403fSchristos# Arguments:
493*440a403fSchristos#	none
494*440a403fSchristos#
495*440a403fSchristos# Results:
496*440a403fSchristos#
497*440a403fSchristos#	Adds the following arguments to configure:
498*440a403fSchristos#		--enable-shared=yes|no
499*440a403fSchristos#
500*440a403fSchristos#	Defines the following vars:
501*440a403fSchristos#		STATIC_BUILD	Used for building import/export libraries
502*440a403fSchristos#				on Windows.
503*440a403fSchristos#
504*440a403fSchristos#	Sets the following vars:
505*440a403fSchristos#		SHARED_BUILD	Value of 1 or 0
506*440a403fSchristos#------------------------------------------------------------------------
507*440a403fSchristos
508*440a403fSchristosAC_DEFUN([SC_ENABLE_SHARED], [
509*440a403fSchristos    AC_MSG_CHECKING([how to build libraries])
510*440a403fSchristos    AC_ARG_ENABLE(shared,
511*440a403fSchristos	[  --enable-shared         build and link with shared libraries [--enable-shared]],
512*440a403fSchristos	[tcl_ok=$enableval], [tcl_ok=yes])
513*440a403fSchristos
514*440a403fSchristos    if test "${enable_shared+set}" = set; then
515*440a403fSchristos	enableval="$enable_shared"
516*440a403fSchristos	tcl_ok=$enableval
517*440a403fSchristos    else
518*440a403fSchristos	tcl_ok=yes
519*440a403fSchristos    fi
520*440a403fSchristos
521*440a403fSchristos    if test "$tcl_ok" = "yes" ; then
522*440a403fSchristos	AC_MSG_RESULT([shared])
523*440a403fSchristos	SHARED_BUILD=1
524*440a403fSchristos    else
525*440a403fSchristos	AC_MSG_RESULT([static])
526*440a403fSchristos	SHARED_BUILD=0
527*440a403fSchristos	AC_DEFINE(STATIC_BUILD)
528*440a403fSchristos    fi
529*440a403fSchristos])
530*440a403fSchristos
531*440a403fSchristos#------------------------------------------------------------------------
532*440a403fSchristos# SC_ENABLE_FRAMEWORK --
533*440a403fSchristos#
534*440a403fSchristos#	Allows the building of shared libraries into frameworks
535*440a403fSchristos#
536*440a403fSchristos# Arguments:
537*440a403fSchristos#	none
538*440a403fSchristos#
539*440a403fSchristos# Results:
540*440a403fSchristos#
541*440a403fSchristos#	Adds the following arguments to configure:
542*440a403fSchristos#		--enable-framework=yes|no
543*440a403fSchristos#
544*440a403fSchristos#	Sets the following vars:
545*440a403fSchristos#		FRAMEWORK_BUILD	Value of 1 or 0
546*440a403fSchristos#------------------------------------------------------------------------
547*440a403fSchristos
548*440a403fSchristosAC_DEFUN([SC_ENABLE_FRAMEWORK], [
549*440a403fSchristos    if test "`uname -s`" = "Darwin" ; then
550*440a403fSchristos	AC_MSG_CHECKING([how to package libraries])
551*440a403fSchristos	AC_ARG_ENABLE(framework,
552*440a403fSchristos	    [  --enable-framework      package shared libraries in MacOSX frameworks [--disable-framework]],
553*440a403fSchristos	    [enable_framework=$enableval], [enable_framework=no])
554*440a403fSchristos	if test $enable_framework = yes; then
555*440a403fSchristos	    if test $SHARED_BUILD = 0; then
556*440a403fSchristos		AC_MSG_WARN([Frameworks can only be built if --enable-shared is yes])
557*440a403fSchristos		enable_framework=no
558*440a403fSchristos	    fi
559*440a403fSchristos	    if test $tcl_corefoundation = no; then
560*440a403fSchristos		AC_MSG_WARN([Frameworks can only be used when CoreFoundation is available])
561*440a403fSchristos		enable_framework=no
562*440a403fSchristos	    fi
563*440a403fSchristos	fi
564*440a403fSchristos	if test $enable_framework = yes; then
565*440a403fSchristos	    AC_MSG_RESULT([framework])
566*440a403fSchristos	    FRAMEWORK_BUILD=1
567*440a403fSchristos	else
568*440a403fSchristos	    if test $SHARED_BUILD = 1; then
569*440a403fSchristos		AC_MSG_RESULT([shared library])
570*440a403fSchristos	    else
571*440a403fSchristos		AC_MSG_RESULT([static library])
572*440a403fSchristos	    fi
573*440a403fSchristos	    FRAMEWORK_BUILD=0
574*440a403fSchristos	fi
575*440a403fSchristos    fi
576*440a403fSchristos])
577*440a403fSchristos
578*440a403fSchristos#------------------------------------------------------------------------
579*440a403fSchristos# SC_ENABLE_THREADS --
580*440a403fSchristos#
581*440a403fSchristos#	Specify if thread support should be enabled.  TCL_THREADS is
582*440a403fSchristos#	checked so that if you are compiling an extension against a
583*440a403fSchristos#	threaded core, your extension must be compiled threaded as well.
584*440a403fSchristos#
585*440a403fSchristos# Arguments:
586*440a403fSchristos#	none
587*440a403fSchristos#
588*440a403fSchristos# Results:
589*440a403fSchristos#
590*440a403fSchristos#	Adds the following arguments to configure:
591*440a403fSchristos#		--enable-threads
592*440a403fSchristos#
593*440a403fSchristos#	Sets the following vars:
594*440a403fSchristos#		THREADS_LIBS	Thread library(s)
595*440a403fSchristos#
596*440a403fSchristos#	Defines the following vars:
597*440a403fSchristos#		TCL_THREADS
598*440a403fSchristos#		_REENTRANT
599*440a403fSchristos#		_THREAD_SAFE
600*440a403fSchristos#
601*440a403fSchristos#------------------------------------------------------------------------
602*440a403fSchristos
603*440a403fSchristosAC_DEFUN([SC_ENABLE_THREADS], [
604*440a403fSchristos    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
605*440a403fSchristos	[tcl_ok=$enableval], [tcl_ok=no])
606*440a403fSchristos
607*440a403fSchristos    if test "${TCL_THREADS}" = 1; then
608*440a403fSchristos	tcl_threaded_core=1;
609*440a403fSchristos    fi
610*440a403fSchristos
611*440a403fSchristos    if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
612*440a403fSchristos	TCL_THREADS=1
613*440a403fSchristos	# USE_THREAD_ALLOC tells us to try the special thread-based
614*440a403fSchristos	# allocator that significantly reduces lock contention
615*440a403fSchristos	AC_DEFINE(USE_THREAD_ALLOC)
616*440a403fSchristos	AC_DEFINE(_REENTRANT)
617*440a403fSchristos	if test "`uname -s`" = "SunOS" ; then
618*440a403fSchristos	    AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
619*440a403fSchristos	fi
620*440a403fSchristos	AC_DEFINE(_THREAD_SAFE)
621*440a403fSchristos	AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
622*440a403fSchristos	if test "$tcl_ok" = "no"; then
623*440a403fSchristos	    # Check a little harder for __pthread_mutex_init in the same
624*440a403fSchristos	    # library, as some systems hide it there until pthread.h is
625*440a403fSchristos	    # defined.  We could alternatively do an AC_TRY_COMPILE with
626*440a403fSchristos	    # pthread.h, but that will work with libpthread really doesn't
627*440a403fSchristos	    # exist, like AIX 4.2.  [Bug: 4359]
628*440a403fSchristos	    AC_CHECK_LIB(pthread, __pthread_mutex_init,
629*440a403fSchristos		tcl_ok=yes, tcl_ok=no)
630*440a403fSchristos	fi
631*440a403fSchristos
632*440a403fSchristos	if test "$tcl_ok" = "yes"; then
633*440a403fSchristos	    # The space is needed
634*440a403fSchristos	    THREADS_LIBS=" -lpthread"
635*440a403fSchristos	else
636*440a403fSchristos	    AC_CHECK_LIB(pthreads, pthread_mutex_init,
637*440a403fSchristos		tcl_ok=yes, tcl_ok=no)
638*440a403fSchristos	    if test "$tcl_ok" = "yes"; then
639*440a403fSchristos		# The space is needed
640*440a403fSchristos		THREADS_LIBS=" -lpthreads"
641*440a403fSchristos	    else
642*440a403fSchristos		AC_CHECK_LIB(c, pthread_mutex_init,
643*440a403fSchristos		    tcl_ok=yes, tcl_ok=no)
644*440a403fSchristos		if test "$tcl_ok" = "no"; then
645*440a403fSchristos		    AC_CHECK_LIB(c_r, pthread_mutex_init,
646*440a403fSchristos			tcl_ok=yes, tcl_ok=no)
647*440a403fSchristos		    if test "$tcl_ok" = "yes"; then
648*440a403fSchristos			# The space is needed
649*440a403fSchristos			THREADS_LIBS=" -pthread"
650*440a403fSchristos		    else
651*440a403fSchristos			TCL_THREADS=0
652*440a403fSchristos			AC_MSG_WARN([Don't know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...])
653*440a403fSchristos		    fi
654*440a403fSchristos		fi
655*440a403fSchristos	    fi
656*440a403fSchristos	fi
657*440a403fSchristos
658*440a403fSchristos	# Does the pthread-implementation provide
659*440a403fSchristos	# 'pthread_attr_setstacksize' ?
660*440a403fSchristos
661*440a403fSchristos	ac_saved_libs=$LIBS
662*440a403fSchristos	LIBS="$LIBS $THREADS_LIBS"
663*440a403fSchristos	AC_CHECK_FUNCS(pthread_attr_setstacksize)
664*440a403fSchristos	AC_CHECK_FUNCS(pthread_atfork)
665*440a403fSchristos	LIBS=$ac_saved_libs
666*440a403fSchristos    else
667*440a403fSchristos	TCL_THREADS=0
668*440a403fSchristos    fi
669*440a403fSchristos    # Do checking message here to not mess up interleaved configure output
670*440a403fSchristos    AC_MSG_CHECKING([for building with threads])
671*440a403fSchristos    if test "${TCL_THREADS}" = 1; then
672*440a403fSchristos	AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
673*440a403fSchristos	if test "${tcl_threaded_core}" = 1; then
674*440a403fSchristos	    AC_MSG_RESULT([yes (threaded core)])
675*440a403fSchristos	else
676*440a403fSchristos	    AC_MSG_RESULT([yes])
677*440a403fSchristos	fi
678*440a403fSchristos    else
679*440a403fSchristos	AC_MSG_RESULT([no (default)])
680*440a403fSchristos    fi
681*440a403fSchristos
682*440a403fSchristos    AC_SUBST(TCL_THREADS)
683*440a403fSchristos])
684*440a403fSchristos
685*440a403fSchristos#------------------------------------------------------------------------
686*440a403fSchristos# SC_ENABLE_SYMBOLS --
687*440a403fSchristos#
688*440a403fSchristos#	Specify if debugging symbols should be used.
689*440a403fSchristos#	Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
690*440a403fSchristos#	can also be enabled.
691*440a403fSchristos#
692*440a403fSchristos# Arguments:
693*440a403fSchristos#	none
694*440a403fSchristos#
695*440a403fSchristos#	Requires the following vars to be set in the Makefile:
696*440a403fSchristos#		CFLAGS_DEBUG
697*440a403fSchristos#		CFLAGS_OPTIMIZE
698*440a403fSchristos#		LDFLAGS_DEBUG
699*440a403fSchristos#		LDFLAGS_OPTIMIZE
700*440a403fSchristos#
701*440a403fSchristos# Results:
702*440a403fSchristos#
703*440a403fSchristos#	Adds the following arguments to configure:
704*440a403fSchristos#		--enable-symbols
705*440a403fSchristos#
706*440a403fSchristos#	Defines the following vars:
707*440a403fSchristos#		CFLAGS_DEFAULT	Sets to $(CFLAGS_DEBUG) if true
708*440a403fSchristos#				Sets to $(CFLAGS_OPTIMIZE) if false
709*440a403fSchristos#		LDFLAGS_DEFAULT	Sets to $(LDFLAGS_DEBUG) if true
710*440a403fSchristos#				Sets to $(LDFLAGS_OPTIMIZE) if false
711*440a403fSchristos#		DBGX		Debug library extension
712*440a403fSchristos#
713*440a403fSchristos#------------------------------------------------------------------------
714*440a403fSchristos
715*440a403fSchristosAC_DEFUN([SC_ENABLE_SYMBOLS], [
716*440a403fSchristos    AC_MSG_CHECKING([for build with symbols])
717*440a403fSchristos    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
718*440a403fSchristos# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
719*440a403fSchristos    if test "$tcl_ok" = "no"; then
720*440a403fSchristos	CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
721*440a403fSchristos	LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
722*440a403fSchristos	DBGX=""
723*440a403fSchristos	AC_MSG_RESULT([no])
724*440a403fSchristos    else
725*440a403fSchristos	CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
726*440a403fSchristos	LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
727*440a403fSchristos	DBGX=g
728*440a403fSchristos	if test "$tcl_ok" = "yes"; then
729*440a403fSchristos	    AC_MSG_RESULT([yes (standard debugging)])
730*440a403fSchristos	fi
731*440a403fSchristos    fi
732*440a403fSchristos    AC_SUBST(CFLAGS_DEFAULT)
733*440a403fSchristos    AC_SUBST(LDFLAGS_DEFAULT)
734*440a403fSchristos
735*440a403fSchristos    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
736*440a403fSchristos	AC_DEFINE(TCL_MEM_DEBUG)
737*440a403fSchristos    fi
738*440a403fSchristos
739*440a403fSchristos    if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
740*440a403fSchristos	AC_DEFINE(TCL_COMPILE_DEBUG)
741*440a403fSchristos	AC_DEFINE(TCL_COMPILE_STATS)
742*440a403fSchristos    fi
743*440a403fSchristos
744*440a403fSchristos    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
745*440a403fSchristos	if test "$tcl_ok" = "all"; then
746*440a403fSchristos	    AC_MSG_RESULT([enabled symbols mem compile debugging])
747*440a403fSchristos	else
748*440a403fSchristos	    AC_MSG_RESULT([enabled $tcl_ok debugging])
749*440a403fSchristos	fi
750*440a403fSchristos    fi
751*440a403fSchristos])
752*440a403fSchristos
753*440a403fSchristos#------------------------------------------------------------------------
754*440a403fSchristos# SC_ENABLE_LANGINFO --
755*440a403fSchristos#
756*440a403fSchristos#	Allows use of modern nl_langinfo check for better l10n.
757*440a403fSchristos#	This is only relevant for Unix.
758*440a403fSchristos#
759*440a403fSchristos# Arguments:
760*440a403fSchristos#	none
761*440a403fSchristos#
762*440a403fSchristos# Results:
763*440a403fSchristos#
764*440a403fSchristos#	Adds the following arguments to configure:
765*440a403fSchristos#		--enable-langinfo=yes|no (default is yes)
766*440a403fSchristos#
767*440a403fSchristos#	Defines the following vars:
768*440a403fSchristos#		HAVE_LANGINFO	Triggers use of nl_langinfo if defined.
769*440a403fSchristos#
770*440a403fSchristos#------------------------------------------------------------------------
771*440a403fSchristos
772*440a403fSchristosAC_DEFUN([SC_ENABLE_LANGINFO], [
773*440a403fSchristos    AC_ARG_ENABLE(langinfo,
774*440a403fSchristos	[  --enable-langinfo	  use nl_langinfo if possible to determine
775*440a403fSchristos			  encoding at startup, otherwise use old heuristic],
776*440a403fSchristos	[langinfo_ok=$enableval], [langinfo_ok=yes])
777*440a403fSchristos
778*440a403fSchristos    HAVE_LANGINFO=0
779*440a403fSchristos    if test "$langinfo_ok" = "yes"; then
780*440a403fSchristos	AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
781*440a403fSchristos    fi
782*440a403fSchristos    AC_MSG_CHECKING([whether to use nl_langinfo])
783*440a403fSchristos    if test "$langinfo_ok" = "yes"; then
784*440a403fSchristos	AC_CACHE_VAL(tcl_cv_langinfo_h, [
785*440a403fSchristos	    AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
786*440a403fSchristos		    [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no])])
787*440a403fSchristos	AC_MSG_RESULT([$tcl_cv_langinfo_h])
788*440a403fSchristos	if test $tcl_cv_langinfo_h = yes; then
789*440a403fSchristos	    AC_DEFINE(HAVE_LANGINFO)
790*440a403fSchristos	fi
791*440a403fSchristos    else
792*440a403fSchristos	AC_MSG_RESULT([$langinfo_ok])
793*440a403fSchristos    fi
794*440a403fSchristos])
795*440a403fSchristos
796*440a403fSchristos#--------------------------------------------------------------------
797*440a403fSchristos# SC_CONFIG_MANPAGES
798*440a403fSchristos#
799*440a403fSchristos#	Decide whether to use symlinks for linking the manpages,
800*440a403fSchristos#	whether to compress the manpages after installation, and
801*440a403fSchristos#	whether to add a package name suffix to the installed
802*440a403fSchristos#	manpages to avoidfile name clashes.
803*440a403fSchristos#	If compression is enabled also find out what file name suffix
804*440a403fSchristos#	the given compression program is using.
805*440a403fSchristos#
806*440a403fSchristos# Arguments:
807*440a403fSchristos#	none
808*440a403fSchristos#
809*440a403fSchristos# Results:
810*440a403fSchristos#
811*440a403fSchristos#	Adds the following arguments to configure:
812*440a403fSchristos#		--enable-man-symlinks
813*440a403fSchristos#		--enable-man-compression=PROG
814*440a403fSchristos#		--enable-man-suffix[=STRING]
815*440a403fSchristos#
816*440a403fSchristos#	Defines the following variable:
817*440a403fSchristos#
818*440a403fSchristos#	MAN_FLAGS -	The appropriate flags for installManPage
819*440a403fSchristos#			according to the user's selection.
820*440a403fSchristos#
821*440a403fSchristos#--------------------------------------------------------------------
822*440a403fSchristos
823*440a403fSchristosAC_DEFUN([SC_CONFIG_MANPAGES], [
824*440a403fSchristos    AC_MSG_CHECKING([whether to use symlinks for manpages])
825*440a403fSchristos    AC_ARG_ENABLE(man-symlinks,
826*440a403fSchristos	    [  --enable-man-symlinks   use symlinks for the manpages],
827*440a403fSchristos	test "$enableval" != "no" && MAN_FLAGS="$MAN_FLAGS --symlinks",
828*440a403fSchristos	enableval="no")
829*440a403fSchristos    AC_MSG_RESULT([$enableval])
830*440a403fSchristos
831*440a403fSchristos    AC_MSG_CHECKING([whether to compress the manpages])
832*440a403fSchristos    AC_ARG_ENABLE(man-compression,
833*440a403fSchristos	    [  --enable-man-compression=PROG
834*440a403fSchristos		      compress the manpages with PROG],
835*440a403fSchristos	[case $enableval in
836*440a403fSchristos	    yes) AC_MSG_ERROR([missing argument to --enable-man-compression]);;
837*440a403fSchristos	    no)  ;;
838*440a403fSchristos	    *)   MAN_FLAGS="$MAN_FLAGS --compress $enableval";;
839*440a403fSchristos	esac],
840*440a403fSchristos	enableval="no")
841*440a403fSchristos    AC_MSG_RESULT([$enableval])
842*440a403fSchristos    if test "$enableval" != "no"; then
843*440a403fSchristos	AC_MSG_CHECKING([for compressed file suffix])
844*440a403fSchristos	touch TeST
845*440a403fSchristos	$enableval TeST
846*440a403fSchristos	Z=`ls TeST* | sed 's/^....//'`
847*440a403fSchristos	rm -f TeST*
848*440a403fSchristos	MAN_FLAGS="$MAN_FLAGS --extension $Z"
849*440a403fSchristos	AC_MSG_RESULT([$Z])
850*440a403fSchristos    fi
851*440a403fSchristos
852*440a403fSchristos    AC_MSG_CHECKING([whether to add a package name suffix for the manpages])
853*440a403fSchristos    AC_ARG_ENABLE(man-suffix,
854*440a403fSchristos	    [  --enable-man-suffix=STRING
855*440a403fSchristos		      use STRING as a suffix to manpage file names
856*440a403fSchristos		      (default: $1)],
857*440a403fSchristos	[case $enableval in
858*440a403fSchristos	    yes) enableval="$1" MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
859*440a403fSchristos	    no)  ;;
860*440a403fSchristos	    *)   MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
861*440a403fSchristos	esac],
862*440a403fSchristos	enableval="no")
863*440a403fSchristos    AC_MSG_RESULT([$enableval])
864*440a403fSchristos
865*440a403fSchristos    AC_SUBST(MAN_FLAGS)
866*440a403fSchristos])
867*440a403fSchristos
868*440a403fSchristos#--------------------------------------------------------------------
869*440a403fSchristos# SC_CONFIG_SYSTEM
870*440a403fSchristos#
871*440a403fSchristos#	Determine what the system is (some things cannot be easily checked
872*440a403fSchristos#	on a feature-driven basis, alas). This can usually be done via the
873*440a403fSchristos#	"uname" command, but there are a few systems, like Next, where
874*440a403fSchristos#	this doesn't work.
875*440a403fSchristos#
876*440a403fSchristos# Arguments:
877*440a403fSchristos#	none
878*440a403fSchristos#
879*440a403fSchristos# Results:
880*440a403fSchristos#	Defines the following var:
881*440a403fSchristos#
882*440a403fSchristos#	system -	System/platform/version identification code.
883*440a403fSchristos#
884*440a403fSchristos#--------------------------------------------------------------------
885*440a403fSchristos
886*440a403fSchristosAC_DEFUN([SC_CONFIG_SYSTEM], [
887*440a403fSchristos    AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
888*440a403fSchristos	if test -f /usr/lib/NextStep/software_version; then
889*440a403fSchristos	    tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
890*440a403fSchristos	else
891*440a403fSchristos	    tcl_cv_sys_version=`uname -s`-`uname -r`
892*440a403fSchristos	    if test "$?" -ne 0 ; then
893*440a403fSchristos		AC_MSG_WARN([can't find uname command])
894*440a403fSchristos		tcl_cv_sys_version=unknown
895*440a403fSchristos	    else
896*440a403fSchristos		# Special check for weird MP-RAS system (uname returns weird
897*440a403fSchristos		# results, and the version is kept in special file).
898*440a403fSchristos
899*440a403fSchristos		if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
900*440a403fSchristos		    tcl_cv_sys_version=MP-RAS-`awk '{print $[3]}' /etc/.relid`
901*440a403fSchristos		fi
902*440a403fSchristos		if test "`uname -s`" = "AIX" ; then
903*440a403fSchristos		    tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
904*440a403fSchristos		fi
905*440a403fSchristos	    fi
906*440a403fSchristos	fi
907*440a403fSchristos    ])
908*440a403fSchristos    system=$tcl_cv_sys_version
909*440a403fSchristos])
910*440a403fSchristos
911*440a403fSchristos#--------------------------------------------------------------------
912*440a403fSchristos# SC_CONFIG_CFLAGS
913*440a403fSchristos#
914*440a403fSchristos#	Try to determine the proper flags to pass to the compiler
915*440a403fSchristos#	for building shared libraries and other such nonsense.
916*440a403fSchristos#
917*440a403fSchristos# Arguments:
918*440a403fSchristos#	none
919*440a403fSchristos#
920*440a403fSchristos# Results:
921*440a403fSchristos#
922*440a403fSchristos#	Defines and substitutes the following vars:
923*440a403fSchristos#
924*440a403fSchristos#       DL_OBJS -       Name of the object file that implements dynamic
925*440a403fSchristos#                       loading for Tcl on this system.
926*440a403fSchristos#       DL_LIBS -       Library file(s) to include in tclsh and other base
927*440a403fSchristos#                       applications in order for the "load" command to work.
928*440a403fSchristos#       LDFLAGS -      Flags to pass to the compiler when linking object
929*440a403fSchristos#                       files into an executable application binary such
930*440a403fSchristos#                       as tclsh.
931*440a403fSchristos#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
932*440a403fSchristos#                       that tell the run-time dynamic linker where to look
933*440a403fSchristos#                       for shared libraries such as libtcl.so.  Depends on
934*440a403fSchristos#                       the variable LIB_RUNTIME_DIR in the Makefile. Could
935*440a403fSchristos#                       be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
936*440a403fSchristos#       CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
937*440a403fSchristos#                       that tell the run-time dynamic linker where to look
938*440a403fSchristos#                       for shared libraries such as libtcl.so.  Depends on
939*440a403fSchristos#                       the variable LIB_RUNTIME_DIR in the Makefile.
940*440a403fSchristos#       MAKE_LIB -      Command to execute to build the a library;
941*440a403fSchristos#                       differs when building shared or static.
942*440a403fSchristos#       MAKE_STUB_LIB -
943*440a403fSchristos#                       Command to execute to build a stub library.
944*440a403fSchristos#       INSTALL_LIB -   Command to execute to install a library;
945*440a403fSchristos#                       differs when building shared or static.
946*440a403fSchristos#       INSTALL_STUB_LIB -
947*440a403fSchristos#                       Command to execute to install a stub library.
948*440a403fSchristos#       STLIB_LD -      Base command to use for combining object files
949*440a403fSchristos#                       into a static library.
950*440a403fSchristos#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
951*440a403fSchristos#                       of a shared library (may request position-independent
952*440a403fSchristos#                       code, among other things).
953*440a403fSchristos#       SHLIB_LD -      Base command to use for combining object files
954*440a403fSchristos#                       into a shared library.
955*440a403fSchristos#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
956*440a403fSchristos#                       creating shared libraries.  This symbol typically
957*440a403fSchristos#                       goes at the end of the "ld" commands that build
958*440a403fSchristos#                       shared libraries. The value of the symbol is
959*440a403fSchristos#                       "${LIBS}" if all of the dependent libraries should
960*440a403fSchristos#                       be specified when creating a shared library.  If
961*440a403fSchristos#                       dependent libraries should not be specified (as on
962*440a403fSchristos#                       SunOS 4.x, where they cause the link to fail, or in
963*440a403fSchristos#                       general if Tcl and Tk aren't themselves shared
964*440a403fSchristos#                       libraries), then this symbol has an empty string
965*440a403fSchristos#                       as its value.
966*440a403fSchristos#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
967*440a403fSchristos#                       extensions.  An empty string means we don't know how
968*440a403fSchristos#                       to use shared libraries on this platform.
969*440a403fSchristos# TCL_SHLIB_LD_EXTRAS - Additional element which are added to SHLIB_LD_LIBS
970*440a403fSchristos#  TK_SHLIB_LD_EXTRAS   for the build of Tcl and Tk, but not recorded in the
971*440a403fSchristos#                       tclConfig.sh, since they are only used for the build
972*440a403fSchristos#                       of Tcl and Tk.
973*440a403fSchristos#                       Examples: MacOS X records the library version and
974*440a403fSchristos#                       compatibility version in the shared library.  But
975*440a403fSchristos#                       of course the Tcl version of this is only used for Tcl.
976*440a403fSchristos#       LIB_SUFFIX -    Specifies everything that comes after the "libfoo"
977*440a403fSchristos#                       in a static or shared library name, using the $VERSION variable
978*440a403fSchristos#                       to put the version in the right place.  This is used
979*440a403fSchristos#                       by platforms that need non-standard library names.
980*440a403fSchristos#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
981*440a403fSchristos#                       to have a version after the .so, and ${VERSION}.a
982*440a403fSchristos#                       on AIX, since a shared library needs to have
983*440a403fSchristos#                       a .a extension whereas shared objects for loadable
984*440a403fSchristos#                       extensions have a .so extension.  Defaults to
985*440a403fSchristos#                       ${VERSION}${SHLIB_SUFFIX}.
986*440a403fSchristos#       TCL_NEEDS_EXP_FILE -
987*440a403fSchristos#                       1 means that an export file is needed to link to a
988*440a403fSchristos#                       shared library.
989*440a403fSchristos#       TCL_EXP_FILE -  The name of the installed export / import file which
990*440a403fSchristos#                       should be used to link to the Tcl shared library.
991*440a403fSchristos#                       Empty if Tcl is unshared.
992*440a403fSchristos#       TCL_BUILD_EXP_FILE -
993*440a403fSchristos#                       The name of the built export / import file which
994*440a403fSchristos#                       should be used to link to the Tcl shared library.
995*440a403fSchristos#                       Empty if Tcl is unshared.
996*440a403fSchristos#	CFLAGS_DEBUG -
997*440a403fSchristos#			Flags used when running the compiler in debug mode
998*440a403fSchristos#	CFLAGS_OPTIMIZE -
999*440a403fSchristos#			Flags used when running the compiler in optimize mode
1000*440a403fSchristos#	CFLAGS -	Additional CFLAGS added as necessary (usually 64-bit)
1001*440a403fSchristos#
1002*440a403fSchristos#--------------------------------------------------------------------
1003*440a403fSchristos
1004*440a403fSchristosAC_DEFUN([SC_CONFIG_CFLAGS], [
1005*440a403fSchristos
1006*440a403fSchristos    # Step 0.a: Enable 64 bit support?
1007*440a403fSchristos
1008*440a403fSchristos    AC_MSG_CHECKING([if 64bit support is requested])
1009*440a403fSchristos    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support (where applicable)],
1010*440a403fSchristos	[do64bit=$enableval], [do64bit=no])
1011*440a403fSchristos    AC_MSG_RESULT([$do64bit])
1012*440a403fSchristos
1013*440a403fSchristos    # Step 0.b: Enable Solaris 64 bit VIS support?
1014*440a403fSchristos
1015*440a403fSchristos    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
1016*440a403fSchristos    AC_ARG_ENABLE(64bit-vis,[  --enable-64bit-vis      enable 64bit Sparc VIS support],
1017*440a403fSchristos	[do64bitVIS=$enableval], [do64bitVIS=no])
1018*440a403fSchristos    AC_MSG_RESULT([$do64bitVIS])
1019*440a403fSchristos
1020*440a403fSchristos    if test "$do64bitVIS" = "yes"; then
1021*440a403fSchristos	# Force 64bit on with VIS
1022*440a403fSchristos	do64bit=yes
1023*440a403fSchristos    fi
1024*440a403fSchristos
1025*440a403fSchristos    # Step 1: set the variable "system" to hold the name and version number
1026*440a403fSchristos    # for the system.
1027*440a403fSchristos
1028*440a403fSchristos    SC_CONFIG_SYSTEM
1029*440a403fSchristos
1030*440a403fSchristos    # Step 2: check for existence of -ldl library.  This is needed because
1031*440a403fSchristos    # Linux can use either -ldl or -ldld for dynamic loading.
1032*440a403fSchristos
1033*440a403fSchristos    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
1034*440a403fSchristos
1035*440a403fSchristos    # Require ranlib early so we can override it in special cases below.
1036*440a403fSchristos
1037*440a403fSchristos    AC_REQUIRE([AC_PROG_RANLIB])
1038*440a403fSchristos
1039*440a403fSchristos    # Step 3: set configuration options based on system name and version.
1040*440a403fSchristos
1041*440a403fSchristos    do64bit_ok=no
1042*440a403fSchristos    LDFLAGS_ORIG="$LDFLAGS"
1043*440a403fSchristos    TCL_EXPORT_FILE_SUFFIX=""
1044*440a403fSchristos    UNSHARED_LIB_SUFFIX=""
1045*440a403fSchristos    TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
1046*440a403fSchristos    ECHO_VERSION='`echo ${VERSION}`'
1047*440a403fSchristos    TCL_LIB_VERSIONS_OK=ok
1048*440a403fSchristos    CFLAGS_DEBUG=-g
1049*440a403fSchristos    CFLAGS_OPTIMIZE=-O
1050*440a403fSchristos    if test "$GCC" = "yes" ; then
1051*440a403fSchristos	CFLAGS_WARNING="-Wall -Wno-implicit-int -fno-strict-aliasing"
1052*440a403fSchristos    else
1053*440a403fSchristos	CFLAGS_WARNING=""
1054*440a403fSchristos    fi
1055*440a403fSchristos    TCL_NEEDS_EXP_FILE=0
1056*440a403fSchristos    TCL_BUILD_EXP_FILE=""
1057*440a403fSchristos    TCL_EXP_FILE=""
1058*440a403fSchristosdnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
1059*440a403fSchristosdnl AC_CHECK_TOOL(AR, ar)
1060*440a403fSchristos    AC_CHECK_PROG(AR, ar, ar)
1061*440a403fSchristos    if test "${AR}" = "" ; then
1062*440a403fSchristos	AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
1063*440a403fSchristos    fi
1064*440a403fSchristos    STLIB_LD='${AR} cr'
1065*440a403fSchristos    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
1066*440a403fSchristos    PLAT_OBJS=""
1067*440a403fSchristos    PLAT_SRCS=""
1068*440a403fSchristos    case $system in
1069*440a403fSchristos	AIX-*)
1070*440a403fSchristos	    if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
1071*440a403fSchristos		# AIX requires the _r compiler when gcc isn't being used
1072*440a403fSchristos		case "${CC}" in
1073*440a403fSchristos		    *_r)
1074*440a403fSchristos			# ok ...
1075*440a403fSchristos			;;
1076*440a403fSchristos		    *)
1077*440a403fSchristos			CC=${CC}_r
1078*440a403fSchristos			;;
1079*440a403fSchristos		esac
1080*440a403fSchristos		AC_MSG_RESULT([Using $CC for compiling with threads])
1081*440a403fSchristos	    fi
1082*440a403fSchristos	    LIBS="$LIBS -lc"
1083*440a403fSchristos	    SHLIB_CFLAGS=""
1084*440a403fSchristos	    # Note: need the LIBS below, otherwise Tk won't find Tcl's
1085*440a403fSchristos	    # symbols when dynamically loaded into tclsh.
1086*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1087*440a403fSchristos	    SHLIB_SUFFIX=".so"
1088*440a403fSchristos
1089*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1090*440a403fSchristos	    LD_LIBRARY_PATH_VAR="LIBPATH"
1091*440a403fSchristos
1092*440a403fSchristos	    # Check to enable 64-bit flags for compiler/linker on AIX 4+
1093*440a403fSchristos	    if test "$do64bit" = "yes" -a "`uname -v`" -gt "3" ; then
1094*440a403fSchristos		if test "$GCC" = "yes" ; then
1095*440a403fSchristos		    AC_MSG_WARN([64bit mode not supported with GCC on $system])
1096*440a403fSchristos		else
1097*440a403fSchristos		    do64bit_ok=yes
1098*440a403fSchristos		    CFLAGS="$CFLAGS -q64"
1099*440a403fSchristos		    LDFLAGS="$LDFLAGS -q64"
1100*440a403fSchristos		    RANLIB="${RANLIB} -X64"
1101*440a403fSchristos		    AR="${AR} -X64"
1102*440a403fSchristos		    SHLIB_LD_FLAGS="-b64"
1103*440a403fSchristos		fi
1104*440a403fSchristos	    fi
1105*440a403fSchristos
1106*440a403fSchristos	    if test "`uname -m`" = "ia64" ; then
1107*440a403fSchristos		# AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
1108*440a403fSchristos		SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1109*440a403fSchristos		# AIX-5 has dl* in libc.so
1110*440a403fSchristos		DL_LIBS=""
1111*440a403fSchristos		if test "$GCC" = "yes" ; then
1112*440a403fSchristos		    CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1113*440a403fSchristos		else
1114*440a403fSchristos		    CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
1115*440a403fSchristos		fi
1116*440a403fSchristos		LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1117*440a403fSchristos	    else
1118*440a403fSchristos		if test "$GCC" = "yes" ; then
1119*440a403fSchristos		    SHLIB_LD="gcc -shared"
1120*440a403fSchristos		else
1121*440a403fSchristos		    SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
1122*440a403fSchristos		fi
1123*440a403fSchristos		SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix ${SHLIB_LD} ${SHLIB_LD_FLAGS}"
1124*440a403fSchristos		DL_LIBS="-ldl"
1125*440a403fSchristos		CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1126*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1127*440a403fSchristos		TCL_NEEDS_EXP_FILE=1
1128*440a403fSchristos		TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
1129*440a403fSchristos	    fi
1130*440a403fSchristos
1131*440a403fSchristos	    # AIX v<=4.1 has some different flags than 4.2+
1132*440a403fSchristos	    if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
1133*440a403fSchristos		LIBOBJS="$LIBOBJS tclLoadAix.o"
1134*440a403fSchristos		DL_LIBS="-lld"
1135*440a403fSchristos	    fi
1136*440a403fSchristos
1137*440a403fSchristos	    # On AIX <=v4 systems, libbsd.a has to be linked in to support
1138*440a403fSchristos	    # non-blocking file IO.  This library has to be linked in after
1139*440a403fSchristos	    # the MATH_LIBS or it breaks the pow() function.  The way to
1140*440a403fSchristos	    # insure proper sequencing, is to add it to the tail of MATH_LIBS.
1141*440a403fSchristos	    # This library also supplies gettimeofday.
1142*440a403fSchristos	    #
1143*440a403fSchristos	    # AIX does not have a timezone field in struct tm. When the AIX
1144*440a403fSchristos	    # bsd library is used, the timezone global and the gettimeofday
1145*440a403fSchristos	    # methods are to be avoided for timezone deduction instead, we
1146*440a403fSchristos	    # deduce the timezone by comparing the localtime result on a
1147*440a403fSchristos	    # known GMT value.
1148*440a403fSchristos
1149*440a403fSchristos	    AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
1150*440a403fSchristos	    if test $libbsd = yes; then
1151*440a403fSchristos	    	MATH_LIBS="$MATH_LIBS -lbsd"
1152*440a403fSchristos	    	AC_DEFINE(USE_DELTA_FOR_TZ)
1153*440a403fSchristos	    fi
1154*440a403fSchristos	    ;;
1155*440a403fSchristos	BeOS*)
1156*440a403fSchristos	    SHLIB_CFLAGS="-fPIC"
1157*440a403fSchristos	    SHLIB_LD="${CC} -nostart"
1158*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1159*440a403fSchristos	    SHLIB_SUFFIX=".so"
1160*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1161*440a403fSchristos	    DL_LIBS="-ldl"
1162*440a403fSchristos
1163*440a403fSchristos	    #-----------------------------------------------------------
1164*440a403fSchristos	    # Check for inet_ntoa in -lbind, for BeOS (which also needs
1165*440a403fSchristos	    # -lsocket, even if the network functions are in -lnet which
1166*440a403fSchristos	    # is always linked to, for compatibility.
1167*440a403fSchristos	    #-----------------------------------------------------------
1168*440a403fSchristos	    AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"])
1169*440a403fSchristos	    ;;
1170*440a403fSchristos	BSD/OS-2.1*|BSD/OS-3*)
1171*440a403fSchristos	    SHLIB_CFLAGS=""
1172*440a403fSchristos	    SHLIB_LD="shlicc -r"
1173*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1174*440a403fSchristos	    SHLIB_SUFFIX=".so"
1175*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1176*440a403fSchristos	    DL_LIBS="-ldl"
1177*440a403fSchristos	    CC_SEARCH_FLAGS=""
1178*440a403fSchristos	    LD_SEARCH_FLAGS=""
1179*440a403fSchristos	    ;;
1180*440a403fSchristos	BSD/OS-4.*)
1181*440a403fSchristos	    SHLIB_CFLAGS="-export-dynamic -fPIC"
1182*440a403fSchristos	    SHLIB_LD="cc -shared"
1183*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1184*440a403fSchristos	    SHLIB_SUFFIX=".so"
1185*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1186*440a403fSchristos	    DL_LIBS="-ldl"
1187*440a403fSchristos	    LDFLAGS="$LDFLAGS -export-dynamic"
1188*440a403fSchristos	    CC_SEARCH_FLAGS=""
1189*440a403fSchristos	    LD_SEARCH_FLAGS=""
1190*440a403fSchristos	    ;;
1191*440a403fSchristos	dgux*)
1192*440a403fSchristos	    SHLIB_CFLAGS="-K PIC"
1193*440a403fSchristos	    SHLIB_LD="cc -G"
1194*440a403fSchristos	    SHLIB_LD_LIBS=""
1195*440a403fSchristos	    SHLIB_SUFFIX=".so"
1196*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1197*440a403fSchristos	    DL_LIBS="-ldl"
1198*440a403fSchristos	    CC_SEARCH_FLAGS=""
1199*440a403fSchristos	    LD_SEARCH_FLAGS=""
1200*440a403fSchristos	    ;;
1201*440a403fSchristos	HP-UX-*.11.*)
1202*440a403fSchristos	    # Use updated header definitions where possible
1203*440a403fSchristos	    AC_DEFINE(_XOPEN_SOURCE)          # Use the XOPEN network library
1204*440a403fSchristos	    AC_DEFINE(_XOPEN_SOURCE_EXTENDED) # Use the XOPEN network library
1205*440a403fSchristos	    LIBS="$LIBS -lxnet"               # Use the XOPEN network library
1206*440a403fSchristos
1207*440a403fSchristos	    if test "`uname -m`" = "ia64" ; then
1208*440a403fSchristos		SHLIB_SUFFIX=".so"
1209*440a403fSchristos	    else
1210*440a403fSchristos		SHLIB_SUFFIX=".sl"
1211*440a403fSchristos	    fi
1212*440a403fSchristos	    AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1213*440a403fSchristos	    if test "$tcl_ok" = yes; then
1214*440a403fSchristos		SHLIB_CFLAGS="+z"
1215*440a403fSchristos		SHLIB_LD="ld -b"
1216*440a403fSchristos		SHLIB_LD_LIBS='${LIBS}'
1217*440a403fSchristos		DL_OBJS="tclLoadShl.o"
1218*440a403fSchristos		DL_LIBS="-ldld"
1219*440a403fSchristos		LDFLAGS="$LDFLAGS -Wl,-E"
1220*440a403fSchristos		CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1221*440a403fSchristos		LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1222*440a403fSchristos		LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1223*440a403fSchristos	    fi
1224*440a403fSchristos	    if test "$GCC" = "yes" ; then
1225*440a403fSchristos		SHLIB_LD="gcc -shared"
1226*440a403fSchristos		SHLIB_LD_LIBS='${LIBS}'
1227*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1228*440a403fSchristos	    fi
1229*440a403fSchristos
1230*440a403fSchristos	    # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
1231*440a403fSchristos	    #CFLAGS="$CFLAGS +DAportable"
1232*440a403fSchristos
1233*440a403fSchristos	    # Check to enable 64-bit flags for compiler/linker
1234*440a403fSchristos	    if test "$do64bit" = "yes" ; then
1235*440a403fSchristos		if test "$GCC" = "yes" ; then
1236*440a403fSchristos		    hpux_arch=`${CC} -dumpmachine`
1237*440a403fSchristos		    case $hpux_arch in
1238*440a403fSchristos			hppa64*)
1239*440a403fSchristos			    # 64-bit gcc in use.  Fix flags for GNU ld.
1240*440a403fSchristos			    do64bit_ok=yes
1241*440a403fSchristos			    SHLIB_LD="${CC} -shared"
1242*440a403fSchristos			    SHLIB_LD_LIBS='${LIBS}'
1243*440a403fSchristos			    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1244*440a403fSchristos			    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1245*440a403fSchristos			    ;;
1246*440a403fSchristos			*)
1247*440a403fSchristos			    AC_MSG_WARN([64bit mode not supported with GCC on $system])
1248*440a403fSchristos			    ;;
1249*440a403fSchristos		    esac
1250*440a403fSchristos		else
1251*440a403fSchristos		    do64bit_ok=yes
1252*440a403fSchristos		    CFLAGS="$CFLAGS +DD64"
1253*440a403fSchristos		    LDFLAGS="$LDFLAGS +DD64"
1254*440a403fSchristos		fi
1255*440a403fSchristos	    fi
1256*440a403fSchristos	    ;;
1257*440a403fSchristos	HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
1258*440a403fSchristos	    SHLIB_SUFFIX=".sl"
1259*440a403fSchristos	    AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1260*440a403fSchristos	    if test "$tcl_ok" = yes; then
1261*440a403fSchristos		SHLIB_CFLAGS="+z"
1262*440a403fSchristos		SHLIB_LD="ld -b"
1263*440a403fSchristos		SHLIB_LD_LIBS=""
1264*440a403fSchristos		DL_OBJS="tclLoadShl.o"
1265*440a403fSchristos		DL_LIBS="-ldld"
1266*440a403fSchristos		LDFLAGS="$LDFLAGS -Wl,-E"
1267*440a403fSchristos		CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1268*440a403fSchristos		LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
1269*440a403fSchristos		LD_LIBRARY_PATH_VAR="SHLIB_PATH"
1270*440a403fSchristos	    fi
1271*440a403fSchristos	    ;;
1272*440a403fSchristos	IRIX-4.*)
1273*440a403fSchristos	    SHLIB_CFLAGS="-G 0"
1274*440a403fSchristos	    SHLIB_SUFFIX=".a"
1275*440a403fSchristos	    SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1276*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1277*440a403fSchristos	    DL_OBJS="tclLoadAout.o"
1278*440a403fSchristos	    DL_LIBS=""
1279*440a403fSchristos	    LDFLAGS="$LDFLAGS -Wl,-D,08000000"
1280*440a403fSchristos	    CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1281*440a403fSchristos	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1282*440a403fSchristos	    SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1283*440a403fSchristos	    ;;
1284*440a403fSchristos	IRIX-5.*)
1285*440a403fSchristos	    SHLIB_CFLAGS=""
1286*440a403fSchristos	    SHLIB_LD="ld -shared -rdata_shared"
1287*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1288*440a403fSchristos	    SHLIB_SUFFIX=".so"
1289*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1290*440a403fSchristos	    DL_LIBS=""
1291*440a403fSchristos	    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1292*440a403fSchristos	    LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1293*440a403fSchristos	    ;;
1294*440a403fSchristos	IRIX-6.*)
1295*440a403fSchristos	    SHLIB_CFLAGS=""
1296*440a403fSchristos	    SHLIB_LD="ld -n32 -shared -rdata_shared"
1297*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1298*440a403fSchristos	    SHLIB_SUFFIX=".so"
1299*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1300*440a403fSchristos	    DL_LIBS=""
1301*440a403fSchristos	    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1302*440a403fSchristos	    LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1303*440a403fSchristos	    if test "$GCC" = "yes" ; then
1304*440a403fSchristos		CFLAGS="$CFLAGS -mabi=n32"
1305*440a403fSchristos		LDFLAGS="$LDFLAGS -mabi=n32"
1306*440a403fSchristos	    else
1307*440a403fSchristos		case $system in
1308*440a403fSchristos		    IRIX-6.3)
1309*440a403fSchristos			# Use to build 6.2 compatible binaries on 6.3.
1310*440a403fSchristos			CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS"
1311*440a403fSchristos			;;
1312*440a403fSchristos		    *)
1313*440a403fSchristos			CFLAGS="$CFLAGS -n32"
1314*440a403fSchristos			;;
1315*440a403fSchristos		esac
1316*440a403fSchristos		LDFLAGS="$LDFLAGS -n32"
1317*440a403fSchristos	    fi
1318*440a403fSchristos	    ;;
1319*440a403fSchristos	IRIX64-6.*)
1320*440a403fSchristos	    SHLIB_CFLAGS=""
1321*440a403fSchristos	    SHLIB_LD="ld -n32 -shared -rdata_shared"
1322*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1323*440a403fSchristos	    SHLIB_SUFFIX=".so"
1324*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1325*440a403fSchristos	    DL_LIBS=""
1326*440a403fSchristos	    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1327*440a403fSchristos	    LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1328*440a403fSchristos
1329*440a403fSchristos	    # Check to enable 64-bit flags for compiler/linker
1330*440a403fSchristos
1331*440a403fSchristos	    if test "$do64bit" = "yes" ; then
1332*440a403fSchristos	        if test "$GCC" = "yes" ; then
1333*440a403fSchristos	            AC_MSG_WARN([64bit mode not supported by gcc])
1334*440a403fSchristos	        else
1335*440a403fSchristos	            do64bit_ok=yes
1336*440a403fSchristos	            SHLIB_LD="ld -64 -shared -rdata_shared"
1337*440a403fSchristos	            CFLAGS="$CFLAGS -64"
1338*440a403fSchristos	            LDFLAGS="$LDFLAGS -64"
1339*440a403fSchristos	        fi
1340*440a403fSchristos	    fi
1341*440a403fSchristos	    ;;
1342*440a403fSchristos	Linux*)
1343*440a403fSchristos	    SHLIB_CFLAGS="-fPIC"
1344*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1345*440a403fSchristos	    SHLIB_SUFFIX=".so"
1346*440a403fSchristos
1347*440a403fSchristos	    CFLAGS_OPTIMIZE=-O2
1348*440a403fSchristos	    # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
1349*440a403fSchristos	    # when you inline the string and math operations.  Turn this off to
1350*440a403fSchristos	    # get rid of the warnings.
1351*440a403fSchristos	    #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
1352*440a403fSchristos
1353*440a403fSchristos	    if test "$have_dl" = yes; then
1354*440a403fSchristos		SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
1355*440a403fSchristos		DL_OBJS="tclLoadDl.o"
1356*440a403fSchristos		DL_LIBS="-ldl"
1357*440a403fSchristos		LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1358*440a403fSchristos		CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1359*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1360*440a403fSchristos	    else
1361*440a403fSchristos		AC_CHECK_HEADER(dld.h, [
1362*440a403fSchristos		    SHLIB_LD="ld -shared"
1363*440a403fSchristos		    DL_OBJS="tclLoadDld.o"
1364*440a403fSchristos		    DL_LIBS="-ldld"
1365*440a403fSchristos		    CC_SEARCH_FLAGS=""
1366*440a403fSchristos		    LD_SEARCH_FLAGS=""])
1367*440a403fSchristos	    fi
1368*440a403fSchristos	    if test "`uname -m`" = "alpha" ; then
1369*440a403fSchristos		CFLAGS="$CFLAGS -mieee"
1370*440a403fSchristos	    fi
1371*440a403fSchristos	    if test $do64bit = yes; then
1372*440a403fSchristos		AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
1373*440a403fSchristos		    hold_cflags=$CFLAGS
1374*440a403fSchristos		    CFLAGS="$CFLAGS -m64"
1375*440a403fSchristos		    AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no)
1376*440a403fSchristos		    CFLAGS=$hold_cflags])
1377*440a403fSchristos		if test $tcl_cv_cc_m64 = yes; then
1378*440a403fSchristos		    CFLAGS="$CFLAGS -m64"
1379*440a403fSchristos		    do64bit_ok=yes
1380*440a403fSchristos		fi
1381*440a403fSchristos	    fi
1382*440a403fSchristos
1383*440a403fSchristos	    # The combo of gcc + glibc has a bug related
1384*440a403fSchristos	    # to inlining of functions like strtod(). The
1385*440a403fSchristos	    # -fno-builtin flag should address this problem
1386*440a403fSchristos	    # but it does not work. The -fno-inline flag
1387*440a403fSchristos	    # is kind of overkill but it works.
1388*440a403fSchristos	    # Disable inlining only when one of the
1389*440a403fSchristos	    # files in compat/*.c is being linked in.
1390*440a403fSchristos	    if test x"${LIBOBJS}" != x ; then
1391*440a403fSchristos	        CFLAGS="$CFLAGS -fno-inline"
1392*440a403fSchristos	    fi
1393*440a403fSchristos
1394*440a403fSchristos	    # XIM peeking works under XFree86.
1395*440a403fSchristos	    AC_DEFINE(PEEK_XCLOSEIM)
1396*440a403fSchristos
1397*440a403fSchristos	    ;;
1398*440a403fSchristos	GNU*)
1399*440a403fSchristos	    SHLIB_CFLAGS="-fPIC"
1400*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1401*440a403fSchristos	    SHLIB_SUFFIX=".so"
1402*440a403fSchristos
1403*440a403fSchristos	    if test "$have_dl" = yes; then
1404*440a403fSchristos		SHLIB_LD="${CC} -shared"
1405*440a403fSchristos		DL_OBJS=""
1406*440a403fSchristos		DL_LIBS="-ldl"
1407*440a403fSchristos		LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
1408*440a403fSchristos		CC_SEARCH_FLAGS=""
1409*440a403fSchristos		LD_SEARCH_FLAGS=""
1410*440a403fSchristos	    else
1411*440a403fSchristos		AC_CHECK_HEADER(dld.h, [
1412*440a403fSchristos		    SHLIB_LD="ld -shared"
1413*440a403fSchristos		    DL_OBJS=""
1414*440a403fSchristos		    DL_LIBS="-ldld"
1415*440a403fSchristos		    CC_SEARCH_FLAGS=""
1416*440a403fSchristos		    LD_SEARCH_FLAGS=""])
1417*440a403fSchristos	    fi
1418*440a403fSchristos	    if test "`uname -m`" = "alpha" ; then
1419*440a403fSchristos		CFLAGS="$CFLAGS -mieee"
1420*440a403fSchristos	    fi
1421*440a403fSchristos	    ;;
1422*440a403fSchristos	Lynx*)
1423*440a403fSchristos	    SHLIB_CFLAGS="-fPIC"
1424*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1425*440a403fSchristos	    SHLIB_SUFFIX=".so"
1426*440a403fSchristos	    CFLAGS_OPTIMIZE=-02
1427*440a403fSchristos	    SHLIB_LD="${CC} -shared "
1428*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1429*440a403fSchristos	    DL_LIBS="-mshared -ldl"
1430*440a403fSchristos	    LD_FLAGS="-Wl,--export-dynamic"
1431*440a403fSchristos	    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1432*440a403fSchristos	    LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1433*440a403fSchristos	    ;;
1434*440a403fSchristos	MP-RAS-02*)
1435*440a403fSchristos	    SHLIB_CFLAGS="-K PIC"
1436*440a403fSchristos	    SHLIB_LD="cc -G"
1437*440a403fSchristos	    SHLIB_LD_LIBS=""
1438*440a403fSchristos	    SHLIB_SUFFIX=".so"
1439*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1440*440a403fSchristos	    DL_LIBS="-ldl"
1441*440a403fSchristos	    CC_SEARCH_FLAGS=""
1442*440a403fSchristos	    LD_SEARCH_FLAGS=""
1443*440a403fSchristos	    ;;
1444*440a403fSchristos	MP-RAS-*)
1445*440a403fSchristos	    SHLIB_CFLAGS="-K PIC"
1446*440a403fSchristos	    SHLIB_LD="cc -G"
1447*440a403fSchristos	    SHLIB_LD_LIBS=""
1448*440a403fSchristos	    SHLIB_SUFFIX=".so"
1449*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1450*440a403fSchristos	    DL_LIBS="-ldl"
1451*440a403fSchristos	    LDFLAGS="$LDFLAGS -Wl,-Bexport"
1452*440a403fSchristos	    CC_SEARCH_FLAGS=""
1453*440a403fSchristos	    LD_SEARCH_FLAGS=""
1454*440a403fSchristos	    ;;
1455*440a403fSchristos	NetBSD-*|FreeBSD-[[1-2]].*)
1456*440a403fSchristos	    # Not available on all versions:  check for include file.
1457*440a403fSchristos	    AC_CHECK_HEADER(dlfcn.h, [
1458*440a403fSchristos		# NetBSD/SPARC needs -fPIC, -fpic will not do.
1459*440a403fSchristos		SHLIB_CFLAGS="-fPIC"
1460*440a403fSchristos		SHLIB_LD="ld -Bshareable -x"
1461*440a403fSchristos		SHLIB_LD_LIBS='${LIBS}'
1462*440a403fSchristos		SHLIB_SUFFIX=".so"
1463*440a403fSchristos		DL_OBJS="tclLoadDl.o"
1464*440a403fSchristos		DL_LIBS=""
1465*440a403fSchristos		CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1466*440a403fSchristos		LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1467*440a403fSchristos		AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
1468*440a403fSchristos		    AC_EGREP_CPP(yes, [
1469*440a403fSchristos#ifdef __ELF__
1470*440a403fSchristos	yes
1471*440a403fSchristos#endif
1472*440a403fSchristos		    ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
1473*440a403fSchristos		if test $tcl_cv_ld_elf = yes; then
1474*440a403fSchristos		    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
1475*440a403fSchristos		else
1476*440a403fSchristos		    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1477*440a403fSchristos		fi
1478*440a403fSchristos	    ], [
1479*440a403fSchristos		SHLIB_CFLAGS=""
1480*440a403fSchristos		SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
1481*440a403fSchristos		SHLIB_LD_LIBS='${LIBS}'
1482*440a403fSchristos		SHLIB_SUFFIX=".a"
1483*440a403fSchristos		DL_OBJS="tclLoadAout.o"
1484*440a403fSchristos		DL_LIBS=""
1485*440a403fSchristos		CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1486*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1487*440a403fSchristos		SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1488*440a403fSchristos	    ])
1489*440a403fSchristos
1490*440a403fSchristos	    # FreeBSD doesn't handle version numbers with dots.
1491*440a403fSchristos
1492*440a403fSchristos	    UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1493*440a403fSchristos	    TCL_LIB_VERSIONS_OK=nodots
1494*440a403fSchristos	    ;;
1495*440a403fSchristos	OpenBSD-*)
1496*440a403fSchristos	    case `arch -s` in
1497*440a403fSchristos	    m88k|vax)
1498*440a403fSchristos		SHLIB_CFLAGS=""
1499*440a403fSchristos		SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
1500*440a403fSchristos		SHLIB_LD_LIBS='${LIBS}'
1501*440a403fSchristos		SHLIB_SUFFIX=".a"
1502*440a403fSchristos		DL_OBJS="tclLoadAout.o"
1503*440a403fSchristos		DL_LIBS=""
1504*440a403fSchristos		LDFLAGS=""
1505*440a403fSchristos		CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1506*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1507*440a403fSchristos		SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1508*440a403fSchristos		;;
1509*440a403fSchristos	    *)
1510*440a403fSchristos		# OpenBSD/SPARC[64] needs -fPIC, -fpic will not do.
1511*440a403fSchristos		case `machine` in
1512*440a403fSchristos		sparc|sparc64)
1513*440a403fSchristos		    SHLIB_CFLAGS="-fPIC";;
1514*440a403fSchristos	        *)
1515*440a403fSchristos		    SHLIB_CFLAGS="-fpic";;
1516*440a403fSchristos	        esac
1517*440a403fSchristos		SHLIB_LD="${CC} -shared ${SHLIB_CFLAGS}"
1518*440a403fSchristos		SHLIB_LD_LIBS='${LIBS}'
1519*440a403fSchristos		SHLIB_SUFFIX=".so"
1520*440a403fSchristos		DL_OBJS="tclLoadDl.o"
1521*440a403fSchristos		DL_LIBS=""
1522*440a403fSchristos		CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1523*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1524*440a403fSchristos		SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1525*440a403fSchristos		AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
1526*440a403fSchristos		    AC_EGREP_CPP(yes, [
1527*440a403fSchristos#ifdef __ELF__
1528*440a403fSchristos	yes
1529*440a403fSchristos#endif
1530*440a403fSchristos		    ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
1531*440a403fSchristos		if test $tcl_cv_ld_elf = yes; then
1532*440a403fSchristos		    LDFLAGS=-Wl,-export-dynamic
1533*440a403fSchristos		else
1534*440a403fSchristos		    LDFLAGS=""
1535*440a403fSchristos	        fi
1536*440a403fSchristos		;;
1537*440a403fSchristos	    esac
1538*440a403fSchristos
1539*440a403fSchristos	    # OpenBSD doesn't do version numbers with dots.
1540*440a403fSchristos	    UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1541*440a403fSchristos	    TCL_LIB_VERSIONS_OK=nodots
1542*440a403fSchristos	    ;;
1543*440a403fSchristos	FreeBSD-*)
1544*440a403fSchristos	    # FreeBSD 3.* and greater have ELF.
1545*440a403fSchristos	    SHLIB_CFLAGS="-fPIC"
1546*440a403fSchristos	    SHLIB_LD="ld -Bshareable -x"
1547*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1548*440a403fSchristos	    SHLIB_SUFFIX=".so"
1549*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1550*440a403fSchristos	    DL_LIBS=""
1551*440a403fSchristos	    LDFLAGS="$LDFLAGS -export-dynamic"
1552*440a403fSchristos	    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1553*440a403fSchristos	    LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1554*440a403fSchristos	    if test "${TCL_THREADS}" = "1" ; then
1555*440a403fSchristos		# The -pthread needs to go in the CFLAGS, not LIBS
1556*440a403fSchristos		LIBS=`echo $LIBS | sed s/-pthread//`
1557*440a403fSchristos		CFLAGS="$CFLAGS -pthread"
1558*440a403fSchristos	    	LDFLAGS="$LDFLAGS -pthread"
1559*440a403fSchristos	    fi
1560*440a403fSchristos	    case $system in
1561*440a403fSchristos	    FreeBSD-3.*)
1562*440a403fSchristos	    	# FreeBSD-3 doesn't handle version numbers with dots.
1563*440a403fSchristos	    	UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1564*440a403fSchristos	    	SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
1565*440a403fSchristos	    	TCL_LIB_VERSIONS_OK=nodots
1566*440a403fSchristos		;;
1567*440a403fSchristos	    esac
1568*440a403fSchristos	    ;;
1569*440a403fSchristos	Darwin-*)
1570*440a403fSchristos	    CFLAGS_OPTIMIZE="-Os"
1571*440a403fSchristos	    SHLIB_CFLAGS="-fno-common"
1572*440a403fSchristos	    # To avoid discrepancies between what headers configure sees during
1573*440a403fSchristos	    # preprocessing tests and compiling tests, move any -isysroot and
1574*440a403fSchristos	    # -mmacosx-version-min flags from CFLAGS to CPPFLAGS:
1575*440a403fSchristos	    CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \
1576*440a403fSchristos		awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
1577*440a403fSchristos		if ([$]i~/^(isysroot|mmacosx-version-min)/) print "-"[$]i}'`"
1578*440a403fSchristos	    CFLAGS="`echo " ${CFLAGS}" | \
1579*440a403fSchristos		awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
1580*440a403fSchristos		if (!([$]i~/^(isysroot|mmacosx-version-min)/)) print "-"[$]i}'`"
1581*440a403fSchristos	    if test $do64bit = yes; then
1582*440a403fSchristos		case `arch` in
1583*440a403fSchristos		    ppc)
1584*440a403fSchristos			AC_CACHE_CHECK([if compiler accepts -arch ppc64 flag],
1585*440a403fSchristos				tcl_cv_cc_arch_ppc64, [
1586*440a403fSchristos			    hold_cflags=$CFLAGS
1587*440a403fSchristos			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1588*440a403fSchristos			    AC_TRY_LINK(,, tcl_cv_cc_arch_ppc64=yes,
1589*440a403fSchristos				    tcl_cv_cc_arch_ppc64=no)
1590*440a403fSchristos			    CFLAGS=$hold_cflags])
1591*440a403fSchristos			if test $tcl_cv_cc_arch_ppc64 = yes; then
1592*440a403fSchristos			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
1593*440a403fSchristos			    do64bit_ok=yes
1594*440a403fSchristos			fi;;
1595*440a403fSchristos		    i386)
1596*440a403fSchristos			AC_CACHE_CHECK([if compiler accepts -arch x86_64 flag],
1597*440a403fSchristos				tcl_cv_cc_arch_x86_64, [
1598*440a403fSchristos			    hold_cflags=$CFLAGS
1599*440a403fSchristos			    CFLAGS="$CFLAGS -arch x86_64"
1600*440a403fSchristos			    AC_TRY_LINK(,, tcl_cv_cc_arch_x86_64=yes,
1601*440a403fSchristos				    tcl_cv_cc_arch_x86_64=no)
1602*440a403fSchristos			    CFLAGS=$hold_cflags])
1603*440a403fSchristos			if test $tcl_cv_cc_arch_x86_64 = yes; then
1604*440a403fSchristos			    CFLAGS="$CFLAGS -arch x86_64"
1605*440a403fSchristos			    do64bit_ok=yes
1606*440a403fSchristos			fi;;
1607*440a403fSchristos		    *)
1608*440a403fSchristos			AC_MSG_WARN([Don't know how enable 64-bit on architecture `arch`]);;
1609*440a403fSchristos		esac
1610*440a403fSchristos	    else
1611*440a403fSchristos		# Check for combined 32-bit and 64-bit fat build
1612*440a403fSchristos		echo "$CFLAGS " | grep -E -q -- '-arch (ppc64|x86_64) ' && \
1613*440a403fSchristos		    echo "$CFLAGS " | grep -E -q -- '-arch (ppc|i386) ' && \
1614*440a403fSchristos		    fat_32_64=yes
1615*440a403fSchristos	    fi
1616*440a403fSchristos	    SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS}'
1617*440a403fSchristos	    AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
1618*440a403fSchristos		hold_ldflags=$LDFLAGS
1619*440a403fSchristos		LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
1620*440a403fSchristos		AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
1621*440a403fSchristos		LDFLAGS=$hold_ldflags])
1622*440a403fSchristos	    if test $tcl_cv_ld_single_module = yes; then
1623*440a403fSchristos		SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
1624*440a403fSchristos	    fi
1625*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1626*440a403fSchristos	    SHLIB_SUFFIX=".dylib"
1627*440a403fSchristos	    DL_OBJS="tclLoadDyld.o"
1628*440a403fSchristos	    DL_LIBS=""
1629*440a403fSchristos	    # Don't use -prebind when building for Mac OS X 10.4 or later only:
1630*440a403fSchristos	    test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int([$]2)}'`" -lt 4 -a \
1631*440a403fSchristos		"`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int([$]2)}'`" -lt 4 && \
1632*440a403fSchristos		LDFLAGS="$LDFLAGS -prebind"
1633*440a403fSchristos	    LDFLAGS="$LDFLAGS -headerpad_max_install_names"
1634*440a403fSchristos	    AC_CACHE_CHECK([if ld accepts -search_paths_first flag], tcl_cv_ld_search_paths_first, [
1635*440a403fSchristos		hold_ldflags=$LDFLAGS
1636*440a403fSchristos		LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1637*440a403fSchristos		AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, tcl_cv_ld_search_paths_first=no)
1638*440a403fSchristos		LDFLAGS=$hold_ldflags])
1639*440a403fSchristos	    if test $tcl_cv_ld_search_paths_first = yes; then
1640*440a403fSchristos		LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
1641*440a403fSchristos	    fi
1642*440a403fSchristos	    CC_SEARCH_FLAGS=""
1643*440a403fSchristos	    LD_SEARCH_FLAGS=""
1644*440a403fSchristos	    LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
1645*440a403fSchristos	    PLAT_OBJS=\$\(MAC\_OSX_OBJS\)
1646*440a403fSchristos	    PLAT_SRCS=\$\(MAC\_OSX_SRCS\)
1647*440a403fSchristos	    AC_MSG_CHECKING([whether to use CoreFoundation])
1648*440a403fSchristos	    AC_ARG_ENABLE(corefoundation, [  --enable-corefoundation use CoreFoundation API [--enable-corefoundation]],
1649*440a403fSchristos		[tcl_corefoundation=$enableval], [tcl_corefoundation=yes])
1650*440a403fSchristos	    AC_MSG_RESULT([$tcl_corefoundation])
1651*440a403fSchristos	    if test $tcl_corefoundation = yes; then
1652*440a403fSchristos		AC_CACHE_CHECK([for CoreFoundation.framework], tcl_cv_lib_corefoundation, [
1653*440a403fSchristos		    hold_libs=$LIBS
1654*440a403fSchristos		    if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do
1655*440a403fSchristos			# On Tiger there is no 64-bit CF, so remove 64-bit archs
1656*440a403fSchristos			# from CFLAGS et al. while testing for presence of CF.
1657*440a403fSchristos			# 64-bit CF is disabled in tclUnixPort.h if necessary.
1658*440a403fSchristos			eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
1659*440a403fSchristos		    done; fi
1660*440a403fSchristos		    LIBS="$LIBS -framework CoreFoundation"
1661*440a403fSchristos		    AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
1662*440a403fSchristos			[CFBundleRef b = CFBundleGetMainBundle();],
1663*440a403fSchristos			tcl_cv_lib_corefoundation=yes, tcl_cv_lib_corefoundation=no)
1664*440a403fSchristos		    if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do
1665*440a403fSchristos			eval $v'="$hold_'$v'"'
1666*440a403fSchristos		    done; fi; LIBS=$hold_libs])
1667*440a403fSchristos		if test $tcl_cv_lib_corefoundation = yes; then
1668*440a403fSchristos		    LIBS="$LIBS -framework CoreFoundation"
1669*440a403fSchristos		    AC_DEFINE(HAVE_COREFOUNDATION)
1670*440a403fSchristos		else
1671*440a403fSchristos		    tcl_corefoundation=no
1672*440a403fSchristos		fi
1673*440a403fSchristos		if test "$fat_32_64" = yes -a $tcl_corefoundation = yes; then
1674*440a403fSchristos		    AC_CACHE_CHECK([for 64-bit CoreFoundation], tcl_cv_lib_corefoundation_64, [
1675*440a403fSchristos			for v in CFLAGS CPPFLAGS LDFLAGS; do
1676*440a403fSchristos			    eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
1677*440a403fSchristos			done
1678*440a403fSchristos			AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
1679*440a403fSchristos			    [CFBundleRef b = CFBundleGetMainBundle();],
1680*440a403fSchristos			    tcl_cv_lib_corefoundation_64=yes, tcl_cv_lib_corefoundation_64=no)
1681*440a403fSchristos			for v in CFLAGS CPPFLAGS LDFLAGS; do
1682*440a403fSchristos			    eval $v'="$hold_'$v'"'
1683*440a403fSchristos			done])
1684*440a403fSchristos		    if test $tcl_cv_lib_corefoundation_64 = no; then
1685*440a403fSchristos			AC_DEFINE(NO_COREFOUNDATION_64)
1686*440a403fSchristos		    fi
1687*440a403fSchristos		fi
1688*440a403fSchristos	    fi
1689*440a403fSchristos	    AC_DEFINE(MAC_OSX_TCL)
1690*440a403fSchristos	    ;;
1691*440a403fSchristos	NEXTSTEP-*)
1692*440a403fSchristos	    SHLIB_CFLAGS=""
1693*440a403fSchristos	    SHLIB_LD="cc -nostdlib -r"
1694*440a403fSchristos	    SHLIB_LD_LIBS=""
1695*440a403fSchristos	    SHLIB_SUFFIX=".so"
1696*440a403fSchristos	    DL_OBJS="tclLoadNext.o"
1697*440a403fSchristos	    DL_LIBS=""
1698*440a403fSchristos	    CC_SEARCH_FLAGS=""
1699*440a403fSchristos	    LD_SEARCH_FLAGS=""
1700*440a403fSchristos	    ;;
1701*440a403fSchristos	OS/390-*)
1702*440a403fSchristos	    CFLAGS_OPTIMIZE=""		# Optimizer is buggy
1703*440a403fSchristos	    AC_DEFINE(_OE_SOCKETS)	# needed in sys/socket.h
1704*440a403fSchristos	    ;;
1705*440a403fSchristos	OSF1-1.0|OSF1-1.1|OSF1-1.2)
1706*440a403fSchristos	    # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
1707*440a403fSchristos	    SHLIB_CFLAGS=""
1708*440a403fSchristos	    # Hack: make package name same as library name
1709*440a403fSchristos	    SHLIB_LD='ld -R -export $@:'
1710*440a403fSchristos	    SHLIB_LD_LIBS=""
1711*440a403fSchristos	    SHLIB_SUFFIX=".so"
1712*440a403fSchristos	    DL_OBJS="tclLoadOSF.o"
1713*440a403fSchristos	    DL_LIBS=""
1714*440a403fSchristos	    CC_SEARCH_FLAGS=""
1715*440a403fSchristos	    LD_SEARCH_FLAGS=""
1716*440a403fSchristos	    ;;
1717*440a403fSchristos	OSF1-1.*)
1718*440a403fSchristos	    # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
1719*440a403fSchristos	    SHLIB_CFLAGS="-fPIC"
1720*440a403fSchristos	    if test "$SHARED_BUILD" = "1" ; then
1721*440a403fSchristos	        SHLIB_LD="ld -shared"
1722*440a403fSchristos	    else
1723*440a403fSchristos	        SHLIB_LD="ld -non_shared"
1724*440a403fSchristos	    fi
1725*440a403fSchristos	    SHLIB_LD_LIBS=""
1726*440a403fSchristos	    SHLIB_SUFFIX=".so"
1727*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1728*440a403fSchristos	    DL_LIBS=""
1729*440a403fSchristos	    CC_SEARCH_FLAGS=""
1730*440a403fSchristos	    LD_SEARCH_FLAGS=""
1731*440a403fSchristos	    ;;
1732*440a403fSchristos	OSF1-V*)
1733*440a403fSchristos	    # Digital OSF/1
1734*440a403fSchristos	    SHLIB_CFLAGS=""
1735*440a403fSchristos	    if test "$SHARED_BUILD" = "1" ; then
1736*440a403fSchristos	        SHLIB_LD='ld -shared -expect_unresolved "*"'
1737*440a403fSchristos	    else
1738*440a403fSchristos	        SHLIB_LD='ld -non_shared -expect_unresolved "*"'
1739*440a403fSchristos	    fi
1740*440a403fSchristos	    SHLIB_LD_LIBS=""
1741*440a403fSchristos	    SHLIB_SUFFIX=".so"
1742*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1743*440a403fSchristos	    DL_LIBS=""
1744*440a403fSchristos	    CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1745*440a403fSchristos	    LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
1746*440a403fSchristos	    if test "$GCC" = "yes" ; then
1747*440a403fSchristos		CFLAGS="$CFLAGS -mieee"
1748*440a403fSchristos            else
1749*440a403fSchristos		CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"
1750*440a403fSchristos	    fi
1751*440a403fSchristos	    # see pthread_intro(3) for pthread support on osf1, k.furukawa
1752*440a403fSchristos	    if test "${TCL_THREADS}" = "1" ; then
1753*440a403fSchristos		CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
1754*440a403fSchristos		CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
1755*440a403fSchristos		LIBS=`echo $LIBS | sed s/-lpthreads//`
1756*440a403fSchristos		if test "$GCC" = "yes" ; then
1757*440a403fSchristos		    LIBS="$LIBS -lpthread -lmach -lexc"
1758*440a403fSchristos		else
1759*440a403fSchristos		    CFLAGS="$CFLAGS -pthread"
1760*440a403fSchristos		    LDFLAGS="$LDFLAGS -pthread"
1761*440a403fSchristos		fi
1762*440a403fSchristos	    fi
1763*440a403fSchristos
1764*440a403fSchristos	    ;;
1765*440a403fSchristos	QNX-6*)
1766*440a403fSchristos	    # QNX RTP
1767*440a403fSchristos	    # This may work for all QNX, but it was only reported for v6.
1768*440a403fSchristos	    SHLIB_CFLAGS="-fPIC"
1769*440a403fSchristos	    SHLIB_LD="ld -Bshareable -x"
1770*440a403fSchristos	    SHLIB_LD_LIBS=""
1771*440a403fSchristos	    SHLIB_SUFFIX=".so"
1772*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1773*440a403fSchristos	    # dlopen is in -lc on QNX
1774*440a403fSchristos	    DL_LIBS=""
1775*440a403fSchristos	    CC_SEARCH_FLAGS=""
1776*440a403fSchristos	    LD_SEARCH_FLAGS=""
1777*440a403fSchristos	    ;;
1778*440a403fSchristos	RISCos-*)
1779*440a403fSchristos	    SHLIB_CFLAGS="-G 0"
1780*440a403fSchristos	    SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1781*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1782*440a403fSchristos	    SHLIB_SUFFIX=".a"
1783*440a403fSchristos	    DL_OBJS="tclLoadAout.o"
1784*440a403fSchristos	    DL_LIBS=""
1785*440a403fSchristos	    LDFLAGS="$LDFLAGS -Wl,-D,08000000"
1786*440a403fSchristos	    CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1787*440a403fSchristos	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1788*440a403fSchristos	    ;;
1789*440a403fSchristos	SCO_SV-3.2*)
1790*440a403fSchristos	    # Note, dlopen is available only on SCO 3.2.5 and greater. However,
1791*440a403fSchristos	    # this test works, since "uname -s" was non-standard in 3.2.4 and
1792*440a403fSchristos	    # below.
1793*440a403fSchristos	    if test "$GCC" = "yes" ; then
1794*440a403fSchristos	    	SHLIB_CFLAGS="-fPIC -melf"
1795*440a403fSchristos	    	LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
1796*440a403fSchristos	    else
1797*440a403fSchristos	    	SHLIB_CFLAGS="-Kpic -belf"
1798*440a403fSchristos	    	LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
1799*440a403fSchristos	    fi
1800*440a403fSchristos	    SHLIB_LD="ld -G"
1801*440a403fSchristos	    SHLIB_LD_LIBS=""
1802*440a403fSchristos	    SHLIB_SUFFIX=".so"
1803*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1804*440a403fSchristos	    DL_LIBS=""
1805*440a403fSchristos	    CC_SEARCH_FLAGS=""
1806*440a403fSchristos	    LD_SEARCH_FLAGS=""
1807*440a403fSchristos	    ;;
1808*440a403fSchristos	SINIX*5.4*)
1809*440a403fSchristos	    SHLIB_CFLAGS="-K PIC"
1810*440a403fSchristos	    SHLIB_LD="cc -G"
1811*440a403fSchristos	    SHLIB_LD_LIBS=""
1812*440a403fSchristos	    SHLIB_SUFFIX=".so"
1813*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1814*440a403fSchristos	    DL_LIBS="-ldl"
1815*440a403fSchristos	    CC_SEARCH_FLAGS=""
1816*440a403fSchristos	    LD_SEARCH_FLAGS=""
1817*440a403fSchristos	    ;;
1818*440a403fSchristos	SunOS-4*)
1819*440a403fSchristos	    SHLIB_CFLAGS="-PIC"
1820*440a403fSchristos	    SHLIB_LD="ld"
1821*440a403fSchristos	    SHLIB_LD_LIBS=""
1822*440a403fSchristos	    SHLIB_SUFFIX=".so"
1823*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1824*440a403fSchristos	    DL_LIBS="-ldl"
1825*440a403fSchristos	    CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1826*440a403fSchristos	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1827*440a403fSchristos
1828*440a403fSchristos	    # SunOS can't handle version numbers with dots in them in library
1829*440a403fSchristos	    # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
1830*440a403fSchristos	    # requires an extra version number at the end of .so file names.
1831*440a403fSchristos	    # So, the library has to have a name like libtcl75.so.1.0
1832*440a403fSchristos
1833*440a403fSchristos	    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1834*440a403fSchristos	    UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1835*440a403fSchristos	    TCL_LIB_VERSIONS_OK=nodots
1836*440a403fSchristos	    ;;
1837*440a403fSchristos	SunOS-5.[[0-6]])
1838*440a403fSchristos	    # Careful to not let 5.10+ fall into this case
1839*440a403fSchristos
1840*440a403fSchristos	    # Note: If _REENTRANT isn't defined, then Solaris
1841*440a403fSchristos	    # won't define thread-safe library routines.
1842*440a403fSchristos
1843*440a403fSchristos	    AC_DEFINE(_REENTRANT)
1844*440a403fSchristos	    AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1845*440a403fSchristos
1846*440a403fSchristos	    SHLIB_CFLAGS="-KPIC"
1847*440a403fSchristos
1848*440a403fSchristos	    # Note: need the LIBS below, otherwise Tk won't find Tcl's
1849*440a403fSchristos	    # symbols when dynamically loaded into tclsh.
1850*440a403fSchristos
1851*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1852*440a403fSchristos	    SHLIB_SUFFIX=".so"
1853*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1854*440a403fSchristos	    DL_LIBS="-ldl"
1855*440a403fSchristos	    if test "$GCC" = "yes" ; then
1856*440a403fSchristos		SHLIB_LD="$CC -shared"
1857*440a403fSchristos		CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1858*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1859*440a403fSchristos	    else
1860*440a403fSchristos		SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1861*440a403fSchristos		CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1862*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1863*440a403fSchristos	    fi
1864*440a403fSchristos	    ;;
1865*440a403fSchristos	SunOS-5*)
1866*440a403fSchristos	    # Note: If _REENTRANT isn't defined, then Solaris
1867*440a403fSchristos	    # won't define thread-safe library routines.
1868*440a403fSchristos
1869*440a403fSchristos	    AC_DEFINE(_REENTRANT)
1870*440a403fSchristos	    AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1871*440a403fSchristos
1872*440a403fSchristos	    SHLIB_CFLAGS="-KPIC"
1873*440a403fSchristos
1874*440a403fSchristos	    # Check to enable 64-bit flags for compiler/linker
1875*440a403fSchristos	    if test "$do64bit" = "yes" ; then
1876*440a403fSchristos		arch=`isainfo`
1877*440a403fSchristos		if test "$arch" = "sparcv9 sparc" ; then
1878*440a403fSchristos			if test "$GCC" = "yes" ; then
1879*440a403fSchristos			    if test "`gcc -dumpversion | awk -F. '{print [$]1}'`" -lt "3" ; then
1880*440a403fSchristos				AC_MSG_WARN([64bit mode not supported with GCC < 3.2 on $system])
1881*440a403fSchristos			    else
1882*440a403fSchristos				do64bit_ok=yes
1883*440a403fSchristos				CFLAGS="$CFLAGS -m64 -mcpu=v9"
1884*440a403fSchristos				LDFLAGS="$LDFLAGS -m64 -mcpu=v9"
1885*440a403fSchristos				SHLIB_CFLAGS="-fPIC"
1886*440a403fSchristos			    fi
1887*440a403fSchristos			else
1888*440a403fSchristos			    do64bit_ok=yes
1889*440a403fSchristos			    if test "$do64bitVIS" = "yes" ; then
1890*440a403fSchristos				CFLAGS="$CFLAGS -xarch=v9a"
1891*440a403fSchristos			    	LDFLAGS="$LDFLAGS -xarch=v9a"
1892*440a403fSchristos			    else
1893*440a403fSchristos				CFLAGS="$CFLAGS -xarch=v9"
1894*440a403fSchristos			    	LDFLAGS="$LDFLAGS -xarch=v9"
1895*440a403fSchristos			    fi
1896*440a403fSchristos			    # Solaris 64 uses this as well
1897*440a403fSchristos			    #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
1898*440a403fSchristos			fi
1899*440a403fSchristos		elif test "$arch" = "amd64 i386" ; then
1900*440a403fSchristos		    if test "$GCC" = "yes" ; then
1901*440a403fSchristos			AC_MSG_WARN([64bit mode not supported with GCC on $system])
1902*440a403fSchristos		    else
1903*440a403fSchristos			do64bit_ok=yes
1904*440a403fSchristos			CFLAGS="$CFLAGS -xarch=amd64"
1905*440a403fSchristos			LDFLAGS="$LDFLAGS -xarch=amd64"
1906*440a403fSchristos		    fi
1907*440a403fSchristos		else
1908*440a403fSchristos		    AC_MSG_WARN([64bit mode not supported for $arch])
1909*440a403fSchristos		fi
1910*440a403fSchristos	    fi
1911*440a403fSchristos
1912*440a403fSchristos	    # Note: need the LIBS below, otherwise Tk won't find Tcl's
1913*440a403fSchristos	    # symbols when dynamically loaded into tclsh.
1914*440a403fSchristos
1915*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1916*440a403fSchristos	    SHLIB_SUFFIX=".so"
1917*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1918*440a403fSchristos	    DL_LIBS="-ldl"
1919*440a403fSchristos	    if test "$GCC" = "yes" ; then
1920*440a403fSchristos		SHLIB_LD="$CC -shared"
1921*440a403fSchristos		CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1922*440a403fSchristos		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1923*440a403fSchristos		if test "$do64bit_ok" = "yes" ; then
1924*440a403fSchristos		    # We need to specify -static-libgcc or we need to
1925*440a403fSchristos		    # add the path to the sparv9 libgcc.
1926*440a403fSchristos		    SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
1927*440a403fSchristos		    # for finding sparcv9 libgcc, get the regular libgcc
1928*440a403fSchristos		    # path, remove so name and append 'sparcv9'
1929*440a403fSchristos		    #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..."
1930*440a403fSchristos		    #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir"
1931*440a403fSchristos		fi
1932*440a403fSchristos	    else
1933*440a403fSchristos		case $system in
1934*440a403fSchristos		    SunOS-5.[[1-9]][[0-9]]*)
1935*440a403fSchristos			SHLIB_LD='${CC} -G -z text';;
1936*440a403fSchristos		    *)
1937*440a403fSchristos			SHLIB_LD="/usr/ccs/bin/ld -G -z text";;
1938*440a403fSchristos		esac
1939*440a403fSchristos		CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1940*440a403fSchristos		LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1941*440a403fSchristos	    fi
1942*440a403fSchristos	    ;;
1943*440a403fSchristos	ULTRIX-4.*)
1944*440a403fSchristos	    SHLIB_CFLAGS="-G 0"
1945*440a403fSchristos	    SHLIB_SUFFIX=".a"
1946*440a403fSchristos	    SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1947*440a403fSchristos	    SHLIB_LD_LIBS='${LIBS}'
1948*440a403fSchristos	    DL_OBJS="tclLoadAout.o"
1949*440a403fSchristos	    DL_LIBS=""
1950*440a403fSchristos	    LDFLAGS="$LDFLAGS -Wl,-D,08000000"
1951*440a403fSchristos	    CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1952*440a403fSchristos	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
1953*440a403fSchristos	    if test "$GCC" != "yes" ; then
1954*440a403fSchristos		CFLAGS="$CFLAGS -DHAVE_TZSET -std1"
1955*440a403fSchristos	    fi
1956*440a403fSchristos	    ;;
1957*440a403fSchristos	UNIX_SV* | UnixWare-5*)
1958*440a403fSchristos	    SHLIB_CFLAGS="-KPIC"
1959*440a403fSchristos	    SHLIB_LD="cc -G"
1960*440a403fSchristos	    SHLIB_LD_LIBS=""
1961*440a403fSchristos	    SHLIB_SUFFIX=".so"
1962*440a403fSchristos	    DL_OBJS="tclLoadDl.o"
1963*440a403fSchristos	    DL_LIBS="-ldl"
1964*440a403fSchristos	    # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
1965*440a403fSchristos	    # that don't grok the -Bexport option.  Test that it does.
1966*440a403fSchristos	    AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [
1967*440a403fSchristos		hold_ldflags=$LDFLAGS
1968*440a403fSchristos		LDFLAGS="$LDFLAGS -Wl,-Bexport"
1969*440a403fSchristos		AC_TRY_LINK(, [int i;], tcl_cv_ld_Bexport=yes, tcl_cv_ld_Bexport=no)
1970*440a403fSchristos	        LDFLAGS=$hold_ldflags])
1971*440a403fSchristos	    if test $tcl_cv_ld_Bexport = yes; then
1972*440a403fSchristos		LDFLAGS="$LDFLAGS -Wl,-Bexport"
1973*440a403fSchristos	    fi
1974*440a403fSchristos	    CC_SEARCH_FLAGS=""
1975*440a403fSchristos	    LD_SEARCH_FLAGS=""
1976*440a403fSchristos	    ;;
1977*440a403fSchristos    esac
1978*440a403fSchristos
1979*440a403fSchristos    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
1980*440a403fSchristos	AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform])
1981*440a403fSchristos    fi
1982*440a403fSchristos
1983*440a403fSchristosdnl # Add any CPPFLAGS set in the environment to our CFLAGS, but delay doing so
1984*440a403fSchristosdnl # until the end of configure, as configure's compile and link tests use
1985*440a403fSchristosdnl # both CPPFLAGS and CFLAGS (unlike our compile and link) but configure's
1986*440a403fSchristosdnl # preprocessing tests use only CPPFLAGS.
1987*440a403fSchristos    SC_CONFIG_COMMANDS_PRE([CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""])
1988*440a403fSchristos
1989*440a403fSchristos    # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
1990*440a403fSchristos    # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
1991*440a403fSchristos    # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
1992*440a403fSchristos    # to determine which of several header files defines the a.out file
1993*440a403fSchristos    # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
1994*440a403fSchristos    # support only a file format that is more or less version-7-compatible.
1995*440a403fSchristos    # In particular,
1996*440a403fSchristos    #	- a.out files must begin with `struct exec'.
1997*440a403fSchristos    #	- the N_TXTOFF on the `struct exec' must compute the seek address
1998*440a403fSchristos    #	  of the text segment
1999*440a403fSchristos    #	- The `struct exec' must contain a_magic, a_text, a_data, a_bss
2000*440a403fSchristos    #	  and a_entry fields.
2001*440a403fSchristos    # The following compilation should succeed if and only if either sys/exec.h
2002*440a403fSchristos    # or a.out.h is usable for the purpose.
2003*440a403fSchristos    #
2004*440a403fSchristos    # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
2005*440a403fSchristos    # `struct exec' includes a second header that contains information that
2006*440a403fSchristos    # duplicates the v7 fields that are needed.
2007*440a403fSchristos
2008*440a403fSchristos    if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
2009*440a403fSchristos	AC_CACHE_CHECK([sys/exec.h], tcl_cv_sysexec_h, [
2010*440a403fSchristos	AC_TRY_COMPILE([#include <sys/exec.h>],[
2011*440a403fSchristos	    struct exec foo;
2012*440a403fSchristos	    unsigned long seek;
2013*440a403fSchristos	    int flag;
2014*440a403fSchristos#if defined(__mips) || defined(mips)
2015*440a403fSchristos	    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
2016*440a403fSchristos#else
2017*440a403fSchristos	    seek = N_TXTOFF (foo);
2018*440a403fSchristos#endif
2019*440a403fSchristos	    flag = (foo.a_magic == OMAGIC);
2020*440a403fSchristos	    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
2021*440a403fSchristos    ], tcl_cv_sysexec_h=usable, tcl_cv_sysexec_h=unusable)])
2022*440a403fSchristos	if test $tcl_cv_sysexec_h = usable; then
2023*440a403fSchristos	    AC_DEFINE(USE_SYS_EXEC_H)
2024*440a403fSchristos	else
2025*440a403fSchristos	    AC_CACHE_CHECK([a.out.h], tcl_cv_aout_h, [
2026*440a403fSchristos	    AC_TRY_COMPILE([#include <a.out.h>],[
2027*440a403fSchristos		struct exec foo;
2028*440a403fSchristos		unsigned long seek;
2029*440a403fSchristos		int flag;
2030*440a403fSchristos#if defined(__mips) || defined(mips)
2031*440a403fSchristos		seek = N_TXTOFF (foo.ex_f, foo.ex_o);
2032*440a403fSchristos#else
2033*440a403fSchristos		seek = N_TXTOFF (foo);
2034*440a403fSchristos#endif
2035*440a403fSchristos		flag = (foo.a_magic == OMAGIC);
2036*440a403fSchristos		return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
2037*440a403fSchristos	    ], tcl_cv_aout_h=usable, tcl_cv_aout_h=unusable)])
2038*440a403fSchristos	    if test $tcl_cv_aout_h = usable; then
2039*440a403fSchristos		AC_DEFINE(USE_A_OUT_H)
2040*440a403fSchristos	    else
2041*440a403fSchristos		AC_CACHE_CHECK([sys/exec_aout.h], tcl_cv_sysexecaout_h, [
2042*440a403fSchristos		AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
2043*440a403fSchristos		    struct exec foo;
2044*440a403fSchristos		    unsigned long seek;
2045*440a403fSchristos		    int flag;
2046*440a403fSchristos#if defined(__mips) || defined(mips)
2047*440a403fSchristos		    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
2048*440a403fSchristos#else
2049*440a403fSchristos		    seek = N_TXTOFF (foo);
2050*440a403fSchristos#endif
2051*440a403fSchristos		    flag = (foo.a_midmag == OMAGIC);
2052*440a403fSchristos		    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
2053*440a403fSchristos		], tcl_cv_sysexecaout_h=usable, tcl_cv_sysexecaout_h=unusable)])
2054*440a403fSchristos		if test $tcl_cv_sysexecaout_h = usable; then
2055*440a403fSchristos		    AC_DEFINE(USE_SYS_EXEC_AOUT_H)
2056*440a403fSchristos		else
2057*440a403fSchristos		    DL_OBJS=""
2058*440a403fSchristos		fi
2059*440a403fSchristos	    fi
2060*440a403fSchristos	fi
2061*440a403fSchristos    fi
2062*440a403fSchristos
2063*440a403fSchristos    # Step 5: disable dynamic loading if requested via a command-line switch.
2064*440a403fSchristos
2065*440a403fSchristos    AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
2066*440a403fSchristos	[tcl_ok=$enableval], [tcl_ok=yes])
2067*440a403fSchristos    if test "$tcl_ok" = "no"; then
2068*440a403fSchristos	DL_OBJS=""
2069*440a403fSchristos    fi
2070*440a403fSchristos
2071*440a403fSchristos    if test "x$DL_OBJS" != "x" ; then
2072*440a403fSchristos	BUILD_DLTEST="\$(DLTEST_TARGETS)"
2073*440a403fSchristos    else
2074*440a403fSchristos	echo "Can't figure out how to do dynamic loading or shared libraries"
2075*440a403fSchristos	echo "on this system."
2076*440a403fSchristos	SHLIB_CFLAGS=""
2077*440a403fSchristos	SHLIB_LD=""
2078*440a403fSchristos	SHLIB_SUFFIX=""
2079*440a403fSchristos	DL_OBJS="tclLoadNone.o"
2080*440a403fSchristos	DL_LIBS=""
2081*440a403fSchristos	LDFLAGS="$LDFLAGS_ORIG"
2082*440a403fSchristos	CC_SEARCH_FLAGS=""
2083*440a403fSchristos	LD_SEARCH_FLAGS=""
2084*440a403fSchristos	BUILD_DLTEST=""
2085*440a403fSchristos    fi
2086*440a403fSchristos
2087*440a403fSchristos    # If we're running gcc, then change the C flags for compiling shared
2088*440a403fSchristos    # libraries to the right flags for gcc, instead of those for the
2089*440a403fSchristos    # standard manufacturer compiler.
2090*440a403fSchristos
2091*440a403fSchristos    if test "$DL_OBJS" != "tclLoadNone.o" ; then
2092*440a403fSchristos	if test "$GCC" = "yes" ; then
2093*440a403fSchristos	    case $system in
2094*440a403fSchristos		AIX-*)
2095*440a403fSchristos		    ;;
2096*440a403fSchristos		BSD/OS*)
2097*440a403fSchristos		    ;;
2098*440a403fSchristos		IRIX*)
2099*440a403fSchristos		    ;;
2100*440a403fSchristos		NetBSD-*|FreeBSD-*|OpenBSD-*)
2101*440a403fSchristos		    ;;
2102*440a403fSchristos		Darwin-*)
2103*440a403fSchristos		    ;;
2104*440a403fSchristos		RISCos-*)
2105*440a403fSchristos		    ;;
2106*440a403fSchristos		SCO_SV-3.2*)
2107*440a403fSchristos		    ;;
2108*440a403fSchristos		ULTRIX-4.*)
2109*440a403fSchristos		    ;;
2110*440a403fSchristos		*)
2111*440a403fSchristos		    SHLIB_CFLAGS="-fPIC"
2112*440a403fSchristos		    ;;
2113*440a403fSchristos	    esac
2114*440a403fSchristos	fi
2115*440a403fSchristos    fi
2116*440a403fSchristos
2117*440a403fSchristos    if test "$SHARED_LIB_SUFFIX" = "" ; then
2118*440a403fSchristos	SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
2119*440a403fSchristos    fi
2120*440a403fSchristos    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
2121*440a403fSchristos	UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
2122*440a403fSchristos    fi
2123*440a403fSchristos
2124*440a403fSchristos    if test "${SHARED_BUILD}" = "1" && test "${SHLIB_SUFFIX}" != "" ; then
2125*440a403fSchristos        LIB_SUFFIX=${SHARED_LIB_SUFFIX}
2126*440a403fSchristos        MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
2127*440a403fSchristos        INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
2128*440a403fSchristos    else
2129*440a403fSchristos        LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}
2130*440a403fSchristos
2131*440a403fSchristos        if test "$RANLIB" = "" ; then
2132*440a403fSchristos            MAKE_LIB='$(STLIB_LD) [$]@ ${OBJS}'
2133*440a403fSchristos            INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
2134*440a403fSchristos        else
2135*440a403fSchristos            MAKE_LIB='${STLIB_LD} [$]@ ${OBJS} ; ${RANLIB} [$]@'
2136*440a403fSchristos            INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(LIB_FILE))'
2137*440a403fSchristos        fi
2138*440a403fSchristos
2139*440a403fSchristosdnl        Not at all clear what this was doing in Tcl's configure.ac
2140*440a403fSchristosdnl        or why it was needed was needed. In any event, this sort of
2141*440a403fSchristosdnl        things needs to be done in the big loop above.
2142*440a403fSchristosdnl        REMOVE THIS BLOCK LATER! (mdejong)
2143*440a403fSchristosdnl        case $system in
2144*440a403fSchristosdnl            BSD/OS*)
2145*440a403fSchristosdnl                ;;
2146*440a403fSchristosdnl            AIX-[[1-4]].*)
2147*440a403fSchristosdnl                ;;
2148*440a403fSchristosdnl            *)
2149*440a403fSchristosdnl                SHLIB_LD_LIBS=""
2150*440a403fSchristosdnl                ;;
2151*440a403fSchristosdnl        esac
2152*440a403fSchristos    fi
2153*440a403fSchristos
2154*440a403fSchristos
2155*440a403fSchristos    # Stub lib does not depend on shared/static configuration
2156*440a403fSchristos    if test "$RANLIB" = "" ; then
2157*440a403fSchristos        MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS}'
2158*440a403fSchristos        INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE)'
2159*440a403fSchristos    else
2160*440a403fSchristos        MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS} ; ${RANLIB} [$]@'
2161*440a403fSchristos        INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(STUB_LIB_FILE))'
2162*440a403fSchristos    fi
2163*440a403fSchristos
2164*440a403fSchristos
2165*440a403fSchristos    AC_SUBST(DL_LIBS)
2166*440a403fSchristos
2167*440a403fSchristos    AC_SUBST(DL_OBJS)
2168*440a403fSchristos    AC_SUBST(PLAT_OBJS)
2169*440a403fSchristos    AC_SUBST(PLAT_SRCS)
2170*440a403fSchristos    AC_SUBST(CFLAGS)
2171*440a403fSchristos    AC_SUBST(CFLAGS_DEBUG)
2172*440a403fSchristos    AC_SUBST(CFLAGS_OPTIMIZE)
2173*440a403fSchristos    AC_SUBST(CFLAGS_WARNING)
2174*440a403fSchristos
2175*440a403fSchristos    AC_SUBST(LDFLAGS)
2176*440a403fSchristos    AC_SUBST(LDFLAGS_DEBUG)
2177*440a403fSchristos    AC_SUBST(LDFLAGS_OPTIMIZE)
2178*440a403fSchristos    AC_SUBST(CC_SEARCH_FLAGS)
2179*440a403fSchristos    AC_SUBST(LD_SEARCH_FLAGS)
2180*440a403fSchristos
2181*440a403fSchristos    AC_SUBST(STLIB_LD)
2182*440a403fSchristos    AC_SUBST(SHLIB_LD)
2183*440a403fSchristos    AC_SUBST(TCL_SHLIB_LD_EXTRAS)
2184*440a403fSchristos    AC_SUBST(TK_SHLIB_LD_EXTRAS)
2185*440a403fSchristos    AC_SUBST(SHLIB_LD_LIBS)
2186*440a403fSchristos    AC_SUBST(SHLIB_CFLAGS)
2187*440a403fSchristos    AC_SUBST(SHLIB_SUFFIX)
2188*440a403fSchristos
2189*440a403fSchristos    AC_SUBST(MAKE_LIB)
2190*440a403fSchristos    AC_SUBST(MAKE_STUB_LIB)
2191*440a403fSchristos    AC_SUBST(INSTALL_LIB)
2192*440a403fSchristos    AC_SUBST(INSTALL_STUB_LIB)
2193*440a403fSchristos    AC_SUBST(RANLIB)
2194*440a403fSchristos])
2195*440a403fSchristos
2196*440a403fSchristos#--------------------------------------------------------------------
2197*440a403fSchristos# SC_SERIAL_PORT
2198*440a403fSchristos#
2199*440a403fSchristos#	Determine which interface to use to talk to the serial port.
2200*440a403fSchristos#	Note that #include lines must begin in leftmost column for
2201*440a403fSchristos#	some compilers to recognize them as preprocessor directives,
2202*440a403fSchristos#	and some build environments have stdin not pointing at a
2203*440a403fSchristos#	pseudo-terminal (usually /dev/null instead.)
2204*440a403fSchristos#
2205*440a403fSchristos# Arguments:
2206*440a403fSchristos#	none
2207*440a403fSchristos#
2208*440a403fSchristos# Results:
2209*440a403fSchristos#
2210*440a403fSchristos#	Defines only one of the following vars:
2211*440a403fSchristos#		HAVE_SYS_MODEM_H
2212*440a403fSchristos#		USE_TERMIOS
2213*440a403fSchristos#		USE_TERMIO
2214*440a403fSchristos#		USE_SGTTY
2215*440a403fSchristos#
2216*440a403fSchristos#--------------------------------------------------------------------
2217*440a403fSchristos
2218*440a403fSchristosAC_DEFUN([SC_SERIAL_PORT], [
2219*440a403fSchristos    AC_CHECK_HEADERS(sys/modem.h)
2220*440a403fSchristos    AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
2221*440a403fSchristos    AC_TRY_RUN([
2222*440a403fSchristos#include <termios.h>
2223*440a403fSchristos
2224*440a403fSchristosint main() {
2225*440a403fSchristos    struct termios t;
2226*440a403fSchristos    if (tcgetattr(0, &t) == 0) {
2227*440a403fSchristos	cfsetospeed(&t, 0);
2228*440a403fSchristos	t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2229*440a403fSchristos	return 0;
2230*440a403fSchristos    }
2231*440a403fSchristos    return 1;
2232*440a403fSchristos}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2233*440a403fSchristos    if test $tcl_cv_api_serial = no ; then
2234*440a403fSchristos	AC_TRY_RUN([
2235*440a403fSchristos#include <termio.h>
2236*440a403fSchristos
2237*440a403fSchristosint main() {
2238*440a403fSchristos    struct termio t;
2239*440a403fSchristos    if (ioctl(0, TCGETA, &t) == 0) {
2240*440a403fSchristos	t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2241*440a403fSchristos	return 0;
2242*440a403fSchristos    }
2243*440a403fSchristos    return 1;
2244*440a403fSchristos}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2245*440a403fSchristos    fi
2246*440a403fSchristos    if test $tcl_cv_api_serial = no ; then
2247*440a403fSchristos	AC_TRY_RUN([
2248*440a403fSchristos#include <sgtty.h>
2249*440a403fSchristos
2250*440a403fSchristosint main() {
2251*440a403fSchristos    struct sgttyb t;
2252*440a403fSchristos    if (ioctl(0, TIOCGETP, &t) == 0) {
2253*440a403fSchristos	t.sg_ospeed = 0;
2254*440a403fSchristos	t.sg_flags |= ODDP | EVENP | RAW;
2255*440a403fSchristos	return 0;
2256*440a403fSchristos    }
2257*440a403fSchristos    return 1;
2258*440a403fSchristos}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2259*440a403fSchristos    fi
2260*440a403fSchristos    if test $tcl_cv_api_serial = no ; then
2261*440a403fSchristos	AC_TRY_RUN([
2262*440a403fSchristos#include <termios.h>
2263*440a403fSchristos#include <errno.h>
2264*440a403fSchristos
2265*440a403fSchristosint main() {
2266*440a403fSchristos    struct termios t;
2267*440a403fSchristos    if (tcgetattr(0, &t) == 0
2268*440a403fSchristos	|| errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2269*440a403fSchristos	cfsetospeed(&t, 0);
2270*440a403fSchristos	t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2271*440a403fSchristos	return 0;
2272*440a403fSchristos    }
2273*440a403fSchristos    return 1;
2274*440a403fSchristos}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2275*440a403fSchristos    fi
2276*440a403fSchristos    if test $tcl_cv_api_serial = no; then
2277*440a403fSchristos	AC_TRY_RUN([
2278*440a403fSchristos#include <termio.h>
2279*440a403fSchristos#include <errno.h>
2280*440a403fSchristos
2281*440a403fSchristosint main() {
2282*440a403fSchristos    struct termio t;
2283*440a403fSchristos    if (ioctl(0, TCGETA, &t) == 0
2284*440a403fSchristos	|| errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2285*440a403fSchristos	t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2286*440a403fSchristos	return 0;
2287*440a403fSchristos    }
2288*440a403fSchristos    return 1;
2289*440a403fSchristos    }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
2290*440a403fSchristos    fi
2291*440a403fSchristos    if test $tcl_cv_api_serial = no; then
2292*440a403fSchristos	AC_TRY_RUN([
2293*440a403fSchristos#include <sgtty.h>
2294*440a403fSchristos#include <errno.h>
2295*440a403fSchristos
2296*440a403fSchristosint main() {
2297*440a403fSchristos    struct sgttyb t;
2298*440a403fSchristos    if (ioctl(0, TIOCGETP, &t) == 0
2299*440a403fSchristos	|| errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
2300*440a403fSchristos	t.sg_ospeed = 0;
2301*440a403fSchristos	t.sg_flags |= ODDP | EVENP | RAW;
2302*440a403fSchristos	return 0;
2303*440a403fSchristos    }
2304*440a403fSchristos    return 1;
2305*440a403fSchristos}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
2306*440a403fSchristos    fi])
2307*440a403fSchristos    case $tcl_cv_api_serial in
2308*440a403fSchristos	termios) AC_DEFINE(USE_TERMIOS);;
2309*440a403fSchristos	termio)  AC_DEFINE(USE_TERMIO);;
2310*440a403fSchristos	sgtty)   AC_DEFINE(USE_SGTTY);;
2311*440a403fSchristos    esac
2312*440a403fSchristos])
2313*440a403fSchristos
2314*440a403fSchristos#--------------------------------------------------------------------
2315*440a403fSchristos# SC_MISSING_POSIX_HEADERS
2316*440a403fSchristos#
2317*440a403fSchristos#	Supply substitutes for missing POSIX header files.  Special
2318*440a403fSchristos#	notes:
2319*440a403fSchristos#	    - stdlib.h doesn't define strtol, strtoul, or
2320*440a403fSchristos#	      strtod insome versions of SunOS
2321*440a403fSchristos#	    - some versions of string.h don't declare procedures such
2322*440a403fSchristos#	      as strstr
2323*440a403fSchristos#
2324*440a403fSchristos# Arguments:
2325*440a403fSchristos#	none
2326*440a403fSchristos#
2327*440a403fSchristos# Results:
2328*440a403fSchristos#
2329*440a403fSchristos#	Defines some of the following vars:
2330*440a403fSchristos#		NO_DIRENT_H
2331*440a403fSchristos#		NO_ERRNO_H
2332*440a403fSchristos#		NO_VALUES_H
2333*440a403fSchristos#		HAVE_LIMITS_H or NO_LIMITS_H
2334*440a403fSchristos#		NO_STDLIB_H
2335*440a403fSchristos#		NO_STRING_H
2336*440a403fSchristos#		NO_SYS_WAIT_H
2337*440a403fSchristos#		NO_DLFCN_H
2338*440a403fSchristos#		HAVE_UNISTD_H
2339*440a403fSchristos#		HAVE_SYS_PARAM_H
2340*440a403fSchristos#
2341*440a403fSchristos#		HAVE_STRING_H ?
2342*440a403fSchristos#
2343*440a403fSchristos#--------------------------------------------------------------------
2344*440a403fSchristos
2345*440a403fSchristosAC_DEFUN([SC_MISSING_POSIX_HEADERS], [
2346*440a403fSchristos    AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [
2347*440a403fSchristos    AC_TRY_LINK([#include <sys/types.h>
2348*440a403fSchristos#include <dirent.h>], [
2349*440a403fSchristos#ifndef _POSIX_SOURCE
2350*440a403fSchristos#   ifdef __Lynx__
2351*440a403fSchristos	/*
2352*440a403fSchristos	 * Generate compilation error to make the test fail:  Lynx headers
2353*440a403fSchristos	 * are only valid if really in the POSIX environment.
2354*440a403fSchristos	 */
2355*440a403fSchristos
2356*440a403fSchristos	missing_procedure();
2357*440a403fSchristos#   endif
2358*440a403fSchristos#endif
2359*440a403fSchristosDIR *d;
2360*440a403fSchristosstruct dirent *entryPtr;
2361*440a403fSchristoschar *p;
2362*440a403fSchristosd = opendir("foobar");
2363*440a403fSchristosentryPtr = readdir(d);
2364*440a403fSchristosp = entryPtr->d_name;
2365*440a403fSchristosclosedir(d);
2366*440a403fSchristos], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no)])
2367*440a403fSchristos
2368*440a403fSchristos    if test $tcl_cv_dirent_h = no; then
2369*440a403fSchristos	AC_DEFINE(NO_DIRENT_H)
2370*440a403fSchristos    fi
2371*440a403fSchristos
2372*440a403fSchristos    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H)])
2373*440a403fSchristos    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H)])
2374*440a403fSchristos    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H)])
2375*440a403fSchristos    AC_CHECK_HEADER(limits.h,
2376*440a403fSchristos	[AC_DEFINE(HAVE_LIMITS_H)], [AC_DEFINE(NO_LIMITS_H)])
2377*440a403fSchristos    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
2378*440a403fSchristos    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
2379*440a403fSchristos    AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
2380*440a403fSchristos    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
2381*440a403fSchristos    if test $tcl_ok = 0; then
2382*440a403fSchristos	AC_DEFINE(NO_STDLIB_H)
2383*440a403fSchristos    fi
2384*440a403fSchristos    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
2385*440a403fSchristos    AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
2386*440a403fSchristos    AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
2387*440a403fSchristos
2388*440a403fSchristos    # See also memmove check below for a place where NO_STRING_H can be
2389*440a403fSchristos    # set and why.
2390*440a403fSchristos
2391*440a403fSchristos    if test $tcl_ok = 0; then
2392*440a403fSchristos	AC_DEFINE(NO_STRING_H)
2393*440a403fSchristos    fi
2394*440a403fSchristos
2395*440a403fSchristos    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H)])
2396*440a403fSchristos    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H)])
2397*440a403fSchristos
2398*440a403fSchristos    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
2399*440a403fSchristos    AC_HAVE_HEADERS(unistd.h sys/param.h)
2400*440a403fSchristos])
2401*440a403fSchristos
2402*440a403fSchristos#--------------------------------------------------------------------
2403*440a403fSchristos# SC_PATH_X
2404*440a403fSchristos#
2405*440a403fSchristos#	Locate the X11 header files and the X11 library archive.  Try
2406*440a403fSchristos#	the ac_path_x macro first, but if it doesn't find the X stuff
2407*440a403fSchristos#	(e.g. because there's no xmkmf program) then check through
2408*440a403fSchristos#	a list of possible directories.  Under some conditions the
2409*440a403fSchristos#	autoconf macro will return an include directory that contains
2410*440a403fSchristos#	no include files, so double-check its result just to be safe.
2411*440a403fSchristos#
2412*440a403fSchristos# Arguments:
2413*440a403fSchristos#	none
2414*440a403fSchristos#
2415*440a403fSchristos# Results:
2416*440a403fSchristos#
2417*440a403fSchristos#	Sets the the following vars:
2418*440a403fSchristos#		XINCLUDES
2419*440a403fSchristos#		XLIBSW
2420*440a403fSchristos#
2421*440a403fSchristos#--------------------------------------------------------------------
2422*440a403fSchristos
2423*440a403fSchristosAC_DEFUN([SC_PATH_X], [
2424*440a403fSchristos    AC_PATH_X
2425*440a403fSchristos    not_really_there=""
2426*440a403fSchristos    if test "$no_x" = ""; then
2427*440a403fSchristos	if test "$x_includes" = ""; then
2428*440a403fSchristos	    AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
2429*440a403fSchristos	else
2430*440a403fSchristos	    if test ! -r $x_includes/X11/Intrinsic.h; then
2431*440a403fSchristos		not_really_there="yes"
2432*440a403fSchristos	    fi
2433*440a403fSchristos	fi
2434*440a403fSchristos    fi
2435*440a403fSchristos    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
2436*440a403fSchristos	AC_MSG_CHECKING([for X11 header files])
2437*440a403fSchristos	found_xincludes="no"
2438*440a403fSchristos	AC_TRY_CPP([#include <X11/Intrinsic.h>], found_xincludes="yes", found_xincludes="no")
2439*440a403fSchristos	if test "$found_xincludes" = "no"; then
2440*440a403fSchristos	    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"
2441*440a403fSchristos	    for i in $dirs ; do
2442*440a403fSchristos		if test -r $i/X11/Intrinsic.h; then
2443*440a403fSchristos		    AC_MSG_RESULT([$i])
2444*440a403fSchristos		    XINCLUDES=" -I$i"
2445*440a403fSchristos		    found_xincludes="yes"
2446*440a403fSchristos		    break
2447*440a403fSchristos		fi
2448*440a403fSchristos	    done
2449*440a403fSchristos	fi
2450*440a403fSchristos    else
2451*440a403fSchristos	if test "$x_includes" != ""; then
2452*440a403fSchristos	    XINCLUDES="-I$x_includes"
2453*440a403fSchristos	    found_xincludes="yes"
2454*440a403fSchristos	fi
2455*440a403fSchristos    fi
2456*440a403fSchristos    if test found_xincludes = "no"; then
2457*440a403fSchristos	AC_MSG_RESULT([couldn't find any!])
2458*440a403fSchristos    fi
2459*440a403fSchristos
2460*440a403fSchristos    if test "$no_x" = yes; then
2461*440a403fSchristos	AC_MSG_CHECKING([for X11 libraries])
2462*440a403fSchristos	XLIBSW=nope
2463*440a403fSchristos	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"
2464*440a403fSchristos	for i in $dirs ; do
2465*440a403fSchristos	    if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
2466*440a403fSchristos		AC_MSG_RESULT([$i])
2467*440a403fSchristos		XLIBSW="-L$i -lX11"
2468*440a403fSchristos		x_libraries="$i"
2469*440a403fSchristos		break
2470*440a403fSchristos	    fi
2471*440a403fSchristos	done
2472*440a403fSchristos    else
2473*440a403fSchristos	if test "$x_libraries" = ""; then
2474*440a403fSchristos	    XLIBSW=-lX11
2475*440a403fSchristos	else
2476*440a403fSchristos	    XLIBSW="-L$x_libraries -lX11"
2477*440a403fSchristos	fi
2478*440a403fSchristos    fi
2479*440a403fSchristos    if test "$XLIBSW" = nope ; then
2480*440a403fSchristos	AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
2481*440a403fSchristos    fi
2482*440a403fSchristos    if test "$XLIBSW" = nope ; then
2483*440a403fSchristos	AC_MSG_RESULT([could not find any!  Using -lX11.])
2484*440a403fSchristos	XLIBSW=-lX11
2485*440a403fSchristos    fi
2486*440a403fSchristos])
2487*440a403fSchristos
2488*440a403fSchristos#--------------------------------------------------------------------
2489*440a403fSchristos# SC_BLOCKING_STYLE
2490*440a403fSchristos#
2491*440a403fSchristos#	The statements below check for systems where POSIX-style
2492*440a403fSchristos#	non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
2493*440a403fSchristos#	On these systems (mostly older ones), use the old BSD-style
2494*440a403fSchristos#	FIONBIO approach instead.
2495*440a403fSchristos#
2496*440a403fSchristos# Arguments:
2497*440a403fSchristos#	none
2498*440a403fSchristos#
2499*440a403fSchristos# Results:
2500*440a403fSchristos#
2501*440a403fSchristos#	Defines some of the following vars:
2502*440a403fSchristos#		HAVE_SYS_IOCTL_H
2503*440a403fSchristos#		HAVE_SYS_FILIO_H
2504*440a403fSchristos#		USE_FIONBIO
2505*440a403fSchristos#		O_NONBLOCK
2506*440a403fSchristos#
2507*440a403fSchristos#--------------------------------------------------------------------
2508*440a403fSchristos
2509*440a403fSchristosAC_DEFUN([SC_BLOCKING_STYLE], [
2510*440a403fSchristos    AC_CHECK_HEADERS(sys/ioctl.h)
2511*440a403fSchristos    AC_CHECK_HEADERS(sys/filio.h)
2512*440a403fSchristos    SC_CONFIG_SYSTEM
2513*440a403fSchristos    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
2514*440a403fSchristos    case $system in
2515*440a403fSchristos	# There used to be code here to use FIONBIO under AIX.  However, it
2516*440a403fSchristos	# was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
2517*440a403fSchristos	# using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
2518*440a403fSchristos	# code (JO, 5/31/97).
2519*440a403fSchristos
2520*440a403fSchristos	OSF*)
2521*440a403fSchristos	    AC_DEFINE(USE_FIONBIO)
2522*440a403fSchristos	    AC_MSG_RESULT([FIONBIO])
2523*440a403fSchristos	    ;;
2524*440a403fSchristos	SunOS-4*)
2525*440a403fSchristos	    AC_DEFINE(USE_FIONBIO)
2526*440a403fSchristos	    AC_MSG_RESULT([FIONBIO])
2527*440a403fSchristos	    ;;
2528*440a403fSchristos	ULTRIX-4.*)
2529*440a403fSchristos	    AC_DEFINE(USE_FIONBIO)
2530*440a403fSchristos	    AC_MSG_RESULT([FIONBIO])
2531*440a403fSchristos	    ;;
2532*440a403fSchristos	*)
2533*440a403fSchristos	    AC_MSG_RESULT([O_NONBLOCK])
2534*440a403fSchristos	    ;;
2535*440a403fSchristos    esac
2536*440a403fSchristos])
2537*440a403fSchristos
2538*440a403fSchristos#--------------------------------------------------------------------
2539*440a403fSchristos# SC_TIME_HANLDER
2540*440a403fSchristos#
2541*440a403fSchristos#	Checks how the system deals with time.h, what time structures
2542*440a403fSchristos#	are used on the system, and what fields the structures have.
2543*440a403fSchristos#
2544*440a403fSchristos# Arguments:
2545*440a403fSchristos#	none
2546*440a403fSchristos#
2547*440a403fSchristos# Results:
2548*440a403fSchristos#
2549*440a403fSchristos#	Defines some of the following vars:
2550*440a403fSchristos#		USE_DELTA_FOR_TZ
2551*440a403fSchristos#		HAVE_TM_GMTOFF
2552*440a403fSchristos#		HAVE_TM_TZADJ
2553*440a403fSchristos#		HAVE_TIMEZONE_VAR
2554*440a403fSchristos#
2555*440a403fSchristos#--------------------------------------------------------------------
2556*440a403fSchristos
2557*440a403fSchristosAC_DEFUN([SC_TIME_HANDLER], [
2558*440a403fSchristos    AC_CHECK_HEADERS(sys/time.h)
2559*440a403fSchristos    AC_HEADER_TIME
2560*440a403fSchristos    AC_STRUCT_TIMEZONE
2561*440a403fSchristos
2562*440a403fSchristos    AC_CHECK_FUNCS(gmtime_r localtime_r)
2563*440a403fSchristos
2564*440a403fSchristos    AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [
2565*440a403fSchristos	AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
2566*440a403fSchristos	    tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no)])
2567*440a403fSchristos    if test $tcl_cv_member_tm_tzadj = yes ; then
2568*440a403fSchristos	AC_DEFINE(HAVE_TM_TZADJ)
2569*440a403fSchristos    fi
2570*440a403fSchristos
2571*440a403fSchristos    AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
2572*440a403fSchristos	AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
2573*440a403fSchristos	    tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)])
2574*440a403fSchristos    if test $tcl_cv_member_tm_gmtoff = yes ; then
2575*440a403fSchristos	AC_DEFINE(HAVE_TM_GMTOFF)
2576*440a403fSchristos    fi
2577*440a403fSchristos
2578*440a403fSchristos    #
2579*440a403fSchristos    # Its important to include time.h in this check, as some systems
2580*440a403fSchristos    # (like convex) have timezone functions, etc.
2581*440a403fSchristos    #
2582*440a403fSchristos    AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [
2583*440a403fSchristos	AC_TRY_COMPILE([#include <time.h>],
2584*440a403fSchristos	    [extern long timezone;
2585*440a403fSchristos	    timezone += 1;
2586*440a403fSchristos	    exit (0);],
2587*440a403fSchristos	    tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no)])
2588*440a403fSchristos    if test $tcl_cv_timezone_long = yes ; then
2589*440a403fSchristos	AC_DEFINE(HAVE_TIMEZONE_VAR)
2590*440a403fSchristos    else
2591*440a403fSchristos	#
2592*440a403fSchristos	# On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
2593*440a403fSchristos	#
2594*440a403fSchristos	AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [
2595*440a403fSchristos	    AC_TRY_COMPILE([#include <time.h>],
2596*440a403fSchristos		[extern time_t timezone;
2597*440a403fSchristos		timezone += 1;
2598*440a403fSchristos		exit (0);],
2599*440a403fSchristos		tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no)])
2600*440a403fSchristos	if test $tcl_cv_timezone_time = yes ; then
2601*440a403fSchristos	    AC_DEFINE(HAVE_TIMEZONE_VAR)
2602*440a403fSchristos	fi
2603*440a403fSchristos    fi
2604*440a403fSchristos])
2605*440a403fSchristos
2606*440a403fSchristos#--------------------------------------------------------------------
2607*440a403fSchristos# SC_BUGGY_STRTOD
2608*440a403fSchristos#
2609*440a403fSchristos#	Under Solaris 2.4, strtod returns the wrong value for the
2610*440a403fSchristos#	terminating character under some conditions.  Check for this
2611*440a403fSchristos#	and if the problem exists use a substitute procedure
2612*440a403fSchristos#	"fixstrtod" (provided by Tcl) that corrects the error.
2613*440a403fSchristos#	Also, on Compaq's Tru64 Unix 5.0,
2614*440a403fSchristos#	strtod(" ") returns 0.0 instead of a failure to convert.
2615*440a403fSchristos#
2616*440a403fSchristos# Arguments:
2617*440a403fSchristos#	none
2618*440a403fSchristos#
2619*440a403fSchristos# Results:
2620*440a403fSchristos#
2621*440a403fSchristos#	Might defines some of the following vars:
2622*440a403fSchristos#		strtod (=fixstrtod)
2623*440a403fSchristos#
2624*440a403fSchristos#--------------------------------------------------------------------
2625*440a403fSchristos
2626*440a403fSchristosAC_DEFUN([SC_BUGGY_STRTOD], [
2627*440a403fSchristos    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
2628*440a403fSchristos    if test "$tcl_strtod" = 1; then
2629*440a403fSchristos	AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[
2630*440a403fSchristos	    AC_TRY_RUN([
2631*440a403fSchristos		extern double strtod();
2632*440a403fSchristos		int main() {
2633*440a403fSchristos		    char *infString="Inf", *nanString="NaN", *spaceString=" ";
2634*440a403fSchristos		    char *term;
2635*440a403fSchristos		    double value;
2636*440a403fSchristos		    value = strtod(infString, &term);
2637*440a403fSchristos		    if ((term != infString) && (term[-1] == 0)) {
2638*440a403fSchristos			exit(1);
2639*440a403fSchristos		    }
2640*440a403fSchristos		    value = strtod(nanString, &term);
2641*440a403fSchristos		    if ((term != nanString) && (term[-1] == 0)) {
2642*440a403fSchristos			exit(1);
2643*440a403fSchristos		    }
2644*440a403fSchristos		    value = strtod(spaceString, &term);
2645*440a403fSchristos		    if (term == (spaceString+1)) {
2646*440a403fSchristos			exit(1);
2647*440a403fSchristos		    }
2648*440a403fSchristos		    exit(0);
2649*440a403fSchristos		}], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy,
2650*440a403fSchristos		    tcl_cv_strtod_buggy=buggy)])
2651*440a403fSchristos	if test "$tcl_cv_strtod_buggy" = buggy; then
2652*440a403fSchristos	    LIBOBJS="$LIBOBJS fixstrtod.o"
2653*440a403fSchristos	    AC_DEFINE(strtod, fixstrtod)
2654*440a403fSchristos	fi
2655*440a403fSchristos    fi
2656*440a403fSchristos])
2657*440a403fSchristos
2658*440a403fSchristos#--------------------------------------------------------------------
2659*440a403fSchristos# SC_TCL_LINK_LIBS
2660*440a403fSchristos#
2661*440a403fSchristos#	Search for the libraries needed to link the Tcl shell.
2662*440a403fSchristos#	Things like the math library (-lm) and socket stuff (-lsocket vs.
2663*440a403fSchristos#	-lnsl) are dealt with here.
2664*440a403fSchristos#
2665*440a403fSchristos# Arguments:
2666*440a403fSchristos#	Requires the following vars to be set in the Makefile:
2667*440a403fSchristos#		DL_LIBS
2668*440a403fSchristos#		LIBS
2669*440a403fSchristos#		MATH_LIBS
2670*440a403fSchristos#
2671*440a403fSchristos# Results:
2672*440a403fSchristos#
2673*440a403fSchristos#	Subst's the following var:
2674*440a403fSchristos#		TCL_LIBS
2675*440a403fSchristos#		MATH_LIBS
2676*440a403fSchristos#
2677*440a403fSchristos#	Might append to the following vars:
2678*440a403fSchristos#		LIBS
2679*440a403fSchristos#
2680*440a403fSchristos#	Might define the following vars:
2681*440a403fSchristos#		HAVE_NET_ERRNO_H
2682*440a403fSchristos#
2683*440a403fSchristos#--------------------------------------------------------------------
2684*440a403fSchristos
2685*440a403fSchristosAC_DEFUN([SC_TCL_LINK_LIBS], [
2686*440a403fSchristos    #--------------------------------------------------------------------
2687*440a403fSchristos    # On a few very rare systems, all of the libm.a stuff is
2688*440a403fSchristos    # already in libc.a.  Set compiler flags accordingly.
2689*440a403fSchristos    # Also, Linux requires the "ieee" library for math to work
2690*440a403fSchristos    # right (and it must appear before "-lm").
2691*440a403fSchristos    #--------------------------------------------------------------------
2692*440a403fSchristos
2693*440a403fSchristos    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
2694*440a403fSchristos    AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
2695*440a403fSchristos
2696*440a403fSchristos    #--------------------------------------------------------------------
2697*440a403fSchristos    # Interactive UNIX requires -linet instead of -lsocket, plus it
2698*440a403fSchristos    # needs net/errno.h to define the socket-related error codes.
2699*440a403fSchristos    #--------------------------------------------------------------------
2700*440a403fSchristos
2701*440a403fSchristos    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
2702*440a403fSchristos    AC_CHECK_HEADER(net/errno.h, [AC_DEFINE(HAVE_NET_ERRNO_H)])
2703*440a403fSchristos
2704*440a403fSchristos    #--------------------------------------------------------------------
2705*440a403fSchristos    #	Check for the existence of the -lsocket and -lnsl libraries.
2706*440a403fSchristos    #	The order here is important, so that they end up in the right
2707*440a403fSchristos    #	order in the command line generated by make.  Here are some
2708*440a403fSchristos    #	special considerations:
2709*440a403fSchristos    #	1. Use "connect" and "accept" to check for -lsocket, and
2710*440a403fSchristos    #	   "gethostbyname" to check for -lnsl.
2711*440a403fSchristos    #	2. Use each function name only once:  can't redo a check because
2712*440a403fSchristos    #	   autoconf caches the results of the last check and won't redo it.
2713*440a403fSchristos    #	3. Use -lnsl and -lsocket only if they supply procedures that
2714*440a403fSchristos    #	   aren't already present in the normal libraries.  This is because
2715*440a403fSchristos    #	   IRIX 5.2 has libraries, but they aren't needed and they're
2716*440a403fSchristos    #	   bogus:  they goof up name resolution if used.
2717*440a403fSchristos    #	4. On some SVR4 systems, can't use -lsocket without -lnsl too.
2718*440a403fSchristos    #	   To get around this problem, check for both libraries together
2719*440a403fSchristos    #	   if -lsocket doesn't work by itself.
2720*440a403fSchristos    #--------------------------------------------------------------------
2721*440a403fSchristos
2722*440a403fSchristos    tcl_checkBoth=0
2723*440a403fSchristos    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
2724*440a403fSchristos    if test "$tcl_checkSocket" = 1; then
2725*440a403fSchristos	AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
2726*440a403fSchristos	    LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
2727*440a403fSchristos    fi
2728*440a403fSchristos    if test "$tcl_checkBoth" = 1; then
2729*440a403fSchristos	tk_oldLibs=$LIBS
2730*440a403fSchristos	LIBS="$LIBS -lsocket -lnsl"
2731*440a403fSchristos	AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
2732*440a403fSchristos    fi
2733*440a403fSchristos    AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
2734*440a403fSchristos	    [LIBS="$LIBS -lnsl"])])
2735*440a403fSchristos
2736*440a403fSchristos    # Don't perform the eval of the libraries here because DL_LIBS
2737*440a403fSchristos    # won't be set until we call SC_CONFIG_CFLAGS
2738*440a403fSchristos
2739*440a403fSchristos    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
2740*440a403fSchristos    AC_SUBST(TCL_LIBS)
2741*440a403fSchristos    AC_SUBST(MATH_LIBS)
2742*440a403fSchristos])
2743*440a403fSchristos
2744*440a403fSchristos#--------------------------------------------------------------------
2745*440a403fSchristos# SC_TCL_EARLY_FLAGS
2746*440a403fSchristos#
2747*440a403fSchristos#	Check for what flags are needed to be passed so the correct OS
2748*440a403fSchristos#	features are available.
2749*440a403fSchristos#
2750*440a403fSchristos# Arguments:
2751*440a403fSchristos#	None
2752*440a403fSchristos#
2753*440a403fSchristos# Results:
2754*440a403fSchristos#
2755*440a403fSchristos#	Might define the following vars:
2756*440a403fSchristos#		_ISOC99_SOURCE
2757*440a403fSchristos#		_LARGEFILE64_SOURCE
2758*440a403fSchristos#		_LARGEFILE_SOURCE64
2759*440a403fSchristos#
2760*440a403fSchristos#--------------------------------------------------------------------
2761*440a403fSchristos
2762*440a403fSchristosAC_DEFUN([SC_TCL_EARLY_FLAG],[
2763*440a403fSchristos    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
2764*440a403fSchristos	AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
2765*440a403fSchristos	    AC_TRY_COMPILE([[#define ]$1[ 1
2766*440a403fSchristos]$2], $3,
2767*440a403fSchristos		[tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
2768*440a403fSchristos		[tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
2769*440a403fSchristos    if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
2770*440a403fSchristos	AC_DEFINE($1)
2771*440a403fSchristos	tcl_flags="$tcl_flags $1"
2772*440a403fSchristos    fi
2773*440a403fSchristos])
2774*440a403fSchristos
2775*440a403fSchristosAC_DEFUN([SC_TCL_EARLY_FLAGS],[
2776*440a403fSchristos    AC_MSG_CHECKING([for required early compiler flags])
2777*440a403fSchristos    tcl_flags=""
2778*440a403fSchristos    SC_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
2779*440a403fSchristos	[char *p = (char *)strtoll; char *q = (char *)strtoull;])
2780*440a403fSchristos    SC_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
2781*440a403fSchristos	[struct stat64 buf; int i = stat64("/", &buf);])
2782*440a403fSchristos    SC_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
2783*440a403fSchristos	[char *p = (char *)open64;])
2784*440a403fSchristos    if test "x${tcl_flags}" = "x" ; then
2785*440a403fSchristos	AC_MSG_RESULT([none])
2786*440a403fSchristos    else
2787*440a403fSchristos	AC_MSG_RESULT([${tcl_flags}])
2788*440a403fSchristos    fi
2789*440a403fSchristos])
2790*440a403fSchristos
2791*440a403fSchristos#--------------------------------------------------------------------
2792*440a403fSchristos# SC_TCL_64BIT_FLAGS
2793*440a403fSchristos#
2794*440a403fSchristos#	Check for what is defined in the way of 64-bit features.
2795*440a403fSchristos#
2796*440a403fSchristos# Arguments:
2797*440a403fSchristos#	None
2798*440a403fSchristos#
2799*440a403fSchristos# Results:
2800*440a403fSchristos#
2801*440a403fSchristos#	Might define the following vars:
2802*440a403fSchristos#		TCL_WIDE_INT_IS_LONG
2803*440a403fSchristos#		TCL_WIDE_INT_TYPE
2804*440a403fSchristos#		HAVE_STRUCT_DIRENT64
2805*440a403fSchristos#		HAVE_STRUCT_STAT64
2806*440a403fSchristos#		HAVE_TYPE_OFF64_T
2807*440a403fSchristos#
2808*440a403fSchristos#--------------------------------------------------------------------
2809*440a403fSchristos
2810*440a403fSchristosAC_DEFUN([SC_TCL_64BIT_FLAGS], [
2811*440a403fSchristos    AC_MSG_CHECKING([for 64-bit integer type])
2812*440a403fSchristos    AC_CACHE_VAL(tcl_cv_type_64bit,[
2813*440a403fSchristos	tcl_cv_type_64bit=none
2814*440a403fSchristos	# See if the compiler knows natively about __int64
2815*440a403fSchristos	AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
2816*440a403fSchristos	    tcl_type_64bit=__int64, tcl_type_64bit="long long")
2817*440a403fSchristos	# See if we should use long anyway  Note that we substitute in the
2818*440a403fSchristos	# type that is our current guess for a 64-bit type inside this check
2819*440a403fSchristos	# program, so it should be modified only carefully...
2820*440a403fSchristos        AC_TRY_COMPILE(,[switch (0) {
2821*440a403fSchristos            case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ;
2822*440a403fSchristos        }],tcl_cv_type_64bit=${tcl_type_64bit})])
2823*440a403fSchristos    if test "${tcl_cv_type_64bit}" = none ; then
2824*440a403fSchristos	AC_DEFINE(TCL_WIDE_INT_IS_LONG)
2825*440a403fSchristos	AC_MSG_RESULT([using long])
2826*440a403fSchristos    else
2827*440a403fSchristos	AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit})
2828*440a403fSchristos	AC_MSG_RESULT([${tcl_cv_type_64bit}])
2829*440a403fSchristos
2830*440a403fSchristos	# Now check for auxiliary declarations
2831*440a403fSchristos	AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
2832*440a403fSchristos	    AC_TRY_COMPILE([#include <sys/types.h>
2833*440a403fSchristos#include <sys/dirent.h>],[struct dirent64 p;],
2834*440a403fSchristos		tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
2835*440a403fSchristos	if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
2836*440a403fSchristos	    AC_DEFINE(HAVE_STRUCT_DIRENT64)
2837*440a403fSchristos	fi
2838*440a403fSchristos
2839*440a403fSchristos	AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[
2840*440a403fSchristos	    AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
2841*440a403fSchristos],
2842*440a403fSchristos		tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
2843*440a403fSchristos	if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
2844*440a403fSchristos	    AC_DEFINE(HAVE_STRUCT_STAT64)
2845*440a403fSchristos	fi
2846*440a403fSchristos
2847*440a403fSchristos	AC_CHECK_FUNCS(open64 lseek64)
2848*440a403fSchristos	AC_MSG_CHECKING([for off64_t])
2849*440a403fSchristos	AC_CACHE_VAL(tcl_cv_type_off64_t,[
2850*440a403fSchristos	    AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
2851*440a403fSchristos],
2852*440a403fSchristos		tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
2853*440a403fSchristos	dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the
2854*440a403fSchristos	dnl functions lseek64 and open64 are defined.
2855*440a403fSchristos	if test "x${tcl_cv_type_off64_t}" = "xyes" && \
2856*440a403fSchristos	        test "x${ac_cv_func_lseek64}" = "xyes" && \
2857*440a403fSchristos	        test "x${ac_cv_func_open64}" = "xyes" ; then
2858*440a403fSchristos	    AC_DEFINE(HAVE_TYPE_OFF64_T)
2859*440a403fSchristos	    AC_MSG_RESULT([yes])
2860*440a403fSchristos	else
2861*440a403fSchristos	    AC_MSG_RESULT([no])
2862*440a403fSchristos	fi
2863*440a403fSchristos    fi
2864*440a403fSchristos])
2865*440a403fSchristos
2866*440a403fSchristos#--------------------------------------------------------------------
2867*440a403fSchristos# SC_TCL_GETHOSTBYADDR_R
2868*440a403fSchristos#
2869*440a403fSchristos#	Check if we have MT-safe variant of gethostbyaddr().
2870*440a403fSchristos#
2871*440a403fSchristos# Arguments:
2872*440a403fSchristos#	None
2873*440a403fSchristos#
2874*440a403fSchristos# Results:
2875*440a403fSchristos#
2876*440a403fSchristos#	Might define the following vars:
2877*440a403fSchristos#		HAVE_GETHOSTBYADDR_R
2878*440a403fSchristos#		HAVE_GETHOSTBYADDR_R_7
2879*440a403fSchristos#		HAVE_GETHOSTBYADDR_R_8
2880*440a403fSchristos#
2881*440a403fSchristos#--------------------------------------------------------------------
2882*440a403fSchristos
2883*440a403fSchristosAC_DEFUN([SC_TCL_GETHOSTBYADDR_R], [AC_CHECK_FUNC(gethostbyaddr_r, [
2884*440a403fSchristos    AC_CACHE_CHECK([for gethostbyaddr_r with 7 args], tcl_cv_api_gethostbyaddr_r_7, [
2885*440a403fSchristos    AC_TRY_COMPILE([
2886*440a403fSchristos	#include <netdb.h>
2887*440a403fSchristos    ], [
2888*440a403fSchristos	char *addr;
2889*440a403fSchristos	int length;
2890*440a403fSchristos	int type;
2891*440a403fSchristos	struct hostent *result;
2892*440a403fSchristos	char buffer[2048];
2893*440a403fSchristos	int buflen = 2048;
2894*440a403fSchristos	int h_errnop;
2895*440a403fSchristos
2896*440a403fSchristos	(void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
2897*440a403fSchristos			       &h_errnop);
2898*440a403fSchristos    ], tcl_cv_api_gethostbyaddr_r_7=yes, tcl_cv_api_gethostbyaddr_r_7=no)])
2899*440a403fSchristos    tcl_ok=$tcl_cv_api_gethostbyaddr_r_7
2900*440a403fSchristos    if test "$tcl_ok" = yes; then
2901*440a403fSchristos	AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
2902*440a403fSchristos    else
2903*440a403fSchristos	AC_CACHE_CHECK([for gethostbyaddr_r with 8 args], tcl_cv_api_gethostbyaddr_r_8, [
2904*440a403fSchristos	AC_TRY_COMPILE([
2905*440a403fSchristos	    #include <netdb.h>
2906*440a403fSchristos	], [
2907*440a403fSchristos	    char *addr;
2908*440a403fSchristos	    int length;
2909*440a403fSchristos	    int type;
2910*440a403fSchristos	    struct hostent *result, *resultp;
2911*440a403fSchristos	    char buffer[2048];
2912*440a403fSchristos	    int buflen = 2048;
2913*440a403fSchristos	    int h_errnop;
2914*440a403fSchristos
2915*440a403fSchristos	    (void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
2916*440a403fSchristos				   &resultp, &h_errnop);
2917*440a403fSchristos	], tcl_cv_api_gethostbyaddr_r_8=yes, tcl_cv_api_gethostbyaddr_r_8=no)])
2918*440a403fSchristos	tcl_ok=$tcl_cv_api_gethostbyaddr_r_8
2919*440a403fSchristos	if test "$tcl_ok" = yes; then
2920*440a403fSchristos	    AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
2921*440a403fSchristos	fi
2922*440a403fSchristos    fi
2923*440a403fSchristos    if test "$tcl_ok" = yes; then
2924*440a403fSchristos	AC_DEFINE(HAVE_GETHOSTBYADDR_R)
2925*440a403fSchristos    fi
2926*440a403fSchristos])])
2927*440a403fSchristos
2928*440a403fSchristos#--------------------------------------------------------------------
2929*440a403fSchristos# SC_TCL_GETHOSTBYNAME_R
2930*440a403fSchristos#
2931*440a403fSchristos#	Check to see what variant of gethostbyname_r() we have.
2932*440a403fSchristos#	Based on David Arnold's example from the comp.programming.threads
2933*440a403fSchristos#	FAQ Q213
2934*440a403fSchristos#
2935*440a403fSchristos# Arguments:
2936*440a403fSchristos#	None
2937*440a403fSchristos#
2938*440a403fSchristos# Results:
2939*440a403fSchristos#
2940*440a403fSchristos#	Might define the following vars:
2941*440a403fSchristos#		HAVE_GETHOSTBYADDR_R
2942*440a403fSchristos#		HAVE_GETHOSTBYADDR_R_3
2943*440a403fSchristos#		HAVE_GETHOSTBYADDR_R_5
2944*440a403fSchristos#		HAVE_GETHOSTBYADDR_R_6
2945*440a403fSchristos#
2946*440a403fSchristos#--------------------------------------------------------------------
2947*440a403fSchristos
2948*440a403fSchristosAC_DEFUN([SC_TCL_GETHOSTBYNAME_R], [AC_CHECK_FUNC(gethostbyname_r, [
2949*440a403fSchristos    AC_CACHE_CHECK([for gethostbyname_r with 6 args], tcl_cv_api_gethostbyname_r_6, [
2950*440a403fSchristos    AC_TRY_COMPILE([
2951*440a403fSchristos	#include <netdb.h>
2952*440a403fSchristos    ], [
2953*440a403fSchristos	char *name;
2954*440a403fSchristos	struct hostent *he, *res;
2955*440a403fSchristos	char buffer[2048];
2956*440a403fSchristos	int buflen = 2048;
2957*440a403fSchristos	int h_errnop;
2958*440a403fSchristos
2959*440a403fSchristos	(void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop);
2960*440a403fSchristos    ], tcl_cv_api_gethostbyname_r_6=yes, tcl_cv_api_gethostbyname_r_6=no)])
2961*440a403fSchristos    tcl_ok=$tcl_cv_api_gethostbyname_r_6
2962*440a403fSchristos    if test "$tcl_ok" = yes; then
2963*440a403fSchristos	AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
2964*440a403fSchristos    else
2965*440a403fSchristos	AC_CACHE_CHECK([for gethostbyname_r with 5 args], tcl_cv_api_gethostbyname_r_5, [
2966*440a403fSchristos	AC_TRY_COMPILE([
2967*440a403fSchristos	    #include <netdb.h>
2968*440a403fSchristos	], [
2969*440a403fSchristos	    char *name;
2970*440a403fSchristos	    struct hostent *he;
2971*440a403fSchristos	    char buffer[2048];
2972*440a403fSchristos	    int buflen = 2048;
2973*440a403fSchristos	    int h_errnop;
2974*440a403fSchristos
2975*440a403fSchristos	    (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop);
2976*440a403fSchristos	], tcl_cv_api_gethostbyname_r_5=yes, tcl_cv_api_gethostbyname_r_5=no)])
2977*440a403fSchristos	tcl_ok=$tcl_cv_api_gethostbyname_r_5
2978*440a403fSchristos	if test "$tcl_ok" = yes; then
2979*440a403fSchristos	    AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
2980*440a403fSchristos	else
2981*440a403fSchristos	    AC_CACHE_CHECK([for gethostbyname_r with 3 args], tcl_cv_api_gethostbyname_r_3, [
2982*440a403fSchristos	    AC_TRY_COMPILE([
2983*440a403fSchristos		#include <netdb.h>
2984*440a403fSchristos	    ], [
2985*440a403fSchristos		char *name;
2986*440a403fSchristos		struct hostent *he;
2987*440a403fSchristos		struct hostent_data data;
2988*440a403fSchristos
2989*440a403fSchristos		(void) gethostbyname_r(name, he, &data);
2990*440a403fSchristos	    ], tcl_cv_api_gethostbyname_r_3=yes, tcl_cv_api_gethostbyname_r_3=no)])
2991*440a403fSchristos	    tcl_ok=$tcl_cv_api_gethostbyname_r_3
2992*440a403fSchristos	    if test "$tcl_ok" = yes; then
2993*440a403fSchristos		AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
2994*440a403fSchristos	    fi
2995*440a403fSchristos	fi
2996*440a403fSchristos    fi
2997*440a403fSchristos    if test "$tcl_ok" = yes; then
2998*440a403fSchristos	AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2999*440a403fSchristos    fi
3000*440a403fSchristos])])
3001*440a403fSchristos
3002*440a403fSchristos#--------------------------------------------------------------------
3003*440a403fSchristos# SC_TCL_GETPWUID_R
3004*440a403fSchristos#
3005*440a403fSchristos#	Check if we have MT-safe variant of getpwuid() and if yes,
3006*440a403fSchristos#	which one exactly.
3007*440a403fSchristos#
3008*440a403fSchristos# Arguments:
3009*440a403fSchristos#	None
3010*440a403fSchristos#
3011*440a403fSchristos# Results:
3012*440a403fSchristos#
3013*440a403fSchristos#	Might define the following vars:
3014*440a403fSchristos#		HAVE_GETPWUID_R
3015*440a403fSchristos#		HAVE_GETPWUID_R_4
3016*440a403fSchristos#		HAVE_GETPWUID_R_5
3017*440a403fSchristos#
3018*440a403fSchristos#--------------------------------------------------------------------
3019*440a403fSchristos
3020*440a403fSchristosAC_DEFUN([SC_TCL_GETPWUID_R], [AC_CHECK_FUNC(getpwuid_r, [
3021*440a403fSchristos    AC_CACHE_CHECK([for getpwuid_r with 5 args], tcl_cv_api_getpwuid_r_5, [
3022*440a403fSchristos    AC_TRY_COMPILE([
3023*440a403fSchristos	#include <sys/types.h>
3024*440a403fSchristos	#include <pwd.h>
3025*440a403fSchristos    ], [
3026*440a403fSchristos	uid_t uid;
3027*440a403fSchristos	struct passwd pw, *pwp;
3028*440a403fSchristos	char buf[512];
3029*440a403fSchristos	int buflen = 512;
3030*440a403fSchristos
3031*440a403fSchristos	(void) getpwuid_r(uid, &pw, buf, buflen, &pwp);
3032*440a403fSchristos    ], tcl_cv_api_getpwuid_r_5=yes, tcl_cv_api_getpwuid_r_5=no)])
3033*440a403fSchristos    tcl_ok=$tcl_cv_api_getpwuid_r_5
3034*440a403fSchristos    if test "$tcl_ok" = yes; then
3035*440a403fSchristos	AC_DEFINE(HAVE_GETPWUID_R_5)
3036*440a403fSchristos    else
3037*440a403fSchristos	AC_CACHE_CHECK([for getpwuid_r with 4 args], tcl_cv_api_getpwuid_r_4, [
3038*440a403fSchristos	AC_TRY_COMPILE([
3039*440a403fSchristos	    #include <sys/types.h>
3040*440a403fSchristos	    #include <pwd.h>
3041*440a403fSchristos	], [
3042*440a403fSchristos	    uid_t uid;
3043*440a403fSchristos	    struct passwd pw;
3044*440a403fSchristos	    char buf[512];
3045*440a403fSchristos	    int buflen = 512;
3046*440a403fSchristos
3047*440a403fSchristos	    (void)getpwnam_r(uid, &pw, buf, buflen);
3048*440a403fSchristos	], tcl_cv_api_getpwuid_r_4=yes, tcl_cv_api_getpwuid_r_4=no)])
3049*440a403fSchristos	tcl_ok=$tcl_cv_api_getpwuid_r_4
3050*440a403fSchristos	if test "$tcl_ok" = yes; then
3051*440a403fSchristos	    AC_DEFINE(HAVE_GETPWUID_R_4)
3052*440a403fSchristos	fi
3053*440a403fSchristos    fi
3054*440a403fSchristos    if test "$tcl_ok" = yes; then
3055*440a403fSchristos	AC_DEFINE(HAVE_GETPWUID_R)
3056*440a403fSchristos    fi
3057*440a403fSchristos])])
3058*440a403fSchristos
3059*440a403fSchristos#--------------------------------------------------------------------
3060*440a403fSchristos# SC_TCL_GETPWNAM_R
3061*440a403fSchristos#
3062*440a403fSchristos#	Check if we have MT-safe variant of getpwnam() and if yes,
3063*440a403fSchristos#	which one exactly.
3064*440a403fSchristos#
3065*440a403fSchristos# Arguments:
3066*440a403fSchristos#	None
3067*440a403fSchristos#
3068*440a403fSchristos# Results:
3069*440a403fSchristos#
3070*440a403fSchristos#	Might define the following vars:
3071*440a403fSchristos#		HAVE_GETPWNAM_R
3072*440a403fSchristos#		HAVE_GETPWNAM_R_4
3073*440a403fSchristos#		HAVE_GETPWNAM_R_5
3074*440a403fSchristos#
3075*440a403fSchristos#--------------------------------------------------------------------
3076*440a403fSchristos
3077*440a403fSchristosAC_DEFUN([SC_TCL_GETPWNAM_R], [AC_CHECK_FUNC(getpwnam_r, [
3078*440a403fSchristos    AC_CACHE_CHECK([for getpwnam_r with 5 args], tcl_cv_api_getpwnam_r_5, [
3079*440a403fSchristos    AC_TRY_COMPILE([
3080*440a403fSchristos	#include <sys/types.h>
3081*440a403fSchristos	#include <pwd.h>
3082*440a403fSchristos    ], [
3083*440a403fSchristos	char *name;
3084*440a403fSchristos	struct passwd pw, *pwp;
3085*440a403fSchristos	char buf[512];
3086*440a403fSchristos	int buflen = 512;
3087*440a403fSchristos
3088*440a403fSchristos	(void) getpwnam_r(name, &pw, buf, buflen, &pwp);
3089*440a403fSchristos    ], tcl_cv_api_getpwnam_r_5=yes, tcl_cv_api_getpwnam_r_5=no)])
3090*440a403fSchristos    tcl_ok=$tcl_cv_api_getpwnam_r_5
3091*440a403fSchristos    if test "$tcl_ok" = yes; then
3092*440a403fSchristos	AC_DEFINE(HAVE_GETPWNAM_R_5)
3093*440a403fSchristos    else
3094*440a403fSchristos	AC_CACHE_CHECK([for getpwnam_r with 4 args], tcl_cv_api_getpwnam_r_4, [
3095*440a403fSchristos	AC_TRY_COMPILE([
3096*440a403fSchristos	    #include <sys/types.h>
3097*440a403fSchristos	    #include <pwd.h>
3098*440a403fSchristos	], [
3099*440a403fSchristos	    char *name;
3100*440a403fSchristos	    struct passwd pw;
3101*440a403fSchristos	    char buf[512];
3102*440a403fSchristos	    int buflen = 512;
3103*440a403fSchristos
3104*440a403fSchristos	    (void)getpwnam_r(name, &pw, buf, buflen);
3105*440a403fSchristos	], tcl_cv_api_getpwnam_r_4=yes, tcl_cv_api_getpwnam_r_4=no)])
3106*440a403fSchristos	tcl_ok=$tcl_cv_api_getpwnam_r_4
3107*440a403fSchristos	if test "$tcl_ok" = yes; then
3108*440a403fSchristos	    AC_DEFINE(HAVE_GETPWNAM_R_4)
3109*440a403fSchristos	fi
3110*440a403fSchristos    fi
3111*440a403fSchristos    if test "$tcl_ok" = yes; then
3112*440a403fSchristos	AC_DEFINE(HAVE_GETPWNAM_R)
3113*440a403fSchristos    fi
3114*440a403fSchristos])])
3115*440a403fSchristos
3116*440a403fSchristos#--------------------------------------------------------------------
3117*440a403fSchristos# SC_TCL_GETGRGID_R
3118*440a403fSchristos#
3119*440a403fSchristos#	Check if we have MT-safe variant of getgrgid() and if yes,
3120*440a403fSchristos#	which one exactly.
3121*440a403fSchristos#
3122*440a403fSchristos# Arguments:
3123*440a403fSchristos#	None
3124*440a403fSchristos#
3125*440a403fSchristos# Results:
3126*440a403fSchristos#
3127*440a403fSchristos#	Might define the following vars:
3128*440a403fSchristos#		HAVE_GETGRGID_R
3129*440a403fSchristos#		HAVE_GETGRGID_R_4
3130*440a403fSchristos#		HAVE_GETGRGID_R_5
3131*440a403fSchristos#
3132*440a403fSchristos#--------------------------------------------------------------------
3133*440a403fSchristos
3134*440a403fSchristosAC_DEFUN([SC_TCL_GETGRGID_R], [AC_CHECK_FUNC(getgrgid_r, [
3135*440a403fSchristos    AC_CACHE_CHECK([for getgrgid_r with 5 args], tcl_cv_api_getgrgid_r_5, [
3136*440a403fSchristos    AC_TRY_COMPILE([
3137*440a403fSchristos	#include <sys/types.h>
3138*440a403fSchristos	#include <grp.h>
3139*440a403fSchristos    ], [
3140*440a403fSchristos	gid_t gid;
3141*440a403fSchristos	struct group gr, *grp;
3142*440a403fSchristos	char buf[512];
3143*440a403fSchristos	int buflen = 512;
3144*440a403fSchristos
3145*440a403fSchristos	(void) getgrgid_r(gid, &gr, buf, buflen, &grp);
3146*440a403fSchristos    ], tcl_cv_api_getgrgid_r_5=yes, tcl_cv_api_getgrgid_r_5=no)])
3147*440a403fSchristos    tcl_ok=$tcl_cv_api_getgrgid_r_5
3148*440a403fSchristos    if test "$tcl_ok" = yes; then
3149*440a403fSchristos	AC_DEFINE(HAVE_GETGRGID_R_5)
3150*440a403fSchristos    else
3151*440a403fSchristos	AC_CACHE_CHECK([for getgrgid_r with 4 args], tcl_cv_api_getgrgid_r_4, [
3152*440a403fSchristos	AC_TRY_COMPILE([
3153*440a403fSchristos	    #include <sys/types.h>
3154*440a403fSchristos	    #include <grp.h>
3155*440a403fSchristos	], [
3156*440a403fSchristos	    gid_t gid;
3157*440a403fSchristos	    struct group gr;
3158*440a403fSchristos	    char buf[512];
3159*440a403fSchristos	    int buflen = 512;
3160*440a403fSchristos
3161*440a403fSchristos	    (void)getgrgid_r(gid, &gr, buf, buflen);
3162*440a403fSchristos	], tcl_cv_api_getgrgid_r_4=yes, tcl_cv_api_getgrgid_r_4=no)])
3163*440a403fSchristos	tcl_ok=$tcl_cv_api_getgrgid_r_4
3164*440a403fSchristos	if test "$tcl_ok" = yes; then
3165*440a403fSchristos	    AC_DEFINE(HAVE_GETGRGID_R_4)
3166*440a403fSchristos	fi
3167*440a403fSchristos    fi
3168*440a403fSchristos    if test "$tcl_ok" = yes; then
3169*440a403fSchristos	AC_DEFINE(HAVE_GETGRGID_R)
3170*440a403fSchristos    fi
3171*440a403fSchristos])])
3172*440a403fSchristos
3173*440a403fSchristos#--------------------------------------------------------------------
3174*440a403fSchristos# SC_TCL_GETGRNAM_R
3175*440a403fSchristos#
3176*440a403fSchristos#	Check if we have MT-safe variant of getgrnam() and if yes,
3177*440a403fSchristos#	which one exactly.
3178*440a403fSchristos#
3179*440a403fSchristos# Arguments:
3180*440a403fSchristos#	None
3181*440a403fSchristos#
3182*440a403fSchristos# Results:
3183*440a403fSchristos#
3184*440a403fSchristos#	Might define the following vars:
3185*440a403fSchristos#		HAVE_GETGRNAM_R
3186*440a403fSchristos#		HAVE_GETGRNAM_R_4
3187*440a403fSchristos#		HAVE_GETGRNAM_R_5
3188*440a403fSchristos#
3189*440a403fSchristos#--------------------------------------------------------------------
3190*440a403fSchristos
3191*440a403fSchristosAC_DEFUN([SC_TCL_GETGRNAM_R], [AC_CHECK_FUNC(getgrnam_r, [
3192*440a403fSchristos    AC_CACHE_CHECK([for getgrnam_r with 5 args], tcl_cv_api_getgrnam_r_5, [
3193*440a403fSchristos    AC_TRY_COMPILE([
3194*440a403fSchristos	#include <sys/types.h>
3195*440a403fSchristos	#include <grp.h>
3196*440a403fSchristos    ], [
3197*440a403fSchristos	char *name;
3198*440a403fSchristos	struct group gr, *grp;
3199*440a403fSchristos	char buf[512];
3200*440a403fSchristos	int buflen = 512;
3201*440a403fSchristos
3202*440a403fSchristos	(void) getgrnam_r(name, &gr, buf, buflen, &grp);
3203*440a403fSchristos    ], tcl_cv_api_getgrnam_r_5=yes, tcl_cv_api_getgrnam_r_5=no)])
3204*440a403fSchristos    tcl_ok=$tcl_cv_api_getgrnam_r_5
3205*440a403fSchristos    if test "$tcl_ok" = yes; then
3206*440a403fSchristos	AC_DEFINE(HAVE_GETGRNAM_R_5)
3207*440a403fSchristos    else
3208*440a403fSchristos	AC_CACHE_CHECK([for getgrnam_r with 4 args], tcl_cv_api_getgrnam_r_4, [
3209*440a403fSchristos	AC_TRY_COMPILE([
3210*440a403fSchristos	    #include <sys/types.h>
3211*440a403fSchristos	    #include <grp.h>
3212*440a403fSchristos	], [
3213*440a403fSchristos	    char *name;
3214*440a403fSchristos	    struct group gr;
3215*440a403fSchristos	    char buf[512];
3216*440a403fSchristos	    int buflen = 512;
3217*440a403fSchristos
3218*440a403fSchristos	    (void)getgrnam_r(name, &gr, buf, buflen);
3219*440a403fSchristos	], tcl_cv_api_getgrnam_r_4=yes, tcl_cv_api_getgrnam_r_4=no)])
3220*440a403fSchristos	tcl_ok=$tcl_cv_api_getgrnam_r_4
3221*440a403fSchristos	if test "$tcl_ok" = yes; then
3222*440a403fSchristos	    AC_DEFINE(HAVE_GETGRNAM_R_4)
3223*440a403fSchristos	fi
3224*440a403fSchristos    fi
3225*440a403fSchristos    if test "$tcl_ok" = yes; then
3226*440a403fSchristos	AC_DEFINE(HAVE_GETGRNAM_R)
3227*440a403fSchristos    fi
3228*440a403fSchristos])])
3229*440a403fSchristos
3230*440a403fSchristos#--------------------------------------------------------------------
3231*440a403fSchristos# SC_CONFIG_COMMANDS_PRE(CMDS)
3232*440a403fSchristos#
3233*440a403fSchristos#	Replacement for autoconf 2.5x AC_COMMANDS_PRE:
3234*440a403fSchristos#		Commands to run right before config.status is
3235*440a403fSchristos#		created. Accumulates.
3236*440a403fSchristos#
3237*440a403fSchristos#	Requires presence of SC_OUTPUT_COMMANDS_PRE at the end
3238*440a403fSchristos#	of configure.ac (right before AC_OUTPUT).
3239*440a403fSchristos#
3240*440a403fSchristos#--------------------------------------------------------------------
3241*440a403fSchristos
3242*440a403fSchristosAC_DEFUN([SC_CONFIG_COMMANDS_PRE], [
3243*440a403fSchristos    define([SC_OUTPUT_COMMANDS_PRE], defn([SC_OUTPUT_COMMANDS_PRE])[$1
3244*440a403fSchristos])])
3245*440a403fSchristosAC_DEFUN([SC_OUTPUT_COMMANDS_PRE])
3246*440a403fSchristos
3247