source: trunk/gui/tcl.m4 @ 158

Last change on this file since 158 was 158, checked in by mmc, 19 years ago
  • Fixed installation so that this "gui" part can be installed with standard autoconf techniques: configure, make all, make install The "gui" library is loaded via "package require RapptureGUI"
  • Added C code for Rappture::rlimit, to support limits on CPU time and file sizes. Default limits are 15 mins of CPU and 1MB for each file. These can be overridden in tool.xml by using <tool><limits><cputime> and <tool><limits><filesize>.
  • Added C code for Rappture::rusage, so we can collect resource usage for all child processes. Each Simulation now reports a line of usage to stderr as follows:

MiddlewareTime?: job=# event=simulation start=xxx cputime=xxx ...

  • Fixed Rappture::exec so that it reports proper error messages when rlimits are execeeded.
File size: 54.7 KB
Line 
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 Scriptics Corporation.
7#
8# See the file "license.terms" for information on usage and redistribution
9# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
11#------------------------------------------------------------------------
12# SC_PATH_TCLCONFIG --
13#
14#       Locate the tclConfig.sh file and perform a sanity check on
15#       the Tcl compile flags
16#
17# Arguments:
18#       none
19#
20# Results:
21#
22#       Adds the following arguments to configure:
23#               --with-tcl=...
24#
25#       Defines the following vars:
26#               TCL_BIN_DIR     Full path to the directory containing
27#                               the tclConfig.sh file
28#------------------------------------------------------------------------
29
30AC_DEFUN(SC_PATH_TCLCONFIG, [
31    #
32    # Ok, lets find the tcl configuration
33    # First, look for one uninstalled.
34    # the alternative search directory is invoked by --with-tcl
35    #
36
37    if test x"${no_tcl}" = x ; then
38        # we reset no_tcl in case something fails here
39        no_tcl=true
40        AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
41        AC_MSG_CHECKING([for Tcl configuration])
42        AC_CACHE_VAL(ac_cv_c_tclconfig,[
43
44            # First check to see if --with-tcl was specified.
45            if test x"${with_tclconfig}" != x ; then
46                if test -f "${with_tclconfig}/tclConfig.sh" ; then
47                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
48                else
49                    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
50                fi
51            fi
52
53            # then check for a private Tcl installation
54            if test x"${ac_cv_c_tclconfig}" = x ; then
55                for i in \
56                        ../tcl \
57                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
58                        ../../tcl \
59                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
60                        ../../../tcl \
61                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
62                    if test -f "$i/unix/tclConfig.sh" ; then
63                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
64                        break
65                    fi
66                done
67            fi
68
69            # check in a few common install locations
70            if test x"${ac_cv_c_tclconfig}" = x ; then
71                for i in `ls -d ${prefix}/lib 2>/dev/null` \
72                        `ls -d /usr/local/lib 2>/dev/null` ; do
73                    if test -f "$i/tclConfig.sh" ; then
74                        ac_cv_c_tclconfig=`(cd $i; pwd)`
75                        break
76                    fi
77                done
78            fi
79
80            # check in a few other private locations
81            if test x"${ac_cv_c_tclconfig}" = x ; then
82                for i in \
83                        ${srcdir}/../tcl \
84                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
85                    if test -f "$i/unix/tclConfig.sh" ; then
86                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
87                    break
88                fi
89                done
90            fi
91        ])
92
93        if test x"${ac_cv_c_tclconfig}" = x ; then
94            TCL_BIN_DIR="# no Tcl configs found"
95            AC_MSG_WARN(Can't find Tcl configuration definitions)
96            exit 0
97        else
98            no_tcl=
99            TCL_BIN_DIR=${ac_cv_c_tclconfig}
100            AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
101        fi
102    fi
103])
104
105#------------------------------------------------------------------------
106# SC_PATH_TKCONFIG --
107#
108#       Locate the tkConfig.sh file
109#
110# Arguments:
111#       none
112#
113# Results:
114#
115#       Adds the following arguments to configure:
116#               --with-tk=...
117#
118#       Defines the following vars:
119#               TK_BIN_DIR      Full path to the directory containing
120#                               the tkConfig.sh file
121#------------------------------------------------------------------------
122
123AC_DEFUN(SC_PATH_TKCONFIG, [
124    #
125    # Ok, lets find the tk configuration
126    # First, look for one uninstalled.
127    # the alternative search directory is invoked by --with-tk
128    #
129
130    if test x"${no_tk}" = x ; then
131        # we reset no_tk in case something fails here
132        no_tk=true
133        AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
134        AC_MSG_CHECKING([for Tk configuration])
135        AC_CACHE_VAL(ac_cv_c_tkconfig,[
136
137            # First check to see if --with-tkconfig was specified.
138            if test x"${with_tkconfig}" != x ; then
139                if test -f "${with_tkconfig}/tkConfig.sh" ; then
140                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
141                else
142                    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
143                fi
144            fi
145
146            # then check for a private Tk library
147            if test x"${ac_cv_c_tkconfig}" = x ; then
148                for i in \
149                        ../tk \
150                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
151                        ../../tk \
152                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
153                        ../../../tk \
154                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
155                    if test -f "$i/unix/tkConfig.sh" ; then
156                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
157                        break
158                    fi
159                done
160            fi
161            # check in a few common install locations
162            if test x"${ac_cv_c_tkconfig}" = x ; then
163                for i in `ls -d ${prefix}/lib 2>/dev/null` \
164                        `ls -d /usr/local/lib 2>/dev/null` ; do
165                    if test -f "$i/tkConfig.sh" ; then
166                        ac_cv_c_tkconfig=`(cd $i; pwd)`
167                        break
168                    fi
169                done
170            fi
171            # check in a few other private locations
172            if test x"${ac_cv_c_tkconfig}" = x ; then
173                for i in \
174                        ${srcdir}/../tk \
175                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
176                    if test -f "$i/unix/tkConfig.sh" ; then
177                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
178                        break
179                    fi
180                done
181            fi
182        ])
183        if test x"${ac_cv_c_tkconfig}" = x ; then
184            TK_BIN_DIR="# no Tk configs found"
185            AC_MSG_WARN(Can't find Tk configuration definitions)
186            exit 0
187        else
188            no_tk=
189            TK_BIN_DIR=${ac_cv_c_tkconfig}
190            AC_MSG_RESULT(found $TK_BIN_DIR/tkConfig.sh)
191        fi
192    fi
193
194])
195
196#------------------------------------------------------------------------
197# SC_LOAD_TCLCONFIG --
198#
199#       Load the tclConfig.sh file
200#
201# Arguments:
202#       
203#       Requires the following vars to be set:
204#               TCL_BIN_DIR
205#
206# Results:
207#
208#       Subst the following vars:
209#               TCL_BIN_DIR
210#               TCL_SRC_DIR
211#               TCL_LIB_FILE
212#
213#------------------------------------------------------------------------
214
215AC_DEFUN(SC_LOAD_TCLCONFIG, [
216    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
217
218    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
219        AC_MSG_RESULT([loading])
220        . $TCL_BIN_DIR/tclConfig.sh
221    else
222        AC_MSG_RESULT([file not found])
223    fi
224
225    #
226    # The eval is required to do the TCL_DBGX substitution in the
227    # TCL_LIB_FILE variable
228    #
229
230    eval TCL_LIB_FILE=${TCL_LIB_FILE}
231    eval TCL_LIB_FLAG=${TCL_LIB_FLAG}
232
233    AC_SUBST(TCL_BIN_DIR)
234    AC_SUBST(TCL_SRC_DIR)
235    AC_SUBST(TCL_LIB_FILE)
236    AC_SUBST(TCL_LIBS)
237    AC_SUBST(TCL_DEFS)
238    AC_SUBST(TCL_SHLIB_LD_LIBS)
239    AC_SUBST(TCL_EXTRA_CFLAGS)
240    AC_SUBST(TCL_LD_FLAGS)
241    AC_SUBST(TCL_LIB_FILE)
242    AC_SUBST(TCL_STUB_LIB_FILE)
243    AC_SUBST(TCL_LIB_SPEC)
244    AC_SUBST(TCL_BUILD_LIB_SPEC)
245    AC_SUBST(TCL_STUB_LIB_SPEC)
246    AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
247])
248
249#------------------------------------------------------------------------
250# SC_LOAD_TKCONFIG --
251#
252#       Load the tkConfig.sh file
253#
254# Arguments:
255#       
256#       Requires the following vars to be set:
257#               TK_BIN_DIR
258#
259# Results:
260#
261#       Sets the following vars that should be in tkConfig.sh:
262#               TK_BIN_DIR
263#------------------------------------------------------------------------
264
265AC_DEFUN(SC_LOAD_TKCONFIG, [
266    AC_MSG_CHECKING([for existence of $TCLCONFIG])
267
268    if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
269        AC_MSG_CHECKING([loading $TK_BIN_DIR/tkConfig.sh])
270        . $TK_BIN_DIR/tkConfig.sh
271    else
272        AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
273    fi
274
275    AC_SUBST(TK_BIN_DIR)
276    AC_SUBST(TK_SRC_DIR)
277    AC_SUBST(TK_LIB_FILE)
278])
279
280#------------------------------------------------------------------------
281# SC_ENABLE_GCC --
282#
283#       Allows the use of GCC if available
284#
285# Arguments:
286#       none
287#       
288# Results:
289#
290#       Adds the following arguments to configure:
291#               --enable-gcc
292#
293#       Sets the following vars:
294#               CC      Command to use for the compiler
295#------------------------------------------------------------------------
296
297AC_DEFUN(SC_ENABLE_GCC, [
298    AC_ARG_ENABLE(gcc, [  --enable-gcc            allow use of gcc if available [--disable-gcc]],
299        [ok=$enableval], [ok=no])
300    if test "$ok" = "yes"; then
301        CC=gcc
302    else
303        case "`uname -s`" in
304            *win32* | *WIN32* | *CYGWIN_NT*)
305                CC=cl
306            ;;
307            *)
308                CC=${CC-cc}
309            ;;
310        esac
311    fi
312    AC_PROG_CC
313])
314
315#------------------------------------------------------------------------
316# SC_ENABLE_SHARED --
317#
318#       Allows the building of shared libraries
319#
320# Arguments:
321#       none
322#       
323# Results:
324#
325#       Adds the following arguments to configure:
326#               --enable-shared=yes|no
327#
328#       Defines the following vars:
329#               STATIC_BUILD    Used for building import/export libraries
330#                               on Windows.
331#
332#       Sets the following vars:
333#               SHARED_BUILD    Value of 1 or 0
334#------------------------------------------------------------------------
335
336AC_DEFUN(SC_ENABLE_SHARED, [
337    AC_MSG_CHECKING([how to build libraries])
338    AC_ARG_ENABLE(shared,
339        [  --enable-shared         build and link with shared libraries [--enable-shared]],
340        [tcl_ok=$enableval], [tcl_ok=yes])
341
342    if test "${enable_shared+set}" = set; then
343        enableval="$enable_shared"
344        tcl_ok=$enableval
345    else
346        tcl_ok=yes
347    fi
348
349    if test "$tcl_ok" = "yes" ; then
350        AC_MSG_RESULT([shared])
351        SHARED_BUILD=1
352    else
353        AC_MSG_RESULT([static])
354        SHARED_BUILD=0
355        AC_DEFINE(STATIC_BUILD)
356    fi
357])
358
359#------------------------------------------------------------------------
360# SC_ENABLE_THREADS --
361#
362#       Specify if thread support should be enabled
363#
364# Arguments:
365#       none
366#       
367# Results:
368#
369#       Adds the following arguments to configure:
370#               --enable-threads
371#
372#       Sets the following vars:
373#               THREADS_LIBS    Thread library(s)
374#
375#       Defines the following vars:
376#               TCL_THREADS
377#               _REENTRANT
378#
379#------------------------------------------------------------------------
380
381AC_DEFUN(SC_ENABLE_THREADS, [
382    AC_MSG_CHECKING(for building with threads)
383    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
384        [tcl_ok=$enableval], [tcl_ok=no])
385
386    if test "$tcl_ok" = "yes"; then
387        AC_MSG_RESULT(yes)
388        TCL_THREADS=1
389        AC_DEFINE(TCL_THREADS)
390        AC_DEFINE(_REENTRANT)
391
392        AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
393        if test "$tcl_ok" = "yes"; then
394            # The space is needed
395            THREADS_LIBS=" -lpthread"
396        else
397            TCL_THREADS=0
398            AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")
399        fi
400    else
401        TCL_THREADS=0
402        AC_MSG_RESULT(no (default))
403    fi
404
405])
406
407#------------------------------------------------------------------------
408# SC_ENABLE_SYMBOLS --
409#
410#       Specify if debugging symbols should be used
411#
412# Arguments:
413#       none
414#       
415#       Requires the following vars to be set:
416#               CFLAGS_DEBUG
417#               CFLAGS_OPTIMIZE
418#               LDFLAGS_DEBUG
419#               LDFLAGS_OPTIMIZE
420#       
421# Results:
422#
423#       Adds the following arguments to configure:
424#               --enable-symbols
425#
426#       Defines the following vars:
427#               CFLAGS_DEFAULT  Sets to CFLAGS_DEBUG if true
428#                               Sets to CFLAGS_OPTIMIZE if false
429#               LDFLAGS_DEFAULT Sets to LDFLAGS_DEBUG if true
430#                               Sets to LDFLAGS_OPTIMIZE if false
431#               DBGX            Debug library extension
432#
433#------------------------------------------------------------------------
434
435AC_DEFUN(SC_ENABLE_SYMBOLS, [
436    case "`uname -s`" in
437        *win32* | *WIN32* | *CYGWIN_NT*)
438            tcl_dbgx=d
439        ;;
440        *)
441            tcl_dbgx=g
442        ;;
443    esac
444
445    AC_MSG_CHECKING([for build with symbols])
446    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
447    if test "$tcl_ok" = "yes"; then
448        CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
449        LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
450        DBGX=${tcl_dbgx}
451        TCL_DBGX=${tcl_dbgx}
452        AC_MSG_RESULT([yes])
453    else
454        CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
455        LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
456        DBGX=""
457        TCL_DBGX=""
458        AC_MSG_RESULT([no])
459    fi
460
461    AC_SUBST(TCL_DBGX)
462    AC_SUBST(CFLAGS_DEFAULT)
463    AC_SUBST(LDFLAGS_DEFAULT)
464])
465
466#--------------------------------------------------------------------
467# SC_CONFIG_CFLAGS
468#
469#       Try to determine the proper flags to pass to the compiler
470#       for building shared libraries and other such nonsense.
471#
472# Arguments:
473#       none
474#
475# Results:
476#
477#       Defines the following vars:
478#
479#       DL_OBJS -       Name of the object file that implements dynamic
480#                       loading for Tcl on this system.
481#       DL_LIBS -       Library file(s) to include in tclsh and other base
482#                       applications in order for the "load" command to work.
483#       LDFLAGS -      Flags to pass to the compiler when linking object
484#                       files into an executable application binary such
485#                       as tclsh.
486#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
487#                       that tell the run-time dynamic linker where to look
488#                       for shared libraries such as libtcl.so.  Depends on
489#                       the variable LIB_RUNTIME_DIR in the Makefile.
490#       MAKE_LIB -      Command to execute to build the Tcl library;
491#                       differs depending on whether or not Tcl is being
492#                       compiled as a shared library.
493#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
494#                       of a shared library (may request position-independent
495#                       code, among other things).
496#       SHLIB_LD -      Base command to use for combining object files
497#                       into a shared library.
498#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
499#                       creating shared libraries.  This symbol typically
500#                       goes at the end of the "ld" commands that build
501#                       shared libraries. The value of the symbol is
502#                       "${LIBS}" if all of the dependent libraries should
503#                       be specified when creating a shared library.  If
504#                       dependent libraries should not be specified (as on
505#                       SunOS 4.x, where they cause the link to fail, or in
506#                       general if Tcl and Tk aren't themselves shared
507#                       libraries), then this symbol has an empty string
508#                       as its value.
509#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
510#                       extensions.  An empty string means we don't know how
511#                       to use shared libraries on this platform.
512#       TCL_LIB_FILE -  Name of the file that contains the Tcl library, such
513#                       as libtcl7.8.so or libtcl7.8.a.
514#       TCL_LIB_SUFFIX -Specifies everything that comes after the "libtcl"
515#                       in the shared library name, using the $VERSION variable
516#                       to put the version in the right place.  This is used
517#                       by platforms that need non-standard library names.
518#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
519#                       to have a version after the .so, and ${VERSION}.a
520#                       on AIX, since the Tcl shared library needs to have
521#                       a .a extension whereas shared objects for loadable
522#                       extensions have a .so extension.  Defaults to
523#                       ${VERSION}${SHLIB_SUFFIX}.
524#       TCL_NEEDS_EXP_FILE -
525#                       1 means that an export file is needed to link to a
526#                       shared library.
527#       TCL_EXP_FILE -  The name of the installed export / import file which
528#                       should be used to link to the Tcl shared library.
529#                       Empty if Tcl is unshared.
530#       TCL_BUILD_EXP_FILE -
531#                       The name of the built export / import file which
532#                       should be used to link to the Tcl shared library.
533#                       Empty if Tcl is unshared.
534#       CFLAGS_DEBUG -
535#                       Flags used when running the compiler in debug mode
536#       CFLAGS_OPTIMIZE -
537#                       Flags used when running the compiler in optimize mode
538#
539#       EXTRA_CFLAGS
540#
541#       Subst's the following vars:
542#               DL_LIBS
543#               CFLAGS_DEBUG
544#               CFLAGS_OPTIMIZE
545#--------------------------------------------------------------------
546
547AC_DEFUN(SC_CONFIG_CFLAGS, [
548
549    # Step 0: Enable 64 bit support?
550
551    AC_MSG_CHECKING([if 64bit support is enabled])
552    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support],,enableval="no")
553
554    if test "$enableval" = "yes"; then
555        AC_MSG_RESULT(Will compile with 64bit support)
556        do64bit=yes
557    else
558        do64bit=no
559    fi
560    AC_MSG_RESULT($do64bit)
561 
562    # Step 1: set the variable "system" to hold the name and version number
563    # for the system.  This can usually be done via the "uname" command, but
564    # there are a few systems, like Next, where this doesn't work.
565
566    AC_MSG_CHECKING([system version (for dynamic loading)])
567    if test -f /usr/lib/NextStep/software_version; then
568        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
569    else
570        system=`uname -s`-`uname -r`
571        if test "$?" -ne 0 ; then
572            AC_MSG_RESULT([unknown (can't find uname command)])
573            system=unknown
574        else
575            # Special check for weird MP-RAS system (uname returns weird
576            # results, and the version is kept in special file).
577       
578            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
579                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
580            fi
581            if test "`uname -s`" = "AIX" ; then
582                system=AIX-`uname -v`.`uname -r`
583            fi
584            AC_MSG_RESULT($system)
585        fi
586    fi
587
588    # Step 2: check for existence of -ldl library.  This is needed because
589    # Linux can use either -ldl or -ldld for dynamic loading.
590
591    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
592
593    # Step 3: set configuration options based on system name and version.
594
595    do64bit_ok=no
596    fullSrcDir=`cd $srcdir; pwd`
597    EXTRA_CFLAGS=""
598    TCL_EXPORT_FILE_SUFFIX=""
599    UNSHARED_LIB_SUFFIX=""
600    TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
601    ECHO_VERSION='`echo ${VERSION}`'
602    TCL_LIB_VERSIONS_OK=ok
603    CFLAGS_DEBUG=-g
604    CFLAGS_OPTIMIZE=-O
605    TCL_NEEDS_EXP_FILE=0
606    TCL_BUILD_EXP_FILE=""
607    TCL_EXP_FILE=""
608    STLIB_LD="ar cr"
609    case $system in
610        AIX-4.[[2-9]])
611            SHLIB_CFLAGS=""
612            SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
613            SHLIB_LD_LIBS='${LIBS}'
614            SHLIB_SUFFIX=".so"
615            DL_OBJS="tclLoadDl.o"
616            DL_LIBS="-ldl"
617            LDFLAGS=""
618            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
619            TCL_NEEDS_EXP_FILE=1
620            TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
621            ;;
622        AIX-*)
623            SHLIB_CFLAGS=""
624            SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512"
625            SHLIB_LD_LIBS='${LIBS}'
626            SHLIB_SUFFIX=".so"
627            DL_OBJS="tclLoadDl.o"
628            LIBOBJS="$LIBOBJS tclLoadAix.o"
629            DL_LIBS="-lld"
630            LDFLAGS=""
631            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
632            TCL_NEEDS_EXP_FILE=1
633            TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
634            ;;
635        BSD/OS-2.1*|BSD/OS-3*)
636            SHLIB_CFLAGS=""
637            SHLIB_LD="shlicc -r"
638            SHLIB_LD_LIBS='${LIBS}'
639            SHLIB_SUFFIX=".so"
640            DL_OBJS="tclLoadDl.o"
641            DL_LIBS="-ldl"
642            LDFLAGS=""
643            LD_SEARCH_FLAGS=""
644            ;;
645        BSD/OS-4.*)
646            SHLIB_CFLAGS="-export-dynamic -fPIC"
647            SHLIB_LD="cc -shared"
648            SHLIB_LD_LIBS='${LIBS}'
649            SHLIB_SUFFIX=".so"
650            DL_OBJS="tclLoadDl.o"
651            DL_LIBS="-ldl"
652            LDFLAGS="-export-dynamic"
653            LD_SEARCH_FLAGS=""
654            ;;
655        *win32*|*WIN32*|CYGWIN_NT*|cygwin_nt*)
656            CFLAGS_DEBUG="-nologo -Z7 -Od -WX ${runtime}d"
657            CFLAGS_OPTIMIZE="-nologo -Oti -Gs -GD ${runtime}"
658            LDFLAGS_CONSOLE="-subsystem:console"
659            LDFLAGS_WINDOW="-subsystem:windows"
660            LDFLAGS_DEBUG="-debug:full -debugtype:cv"
661            LDFLAGS_OPTIMIZE="-release"
662            EXTRA_CFLAGS="-YX"
663            PATHTYPE=-w
664            STLIB_LD="lib -nologo"
665            SHLIB_LD="link -dll -nologo"
666            SHLIB_LD_LIBS="user32.lib advapi32.lib"
667            RC="rc"
668            ;;
669        dgux*)
670            SHLIB_CFLAGS="-K PIC"
671            SHLIB_LD="cc -G"
672            SHLIB_LD_LIBS=""
673            SHLIB_SUFFIX=".so"
674            DL_OBJS="tclLoadDl.o"
675            DL_LIBS="-ldl"
676            LDFLAGS=""
677            LD_SEARCH_FLAGS=""
678            ;;
679        HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*|HP-UX-*.11.*)
680            SHLIB_SUFFIX=".sl"
681            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
682            if test "$tcl_ok" = yes; then
683                SHLIB_CFLAGS="+z"
684                SHLIB_LD="ld -b"
685                SHLIB_LD_LIBS=""
686                DL_OBJS="tclLoadShl.o"
687                DL_LIBS="-ldld"
688                LDFLAGS="-Wl,-E"
689                LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
690            fi
691            ;;
692        IRIX-4.*)
693            SHLIB_CFLAGS="-G 0"
694            SHLIB_SUFFIX=".a"
695            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
696            SHLIB_LD_LIBS='${LIBS}'
697            DL_OBJS="tclLoadAout.o"
698            DL_LIBS=""
699            LDFLAGS="-Wl,-D,08000000"
700            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
701            SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
702            ;;
703        IRIX-5.*|IRIX-6.*|IRIX64-6.5*)
704            SHLIB_CFLAGS=""
705            SHLIB_LD="ld -n32 -shared -rdata_shared"
706            SHLIB_LD_LIBS=""
707            SHLIB_SUFFIX=".so"
708            DL_OBJS="tclLoadDl.o"
709            DL_LIBS=""
710            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
711            if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
712                EXTRA_CFLAGS="-mabi=n32"
713                LDFLAGS="-mabi=n32"
714            else
715                case $system in
716                    IRIX-6.3)
717                        # Use to build 6.2 compatible binaries on 6.3.
718                        EXTRA_CFLAGS="-n32 -D_OLD_TERMIOS"
719                        ;;
720                    *)
721                        EXTRA_CFLAGS="-n32"
722                        ;;
723                esac
724                LDFLAGS="-n32"
725            fi
726            ;;
727        IRIX64-6.*)
728            SHLIB_CFLAGS=""
729            SHLIB_LD="ld -32 -shared -rdata_shared"
730            SHLIB_LD_LIBS='${LIBS}'
731            SHLIB_SUFFIX=".so"
732            DL_OBJS="tclLoadDl.o"
733            DL_LIBS=""
734            LDFLAGS=""
735            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
736            ;;
737        Linux*)
738            SHLIB_CFLAGS="-fPIC"
739            SHLIB_LD_LIBS='${LIBS}'
740            SHLIB_SUFFIX=".so"
741
742            # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
743            # when you inline the string and math operations.  Turn this off to
744            # get rid of the warnings.
745
746            CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
747
748            if test "$have_dl" = yes; then
749                SHLIB_LD="${CC} -shared"
750                DL_OBJS="tclLoadDl.o"
751                DL_LIBS="-ldl"
752                LDFLAGS="-rdynamic"
753                LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
754            else
755                AC_CHECK_HEADER(dld.h, [
756                    SHLIB_LD="ld -shared"
757                    DL_OBJS="tclLoadDld.o"
758                    DL_LIBS="-ldld"
759                    LDFLAGS=""
760                    LD_SEARCH_FLAGS=""])
761            fi
762            if test "`uname -m`" = "alpha" ; then
763                EXTRA_CFLAGS="-mieee"
764            fi
765            ;;
766        MP-RAS-02*)
767            SHLIB_CFLAGS="-K PIC"
768            SHLIB_LD="cc -G"
769            SHLIB_LD_LIBS=""
770            SHLIB_SUFFIX=".so"
771            DL_OBJS="tclLoadDl.o"
772            DL_LIBS="-ldl"
773            LDFLAGS=""
774            LD_SEARCH_FLAGS=""
775            ;;
776        MP-RAS-*)
777            SHLIB_CFLAGS="-K PIC"
778            SHLIB_LD="cc -G"
779            SHLIB_LD_LIBS=""
780            SHLIB_SUFFIX=".so"
781            DL_OBJS="tclLoadDl.o"
782            DL_LIBS="-ldl"
783            LDFLAGS="-Wl,-Bexport"
784            LD_SEARCH_FLAGS=""
785            ;;
786        NetBSD-*|FreeBSD-[[12]].*|OpenBSD-*)
787            # Not available on all versions:  check for include file.
788            AC_CHECK_HEADER(dlfcn.h, [
789                SHLIB_CFLAGS="-fpic"
790                SHLIB_LD="ld -Bshareable -x"
791                SHLIB_LD_LIBS=""
792                SHLIB_SUFFIX=".so"
793                DL_OBJS="tclLoadDl.o"
794                DL_LIBS=""
795                LDFLAGS=""
796                LD_SEARCH_FLAGS=""
797                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
798            ], [
799                SHLIB_CFLAGS=""
800                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
801                SHLIB_LD_LIBS='${LIBS}'
802                SHLIB_SUFFIX=".a"
803                DL_OBJS="tclLoadAout.o"
804                DL_LIBS=""
805                LDFLAGS=""
806                LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
807                SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
808            ])
809
810            # FreeBSD doesn't handle version numbers with dots.
811
812            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
813            TCL_LIB_VERSIONS_OK=nodots
814            ;;
815        FreeBSD-*)
816            # FreeBSD 3.* and greater have ELF.
817            SHLIB_CFLAGS="-fpic"
818            SHLIB_LD="ld -Bshareable -x"
819            SHLIB_LD_LIBS=""
820            SHLIB_SUFFIX=".so"
821            DL_OBJS="tclLoadDl.o"
822            DL_LIBS=""
823            LDFLAGS=""
824            LD_SEARCH_FLAGS=""
825            ;;
826        NEXTSTEP-*)
827            SHLIB_CFLAGS=""
828            SHLIB_LD="cc -nostdlib -r"
829            SHLIB_LD_LIBS=""
830            SHLIB_SUFFIX=".so"
831            DL_OBJS="tclLoadNext.o"
832            DL_LIBS=""
833            LDFLAGS=""
834            LD_SEARCH_FLAGS=""
835            ;;
836        OS/390-*)
837            CFLAGS_OPTIMIZE=""      # Optimizer is buggy
838            AC_DEFINE(_OE_SOCKETS)  # needed in sys/socket.h
839            ;;     
840        OSF1-1.0|OSF1-1.1|OSF1-1.2)
841            # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
842            SHLIB_CFLAGS=""
843            # Hack: make package name same as library name
844            SHLIB_LD='ld -R -export $@:'
845            SHLIB_LD_LIBS=""
846            SHLIB_SUFFIX=".so"
847            DL_OBJS="tclLoadOSF.o"
848            DL_LIBS=""
849            LDFLAGS=""
850            LD_SEARCH_FLAGS=""
851            ;;
852        OSF1-1.*)
853            # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
854            SHLIB_CFLAGS="-fpic"
855            SHLIB_LD="ld -shared"
856            SHLIB_LD_LIBS=""
857            SHLIB_SUFFIX=".so"
858            DL_OBJS="tclLoadDl.o"
859            DL_LIBS=""
860            LDFLAGS=""
861            LD_SEARCH_FLAGS=""
862            ;;
863        OSF1-V*)
864            # Digital OSF/1
865            SHLIB_CFLAGS=""
866            SHLIB_LD='ld -shared -expect_unresolved "*"'
867            SHLIB_LD_LIBS=""
868            SHLIB_SUFFIX=".so"
869            DL_OBJS="tclLoadDl.o"
870            DL_LIBS=""
871            LDFLAGS=""
872            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
873            ;;
874        RISCos-*)
875            SHLIB_CFLAGS="-G 0"
876            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
877            SHLIB_LD_LIBS='${LIBS}'
878            SHLIB_SUFFIX=".a"
879            DL_OBJS="tclLoadAout.o"
880            DL_LIBS=""
881            LDFLAGS="-Wl,-D,08000000"
882            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
883            ;;
884        SCO_SV-3.2*)
885            # Note, dlopen is available only on SCO 3.2.5 and greater.  However,
886            # this test works, since "uname -s" was non-standard in 3.2.4 and
887            # below.
888            SHLIB_CFLAGS="-Kpic -belf"
889            SHLIB_LD="ld -G"
890            SHLIB_LD_LIBS=""
891            SHLIB_SUFFIX=".so"
892            DL_OBJS="tclLoadDl.o"
893            DL_LIBS=""
894            LDFLAGS="-belf -Wl,-Bexport"
895            LD_SEARCH_FLAGS=""
896            ;;
897        SINIX*5.4*)
898            SHLIB_CFLAGS="-K PIC"
899            SHLIB_LD="cc -G"
900            SHLIB_LD_LIBS=""
901            SHLIB_SUFFIX=".so"
902            DL_OBJS="tclLoadDl.o"
903            DL_LIBS="-ldl"
904            LDFLAGS=""
905            LD_SEARCH_FLAGS=""
906            ;;
907        SunOS-4*)
908            SHLIB_CFLAGS="-PIC"
909            SHLIB_LD="ld"
910            SHLIB_LD_LIBS=""
911            SHLIB_SUFFIX=".so"
912            DL_OBJS="tclLoadDl.o"
913            DL_LIBS="-ldl"
914            LDFLAGS=""
915            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
916
917            # SunOS can't handle version numbers with dots in them in library
918            # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
919            # requires an extra version number at the end of .so file names.
920            # So, the library has to have a name like libtcl75.so.1.0
921
922            SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
923            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
924            TCL_LIB_VERSIONS_OK=nodots
925            ;;
926        SunOS-5.[[0-6]]*)
927            SHLIB_CFLAGS="-KPIC"
928            SHLIB_LD="/usr/ccs/bin/ld -G -z text"
929
930            # Note: need the LIBS below, otherwise Tk won't find Tcl's
931            # symbols when dynamically loaded into tclsh.
932
933            SHLIB_LD_LIBS='${LIBS}'
934            SHLIB_SUFFIX=".so"
935            DL_OBJS="tclLoadDl.o"
936            DL_LIBS="-ldl"
937            LDFLAGS=""
938            LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
939            ;;
940        SunOS-5*)
941            SHLIB_CFLAGS="-KPIC"
942            SHLIB_LD="/usr/ccs/bin/ld -G -z text"
943            LDFLAGS=""
944   
945            do64bit_ok=no
946            if test "$do64bit" = "yes" ; then
947            arch=`isainfo`
948            if test "$arch" = "sparcv9 sparc" ; then
949                if test "$CC" != "gcc" -a `$CC -v 2>&1 | grep -c gcc` = "0" ; then
950                do64bit_ok=yes
951                EXTRA_CFLAGS="-xarch=v9"
952                LDFLAGS="-xarch=v9"
953                else
954                AC_MSG_WARN("64bit mode not supported using GCC on $system")
955                fi
956            else
957                AC_MSG_WARN("64bit mode only supported sparcv9 system")
958            fi
959            fi
960           
961            # Note: need the LIBS below, otherwise Tk won't find Tcl's
962            # symbols when dynamically loaded into tclsh.
963
964            SHLIB_LD_LIBS='${LIBS}'
965            SHLIB_SUFFIX=".so"
966            DL_OBJS="tclLoadDl.o"
967            DL_LIBS="-ldl"
968            if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
969                LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
970            else
971                LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
972            fi
973            ;;
974        ULTRIX-4.*)
975            SHLIB_CFLAGS="-G 0"
976            SHLIB_SUFFIX=".a"
977            SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
978            SHLIB_LD_LIBS='${LIBS}'
979            DL_OBJS="tclLoadAout.o"
980            DL_LIBS=""
981            LDFLAGS="-Wl,-D,08000000"
982            LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
983            ;;
984        UNIX_SV* | UnixWare-5*)
985            SHLIB_CFLAGS="-KPIC"
986            SHLIB_LD="cc -G"
987            SHLIB_LD_LIBS=""
988            SHLIB_SUFFIX=".so"
989            DL_OBJS="tclLoadDl.o"
990            DL_LIBS="-ldl"
991            # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
992            # that don't grok the -Bexport option.  Test that it does.
993            hold_ldflags=$LDFLAGS
994            AC_MSG_CHECKING(for ld accepts -Bexport flag)
995            LDFLAGS="${LDFLAGS} -Wl,-Bexport"
996            AC_TRY_LINK(, [int i;], found=yes, found=no)
997            LDFLAGS=$hold_ldflags
998            AC_MSG_RESULT($found)
999            if test $found = yes; then
1000            LDFLAGS="-Wl,-Bexport"
1001            else
1002            LDFLAGS=""
1003            fi
1004            LD_SEARCH_FLAGS=""
1005            ;;
1006    esac
1007
1008    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
1009    AC_MSG_WARN("64bit support being disabled -- not supported on this platform")
1010    fi
1011
1012    # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
1013    # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
1014    # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
1015    # to determine which of several header files defines the a.out file
1016    # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
1017    # support only a file format that is more or less version-7-compatible.
1018    # In particular,
1019    #   - a.out files must begin with `struct exec'.
1020    #   - the N_TXTOFF on the `struct exec' must compute the seek address
1021    #     of the text segment
1022    #   - The `struct exec' must contain a_magic, a_text, a_data, a_bss
1023    #     and a_entry fields.
1024    # The following compilation should succeed if and only if either sys/exec.h
1025    # or a.out.h is usable for the purpose.
1026    #
1027    # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
1028    # `struct exec' includes a second header that contains information that
1029    # duplicates the v7 fields that are needed.
1030
1031    if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
1032        AC_MSG_CHECKING(sys/exec.h)
1033        AC_TRY_COMPILE([#include <sys/exec.h>],[
1034            struct exec foo;
1035            unsigned long seek;
1036            int flag;
1037#if defined(__mips) || defined(mips)
1038            seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1039#else
1040            seek = N_TXTOFF (foo);
1041#endif
1042            flag = (foo.a_magic == OMAGIC);
1043            return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1044    ], tcl_ok=usable, tcl_ok=unusable)
1045        AC_MSG_RESULT($tcl_ok)
1046        if test $tcl_ok = usable; then
1047            AC_DEFINE(USE_SYS_EXEC_H)
1048        else
1049            AC_MSG_CHECKING(a.out.h)
1050            AC_TRY_COMPILE([#include <a.out.h>],[
1051                struct exec foo;
1052                unsigned long seek;
1053                int flag;
1054#if defined(__mips) || defined(mips)
1055                seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1056#else
1057                seek = N_TXTOFF (foo);
1058#endif
1059                flag = (foo.a_magic == OMAGIC);
1060                return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1061            ], tcl_ok=usable, tcl_ok=unusable)
1062            AC_MSG_RESULT($tcl_ok)
1063            if test $tcl_ok = usable; then
1064                AC_DEFINE(USE_A_OUT_H)
1065            else
1066                AC_MSG_CHECKING(sys/exec_aout.h)
1067                AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
1068                    struct exec foo;
1069                    unsigned long seek;
1070                    int flag;
1071#if defined(__mips) || defined(mips)
1072                    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1073#else
1074                    seek = N_TXTOFF (foo);
1075#endif
1076                    flag = (foo.a_midmag == OMAGIC);
1077                    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1078                ], tcl_ok=usable, tcl_ok=unusable)
1079                AC_MSG_RESULT($tcl_ok)
1080                if test $tcl_ok = usable; then
1081                    AC_DEFINE(USE_SYS_EXEC_AOUT_H)
1082                else
1083                    DL_OBJS=""
1084                fi
1085            fi
1086        fi
1087    fi
1088
1089    # Step 5: disable dynamic loading if requested via a command-line switch.
1090
1091    AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
1092        [tcl_ok=$enableval], [tcl_ok=yes])
1093    if test "$tcl_ok" = "no"; then
1094        DL_OBJS=""
1095    fi
1096
1097    if test "x$DL_OBJS" != "x" ; then
1098        BUILD_DLTEST="\$(DLTEST_TARGETS)"
1099    else
1100        echo "Can't figure out how to do dynamic loading or shared libraries"
1101        echo "on this system."
1102        SHLIB_CFLAGS=""
1103        SHLIB_LD=""
1104        SHLIB_SUFFIX=""
1105        DL_OBJS="tclLoadNone.o"
1106        DL_LIBS=""
1107        LDFLAGS=""
1108        LD_SEARCH_FLAGS=""
1109        BUILD_DLTEST=""
1110    fi
1111
1112    # If we're running gcc, then change the C flags for compiling shared
1113    # libraries to the right flags for gcc, instead of those for the
1114    # standard manufacturer compiler.
1115
1116    if test "$DL_OBJS" != "tclLoadNone.o" ; then
1117        if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
1118            case $system in
1119                AIX-*)
1120                    ;;
1121                BSD/OS*)
1122                    ;;
1123                IRIX*)
1124                    ;;
1125                NetBSD-*|FreeBSD-*|OpenBSD-*)
1126                    ;;
1127                RISCos-*)
1128                    ;;
1129                ULTRIX-4.*)
1130                    ;;
1131                *)
1132                    SHLIB_CFLAGS="-fPIC"
1133                    ;;
1134            esac
1135        fi
1136    fi
1137
1138    if test "$SHARED_LIB_SUFFIX" = "" ; then
1139        SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
1140    fi
1141    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
1142        UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1143    fi
1144
1145    AC_SUBST(STLIB_LD)
1146    AC_SUBST(SHLIB_LD)
1147    AC_SUBST(SHLIB_CFLAGS)
1148    AC_SUBST(SHLIB_LDFLAGS)
1149    AC_SUBST(DL_LIBS)
1150    AC_SUBST(CFLAGS_DEBUG)
1151    AC_SUBST(CFLAGS_OPTIMIZE)
1152    AC_SUBST(LDFLAGS_DEBUG)
1153    AC_SUBST(LDFLAGS_OPTIMIZE)
1154])
1155
1156#--------------------------------------------------------------------
1157# SC_SERIAL_PORT
1158#
1159#       Determine which interface to use to talk to the serial port.
1160#       Note that #include lines must begin in leftmost column for
1161#       some compilers to recognize them as preprocessor directives.
1162#
1163# Arguments:
1164#       none
1165#       
1166# Results:
1167#
1168#       Defines only one of the following vars:
1169#               USE_TERMIOS
1170#               USE_TERMIO
1171#               USE_SGTTY
1172#
1173#--------------------------------------------------------------------
1174
1175AC_DEFUN(SC_SERIAL_PORT, [
1176    AC_MSG_CHECKING([termios vs. termio vs. sgtty])
1177
1178    AC_TRY_RUN([
1179#include <termios.h>
1180
1181main()
1182{
1183    struct termios t;
1184    if (tcgetattr(0, &t) == 0) {
1185        cfsetospeed(&t, 0);
1186        t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
1187        return 0;
1188    }
1189    return 1;
1190}], tk_ok=termios, tk_ok=no, tk_ok=no)
1191
1192    if test $tk_ok = termios; then
1193        AC_DEFINE(USE_TERMIOS)
1194    else
1195        AC_TRY_RUN([
1196#include <termio.h>
1197
1198main()
1199{
1200    struct termio t;
1201    if (ioctl(0, TCGETA, &t) == 0) {
1202        t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
1203        return 0;
1204    }
1205    return 1;
1206    }], tk_ok=termio, tk_ok=no, tk_ok=no)
1207
1208    if test $tk_ok = termio; then
1209        AC_DEFINE(USE_TERMIO)
1210    else
1211        AC_TRY_RUN([
1212#include <sgtty.h>
1213
1214main()
1215{
1216    struct sgttyb t;
1217    if (ioctl(0, TIOCGETP, &t) == 0) {
1218        t.sg_ospeed = 0;
1219        t.sg_flags |= ODDP | EVENP | RAW;
1220        return 0;
1221    }
1222    return 1;
1223}], tk_ok=sgtty, tk_ok=none, tk_ok=none)
1224    if test $tk_ok = sgtty; then
1225        AC_DEFINE(USE_SGTTY)
1226    fi
1227    fi
1228    fi
1229    AC_MSG_RESULT($tk_ok)
1230])
1231
1232#--------------------------------------------------------------------
1233# SC_MISSING_POSIX_HEADERS
1234#
1235#       Supply substitutes for missing POSIX header files.  Special
1236#       notes:
1237#           - stdlib.h doesn't define strtol, strtoul, or
1238#             strtod insome versions of SunOS
1239#           - some versions of string.h don't declare procedures such
1240#             as strstr
1241#
1242# Arguments:
1243#       none
1244#       
1245# Results:
1246#
1247#       Defines some of the following vars:
1248#               NO_DIRENT_H
1249#               NO_ERRNO_H
1250#               NO_VALUES_H
1251#               NO_LIMITS_H
1252#               NO_STDLIB_H
1253#               NO_STRING_H
1254#               NO_SYS_WAIT_H
1255#               NO_DLFCN_H
1256#               HAVE_UNISTD_H
1257#               HAVE_SYS_PARAM_H
1258#
1259#               HAVE_STRING_H ?
1260#
1261#--------------------------------------------------------------------
1262
1263AC_DEFUN(SC_MISSING_POSIX_HEADERS, [
1264
1265    AC_MSG_CHECKING(dirent.h)
1266    AC_TRY_LINK([#include <sys/types.h>
1267#include <dirent.h>], [
1268#ifndef _POSIX_SOURCE
1269#   ifdef __Lynx__
1270        /*
1271         * Generate compilation error to make the test fail:  Lynx headers
1272         * are only valid if really in the POSIX environment.
1273         */
1274
1275        missing_procedure();
1276#   endif
1277#endif
1278DIR *d;
1279struct dirent *entryPtr;
1280char *p;
1281d = opendir("foobar");
1282entryPtr = readdir(d);
1283p = entryPtr->d_name;
1284closedir(d);
1285], tcl_ok=yes, tcl_ok=no)
1286
1287    if test $tcl_ok = no; then
1288        AC_DEFINE(NO_DIRENT_H)
1289    fi
1290
1291    AC_MSG_RESULT($tcl_ok)
1292    AC_CHECK_HEADER(errno.h, , AC_DEFINE(NO_ERRNO_H))
1293    AC_CHECK_HEADER(float.h, , AC_DEFINE(NO_FLOAT_H))
1294    AC_CHECK_HEADER(values.h, , AC_DEFINE(NO_VALUES_H))
1295    AC_CHECK_HEADER(limits.h, , AC_DEFINE(NO_LIMITS_H))
1296    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
1297    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
1298    AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
1299    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
1300    if test $tcl_ok = 0; then
1301        AC_DEFINE(NO_STDLIB_H)
1302    fi
1303    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
1304    AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
1305    AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
1306
1307    # See also memmove check below for a place where NO_STRING_H can be
1308    # set and why.
1309
1310    if test $tcl_ok = 0; then
1311        AC_DEFINE(NO_STRING_H)
1312    fi
1313
1314    AC_CHECK_HEADER(sys/wait.h, , AC_DEFINE(NO_SYS_WAIT_H))
1315    AC_CHECK_HEADER(dlfcn.h, , AC_DEFINE(NO_DLFCN_H))
1316
1317    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
1318
1319    AC_HAVE_HEADERS(unistd.h sys/param.h)
1320
1321])
1322
1323#--------------------------------------------------------------------
1324# SC_PATH_X
1325#
1326#       Locate the X11 header files and the X11 library archive.  Try
1327#       the ac_path_x macro first, but if it doesn't find the X stuff
1328#       (e.g. because there's no xmkmf program) then check through
1329#       a list of possible directories.  Under some conditions the
1330#       autoconf macro will return an include directory that contains
1331#       no include files, so double-check its result just to be safe.
1332#
1333# Arguments:
1334#       none
1335#       
1336# Results:
1337#
1338#       Sets the the following vars:
1339#               XINCLUDES
1340#               XLIBSW
1341#
1342#--------------------------------------------------------------------
1343
1344AC_DEFUN(SC_PATH_X, [
1345    AC_PATH_X
1346    not_really_there=""
1347    if test "$no_x" = ""; then
1348        if test "$x_includes" = ""; then
1349            AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
1350        else
1351            if test ! -r $x_includes/X11/Intrinsic.h; then
1352                not_really_there="yes"
1353            fi
1354        fi
1355    fi
1356    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
1357        AC_MSG_CHECKING(for X11 header files)
1358        XINCLUDES="# no special path needed"
1359        AC_TRY_CPP([#include <X11/Intrinsic.h>], , XINCLUDES="nope")
1360        if test "$XINCLUDES" = nope; then
1361            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"
1362            for i in $dirs ; do
1363                if test -r $i/X11/Intrinsic.h; then
1364                    AC_MSG_RESULT($i)
1365                    XINCLUDES=" -I$i"
1366                    break
1367                fi
1368            done
1369        fi
1370    else
1371        if test "$x_includes" != ""; then
1372            XINCLUDES=-I$x_includes
1373        else
1374            XINCLUDES="# no special path needed"
1375        fi
1376    fi
1377    if test "$XINCLUDES" = nope; then
1378        AC_MSG_RESULT(couldn't find any!)
1379        XINCLUDES="# no include files found"
1380    fi
1381
1382    if test "$no_x" = yes; then
1383        AC_MSG_CHECKING(for X11 libraries)
1384        XLIBSW=nope
1385        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"
1386        for i in $dirs ; do
1387            if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
1388                AC_MSG_RESULT($i)
1389                XLIBSW="-L$i -lX11"
1390                x_libraries="$i"
1391                break
1392            fi
1393        done
1394    else
1395        if test "$x_libraries" = ""; then
1396            XLIBSW=-lX11
1397        else
1398            XLIBSW="-L$x_libraries -lX11"
1399        fi
1400    fi
1401    if test "$XLIBSW" = nope ; then
1402        AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
1403    fi
1404    if test "$XLIBSW" = nope ; then
1405        AC_MSG_RESULT(couldn't find any!  Using -lX11.)
1406        XLIBSW=-lX11
1407    fi
1408])
1409#--------------------------------------------------------------------
1410# SC_BLOCKING_STYLE
1411#
1412#       The statements below check for systems where POSIX-style
1413#       non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
1414#       On these systems (mostly older ones), use the old BSD-style
1415#       FIONBIO approach instead.
1416#
1417# Arguments:
1418#       none
1419#       
1420# Results:
1421#
1422#       Defines some of the following vars:
1423#               HAVE_SYS_IOCTL_H
1424#               HAVE_SYS_FILIO_H
1425#               USE_FIONBIO
1426#               O_NONBLOCK
1427#
1428#--------------------------------------------------------------------
1429
1430AC_DEFUN(SC_BLOCKING_STYLE, [
1431    AC_CHECK_HEADERS(sys/ioctl.h)
1432    AC_CHECK_HEADERS(sys/filio.h)
1433    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
1434    if test -f /usr/lib/NextStep/software_version; then
1435        system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
1436    else
1437        system=`uname -s`-`uname -r`
1438        if test "$?" -ne 0 ; then
1439            system=unknown
1440        else
1441            # Special check for weird MP-RAS system (uname returns weird
1442            # results, and the version is kept in special file).
1443       
1444            if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
1445                system=MP-RAS-`awk '{print $3}' /etc/.relid'`
1446            fi
1447            if test "`uname -s`" = "AIX" ; then
1448                system=AIX-`uname -v`.`uname -r`
1449            fi
1450        fi
1451    fi
1452    case $system in
1453        # There used to be code here to use FIONBIO under AIX.  However, it
1454        # was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
1455        # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
1456        # code (JO, 5/31/97).
1457
1458        OSF*)
1459            AC_DEFINE(USE_FIONBIO)
1460            AC_MSG_RESULT(FIONBIO)
1461            ;;
1462        SunOS-4*)
1463            AC_DEFINE(USE_FIONBIO)
1464            AC_MSG_RESULT(FIONBIO)
1465            ;;
1466        ULTRIX-4.*)
1467            AC_DEFINE(USE_FIONBIO)
1468            AC_MSG_RESULT(FIONBIO)
1469            ;;
1470        *)
1471            AC_MSG_RESULT(O_NONBLOCK)
1472            ;;
1473    esac
1474])
1475
1476#--------------------------------------------------------------------
1477# SC_HAVE_VFORK
1478#
1479#       Check to see whether the system provides a vfork kernel call.
1480#       If not, then use fork instead.  Also, check for a problem with
1481#       vforks and signals that can cause core dumps if a vforked child
1482#       resets a signal handler.  If the problem exists, then use fork
1483#       instead of vfork.
1484#
1485# Arguments:
1486#       none
1487#       
1488# Results:
1489#
1490#       Defines some of the following vars:
1491#               vfork (=fork)
1492#
1493#--------------------------------------------------------------------
1494
1495AC_DEFUN(SC_HAVE_VFORK, [
1496    AC_TYPE_SIGNAL()
1497    AC_CHECK_FUNC(vfork, tcl_ok=1, tcl_ok=0)
1498    if test "$tcl_ok" = 1; then
1499        AC_MSG_CHECKING([vfork/signal bug]);
1500        AC_TRY_RUN([
1501#include <stdio.h>
1502#include <signal.h>
1503#include <sys/wait.h>
1504int gotSignal = 0;
1505sigProc(sig)
1506    int sig;
1507{
1508    gotSignal = 1;
1509}
1510main()
1511{
1512    int pid, sts;
1513    (void) signal(SIGCHLD, sigProc);
1514    pid = vfork();
1515    if (pid <  0) {
1516        exit(1);
1517    } else if (pid == 0) {
1518        (void) signal(SIGCHLD, SIG_DFL);
1519        _exit(0);
1520    } else {
1521        (void) wait(&sts);
1522    }
1523    exit((gotSignal) ? 0 : 1);
1524}], tcl_ok=1, tcl_ok=0, tcl_ok=0)
1525
1526        if test "$tcl_ok" = 1; then
1527            AC_MSG_RESULT(ok)
1528        else
1529            AC_MSG_RESULT([buggy, using fork instead])
1530        fi
1531    fi
1532    rm -f core
1533    if test "$tcl_ok" = 0; then
1534        AC_DEFINE(vfork, fork)
1535    fi
1536])
1537
1538#--------------------------------------------------------------------
1539# SC_TIME_HANLDER
1540#
1541#       Checks how the system deals with time.h, what time structures
1542#       are used on the system, and what fields the structures have.
1543#
1544# Arguments:
1545#       none
1546#       
1547# Results:
1548#
1549#       Defines some of the following vars:
1550#               USE_DELTA_FOR_TZ
1551#               HAVE_TM_GMTOFF
1552#               HAVE_TM_TZADJ
1553#               HAVE_TIMEZONE_VAR
1554#
1555#--------------------------------------------------------------------
1556
1557AC_DEFUN(SC_TIME_HANDLER, [
1558    AC_CHECK_HEADERS(sys/time.h)
1559    AC_HEADER_TIME
1560    AC_STRUCT_TIMEZONE
1561
1562    AC_MSG_CHECKING([tm_tzadj in struct tm])
1563    AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
1564            [AC_DEFINE(HAVE_TM_TZADJ)
1565            AC_MSG_RESULT(yes)],
1566            AC_MSG_RESULT(no))
1567
1568    AC_MSG_CHECKING([tm_gmtoff in struct tm])
1569    AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
1570            [AC_DEFINE(HAVE_TM_GMTOFF)
1571            AC_MSG_RESULT(yes)],
1572            AC_MSG_RESULT(no))
1573
1574    #
1575    # Its important to include time.h in this check, as some systems
1576    # (like convex) have timezone functions, etc.
1577    #
1578    have_timezone=no
1579    AC_MSG_CHECKING([long timezone variable])
1580    AC_TRY_COMPILE([#include <time.h>],
1581            [extern long timezone;
1582            timezone += 1;
1583            exit (0);],
1584            [have_timezone=yes
1585            AC_DEFINE(HAVE_TIMEZONE_VAR)
1586            AC_MSG_RESULT(yes)],
1587            AC_MSG_RESULT(no))
1588
1589    #
1590    # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
1591    #
1592    if test "$have_timezone" = no; then
1593    AC_MSG_CHECKING([time_t timezone variable])
1594    AC_TRY_COMPILE([#include <time.h>],
1595            [extern time_t timezone;
1596            timezone += 1;
1597            exit (0);],
1598            [AC_DEFINE(HAVE_TIMEZONE_VAR)
1599            AC_MSG_RESULT(yes)],
1600            AC_MSG_RESULT(no))
1601    fi
1602
1603    #
1604    # AIX does not have a timezone field in struct tm. When the AIX bsd
1605    # library is used, the timezone global and the gettimeofday methods are
1606    # to be avoided for timezone deduction instead, we deduce the timezone
1607    # by comparing the localtime result on a known GMT value.
1608    #
1609
1610    if test "`uname -s`" = "AIX" ; then
1611        AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes)
1612        if test $libbsd = yes; then
1613            AC_DEFINE(USE_DELTA_FOR_TZ)
1614        fi
1615    fi
1616])
1617
1618#--------------------------------------------------------------------
1619# SC_BUGGY_STRTOD
1620#
1621#       Under Solaris 2.4, strtod returns the wrong value for the
1622#       terminating character under some conditions.  Check for this
1623#       and if the problem exists use a substitute procedure
1624#       "fixstrtod" (provided by Tcl) that corrects the error.
1625#
1626# Arguments:
1627#       none
1628#       
1629# Results:
1630#
1631#       Might defines some of the following vars:
1632#               strtod (=fixstrtod)
1633#
1634#--------------------------------------------------------------------
1635
1636AC_DEFUN(SC_BUGGY_STRTOD, [
1637    AC_CHECK_FUNC(strtod, tk_strtod=1, tk_strtod=0)
1638    if test "$tk_strtod" = 1; then
1639        AC_MSG_CHECKING([for Solaris 2.4 strtod bug])
1640        AC_TRY_RUN([
1641            extern double strtod();
1642            int main()
1643            {
1644                char *string = "NaN";
1645                char *term;
1646                strtod(string, &term);
1647                if ((term != string) && (term[-1] == 0)) {
1648                    exit(1);
1649                }
1650                exit(0);
1651            }], tk_ok=1, tk_ok=0, tk_ok=0)
1652        if test "$tk_ok" = 1; then
1653            AC_MSG_RESULT(ok)
1654        else
1655            AC_MSG_RESULT(buggy)
1656            AC_DEFINE(strtod, fixstrtod)
1657        fi
1658    fi
1659])
1660
1661#--------------------------------------------------------------------
1662# SC_TCL_LINK_LIBS
1663#
1664#       Search for the libraries needed to link the Tcl shell.
1665#       Things like the math library (-lm) and socket stuff (-lsocket vs.
1666#       -lnsl) are dealt with here.
1667#
1668# Arguments:
1669#       Requires the following vars to be set in the Makefile:
1670#               DL_LIBS
1671#               LIBS
1672#               MATH_LIBS
1673#       
1674# Results:
1675#
1676#       Subst's the following var:
1677#               TCL_LIBS
1678#               MATH_LIBS
1679#
1680#       Might append to the following vars:
1681#               LIBS
1682#
1683#       Might define the following vars:
1684#               HAVE_NET_ERRNO_H
1685#
1686#--------------------------------------------------------------------
1687
1688AC_DEFUN(SC_TCL_LINK_LIBS, [
1689    #--------------------------------------------------------------------
1690    # On a few very rare systems, all of the libm.a stuff is
1691    # already in libc.a.  Set compiler flags accordingly.
1692    # Also, Linux requires the "ieee" library for math to work
1693    # right (and it must appear before "-lm").
1694    #--------------------------------------------------------------------
1695
1696    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
1697    AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
1698
1699    #--------------------------------------------------------------------
1700    # On AIX systems, libbsd.a has to be linked in to support
1701    # non-blocking file IO.  This library has to be linked in after
1702    # the MATH_LIBS or it breaks the pow() function.  The way to
1703    # insure proper sequencing, is to add it to the tail of MATH_LIBS.
1704    # This library also supplies gettimeofday.
1705    #--------------------------------------------------------------------
1706
1707    libbsd=no
1708    if test "`uname -s`" = "AIX" ; then
1709        AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes)
1710        if test $libbsd = yes; then
1711            MATH_LIBS="$MATH_LIBS -lbsd"
1712        fi
1713    fi
1714
1715
1716    #--------------------------------------------------------------------
1717    # Interactive UNIX requires -linet instead of -lsocket, plus it
1718    # needs net/errno.h to define the socket-related error codes.
1719    #--------------------------------------------------------------------
1720
1721    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
1722    AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))
1723
1724    #--------------------------------------------------------------------
1725    #   Check for the existence of the -lsocket and -lnsl libraries.
1726    #   The order here is important, so that they end up in the right
1727    #   order in the command line generated by make.  Here are some
1728    #   special considerations:
1729    #   1. Use "connect" and "accept" to check for -lsocket, and
1730    #      "gethostbyname" to check for -lnsl.
1731    #   2. Use each function name only once:  can't redo a check because
1732    #      autoconf caches the results of the last check and won't redo it.
1733    #   3. Use -lnsl and -lsocket only if they supply procedures that
1734    #      aren't already present in the normal libraries.  This is because
1735    #      IRIX 5.2 has libraries, but they aren't needed and they're
1736    #      bogus:  they goof up name resolution if used.
1737    #   4. On some SVR4 systems, can't use -lsocket without -lnsl too.
1738    #      To get around this problem, check for both libraries together
1739    #      if -lsocket doesn't work by itself.
1740    #--------------------------------------------------------------------
1741
1742    tcl_checkBoth=0
1743    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
1744    if test "$tcl_checkSocket" = 1; then
1745        AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tcl_checkBoth=1)
1746    fi
1747    if test "$tcl_checkBoth" = 1; then
1748        tk_oldLibs=$LIBS
1749        LIBS="$LIBS -lsocket -lnsl"
1750        AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
1751    fi
1752    AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main,
1753            [LIBS="$LIBS -lnsl"]))
1754   
1755    # Don't perform the eval of the libraries here because DL_LIBS
1756    # won't be set until we call SC_CONFIG_CFLAGS
1757
1758    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
1759    AC_SUBST(TCL_LIBS)
1760    AC_SUBST(MATH_LIBS)
1761])
1762
1763#------------------------------------------------------------------------
1764# SC_MAKE_LIB --
1765#
1766#       Generate a line that can be used to build a shared/unshared library
1767#       in a platform independent manner.
1768#
1769# Arguments:
1770#       none
1771#
1772#       Requires:
1773#
1774# Results:
1775#
1776#       Defines the following vars:
1777#               MAKE_LIB        Makefile rule for building a library
1778#               MAKE_SHARED_LIB Makefile rule for building a shared library
1779#               MAKE_UNSHARED_LIB       Makefile rule for building a static
1780#                               library
1781#------------------------------------------------------------------------
1782
1783AC_DEFUN(SC_MAKE_LIB, [
1784    case "`uname -s`" in
1785        *win32* | *WIN32* | *CYGWIN_NT*)
1786            if test "${CC-cc}" = "cl"; then
1787                MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(\[$]@_OBJECTS) "
1788                MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS} \$(LDFLAGS) -out:\[$]@ \$(\[$]@_OBJECTS) "
1789            fi
1790            ;;
1791        *)
1792            MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(\[$]@_OBJECTS)"
1793            MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(\[$]@_OBJECTS) \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS}"
1794            ;;
1795    esac
1796
1797    if test "${SHARED_BUILD}" = "1" ; then
1798        MAKE_LIB=${MAKE_SHARED_LIB}
1799    else
1800        MAKE_LIB=${MAKE_STATIC_LIB}
1801    fi
1802
1803    AC_SUBST(MAKE_LIB)
1804    AC_SUBST(MAKE_SHARED_LIB)
1805    AC_SUBST(MAKE_STATIC_LIB)
1806])
1807
1808#------------------------------------------------------------------------
1809# SC_LIB_SPEC --
1810#
1811#       Compute the name of an existing object library located in libdir
1812#       from the given base name and produce the appropriate linker flags.
1813#
1814# Arguments:
1815#       basename        The base name of the library without version
1816#                       numbers, extensions, or "lib" prefixes.
1817#
1818#       Requires:
1819#
1820# Results:
1821#
1822#       Defines the following vars:
1823#               ${basename}_LIB_NAME    The computed library name.
1824#               ${basename}_LIB_SPEC    The computed linker flags.
1825#------------------------------------------------------------------------
1826
1827AC_DEFUN(SC_LIB_SPEC, [
1828    AC_MSG_CHECKING(for $1 library)
1829    eval "sc_lib_name_dir=${libdir}"
1830    for i in \
1831            `ls -dr ${sc_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
1832            `ls -dr ${sc_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
1833            `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
1834            `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
1835            `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
1836            `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
1837        if test -f "$i" ; then
1838
1839            sc_lib_name_dir=`dirname $i`
1840            $1_LIB_NAME=`basename $i`
1841            break
1842        fi
1843    done
1844
1845    case "`uname -s`" in
1846        *win32* | *WIN32* | *CYGWIN_NT*)
1847            $1_LIB_SPEC=${$1_LIB_NAME}
1848            ;;
1849        *)
1850            # Strip off the leading "lib" and trailing ".a" or ".so"
1851
1852            sc_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//'`
1853            $1_LIB_SPEC="-L${sc_lib_name_dir} -l${sc_lib_name_lib}"
1854            ;;
1855    esac
1856    if test "x$1_LIB_NAME" = x ; then
1857        AC_MSG_ERROR(not found)
1858    else
1859        AC_MSG_RESULT(${$1_LIB_SPEC})
1860    fi
1861])
1862
1863#------------------------------------------------------------------------
1864# SC_PRIVATE_TCL_INCLUDE --
1865#
1866#       Locate the private Tcl include files
1867#
1868# Arguments:
1869#
1870#       Requires:
1871#               TCL_SRC_DIR     Assumes that SC_LOAD_TCLCONFIG has
1872#                                already been called.
1873#
1874# Results:
1875#
1876#       Substs the following vars:
1877#               TCL_TOP_DIR_NATIVE
1878#               TCL_GENERIC_DIR_NATIVE
1879#               TCL_UNIX_DIR_NATIVE
1880#               TCL_WIN_DIR_NATIVE
1881#               TCL_BMAP_DIR_NATIVE
1882#               TCL_TOOL_DIR_NATIVE
1883#               TCL_PLATFORM_DIR_NATIVE
1884#               TCL_BIN_DIR_NATIVE
1885#               TCL_INCLUDES
1886#------------------------------------------------------------------------
1887
1888AC_DEFUN(SC_PRIVATE_TCL_HEADERS, [
1889    AC_MSG_CHECKING(for Tcl private include files)
1890
1891    case "`uname -s`" in
1892        *win32* | *WIN32* | *CYGWIN_NT*)
1893            TCL_TOP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/..`\"
1894            TCL_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../generic`\"
1895            TCL_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../unix`\"
1896            TCL_WIN_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../win`\"
1897            TCL_BMAP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../bitmaps`\"
1898            TCL_TOOL_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../tools`\"
1899            TCL_COMPAT_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../compat`\"
1900            TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
1901        ;;
1902        *)
1903            TCL_TOP_DIR_NATIVE=${TCL_SRC_DIR}
1904            TCL_GENERIC_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/generic'
1905            TCL_UNIX_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/unix'
1906            TCL_WIN_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/win'
1907            TCL_BMAP_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/bitmaps'
1908            TCL_TOOL_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/tools'
1909            TCL_COMPAT_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/compat'
1910            TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
1911        ;;
1912    esac
1913
1914    AC_SUBST(TCL_TOP_DIR_NATIVE)
1915    AC_SUBST(TCL_GENERIC_DIR_NATIVE)
1916    AC_SUBST(TCL_UNIX_DIR_NATIVE)
1917    AC_SUBST(TCL_WIN_DIR_NATIVE)
1918    AC_SUBST(TCL_BMAP_DIR_NATIVE)
1919    AC_SUBST(TCL_TOOL_DIR_NATIVE)
1920    AC_SUBST(TCL_PLATFORM_DIR_NATIVE)
1921
1922    TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
1923    AC_SUBST(TCL_INCLUDES)
1924    AC_MSG_RESULT(Using srcdir found in tclConfig.sh)
1925])
1926
1927#------------------------------------------------------------------------
1928# SC_PUBLIC_TCL_HEADERS --
1929#
1930#       Locate the installed public Tcl header files
1931#
1932# Arguments:
1933#       None.
1934#
1935# Requires:
1936#       CYGPATH must be set
1937#
1938# Results:
1939#
1940#       Adds a --with-tclinclude switch to configure.
1941#       Result is cached.
1942#
1943#       Substs the following vars:
1944#               TCL_INCLUDES
1945#------------------------------------------------------------------------
1946
1947AC_DEFUN(SC_PUBLIC_TCL_HEADERS, [
1948    AC_MSG_CHECKING(for Tcl public headers)
1949
1950    AC_ARG_WITH(tclinclude, [ --with-tclinclude      directory containing the public Tcl header files.], with_tclinclude=${withval})
1951
1952    if test x"${with_tclinclude}" != x ; then
1953        if test -f "${with_tclinclude}/tcl.h" ; then
1954            ac_cv_c_tclh=${with_tclinclude}
1955        else
1956            AC_MSG_ERROR([${with_tclinclude} directory does not contain Tcl public header file tcl.h])
1957        fi
1958    else
1959        AC_CACHE_VAL(ac_cv_c_tclh, [
1960            # Use the value from --with-tclinclude, if it was given
1961
1962            if test x"${with_tclinclude}" != x ; then
1963                ac_cv_c_tclh=${with_tclinclude}
1964            else
1965                # Check in the includedir, if --prefix was specified
1966
1967                eval "temp_includedir=${includedir}"
1968                for i in \
1969                        `ls -d ${temp_includedir} 2>/dev/null` \
1970                        /usr/local/include /usr/include ; do
1971                    if test -f "$i/tcl.h" ; then
1972                        ac_cv_c_tclh=$i
1973                        break
1974                    fi
1975                done
1976            fi
1977        ])
1978    fi
1979
1980    # Print a message based on how we determined the include path
1981
1982    if test x"${ac_cv_c_tclh}" = x ; then
1983        AC_MSG_ERROR(tcl.h not found.  Please specify its location with --with-tclinclude)
1984    else
1985        AC_MSG_RESULT(${ac_cv_c_tclh})
1986    fi
1987
1988    # Convert to a native path and substitute into the output files.
1989
1990    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
1991
1992    TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
1993
1994    AC_SUBST(TCL_INCLUDES)
1995])
Note: See TracBrowser for help on using the repository browser.