~ubuntu-branches/ubuntu/intrepid/graphicsmagick/intrepid

« back to all changes in this revision

Viewing changes to TclMagick/tcl.m4

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2006-05-06 16:28:08 UTC
  • Revision ID: james.westby@ubuntu.com-20060506162808-vt2ni3r5nytcszms
Tags: upstream-1.1.7
ImportĀ upstreamĀ versionĀ 1.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# tcl.m4 --
 
2
#
 
3
#       This file provides a set of autoconf macros to help TEA-enable
 
4
#       a Tcl extension.
 
5
#
 
6
# Copyright (c) 1999-2000 Ajuba Solutions.
 
7
# Copyright (c) 2002-2003 ActiveState Corporation.
 
8
#
 
9
# See the file "license.terms" for information on usage and redistribution
 
10
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
11
#
 
12
# RCS: @(#) $Id: tcl.m4,v 1.1 2004/01/25 23:42:33 davidw Exp $
 
13
 
 
14
AC_PREREQ(2.50)
 
15
 
 
16
#------------------------------------------------------------------------
 
17
# TEA_PATH_TCLCONFIG --
 
18
#
 
19
#       Locate the tclConfig.sh file and perform a sanity check on
 
20
#       the Tcl compile flags
 
21
#
 
22
# Arguments:
 
23
#       none
 
24
#
 
25
# Results:
 
26
#
 
27
#       Adds the following arguments to configure:
 
28
#               --with-tcl=...
 
29
#
 
30
#       Defines the following vars:
 
31
#               TCL_BIN_DIR     Full path to the directory containing
 
32
#                               the tclConfig.sh file
 
33
#------------------------------------------------------------------------
 
34
 
 
35
AC_DEFUN(TEA_PATH_TCLCONFIG, [
 
36
    dnl Make sure we are initialized
 
37
    AC_REQUIRE([TEA_INIT])
 
38
    #
 
39
    # Ok, lets find the tcl configuration
 
40
    # First, look for one uninstalled.
 
41
    # the alternative search directory is invoked by --with-tcl
 
42
    #
 
43
 
 
44
    if test x"${no_tcl}" = x ; then
 
45
        # we reset no_tcl in case something fails here
 
46
        no_tcl=true
 
47
        AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
 
48
        AC_MSG_CHECKING([for Tcl configuration])
 
49
        AC_CACHE_VAL(ac_cv_c_tclconfig,[
 
50
 
 
51
            # First check to see if --with-tcl was specified.
 
52
            if test x"${with_tclconfig}" != x ; then
 
53
                if test -f "${with_tclconfig}/tclConfig.sh" ; then
 
54
                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
 
55
                else
 
56
                    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
 
57
                fi
 
58
            fi
 
59
 
 
60
            # then check for a private Tcl installation
 
61
            if test x"${ac_cv_c_tclconfig}" = x ; then
 
62
                for i in \
 
63
                        ../tcl \
 
64
                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
 
65
                        ../../tcl \
 
66
                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
 
67
                        ../../../tcl \
 
68
                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
 
69
                    if test -f "$i/unix/tclConfig.sh" ; then
 
70
                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
 
71
                        break
 
72
                    fi
 
73
                done
 
74
            fi
 
75
 
 
76
            # check in a few common install locations
 
77
            if test x"${ac_cv_c_tclconfig}" = x ; then
 
78
                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
 
79
                        `ls -d ${prefix}/lib 2>/dev/null` \
 
80
                        `ls -d /usr/local/lib 2>/dev/null` \
 
81
                        `ls -d /usr/contrib/lib 2>/dev/null` \
 
82
                        `ls -d /usr/lib 2>/dev/null` \
 
83
                        ; do
 
84
                    if test -f "$i/tclConfig.sh" ; then
 
85
                        ac_cv_c_tclconfig=`(cd $i; pwd)`
 
86
                        break
 
87
                    fi
 
88
                done
 
89
            fi
 
90
 
 
91
            # check in a few other private locations
 
92
            if test x"${ac_cv_c_tclconfig}" = x ; then
 
93
                for i in \
 
94
                        ${srcdir}/../tcl \
 
95
                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
 
96
                    if test -f "$i/unix/tclConfig.sh" ; then
 
97
                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
 
98
                    break
 
99
                fi
 
100
                done
 
101
            fi
 
102
        ])
 
103
 
 
104
        if test x"${ac_cv_c_tclconfig}" = x ; then
 
105
            TCL_BIN_DIR="# no Tcl configs found"
 
106
            AC_MSG_WARN("Cannot find Tcl configuration definitions")
 
107
            exit 0
 
108
        else
 
109
            no_tcl=
 
110
            TCL_BIN_DIR=${ac_cv_c_tclconfig}
 
111
            AC_MSG_RESULT([found $TCL_BIN_DIR/tclConfig.sh])
 
112
        fi
 
113
    fi
 
114
])
 
115
 
 
116
#------------------------------------------------------------------------
 
117
# TEA_PATH_TKCONFIG --
 
118
#
 
119
#       Locate the tkConfig.sh file
 
120
#
 
121
# Arguments:
 
122
#       none
 
123
#
 
124
# Results:
 
125
#
 
126
#       Adds the following arguments to configure:
 
127
#               --with-tk=...
 
128
#
 
129
#       Defines the following vars:
 
130
#               TK_BIN_DIR      Full path to the directory containing
 
131
#                               the tkConfig.sh file
 
132
#------------------------------------------------------------------------
 
133
 
 
134
AC_DEFUN(TEA_PATH_TKCONFIG, [
 
135
    #
 
136
    # Ok, lets find the tk configuration
 
137
    # First, look for one uninstalled.
 
138
    # the alternative search directory is invoked by --with-tk
 
139
    #
 
140
 
 
141
    if test x"${no_tk}" = x ; then
 
142
        # we reset no_tk in case something fails here
 
143
        no_tk=true
 
144
        AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
 
145
        AC_MSG_CHECKING([for Tk configuration])
 
146
        AC_CACHE_VAL(ac_cv_c_tkconfig,[
 
147
 
 
148
            # First check to see if --with-tkconfig was specified.
 
149
            if test x"${with_tkconfig}" != x ; then
 
150
                if test -f "${with_tkconfig}/tkConfig.sh" ; then
 
151
                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
 
152
                else
 
153
                    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
 
154
                fi
 
155
            fi
 
156
 
 
157
            # then check for a private Tk library
 
158
            if test x"${ac_cv_c_tkconfig}" = x ; then
 
159
                for i in \
 
160
                        ../tk \
 
161
                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
 
162
                        ../../tk \
 
163
                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
 
164
                        ../../../tk \
 
165
                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
 
166
                    if test -f "$i/unix/tkConfig.sh" ; then
 
167
                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
 
168
                        break
 
169
                    fi
 
170
                done
 
171
            fi
 
172
            # check in a few common install locations
 
173
            if test x"${ac_cv_c_tkconfig}" = x ; then
 
174
                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
 
175
                        `ls -d ${prefix}/lib 2>/dev/null` \
 
176
                        `ls -d /usr/local/lib 2>/dev/null` \
 
177
                        `ls -d /usr/contrib/lib 2>/dev/null` \
 
178
                        `ls -d /usr/lib 2>/dev/null` \
 
179
                        ; do
 
180
                    if test -f "$i/tkConfig.sh" ; then
 
181
                        ac_cv_c_tkconfig=`(cd $i; pwd)`
 
182
                        break
 
183
                    fi
 
184
                done
 
185
            fi
 
186
            # check in a few other private locations
 
187
            if test x"${ac_cv_c_tkconfig}" = x ; then
 
188
                for i in \
 
189
                        ${srcdir}/../tk \
 
190
                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
 
191
                    if test -f "$i/unix/tkConfig.sh" ; then
 
192
                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
 
193
                        break
 
194
                    fi
 
195
                done
 
196
            fi
 
197
        ])
 
198
        if test x"${ac_cv_c_tkconfig}" = x ; then
 
199
            TK_BIN_DIR="# no Tk configs found"
 
200
            AC_MSG_WARN("Cannot find Tk configuration definitions")
 
201
            exit 0
 
202
        else
 
203
            no_tk=
 
204
            TK_BIN_DIR=${ac_cv_c_tkconfig}
 
205
            AC_MSG_RESULT([found $TK_BIN_DIR/tkConfig.sh])
 
206
        fi
 
207
    fi
 
208
 
 
209
])
 
210
 
 
211
#------------------------------------------------------------------------
 
212
# TEA_LOAD_TCLCONFIG --
 
213
#
 
214
#       Load the tclConfig.sh file
 
215
#
 
216
# Arguments:
 
217
#       
 
218
#       Requires the following vars to be set:
 
219
#               TCL_BIN_DIR
 
220
#
 
221
# Results:
 
222
#
 
223
#       Subst the following vars:
 
224
#               TCL_BIN_DIR
 
225
#               TCL_SRC_DIR
 
226
#               TCL_LIB_FILE
 
227
#
 
228
#------------------------------------------------------------------------
 
229
 
 
230
AC_DEFUN(TEA_LOAD_TCLCONFIG, [
 
231
    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
 
232
 
 
233
    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
 
234
        AC_MSG_RESULT([loading])
 
235
        . $TCL_BIN_DIR/tclConfig.sh
 
236
    else
 
237
        AC_MSG_RESULT([file not found])
 
238
    fi
 
239
 
 
240
    #
 
241
    # If the TCL_BIN_DIR is the build directory (not the install directory),
 
242
    # then set the common variable name to the value of the build variables.
 
243
    # For example, the variable TCL_LIB_SPEC will be set to the value
 
244
    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
 
245
    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
 
246
    # installed and uninstalled version of Tcl.
 
247
    #
 
248
 
 
249
    if test -f $TCL_BIN_DIR/Makefile ; then
 
250
        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
 
251
        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
 
252
        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
 
253
    fi
 
254
 
 
255
    #
 
256
    # eval is required to do the TCL_DBGX substitution
 
257
    #
 
258
 
 
259
    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
 
260
    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
 
261
    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
 
262
 
 
263
    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
 
264
    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
 
265
    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
 
266
 
 
267
    AC_SUBST(TCL_VERSION)
 
268
    AC_SUBST(TCL_BIN_DIR)
 
269
    AC_SUBST(TCL_SRC_DIR)
 
270
 
 
271
    AC_SUBST(TCL_LIB_FILE)
 
272
    AC_SUBST(TCL_LIB_FLAG)
 
273
    AC_SUBST(TCL_LIB_SPEC)
 
274
 
 
275
    AC_SUBST(TCL_STUB_LIB_FILE)
 
276
    AC_SUBST(TCL_STUB_LIB_FLAG)
 
277
    AC_SUBST(TCL_STUB_LIB_SPEC)
 
278
 
 
279
    #AC_SUBST(TCL_DBGX)
 
280
    AC_SUBST(TCL_LIBS)
 
281
    AC_SUBST(TCL_DEFS)
 
282
    AC_SUBST(TCL_EXTRA_CFLAGS)
 
283
    AC_SUBST(TCL_LD_FLAGS)
 
284
    AC_SUBST(TCL_SHLIB_LD_LIBS)
 
285
    #AC_SUBST(TCL_BUILD_LIB_SPEC)
 
286
    #AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
 
287
])
 
288
 
 
289
#------------------------------------------------------------------------
 
290
# TEA_LOAD_TKCONFIG --
 
291
#
 
292
#       Load the tkConfig.sh file
 
293
#
 
294
# Arguments:
 
295
#       
 
296
#       Requires the following vars to be set:
 
297
#               TK_BIN_DIR
 
298
#
 
299
# Results:
 
300
#
 
301
#       Sets the following vars that should be in tkConfig.sh:
 
302
#               TK_BIN_DIR
 
303
#------------------------------------------------------------------------
 
304
 
 
305
AC_DEFUN(TEA_LOAD_TKCONFIG, [
 
306
    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
 
307
 
 
308
    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
 
309
        AC_MSG_RESULT([loading])
 
310
        . $TK_BIN_DIR/tkConfig.sh
 
311
    else
 
312
        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
 
313
    fi
 
314
 
 
315
    #
 
316
    # If the TK_BIN_DIR is the build directory (not the install directory),
 
317
    # then set the common variable name to the value of the build variables.
 
318
    # For example, the variable TK_LIB_SPEC will be set to the value
 
319
    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
 
320
    # instead of TK_BUILD_LIB_SPEC since it will work with both an
 
321
    # installed and uninstalled version of Tcl.
 
322
    #
 
323
 
 
324
    if test -f $TK_BIN_DIR/Makefile ; then
 
325
        TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
 
326
        TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
 
327
        TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
 
328
    fi
 
329
 
 
330
    #
 
331
    # eval is required to do the TK_DBGX substitution
 
332
    #
 
333
 
 
334
    eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
 
335
    eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
 
336
    eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
 
337
 
 
338
    eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
 
339
    eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
 
340
    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
 
341
 
 
342
    AC_SUBST(TK_VERSION)
 
343
    AC_SUBST(TK_BIN_DIR)
 
344
    AC_SUBST(TK_SRC_DIR)
 
345
 
 
346
    AC_SUBST(TK_LIB_FILE)
 
347
    AC_SUBST(TK_LIB_FLAG)
 
348
    AC_SUBST(TK_LIB_SPEC)
 
349
 
 
350
    AC_SUBST(TK_STUB_LIB_FILE)
 
351
    AC_SUBST(TK_STUB_LIB_FLAG)
 
352
    AC_SUBST(TK_STUB_LIB_SPEC)
 
353
 
 
354
    AC_SUBST(TK_LIBS)
 
355
    AC_SUBST(TK_XINCLUDES)
 
356
])
 
357
 
 
358
#------------------------------------------------------------------------
 
359
# TEA_ENABLE_SHARED --
 
360
#
 
361
#       Allows the building of shared libraries
 
362
#
 
363
# Arguments:
 
364
#       none
 
365
#       
 
366
# Results:
 
367
#
 
368
#       Adds the following arguments to configure:
 
369
#               --enable-shared=yes|no
 
370
#
 
371
#       Defines the following vars:
 
372
#               STATIC_BUILD    Used for building import/export libraries
 
373
#                               on Windows.
 
374
#
 
375
#       Sets the following vars:
 
376
#               SHARED_BUILD    Value of 1 or 0
 
377
#------------------------------------------------------------------------
 
378
 
 
379
AC_DEFUN(TEA_ENABLE_SHARED, [
 
380
    AC_MSG_CHECKING([how to build libraries])
 
381
    AC_ARG_ENABLE(shared,
 
382
        [  --enable-shared         build and link with shared libraries [--enable-shared]],
 
383
        [tcl_ok=$enableval], [tcl_ok=yes])
 
384
 
 
385
    if test "${enable_shared+set}" = set; then
 
386
        enableval="$enable_shared"
 
387
        tcl_ok=$enableval
 
388
    else
 
389
        tcl_ok=yes
 
390
    fi
 
391
 
 
392
    if test "$tcl_ok" = "yes" ; then
 
393
        AC_MSG_RESULT([shared])
 
394
        SHARED_BUILD=1
 
395
    else
 
396
        AC_MSG_RESULT([static])
 
397
        SHARED_BUILD=0
 
398
        AC_DEFINE(STATIC_BUILD)
 
399
    fi
 
400
    AC_SUBST(SHARED_BUILD)
 
401
])
 
402
 
 
403
#------------------------------------------------------------------------
 
404
# TEA_ENABLE_THREADS --
 
405
#
 
406
#       Specify if thread support should be enabled.  If "yes" is
 
407
#       specified as an arg (optional), threads are enabled by default.
 
408
#
 
409
# Arguments:
 
410
#       none
 
411
#       
 
412
# Results:
 
413
#
 
414
#       Adds the following arguments to configure:
 
415
#               --enable-threads
 
416
#
 
417
#       Sets the following vars:
 
418
#               THREADS_LIBS    Thread library(s)
 
419
#
 
420
#       Defines the following vars:
 
421
#               TCL_THREADS
 
422
#               _REENTRANT
 
423
#
 
424
#------------------------------------------------------------------------
 
425
 
 
426
AC_DEFUN(TEA_ENABLE_THREADS, [
 
427
    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
 
428
        [tcl_ok=$enableval], [tcl_ok=$1])
 
429
 
 
430
    if test "$tcl_ok" = "yes"; then
 
431
        TCL_THREADS=1
 
432
 
 
433
        if test "${TEA_PLATFORM}" != "windows" ; then
 
434
            # We are always OK on Windows, so check what this platform wants.
 
435
            AC_DEFINE(USE_THREAD_ALLOC)
 
436
            AC_DEFINE(_REENTRANT)
 
437
            AC_DEFINE(_THREAD_SAFE)
 
438
            AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
 
439
            if test "$tcl_ok" = "no"; then
 
440
                # Check a little harder for __pthread_mutex_init in the
 
441
                # same library, as some systems hide it there until
 
442
                # pthread.h is defined.  We could alternatively do an
 
443
                # AC_TRY_COMPILE with pthread.h, but that will work with
 
444
                # libpthread really doesn't exist, like AIX 4.2.
 
445
                # [Bug: 4359]
 
446
                AC_CHECK_LIB(pthread, __pthread_mutex_init,
 
447
                    tcl_ok=yes, tcl_ok=no)
 
448
            fi
 
449
            
 
450
            if test "$tcl_ok" = "yes"; then
 
451
                # The space is needed
 
452
                THREADS_LIBS=" -lpthread"
 
453
            else
 
454
                AC_CHECK_LIB(pthreads, pthread_mutex_init,
 
455
                    tcl_ok=yes, tcl_ok=no)
 
456
                if test "$tcl_ok" = "yes"; then
 
457
                    # The space is needed
 
458
                    THREADS_LIBS=" -lpthreads"
 
459
                else
 
460
                    AC_CHECK_LIB(c, pthread_mutex_init,
 
461
                        tcl_ok=yes, tcl_ok=no)
 
462
                    if test "$tcl_ok" = "no"; then
 
463
                        AC_CHECK_LIB(c_r, pthread_mutex_init,
 
464
                            tcl_ok=yes, tcl_ok=no)
 
465
                        if test "$tcl_ok" = "yes"; then
 
466
                            # The space is needed
 
467
                            THREADS_LIBS=" -pthread"
 
468
                        else
 
469
                            TCL_THREADS=0
 
470
                            AC_MSG_WARN("Don t know how to find pthread lib on your system - thread support disabled")
 
471
                        fi
 
472
                    fi
 
473
                fi
 
474
            fi
 
475
 
 
476
            # Does the pthread-implementation provide
 
477
            # 'pthread_attr_setstacksize' ?
 
478
 
 
479
            ac_saved_libs=$LIBS
 
480
            LIBS="$LIBS $THREADS_LIBS"
 
481
            AC_CHECK_FUNCS(pthread_attr_setstacksize)
 
482
            LIBS=$ac_saved_libs
 
483
            AC_CHECK_FUNCS(readdir_r)
 
484
        fi
 
485
    else
 
486
        TCL_THREADS=0
 
487
    fi
 
488
    # Do checking message here to not mess up interleaved configure output
 
489
    AC_MSG_CHECKING([for building with threads])
 
490
    if test "${TCL_THREADS}" = "1"; then
 
491
        AC_DEFINE(TCL_THREADS)
 
492
        AC_MSG_RESULT([yes])
 
493
    else
 
494
        AC_MSG_RESULT([no (default)])
 
495
    fi
 
496
    # TCL_THREADS sanity checking.  See if our request for building with
 
497
    # threads is the same as the way Tcl was built.  If not, warn the user.
 
498
    case ${TCL_DEFS} in
 
499
        *THREADS=1*)
 
500
            if test "${TCL_THREADS}" = "0"; then
 
501
                AC_MSG_WARN([
 
502
    Building ${PACKAGE_NAME} without threads enabled, but building against a Tcl
 
503
    that IS thread-enabled.])
 
504
            fi
 
505
            ;;
 
506
        *)
 
507
            if test "${TCL_THREADS}" = "1"; then
 
508
                AC_MSG_WARN([
 
509
    --enable-threads requested, but attempting building against a Tcl
 
510
    that is NOT thread-enabled.])
 
511
            fi
 
512
            ;;
 
513
    esac
 
514
    AC_SUBST(TCL_THREADS)
 
515
])
 
516
 
 
517
#------------------------------------------------------------------------
 
