~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to build/tcl.m4

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

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