~ubuntu-branches/ubuntu/raring/tcl8.5/raring

« back to all changes in this revision

Viewing changes to .pc/rpath.diff/unix/tcl.m4

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-07-02 15:39:58 UTC
  • mfrom: (11.2.4 sid)
  • Revision ID: package-import@ubuntu.com-20120702153958-9wkr42dghr437ds3
Tags: 8.5.11-2ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Don't use tcl itself to install things when building, to allow for
    cross-building.

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