518
# TEA_ENABLE_SYMBOLS --
 
519
#
 
520
#       Specify if debugging symbols should be used
 
521
#       Memory (TCL_MEM_DEBUG) debugging can also be enabled.
 
522
#
 
523
# Arguments:
 
524
#       none
 
525
#       
 
526
#       Requires the following vars to be set:
 
527
#               CFLAGS_DEBUG
 
528
#               CFLAGS_OPTIMIZE
 
529
#               LDFLAGS_DEBUG
 
530
#               LDFLAGS_OPTIMIZE
 
531
#       
 
532
# Results:
 
533
#
 
534
#       Adds the following arguments to configure:
 
535
#               --enable-symbols
 
536
#
 
537
#       Defines the following vars:
 
538
#               CFLAGS_DEFAULT  Sets to CFLAGS_DEBUG if true
 
539
#                               Sets to CFLAGS_OPTIMIZE if false
 
540
#               LDFLAGS_DEFAULT Sets to LDFLAGS_DEBUG if true
 
541
#                               Sets to LDFLAGS_OPTIMIZE if false
 
542
#               DBGX            Debug library extension
 
543
#
 
544
#------------------------------------------------------------------------
 
545
 
 
546
AC_DEFUN(TEA_ENABLE_SYMBOLS, [
 
547
    dnl Make sure we are initialized
 
548
    AC_REQUIRE([TEA_CONFIG_CFLAGS])
 
549
 
 
550
    if test "${TEA_PLATFORM}" = "windows" ; then
 
551
        tcl_dbgx=d
 
552
    else
 
553
        tcl_dbgx=g
 
554
    fi
 
555
 
 
556
    AC_MSG_CHECKING([for build with symbols])
 
557
    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
 
558
    if test "$tcl_ok" = "no"; then
 
559
        CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
 
560
        LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
 
561
        DBGX=""
 
562
        TCL_DBGX=""
 
563
        AC_MSG_RESULT([no])
 
564
    else
 
565
        CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
 
566
        LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
 
567
        DBGX=${tcl_dbgx}
 
568
        TCL_DBGX=${tcl_dbgx}
 
569
        if test "$tcl_ok" = "yes"; then
 
570
            AC_MSG_RESULT([yes (standard debugging)])
 
571
        fi
 
572
    fi
 
573
    if test "${TEA_PLATFORM}" != "windows" ; then
 
574
        LDFLAGS_DEFAULT="${LDFLAGS}"
 
575
    fi
 
576
 
 
577
    AC_SUBST(TCL_DBGX)
 
578
    AC_SUBST(CFLAGS_DEFAULT)
 
579
    AC_SUBST(LDFLAGS_DEFAULT)
 
580
 
 
581
    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
 
582
        AC_DEFINE(TCL_MEM_DEBUG)
 
583
    fi
 
584
 
 
585
    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
 
586
        if test "$tcl_ok" = "all"; then
 
587
            AC_MSG_RESULT([enabled symbols mem debugging])
 
588
        else
 
589
            AC_MSG_RESULT([enabled $tcl_ok debugging])
 
590
        fi
 
591
    fi
 
592
])
 
593
 
 
594
#------------------------------------------------------------------------
 
595
# TEA_ENABLE_LANGINFO --
 
596
#
 
597
#       Allows use of modern nl_langinfo check for better l10n.
 
598
#       This is only relevant for Unix.
 
599
#
 
600
# Arguments:
 
601
#       none
 
602
#       
 
603
# Results:
 
604
#
 
605
#       Adds the following arguments to configure:
 
606
#               --enable-langinfo=yes|no (default is yes)
 
607
#
 
608
#       Defines the following vars:
 
609
#               HAVE_LANGINFO   Triggers use of nl_langinfo if defined.
 
610
#
 
611
#------------------------------------------------------------------------
 
612
 
 
613
AC_DEFUN(TEA_ENABLE_LANGINFO, [
 
614
    AC_ARG_ENABLE(langinfo,
 
615
        [  --enable-langinfo      use nl_langinfo if possible to determine
 
616
                          encoding at startup, otherwise use old heuristic],
 
617
        [langinfo_ok=$enableval], [langinfo_ok=yes])
 
618
 
 
619
    HAVE_LANGINFO=0
 
620
    if test "$langinfo_ok" = "yes"; then
 
621
        if test "$langinfo_ok" = "yes"; then
 
622
            AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
 
623
        fi
 
624
    fi
 
625
    AC_MSG_CHECKING([whether to use nl_langinfo])
 
626
    if test "$langinfo_ok" = "yes"; then
 
627
        AC_TRY_COMPILE([#include <langinfo.h>],
 
628
                [nl_langinfo(CODESET);],[langinfo_ok=yes],[langinfo_ok=no])
 
629
        if test "$langinfo_ok" = "no"; then
 
630
            langinfo_ok="no (could not compile with nl_langinfo)";
 
631
        fi
 
632
        if test "$langinfo_ok" = "yes"; then
 
633
            AC_DEFINE(HAVE_LANGINFO)
 
634
        fi
 
635
    fi
 
636
    AC_MSG_RESULT([$langinfo_ok])
 
637
])
 
638
 
 
639
#--------------------------------------------------------------------
 
640
# TEA_CONFIG_CFLAGS
 
641
#
 
642
#       Try to determine the proper flags to pass to the compiler
 
643
#       for building shared libraries and other such nonsense.
 
644
#
 
645
# Arguments:
 
646
#       none
 
647
#
 
648
# Results:
 
649
#
 
650
#       Defines the following vars:
 
651
#
 
652
#       DL_OBJS -       Name of the object file that implements dynamic
 
653
#                       loading for Tcl on this system.
 
654
#       DL_LIBS -       Library file(s) to include in tclsh and other base
 
655
#                       applications in order for the "load" command to work.
 
656
#       LDFLAGS -      Flags to pass to the compiler when linking object
 
657
#                       files into an executable application binary such
 
658
#                       as tclsh.
 
659
#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
 
660
#                       that tell the run-time dynamic linker where to look
 
661
#                       for shared libraries such as libtcl.so.  Depends on
 
662
#                       the variable LIB_RUNTIME_DIR in the Makefile.
 
663
#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
 
664
#                       of a shared library (may request position-independent
 
665
#                       code, among other things).
 
666
#       SHLIB_LD -      Base command to use for combining object files
 
667
#                       into a shared library.
 
668
#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
 
669
#                       creating shared libraries.  This symbol typically
 
670
#                       goes at the end of the "ld" commands that build
 
671
#                       shared libraries. The value of the symbol is
 
672
#                       "${LIBS}" if all of the dependent libraries should
 
673
#                       be specified when creating a shared library.  If
 
674
#                       dependent libraries should not be specified (as on
 
675
#                       SunOS 4.x, where they cause the link to fail, or in
 
676
#                       general if Tcl and Tk aren't themselves shared
 
677
#                       libraries), then this symbol has an empty string
 
678
#                       as its value.
 
679
#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
 
680
#                       extensions.  An empty string means we don't know how
 
681
#                       to use shared libraries on this platform.
 
682
#       TCL_LIB_FILE -  Name of the file that contains the Tcl library, such
 
683
#                       as libtcl7.8.so or libtcl7.8.a.
 
684
#       TCL_LIB_SUFFIX -Specifies everything that comes after the "libtcl"
 
685
#                       in the shared library name, using the
 
686
#                       ${PACKAGE_VERSION} variable to put the version in
 
687
#                       the right place.  This is used by platforms that
 
688
#                       need non-standard library names.
 
689
#                       Examples:  ${PACKAGE_VERSION}.so.1.1 on NetBSD,
 
690
#                       since it needs to have a version after the .so, and
 
691
#                       ${PACKAGE_VERSION}.a on AIX, since the Tcl shared
 
692
#                       library needs to have a .a extension whereas shared
 
693
#                       objects for loadable extensions have a .so
 
694
#                       extension.  Defaults to
 
695
#                       ${PACKAGE_VERSION}${SHLIB_SUFFIX}.
 
696
#       TCL_NEEDS_EXP_FILE -
 
697
#                       1 means that an export file is needed to link to a
 
698
#                       shared library.
 
699
#       TCL_EXP_FILE -  The name of the installed export / import file which
 
700
#                       should be used to link to the Tcl shared library.
 
701
#                       Empty if Tcl is unshared.
 
702
#       TCL_BUILD_EXP_FILE -
 
703
#                       The name of the built export / import file which
 
704
#                       should be used to link to the Tcl shared library.
 
705
#                       Empty if Tcl is unshared.
 
706
#       CFLAGS_DEBUG -
 
707
#                       Flags used when running the compiler in debug mode
 
708
#       CFLAGS_OPTIMIZE -
 
709
#                       Flags used when running the compiler in optimize mode
 
710
#       EXTRA_CFLAGS -
 
711
#                       Extra CFLAGS to pass to the compiler
 
712
#
 
713
#       Subst's the following vars:
 
714
#               DL_LIBS
 
715
#               CFLAGS_DEBUG
 
716
#               CFLAGS_OPTIMIZE
 
717
#               CFLAGS_WARNING
 
718
#
 
719
#               STLIB_LD
 
720
#               SHLIB_LD
 
721
#               SHLIB_CFLAGS
 
722
#               SHLIB_LD_FLAGS
 
723
#               LDFLAGS_DEBUG
 
724
#               LDFLAGS_OPTIMIZE
 
725
#--------------------------------------------------------------------
 
726
 
 
727
AC_DEFUN(TEA_CONFIG_CFLAGS, [
 
728
    dnl Make sure we are initialized
 
729
    AC_REQUIRE([TEA_INIT])
 
730
 
 
731
    # Step 0: Enable 64 bit support?
 
732
 
 
733
    AC_MSG_CHECKING([if 64bit support is enabled])
 
734
    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support (where applicable)], [do64bit=$enableval], [do64bit=no])
 
735
    AC_MSG_RESULT([$do64bit])
 
736
 
 
737
    # Step 0.b: Enable Solaris 64 bit VIS support?
 
738
 
 
739
    AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
 
740
    AC_ARG_ENABLE(64bit-vis,[  --enable-64bit-vis      enable 64bit Sparc VIS support], [do64bitVIS=$enableval], [do64bitVIS=no])
 
741
    AC_MSG_RESULT([$do64bitVIS])
 
742
 
 
743
    if test "$do64bitVIS" = "yes"; then
 
744
        # Force 64bit on with VIS
 
745
        do64bit=yes
 
746
    fi
 
747
 
 
748
    # Step 0.c: Cross-compiling options for Windows/CE builds?
 
749
 
 
750
    if test "${TEA_PLATFORM}" = "windows" ; then
 
751
        AC_MSG_CHECKING([if Windows/CE build is requested])
 
752
        AC_ARG_ENABLE(wince,[  --enable-wince          enable Win/CE support (where applicable)], [doWince=$enableval], [doWince=no])
 
753
        AC_MSG_RESULT($doWince)
 
754
    fi
 
755
 
 
756
    # Step 1: set the variable "system" to hold the name and version number
 
757
    # for the system.  This can usually be done via the "uname" command, but
 
758
    # there are a few systems, like Next, where this doesn't work.
 
759
 
 
760
    AC_MSG_CHECKING([system version (for dynamic loading)])
 
761
    if test -f /usr/lib/NextStep/software_version; then
 
762
        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
 
763
    else
 
764
        system=`uname -s`-`uname -r`
 
765
        if test "$?" -ne 0 ; then
 
766
            AC_MSG_RESULT([unknown (can't find uname command)])
 
767
            system=unknown
 
768
        else
 
769
            # Special check for weird MP-RAS system (uname returns weird
 
770
            # results, and the version is kept in special file).
 
771
        
 
772
            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
 
773
                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
 
774
            fi
 
775
            if test "`uname -s`" = "AIX" ; then
 
776
                system=AIX-`uname -v`.`uname -r`
 
777
            fi
 
778
            if test "${TEA_PLATFORM}" = "windows" ; then
 
779
                system=windows
 
780
            fi
 
781
            AC_MSG_RESULT([$system])
 
782
        fi
 
783
    fi
 
784
 
 
785
    # Step 2: check for existence of -ldl library.  This is needed because
 
786
    # Linux can use either -ldl or -ldld for dynamic loading.
 
787
 
 
788
    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
 
789
 
 
790
    # Step 3: set configuration options based on system name and version.
 
791
 
 
792
    do64bit_ok=no
 
793
    EXTRA_CFLAGS=""
 
794
    TCL_EXPORT_FILE_SUFFIX=""
 
795
    UNSHARED_LIB_SUFFIX=""
 
796
    TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`'
 
797
    ECHO_VERSION='`echo ${PACKAGE_VERSION}`'
 
798
    TCL_LIB_VERSIONS_OK=ok
 
799
    CFLAGS_DEBUG=-g
 
800
    CFLAGS_OPTIMIZE=-O
 
801
    if test "$GCC" = "yes" ; then
 
802
        CFLAGS_WARNING="-Wall -Wconversion -Wno-implicit-int"
 
803
    else
 
804
        CFLAGS_WARNING=""
 
805
    fi
 
806
    TCL_NEEDS_EXP_FILE=0
 
807
    TCL_BUILD_EXP_FILE=""
 
808
    TCL_EXP_FILE=""
 
809
dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
 
810
dnl AC_CHECK_TOOL(AR, ar, :)
 
811
    AC_CHECK_PROG(AR, ar, ar)
 
812
    STLIB_LD='${AR} cr'
 
813
    LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
 
814
    case $system in
 
815
        windows)
 
816
            # This is a 2-stage check to make sure we have the 64-bit SDK
 
817
            # We have to know where the SDK is installed.
 
818
            if test "$do64bit" = "yes" ; then
 
819
                if test "x${MSSDK}x" = "xx" ; then
 
820
                    MSSDK="C:/Progra~1/Microsoft SDK"
 
821
                fi
 
822
                # In order to work in the tortured autoconf environment,
 
823
                # we need to ensure that this path has no spaces
 
824
                MSSDK=`cygpath -w -s "$MSSDK" | sed -e 's!\\\!/!g'`
 
825
                if test ! -d "${MSSDK}/bin/win64" ; then
 
826
                    AC_MSG_WARN("could not find 64-bit SDK to enable 64bit mode")
 
827
                    do64bit="no"
 
828
                else
 
829
                    do64bit_ok="yes"
 
830
                fi
 
831
            fi
 
832
 
 
833
            if test "$doWince" != "no" ; then
 
834
                if test "$do64bit" = "yes" ; then
 
835
                    AC_MSG_ERROR([Windows/CE and 64-bit builds incompatible])
 
836
                fi
 
837
                if test "$GCC" = "yes" ; then
 
838
                    AC_MSG_ERROR([Windows/CE and GCC builds incompatible])
 
839
                fi
 
840
                TEA_PATH_CELIB
 
841
                # set defaults
 
842
                # Currently Tcl requires 300+
 
843
                CEVERSION=300;    # could be 211 300 301 ...
 
844
                TARGETCPU=ARM;    # could be ARM MIPS SH3 X86 ...
 
845
                PLATFORM="Pocket PC 2002"
 
846
                if test "$doWince" = "yes"; then
 
847
                    doWince="300,ARM,ARM,Pocket PC 2002"
 
848
                fi
 
849
                eval `echo $doWince | awk -F "," '{ \
 
850
                    if (length([$]1)) { printf "CEVERSION=%s\n", [$]1 }; \
 
851
                    if (length([$]2)) { printf "TARGETCPU=%s\n", toupper([$]2) }; \
 
852
                    if (length([$]3)) { printf "ARCH=%s\n", toupper([$]3) }; \
 
853
                    if (length([$]4)) { printf "PLATFORM=%s\n", [$]4 }; \
 
854
                    }'`
 
855
                OSVERSION=WCE$CEVERSION;
 
856
                if test "x${ARCH}" = "x" ; then
 
857
                    ARCH=$TARGETCPU;  # could be ARM MIPS SH3 X86 X86EM ...
 
858
                fi
 
859
                if test "x${WCEROOT}" = "x" ; then
 
860
                    WCEROOT="C:/Program Files/Microsoft eMbedded Tools"
 
861
                fi
 
862
                if test "x${SDKROOT}" = "x" ; then
 
863
                    SDKROOT="C:/Windows CE Tools"
 
864
                fi
 
865
                # In order to work in the tortured autoconf environment,
 
866
                # we need to ensure that this path has no spaces
 
867
                WCEROOT=`cygpath -w -s "$WCEROOT" | sed -e 's!\\\!/!g'`
 
868
                SDKROOT=`cygpath -w -s "$SDKROOT" | sed -e 's!\\\!/!g'`
 
869
                CELIB_DIR=`cygpath -w -s "$CELIB_DIR" | sed -e 's!\\\!/!g'`
 
870
                if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \
 
871
                    -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
 
872
                    AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]])
 
873
                    doWince="no"
 
874
                else
 
875
                    CEINCLUDE=`cygpath -w -s "${SDKROOT}/${OSVERSION}/${PLATFORM}/include" | sed -e 's!\\\!/!g'`
 
876
                    CELIBPATH=`cygpath -w -s "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" | sed -e 's!\\\!/!g'`
 
877
                fi
 
878
            fi
 
879
 
 
880
            if test "$GCC" != "yes" ; then
 
881
                if test "${SHARED_BUILD}" = "0" ; then
 
882
                    runtime=-MT
 
883
                else
 
884
                    runtime=-MD
 
885
                fi
 
886
 
 
887
                if test "$do64bit" = "yes" ; then
 
888
                    # All this magic is necessary for the Win64 SDK RC1 - hobbs
 
889
                    export CC="${MSSDK}/Bin/Win64/cl.exe \
 
890
                        -I${MSSDK}/Include/prerelease \
 
891
                        -I${MSSDK}/Include/Win64/crt \
 
892
                        -I${MSSDK}/Include"
 
893
                    export RC="${MSSDK}/bin/rc.exe"
 
894
                    export lflags="-MACHINE:IA64 -LIBPATH:${MSSDK}/Lib/IA64 \
 
895
                        -LIBPATH:${MSSDK}/Lib/Prerelease/IA64"
 
896
                    export STLIB_LD="${MSSDK}/bin/win64/lib.exe -nologo ${lflags}"
 
897
                    export LINKBIN="${MSSDK}/bin/win64/link.exe ${lflags}"
 
898
                    CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d"
 
899
                    CFLAGS_OPTIMIZE="-nologo -O2 -Gs -W2 ${runtime}"
 
900
                elif test "$doWince" != "no" ; then
 
901
                    if test "${TARGETCPU}" = "X86"; then
 
902
                        CC="${WCEROOT}/EVC/${OSVERSION}/bin/cl.exe -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
 
903
                    else
 
904
                        CC="${WCEROOT}/EVC/${OSVERSION}/bin/cl${TARGETCPU}.exe -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
 
905
                    fi
 
906
                    RC="${WCEROOT}/Common/EVC/bin/rc.exe"
 
907
                    cpulower=`echo ${TARGETCPU} | awk '{print tolower([$]0)}'`
 
908
                    defs="${TARGETCPU} _${TARGETCPU}_ ${cpulower} _${cpulower}_ POCKET_SIZE PALM_SIZE _MT _DLL _WINDOWS"
 
909
                    for i in $defs ; do
 
910
                        AC_DEFINE_UNQUOTED($i)
 
911
                    done
 
912
                    AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION)
 
913
                    AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION)
 
914
                    CFLAGS_DEBUG="-nologo -Zi -Od"
 
915
                    CFLAGS_OPTIMIZE="-nologo -Ox"
 
916
                    lflags="-MACHINE:${TARGETCPU} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,3.00"
 
917
                    STLIB_LD="${WCEROOT}/EVC/${OSVERSION}/bin/lib.exe -nologo ${lflags}"
 
918
                    LINKBIN="${WCEROOT}/EVC/${OSVERSION}/bin/link.exe ${lflags}"
 
919
                else
 
920
                    RC="rc"
 
921
                    STLIB_LD="lib -nologo"
 
922
                    LINKBIN="link -link50compat"
 
923
                    CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d"
 
924
                    CFLAGS_OPTIMIZE="-nologo -O2 -Gs -GD -W2 ${runtime}"
 
925
                fi
 
926
            fi
 
927
 
 
928
            if test "$GCC" = "yes"; then
 
929
                # mingw gcc mode
 
930
                RC="windres"
 
