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