OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [config/] [tcl.m4] - Blame information for rev 281

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

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

powered by: WebSVN 2.1.0

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