931
                CFLAGS_DEBUG="-g"
 
932
                CFLAGS_OPTIMIZE="-O2"
 
933
                SHLIB_LD="$CC -shared"
 
934
                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
 
935
                LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}"
 
936
                LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}"
 
937
            else
 
938
                SHLIB_LD="${LINKBIN} -dll -nologo"
 
939
                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.lib'
 
940
                EXTRA_CFLAGS="-YX"
 
941
                PATHTYPE=-w
 
942
                # For information on what debugtype is most useful, see:
 
943
                # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp
 
944
                # This essentially turns it all on.
 
945
                LDFLAGS_DEBUG="-debug:full -debugtype:both -warn:2"
 
946
                LDFLAGS_OPTIMIZE="-release"
 
947
                if test "$doWince" != "no" ; then
 
948
                    LDFLAGS_CONSOLE="-link ${lflags}"
 
949
                    LDFLAGS_WINDOW=${LDFLAGS_CONSOLE}
 
950
                else
 
951
                    LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
 
952
                    LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
 
953
                fi
 
954
            fi
 
955
 
 
956
            SHLIB_LD_LIBS='${LIBS}'
 
957
            SHLIB_SUFFIX=".dll"
 
958
            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.dll'
 
959
 
 
960
            TCL_LIB_VERSIONS_OK=nodots
 
961
            # Bogus to avoid getting this turned off
 
962
            DL_OBJS="tclLoadNone.obj"
 
963
            ;;
 
964
        AIX-*)
 
965
            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
 
966
                # AIX requires the _r compiler when gcc isn't being used
 
967
                if test "${CC}" != "cc_r" ; then
 
968
                    CC=${CC}_r
 
969
                fi
 
970
                AC_MSG_RESULT([Using $CC for compiling with threads])
 
971
            fi
 
972
            LIBS="$LIBS -lc"
 
973
            SHLIB_CFLAGS=""
 
974
            SHLIB_SUFFIX=".so"
 
975
            SHLIB_LD_LIBS='${LIBS}'
 
976
 
 
977
            DL_OBJS="tclLoadDl.o"
 
978
            LDFLAGS=""
 
979
            LD_LIBRARY_PATH_VAR="LIBPATH"
 
980
 
 
981
            # AIX v<=4.1 has some different flags than 4.2+
 
982
            if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
 
983
                #LIBOBJS="$LIBOBJS tclLoadAix.o"
 
984
                AC_LIBOBJ([tclLoadAix])
 
985
                DL_LIBS="-lld"
 
986
            fi
 
987
 
 
988
            # Check to enable 64-bit flags for compiler/linker on AIX 4+
 
989
            if test "$do64bit" = "yes" -a "`uname -v`" -gt "3" ; then
 
990
                if test "$GCC" = "yes" ; then
 
991
                    AC_MSG_WARN("64bit mode not supported with GCC on $system")
 
992
                else 
 
993
                    do64bit_ok=yes
 
994
                    EXTRA_CFLAGS="-q64"
 
995
                    LDFLAGS="-q64"
 
996
                    RANLIB="${RANLIB} -X64"
 
997
                    AR="${AR} -X64"
 
998
                    SHLIB_LD_FLAGS="-b64"
 
999
                fi
 
1000
            fi
 
1001
 
 
1002
            if test "`uname -m`" = "ia64" ; then
 
1003
                # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
 
1004
                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
 
1005
                # AIX-5 has dl* in libc.so
 
1006
                DL_LIBS=""
 
1007
                if test "$GCC" = "yes" ; then
 
1008
                    LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
 
1009
                else
 
1010
                    LD_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
 
1011
                fi
 
1012
            else
 
1013
                SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry ${SHLIB_LD_FLAGS}"
 
1014
                DL_LIBS="-ldl"
 
1015
                LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
 
1016
                TCL_NEEDS_EXP_FILE=1
 
1017
                TCL_EXPORT_FILE_SUFFIX='${PACKAGE_VERSION}\$\{DBGX\}.exp'
 
1018
            fi
 
1019
 
 
1020
            # On AIX <=v4 systems, libbsd.a has to be linked in to support
 
1021
            # non-blocking file IO.  This library has to be linked in after
 
1022
            # the MATH_LIBS or it breaks the pow() function.  The way to
 
1023
            # insure proper sequencing, is to add it to the tail of MATH_LIBS.
 
1024
            # This library also supplies gettimeofday.
 
1025
            #
 
1026
            # AIX does not have a timezone field in struct tm. When the AIX
 
1027
            # bsd library is used, the timezone global and the gettimeofday
 
1028
            # methods are to be avoided for timezone deduction instead, we
 
1029
            # deduce the timezone by comparing the localtime result on a
 
1030
            # known GMT value.
 
1031
 
 
1032
            AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
 
1033
            if test $libbsd = yes; then
 
1034
                MATH_LIBS="$MATH_LIBS -lbsd"
 
1035
                AC_DEFINE(USE_DELTA_FOR_TZ)
 
1036
            fi
 
1037
            ;;
 
1038
        BSD/OS-2.1*|BSD/OS-3*)
 
1039
            SHLIB_CFLAGS=""
 
1040
            SHLIB_LD="shlicc -r"
 
1041
            SHLIB_LD_LIBS='${LIBS}'
 
1042
            SHLIB_SUFFIX=".so"
 
1043
            DL_OBJS="tclLoadDl.o"
 
1044
            DL_LIBS="-ldl"
 
1045
            LDFLAGS=""
 
1046
            LD_SEARCH_FLAGS=""
 
1047
            ;;
 
1048
        BSD/OS-4.*)
 
1049
            SHLIB_CFLAGS="-export-dynamic -fPIC"
 
1050
            SHLIB_LD="cc -shared"
 
1051
            SHLIB_LD_LIBS='${LIBS}'
 
1052
            SHLIB_SUFFIX=".so"
 
1053
            DL_OBJS="tclLoadDl.o"
 
1054
            DL_LIBS="-ldl"
 
1055
            LDFLAGS="-export-dynamic"
 
1056
            LD_SEARCH_FLAGS=""
 
1057
            ;;
 
1058
        dgux*)
 
1059
            SHLIB_CFLAGS="-K PIC"
 
1060
            SHLIB_LD="cc -G"
 
1061
            SHLIB_LD_LIBS=""
 
1062
            SHLIB_SUFFIX=".so"
 
1063
            DL_OBJS="tclLoadDl.o"
 
1064
            DL_LIBS="-ldl"
 
1065
            LDFLAGS=""
 
1066
            LD_SEARCH_FLAGS=""
 
1067
            ;;
 
1068
        HP-UX-*.11.*)
 
1069
            # Use updated header definitions where possible
 
1070
            AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
 
1071
 
 
1072
            SHLIB_SUFFIX=".sl"
 
1073
            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
 
1074
            if test "$tcl_ok" = yes; then
 
1075
                SHLIB_CFLAGS="+z"
 
1076
                SHLIB_LD="ld -b"
 
1077
                SHLIB_LD_LIBS='${LIBS}'
 
1078
                DL_OBJS="tclLoadShl.o"
 
1079
                DL_LIBS="-ldld"
 
1080
                LDFLAGS="-Wl,-E"
 
1081
                LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
 
1082
            fi
 
1083
            LD_LIBRARY_PATH_VAR="SHLIB_PATH"
 
1084
 
 
1085
            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
 
1086
            #EXTRA_CFLAGS="+DAportable"
 
1087
 
 
1088
            # Check to enable 64-bit flags for compiler/linker
 
1089
            if test "$do64bit" = "yes" ; then
 
1090
                if test "$GCC" = "yes" ; then
 
1091
                    hpux_arch=`${CC} -dumpmachine`
 
1092
                    case $hpux_arch in
 
1093
                        hppa64*)
 
1094
                            # 64-bit gcc in use.  Fix flags for GNU ld.
 
1095
                            do64bit_ok=yes
 
1096
                            SHLIB_LD="${CC} -shared"
 
1097
                            SHLIB_LD_LIBS=""
 
1098
                            LD_SEARCH_FLAGS=''
 
1099
                            ;;
 
1100
                        *)
 
1101
                            AC_MSG_WARN("64bit mode not supported with GCC on $system")
 
1102
                            ;;
 
1103
                    esac
 
1104
                else
 
1105
                    do64bit_ok=yes
 
1106
                    if test "`uname -m`" = "ia64" ; then
 
1107
                        EXTRA_CFLAGS="+DD64"
 
1108
                        LDFLAGS="+DD64 $LDFLAGS"
 
1109
                    else
 
1110
                        EXTRA_CFLAGS="+DA2.0W"
 
1111
                        LDFLAGS="+DA2.0W $LDFLAGS"
 
1112
                    fi
 
1113
                fi
 
1114
            fi
 
1115
            ;;
 
1116
        HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
 
1117
            SHLIB_SUFFIX=".sl"
 
1118
            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
 
1119
            if test "$tcl_ok" = yes; then
 
1120
                SHLIB_CFLAGS="+z"
 
1121
                SHLIB_LD="ld -b"
 
1122
                SHLIB_LD_LIBS=""
 
1123
                DL_OBJS="tclLoadShl.o"
 
1124
                DL_LIBS="-ldld"
 
1125
                LDFLAGS="-Wl,-E"
 
1126
                LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
 
1127
            fi
 
1128
            LD_LIBRARY_PATH_VAR="SHLIB_PATH"
 
1129
            ;;
 
1130
        IRIX-4.*)
 
1131
            SHLIB_CFLAGS="-G 0"
 
1132
            SHLIB_SUFFIX=".a"
 
1133
            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
 
1134
            SHLIB_LD_LIBS='${LIBS}'
 
1135
            DL_OBJS="tclLoadAout.o"
 
1136
            DL_LIBS=""
 
1137
            LDFLAGS="-Wl,-D,08000000"
 
1138
            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
 
1139
            SHARED_LIB_SUFFIX='${PACKAGE_VERSION}\$\{DBGX\}.a'
 
1140
            ;;
 
1141
        IRIX-5.*)
 
1142
            SHLIB_CFLAGS=""
 
1143
            SHLIB_LD="ld -shared -rdata_shared"
 
1144
            SHLIB_LD_LIBS='${LIBS}'
 
1145
            SHLIB_SUFFIX=".so"
 
1146
            DL_OBJS="tclLoadDl.o"
 
1147
            DL_LIBS=""
 
1148
            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
 
1149
            EXTRA_CFLAGS=""
 
1150
            LDFLAGS=""
 
1151
            ;;
 
1152
        IRIX-6.*|IRIX64-6.5*)
 
1153
            SHLIB_CFLAGS=""
 
1154
            SHLIB_LD="ld -n32 -shared -rdata_shared"
 
1155
            SHLIB_LD_LIBS='${LIBS}'
 
1156
            SHLIB_SUFFIX=".so"
 
1157
            DL_OBJS="tclLoadDl.o"
 
1158
            DL_LIBS=""
 
1159
            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
 
1160
            if test "$GCC" = "yes" ; then
 
1161
                EXTRA_CFLAGS="-mabi=n32"
 
1162
                LDFLAGS="-mabi=n32"
 
1163
            else
 
1164
                case $system in
 
1165
                    IRIX-6.3)
 
1166
                        # Use to build 6.2 compatible binaries on 6.3.
 
1167
                        EXTRA_CFLAGS="-n32 -D_OLD_TERMIOS"
 
1168
                        ;;
 
1169
                    *)
 
1170
                        EXTRA_CFLAGS="-n32"
 
1171
                        ;;
 
1172
                esac
 
1173
                LDFLAGS="-n32"
 
1174
            fi
 
1175
            ;;
 
1176
        IRIX64-6.*)
 
1177
            SHLIB_CFLAGS=""
 
1178
            SHLIB_LD="ld -n32 -shared -rdata_shared"
 
1179
            SHLIB_LD_LIBS='${LIBS}'
 
1180
            SHLIB_SUFFIX=".so"
 
1181
            DL_OBJS="tclLoadDl.o"
 
1182
            DL_LIBS=""
 
1183
            LDFLAGS=""
 
1184
            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
 
1185
 
 
1186
            # Check to enable 64-bit flags for compiler/linker
 
1187
 
 
1188
            if test "$do64bit" = "yes" ; then
 
1189
                if test "$GCC" = "yes" ; then
 
1190
                    AC_MSG_WARN([64bit mode not supported by gcc])
 
1191
                else
 
1192
                    do64bit_ok=yes
 
1193
                    SHLIB_LD="ld -64 -shared -rdata_shared"
 
1194
                    EXTRA_CFLAGS="-64"
 
1195
                    LDFLAGS="-64"
 
1196
                fi
 
1197
            fi
 
1198
            ;;
 
1199
        Linux*)
 
1200
            SHLIB_CFLAGS="-fPIC"
 
1201
            SHLIB_LD_LIBS='${LIBS}'
 
1202
            SHLIB_SUFFIX=".so"
 
1203
 
 
1204
            # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings 
 
1205
            # when you inline the string and math operations.  Turn this off to
 
1206
            # get rid of the warnings.
 
1207
 
 
1208
            #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
 
1209
 
 
1210
            if test "$have_dl" = yes; then
 
1211
                SHLIB_LD="${CC} -shared"
 
1212
                DL_OBJS="tclLoadDl.o"
 
1213
                DL_LIBS="-ldl"
 
1214
                LDFLAGS="-rdynamic"
 
1215
                LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
 
1216
            else
 
1217
                AC_CHECK_HEADER(dld.h, [
 
1218
                    SHLIB_LD="ld -shared"
 
1219
                    DL_OBJS="tclLoadDld.o"
 
1220
                    DL_LIBS="-ldld"
 
1221
                    LDFLAGS=""
 
1222
                    LD_SEARCH_FLAGS=""])
 
1223
            fi
 
1224
            if test "`uname -m`" = "alpha" ; then
 
1225
                EXTRA_CFLAGS="-mieee"
 
1226
            fi
 
1227
 
 
1228
            # The combo of gcc + glibc has a bug related
 
1229
            # to inlining of functions like strtod(). The
 
1230
            # -fno-builtin flag should address this problem
 
1231
            # but it does not work. The -fno-inline flag
 
1232
            # is kind of overkill but it works.
 
1233
            # Disable inlining only when one of the
 
1234
            # files in compat/*.c is being linked in.
 
1235
            if test x"${USE_COMPAT}" != x ; then
 
1236
                EXTRA_CFLAGS="${EXTRA_CFLAGS} -fno-inline"
 
1237
            fi
 
1238
 
 
1239
            ;;
 
1240
        GNU*)
 
1241
            SHLIB_CFLAGS="-fPIC"
 
1242
            SHLIB_LD_LIBS='${LIBS}'
 
1243
            SHLIB_SUFFIX=".so"
 
1244
 
 
1245
            if test "$have_dl" = yes; then
 
1246
                SHLIB_LD="${CC} -shared"
 
1247
                DL_OBJS=""
 
1248
                DL_LIBS="-ldl"
 
1249
                LDFLAGS="-rdynamic"
 
1250
                LD_SEARCH_FLAGS=""
 
1251
            else
 
1252
                AC_CHECK_HEADER(dld.h, [
 
1253
                    SHLIB_LD="ld -shared"
 
1254
                    DL_OBJS=""
 
1255
                    DL_LIBS="-ldld"
 
1256
                    LDFLAGS=""
 
1257
                    LD_SEARCH_FLAGS=""])
 
1258
            fi
 
1259
            if test "`uname -m`" = "alpha" ; then
 
1260
                EXTRA_CFLAGS="-mieee"
 
1261
            fi
 
1262
            ;;
 
1263
        MP-RAS-02*)
 
1264
            SHLIB_CFLAGS="-K PIC"
 
1265
            SHLIB_LD="cc -G"
 
1266
            SHLIB_LD_LIBS=""
 
1267
            SHLIB_SUFFIX=".so"
 
1268
            DL_OBJS="tclLoadDl.o"
 
1269
            DL_LIBS="-ldl"
 
1270
            LDFLAGS=""
 
1271
            LD_SEARCH_FLAGS=""
 
1272
            ;;
 
1273
        MP-RAS-*)
 
1274
            SHLIB_CFLAGS="-K PIC"
 
1275
            SHLIB_LD="cc -G"
 
1276
            SHLIB_LD_LIBS=""
 
1277
            SHLIB_SUFFIX=".so"
 
1278
            DL_OBJS="tclLoadDl.o"
 
1279
            DL_LIBS="-ldl"
 
1280
            LDFLAGS="-Wl,-Bexport"
 
1281
            LD_SEARCH_FLAGS=""
 
1282
            ;;
 
1283
        NetBSD-*|FreeBSD-[[1-2]].*)
 
1284
            # Not available on all versions:  check for include file.
 
1285
            AC_CHECK_HEADER(dlfcn.h, [
 
1286
                # NetBSD/SPARC needs -fPIC, -fpic will not do.
 
1287
                SHLIB_CFLAGS="-fPIC"
 
1288
                SHLIB_LD="ld -Bshareable -x"
 
1289
                SHLIB_LD_LIBS=""
 
1290
                SHLIB_SUFFIX=".so"
 
1291
                DL_OBJS="tclLoadDl.o"
 
1292
                DL_LIBS=""
 
1293
                LDFLAGS=""
 
1294
                LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
 
1295
                AC_MSG_CHECKING([for ELF])
 
1296
                AC_EGREP_CPP(yes, [
 
1297
#ifdef __ELF__
 
1298
        yes
 
1299
#endif
 
1300
                ],
 
1301
                    AC_MSG_RESULT([yes])
 
1302
                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so',
 
1303
                    AC_MSG_RESULT([no])
 
1304
                    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
 
1305
                )
 
1306
            ], [
 
1307
                SHLIB_CFLAGS=""
 
1308
                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
 
1309
                SHLIB_LD_LIBS='${LIBS}'
 
1310
                SHLIB_SUFFIX=".a"
 
1311
                DL_OBJS="tclLoadAout.o"
 
1312
                DL_LIBS=""
 
1313
                LDFLAGS=""
 
1314
                LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
 
1315
                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
 
1316
            ])
 
1317
 
 
1318
            # FreeBSD doesn't handle version numbers with dots.
 
1319
 
 
1320
            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
 
1321
            TCL_LIB_VERSIONS_OK=nodots
 
1322
            ;;
 
1323
        OpenBSD-*)
 
1324
            SHLIB_LD="${CC} -shared"
 
1325
            SHLIB_LD_LIBS='${LIBS}'
 
1326
            SHLIB_SUFFIX=".so"
 
1327
            DL_OBJS="tclLoadDl.o"
 
1328
            DL_LIBS=""
 
1329
            LDFLAGS=""
 
1330
            LD_SEARCH_FLAGS=""
 
1331
            AC_MSG_CHECKING(for ELF)
 
1332
            AC_EGREP_CPP(yes, [
 
1333
#ifdef __ELF__
 
1334
        yes
 
1335
#endif
 
1336
            ],
 
1337
                [AC_MSG_RESULT(yes)
 
1338
                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'],
 
1339
                [AC_MSG_RESULT(no)
 
1340
                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0']
 
1341
            )
 
1342
 
 
1343
            # OpenBSD doesn't do version numbers with dots.
 
1344
            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
 
1345
            TCL_LIB_VERSIONS_OK=nodots
 
1346
            ;;
 
1347
        FreeBSD-*)
 
1348
            # FreeBSD 3.* and greater have ELF.
 
1349
            SHLIB_CFLAGS="-fPIC"
 
1350
            SHLIB_LD="ld -Bshareable -x"
 
1351
            SHLIB_LD_LIBS='${LIBS}'
 
1352
            SHLIB_SUFFIX=".so"
 
1353
            DL_OBJS="tclLoadDl.o"
 
1354
            DL_LIBS=""
 
1355
            LDFLAGS="-export-dynamic"
 
1356
            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
 
1357
            if test "${TCL_THREADS}" = "1" ; then
 
1358
                # The -pthread needs to go in the CFLAGS, not LIBS
 
1359
                LIBS=`echo $LIBS | sed s/-pthread//`
 
1360
                EXTRA_CFLAGS="-pthread"
 
1361
                LDFLAGS="$LDFLAGS -pthread"
 
1362
            fi
 
1363
            case $system in
 
1364
            FreeBSD-3.*)
 
1365
                # FreeBSD-3 doesn't handle version numbers with dots.
 
