OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [config/] [tcl.m4] - Blame information for rev 635

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.