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