1366
                UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
 
1367
                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
 
1368
                TCL_LIB_VERSIONS_OK=nodots
 
1369
                ;;
 
1370
            esac
 
1371
            ;;
 
1372
        Rhapsody-*|Darwin-*)
 
1373
            SHLIB_CFLAGS="-fno-common"
 
1374
            SHLIB_LD="cc -dynamiclib \${LDFLAGS}"
 
1375
            TCL_SHLIB_LD_EXTRAS="-compatibility_version ${TCL_MAJOR_VERSION} -current_version \${PACKAGE_VERSION} -install_name \${LIB_RUNTIME_DIR}/\${TCL_LIB_FILE} -prebind -seg1addr 0xa000000"
 
1376
            SHLIB_LD_LIBS='${LIBS}'
 
1377
            SHLIB_SUFFIX=".dylib"
 
1378
            DL_OBJS="tclLoadDyld.o"
 
1379
            DL_LIBS=""
 
1380
            LDFLAGS="-prebind"
 
1381
            LD_SEARCH_FLAGS=""
 
1382
            LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
 
1383
            CFLAGS_OPTIMIZE="-O3"
 
1384
            EXTRA_CFLAGS="-arch ppc -pipe"
 
1385
            ;;
 
1386
        NEXTSTEP-*)
 
1387
            SHLIB_CFLAGS=""
 
1388
            SHLIB_LD="cc -nostdlib -r"
 
1389
            SHLIB_LD_LIBS=""
 
1390
            SHLIB_SUFFIX=".so"
 
1391
            DL_OBJS="tclLoadNext.o"
 
1392
            DL_LIBS=""
 
1393
            LDFLAGS=""
 
1394
            LD_SEARCH_FLAGS=""
 
1395
            ;;
 
1396
        OS/390-*)
 
1397
            CFLAGS_OPTIMIZE=""      # Optimizer is buggy
 
1398
            AC_DEFINE(_OE_SOCKETS)  # needed in sys/socket.h
 
1399
            ;;      
 
1400
        OSF1-1.0|OSF1-1.1|OSF1-1.2)
 
1401
            # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
 
1402
            SHLIB_CFLAGS=""
 
1403
            # Hack: make package name same as library name
 
1404
            SHLIB_LD='ld -R -export $@:'
 
1405
            SHLIB_LD_LIBS=""
 
1406
            SHLIB_SUFFIX=".so"
 
1407
            DL_OBJS="tclLoadOSF.o"
 
1408
            DL_LIBS=""
 
1409
            LDFLAGS=""
 
1410
            LD_SEARCH_FLAGS=""
 
1411
            ;;
 
1412
        OSF1-1.*)
 
1413
            # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
 
1414
            SHLIB_CFLAGS="-fPIC"
 
1415
            if test "$SHARED_BUILD" = "1" ; then
 
1416
                SHLIB_LD="ld -shared"
 
1417
            else
 
1418
                SHLIB_LD="ld -non_shared"
 
1419
            fi
 
1420
            SHLIB_LD_LIBS=""
 
1421
            SHLIB_SUFFIX=".so"
 
1422
            DL_OBJS="tclLoadDl.o"
 
1423
            DL_LIBS=""
 
1424
            LDFLAGS=""
 
1425
            LD_SEARCH_FLAGS=""
 
1426
            ;;
 
1427
        OSF1-V*)
 
1428
            # Digital OSF/1
 
1429
            SHLIB_CFLAGS=""
 
1430
            if test "$SHARED_BUILD" = "1" ; then
 
1431
                SHLIB_LD='ld -shared -expect_unresolved "*"'
 
1432
            else
 
1433
                SHLIB_LD='ld -non_shared -expect_unresolved "*"'
 
1434
            fi
 
1435
            SHLIB_LD_LIBS=""
 
1436
            SHLIB_SUFFIX=".so"
 
1437
            DL_OBJS="tclLoadDl.o"
 
1438
            DL_LIBS=""
 
1439
            LDFLAGS=""
 
1440
            LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
 
1441
            if test "$GCC" != "yes" ; then
 
1442
                EXTRA_CFLAGS="-DHAVE_TZSET -std1"
 
1443
            fi
 
1444
            # see pthread_intro(3) for pthread support on osf1, k.furukawa
 
1445
            if test "${TCL_THREADS}" = "1" ; then
 
1446
                EXTRA_CFLAGS="${EXTRA_CFLAGS} -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
 
1447
                EXTRA_CFLAGS="${EXTRA_CFLAGS} -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
 
1448
                LIBS=`echo $LIBS | sed s/-lpthreads//`
 
1449
                if test "$GCC" = "yes" ; then
 
1450
                    LIBS="$LIBS -lpthread -lmach -lexc"
 
1451
                else
 
1452
                    EXTRA_CFLAGS="${EXTRA_CFLAGS} -pthread"
 
1453
                    LDFLAGS="-pthread"
 
1454
                fi
 
1455
            fi
 
1456
 
 
1457
            ;;
 
1458
        QNX-6*)
 
1459
            # QNX RTP
 
1460
            # This may work for all QNX, but it was only reported for v6.
 
1461
            SHLIB_CFLAGS="-fPIC"
 
1462
            SHLIB_LD="ld -Bshareable -x"
 
1463
            SHLIB_LD_LIBS=""
 
1464
            SHLIB_SUFFIX=".so"
 
1465
            DL_OBJS="tclLoadDl.o"
 
1466
            # dlopen is in -lc on QNX
 
1467
            DL_LIBS=""
 
1468
            LDFLAGS=""
 
1469
            LD_SEARCH_FLAGS=""
 
1470
            ;;
 
1471
        RISCos-*)
 
1472
            SHLIB_CFLAGS="-G 0"
 
1473
            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
 
1474
            SHLIB_LD_LIBS='${LIBS}'
 
1475
            SHLIB_SUFFIX=".a"
 
1476
            DL_OBJS="tclLoadAout.o"
 
1477
            DL_LIBS=""
 
1478
            LDFLAGS="-Wl,-D,08000000"
 
1479
            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
 
1480
            ;;
 
1481
        SCO_SV-3.2*)
 
1482
            # Note, dlopen is available only on SCO 3.2.5 and greater. However,
 
1483
            # this test works, since "uname -s" was non-standard in 3.2.4 and
 
1484
            # below.
 
1485
            if test "$GCC" = "yes" ; then
 
1486
                SHLIB_CFLAGS="-fPIC -melf"
 
1487
                LDFLAGS="-melf -Wl,-Bexport"
 
1488
            else
 
1489
                SHLIB_CFLAGS="-Kpic -belf"
 
1490
                LDFLAGS="-belf -Wl,-Bexport"
 
1491
            fi
 
1492
            SHLIB_LD="ld -G"
 
1493
            SHLIB_LD_LIBS=""
 
1494
            SHLIB_SUFFIX=".so"
 
1495
            DL_OBJS="tclLoadDl.o"
 
1496
            DL_LIBS=""
 
1497
            LD_SEARCH_FLAGS=""
 
1498
            ;;
 
1499
        SINIX*5.4*)
 
1500
            SHLIB_CFLAGS="-K PIC"
 
1501
            SHLIB_LD="cc -G"
 
1502
            SHLIB_LD_LIBS=""
 
1503
            SHLIB_SUFFIX=".so"
 
1504
            DL_OBJS="tclLoadDl.o"
 
1505
            DL_LIBS="-ldl"
 
1506
            LDFLAGS=""
 
1507
            LD_SEARCH_FLAGS=""
 
1508
            ;;
 
1509
        SunOS-4*)
 
1510
            SHLIB_CFLAGS="-PIC"
 
1511
            SHLIB_LD="ld"
 
1512
            SHLIB_LD_LIBS=""
 
1513
            SHLIB_SUFFIX=".so"
 
1514
            DL_OBJS="tclLoadDl.o"
 
1515
            DL_LIBS="-ldl"
 
1516
            LDFLAGS=""
 
1517
            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
 
1518
 
 
1519
            # SunOS can't handle version numbers with dots in them in library
 
1520
            # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
 
1521
            # requires an extra version number at the end of .so file names.
 
1522
            # So, the library has to have a name like libtcl75.so.1.0
 
1523
 
 
1524
            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
 
1525
            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
 
1526
            TCL_LIB_VERSIONS_OK=nodots
 
1527
            ;;
 
1528
        SunOS-5.[[0-6]]*)
 
1529
 
 
1530
            # Note: If _REENTRANT isn't defined, then Solaris
 
1531
            # won't define thread-safe library routines.
 
1532
 
 
1533
            AC_DEFINE(_REENTRANT)
 
1534
            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
 
1535
 
 
1536
            SHLIB_CFLAGS="-KPIC"
 
1537
 
 
1538
            # Note: need the LIBS below, otherwise Tk won't find Tcl's
 
1539
            # symbols when dynamically loaded into tclsh.
 
1540
 
 
1541
            SHLIB_LD_LIBS='${LIBS}'
 
1542
            SHLIB_SUFFIX=".so"
 
1543
            DL_OBJS="tclLoadDl.o"
 
1544
            DL_LIBS="-ldl"
 
1545
            LDFLAGS=""
 
1546
            if test "$GCC" = "yes" ; then
 
1547
                SHLIB_LD="$CC -shared"
 
1548
                LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
 
1549
            else
 
1550
                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
 
1551
                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
 
1552
            fi
 
1553
            ;;
 
1554
        SunOS-5*)
 
1555
 
 
1556
            # Note: If _REENTRANT isn't defined, then Solaris
 
1557
            # won't define thread-safe library routines.
 
1558
 
 
1559
            AC_DEFINE(_REENTRANT)
 
1560
            AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
 
1561
 
 
1562
            SHLIB_CFLAGS="-KPIC"
 
1563
            LDFLAGS=""
 
1564
    
 
1565
            # Check to enable 64-bit flags for compiler/linker
 
1566
            if test "$do64bit" = "yes" ; then
 
1567
                arch=`isainfo`
 
1568
                if test "$arch" = "sparcv9 sparc" ; then
 
1569
                        if test "$GCC" = "yes" ; then
 
1570
                            AC_MSG_WARN("64bit mode not supported with GCC on $system")
 
1571
                        else
 
1572
                            do64bit_ok=yes
 
1573
                            if test "$do64bitVIS" = "yes" ; then
 
1574
                                EXTRA_CFLAGS="-xarch=v9a"
 
1575
                                LDFLAGS="-xarch=v9a"
 
1576
                            else
 
1577
                                EXTRA_CFLAGS="-xarch=v9"
 
1578
                                LDFLAGS="-xarch=v9"
 
1579
                            fi
 
1580
                        fi
 
1581
                else
 
1582
                    AC_MSG_WARN("64bit mode only supported sparcv9 system")
 
1583
                fi
 
1584
            fi
 
1585
            
 
1586
            # Note: need the LIBS below, otherwise Tk won't find Tcl's
 
1587
            # symbols when dynamically loaded into tclsh.
 
1588
 
 
1589
            SHLIB_LD_LIBS='${LIBS}'
 
1590
            SHLIB_SUFFIX=".so"
 
1591
            DL_OBJS="tclLoadDl.o"
 
1592
            DL_LIBS="-ldl"
 
1593
            if test "$GCC" = "yes" ; then
 
1594
                SHLIB_LD="$CC -shared"
 
1595
                LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
 
1596
            else
 
1597
                SHLIB_LD="/usr/ccs/bin/ld -G -z text"
 
1598
                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
 
1599
            fi
 
1600
            ;;
 
1601
        ULTRIX-4.*)
 
1602
            SHLIB_CFLAGS="-G 0"
 
1603
            SHLIB_SUFFIX=".a"
 
1604
            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
 
1605
            SHLIB_LD_LIBS='${LIBS}'
 
1606
            DL_OBJS="tclLoadAout.o"
 
1607
            DL_LIBS=""
 
1608
            LDFLAGS="-Wl,-D,08000000"
 
1609
            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
 
1610
            if test "$GCC" != "yes" ; then
 
1611
                EXTRA_CFLAGS="-DHAVE_TZSET -std1"
 
1612
            fi
 
1613
            ;;
 
1614
        UNIX_SV* | UnixWare-5*)
 
1615
            SHLIB_CFLAGS="-KPIC"
 
1616
            SHLIB_LD="cc -G"
 
1617
            SHLIB_LD_LIBS=""
 
1618
            SHLIB_SUFFIX=".so"
 
1619
            DL_OBJS="tclLoadDl.o"
 
1620
            DL_LIBS="-ldl"
 
1621
            # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
 
1622
            # that don't grok the -Bexport option.  Test that it does.
 
1623
            hold_ldflags=$LDFLAGS
 
1624
            AC_MSG_CHECKING([for ld accepts -Bexport flag])
 
1625
            LDFLAGS="${LDFLAGS} -Wl,-Bexport"
 
1626
            AC_TRY_LINK(, [int i;], found=yes, found=no)
 
1627
            LDFLAGS=$hold_ldflags
 
1628
            AC_MSG_RESULT([$found])
 
1629
            if test $found = yes; then
 
1630
            LDFLAGS="-Wl,-Bexport"
 
1631
            else
 
1632
            LDFLAGS=""
 
1633
            fi
 
1634
            LD_SEARCH_FLAGS=""
 
1635
            ;;
 
1636
    esac
 
1637
 
 
1638
    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
 
1639
    AC_MSG_WARN("64bit support being disabled -- don\'t know magic for this platform")
 
1640
    fi
 
1641
 
 
1642
    # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
 
1643
    # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
 
1644
    # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
 
1645
    # to determine which of several header files defines the a.out file
 
1646
    # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
 
1647
    # support only a file format that is more or less version-7-compatible. 
 
1648
    # In particular,
 
1649
    #   - a.out files must begin with `struct exec'.
 
1650
    #   - the N_TXTOFF on the `struct exec' must compute the seek address
 
1651
    #     of the text segment
 
1652
    #   - The `struct exec' must contain a_magic, a_text, a_data, a_bss
 
1653
    #     and a_entry fields.
 
1654
    # The following compilation should succeed if and only if either sys/exec.h
 
1655
    # or a.out.h is usable for the purpose.
 
1656
    #
 
1657
    # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
 
1658
    # `struct exec' includes a second header that contains information that
 
1659
    # duplicates the v7 fields that are needed.
 
1660
 
 
1661
    if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
 
1662
        AC_MSG_CHECKING([sys/exec.h])
 
1663
        AC_TRY_COMPILE([#include <sys/exec.h>],[
 
1664
            struct exec foo;
 
1665
            unsigned long seek;
 
1666
            int flag;
 
1667
#if defined(__mips) || defined(mips)
 
1668
            seek = N_TXTOFF (foo.ex_f, foo.ex_o);
 
1669
#else
 
1670
            seek = N_TXTOFF (foo);
 
1671
#endif
 
1672
            flag = (foo.a_magic == OMAGIC);
 
1673
            return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
 
1674
    ], tcl_ok=usable, tcl_ok=unusable)
 
1675
        AC_MSG_RESULT([$tcl_ok])
 
1676
        if test $tcl_ok = usable; then
 
1677
            AC_DEFINE(USE_SYS_EXEC_H)
 
1678
        else
 
1679
            AC_MSG_CHECKING([a.out.h])
 
1680
            AC_TRY_COMPILE([#include <a.out.h>],[
 
1681
                struct exec foo;
 
1682
                unsigned long seek;
 
1683
                int flag;
 
1684
#if defined(__mips) || defined(mips)
 
1685
                seek = N_TXTOFF (foo.ex_f, foo.ex_o);
 
1686
#else
 
1687
                seek = N_TXTOFF (foo);
 
1688
#endif
 
1689
                flag = (foo.a_magic == OMAGIC);
 
1690
                return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
 
1691
            ], tcl_ok=usable, tcl_ok=unusable)
 
1692
            AC_MSG_RESULT([$tcl_ok])
 
1693
            if test $tcl_ok = usable; then
 
1694
                AC_DEFINE(USE_A_OUT_H)
 
1695
            else
 
1696
                AC_MSG_CHECKING([sys/exec_aout.h])
 
1697
                AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
 
1698
                    struct exec foo;
 
1699
                    unsigned long seek;
 
1700
                    int flag;
 
1701
#if defined(__mips) || defined(mips)
 
1702
                    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
 
1703
#else
 
1704
                    seek = N_TXTOFF (foo);
 
1705
#endif
 
1706
                    flag = (foo.a_midmag == OMAGIC);
 
1707
                    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
 
1708
                ], tcl_ok=usable, tcl_ok=unusable)
 
1709
                AC_MSG_RESULT([$tcl_ok])
 
1710
                if test $tcl_ok = usable; then
 
1711
                    AC_DEFINE(USE_SYS_EXEC_AOUT_H)
 
1712
                else
 
1713
                    DL_OBJS=""
 
1714
                fi
 
1715
            fi
 
1716
        fi
 
1717
    fi
 
1718
 
 
1719
    # Step 5: disable dynamic loading if requested via a command-line switch.
 
1720
 
 
1721
    AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
 
1722
        [tcl_ok=$enableval], [tcl_ok=yes])
 
1723
    if test "$tcl_ok" = "no"; then
 
1724
        DL_OBJS=""
 
1725
    fi
 
1726
 
 
1727
    if test "x$DL_OBJS" != "x" ; then
 
1728
        BUILD_DLTEST="\$(DLTEST_TARGETS)"
 
1729
    else
 
1730
        echo "Can't figure out how to do dynamic loading or shared libraries"
 
1731
        echo "on this system."
 
1732
        SHLIB_CFLAGS=""
 
1733
        SHLIB_LD=""
 
1734
        SHLIB_SUFFIX=""
 
1735
        DL_OBJS="tclLoadNone.o"
 
1736
        DL_LIBS=""
 
1737
        LDFLAGS=""
 
1738
        LD_SEARCH_FLAGS=""
 
1739
        BUILD_DLTEST=""
 
1740
    fi
 
1741
 
 
1742
    # If we're running gcc, then change the C flags for compiling shared
 
1743
    # libraries to the right flags for gcc, instead of those for the
 
1744
    # standard manufacturer compiler.
 
1745
 
 
1746
    if test "$DL_OBJS" != "tclLoadNone.o" ; then
 
1747
        if test "$GCC" = "yes" ; then
 
1748
            case $system in
 
1749
                AIX-*)
 
1750
                    ;;
 
1751
                BSD/OS*)
 
1752
                    ;;
 
1753
                IRIX*)
 
1754
                    ;;
 
1755
                NetBSD-*|FreeBSD-*)
 
1756
                    ;;
 
1757
                Rhapsody-*|Darwin-*)
 
1758
                    ;;
 
1759
                RISCos-*)
 
1760
                    ;;
 
1761
                SCO_SV-3.2*)
 
1762
                    ;;
 
1763
                ULTRIX-4.*)
 
1764
                    ;;
 
1765
                windows)
 
1766
                    ;;
 
1767
                *)
 
1768
                    SHLIB_CFLAGS="-fPIC"
 
1769
                    ;;
 
1770
            esac
 
1771
        fi
 
1772
    fi
 
1773
 
 
1774
    if test "$SHARED_LIB_SUFFIX" = "" ; then
 
1775
        SHARED_LIB_SUFFIX='${PACKAGE_VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
 
1776
    fi
 
1777
    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
 
1778
        UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}\$\{DBGX\}.a'
 
1779
    fi
 
1780
 
 
1781
    AC_SUBST(DL_LIBS)
 
1782
    AC_SUBST(CFLAGS_DEBUG)
 
1783
    AC_SUBST(CFLAGS_OPTIMIZE)
 
1784
    AC_SUBST(CFLAGS_WARNING)
 
1785
    AC_SUBST(EXTRA_CFLAGS)
 
1786
 
 
1787
    AC_SUBST(STLIB_LD)
 
1788
    AC_SUBST(SHLIB_LD)
 
1789
    AC_SUBST(SHLIB_CFLAGS)
 
1790
    AC_SUBST(SHLIB_LD_FLAGS)
 
1791
    AC_SUBST(SHLIB_LD_LIBS)
 
1792
    AC_SUBST(LDFLAGS_DEBUG)
 
1793
    AC_SUBST(LDFLAGS_OPTIMIZE)
 
1794
    AC_SUBST(LD_LIBRARY_PATH_VAR)
 
1795
])
 
1796
 
 
1797
#--------------------------------------------------------------------
 
1798
# TEA_SERIAL_PORT
 
1799
#
 
1800
#       Determine which interface to use to talk to the serial port.
 
1801
#       Note that #include lines must begin in leftmost column for
 
1802
#       some compilers to recognize them as preprocessor directives,
 
1803
#       and some build environments have stdin not pointing at a
 
1804
#       pseudo-terminal (usually /dev/null instead.)
 
1805
#
 
1806
# Arguments:
 
1807
#       none
 
1808
#       
 
1809
# Results:
 
1810
#
 
1811
#       Defines only one of the following vars:
 
1812
#               HAVE_SYS_MODEM_H
 
1813
#               USE_TERMIOS
 
1814
#               USE_TERMIO
 
1815
#               USE_SGTTY
 
1816
#
 
1817
#--------------------------------------------------------------------
 
1818
 
 
1819
AC_DEFUN(TEA_SERIAL_PORT, [
 
1820
    AC_CHECK_HEADERS(sys/modem.h)
 
1821
    AC_MSG_CHECKING([termios vs. termio vs. sgtty])
 
1822
    AC_CACHE_VAL(tcl_cv_api_serial, [
 
1823
    AC_TRY_RUN([
 
1824
#include <termios.h>
 
1825
 
 
1826
int main() {
 
1827
    struct termios t;
 
1828
    if (tcgetattr(0, &t) == 0) {
 
1829
        cfsetospeed(&t, 0);
 
1830
        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
 
1831
        return 0;
 
1832
    }
 
1833
    return 1;
 
1834
}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
 
1835
    if test $tcl_cv_api_serial = no ; then
 
1836
        AC_TRY_RUN([
 
1837
#include <termio.h>
 
1838
 
 
1839
int main() {
 
1840
    struct termio t;
 
1841
    if (ioctl(0, TCGETA, &t) == 0) {
 
1842
        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
 
1843
        return 0;
 
1844
    }
 
1845
    return 1;
 
1846
}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
 
1847
    fi
 
1848
    if test $tcl_cv_api_serial = no ; then
 
1849
        AC_TRY_RUN([
 
1850
#include <sgtty.h>
 
1851
 
 
1852
int main() {
 
1853
    struct sgttyb t;
 
1854
    if (ioctl(0, TIOCGETP, &t) == 0) {
 
1855
        t.sg_ospeed = 0;
 
1856
        t.sg_flags |= ODDP | EVENP | RAW;
 
1857
        return 0;
 
1858
    }
 
1859
    return 1;
 
1860
}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
 
1861
    fi
 
1862
    if test $tcl_cv_api_serial = no ; then
 
1863
        AC_TRY_RUN([
 
1864
#include <termios.h>
 
1865
#include <errno.h>
 
1866
 
 
1867
int main() {
 
1868
    struct termios t;
 
1869
    if (tcgetattr(0, &t) == 0
 
1870
        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
 
1871
        cfsetospeed(&t, 0);
 
1872
        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
 
1873
        return 0;
 
1874
    }
 
1875
    return 1;
 
1876
}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
 
1877
    fi
 
1878
    if test $tcl_cv_api_serial = no; then
 
1879
        AC_TRY_RUN([
 
1880
#include <termio.h>
 
1881
#include <errno.h>
 
1882
 
 
1883
int main() {
 
1884
    struct termio t;
 
1885
    if (ioctl(0, TCGETA, &t) == 0
 
1886
        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
 
1887
        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
 
1888
        return 0;
 
1889
    }
 
1890
    return 1;
 
1891
    }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
 
1892
    fi
 
1893
    if test $tcl_cv_api_serial = no; then
 
1894
        AC_TRY_RUN([
 
1895
#include <sgtty.h>
 
1896
#include <errno.h>
 
1897
 
 
1898
int main() {
 
1899
    struct sgttyb t;
 
1900
    if (ioctl(0, TIOCGETP, &t) == 0
 
1901
        || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
 
1902
        t.sg_ospeed = 0;
 
1903
        t.sg_flags |= ODDP | EVENP | RAW;
 
1904
        return 0;
 
1905
    }
 
1906
    return 1;
 
1907
}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
 
1908
    fi])
 
1909
    case $tcl_cv_api_serial in
 
1910
        termios) AC_DEFINE(USE_TERMIOS);;
 
1911
        termio)  AC_DEFINE(USE_TERMIO);;
 
1912
        sgtty)   AC_DEFINE(USE_SGTTY);;
 
1913
    esac
 
1914
    AC_MSG_RESULT([$tcl_cv_api_serial])
 
1915
])
 
1916
 
 
1917
#--------------------------------------------------------------------
 
1918
# TEA_MISSING_POSIX_HEADERS
 
1919
#
 
1920
#       Supply substitutes for missing POSIX header files.  Special
 
1921
#       notes:
 
1922
#           - stdlib.h doesn't define strtol, strtoul, or
 
1923
#             strtod insome versions of SunOS
 
1924
#           - some versions of string.h don't declare procedures such
 
1925
#             as strstr
 
1926
#
 
1927
# Arguments:
 
1928
#       none
 
1929
#       
 
1930
# Results:
 
1931
#
 
1932
#       Defines some of the following vars:
 
1933
#               NO_DIRENT_H
 
1934
#               NO_ERRNO_H
 
1935
#               NO_VALUES_H
 
1936
#               NO_LIMITS_H
 
1937
#               NO_STDLIB_H
 
1938
#               NO_STRING_H
 
1939
#               NO_SYS_WAIT_H
 
1940
#               NO_DLFCN_H
 
1941
#               HAVE_UNISTD_H
 
1942
#               HAVE_SYS_PARAM_H
 
1943
#
 
1944
#               HAVE_STRING_H ?
 
1945
#
 
1946
#--------------------------------------------------------------------
 
1947
 
 
1948
AC_DEFUN(TEA_MISSING_POSIX_HEADERS, [
 
1949
    AC_MSG_CHECKING([dirent.h])
 
1950
    AC_TRY_LINK([#include <sys/types.h>
 
1951
#include <dirent.h>], [
 
1952
#ifndef _POSIX_SOURCE
 
1953
#   ifdef __Lynx__
 
1954
        /*
 
1955
         * Generate compilation error to make the test fail:  Lynx headers
 
1956
         * are only valid if really in the POSIX environment.
 
1957
         */
 
1958
 
 
1959
        missing_procedure();
 
1960
#   endif
 
1961
#endif
 
1962
DIR *d;
 
1963
struct dirent *entryPtr;
 
1964
char *p;
 
1965
d = opendir("foobar");
 
1966
entryPtr = readdir(d);
 
1967
p = entryPtr->d_name;
 
1968
closedir(d);
 
1969
], tcl_ok=yes, tcl_ok=no)
 
1970
 
 
1971
    if test $tcl_ok = no; then
 
1972
        AC_DEFINE(NO_DIRENT_H)
 
1973
    fi
 
1974
 
 
1975
    AC_MSG_RESULT([$tcl_ok])
 
1976
    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H)])
 
1977
    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H)])
 
1978
    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H)])
 
1979
    AC_CHECK_HEADER(limits.h, , [AC_DEFINE(NO_LIMITS_H)])
 
1980
    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
 
1981
    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
 
1982
    AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
 
1983
    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
 
1984
    if test $tcl_ok = 0; then
 
1985
        AC_DEFINE(NO_STDLIB_H)
 
1986
    fi
 
1987
    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
 
1988
    AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
 
1989
    AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
 
1990
 
 
1991
    # See also memmove check below for a place where NO_STRING_H can be
 
1992
    # set and why.
 
1993
 
 
1994
    if test $tcl_ok = 0; then
 
1995
        AC_DEFINE(NO_STRING_H)
 
1996
    fi
 
1997
 
 
1998
    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H)])
 
1999
    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H)])
 
2000
 
 
2001
    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
 
2002
 
 
2003
    AC_HAVE_HEADERS(unistd.h sys/param.h)
 
2004
 
 
2005
])
 
2006
 
 
2007
#--------------------------------------------------------------------
 
2008
# TEA_PATH_X
 
2009
#
 
2010
#       Locate the X11 header files and the X11 library archive.  Try
 
2011
#       the ac_path_x macro first, but if it doesn't find the X stuff
 
2012
#       (e.g. because there's no xmkmf program) then check through
 
2013
#       a list of possible directories.  Under some conditions the
 
2014
#       autoconf macro will return an include directory that contains
 
2015
#       no include files, so double-check its result just to be safe.
 
2016
#
 
2017
#       This should be called after TEA_CONFIG_CFLAGS as setting the
 
2018
#       LIBS line can confuse some configure macro magic.
 
2019
#
 
2020
# Arguments:
 
2021
#       none
 
2022
#       
 
2023
# Results:
 
2024
#
 
2025
#       Sets the following vars:
 
2026
#               XINCLUDES
 
2027
#               XLIBSW
 
2028
#               LIBS (appends to)
 
2029
#
 
2030
#--------------------------------------------------------------------
 
2031
 
 
2032
AC_DEFUN(TEA_PATH_X, [
 
2033
    if test "${TEA_PLATFORM}" = "unix" ; then
 
2034
        TEA_PATH_UNIX_X
 
2035
    fi
 
2036
])
 
2037
 
 
2038
AC_DEFUN(TEA_PATH_UNIX_X, [
 
2039
    AC_PATH_X
 
2040
    not_really_there=""
 
2041
    if test "$no_x" = ""; then
 
2042
        if test "$x_includes" = ""; then
 
2043
            AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
 
2044
        else
 
2045
            if test ! -r $x_includes/X11/Intrinsic.h; then
 
2046
                not_really_there="yes"
 
2047
            fi
 
2048
        fi
 
2049
    fi
 
2050
    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
 
2051
        AC_MSG_CHECKING([for X11 header files])
 
2052
        XINCLUDES="# no special path needed"
 
2053
        AC_TRY_CPP([#include <X11/Intrinsic.h>], , XINCLUDES="nope")
 
2054
        if test "$XINCLUDES" = nope; then
 
2055
            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"
 
2056
            for i in $dirs ; do
 
2057
                if test -r $i/X11/Intrinsic.h; then
 
2058
                    AC_MSG_RESULT([$i])
 
2059
                    XINCLUDES=" -I$i"
 
2060
                    break
 
2061
                fi
 
2062
            done
 
2063
        fi
 
2064
    else
 
2065
        if test "$x_includes" != ""; then
 
2066
            XINCLUDES=-I$x_includes
 
2067
        else
 
2068
            XINCLUDES="# no special path needed"
 
2069
        fi
 
2070
    fi
 
2071
    if test "$XINCLUDES" = nope; then
 
2072
        AC_MSG_RESULT([could not find any!])
 
2073
        XINCLUDES="# no include files found"
 
2074
    fi
 
2075
 
 
2076
    if test "$no_x" = yes; then
 
2077
        AC_MSG_CHECKING([for X11 libraries])
 
2078
        XLIBSW=nope
 
2079
        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"
 
2080
        for i in $dirs ; do
 
2081
            if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
 
2082
                AC_MSG_RESULT([$i])
 
2083
                XLIBSW="-L$i -lX11"
 
2084
                x_libraries="$i"
 
2085
                break
 
2086
            fi
 
2087
        done
 
2088
    else
 
2089
        if test "$x_libraries" = ""; then
 
2090
            XLIBSW=-lX11
 
2091
        else
 
2092
            XLIBSW="-L$x_libraries -lX11"
 
2093
        fi
 
2094
    fi
 
2095
    if test "$XLIBSW" = nope ; then
 
2096
        AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
 
2097
    fi
 
2098
    if test "$XLIBSW" = nope ; then
 
2099
        AC_MSG_RESULT([could not find any!  Using -lX11.])
 
2100
        XLIBSW=-lX11
 
2101
    fi
 
2102
    if test x"${XLIBSW}" != x ; then
 
2103
        PKG_LIBS="${PKG_LIBS} ${XLIBSW}"
 
2104
    fi
 
2105
])
 
2106
 
 
2107
#--------------------------------------------------------------------
 
2108
# TEA_BLOCKING_STYLE
 
2109
#
 
2110
#       The statements below check for systems where POSIX-style
 
2111
#       non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented. 
 
2112
#       On these systems (mostly older ones), use the old BSD-style
 
2113
#       FIONBIO approach instead.
 
2114
#
 
2115
# Arguments:
 
2116
#       none
 
2117
#       
 
2118
# Results:
 
2119
#
 
2120
#       Defines some of the following vars:
 
2121
#               HAVE_SYS_IOCTL_H
 
2122
#               HAVE_SYS_FILIO_H
 
2123
#               USE_FIONBIO
 
2124
#               O_NONBLOCK
 
2125
#
 
2126
#--------------------------------------------------------------------
 
2127
 
 
2128
AC_DEFUN(TEA_BLOCKING_STYLE, [
 
2129
    AC_CHECK_HEADERS(sys/ioctl.h)
 
2130
    AC_CHECK_HEADERS(sys/filio.h)
 
2131
    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
 
2132
    if test -f /usr/lib/NextStep/software_version; then
 
2133
        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
 
2134
    else
 
2135
        system=`uname -s`-`uname -r`
 
2136
        if test "$?" -ne 0 ; then
 
2137
            system=unknown
 
2138
        else
 
2139
            # Special check for weird MP-RAS system (uname returns weird
 
2140
            # results, and the version is kept in special file).
 
2141
        
 
2142
            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
 
2143
                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
 
2144
            fi
 
2145
            if test "`uname -s`" = "AIX" ; then
 
2146
                system=AIX-`uname -v`.`uname -r`
 
2147
            fi
 
2148
        fi
 
2149
    fi
 
2150
    case $system in
 
2151
        # There used to be code here to use FIONBIO under AIX.  However, it
 
2152
        # was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
 
2153
        # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
 
2154
        # code (JO, 5/31/97).
 
2155
 
 
2156
        OSF*)
 
2157
            AC_DEFINE(USE_FIONBIO)
 
2158
            AC_MSG_RESULT([FIONBIO])
 
2159
            ;;
 
2160
        SunOS-4*)
 
2161
            AC_DEFINE(USE_FIONBIO)
 
2162
            AC_MSG_RESULT([FIONBIO])
 
2163
            ;;
 
2164
        ULTRIX-4.*)
 
2165
            AC_DEFINE(USE_FIONBIO)
 
2166
            AC_MSG_RESULT([FIONBIO])
 
2167
            ;;
 
2168
        *)
 
2169
            AC_MSG_RESULT([O_NONBLOCK])
 
2170
            ;;
 
2171
    esac
 
2172
])
 
2173
 
 
2174
#--------------------------------------------------------------------
 
2175
# TEA_TIME_HANLDER
 
2176
#
 
2177
#       Checks how the system deals with time.h, what time structures
 
2178
#       are used on the system, and what fields the structures have.
 
2179
#
 
2180
# Arguments:
 
2181
#       none
 
2182
#       
 
2183
# Results:
 
2184
#
 
2185
#       Defines some of the following vars:
 
2186
#               USE_DELTA_FOR_TZ
 
2187
#               HAVE_TM_GMTOFF
 
2188
#               HAVE_TM_TZADJ
 
2189
#               HAVE_TIMEZONE_VAR
 
2190
#
 
2191
#--------------------------------------------------------------------
 
2192
 
 
2193
AC_DEFUN(TEA_TIME_HANDLER, [
 
2194
    AC_CHECK_HEADERS(sys/time.h)
 
2195
    AC_HEADER_TIME
 
2196
    AC_STRUCT_TIMEZONE
 
2197
 
 
2198
    AC_CHECK_FUNCS(gmtime_r localtime_r)
 
2199
 
 
2200
    AC_MSG_CHECKING([tm_tzadj in struct tm])
 
2201
    AC_CACHE_VAL(tcl_cv_member_tm_tzadj,
 
2202
        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
 
2203
            tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no))
 
2204
    AC_MSG_RESULT([$tcl_cv_member_tm_tzadj])
 
2205
    if test $tcl_cv_member_tm_tzadj = yes ; then
 
2206
        AC_DEFINE(HAVE_TM_TZADJ)
 
2207
    fi
 
2208
 
 
2209
    AC_MSG_CHECKING([tm_gmtoff in struct tm])
 
2210
    AC_CACHE_VAL(tcl_cv_member_tm_gmtoff,
 
2211
        AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
 
2212
            tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no))
 
2213
    AC_MSG_RESULT([$tcl_cv_member_tm_gmtoff])
 
2214
    if test $tcl_cv_member_tm_gmtoff = yes ; then
 
2215
        AC_DEFINE(HAVE_TM_GMTOFF)
 
2216
    fi
 
2217
 
 
2218
    #
 
2219
    # Its important to include time.h in this check, as some systems
 
2220
    # (like convex) have timezone functions, etc.
 
2221
    #
 
2222
    AC_MSG_CHECKING([long timezone variable])
 
2223
    AC_CACHE_VAL(tcl_cv_var_timezone,
 
2224
        AC_TRY_COMPILE([#include <time.h>],
 
2225
            [extern long timezone;
 
2226
            timezone += 1;
 
2227
            exit (0);],
 
2228
            tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no))
 
2229
    AC_MSG_RESULT([$tcl_cv_timezone_long])
 
2230
    if test $tcl_cv_timezone_long = yes ; then
 
2231
        AC_DEFINE(HAVE_TIMEZONE_VAR)
 
2232
    else
 
2233
        #
 
2234
        # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
 
2235
        #
 
2236
        AC_MSG_CHECKING([time_t timezone variable])
 
2237
        AC_CACHE_VAL(tcl_cv_timezone_time,
 
2238
            AC_TRY_COMPILE([#include <time.h>],
 
2239
                [extern time_t timezone;
 
2240
                timezone += 1;
 
2241
                exit (0);],
 
2242
                tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no))
 
2243
        AC_MSG_RESULT([$tcl_cv_timezone_time])
 
2244
        if test $tcl_cv_timezone_time = yes ; then
 
2245
            AC_DEFINE(HAVE_TIMEZONE_VAR)
 
2246
        fi
 
2247
    fi
 
2248
])
 
2249
 
 
2250
#--------------------------------------------------------------------
 
2251
# TEA_BUGGY_STRTOD
 
2252
#
 
2253
#       Under Solaris 2.4, strtod returns the wrong value for the
 
2254
#       terminating character under some conditions.  Check for this
 
2255
#       and if the problem exists use a substitute procedure
 
2256
#       "fixstrtod" (provided by Tcl) that corrects the error.
 
2257
#       Also, on Compaq's Tru64 Unix 5.0,
 
2258
#       strtod(" ") returns 0.0 instead of a failure to convert.
 
2259
#
 
2260
# Arguments:
 
2261
#       none
 
2262
#       
 
2263
# Results:
 
2264
#
 
2265
#       Might defines some of the following vars:
 
2266
#               strtod (=fixstrtod)
 
2267
#
 
2268
#--------------------------------------------------------------------
 
2269
 
 
2270
AC_DEFUN(TEA_BUGGY_STRTOD, [
 
2271
    AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
 
2272
    if test "$tcl_strtod" = 1; then
 
2273
        AC_MSG_CHECKING([for Solaris2.4/Tru64 strtod bugs])
 
2274
        AC_TRY_RUN([
 
2275
            extern double strtod();
 
2276
            int main()
 
2277
            {
 
2278
                char *string = "NaN", *spaceString = " ";
 
2279
                char *term;
 
2280
                double value;
 
2281
                value = strtod(string, &term);
 
2282
                if ((term != string) && (term[-1] == 0)) {
 
2283
                    exit(1);
 
2284
                }
 
2285
                value = strtod(spaceString, &term);
 
2286
                if (term == (spaceString+1)) {
 
2287
                    exit(1);
 
2288
                }
 
2289
                exit(0);
 
2290
            }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
 
2291
        if test "$tcl_ok" = 1; then
 
2292
            AC_MSG_RESULT([ok])
 
2293
        else
 
2294
            AC_MSG_RESULT([buggy])
 
2295
            #LIBOBJS="$LIBOBJS fixstrtod.o"
 
2296
            AC_LIBOBJ([fixstrtod])
 
2297
            USE_COMPAT=1
 
2298
            AC_DEFINE(strtod, fixstrtod)
 
2299
        fi
 
2300
    fi
 
2301
])
 
2302
 
 
2303
#--------------------------------------------------------------------
 
2304
# TEA_TCL_LINK_LIBS
 
2305
#
 
2306
#       Search for the libraries needed to link the Tcl shell.
 
2307
#       Things like the math library (-lm) and socket stuff (-lsocket vs.
 
2308
#       -lnsl) are dealt with here.
 
2309
#
 
2310
# Arguments:
 
2311
#       Requires the following vars to be set in the Makefile:
 
2312
#               DL_LIBS
 
2313
#               LIBS
 
2314
#               MATH_LIBS
 
2315
#       
 
2316
# Results:
 
2317
#
 
2318
#       Subst's the following var:
 
2319
#               TCL_LIBS
 
2320
#               MATH_LIBS
 
2321
#
 
2322
#       Might append to the following vars:
 
2323
#               LIBS
 
2324
#
 
2325
#       Might define the following vars:
 
2326
#               HAVE_NET_ERRNO_H
 
2327
#
 
2328
#--------------------------------------------------------------------
 
2329
 
 
2330
AC_DEFUN(TEA_TCL_LINK_LIBS, [
 
2331
    #--------------------------------------------------------------------
 
2332
    # On a few very rare systems, all of the libm.a stuff is
 
2333
    # already in libc.a.  Set compiler flags accordingly.
 
2334
    # Also, Linux requires the "ieee" library for math to work
 
2335
    # right (and it must appear before "-lm").
 
2336
    #--------------------------------------------------------------------
 
2337
 
 
2338
    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
 
2339
    AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
 
2340
 
 
2341
    #--------------------------------------------------------------------
 
2342
    # Interactive UNIX requires -linet instead of -lsocket, plus it
 
2343
    # needs net/errno.h to define the socket-related error codes.
 
2344
    #--------------------------------------------------------------------
 
2345
 
 
2346
    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
 
2347
    AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))
 
2348
 
 
2349
    #--------------------------------------------------------------------
 
2350
    #   Check for the existence of the -lsocket and -lnsl libraries.
 
2351
    #   The order here is important, so that they end up in the right
 
2352
    #   order in the command line generated by make.  Here are some
 
2353
    #   special considerations:
 
2354
    #   1. Use "connect" and "accept" to check for -lsocket, and
 
2355
    #      "gethostbyname" to check for -lnsl.
 
2356
    #   2. Use each function name only once:  can't redo a check because
 
2357
    #      autoconf caches the results of the last check and won't redo it.
 
2358
    #   3. Use -lnsl and -lsocket only if they supply procedures that
 
2359
    #      aren't already present in the normal libraries.  This is because
 
2360
    #      IRIX 5.2 has libraries, but they aren't needed and they're
 
2361
    #      bogus:  they goof up name resolution if used.
 
2362
    #   4. On some SVR4 systems, can't use -lsocket without -lnsl too.
 
2363
    #      To get around this problem, check for both libraries together
 
2364
    #      if -lsocket doesn't work by itself.
 
2365
    #--------------------------------------------------------------------
 
2366
 
 
2367
    tcl_checkBoth=0
 
2368
    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
 
2369
    if test "$tcl_checkSocket" = 1; then
 
2370
        AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
 
2371
            LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
 
2372
    fi
 
2373
    if test "$tcl_checkBoth" = 1; then
 
2374
        tk_oldLibs=$LIBS
 
2375
        LIBS="$LIBS -lsocket -lnsl"
 
2376
        AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
 
2377
    fi
 
2378
    AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
 
2379
            [LIBS="$LIBS -lnsl"])])
 
2380
    
 
2381
    # Don't perform the eval of the libraries here because DL_LIBS
 
2382
    # won't be set until we call TEA_CONFIG_CFLAGS
 
2383
 
 
2384
    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
 
2385
    AC_SUBST(TCL_LIBS)
 
2386
    AC_SUBST(MATH_LIBS)
 
2387
])
 
2388
 
 
2389
#--------------------------------------------------------------------
 
2390
# TEA_TCL_EARLY_FLAGS
 
2391
#
 
2392
#       Check for what flags are needed to be passed so the correct OS
 
2393
#       features are available.
 
2394
#
 
2395
# Arguments:
 
2396
#       None
 
2397
#       
 
2398
# Results:
 
2399
#
 
2400
#       Might define the following vars:
 
2401
#               _ISOC99_SOURCE
 
2402
#               _LARGEFILE64_SOURCE
 
2403
#
 
2404
#--------------------------------------------------------------------
 
2405
 
 
2406
AC_DEFUN(TEA_TCL_EARLY_FLAG,[
 
2407
    AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
 
2408
        AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
 
2409
            AC_TRY_COMPILE([[#define ]$1[ 1
 
2410
]$2], $3,
 
2411
                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
 
2412
                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
 
2413
    if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
 
2414
        AC_DEFINE($1)
 
2415
        tcl_flags="$tcl_flags $1"
 
2416
    fi
 
2417
])
 
2418
 
 
2419
AC_DEFUN(TEA_TCL_EARLY_FLAGS,[
 
2420
    AC_MSG_CHECKING([for required early compiler flags])
 
2421
    tcl_flags=""
 
2422
    TEA_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
 
2423
        [char *p = (char *)strtoll; char *q = (char *)strtoull;])
 
2424
    TEA_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
 
2425
        [struct stat64 buf; int i = stat64("/", &buf);])
 
2426
    if test "x${tcl_flags}" = "x" ; then
 
2427
        AC_MSG_RESULT([none])
 
2428
    else
 
2429
        AC_MSG_RESULT([${tcl_flags}])
 
2430
    fi
 
2431
])
 
2432
 
 
2433
#--------------------------------------------------------------------
 
2434
# TEA_TCL_64BIT_FLAGS
 
2435
#
 
2436
#       Check for what is defined in the way of 64-bit features.
 
2437
#
 
2438
# Arguments:
 
2439
#       None
 
2440
#       
 
2441
# Results:
 
2442
#
 
2443
#       Might define the following vars:
 
2444
#               TCL_WIDE_INT_IS_LONG
 
2445
#               TCL_WIDE_INT_TYPE
 
2446
#               HAVE_STRUCT_DIRENT64
 
2447
#               HAVE_STRUCT_STAT64
 
2448
#               HAVE_TYPE_OFF64_T
 
2449
#
 
2450
#--------------------------------------------------------------------
 
2451
 
 
2452
AC_DEFUN(TEA_TCL_64BIT_FLAGS, [
 
2453
    AC_MSG_CHECKING([for 64-bit integer type])
 
2454
    AC_CACHE_VAL(tcl_cv_type_64bit,[
 
2455
        AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
 
2456
           tcl_cv_type_64bit=__int64,tcl_cv_type_64bit=none
 
2457
           AC_TRY_RUN([#include <unistd.h>
 
2458
                int main() {exit(!(sizeof(long long) > sizeof(long)));}
 
2459
                ], tcl_cv_type_64bit="long long"))])
 
2460
    if test "${tcl_cv_type_64bit}" = none ; then
 
2461
        AC_MSG_RESULT([using long])
 
2462
    elif test "${tcl_cv_type_64bit}" = "__int64" ; then
 
2463
        # We actually want to use the default tcl.h checks in this
 
2464
        # case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER*
 
2465
        AC_MSG_RESULT([using Tcl header defaults])
 
2466
    else
 
2467
        AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit})
 
2468
        AC_MSG_RESULT([${tcl_cv_type_64bit}])
 
2469
 
 
2470
        # Now check for auxiliary declarations
 
2471
        AC_MSG_CHECKING([for struct dirent64])
 
2472
        AC_CACHE_VAL(tcl_cv_struct_dirent64,[
 
2473
            AC_TRY_COMPILE([#include <sys/types.h>
 
2474
#include <sys/dirent.h>],[struct dirent64 p;],
 
2475
                tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
 
2476
        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
 
2477
            AC_DEFINE(HAVE_STRUCT_DIRENT64)
 
2478
        fi
 
2479
        AC_MSG_RESULT([${tcl_cv_struct_dirent64}])
 
2480
 
 
2481
        AC_MSG_CHECKING([for struct stat64])
 
2482
        AC_CACHE_VAL(tcl_cv_struct_stat64,[
 
2483
            AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
 
2484
],
 
2485
                tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
 
2486
        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
 
2487
            AC_DEFINE(HAVE_STRUCT_STAT64)
 
2488
        fi
 
2489
        AC_MSG_RESULT([${tcl_cv_struct_stat64}])
 
2490
 
 
2491
        AC_MSG_CHECKING([for off64_t])
 
2492
        AC_CACHE_VAL(tcl_cv_type_off64_t,[
 
2493
            AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
 
2494
],
 
2495
                tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
 
2496
        if test "x${tcl_cv_type_off64_t}" = "xyes" ; then
 
2497
            AC_DEFINE(HAVE_TYPE_OFF64_T)
 
2498
        fi
 
2499
        AC_MSG_RESULT([${tcl_cv_type_off64_t}])
 
2500
    fi
 
2501
])
 
2502
 
 
2503
##
 
2504
## Here ends the standard Tcl configuration bits and starts the
 
2505
## TEA specific functions
 
2506
##
 
2507
 
 
2508
#------------------------------------------------------------------------
 
2509
# TEA_INIT --
 
2510
#
 
2511
#       Init various Tcl Extension Architecture (TEA) variables.
 
2512
#       This should be the first called TEA_* macro.
 
2513
#
 
2514
# Arguments:
 
2515
#       none
 
2516
#
 
2517
# Results:
 
2518
#
 
2519
#       Defines and substs the following vars:
 
2520
#               CYGPATH
 
2521
#               EXEEXT
 
2522
#       Defines only:
 
2523
#               TEA_INITED
 
2524
#               TEA_PLATFORM (windows or unix)
 
2525
#
 
2526
# "cygpath" is used on windows to generate native path names for include
 
2527
# files. These variables should only be used with the compiler and linker
 
2528
# since they generate native path names.
 
2529
#
 
2530
# EXEEXT
 
2531
#       Select the executable extension based on the host type.  This
 
2532
#       is a lightweight replacement for AC_EXEEXT that doesn't require
 
2533
#       a compiler.
 
2534
#------------------------------------------------------------------------
 
2535
 
 
2536
AC_DEFUN(TEA_INIT, [
 
2537
    TEA_VERSION="3.0"
 
2538
 
 
2539
    AC_MSG_CHECKING([for correct TEA configuration])
 
2540
    if test x"${PACKAGE_NAME}" = x ; then
 
2541
        AC_MSG_ERROR([
 
2542
The PACKAGE_NAME variable must be defined by your TEA configure.in])
 
2543
    fi
 
2544
    if test x"$1" = x ; then
 
2545
        AC_MSG_ERROR([
 
2546
TEA version not specified.])
 
2547
    elif test "$1" != "${TEA_VERSION}" ; then
 
2548
        AC_MSG_RESULT([warning: TEA version "$1" != ${TEA_VERSION}])
 
2549
    else
 
2550
        AC_MSG_RESULT([ok])
 
2551
    fi
 
2552
    case "`uname -s`" in
 
2553
        *win32*|*WIN32*|*CYGWIN_NT*|*CYGWIN_9*|*CYGWIN_ME*|*MINGW32_*)
 
2554
            AC_CHECK_PROG(CYGPATH, cygpath, cygpath -w, echo)
 
2555
            EXEEXT=".exe"
 
2556
            TEA_PLATFORM="windows"
 
2557
            ;;
 
2558
        *)
 
2559
            CYGPATH=echo
 
2560
            EXEEXT=""
 
2561
            TEA_PLATFORM="unix"
 
2562
            ;;
 
2563
    esac
 
2564
 
 
2565
    # Check if exec_prefix is set. If not use fall back to prefix
 
2566
    if test x$exec_prefix = xNONE ; then exec_prefix=$prefix ; fi
 
2567
 
 
2568
    AC_SUBST(EXEEXT)
 
2569
    AC_SUBST(CYGPATH)
 
2570
 
 
2571
    # This package name must be replaced statically for AC_SUBST to work
 
2572
    AC_SUBST(PKG_LIB_FILE)
 
2573
    # Substitute STUB_LIB_FILE in case package creates a stub library too.
 
2574
    AC_SUBST(PKG_STUB_LIB_FILE)
 
2575
 
 
2576
    # We AC_SUBST these here to ensure they are subst'ed,
 
2577
    # in case the user doesn't call TEA_ADD_...
 
2578
    AC_SUBST(PKG_STUB_SOURCES)
 
2579
    AC_SUBST(PKG_STUB_OBJECTS)
 
2580
    AC_SUBST(PKG_TCL_SOURCES)
 
2581
    AC_SUBST(PKG_HEADERS)
 
2582
    AC_SUBST(PKG_INCLUDES)
 
2583
    AC_SUBST(PKG_LIBS)
 
2584
    AC_SUBST(PKG_CFLAGS)
 
2585
])
 
2586
 
 
2587
#------------------------------------------------------------------------
 
2588
# TEA_ADD_SOURCES --
 
2589
#
 
2590
#       Specify one or more source files.  Users should check for
 
2591
#       the right platform before adding to their list.
 
2592
#       It is not important to specify the directory, as long as it is
 
2593
#       in the generic, win or unix subdirectory of $(srcdir).
 
2594
#
 
2595
# Arguments:
 
2596
#       one or more file names
 
2597
#
 
2598
# Results:
 
2599
#
 
2600
#       Defines and substs the following vars:
 
2601
#               PKG_SOURCES
 
2602
#               PKG_OBJECTS
 
2603
#------------------------------------------------------------------------
 
2604
AC_DEFUN(TEA_ADD_SOURCES, [
 
2605
    vars="$@"
 
2606
    for i in $vars; do
 
2607
        # check for existence - allows for generic/win/unix VPATH
 
2608
        if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
 
2609
            -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
 
2610
            ; then
 
2611
            AC_MSG_ERROR([could not find source file '$i'])
 
2612
        fi
 
2613
        PKG_SOURCES="$PKG_SOURCES $i"
 
2614
        # this assumes it is in a VPATH dir
 
2615
        i=`basename $i`
 
2616
        # handle user calling this before or after TEA_SETUP_COMPILER
 
2617
        if test x"${OBJEXT}" != x ; then
 
2618
            j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
 
2619
        else
 
2620
            j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
 
2621
        fi
 
2622
        PKG_OBJECTS="$PKG_OBJECTS $j"
 
2623
    done
 
2624
    AC_SUBST(PKG_SOURCES)
 
2625
    AC_SUBST(PKG_OBJECTS)
 
2626
])
 
2627
 
 
2628
#------------------------------------------------------------------------
 
2629
# TEA_ADD_STUB_SOURCES --
 
2630
#
 
2631
#       Specify one or more source files.  Users should check for
 
2632
#       the right platform before adding to their list.
 
2633
#       It is not important to specify the directory, as long as it is
 
2634
#       in the generic, win or unix subdirectory of $(srcdir).
 
2635
#
 
2636
# Arguments:
 
2637
#       one or more file names
 
2638
#
 
2639
# Results:
 
2640
#
 
2641
#       Defines and substs the following vars:
 
2642
#               PKG_STUB_SOURCES
 
2643
#               PKG_STUB_OBJECTS
 
2644
#------------------------------------------------------------------------
 
2645
AC_DEFUN(TEA_ADD_STUB_SOURCES, [
 
2646
    vars="$@"
 
2647
    for i in $vars; do
 
2648
        # check for existence - allows for generic/win/unix VPATH
 
2649
        if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
 
2650
            -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
 
2651
            ; then
 
2652
            AC_MSG_ERROR([could not find stub source file '$i'])
 
2653
        fi
 
2654
        PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i"
 
2655
        # this assumes it is in a VPATH dir
 
2656
        i=`basename $i`
 
2657
        # handle user calling this before or after TEA_SETUP_COMPILER
 
2658
        if test x"${OBJEXT}" != x ; then
 
2659
            j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}"
 
2660
        else
 
2661
            j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}"
 
2662
        fi
 
2663
        PKG_STUB_OBJECTS="$PKG_STUB_OBJECTS $j"
 
2664
    done
 
2665
    AC_SUBST(PKG_STUB_SOURCES)
 
2666
    AC_SUBST(PKG_STUB_OBJECTS)
 
2667
])
 
2668
 
 
2669
#------------------------------------------------------------------------
 
2670
# TEA_ADD_TCL_SOURCES --
 
2671
#
 
2672
#       Specify one or more Tcl source files.  These should be platform
 
2673
#       independent runtime files.
 
2674
#
 
2675
# Arguments:
 
2676
#       one or more file names
 
2677
#
 
2678
# Results:
 
2679
#
 
2680
#       Defines and substs the following vars:
 
2681
#               PKG_TCL_SOURCES
 
2682
#------------------------------------------------------------------------
 
2683
AC_DEFUN(TEA_ADD_TCL_SOURCES, [
 
2684
    vars="$@"
 
2685
    for i in $vars; do
 
2686
        # check for existence, be strict because it is installed
 
2687
        if test ! -f "${srcdir}/$i" ; then
 
2688
            AC_MSG_ERROR([could not find tcl source file '${srcdir}/$i'])
 
2689
        fi
 
2690
        PKG_TCL_SOURCES="$PKG_TCL_SOURCES $i"
 
2691
    done
 
2692
    AC_SUBST(PKG_TCL_SOURCES)
 
2693
])
 
2694
 
 
2695
#------------------------------------------------------------------------
 
2696
# TEA_ADD_HEADERS --
 
2697
#
 
2698
#       Specify one or more source headers.  Users should check for
 
2699
#       the right platform before adding to their list.
 
2700
#
 
2701
# Arguments:
 
2702
#       one or more file names
 
2703
#
 
2704
# Results:
 
2705
#
 
2706
#       Defines and substs the following vars:
 
2707
#               PKG_HEADERS
 
2708
#------------------------------------------------------------------------
 
2709
AC_DEFUN(TEA_ADD_HEADERS, [
 
2710
    vars="$@"
 
2711
    for i in $vars; do
 
2712
        # check for existence, be strict because it is installed
 
2713
        if test ! -f "${srcdir}/$i" ; then
 
2714
            AC_MSG_ERROR([could not find header file '${srcdir}/$i'])
 
2715
        fi
 
2716
        PKG_HEADERS="$PKG_HEADERS $i"
 
2717
    done
 
2718
    AC_SUBST(PKG_HEADERS)
 
2719
])
 
2720
 
 
2721
#------------------------------------------------------------------------
 
2722
# TEA_ADD_INCLUDES --
 
2723
#
 
2724
#       Specify one or more include dirs.  Users should check for
 
2725
#       the right platform before adding to their list.
 
2726
#
 
2727
# Arguments:
 
2728
#       one or more file names
 
2729
#
 
2730
# Results:
 
2731
#
 
2732
#       Defines and substs the following vars:
 
2733
#               PKG_INCLUDES
 
2734
#------------------------------------------------------------------------
 
2735
AC_DEFUN(TEA_ADD_INCLUDES, [
 
2736
    vars="$@"
 
2737
    for i in $vars; do
 
2738
        PKG_INCLUDES="$PKG_INCLUDES $i"
 
2739
    done
 
2740
    AC_SUBST(PKG_INCLUDES)
 
2741
])
 
2742
 
 
2743
#------------------------------------------------------------------------
 
2744
# TEA_ADD_LIBS --
 
2745
#
 
2746
#       Specify one or more libraries.  Users should check for
 
2747
#       the right platform before adding to their list.
 
2748
#
 
2749
# Arguments:
 
2750
#       one or more file names
 
2751
#
 
2752
# Results:
 
2753
#
 
2754
#       Defines and substs the following vars:
 
2755
#               PKG_LIBS
 
2756
#------------------------------------------------------------------------
 
2757
AC_DEFUN(TEA_ADD_LIBS, [
 
2758
    vars="$@"
 
2759
    for i in $vars; do
 
2760
        PKG_LIBS="$PKG_LIBS $i"
 
2761
    done
 
2762
    AC_SUBST(PKG_LIBS)
 
2763
])
 
2764
 
 
2765
#------------------------------------------------------------------------
 
2766
# TEA_ADD_CFLAGS --
 
2767
#
 
2768
#       Specify one or more CFLAGS.  Users should check for
 
2769
#       the right platform before adding to their list.
 
2770
#
 
2771
# Arguments:
 
2772
#       one or more file names
 
2773
#
 
2774
# Results:
 
2775
#
 
2776
#       Defines and substs the following vars:
 
2777
#               PKG_CFLAGS
 
2778
#------------------------------------------------------------------------
 
2779
AC_DEFUN(TEA_ADD_CFLAGS, [
 
2780
    PKG_CFLAGS="$PKG_CFLAGS $@"
 
2781
    AC_SUBST(PKG_CFLAGS)
 
2782
])
 
2783
 
 
2784
#------------------------------------------------------------------------
 
2785
# TEA_PREFIX --
 
2786
#
 
2787
#       Handle the --prefix=... option by defaulting to what Tcl gave
 
2788
#
 
2789
# Arguments:
 
2790
#       none
 
2791
#
 
2792
# Results:
 
2793
#
 
2794
#       If --prefix or --exec-prefix was not specified, $prefix and
 
2795
#       $exec_prefix will be set to the values given to Tcl when it was
 
2796
#       configured.
 
2797
#------------------------------------------------------------------------
 
2798
AC_DEFUN(TEA_PREFIX, [
 
2799
    # Should be AC_MSG_NOTICE, but that requires autoconf 2.50
 
2800
    if test "${prefix}" = "NONE"; then
 
2801
        prefix_default=yes
 
2802
        if test x"${TCL_PREFIX}" != x; then
 
2803
            AC_MSG_WARN([--prefix defaulting to TCL_PREFIX ${TCL_PREFIX}])
 
2804
            prefix=${TCL_PREFIX}
 
2805
        else
 
2806
            prefix=/usr/local
 
2807
        fi
 
2808
    fi
 
2809
    if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" ; then
 
2810
        if test x"${TCL_EXEC_PREFIX}" != x; then
 
2811
            AC_MSG_WARN([--exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}])
 
2812
            exec_prefix=${TCL_EXEC_PREFIX}
 
2813
        else
 
2814
            exec_prefix=$prefix
 
2815
        fi
 
2816
    fi
 
2817
])
 
2818
 
 
2819
#------------------------------------------------------------------------
 
2820
# TEA_SETUP_COMPILER_CC --
 
2821
#
 
2822
#       Do compiler checks the way we want.  This is just a replacement
 
2823
#       for AC_PROG_CC in TEA configure.in files to make them cleaner.
 
2824
#
 
2825
# Arguments:
 
2826
#       none
 
2827
#
 
2828
# Results:
 
2829
#
 
2830
#       Sets up CC var and other standard bits we need to make executables.
 
2831
#------------------------------------------------------------------------
 
2832
AC_DEFUN(TEA_SETUP_COMPILER_CC, [
 
2833
    # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE)
 
2834
    # in this macro, they need to go into TEA_SETUP_COMPILER instead.
 
2835
 
 
2836
    # If the user did not set CFLAGS, set it now to keep
 
2837
    # the AC_PROG_CC macro from adding "-g -O2".
 
2838
    if test "${CFLAGS+set}" != "set" ; then
 
2839
        CFLAGS=""
 
2840
    fi
 
2841
 
 
2842
    AC_PROG_CC
 
2843
    AC_PROG_CPP
 
2844
 
 
2845
    AC_PROG_INSTALL
 
2846
 
 
2847
    #--------------------------------------------------------------------
 
2848
    # Checks to see if the make program sets the $MAKE variable.
 
2849
    #--------------------------------------------------------------------
 
2850
 
 
2851
    AC_PROG_MAKE_SET
 
2852
 
 
2853
    #--------------------------------------------------------------------
 
2854
    # Find ranlib
 
2855
    #--------------------------------------------------------------------
 
2856
 
 
2857
    AC_PROG_RANLIB
 
2858
 
 
2859
    #--------------------------------------------------------------------
 
2860
    # Determines the correct binary file extension (.o, .obj, .exe etc.)
 
2861
    #--------------------------------------------------------------------
 
2862
 
 
2863
    AC_OBJEXT
 
2864
    AC_EXEEXT
 
2865
])
 
2866
 
 
2867
#------------------------------------------------------------------------
 
2868
# TEA_SETUP_COMPILER --
 
2869
#
 
2870
#       Do compiler checks that use the compiler.  This must go after
 
2871
#       TEA_SETUP_COMPILER_CC, which does the actual compiler check.
 
2872
#
 
2873
# Arguments:
 
2874
#       none
 
2875
#
 
2876
# Results:
 
2877
#
 
2878
#       Sets up CC var and other standard bits we need to make executables.
 
2879
#------------------------------------------------------------------------
 
2880
AC_DEFUN(TEA_SETUP_COMPILER, [
 
2881
    # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here.
 
2882
    AC_REQUIRE([TEA_SETUP_COMPILER_CC])
 
2883
 
 
2884
    #------------------------------------------------------------------------
 
2885
    # If we're using GCC, see if the compiler understands -pipe. If so, use it.
 
2886
    # It makes compiling go faster.  (This is only a performance feature.)
 
2887
    #------------------------------------------------------------------------
 
2888
 
 
2889
    if test -z "$no_pipe" -a -n "$GCC"; then
 
2890
        AC_MSG_CHECKING([if the compiler understands -pipe])
 
2891
        OLDCC="$CC"
 
2892
        CC="$CC -pipe"
 
2893
        AC_TRY_COMPILE(,, AC_MSG_RESULT([yes]), CC="$OLDCC"
 
2894
            AC_MSG_RESULT([no]))
 
2895
    fi
 
2896
 
 
2897
    #--------------------------------------------------------------------
 
2898
    # Common compiler flag setup
 
2899
    #--------------------------------------------------------------------
 
2900
 
 
2901
    TEA_TCL_EARLY_FLAGS
 
2902
    TEA_TCL_64BIT_FLAGS
 
2903
    AC_C_BIGENDIAN
 
2904
    if test "${TEA_PLATFORM}" = "unix" ; then
 
2905
        TEA_TCL_LINK_LIBS
 
2906
        TEA_MISSING_POSIX_HEADERS
 
2907
        # Let the user call this, because if it triggers, they will
 
2908
        # need a compat/strtod.c that is correct.  Users can also
 
2909
        # use Tcl_GetDouble(FromObj) instead.
 
2910
        #TEA_BUGGY_STRTOD
 
2911
    fi
 
2912
])
 
2913
 
 
2914
#------------------------------------------------------------------------
 
2915
# TEA_MAKE_LIB --
 
2916
#
 
2917
#       Generate a line that can be used to build a shared/unshared library
 
2918
#       in a platform independent manner.
 
2919
#
 
2920
# Arguments:
 
2921
#       none
 
2922
#
 
2923
#       Requires:
 
2924
#
 
2925
# Results:
 
2926
#
 
2927
#       Defines the following vars:
 
2928
#       CFLAGS -        Done late here to note disturb other AC macros
 
2929
#       MAKE_LIB -      Command to execute to build the Tcl library;
 
2930
#                       differs depending on whether or not Tcl is being
 
2931
#                       compiled as a shared library.
 
2932
#       MAKE_SHARED_LIB Makefile rule for building a shared library
 
2933
#       MAKE_STATIC_LIB Makefile rule for building a static library
 
2934
#       MAKE_STUB_LIB   Makefile rule for building a stub library
 
2935
#------------------------------------------------------------------------
 
2936
 
 
2937
AC_DEFUN(TEA_MAKE_LIB, [
 
2938
    if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then
 
2939
        MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_OBJECTS)"
 
2940
        MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_FLAGS} \${SHLIB_LD_LIBS} \$(LDFLAGS) -out:\[$]@ \$(PKG_OBJECTS)"
 
2941
        MAKE_STUB_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_STUB_OBJECTS)"
 
2942
    else
 
2943
        MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(PKG_OBJECTS)"
 
2944
        MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_FLAGS} \${SHLIB_LD_LIBS}"
 
2945
        MAKE_STUB_LIB="\${STLIB_LD} \[$]@ \$(PKG_STUB_OBJECTS)"
 
2946
    fi
 
2947
 
 
2948
    if test "${SHARED_BUILD}" = "1" ; then
 
2949
        MAKE_LIB="${MAKE_SHARED_LIB} "
 
2950
    else
 
2951
        MAKE_LIB="${MAKE_STATIC_LIB} "
 
2952
    fi
 
2953
 
 
2954
    #--------------------------------------------------------------------
 
2955
    # Shared libraries and static libraries have different names.
 
2956
    # Use the double eval to make sure the ${DBGX} in the suffix is
 
2957
    # substituted.
 
2958
    #--------------------------------------------------------------------
 
2959
 
 
2960
    RANLIB_STUB="${RANLIB}"
 
2961
    if test "${TEA_PLATFORM}" = "windows" ; then
 
2962
        if test "${SHARED_BUILD}" = "1" ; then
 
2963
            # We force the unresolved linking of symbols that are really in
 
2964
            # the private libraries of Tcl and Tk.
 
2965
            SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\""
 
2966
            if test x"${TK_BIN_DIR}" != x ; then
 
2967
                SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\""
 
2968
            fi
 
2969
            eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
 
2970
            RANLIB=:
 
2971
        else
 
2972
            eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
 
2973
        fi
 
2974
        # Some packages build there own stubs libraries
 
2975
        eval eval "PKG_STUB_LIB_FILE=${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
 
2976
    else
 
2977
        if test "${SHARED_BUILD}" = "1" ; then
 
2978
            SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}"
 
2979
            if test x"${TK_BIN_DIR}" != x ; then
 
2980
                SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}"
 
2981
            fi
 
2982
            eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
 
2983
            RANLIB=:
 
2984
        else
 
2985
            eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
 
2986
        fi
 
2987
        # Some packages build there own stubs libraries
 
2988
        eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
 
2989
    fi
 
2990
 
 
2991
    # These are escaped so that only CFLAGS is picked up at configure time.
 
2992
    # The other values will be substituted at make time.
 
2993
    CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}"
 
2994
    if test "${SHARED_BUILD}" = "1" ; then
 
2995
        CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}"
 
2996
    fi
 
2997
 
 
2998
    AC_SUBST(MAKE_LIB)
 
2999
    AC_SUBST(MAKE_SHARED_LIB)
 
3000
    AC_SUBST(MAKE_STATIC_LIB)
 
3001
    AC_SUBST(MAKE_STUB_LIB)
 
3002
    AC_SUBST(RANLIB_STUB)
 
3003
])
 
3004
 
 
3005
#------------------------------------------------------------------------
 
3006
# TEA_LIB_SPEC --
 
3007
#
 
3008
#       Compute the name of an existing object library located in libdir
 
3009
#       from the given base name and produce the appropriate linker flags.
 
3010
#
 
3011
# Arguments:
 
3012
#       basename        The base name of the library without version
 
3013
#                       numbers, extensions, or "lib" prefixes.
 
3014
#       extra_dir       Extra directory in which to search for the
 
3015
#                       library.  This location is used first, then
 
3016
#                       $prefix/$exec-prefix, then some defaults.
 
3017
#
 
3018
# Requires:
 
3019
#       TEA_INIT and TEA_PREFIX must be called first.
 
3020
#
 
3021
# Results:
 
3022
#
 
3023
#       Defines the following vars:
 
3024
#               ${basename}_LIB_NAME    The computed library name.
 
3025
#               ${basename}_LIB_SPEC    The computed linker flags.
 
3026
#------------------------------------------------------------------------
 
3027
 
 
3028
AC_DEFUN(TEA_LIB_SPEC, [
 
3029
    AC_MSG_CHECKING([for $1 library])
 
3030
 
 
3031
    # Look in exec-prefix for the library (defined by TEA_PREFIX).
 
3032
 
 
3033
    tea_lib_name_dir="${exec_prefix}/lib"
 
3034
 
 
3035
    # Or in a user-specified location.
 
3036
 
 
3037
    if test x"$2" != x ; then
 
3038
        tea_extra_lib_dir=$2
 
3039
    else
 
3040
        tea_extra_lib_dir=NONE
 
3041
    fi
 
3042
 
 
3043
    for i in \
 
3044
            `ls -dr ${tea_extra_lib_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
 
3045
            `ls -dr ${tea_extra_lib_dir}/lib$1[[0-9]]* 2>/dev/null ` \
 
3046
            `ls -dr ${tea_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
 
3047
            `ls -dr ${tea_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
 
3048
            `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
 
3049
            `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
 
3050
            `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
 
3051
            `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
 
3052
        if test -f "$i" ; then
 
3053
            tea_lib_name_dir=`dirname $i`
 
3054
            $1_LIB_NAME=`basename $i`
 
3055
            $1_LIB_PATH_NAME=$i
 
3056
            break
 
3057
        fi
 
3058
    done
 
3059
 
 
3060
    if test "${TEA_PLATFORM}" = "windows"; then
 
3061
        $1_LIB_SPEC=\"`${CYGPATH} ${$1_LIB_PATH_NAME} 2>/dev/null`\"
 
3062
    else
 
3063
        # Strip off the leading "lib" and trailing ".a" or ".so"
 
3064
 
 
3065
        tea_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//' -e 's/\.so.*//'`
 
3066
        $1_LIB_SPEC="-L${tea_lib_name_dir} -l${tea_lib_name_lib}"
 
3067
    fi
 
3068
 
 
3069
    if test "x${$1_LIB_NAME}" = x ; then
 
3070
        AC_MSG_ERROR([not found])
 
3071
    else
 
3072
        AC_MSG_RESULT([${$1_LIB_SPEC}])
 
3073
    fi
 
3074
])
 
3075
 
 
3076
#------------------------------------------------------------------------
 
3077
# TEA_PRIVATE_TCL_HEADERS --
 
3078
#
 
3079
#       Locate the private Tcl include files
 
3080
#
 
3081
# Arguments:
 
3082
#
 
3083
#       Requires:
 
3084
#               TCL_SRC_DIR     Assumes that TEA_LOAD_TCLCONFIG has
 
3085
#                                already been called.
 
3086
#
 
3087
# Results:
 
3088
#
 
3089
#       Substs the following vars:
 
3090
#               TCL_TOP_DIR_NATIVE
 
3091
#               TCL_GENERIC_DIR_NATIVE
 
3092
#               TCL_UNIX_DIR_NATIVE
 
3093
#               TCL_WIN_DIR_NATIVE
 
3094
#               TCL_BMAP_DIR_NATIVE
 
3095
#               TCL_TOOL_DIR_NATIVE
 
3096
#               TCL_PLATFORM_DIR_NATIVE
 
3097
#               TCL_BIN_DIR_NATIVE
 
3098
#               TCL_INCLUDES
 
3099
#------------------------------------------------------------------------
 
3100
 
 
3101
AC_DEFUN(TEA_PRIVATE_TCL_HEADERS, [
 
3102
    AC_MSG_CHECKING([for Tcl private include files])
 
3103
 
 
3104
    if test "${TEA_PLATFORM}" = "windows"; then
 
3105
        TCL_TOP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}`\"
 
3106
        TCL_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/generic`\"
 
3107
        TCL_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/unix`\"
 
3108
        TCL_WIN_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/win`\"
 
3109
        TCL_BMAP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/bitmaps`\"
 
3110
        TCL_TOOL_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/tools`\"
 
3111
        TCL_COMPAT_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/compat`\"
 
3112
        TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
 
3113
    else
 
3114
        TCL_TOP_DIR_NATIVE='$(TCL_SRC_DIR)'
 
3115
        TCL_GENERIC_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/generic'
 
3116
        TCL_UNIX_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/unix'
 
3117
        TCL_WIN_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/win'
 
3118
        TCL_BMAP_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/bitmaps'
 
3119
        TCL_TOOL_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/tools'
 
3120
        TCL_COMPAT_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/compat'
 
3121
        TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
 
3122
    fi
 
3123
 
 
3124
    AC_SUBST(TCL_TOP_DIR_NATIVE)
 
3125
    AC_SUBST(TCL_GENERIC_DIR_NATIVE)
 
3126
    AC_SUBST(TCL_UNIX_DIR_NATIVE)
 
3127
    AC_SUBST(TCL_WIN_DIR_NATIVE)
 
3128
    AC_SUBST(TCL_BMAP_DIR_NATIVE)
 
3129
    AC_SUBST(TCL_TOOL_DIR_NATIVE)
 
3130
    AC_SUBST(TCL_PLATFORM_DIR_NATIVE)
 
3131
 
 
3132
    TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
 
3133
    AC_SUBST(TCL_INCLUDES)
 
3134
    AC_MSG_RESULT([Using srcdir found in tclConfig.sh: ${TCL_SRC_DIR}])
 
3135
])
 
3136
 
 
3137
#------------------------------------------------------------------------
 
3138
# TEA_PUBLIC_TCL_HEADERS --
 
3139
#
 
3140
#       Locate the installed public Tcl header files
 
3141
#
 
3142
# Arguments:
 
3143
#       None.
 
3144
#
 
3145
# Requires:
 
3146
#       CYGPATH must be set
 
3147
#
 
3148
# Results:
 
3149
#
 
3150
#       Adds a --with-tclinclude switch to configure.
 
3151
#       Result is cached.
 
3152
#
 
3153
#       Substs the following vars:
 
3154
#               TCL_INCLUDES
 
3155
#------------------------------------------------------------------------
 
3156
 
 
3157
AC_DEFUN(TEA_PUBLIC_TCL_HEADERS, [
 
3158
    AC_MSG_CHECKING([for Tcl public headers])
 
3159
 
 
3160
    AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory containing the public Tcl header files], with_tclinclude=${withval})
 
3161
 
 
3162
    AC_CACHE_VAL(ac_cv_c_tclh, [
 
3163
        # Use the value from --with-tclinclude, if it was given
 
3164
 
 
3165
        if test x"${with_tclinclude}" != x ; then
 
3166
            if test -f "${with_tclinclude}/tcl.h" ; then
 
3167
                ac_cv_c_tclh=${with_tclinclude}
 
3168
            else
 
3169
                AC_MSG_ERROR([${with_tclinclude} directory does not contain tcl.h])
 
3170
            fi
 
3171
        else
 
3172
            # Check order: pkg --prefix location, Tcl's --prefix location,
 
3173
            # directory of tclConfig.sh, and Tcl source directory.
 
3174
            # Looking in the source dir is not ideal, but OK.
 
3175
 
 
3176
            eval "temp_includedir=${includedir}"
 
3177
            list="`ls -d ${temp_includedir}      2>/dev/null` \
 
3178
                `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
 
3179
                `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null` \
 
3180
                `ls -d ${TCL_SRC_DIR}/generic    2>/dev/null`"
 
3181
            if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
 
3182
                list="$list /usr/local/include /usr/include"
 
3183
            fi
 
3184
            for i in $list ; do
 
3185
                if test -f "$i/tcl.h" ; then
 
3186
                    ac_cv_c_tclh=$i
 
3187
                    break
 
3188
                fi
 
3189
            done
 
3190
        fi
 
3191
    ])
 
3192
 
 
3193
    # Print a message based on how we determined the include path
 
3194
 
 
3195
    if test x"${ac_cv_c_tclh}" = x ; then
 
3196
        AC_MSG_ERROR([tcl.h not found.  Please specify its location with --with-tclinclude])
 
3197
    else
 
3198
        AC_MSG_RESULT([${ac_cv_c_tclh}])
 
3199
    fi
 
3200
 
 
3201
    # Convert to a native path and substitute into the output files.
 
3202
 
 
3203
    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
 
3204
 
 
3205
    TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
 
3206
 
 
3207
    AC_SUBST(TCL_INCLUDES)
 
3208
])
 
3209
 
 
3210
#------------------------------------------------------------------------
 
3211
# TEA_PRIVATE_TK_HEADERS --
 
3212
#
 
3213
#       Locate the private Tk include files
 
3214
#
 
3215
# Arguments:
 
3216
#
 
3217
#       Requires:
 
3218
#               TK_SRC_DIR      Assumes that TEA_LOAD_TKCONFIG has
 
3219
#                                already been called.
 
3220
#
 
3221
# Results:
 
3222
#
 
3223
#       Substs the following vars:
 
3224
#               TK_INCLUDES
 
3225
#------------------------------------------------------------------------
 
3226
 
 
3227
AC_DEFUN(TEA_PRIVATE_TK_HEADERS, [
 
3228
    AC_MSG_CHECKING([for Tk private include files])
 
3229
 
 
3230
    if test "${TEA_PLATFORM}" = "windows"; then
 
3231
        TK_TOP_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}`\"
 
3232
        TK_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/unix`\"
 
3233
        TK_WIN_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/win`\"
 
3234
        TK_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/generic`\"
 
3235
        TK_XLIB_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/xlib`\"
 
3236
        TK_PLATFORM_DIR_NATIVE=${TK_WIN_DIR_NATIVE}
 
3237
 
 
3238
        TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE} -I${TK_XLIB_DIR_NATIVE}"
 
3239
    else
 
3240
        TK_TOP_DIR_NATIVE='$(TK_SRC_DIR)'
 
3241
        TK_GENERIC_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/generic'
 
3242
        TK_UNIX_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/unix'
 
3243
        TK_WIN_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/win'
 
3244
        TK_PLATFORM_DIR_NATIVE=${TK_UNIX_DIR_NATIVE}
 
3245
 
 
3246
        TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
 
3247
    fi
 
3248
 
 
3249
    AC_SUBST(TK_TOP_DIR_NATIVE)
 
3250
    AC_SUBST(TK_UNIX_DIR_NATIVE)
 
3251
    AC_SUBST(TK_WIN_DIR_NATIVE)
 
3252
    AC_SUBST(TK_GENERIC_DIR_NATIVE)
 
3253
    AC_SUBST(TK_XLIB_DIR_NATIVE)
 
3254
    AC_SUBST(TK_PLATFORM_DIR_NATIVE)
 
3255
 
 
3256
    AC_SUBST(TK_INCLUDES)
 
3257
    AC_MSG_RESULT([Using srcdir found in tkConfig.sh: ${TK_SRC_DIR}])
 
3258
])
 
3259
 
 
3260
#------------------------------------------------------------------------
 
3261
# TEA_PUBLIC_TK_HEADERS --
 
3262
#
 
3263
#       Locate the installed public Tk header files
 
3264
#
 
3265
# Arguments:
 
3266
#       None.
 
3267
#
 
3268
# Requires:
 
3269
#       CYGPATH must be set
 
3270
#
 
3271
# Results:
 
3272
#
 
3273
#       Adds a --with-tkinclude switch to configure.
 
3274
#       Result is cached.
 
3275
#
 
3276
#       Substs the following vars:
 
3277
#               TK_INCLUDES
 
3278
#------------------------------------------------------------------------
 
3279
 
 
3280
AC_DEFUN(TEA_PUBLIC_TK_HEADERS, [
 
3281
    AC_MSG_CHECKING([for Tk public headers])
 
3282
 
 
3283
    AC_ARG_WITH(tkinclude, [  --with-tkinclude      directory containing the public Tk header files.], with_tkinclude=${withval})
 
3284
 
 
3285
    AC_CACHE_VAL(ac_cv_c_tkh, [
 
3286
        # Use the value from --with-tkinclude, if it was given
 
3287
 
 
3288
        if test x"${with_tkinclude}" != x ; then
 
3289
            if test -f "${with_tkinclude}/tk.h" ; then
 
3290
                ac_cv_c_tkh=${with_tkinclude}
 
3291
            else
 
3292
                AC_MSG_ERROR([${with_tkinclude} directory does not contain tk.h])
 
3293
            fi
 
3294
        else
 
3295
            # Check order: pkg --prefix location, Tcl's --prefix location,
 
3296
            # directory of tclConfig.sh, and Tcl source directory.
 
3297
            # Looking in the source dir is not ideal, but OK.
 
3298
 
 
3299
            eval "temp_includedir=${includedir}"
 
3300
            list="`ls -d ${temp_includedir}      2>/dev/null` \
 
3301
                `ls -d ${TK_PREFIX}/include      2>/dev/null` \
 
3302
                `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
 
3303
                `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null` \
 
3304
                `ls -d ${TK_SRC_DIR}/generic     2>/dev/null`"
 
3305
            if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
 
3306
                list="$list /usr/local/include /usr/include"
 
3307
            fi
 
3308
            for i in $list ; do
 
3309
                if test -f "$i/tk.h" ; then
 
3310
                    ac_cv_c_tkh=$i
 
3311
                    break
 
3312
                fi
 
3313
            done
 
3314
        fi
 
3315
    ])
 
3316
 
 
3317
    # Print a message based on how we determined the include path
 
3318
 
 
3319
    if test x"${ac_cv_c_tkh}" = x ; then
 
3320
        AC_MSG_ERROR([tk.h not found.  Please specify its location with --with-tkinclude])
 
3321
    else
 
3322
        AC_MSG_RESULT([${ac_cv_c_tkh}])
 
3323
    fi
 
3324
 
 
3325
    # Convert to a native path and substitute into the output files.
 
3326
 
 
3327
    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}`
 
3328
 
 
3329
    TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
 
3330
 
 
3331
    AC_SUBST(TK_INCLUDES)
 
3332
 
 
3333
    if test "${TEA_PLATFORM}" = "windows" ; then
 
3334
        # On Windows, we need the X compat headers
 
3335
        AC_MSG_CHECKING([for X11 header files])
 
3336
        if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then
 
3337
            INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`"
 
3338
            TK_XINCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
 
3339
            AC_SUBST(TK_XINCLUDES)
 
3340
        fi
 
3341
        AC_MSG_RESULT([${INCLUDE_DIR_NATIVE}])
 
3342
    fi
 
3343
])
 
3344
 
 
3345
#------------------------------------------------------------------------
 
3346
# TEA_PROG_TCLSH
 
3347
#       Locate a tclsh shell in the following directories:
 
3348
#               ${TCL_BIN_DIR}          ${TCL_BIN_DIR}/../bin
 
3349
#               ${exec_prefix}/bin      ${prefix}/bin
 
3350
#               ${PATH}
 
3351
#
 
3352
# Arguments
 
3353
#       none
 
3354
#
 
3355
# Results
 
3356
#       Subst's the following values:
 
3357
#               TCLSH_PROG
 
3358
#------------------------------------------------------------------------
 
3359
 
 
3360
AC_DEFUN(TEA_PROG_TCLSH, [
 
3361
    AC_MSG_CHECKING([for tclsh])
 
3362
 
 
3363
    AC_CACHE_VAL(ac_cv_path_tclsh, [
 
3364
        if test "x${CELIB_DIR}" != "x" ; then
 
3365
            # If CELIB_DIR is defined, assume Windows/CE target is requested
 
3366
            # which means target tclsh cannot be run (cross-compile)
 
3367
            search_path=`echo ${PATH} | sed -e 's/:/ /g'`
 
3368
        else
 
3369
            search_path=`echo ${TCL_BIN_DIR}:${TCL_BIN_DIR}/../bin:${exec_prefix}/bin:${prefix}/bin:${PATH} | sed -e 's/:/ /g'`
 
3370
        fi
 
3371
        for dir in $search_path ; do
 
3372
            for j in `ls -r $dir/tclsh[[8-9]]*${EXEEXT} 2> /dev/null` \
 
3373
                    `ls -r $dir/tclsh*${EXEEXT} 2> /dev/null` ; do
 
3374
                if test x"$ac_cv_path_tclsh" = x ; then
 
3375
                    if test -f "$j" ; then
 
3376
                        ac_cv_path_tclsh=$j
 
3377
                        break
 
3378
                    fi
 
3379
                fi
 
3380
            done
 
3381
        done
 
3382
    ])
 
3383
 
 
3384
    if test -f "$ac_cv_path_tclsh" ; then
 
3385
        TCLSH_PROG=$ac_cv_path_tclsh
 
3386
        AC_MSG_RESULT([$TCLSH_PROG])
 
3387
    else
 
3388
        AC_MSG_ERROR([No tclsh found in PATH:  $search_path])
 
3389
    fi
 
3390
    AC_SUBST(TCLSH_PROG)
 
3391
])
 
3392
 
 
3393
#------------------------------------------------------------------------
 
3394
# TEA_PROG_WISH
 
3395
#       Locate a wish shell in the following directories:
 
3396
#               ${TK_BIN_DIR}           ${TK_BIN_DIR}/../bin
 
3397
#               ${TCL_BIN_DIR}          ${TCL_BIN_DIR}/../bin
 
3398
#               ${exec_prefix}/bin      ${prefix}/bin
 
3399
#               ${PATH}
 
3400
#
 
3401
# Arguments
 
3402
#       none
 
3403
#
 
3404
# Results
 
3405
#       Subst's the following values:
 
3406
#               WISH_PROG
 
3407
#------------------------------------------------------------------------
 
3408
 
 
3409
AC_DEFUN(TEA_PROG_WISH, [
 
3410
    AC_MSG_CHECKING([for wish])
 
3411
 
 
3412
    AC_CACHE_VAL(ac_cv_path_wish, [
 
3413
        if test "x${CELIB_DIR}" != "x" ; then
 
3414
            # If CELIB_DIR is defined, assume Windows/CE target is requested
 
3415
            # which means target wish cannot be run (cross-compile)
 
3416
            search_path=`echo ${PATH} | sed -e 's/:/ /g'`
 
3417
        else
 
3418
            search_path=`echo ${TK_BIN_DIR}:${TK_BIN_DIR}/../bin:${TCL_BIN_DIR}:${TCL_BIN_DIR}/../bin:${exec_prefix}/bin:${prefix}/bin:${PATH} | sed -e 's/:/ /g'`
 
3419
        fi
 
3420
        for dir in $search_path ; do
 
3421
            for j in `ls -r $dir/wish[[8-9]]*${EXEEXT} 2> /dev/null` \
 
3422
                    `ls -r $dir/wish*${EXEEXT} 2> /dev/null` ; do
 
3423
                if test x"$ac_cv_path_wish" = x ; then
 
3424
                    if test -f "$j" ; then
 
3425
                        ac_cv_path_wish=$j
 
3426
                        break
 
3427
                    fi
 
3428
                fi
 
3429
            done
 
3430
        done
 
3431
    ])
 
3432
 
 
3433
    if test -f "$ac_cv_path_wish" ; then
 
3434
        WISH_PROG=$ac_cv_path_wish
 
3435
        AC_MSG_RESULT([$WISH_PROG])
 
3436
    else
 
3437
        AC_MSG_ERROR([No wish found in PATH:  $search_path])
 
3438
    fi
 
3439
    AC_SUBST(WISH_PROG)
 
3440
])
 
3441
 
 
3442
#------------------------------------------------------------------------
 
3443
# TEA_PATH_CONFIG --
 
3444
#
 
3445
#       Locate the ${1}Config.sh file and perform a sanity check on
 
3446
#       the ${1} compile flags.  These are used by packages like
 
3447
#       [incr Tk] that load *Config.sh files from more than Tcl and Tk.
 
3448
#
 
3449
# Arguments:
 
3450
#       none
 
3451
#
 
3452
# Results:
 
3453
#
 
3454
#       Adds the following arguments to configure:
 
3455
#               --with-$1=...
 
3456
#
 
3457
#       Defines the following vars:
 
3458
#               $1_BIN_DIR      Full path to the directory containing
 
3459
#                               the $1Config.sh file
 
3460
#------------------------------------------------------------------------
 
3461
 
 
3462
AC_DEFUN(TEA_PATH_CONFIG, [
 
3463
    #
 
3464
    # Ok, lets find the $1 configuration
 
3465
    # First, look for one uninstalled.
 
3466
    # the alternative search directory is invoked by --with-$1
 
3467
    #
 
3468
 
 
3469
    if test x"${no_$1}" = x ; then
 
3470
        # we reset no_$1 in case something fails here
 
3471
        no_$1=true
 
3472
        AC_ARG_WITH($1, [  --with-$1              directory containing $1 configuration ($1Config.sh)], with_$1config=${withval})
 
3473
        AC_MSG_CHECKING([for $1 configuration])
 
3474
        AC_CACHE_VAL(ac_cv_c_$1config,[
 
3475
 
 
3476
            # First check to see if --with-$1 was specified.
 
3477
            if test x"${with_$1config}" != x ; then
 
3478
                if test -f "${with_$1config}/$1Config.sh" ; then
 
3479
                    ac_cv_c_$1config=`(cd ${with_$1config}; pwd)`
 
3480
                else
 
3481
                    AC_MSG_ERROR([${with_$1config} directory doesn't contain $1Config.sh])
 
3482
                fi
 
3483
            fi
 
3484
 
 
3485
            # then check for a private $1 installation
 
3486
            if test x"${ac_cv_c_$1config}" = x ; then
 
3487
                for i in \
 
3488
                        ../$1 \
 
3489
                        `ls -dr ../$1[[8-9]].[[0-9]]* 2>/dev/null` \
 
3490
                        ../../$1 \
 
3491
                        `ls -dr ../../$1[[8-9]].[[0-9]]* 2>/dev/null` \
 
3492
                        ../../../$1 \
 
3493
                        `ls -dr ../../../$1[[8-9]].[[0-9]]* 2>/dev/null` \
 
3494
                        ${srcdir}/../$1 \
 
3495
                        `ls -dr ${srcdir}/../$1[[8-9]].[[0-9]]* 2>/dev/null` \
 
3496
                        ; do
 
3497
                    if test -f "$i/$1Config.sh" ; then
 
3498
                        ac_cv_c_$1config=`(cd $i; pwd)`
 
3499
                        break
 
3500
                    fi
 
3501
                    if test -f "$i/unix/$1Config.sh" ; then
 
3502
                        ac_cv_c_$1config=`(cd $i/unix; pwd)`
 
3503
                        break
 
3504
                    fi
 
3505
                done
 
3506
            fi
 
3507
 
 
3508
            # check in a few common install locations
 
3509
            if test x"${ac_cv_c_$1config}" = x ; then
 
3510
                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
 
3511
                        `ls -d ${prefix}/lib 2>/dev/null` \
 
3512
                        `ls -d /usr/local/lib 2>/dev/null` \
 
3513
                        `ls -d /usr/contrib/lib 2>/dev/null` \
 
3514
                        `ls -d /usr/lib 2>/dev/null` \
 
3515
                        ; do
 
3516
                    if test -f "$i/$1Config.sh" ; then
 
3517
                        ac_cv_c_$1config=`(cd $i; pwd)`
 
3518
                        break
 
3519
                    fi
 
3520
                done
 
3521
            fi
 
3522
        ])
 
3523
 
 
3524
        if test x"${ac_cv_c_$1config}" = x ; then
 
3525
            $1_BIN_DIR="# no $1 configs found"
 
3526
            AC_MSG_WARN("Cannot find $1 configuration definitions")
 
3527
            exit 0
 
3528
        else
 
3529
            no_$1=
 
3530
            $1_BIN_DIR=${ac_cv_c_$1config}
 
3531
            AC_MSG_RESULT([found $$1_BIN_DIR/$1Config.sh])
 
3532
        fi
 
3533
    fi
 
3534
])
 
3535
 
 
3536
#------------------------------------------------------------------------
 
3537
# TEA_LOAD_CONFIG --
 
3538
#
 
3539
#       Load the $1Config.sh file
 
3540
#
 
3541
# Arguments:
 
3542
#       
 
3543
#       Requires the following vars to be set:
 
3544
#               $1_BIN_DIR
 
3545
#
 
3546
# Results:
 
3547
#
 
3548
#       Subst the following vars:
 
3549
#               $1_SRC_DIR
 
3550
#               $1_LIB_FILE
 
3551
#               $1_LIB_SPEC
 
3552
#
 
3553
#------------------------------------------------------------------------
 
3554
 
 
3555
AC_DEFUN(TEA_LOAD_CONFIG, [
 
3556
    AC_MSG_CHECKING([for existence of ${$1_BIN_DIR}/$1Config.sh])
 
3557
 
 
3558
    if test -f "${$1_BIN_DIR}/$1Config.sh" ; then
 
3559
        AC_MSG_RESULT([loading])
 
3560
        . ${$1_BIN_DIR}/$1Config.sh
 
3561
    else
 
3562
        AC_MSG_RESULT([file not found])
 
3563
    fi
 
3564
 
 
3565
    #
 
3566
    # If the $1_BIN_DIR is the build directory (not the install directory),
 
3567
    # then set the common variable name to the value of the build variables.
 
3568
    # For example, the variable $1_LIB_SPEC will be set to the value
 
3569
    # of $1_BUILD_LIB_SPEC. An extension should make use of $1_LIB_SPEC
 
3570
    # instead of $1_BUILD_LIB_SPEC since it will work with both an
 
3571
    # installed and uninstalled version of Tcl.
 
3572
    #
 
3573
 
 
3574
    if test -f ${$1_BIN_DIR}/Makefile ; then
 
3575
        AC_MSG_WARN([Found Makefile - using build library specs for $1])
 
3576
        $1_LIB_SPEC=${$1_BUILD_LIB_SPEC}
 
3577
        $1_STUB_LIB_SPEC=${$1_BUILD_STUB_LIB_SPEC}
 
3578
        $1_STUB_LIB_PATH=${$1_BUILD_STUB_LIB_PATH}
 
3579
    fi
 
3580
 
 
3581
    AC_SUBST($1_VERSION)
 
3582
    AC_SUBST($1_SRC_DIR)
 
3583
 
 
3584
    AC_SUBST($1_LIB_FILE)
 
3585
    AC_SUBST($1_LIB_SPEC)
 
3586
 
 
3587
    AC_SUBST($1_STUB_LIB_FILE)
 
3588
    AC_SUBST($1_STUB_LIB_SPEC)
 
3589
    AC_SUBST($1_STUB_LIB_PATH)
 
3590
])
 
3591
 
 
3592
#------------------------------------------------------------------------
 
3593
# TEA_PATH_CELIB --
 
3594
#
 
3595
#       Locate Keuchel's celib emulation layer for targeting Win/CE
 
3596
#
 
3597
# Arguments:
 
3598
#       none
 
3599
#
 
3600
# Results:
 
3601
#
 
3602
#       Adds the following arguments to configure:
 
3603
#               --with-celib=...
 
3604
#
 
3605
#       Defines the following vars:
 
3606
#               CELIB_DIR       Full path to the directory containing
 
3607
#                               the include and platform lib files
 
3608
#------------------------------------------------------------------------
 
3609
 
 
3610
AC_DEFUN(TEA_PATH_CELIB, [
 
3611
    # First, look for one uninstalled.
 
3612
    # the alternative search directory is invoked by --with-celib
 
3613
 
 
3614
    if test x"${no_celib}" = x ; then
 
3615
        # we reset no_celib in case something fails here
 
3616
        no_celib=true
 
3617
        AC_ARG_WITH(celib,[  --with-celib=DIR        use Windows/CE support library from DIR], with_celibconfig=${withval})
 
3618
        AC_MSG_CHECKING([for Windows/CE celib directory])
 
3619
        AC_CACHE_VAL(ac_cv_c_celibconfig,[
 
3620
            # First check to see if --with-celibconfig was specified.
 
3621
            if test x"${with_celibconfig}" != x ; then
 
3622
                if test -d "${with_celibconfig}/inc" ; then
 
3623
                    ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)`
 
3624
                else
 
3625
                    AC_MSG_ERROR([${with_celibconfig} directory doesn't contain inc directory])
 
3626
                fi
 
3627
            fi
 
3628
 
 
3629
            # then check for a celib library
 
3630
            if test x"${ac_cv_c_celibconfig}" = x ; then
 
3631
                for i in \
 
3632
                        ../celib-palm-3.0 \
 
3633
                        ../celib \
 
3634
                        ../../celib-palm-3.0 \
 
3635
                        ../../celib \
 
3636
                        `ls -dr ../celib-*3.[[0-9]]* 2>/dev/null` \
 
3637
                        ${srcdir}/../celib-palm-3.0 \
 
3638
                        ${srcdir}/../celib \
 
3639
                        `ls -dr ${srcdir}/../celib-*3.[[0-9]]* 2>/dev/null` \
 
3640
                        ; do
 
3641
                    if test -d "$i/inc" ; then
 
3642
                        ac_cv_c_celibconfig=`(cd $i; pwd)`
 
3643
                        break
 
3644
                    fi
 
3645
                done
 
3646
            fi
 
3647
        ])
 
3648
        if test x"${ac_cv_c_celibconfig}" = x ; then
 
3649
            CELIB_DIR="# no Celib configs found"
 
3650
            AC_MSG_ERROR([Cannot find celib support library directory])
 
3651
        else
 
3652
            no_celib=
 
3653
            CELIB_DIR=${ac_cv_c_celibconfig}
 
3654
            AC_MSG_RESULT([found $CELIB_DIR])
 
3655
        fi
 
3656
    fi
 
3657
])