1dnl aclocal.m4 generated automatically by aclocal 1.4-p5
2
3dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11dnl PARTICULAR PURPOSE.
12
13
14# serial 46 AC_PROG_LIBTOOL
15AC_DEFUN([AC_PROG_LIBTOOL],
16[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
17dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
18dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
19  AC_PROVIDE_IFELSE([AC_PROG_CXX],
20    [AC_LIBTOOL_CXX],
21    [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
22])])
23
24dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
25dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
26dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
27  AC_PROVIDE_IFELSE([AC_PROG_GCJ],
28    [AC_LIBTOOL_GCJ],
29    [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
30        [AC_LIBTOOL_GCJ],
31	[AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
32	  [AC_LIBTOOL_GCJ],
33	[ifdef([AC_PROG_GCJ],
34	       [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ
35])])
36	 ifdef([A][M_PROG_GCJ],
37	       [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ
38])])
39	 ifdef([LT_AC_PROG_GCJ],
40	       [define([LT_AC_PROG_GCJ], defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ
41])])])])])])
42
43AC_DEFUN([_AC_PROG_LIBTOOL],
44[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
45AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
46AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
47
48# Save cache, so that ltconfig can load it
49AC_CACHE_SAVE
50
51# Actually configure libtool.  ac_aux_dir is where install-sh is found.
52AR="$AR" LTCC="$CC" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
53MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
54LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
55AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
56objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
57deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \
58${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
59$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \
60|| AC_MSG_ERROR([libtool configure failed])
61
62# Reload cache, that may have been modified by ltconfig
63AC_CACHE_LOAD
64
65# This can be used to rebuild libtool when needed
66LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh $ac_aux_dir/ltcf-c.sh"
67
68# Always use our own libtool.
69LIBTOOL='$(SHELL) $(top_builddir)/libtool'
70AC_SUBST(LIBTOOL)dnl
71
72# Redirect the config.log output again, so that the ltconfig log is not
73# clobbered by the next message.
74exec 5>>./config.log
75])
76
77AC_DEFUN([AC_LIBTOOL_SETUP],
78[AC_PREREQ(2.13)dnl
79AC_REQUIRE([AC_ENABLE_SHARED])dnl
80AC_REQUIRE([AC_ENABLE_STATIC])dnl
81AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
82AC_REQUIRE([AC_CANONICAL_HOST])dnl
83AC_REQUIRE([AC_CANONICAL_BUILD])dnl
84AC_REQUIRE([AC_PROG_CC])dnl
85AC_REQUIRE([AC_PROG_LD])dnl
86AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
87AC_REQUIRE([AC_PROG_NM])dnl
88AC_REQUIRE([AC_PROG_LN_S])dnl
89AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
90# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
91AC_REQUIRE([AC_OBJEXT])dnl
92AC_REQUIRE([AC_EXEEXT])dnl
93dnl
94
95# Only perform the check for file, if the check method requires it
96case $deplibs_check_method in
97file_magic*)
98  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
99    AC_PATH_MAGIC
100  fi
101  ;;
102esac
103
104AC_CHECK_TOOL(RANLIB, ranlib, :)
105AC_CHECK_TOOL(STRIP, strip, :)
106
107# Check for any special flags to pass to ltconfig.
108libtool_flags="--cache-file=$cache_file"
109test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
110test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
111test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
112test "$GCC" = yes && libtool_flags="$libtool_flags --with-gcc"
113test "$lt_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
114ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
115[libtool_flags="$libtool_flags --enable-dlopen"])
116ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
117[libtool_flags="$libtool_flags --enable-win32-dll"])
118AC_ARG_ENABLE(libtool-lock,
119  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
120test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
121test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
122
123AC_ARG_WITH(pic,
124  [  --with-pic              try to use only PIC/non-PIC objects [default=use both]],
125     pic_mode="$withval", pic_mode=default)
126test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic"
127test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
128
129# Some flags need to be propagated to the compiler or linker for good
130# libtool support.
131case $host in
132*-*-irix6*)
133  # Find out which ABI we are using.
134  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
135  if AC_TRY_EVAL(ac_compile); then
136    case `/usr/bin/file conftest.$ac_objext` in
137    *32-bit*)
138      LD="${LD-ld} -32"
139      ;;
140    *N32*)
141      LD="${LD-ld} -n32"
142      ;;
143    *64-bit*)
144      LD="${LD-ld} -64"
145      ;;
146    esac
147  fi
148  rm -rf conftest*
149  ;;
150
151*-*-sco3.2v5*)
152  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
153  SAVE_CFLAGS="$CFLAGS"
154  CFLAGS="$CFLAGS -belf"
155  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
156    [AC_LANG_SAVE
157     AC_LANG_C
158     AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
159     AC_LANG_RESTORE])
160  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
161    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
162    CFLAGS="$SAVE_CFLAGS"
163  fi
164  ;;
165
166ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
167[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
168  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
169  AC_CHECK_TOOL(AS, as, false)
170  AC_CHECK_TOOL(OBJDUMP, objdump, false)
171
172  # recent cygwin and mingw systems supply a stub DllMain which the user
173  # can override, but on older systems we have to supply one
174  AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain,
175    [AC_TRY_LINK([],
176      [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);
177      DllMain (0, 0, 0);],
178      [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])])
179
180  case $host/$CC in
181  *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*)
182    # old mingw systems require "-dll" to link a DLL, while more recent ones
183    # require "-mdll"
184    SAVE_CFLAGS="$CFLAGS"
185    CFLAGS="$CFLAGS -mdll"
186    AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch,
187      [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])])
188    CFLAGS="$SAVE_CFLAGS" ;;
189  *-*-cygwin* | *-*-pw32*)
190    # cygwin systems need to pass --dll to the linker, and not link
191    # crt.o which will require a WinMain@16 definition.
192    lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;;
193  esac
194  ;;
195  ])
196esac
197])
198
199# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
200AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
201
202# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
203AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
204
205# AC_ENABLE_SHARED - implement the --enable-shared flag
206# Usage: AC_ENABLE_SHARED[(DEFAULT)]
207#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
208#   `yes'.
209AC_DEFUN([AC_ENABLE_SHARED],
210[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
211AC_ARG_ENABLE(shared,
212changequote(<<, >>)dnl
213<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
214changequote([, ])dnl
215[p=${PACKAGE-default}
216case $enableval in
217yes) enable_shared=yes ;;
218no) enable_shared=no ;;
219*)
220  enable_shared=no
221  # Look at the argument we got.  We use all the common list separators.
222  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
223  for pkg in $enableval; do
224    if test "X$pkg" = "X$p"; then
225      enable_shared=yes
226    fi
227  done
228  IFS="$ac_save_ifs"
229  ;;
230esac],
231enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
232])
233
234# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
235AC_DEFUN([AC_DISABLE_SHARED], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
236AC_ENABLE_SHARED(no)])
237
238# AC_ENABLE_STATIC - implement the --enable-static flag
239# Usage: AC_ENABLE_STATIC[(DEFAULT)]
240#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
241#   `yes'.
242AC_DEFUN([AC_ENABLE_STATIC],
243[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
244AC_ARG_ENABLE(static,
245changequote(<<, >>)dnl
246<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
247changequote([, ])dnl
248[p=${PACKAGE-default}
249case $enableval in
250yes) enable_static=yes ;;
251no) enable_static=no ;;
252*)
253  enable_static=no
254  # Look at the argument we got.  We use all the common list separators.
255  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
256  for pkg in $enableval; do
257    if test "X$pkg" = "X$p"; then
258      enable_static=yes
259    fi
260  done
261  IFS="$ac_save_ifs"
262  ;;
263esac],
264enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
265])
266
267# AC_DISABLE_STATIC - set the default static flag to --disable-static
268AC_DEFUN([AC_DISABLE_STATIC],
269[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
270AC_ENABLE_STATIC(no)])
271
272
273# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
274# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
275#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
276#   `yes'.
277AC_DEFUN([AC_ENABLE_FAST_INSTALL],
278[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
279AC_ARG_ENABLE(fast-install,
280changequote(<<, >>)dnl
281<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
282changequote([, ])dnl
283[p=${PACKAGE-default}
284case $enableval in
285yes) enable_fast_install=yes ;;
286no) enable_fast_install=no ;;
287*)
288  enable_fast_install=no
289  # Look at the argument we got.  We use all the common list separators.
290  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
291  for pkg in $enableval; do
292    if test "X$pkg" = "X$p"; then
293      enable_fast_install=yes
294    fi
295  done
296  IFS="$ac_save_ifs"
297  ;;
298esac],
299enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
300])
301
302# AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install
303AC_DEFUN([AC_DISABLE_FAST_INSTALL],
304[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
305AC_ENABLE_FAST_INSTALL(no)])
306
307# AC_LIBTOOL_PICMODE - implement the --with-pic flag
308# Usage: AC_LIBTOOL_PICMODE[(MODE)]
309#   Where MODE is either `yes' or `no'.  If omitted, it defaults to
310#   `both'.
311AC_DEFUN([AC_LIBTOOL_PICMODE],
312[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
313pic_mode=ifelse($#,1,$1,default)])
314
315
316# AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library
317AC_DEFUN([AC_PATH_TOOL_PREFIX],
318[AC_MSG_CHECKING([for $1])
319AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
320[case $MAGIC_CMD in
321  /*)
322  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
323  ;;
324  ?:/*)
325  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
326  ;;
327  *)
328  ac_save_MAGIC_CMD="$MAGIC_CMD"
329  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
330dnl $ac_dummy forces splitting on constant user-supplied paths.
331dnl POSIX.2 word splitting is done only on the output of word expansions,
332dnl not every word.  This closes a longstanding sh security hole.
333  ac_dummy="ifelse([$2], , $PATH, [$2])"
334  for ac_dir in $ac_dummy; do
335    test -z "$ac_dir" && ac_dir=.
336    if test -f $ac_dir/$1; then
337      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
338      if test -n "$file_magic_test_file"; then
339	case $deplibs_check_method in
340	"file_magic "*)
341	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
342	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
343	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
344	    egrep "$file_magic_regex" > /dev/null; then
345	    :
346	  else
347	    cat <<EOF 1>&2
348
349*** Warning: the command libtool uses to detect shared libraries,
350*** $file_magic_cmd, produces output that libtool cannot recognize.
351*** The result is that libtool may fail to recognize shared libraries
352*** as such.  This will affect the creation of libtool libraries that
353*** depend on shared libraries, but programs linked with such libtool
354*** libraries will work regardless of this problem.  Nevertheless, you
355*** may want to report the problem to your system manager and/or to
356*** bug-libtool@gnu.org
357
358EOF
359	  fi ;;
360	esac
361      fi
362      break
363    fi
364  done
365  IFS="$ac_save_ifs"
366  MAGIC_CMD="$ac_save_MAGIC_CMD"
367  ;;
368esac])
369MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
370if test -n "$MAGIC_CMD"; then
371  AC_MSG_RESULT($MAGIC_CMD)
372else
373  AC_MSG_RESULT(no)
374fi
375])
376
377
378# AC_PATH_MAGIC - find a file program which can recognise a shared library
379AC_DEFUN([AC_PATH_MAGIC],
380[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl
381AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin:$PATH)
382if test -z "$lt_cv_path_MAGIC_CMD"; then
383  if test -n "$ac_tool_prefix"; then
384    AC_PATH_TOOL_PREFIX(file, /usr/bin:$PATH)
385  else
386    MAGIC_CMD=:
387  fi
388fi
389])
390
391
392# AC_PROG_LD - find the path to the GNU or non-GNU linker
393AC_DEFUN([AC_PROG_LD],
394[AC_ARG_WITH(gnu-ld,
395[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
396test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
397AC_REQUIRE([AC_PROG_CC])dnl
398AC_REQUIRE([AC_CANONICAL_HOST])dnl
399AC_REQUIRE([AC_CANONICAL_BUILD])dnl
400ac_prog=ld
401if test "$GCC" = yes; then
402  # Check if gcc -print-prog-name=ld gives a path.
403  AC_MSG_CHECKING([for ld used by GCC])
404  case $host in
405  *-*-mingw*)
406    # gcc leaves a trailing carriage return which upsets mingw
407    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
408  *)
409    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
410  esac
411  case $ac_prog in
412    # Accept absolute paths.
413    [[\\/]* | [A-Za-z]:[\\/]*)]
414      re_direlt=['/[^/][^/]*/\.\./']
415      # Canonicalize the path of ld
416      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
417      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
418	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
419      done
420      test -z "$LD" && LD="$ac_prog"
421      ;;
422  "")
423    # If it fails, then pretend we aren't using GCC.
424    ac_prog=ld
425    ;;
426  *)
427    # If it is relative, then search for the first ld in PATH.
428    with_gnu_ld=unknown
429    ;;
430  esac
431elif test "$with_gnu_ld" = yes; then
432  AC_MSG_CHECKING([for GNU ld])
433else
434  AC_MSG_CHECKING([for non-GNU ld])
435fi
436AC_CACHE_VAL(lt_cv_path_LD,
437[if test -z "$LD"; then
438  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
439  for ac_dir in $PATH; do
440    test -z "$ac_dir" && ac_dir=.
441    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
442      lt_cv_path_LD="$ac_dir/$ac_prog"
443      # Check to see if the program is GNU ld.  I'd rather use --version,
444      # but apparently some GNU ld's only accept -v.
445      # Break only if it was the GNU/non-GNU ld that we prefer.
446      if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
447	test "$with_gnu_ld" != no && break
448      else
449	test "$with_gnu_ld" != yes && break
450      fi
451    fi
452  done
453  IFS="$ac_save_ifs"
454else
455  lt_cv_path_LD="$LD" # Let the user override the test with a path.
456fi])
457LD="$lt_cv_path_LD"
458if test -n "$LD"; then
459  AC_MSG_RESULT($LD)
460else
461  AC_MSG_RESULT(no)
462fi
463test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
464AC_PROG_LD_GNU
465])
466
467AC_DEFUN([AC_PROG_LD_GNU],
468[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
469[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
470if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
471  lt_cv_prog_gnu_ld=yes
472else
473  lt_cv_prog_gnu_ld=no
474fi])
475with_gnu_ld=$lt_cv_prog_gnu_ld
476])
477
478# AC_PROG_LD_RELOAD_FLAG - find reload flag for linker
479#   -- PORTME Some linkers may need a different reload flag.
480AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
481[AC_CACHE_CHECK([for $LD option to reload object files], lt_cv_ld_reload_flag,
482[lt_cv_ld_reload_flag='-r'])
483reload_flag=$lt_cv_ld_reload_flag
484test -n "$reload_flag" && reload_flag=" $reload_flag"
485])
486
487# AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies
488#  -- PORTME fill in with the dynamic library characteristics
489AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
490[AC_CACHE_CHECK([how to recognise dependant libraries],
491lt_cv_deplibs_check_method,
492[lt_cv_file_magic_cmd='$MAGIC_CMD'
493lt_cv_file_magic_test_file=
494lt_cv_deplibs_check_method='unknown'
495# Need to set the preceding variable on all platforms that support
496# interlibrary dependencies.
497# 'none' -- dependencies not supported.
498# `unknown' -- same as none, but documents that we really don't know.
499# 'pass_all' -- all dependencies passed with no checks.
500# 'test_compile' -- check by making test program.
501# 'file_magic [regex]' -- check by looking for files in library path
502# which responds to the $file_magic_cmd with a given egrep regex.
503# If you have `file' or equivalent on your system and you're not sure
504# whether `pass_all' will *always* work, you probably want this one.
505
506case $host_os in
507aix*)
508  lt_cv_deplibs_check_method=pass_all
509  ;;
510
511beos*)
512  lt_cv_deplibs_check_method=pass_all
513  ;;
514
515bsdi4*)
516  lt_cv_deplibs_check_method=['file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)']
517  lt_cv_file_magic_cmd='/usr/bin/file -L'
518  lt_cv_file_magic_test_file=/shlib/libc.so
519  ;;
520
521cygwin* | mingw* |pw32*)
522  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
523  lt_cv_file_magic_cmd='$OBJDUMP -f'
524  ;;
525
526darwin* | rhapsody*)
527  lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library'
528  lt_cv_file_magic_cmd='/usr/bin/file -L'
529  case "$host_os" in
530  rhapsody* | darwin1.[012])
531    lt_cv_file_magic_test_file='/System/Library/Frameworks/System.framework/System'
532    ;;
533  *) # Darwin 1.3 on
534    lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib'
535    ;;
536  esac
537  ;;
538
539freebsd* )
540  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
541    case $host_cpu in
542    i*86 )
543      # Not sure whether the presence of OpenBSD here was a mistake.
544      # Let's accept both of them until this is cleared up.
545      lt_cv_deplibs_check_method=['file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library']
546      lt_cv_file_magic_cmd=/usr/bin/file
547      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
548      ;;
549    esac
550  else
551    lt_cv_deplibs_check_method=pass_all
552  fi
553  ;;
554
555gnu*)
556  lt_cv_deplibs_check_method=pass_all
557  ;;
558
559hpux10.20*|hpux11*)
560  lt_cv_deplibs_check_method=['file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library']
561  lt_cv_file_magic_cmd=/usr/bin/file
562  lt_cv_file_magic_test_file=/usr/lib/libc.sl
563  ;;
564
565irix5* | irix6*)
566  case $host_os in
567  irix5*)
568    # this will be overridden with pass_all, but let us keep it just in case
569    lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
570    ;;
571  *)
572    case $LD in
573    *-32|*"-32 ") libmagic=32-bit;;
574    *-n32|*"-n32 ") libmagic=N32;;
575    *-64|*"-64 ") libmagic=64-bit;;
576    *) libmagic=never-match;;
577    esac
578    # this will be overridden with pass_all, but let us keep it just in case
579    lt_cv_deplibs_check_method=["file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"]
580    ;;
581  esac
582  lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*`
583  lt_cv_deplibs_check_method=pass_all
584  ;;
585
586# This must be Linux ELF.
587linux-gnu*)
588  case $host_cpu in
589  alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* )
590    lt_cv_deplibs_check_method=pass_all ;;
591  *)
592    # glibc up to 2.1.1 does not perform some relocations on ARM
593    lt_cv_deplibs_check_method=['file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'] ;;
594  esac
595  lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
596  ;;
597
598netbsd*)
599  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
600    [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
601  else
602    [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$']
603  fi
604  ;;
605
606newsos6)
607  [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)']
608  lt_cv_file_magic_cmd=/usr/bin/file
609  lt_cv_file_magic_test_file=/usr/lib/libnls.so
610  ;;
611
612osf3* | osf4* | osf5*)
613  # this will be overridden with pass_all, but let us keep it just in case
614  lt_cv_deplibs_check_method='file_magic COFF format alpha shared library'
615  lt_cv_file_magic_test_file=/shlib/libc.so
616  lt_cv_deplibs_check_method=pass_all
617  ;;
618
619sco3.2v5*)
620  lt_cv_deplibs_check_method=pass_all
621  ;;
622
623solaris*)
624  lt_cv_deplibs_check_method=pass_all
625  lt_cv_file_magic_test_file=/lib/libc.so
626  ;;
627
628[sysv5uw[78]* | sysv4*uw2*)]
629  lt_cv_deplibs_check_method=pass_all
630  ;;
631
632sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
633  case $host_vendor in
634  ncr)
635    lt_cv_deplibs_check_method=pass_all
636    ;;
637  motorola)
638    lt_cv_deplibs_check_method=['file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]']
639    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
640    ;;
641  esac
642  ;;
643esac
644])
645file_magic_cmd=$lt_cv_file_magic_cmd
646deplibs_check_method=$lt_cv_deplibs_check_method
647])
648
649
650# AC_PROG_NM - find the path to a BSD-compatible name lister
651AC_DEFUN([AC_PROG_NM],
652[AC_MSG_CHECKING([for BSD-compatible nm])
653AC_CACHE_VAL(lt_cv_path_NM,
654[if test -n "$NM"; then
655  # Let the user override the test.
656  lt_cv_path_NM="$NM"
657else
658  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
659  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
660    test -z "$ac_dir" && ac_dir=.
661    tmp_nm=$ac_dir/${ac_tool_prefix}nm
662    if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then
663      # Check to see if the nm accepts a BSD-compat flag.
664      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
665      #   nm: unknown option "B" ignored
666      # Tru64's nm complains that /dev/null is an invalid object file
667      if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then
668	lt_cv_path_NM="$tmp_nm -B"
669	break
670      elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
671	lt_cv_path_NM="$tmp_nm -p"
672	break
673      else
674	lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
675	continue # so that we can try to find one that supports BSD flags
676      fi
677    fi
678  done
679  IFS="$ac_save_ifs"
680  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
681fi])
682NM="$lt_cv_path_NM"
683AC_MSG_RESULT([$NM])
684])
685
686# AC_CHECK_LIBM - check for math library
687AC_DEFUN([AC_CHECK_LIBM],
688[AC_REQUIRE([AC_CANONICAL_HOST])dnl
689LIBM=
690case $host in
691*-*-beos* | *-*-cygwin* | *-*-pw32*)
692  # These system don't have libm
693  ;;
694*-ncr-sysv4.3*)
695  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
696  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
697  ;;
698*)
699  AC_CHECK_LIB(m, main, LIBM="-lm")
700  ;;
701esac
702])
703
704# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
705# the libltdl convenience library and INCLTDL to the include flags for
706# the libltdl header and adds --enable-ltdl-convenience to the
707# configure arguments.  Note that LIBLTDL and INCLTDL are not
708# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If DIR is not
709# provided, it is assumed to be `libltdl'.  LIBLTDL will be prefixed
710# with '${top_builddir}/' and INCLTDL will be prefixed with
711# '${top_srcdir}/' (note the single quotes!).  If your package is not
712# flat and you're not using automake, define top_builddir and
713# top_srcdir appropriately in the Makefiles.
714AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
715[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
716  case $enable_ltdl_convenience in
717  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
718  "") enable_ltdl_convenience=yes
719      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
720  esac
721  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
722  INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
723])
724
725# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
726# the libltdl installable library and INCLTDL to the include flags for
727# the libltdl header and adds --enable-ltdl-install to the configure
728# arguments.  Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
729# AC_CONFIG_SUBDIRS called.  If DIR is not provided and an installed
730# libltdl is not found, it is assumed to be `libltdl'.  LIBLTDL will
731# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
732# with '${top_srcdir}/' (note the single quotes!).  If your package is
733# not flat and you're not using automake, define top_builddir and
734# top_srcdir appropriately in the Makefiles.
735# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
736AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
737[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
738  AC_CHECK_LIB(ltdl, main,
739  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
740  [if test x"$enable_ltdl_install" = xno; then
741     AC_MSG_WARN([libltdl not installed, but installation disabled])
742   else
743     enable_ltdl_install=yes
744   fi
745  ])
746  if test x"$enable_ltdl_install" = x"yes"; then
747    ac_configure_args="$ac_configure_args --enable-ltdl-install"
748    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
749    INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
750  else
751    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
752    LIBLTDL="-lltdl"
753    INCLTDL=
754  fi
755])
756
757# If this macro is not defined by Autoconf, define it here.
758ifdef([AC_PROVIDE_IFELSE],
759      [],
760      [define([AC_PROVIDE_IFELSE],
761              [ifdef([AC_PROVIDE_$1],
762                     [$2], [$3])])])
763
764# AC_LIBTOOL_CXX - enable support for C++ libraries
765AC_DEFUN([AC_LIBTOOL_CXX], [AC_REQUIRE([_AC_LIBTOOL_CXX])])
766
767AC_DEFUN([_AC_LIBTOOL_CXX],
768[AC_REQUIRE([AC_PROG_CXX])
769AC_REQUIRE([AC_PROG_CXXCPP])
770LIBTOOL_DEPS=$LIBTOOL_DEPS" $ac_aux_dir/ltcf-cxx.sh"
771lt_save_CC="$CC"
772lt_save_CFLAGS="$CFLAGS"
773dnl Make sure LTCC is set to the C compiler, i.e. set LTCC before CC
774dnl is set to the C++ compiler.
775AR="$AR" LTCC="$CC" CC="$CXX" CXX="$CXX" CFLAGS="$CXXFLAGS" CPPFLAGS="$CPPFLAGS" \
776MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
777LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
778AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
779objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
780deplibs_check_method="$deplibs_check_method" \
781file_magic_cmd="$file_magic_cmd" \
782${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig -o libtool $libtool_flags \
783--build="$build" --add-tag=CXX $ac_aux_dir/ltcf-cxx.sh $host \
784|| AC_MSG_ERROR([libtool tag configuration failed])
785CC="$lt_save_CC"
786CFLAGS="$lt_save_CFLAGS"
787
788# Redirect the config.log output again, so that the ltconfig log is not
789# clobbered by the next message.
790exec 5>>./config.log
791])
792
793# AC_LIBTOOL_GCJ - enable support for GCJ libraries
794AC_DEFUN([AC_LIBTOOL_GCJ],[AC_REQUIRE([_AC_LIBTOOL_GCJ])])
795
796AC_DEFUN([_AC_LIBTOOL_GCJ],
797[AC_REQUIRE([AC_PROG_LIBTOOL])
798AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
799  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
800    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
801      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
802         [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
803           [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
804LIBTOOL_DEPS=$LIBTOOL_DEPS" $ac_aux_dir/ltcf-gcj.sh"
805lt_save_CC="$CC"
806lt_save_CFLAGS="$CFLAGS"
807dnl Make sure LTCC is set to the C compiler, i.e. set LTCC before CC
808dnl is set to the C++ compiler.
809AR="$AR" LTCC="$CC" CC="$GCJ" CFLAGS="$GCJFLAGS" CPPFLAGS="$CPPFLAGS" \
810MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
811LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
812AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
813objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
814deplibs_check_method="$deplibs_check_method" \
815file_magic_cmd="$file_magic_cmd" \
816${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig -o libtool $libtool_flags \
817--build="$build" --add-tag=GCJ $ac_aux_dir/ltcf-gcj.sh $host \
818|| AC_MSG_ERROR([libtool tag configuration failed])
819CC="$lt_save_CC"
820CFLAGS="$lt_save_CFLAGS"
821
822# Redirect the config.log output again, so that the ltconfig log is not
823# clobbered by the next message.
824exec 5>>./config.log
825])
826
827dnl old names
828AC_DEFUN([AM_PROG_LIBTOOL],   [AC_PROG_LIBTOOL])
829AC_DEFUN([AM_ENABLE_SHARED],  [AC_ENABLE_SHARED($@)])
830AC_DEFUN([AM_ENABLE_STATIC],  [AC_ENABLE_STATIC($@)])
831AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
832AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
833AC_DEFUN([AM_PROG_LD],        [AC_PROG_LD])
834AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
835
836dnl This is just to silence aclocal about the macro not being used
837ifelse([AC_DISABLE_FAST_INSTALL])dnl
838
839AC_DEFUN([LT_AC_PROG_GCJ],
840[AC_CHECK_TOOL(GCJ, gcj, no)
841  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
842  AC_SUBST(GCJFLAGS)
843])
844
845# tcl.m4 --
846#
847#	This file provides a set of autoconf macros to help TEA-enable
848#	a Tcl extension.
849#
850# Copyright (c) 1999 Scriptics Corporation.
851#
852# See the file "license.terms" for information on usage and redistribution
853# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
854
855#------------------------------------------------------------------------
856# SC_PATH_TCLCONFIG --
857#
858#	Locate the tclConfig.sh file and perform a sanity check on
859#	the Tcl compile flags
860#
861# Arguments:
862#	none
863#
864# Results:
865#
866#	Adds the following arguments to configure:
867#		--with-tcl=...
868#
869#	Defines the following vars:
870#		TCL_BIN_DIR	Full path to the directory containing
871#				the tclConfig.sh file
872#------------------------------------------------------------------------
873
874AC_DEFUN(SC_PATH_TCLCONFIG, [
875    #
876    # Ok, lets find the tcl configuration
877    # First, look for one uninstalled.
878    # the alternative search directory is invoked by --with-tcl
879    #
880
881    if test x"${no_tcl}" = x ; then
882	# we reset no_tcl in case something fails here
883	no_tcl=true
884	AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
885	AC_MSG_CHECKING([for Tcl configuration])
886	AC_CACHE_VAL(ac_cv_c_tclconfig,[
887
888	    # First check to see if --with-tcl was specified.
889	    if test x"${with_tclconfig}" != x ; then
890		if test -f "${with_tclconfig}/tclConfig.sh" ; then
891		    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
892		else
893		    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
894		fi
895	    fi
896
897	    # then check for a private Tcl installation
898	    if test x"${ac_cv_c_tclconfig}" = x ; then
899		for i in \
900			../tcl \
901			`ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
902			../../tcl \
903			`ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
904			../../../tcl \
905			`ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
906		    if test -f "$i/unix/tclConfig.sh" ; then
907			ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
908			break
909		    fi
910		done
911	    fi
912
913	    # check in a few common install locations
914	    if test x"${ac_cv_c_tclconfig}" = x ; then
915		for i in `ls -d ${prefix}/lib 2>/dev/null` \
916			`ls -d /usr/local/lib 2>/dev/null` ; do
917		    if test -f "$i/tclConfig.sh" ; then
918			ac_cv_c_tclconfig=`(cd $i; pwd)`
919			break
920		    fi
921		done
922	    fi
923
924	    # check in a few other private locations
925	    if test x"${ac_cv_c_tclconfig}" = x ; then
926		for i in \
927			${srcdir}/../tcl \
928			`ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
929		    if test -f "$i/unix/tclConfig.sh" ; then
930		    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
931		    break
932		fi
933		done
934	    fi
935	])
936
937	if test x"${ac_cv_c_tclconfig}" = x ; then
938	    TCL_BIN_DIR="# no Tcl configs found"
939	    AC_MSG_WARN(Can't find Tcl configuration definitions)
940	    exit 0
941	else
942	    no_tcl=
943	    TCL_BIN_DIR=${ac_cv_c_tclconfig}
944	    AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
945	fi
946    fi
947])
948
949#------------------------------------------------------------------------
950# SC_PATH_TKCONFIG --
951#
952#	Locate the tkConfig.sh file
953#
954# Arguments:
955#	none
956#
957# Results:
958#
959#	Adds the following arguments to configure:
960#		--with-tk=...
961#
962#	Defines the following vars:
963#		TK_BIN_DIR	Full path to the directory containing
964#				the tkConfig.sh file
965#------------------------------------------------------------------------
966
967AC_DEFUN(SC_PATH_TKCONFIG, [
968    #
969    # Ok, lets find the tk configuration
970    # First, look for one uninstalled.
971    # the alternative search directory is invoked by --with-tk
972    #
973
974    if test x"${no_tk}" = x ; then
975	# we reset no_tk in case something fails here
976	no_tk=true
977	AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
978	AC_MSG_CHECKING([for Tk configuration])
979	AC_CACHE_VAL(ac_cv_c_tkconfig,[
980
981	    # First check to see if --with-tkconfig was specified.
982	    if test x"${with_tkconfig}" != x ; then
983		if test -f "${with_tkconfig}/tkConfig.sh" ; then
984		    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
985		else
986		    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
987		fi
988	    fi
989
990	    # then check for a private Tk library
991	    if test x"${ac_cv_c_tkconfig}" = x ; then
992		for i in \
993			../tk \
994			`ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
995			../../tk \
996			`ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
997			../../../tk \
998			`ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
999		    if test -f "$i/unix/tkConfig.sh" ; then
1000			ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
1001			break
1002		    fi
1003		done
1004	    fi
1005	    # check in a few common install locations
1006	    if test x"${ac_cv_c_tkconfig}" = x ; then
1007		for i in `ls -d ${prefix}/lib 2>/dev/null` \
1008			`ls -d /usr/local/lib 2>/dev/null` ; do
1009		    if test -f "$i/tkConfig.sh" ; then
1010			ac_cv_c_tkconfig=`(cd $i; pwd)`
1011			break
1012		    fi
1013		done
1014	    fi
1015	    # check in a few other private locations
1016	    if test x"${ac_cv_c_tkconfig}" = x ; then
1017		for i in \
1018			${srcdir}/../tk \
1019			`ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
1020		    if test -f "$i/unix/tkConfig.sh" ; then
1021			ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
1022			break
1023		    fi
1024		done
1025	    fi
1026	])
1027	if test x"${ac_cv_c_tkconfig}" = x ; then
1028	    TK_BIN_DIR="# no Tk configs found"
1029	    AC_MSG_WARN(Can't find Tk configuration definitions)
1030	    exit 0
1031	else
1032	    no_tk=
1033	    TK_BIN_DIR=${ac_cv_c_tkconfig}
1034	    AC_MSG_RESULT(found $TK_BIN_DIR/tkConfig.sh)
1035	fi
1036    fi
1037
1038])
1039
1040#------------------------------------------------------------------------
1041# SC_LOAD_TCLCONFIG --
1042#
1043#	Load the tclConfig.sh file
1044#
1045# Arguments:
1046#
1047#	Requires the following vars to be set:
1048#		TCL_BIN_DIR
1049#
1050# Results:
1051#
1052#	Subst the following vars:
1053#		TCL_BIN_DIR
1054#		TCL_SRC_DIR
1055#		TCL_LIB_FILE
1056#
1057#------------------------------------------------------------------------
1058
1059AC_DEFUN(SC_LOAD_TCLCONFIG, [
1060    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
1061
1062    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
1063        AC_MSG_RESULT([loading])
1064	. $TCL_BIN_DIR/tclConfig.sh
1065    else
1066        AC_MSG_RESULT([file not found])
1067    fi
1068
1069    #
1070    # The eval is required to do the TCL_DBGX substitution in the
1071    # TCL_LIB_FILE variable
1072    #
1073
1074    eval TCL_LIB_FILE=${TCL_LIB_FILE}
1075    eval TCL_LIB_FLAG=${TCL_LIB_FLAG}
1076
1077    AC_SUBST(TCL_DBGX)
1078    AC_SUBST(TCL_BIN_DIR)
1079    AC_SUBST(TCL_SRC_DIR)
1080    AC_SUBST(TCL_LIB_FILE)
1081    AC_SUBST(TCL_LIBS)
1082    AC_SUBST(TCL_DEFS)
1083    AC_SUBST(TCL_SHLIB_LD_LIBS)
1084    AC_SUBST(TCL_EXTRA_CFLAGS)
1085    AC_SUBST(TCL_LD_FLAGS)
1086    AC_SUBST(TCL_LIB_FILE)
1087    AC_SUBST(TCL_STUB_LIB_FILE)
1088    AC_SUBST(TCL_LIB_SPEC)
1089    AC_SUBST(TCL_BUILD_LIB_SPEC)
1090    AC_SUBST(TCL_STUB_LIB_SPEC)
1091    AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
1092])
1093
1094#------------------------------------------------------------------------
1095# SC_LOAD_TKCONFIG --
1096#
1097#	Load the tkConfig.sh file
1098#
1099# Arguments:
1100#
1101#	Requires the following vars to be set:
1102#		TK_BIN_DIR
1103#
1104# Results:
1105#
1106#	Sets the following vars that should be in tkConfig.sh:
1107#		TK_BIN_DIR
1108#------------------------------------------------------------------------
1109
1110AC_DEFUN(SC_LOAD_TKCONFIG, [
1111    AC_MSG_CHECKING([for existence of $TK_BIN_DIR/tkConfig.sh])
1112
1113    if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
1114        AC_MSG_RESULT([loading])
1115	. $TK_BIN_DIR/tkConfig.sh
1116    else
1117        AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
1118    fi
1119
1120    AC_SUBST(TK_BIN_DIR)
1121    AC_SUBST(TK_SRC_DIR)
1122    AC_SUBST(TK_LIB_FILE)
1123    AC_SUBST(TK_XINCLUDES)
1124])
1125
1126#------------------------------------------------------------------------
1127# SC_ENABLE_GCC --
1128#
1129#	Allows the use of GCC if available
1130#
1131# Arguments:
1132#	none
1133#
1134# Results:
1135#
1136#	Adds the following arguments to configure:
1137#		--enable-gcc
1138#
1139#	Sets the following vars:
1140#		CC	Command to use for the compiler
1141#------------------------------------------------------------------------
1142
1143AC_DEFUN(SC_ENABLE_GCC, [
1144    AC_ARG_ENABLE(gcc, [  --enable-gcc            allow use of gcc if available [--disable-gcc]],
1145	[ok=$enableval], [ok=no])
1146    if test "$ok" = "yes"; then
1147	CC=gcc
1148    else
1149	case "`uname -s`" in
1150	    *win32* | *WIN32* | *CYGWIN_NT* | *CYGWIN_98* | *CYGWIN_95*)
1151		CC=cl
1152	    ;;
1153	    *)
1154		CC=${CC-cc}
1155	    ;;
1156	esac
1157    fi
1158    AC_PROG_CC
1159])
1160
1161#------------------------------------------------------------------------
1162# SC_ENABLE_SHARED --
1163#
1164#	Allows the building of shared libraries
1165#
1166# Arguments:
1167#	none
1168#
1169# Results:
1170#
1171#	Adds the following arguments to configure:
1172#		--enable-shared=yes|no
1173#
1174#	Defines the following vars:
1175#		STATIC_BUILD	Used for building import/export libraries
1176#				on Windows.
1177#
1178#	Sets the following vars:
1179#		SHARED_BUILD	Value of 1 or 0
1180#------------------------------------------------------------------------
1181
1182AC_DEFUN(SC_ENABLE_SHARED, [
1183    AC_MSG_CHECKING([how to build libraries])
1184    AC_ARG_ENABLE(shared,
1185	[  --enable-shared         build and link with shared libraries [--enable-shared]],
1186	[tcl_ok=$enableval], [tcl_ok=yes])
1187
1188    if test "${enable_shared+set}" = set; then
1189	enableval="$enable_shared"
1190	tcl_ok=$enableval
1191    else
1192	tcl_ok=yes
1193    fi
1194
1195    if test "$tcl_ok" = "yes" ; then
1196	AC_MSG_RESULT([shared])
1197	SHARED_BUILD=1
1198    else
1199	AC_MSG_RESULT([static])
1200	SHARED_BUILD=0
1201	AC_DEFINE(STATIC_BUILD)
1202    fi
1203])
1204
1205#------------------------------------------------------------------------
1206# SC_ENABLE_THREADS --
1207#
1208#	Specify if thread support should be enabled
1209#
1210# Arguments:
1211#	none
1212#
1213# Results:
1214#
1215#	Adds the following arguments to configure:
1216#		--enable-threads
1217#
1218#	Sets the following vars:
1219#		THREADS_LIBS	Thread library(s)
1220#
1221#	Defines the following vars:
1222#		TCL_THREADS
1223#		_REENTRANT
1224#
1225#------------------------------------------------------------------------
1226
1227AC_DEFUN(SC_ENABLE_THREADS, [
1228    AC_MSG_CHECKING(for building with threads)
1229    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
1230	[tcl_ok=$enableval], [tcl_ok=no])
1231
1232    if test "$tcl_ok" = "yes"; then
1233	TCL_THREADS=1
1234	AC_DEFINE(TCL_THREADS)
1235	AC_DEFINE(_REENTRANT)
1236
1237	case "`uname -s`" in
1238	    *win32* | *WIN32* | *CYGWIN_NT* | *CYGWIN_98* | *CYGWIN_95*)
1239		    AC_MSG_RESULT(yes)
1240		;;
1241	    *)
1242		AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
1243		if test "$tcl_ok" = "yes"; then
1244		    # The space is needed
1245		    THREADS_LIBS=" -lpthread"
1246		    AC_MSG_RESULT(yes)
1247		else
1248		    TCL_THREADS=0
1249		    AC_MSG_RESULT(no)
1250		    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...")
1251		fi
1252		;;
1253	esac
1254    else
1255	TCL_THREADS=0
1256	AC_MSG_RESULT(no (default))
1257    fi
1258
1259])
1260
1261#------------------------------------------------------------------------
1262# SC_ENABLE_SYMBOLS --
1263#
1264#	Specify if debugging symbols should be used
1265#
1266# Arguments:
1267#	none
1268#
1269#	Requires the following vars to be set:
1270#		CFLAGS_DEBUG
1271#		CFLAGS_OPTIMIZE
1272#		LDFLAGS_DEBUG
1273#		LDFLAGS_OPTIMIZE
1274#
1275# Results:
1276#
1277#	Adds the following arguments to configure:
1278#		--enable-symbols
1279#
1280#	Defines the following vars:
1281#		CFLAGS_DEFAULT	Sets to CFLAGS_DEBUG if true
1282#				Sets to CFLAGS_OPTIMIZE if false
1283#		LDFLAGS_DEFAULT	Sets to LDFLAGS_DEBUG if true
1284#				Sets to LDFLAGS_OPTIMIZE if false
1285#		DBGX		Debug library extension
1286#
1287#------------------------------------------------------------------------
1288
1289AC_DEFUN(SC_ENABLE_SYMBOLS, [
1290    case "`uname -s`" in
1291	*win32* | *WIN32* | *CYGWIN_NT* | *CYGWIN_98* | *CYGWIN_95*)
1292	    tcl_dbgx=d
1293	;;
1294	*)
1295	    tcl_dbgx=g
1296	;;
1297    esac
1298
1299    AC_MSG_CHECKING([for build with symbols])
1300    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
1301    if test "$tcl_ok" = "yes"; then
1302	CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
1303	LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
1304	DBGX=${tcl_dbgx}
1305	TCL_DBGX=${tcl_dbgx}
1306	AC_MSG_RESULT([yes])
1307    else
1308	CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
1309	LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
1310	DBGX=""
1311	TCL_DBGX=""
1312	AC_MSG_RESULT([no])
1313    fi
1314
1315    AC_SUBST(TCL_DBGX)
1316    AC_SUBST(CFLAGS_DEFAULT)
1317    AC_SUBST(LDFLAGS_DEFAULT)
1318])
1319
1320#--------------------------------------------------------------------
1321# SC_CONFIG_CFLAGS
1322#
1323#	Try to determine the proper flags to pass to the compiler
1324#	for building shared libraries and other such nonsense.
1325#
1326# Arguments:
1327#	none
1328#
1329# Results:
1330#
1331#	Defines the following vars:
1332#
1333#       DL_OBJS -       Name of the object file that implements dynamic
1334#                       loading for Tcl on this system.
1335#       DL_LIBS -       Library file(s) to include in tclsh and other base
1336#                       applications in order for the "load" command to work.
1337#       LDFLAGS -      Flags to pass to the compiler when linking object
1338#                       files into an executable application binary such
1339#                       as tclsh.
1340#       LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
1341#                       that tell the run-time dynamic linker where to look
1342#                       for shared libraries such as libtcl.so.  Depends on
1343#                       the variable LIB_RUNTIME_DIR in the Makefile.
1344#       MAKE_LIB -      Command to execute to build the Tcl library;
1345#                       differs depending on whether or not Tcl is being
1346#                       compiled as a shared library.
1347#       SHLIB_CFLAGS -  Flags to pass to cc when compiling the components
1348#                       of a shared library (may request position-independent
1349#                       code, among other things).
1350#       SHLIB_LD -      Base command to use for combining object files
1351#                       into a shared library.
1352#       SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
1353#                       creating shared libraries.  This symbol typically
1354#                       goes at the end of the "ld" commands that build
1355#                       shared libraries. The value of the symbol is
1356#                       "${LIBS}" if all of the dependent libraries should
1357#                       be specified when creating a shared library.  If
1358#                       dependent libraries should not be specified (as on
1359#                       SunOS 4.x, where they cause the link to fail, or in
1360#                       general if Tcl and Tk aren't themselves shared
1361#                       libraries), then this symbol has an empty string
1362#                       as its value.
1363#       SHLIB_SUFFIX -  Suffix to use for the names of dynamically loadable
1364#                       extensions.  An empty string means we don't know how
1365#                       to use shared libraries on this platform.
1366#       TCL_LIB_FILE -  Name of the file that contains the Tcl library, such
1367#                       as libtcl7.8.so or libtcl7.8.a.
1368#       TCL_LIB_SUFFIX -Specifies everything that comes after the "libtcl"
1369#                       in the shared library name, using the $VERSION variable
1370#                       to put the version in the right place.  This is used
1371#                       by platforms that need non-standard library names.
1372#                       Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
1373#                       to have a version after the .so, and ${VERSION}.a
1374#                       on AIX, since the Tcl shared library needs to have
1375#                       a .a extension whereas shared objects for loadable
1376#                       extensions have a .so extension.  Defaults to
1377#                       ${VERSION}${SHLIB_SUFFIX}.
1378#       TCL_NEEDS_EXP_FILE -
1379#                       1 means that an export file is needed to link to a
1380#                       shared library.
1381#       TCL_EXP_FILE -  The name of the installed export / import file which
1382#                       should be used to link to the Tcl shared library.
1383#                       Empty if Tcl is unshared.
1384#       TCL_BUILD_EXP_FILE -
1385#                       The name of the built export / import file which
1386#                       should be used to link to the Tcl shared library.
1387#                       Empty if Tcl is unshared.
1388#	CFLAGS_DEBUG -
1389#			Flags used when running the compiler in debug mode
1390#	CFLAGS_OPTIMIZE -
1391#			Flags used when running the compiler in optimize mode
1392#
1393#	EXTRA_CFLAGS
1394#
1395#	Subst's the following vars:
1396#		DL_LIBS
1397#		CFLAGS_DEBUG
1398#		CFLAGS_OPTIMIZE
1399#--------------------------------------------------------------------
1400
1401AC_DEFUN(SC_CONFIG_CFLAGS, [
1402
1403    # Step 0: Enable 64 bit support?
1404
1405    AC_MSG_CHECKING([if 64bit support is enabled])
1406    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support],,enableval="no")
1407
1408    if test "$enableval" = "yes"; then
1409	AC_MSG_RESULT(Will compile with 64bit support)
1410	do64bit=yes
1411    else
1412	do64bit=no
1413    fi
1414    AC_MSG_RESULT($do64bit)
1415
1416    # Step 1: set the variable "system" to hold the name and version number
1417    # for the system.  This can usually be done via the "uname" command, but
1418    # there are a few systems, like Next, where this doesn't work.
1419
1420    AC_MSG_CHECKING([system version (for dynamic loading)])
1421    if test -f /usr/lib/NextStep/software_version; then
1422	system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
1423    else
1424	system=`uname -s`-`uname -r`
1425	if test "$?" -ne 0 ; then
1426	    AC_MSG_RESULT([unknown (can't find uname command)])
1427	    system=unknown
1428	else
1429	    # Special check for weird MP-RAS system (uname returns weird
1430	    # results, and the version is kept in special file).
1431
1432	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
1433		system=MP-RAS-`awk '{print $3}' /etc/.relid'`
1434	    fi
1435	    if test "`uname -s`" = "AIX" ; then
1436		system=AIX-`uname -v`.`uname -r`
1437	    fi
1438	    AC_MSG_RESULT($system)
1439	fi
1440    fi
1441
1442    # Step 2: check for existence of -ldl library.  This is needed because
1443    # Linux can use either -ldl or -ldld for dynamic loading.
1444
1445    AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
1446
1447    # Step 3: set configuration options based on system name and version.
1448
1449    do64bit_ok=no
1450    fullSrcDir=`cd $srcdir; pwd`
1451    EXTRA_CFLAGS=""
1452    TCL_EXPORT_FILE_SUFFIX=""
1453    UNSHARED_LIB_SUFFIX=""
1454    TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
1455    ECHO_VERSION='`echo ${VERSION}`'
1456    TCL_LIB_VERSIONS_OK=ok
1457    CFLAGS_DEBUG=-g
1458    CFLAGS_OPTIMIZE=-O
1459    TCL_NEEDS_EXP_FILE=0
1460    TCL_BUILD_EXP_FILE=""
1461    TCL_EXP_FILE=""
1462    STLIB_LD="ar cr"
1463    case $system in
1464	AIX-4.[[2-9]])
1465	    SHLIB_CFLAGS=""
1466	    SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
1467	    SHLIB_LD_LIBS='${LIBS}'
1468	    SHLIB_SUFFIX=".so"
1469	    DL_OBJS="tclLoadDl.o"
1470	    DL_LIBS="-ldl"
1471	    LDFLAGS=""
1472	    LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1473	    TCL_NEEDS_EXP_FILE=1
1474	    TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
1475	    ;;
1476	AIX-*)
1477	    SHLIB_CFLAGS=""
1478	    SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512"
1479	    SHLIB_LD_LIBS='${LIBS}'
1480	    SHLIB_SUFFIX=".so"
1481	    DL_OBJS="tclLoadDl.o"
1482	    LIBOBJS="$LIBOBJS tclLoadAix.o"
1483	    DL_LIBS="-lld"
1484	    LDFLAGS=""
1485	    LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1486	    TCL_NEEDS_EXP_FILE=1
1487	    TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
1488	    ;;
1489	BSD/OS-2.1*|BSD/OS-3*)
1490	    SHLIB_CFLAGS=""
1491	    SHLIB_LD="shlicc -r"
1492	    SHLIB_LD_LIBS='${LIBS}'
1493	    SHLIB_SUFFIX=".so"
1494	    DL_OBJS="tclLoadDl.o"
1495	    DL_LIBS="-ldl"
1496	    LDFLAGS=""
1497	    LD_SEARCH_FLAGS=""
1498	    ;;
1499	BSD/OS-4.*)
1500	    SHLIB_CFLAGS="-export-dynamic -fPIC"
1501	    SHLIB_LD="cc -shared"
1502	    SHLIB_LD_LIBS='${LIBS}'
1503	    SHLIB_SUFFIX=".so"
1504	    DL_OBJS="tclLoadDl.o"
1505	    DL_LIBS="-ldl"
1506	    LDFLAGS="-export-dynamic"
1507	    LD_SEARCH_FLAGS=""
1508	    ;;
1509	*win32*|*WIN32*|CYGWIN_NT*|cygwin_nt*|*CYGWIN_98*|*CYGWIN_95*)
1510	    CFLAGS_DEBUG="-nologo -Z7 -Od -WX ${runtime}d"
1511	    CFLAGS_OPTIMIZE="-nologo -Oti -Gs -GD ${runtime}"
1512	    LDFLAGS_CONSOLE="-subsystem:console"
1513	    LDFLAGS_WINDOW="-subsystem:windows"
1514	    LDFLAGS_DEBUG="-debug:full -debugtype:cv"
1515	    LDFLAGS_OPTIMIZE="-release"
1516	    EXTRA_CFLAGS="-YX"
1517	    PATHTYPE=-w
1518	    STLIB_LD="lib -nologo"
1519	    SHLIB_LD="link -dll -nologo"
1520	    SHLIB_LD_LIBS="user32.lib advapi32.lib"
1521	    RC="rc"
1522	    ;;
1523	dgux*)
1524	    SHLIB_CFLAGS="-K PIC"
1525	    SHLIB_LD="cc -G"
1526	    SHLIB_LD_LIBS=""
1527	    SHLIB_SUFFIX=".so"
1528	    DL_OBJS="tclLoadDl.o"
1529	    DL_LIBS="-ldl"
1530	    LDFLAGS=""
1531	    LD_SEARCH_FLAGS=""
1532	    ;;
1533	HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*|HP-UX-*.11.*)
1534	    SHLIB_SUFFIX=".sl"
1535	    AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
1536	    if test "$tcl_ok" = yes; then
1537		SHLIB_CFLAGS="+z"
1538		SHLIB_LD="ld -b"
1539		SHLIB_LD_LIBS=""
1540		DL_OBJS="tclLoadShl.o"
1541		DL_LIBS="-ldld"
1542		LDFLAGS="-Wl,-E"
1543		LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
1544	    fi
1545	    ;;
1546	IRIX-4.*)
1547	    SHLIB_CFLAGS="-G 0"
1548	    SHLIB_SUFFIX=".a"
1549	    SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1550	    SHLIB_LD_LIBS='${LIBS}'
1551	    DL_OBJS="tclLoadAout.o"
1552	    DL_LIBS=""
1553	    LDFLAGS="-Wl,-D,08000000"
1554	    LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1555	    SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1556	    ;;
1557	IRIX-5.*|IRIX-6.*|IRIX64-6.5*)
1558	    SHLIB_CFLAGS=""
1559	    SHLIB_LD="ld -n32 -shared -rdata_shared"
1560	    SHLIB_LD_LIBS=""
1561	    SHLIB_SUFFIX=".so"
1562	    DL_OBJS="tclLoadDl.o"
1563	    DL_LIBS=""
1564	    LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1565	    if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
1566		EXTRA_CFLAGS="-mabi=n32"
1567		LDFLAGS="-mabi=n32"
1568	    else
1569		case $system in
1570		    IRIX-6.3)
1571			# Use to build 6.2 compatible binaries on 6.3.
1572			EXTRA_CFLAGS="-n32 -D_OLD_TERMIOS"
1573			;;
1574		    *)
1575			EXTRA_CFLAGS="-n32"
1576			;;
1577		esac
1578		LDFLAGS="-n32"
1579	    fi
1580	    ;;
1581	IRIX64-6.*)
1582	    SHLIB_CFLAGS=""
1583	    SHLIB_LD="ld -32 -shared -rdata_shared"
1584	    SHLIB_LD_LIBS='${LIBS}'
1585	    SHLIB_SUFFIX=".so"
1586	    DL_OBJS="tclLoadDl.o"
1587	    DL_LIBS=""
1588	    LDFLAGS=""
1589	    LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1590	    ;;
1591	Linux*)
1592	    SHLIB_CFLAGS="-fPIC"
1593	    SHLIB_LD_LIBS='${LIBS}'
1594	    SHLIB_SUFFIX=".so"
1595
1596	    # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
1597	    # when you inline the string and math operations.  Turn this off to
1598	    # get rid of the warnings.
1599
1600	    CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
1601
1602	    if test "$have_dl" = yes; then
1603		SHLIB_LD="${CC} -shared"
1604		DL_OBJS="tclLoadDl.o"
1605		DL_LIBS="-ldl"
1606		LDFLAGS="-rdynamic"
1607		LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1608	    else
1609		AC_CHECK_HEADER(dld.h, [
1610		    SHLIB_LD="ld -shared"
1611		    DL_OBJS="tclLoadDld.o"
1612		    DL_LIBS="-ldld"
1613		    LDFLAGS=""
1614		    LD_SEARCH_FLAGS=""])
1615	    fi
1616	    if test "`uname -m`" = "alpha" ; then
1617		EXTRA_CFLAGS="-mieee"
1618	    fi
1619	    ;;
1620	MP-RAS-02*)
1621	    SHLIB_CFLAGS="-K PIC"
1622	    SHLIB_LD="cc -G"
1623	    SHLIB_LD_LIBS=""
1624	    SHLIB_SUFFIX=".so"
1625	    DL_OBJS="tclLoadDl.o"
1626	    DL_LIBS="-ldl"
1627	    LDFLAGS=""
1628	    LD_SEARCH_FLAGS=""
1629	    ;;
1630	MP-RAS-*)
1631	    SHLIB_CFLAGS="-K PIC"
1632	    SHLIB_LD="cc -G"
1633	    SHLIB_LD_LIBS=""
1634	    SHLIB_SUFFIX=".so"
1635	    DL_OBJS="tclLoadDl.o"
1636	    DL_LIBS="-ldl"
1637	    LDFLAGS="-Wl,-Bexport"
1638	    LD_SEARCH_FLAGS=""
1639	    ;;
1640	NetBSD-*|FreeBSD-[[12]].*|OpenBSD-*)
1641	    # Not available on all versions:  check for include file.
1642	    AC_CHECK_HEADER(dlfcn.h, [
1643		SHLIB_CFLAGS="-fpic"
1644		SHLIB_LD="ld -Bshareable -x"
1645		SHLIB_LD_LIBS=""
1646		SHLIB_SUFFIX=".so"
1647		DL_OBJS="tclLoadDl.o"
1648		DL_LIBS=""
1649		LDFLAGS=""
1650		LD_SEARCH_FLAGS=""
1651		SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1652	    ], [
1653		SHLIB_CFLAGS=""
1654		SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
1655		SHLIB_LD_LIBS='${LIBS}'
1656		SHLIB_SUFFIX=".a"
1657		DL_OBJS="tclLoadAout.o"
1658		DL_LIBS=""
1659		LDFLAGS=""
1660		LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1661		SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1662	    ])
1663
1664	    # FreeBSD doesn't handle version numbers with dots.
1665
1666	    UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1667	    TCL_LIB_VERSIONS_OK=nodots
1668	    ;;
1669	FreeBSD-*)
1670	    # FreeBSD 3.* and greater have ELF.
1671	    SHLIB_CFLAGS="-fpic"
1672	    SHLIB_LD="ld -Bshareable -x"
1673	    SHLIB_LD_LIBS=""
1674	    SHLIB_SUFFIX=".so"
1675	    DL_OBJS="tclLoadDl.o"
1676	    DL_LIBS=""
1677	    LDFLAGS=""
1678	    LD_SEARCH_FLAGS=""
1679	    ;;
1680	NEXTSTEP-*)
1681	    SHLIB_CFLAGS=""
1682	    SHLIB_LD="cc -nostdlib -r"
1683	    SHLIB_LD_LIBS=""
1684	    SHLIB_SUFFIX=".so"
1685	    DL_OBJS="tclLoadNext.o"
1686	    DL_LIBS=""
1687	    LDFLAGS=""
1688	    LD_SEARCH_FLAGS=""
1689	    ;;
1690	OS/390-*)
1691	    CFLAGS_OPTIMIZE=""      # Optimizer is buggy
1692	    AC_DEFINE(_OE_SOCKETS)  # needed in sys/socket.h
1693	    ;;
1694	OSF1-1.0|OSF1-1.1|OSF1-1.2)
1695	    # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
1696	    SHLIB_CFLAGS=""
1697	    # Hack: make package name same as library name
1698	    SHLIB_LD='ld -R -export $@:'
1699	    SHLIB_LD_LIBS=""
1700	    SHLIB_SUFFIX=".so"
1701	    DL_OBJS="tclLoadOSF.o"
1702	    DL_LIBS=""
1703	    LDFLAGS=""
1704	    LD_SEARCH_FLAGS=""
1705	    ;;
1706	OSF1-1.*)
1707	    # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
1708	    SHLIB_CFLAGS="-fpic"
1709	    SHLIB_LD="ld -shared"
1710	    SHLIB_LD_LIBS=""
1711	    SHLIB_SUFFIX=".so"
1712	    DL_OBJS="tclLoadDl.o"
1713	    DL_LIBS=""
1714	    LDFLAGS=""
1715	    LD_SEARCH_FLAGS=""
1716	    ;;
1717	OSF1-V*)
1718	    # Digital OSF/1
1719	    SHLIB_CFLAGS=""
1720	    SHLIB_LD='ld -shared -expect_unresolved "*"'
1721	    SHLIB_LD_LIBS=""
1722	    SHLIB_SUFFIX=".so"
1723	    DL_OBJS="tclLoadDl.o"
1724	    DL_LIBS=""
1725	    LDFLAGS=""
1726	    LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1727	    ;;
1728	RISCos-*)
1729	    SHLIB_CFLAGS="-G 0"
1730	    SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1731	    SHLIB_LD_LIBS='${LIBS}'
1732	    SHLIB_SUFFIX=".a"
1733	    DL_OBJS="tclLoadAout.o"
1734	    DL_LIBS=""
1735	    LDFLAGS="-Wl,-D,08000000"
1736	    LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1737	    ;;
1738	SCO_SV-3.2*)
1739	    # Note, dlopen is available only on SCO 3.2.5 and greater.  However,
1740	    # this test works, since "uname -s" was non-standard in 3.2.4 and
1741	    # below.
1742	    SHLIB_CFLAGS="-Kpic -belf"
1743	    SHLIB_LD="ld -G"
1744	    SHLIB_LD_LIBS=""
1745	    SHLIB_SUFFIX=".so"
1746	    DL_OBJS="tclLoadDl.o"
1747	    DL_LIBS=""
1748	    LDFLAGS="-belf -Wl,-Bexport"
1749	    LD_SEARCH_FLAGS=""
1750	    ;;
1751	SINIX*5.4*)
1752	    SHLIB_CFLAGS="-K PIC"
1753	    SHLIB_LD="cc -G"
1754	    SHLIB_LD_LIBS=""
1755	    SHLIB_SUFFIX=".so"
1756	    DL_OBJS="tclLoadDl.o"
1757	    DL_LIBS="-ldl"
1758	    LDFLAGS=""
1759	    LD_SEARCH_FLAGS=""
1760	    ;;
1761	SunOS-4*)
1762	    SHLIB_CFLAGS="-PIC"
1763	    SHLIB_LD="ld"
1764	    SHLIB_LD_LIBS=""
1765	    SHLIB_SUFFIX=".so"
1766	    DL_OBJS="tclLoadDl.o"
1767	    DL_LIBS="-ldl"
1768	    LDFLAGS=""
1769	    LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1770
1771	    # SunOS can't handle version numbers with dots in them in library
1772	    # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
1773	    # requires an extra version number at the end of .so file names.
1774	    # So, the library has to have a name like libtcl75.so.1.0
1775
1776	    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
1777	    UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
1778	    TCL_LIB_VERSIONS_OK=nodots
1779	    ;;
1780	SunOS-5.[[0-6]]*)
1781	    SHLIB_CFLAGS="-KPIC"
1782	    SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1783
1784	    # Note: need the LIBS below, otherwise Tk won't find Tcl's
1785	    # symbols when dynamically loaded into tclsh.
1786
1787	    SHLIB_LD_LIBS='${LIBS}'
1788	    SHLIB_SUFFIX=".so"
1789	    DL_OBJS="tclLoadDl.o"
1790	    DL_LIBS="-ldl"
1791	    LDFLAGS=""
1792	    LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1793	    ;;
1794	SunOS-5*)
1795	    SHLIB_CFLAGS="-KPIC"
1796	    SHLIB_LD="/usr/ccs/bin/ld -G -z text"
1797	    LDFLAGS=""
1798
1799	    do64bit_ok=no
1800	    if test "$do64bit" = "yes" ; then
1801	    arch=`isainfo`
1802	    if test "$arch" = "sparcv9 sparc" ; then
1803		if test "$CC" != "gcc" -a `$CC -v 2>&1 | grep -c gcc` = "0" ; then
1804		do64bit_ok=yes
1805		EXTRA_CFLAGS="-xarch=v9"
1806		LDFLAGS="-xarch=v9"
1807		else
1808		AC_MSG_WARN("64bit mode not supported using GCC on $system")
1809		fi
1810	    else
1811		AC_MSG_WARN("64bit mode only supported sparcv9 system")
1812	    fi
1813	    fi
1814
1815	    # Note: need the LIBS below, otherwise Tk won't find Tcl's
1816	    # symbols when dynamically loaded into tclsh.
1817
1818	    SHLIB_LD_LIBS='${LIBS}'
1819	    SHLIB_SUFFIX=".so"
1820	    DL_OBJS="tclLoadDl.o"
1821	    DL_LIBS="-ldl"
1822	    if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
1823		LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
1824	    else
1825		LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
1826	    fi
1827	    ;;
1828	ULTRIX-4.*)
1829	    SHLIB_CFLAGS="-G 0"
1830	    SHLIB_SUFFIX=".a"
1831	    SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
1832	    SHLIB_LD_LIBS='${LIBS}'
1833	    DL_OBJS="tclLoadAout.o"
1834	    DL_LIBS=""
1835	    LDFLAGS="-Wl,-D,08000000"
1836	    LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
1837	    ;;
1838	UNIX_SV* | UnixWare-5*)
1839	    SHLIB_CFLAGS="-KPIC"
1840	    SHLIB_LD="cc -G"
1841	    SHLIB_LD_LIBS=""
1842	    SHLIB_SUFFIX=".so"
1843	    DL_OBJS="tclLoadDl.o"
1844	    DL_LIBS="-ldl"
1845	    # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
1846	    # that don't grok the -Bexport option.  Test that it does.
1847	    hold_ldflags=$LDFLAGS
1848	    AC_MSG_CHECKING(for ld accepts -Bexport flag)
1849	    LDFLAGS="${LDFLAGS} -Wl,-Bexport"
1850	    AC_TRY_LINK(, [int i;], found=yes, found=no)
1851	    LDFLAGS=$hold_ldflags
1852	    AC_MSG_RESULT($found)
1853	    if test $found = yes; then
1854	    LDFLAGS="-Wl,-Bexport"
1855	    else
1856	    LDFLAGS=""
1857	    fi
1858	    LD_SEARCH_FLAGS=""
1859	    ;;
1860    esac
1861
1862    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
1863    AC_MSG_WARN("64bit support being disabled -- not supported on this platform")
1864    fi
1865
1866    # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
1867    # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
1868    # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
1869    # to determine which of several header files defines the a.out file
1870    # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
1871    # support only a file format that is more or less version-7-compatible.
1872    # In particular,
1873    #	- a.out files must begin with `struct exec'.
1874    #	- the N_TXTOFF on the `struct exec' must compute the seek address
1875    #	  of the text segment
1876    #	- The `struct exec' must contain a_magic, a_text, a_data, a_bss
1877    #	  and a_entry fields.
1878    # The following compilation should succeed if and only if either sys/exec.h
1879    # or a.out.h is usable for the purpose.
1880    #
1881    # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
1882    # `struct exec' includes a second header that contains information that
1883    # duplicates the v7 fields that are needed.
1884
1885    if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
1886	AC_MSG_CHECKING(sys/exec.h)
1887	AC_TRY_COMPILE([#include <sys/exec.h>],[
1888	    struct exec foo;
1889	    unsigned long seek;
1890	    int flag;
1891#if defined(__mips) || defined(mips)
1892	    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1893#else
1894	    seek = N_TXTOFF (foo);
1895#endif
1896	    flag = (foo.a_magic == OMAGIC);
1897	    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1898    ], tcl_ok=usable, tcl_ok=unusable)
1899	AC_MSG_RESULT($tcl_ok)
1900	if test $tcl_ok = usable; then
1901	    AC_DEFINE(USE_SYS_EXEC_H)
1902	else
1903	    AC_MSG_CHECKING(a.out.h)
1904	    AC_TRY_COMPILE([#include <a.out.h>],[
1905		struct exec foo;
1906		unsigned long seek;
1907		int flag;
1908#if defined(__mips) || defined(mips)
1909		seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1910#else
1911		seek = N_TXTOFF (foo);
1912#endif
1913		flag = (foo.a_magic == OMAGIC);
1914		return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1915	    ], tcl_ok=usable, tcl_ok=unusable)
1916	    AC_MSG_RESULT($tcl_ok)
1917	    if test $tcl_ok = usable; then
1918		AC_DEFINE(USE_A_OUT_H)
1919	    else
1920		AC_MSG_CHECKING(sys/exec_aout.h)
1921		AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
1922		    struct exec foo;
1923		    unsigned long seek;
1924		    int flag;
1925#if defined(__mips) || defined(mips)
1926		    seek = N_TXTOFF (foo.ex_f, foo.ex_o);
1927#else
1928		    seek = N_TXTOFF (foo);
1929#endif
1930		    flag = (foo.a_midmag == OMAGIC);
1931		    return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
1932		], tcl_ok=usable, tcl_ok=unusable)
1933		AC_MSG_RESULT($tcl_ok)
1934		if test $tcl_ok = usable; then
1935		    AC_DEFINE(USE_SYS_EXEC_AOUT_H)
1936		else
1937		    DL_OBJS=""
1938		fi
1939	    fi
1940	fi
1941    fi
1942
1943    # Step 5: disable dynamic loading if requested via a command-line switch.
1944
1945    AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
1946	[tcl_ok=$enableval], [tcl_ok=yes])
1947    if test "$tcl_ok" = "no"; then
1948	DL_OBJS=""
1949    fi
1950
1951    if test "x$DL_OBJS" != "x" ; then
1952	BUILD_DLTEST="\$(DLTEST_TARGETS)"
1953    else
1954	echo "Can't figure out how to do dynamic loading or shared libraries"
1955	echo "on this system."
1956	SHLIB_CFLAGS=""
1957	SHLIB_LD=""
1958	SHLIB_SUFFIX=""
1959	DL_OBJS="tclLoadNone.o"
1960	DL_LIBS=""
1961	LDFLAGS=""
1962	LD_SEARCH_FLAGS=""
1963	BUILD_DLTEST=""
1964    fi
1965
1966    # If we're running gcc, then change the C flags for compiling shared
1967    # libraries to the right flags for gcc, instead of those for the
1968    # standard manufacturer compiler.
1969
1970    if test "$DL_OBJS" != "tclLoadNone.o" ; then
1971	if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
1972	    case $system in
1973		AIX-*)
1974		    ;;
1975		BSD/OS*)
1976		    ;;
1977		IRIX*)
1978		    ;;
1979		NetBSD-*|FreeBSD-*|OpenBSD-*)
1980		    ;;
1981		RISCos-*)
1982		    ;;
1983		ULTRIX-4.*)
1984		    ;;
1985		*)
1986		    SHLIB_CFLAGS="-fPIC"
1987		    ;;
1988	    esac
1989	fi
1990    fi
1991
1992    if test "$SHARED_LIB_SUFFIX" = "" ; then
1993	SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
1994    fi
1995    if test "$UNSHARED_LIB_SUFFIX" = "" ; then
1996	UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
1997    fi
1998
1999    AC_SUBST(STLIB_LD)
2000    AC_SUBST(SHLIB_LD)
2001    AC_SUBST(SHLIB_CFLAGS)
2002    AC_SUBST(SHLIB_LDFLAGS)
2003    AC_SUBST(DL_LIBS)
2004    AC_SUBST(CFLAGS_DEBUG)
2005    AC_SUBST(CFLAGS_OPTIMIZE)
2006    AC_SUBST(LDFLAGS_DEBUG)
2007    AC_SUBST(LDFLAGS_OPTIMIZE)
2008])
2009
2010#--------------------------------------------------------------------
2011# SC_SERIAL_PORT
2012#
2013#	Determine which interface to use to talk to the serial port.
2014#	Note that #include lines must begin in leftmost column for
2015#	some compilers to recognize them as preprocessor directives.
2016#
2017# Arguments:
2018#	none
2019#
2020# Results:
2021#
2022#	Defines only one of the following vars:
2023#		USE_TERMIOS
2024#		USE_TERMIO
2025#		USE_SGTTY
2026#
2027#--------------------------------------------------------------------
2028
2029AC_DEFUN(SC_SERIAL_PORT, [
2030    AC_MSG_CHECKING([termios vs. termio vs. sgtty])
2031
2032    AC_TRY_RUN([
2033#include <termios.h>
2034
2035main()
2036{
2037    struct termios t;
2038    if (tcgetattr(0, &t) == 0) {
2039	cfsetospeed(&t, 0);
2040	t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
2041	return 0;
2042    }
2043    return 1;
2044}], tk_ok=termios, tk_ok=no, tk_ok=no)
2045
2046    if test $tk_ok = termios; then
2047	AC_DEFINE(USE_TERMIOS)
2048    else
2049	AC_TRY_RUN([
2050#include <termio.h>
2051
2052main()
2053{
2054    struct termio t;
2055    if (ioctl(0, TCGETA, &t) == 0) {
2056	t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
2057	return 0;
2058    }
2059    return 1;
2060    }], tk_ok=termio, tk_ok=no, tk_ok=no)
2061
2062    if test $tk_ok = termio; then
2063	AC_DEFINE(USE_TERMIO)
2064    else
2065	AC_TRY_RUN([
2066#include <sgtty.h>
2067
2068main()
2069{
2070    struct sgttyb t;
2071    if (ioctl(0, TIOCGETP, &t) == 0) {
2072	t.sg_ospeed = 0;
2073	t.sg_flags |= ODDP | EVENP | RAW;
2074	return 0;
2075    }
2076    return 1;
2077}], tk_ok=sgtty, tk_ok=none, tk_ok=none)
2078    if test $tk_ok = sgtty; then
2079	AC_DEFINE(USE_SGTTY)
2080    fi
2081    fi
2082    fi
2083    AC_MSG_RESULT($tk_ok)
2084])
2085
2086#--------------------------------------------------------------------
2087# SC_MISSING_POSIX_HEADERS
2088#
2089#	Supply substitutes for missing POSIX header files.  Special
2090#	notes:
2091#	    - stdlib.h doesn't define strtol, strtoul, or
2092#	      strtod insome versions of SunOS
2093#	    - some versions of string.h don't declare procedures such
2094#	      as strstr
2095#
2096# Arguments:
2097#	none
2098#
2099# Results:
2100#
2101#	Defines some of the following vars:
2102#		NO_DIRENT_H
2103#		NO_ERRNO_H
2104#		NO_VALUES_H
2105#		NO_LIMITS_H
2106#		NO_STDLIB_H
2107#		NO_STRING_H
2108#		NO_SYS_WAIT_H
2109#		NO_DLFCN_H
2110#		HAVE_UNISTD_H
2111#		HAVE_SYS_PARAM_H
2112#
2113#		HAVE_STRING_H ?
2114#
2115#--------------------------------------------------------------------
2116
2117AC_DEFUN(SC_MISSING_POSIX_HEADERS, [
2118
2119    AC_MSG_CHECKING(dirent.h)
2120    AC_TRY_LINK([#include <sys/types.h>
2121#include <dirent.h>], [
2122#ifndef _POSIX_SOURCE
2123#   ifdef __Lynx__
2124	/*
2125	 * Generate compilation error to make the test fail:  Lynx headers
2126	 * are only valid if really in the POSIX environment.
2127	 */
2128
2129	missing_procedure();
2130#   endif
2131#endif
2132DIR *d;
2133struct dirent *entryPtr;
2134char *p;
2135d = opendir("foobar");
2136entryPtr = readdir(d);
2137p = entryPtr->d_name;
2138closedir(d);
2139], tcl_ok=yes, tcl_ok=no)
2140
2141    if test $tcl_ok = no; then
2142	AC_DEFINE(NO_DIRENT_H)
2143    fi
2144
2145    AC_MSG_RESULT($tcl_ok)
2146    AC_CHECK_HEADER(errno.h, , AC_DEFINE(NO_ERRNO_H))
2147    AC_CHECK_HEADER(float.h, , AC_DEFINE(NO_FLOAT_H))
2148    AC_CHECK_HEADER(values.h, , AC_DEFINE(NO_VALUES_H))
2149    AC_CHECK_HEADER(limits.h, , AC_DEFINE(NO_LIMITS_H))
2150    AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
2151    AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
2152    AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
2153    AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
2154    if test $tcl_ok = 0; then
2155	AC_DEFINE(NO_STDLIB_H)
2156    fi
2157    AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
2158    AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
2159    AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
2160
2161    # See also memmove check below for a place where NO_STRING_H can be
2162    # set and why.
2163
2164    if test $tcl_ok = 0; then
2165	AC_DEFINE(NO_STRING_H)
2166    fi
2167
2168    AC_CHECK_HEADER(sys/wait.h, , AC_DEFINE(NO_SYS_WAIT_H))
2169    AC_CHECK_HEADER(dlfcn.h, , AC_DEFINE(NO_DLFCN_H))
2170
2171    # OS/390 lacks sys/param.h (and doesn't need it, by chance).
2172
2173    AC_HAVE_HEADERS(unistd.h sys/param.h)
2174
2175])
2176
2177#--------------------------------------------------------------------
2178# SC_PATH_X
2179#
2180#	Locate the X11 header files and the X11 library archive.  Try
2181#	the ac_path_x macro first, but if it doesn't find the X stuff
2182#	(e.g. because there's no xmkmf program) then check through
2183#	a list of possible directories.  Under some conditions the
2184#	autoconf macro will return an include directory that contains
2185#	no include files, so double-check its result just to be safe.
2186#
2187# Arguments:
2188#	none
2189#
2190# Results:
2191#
2192#	Sets the the following vars:
2193#		XINCLUDES
2194#		XLIBSW
2195#
2196#--------------------------------------------------------------------
2197
2198AC_DEFUN(SC_PATH_X, [
2199    AC_PATH_X
2200    not_really_there=""
2201    if test "$no_x" = ""; then
2202	if test "$x_includes" = ""; then
2203	    AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
2204	else
2205	    if test ! -r $x_includes/X11/Intrinsic.h; then
2206		not_really_there="yes"
2207	    fi
2208	fi
2209    fi
2210    if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
2211	AC_MSG_CHECKING(for X11 header files)
2212	XINCLUDES="# no special path needed"
2213	AC_TRY_CPP([#include <X11/Intrinsic.h>], , XINCLUDES="nope")
2214	if test "$XINCLUDES" = nope; then
2215	    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"
2216	    for i in $dirs ; do
2217		if test -r $i/X11/Intrinsic.h; then
2218		    AC_MSG_RESULT($i)
2219		    XINCLUDES=" -I$i"
2220		    break
2221		fi
2222	    done
2223	fi
2224    else
2225	if test "$x_includes" != ""; then
2226	    XINCLUDES=-I$x_includes
2227	else
2228	    XINCLUDES="# no special path needed"
2229	fi
2230    fi
2231    if test "$XINCLUDES" = nope; then
2232	AC_MSG_RESULT(couldn't find any!)
2233	XINCLUDES="# no include files found"
2234    fi
2235
2236    if test "$no_x" = yes; then
2237	AC_MSG_CHECKING(for X11 libraries)
2238	XLIBSW=nope
2239	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"
2240	for i in $dirs ; do
2241	    if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
2242		AC_MSG_RESULT($i)
2243		XLIBSW="-L$i -lX11"
2244		x_libraries="$i"
2245		break
2246	    fi
2247	done
2248    else
2249	if test "$x_libraries" = ""; then
2250	    XLIBSW=-lX11
2251	else
2252	    XLIBSW="-L$x_libraries -lX11"
2253	fi
2254    fi
2255    if test "$XLIBSW" = nope ; then
2256	AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
2257    fi
2258    if test "$XLIBSW" = nope ; then
2259	AC_MSG_RESULT(couldn't find any!  Using -lX11.)
2260	XLIBSW=-lX11
2261    fi
2262])
2263#--------------------------------------------------------------------
2264# SC_BLOCKING_STYLE
2265#
2266#	The statements below check for systems where POSIX-style
2267#	non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
2268#	On these systems (mostly older ones), use the old BSD-style
2269#	FIONBIO approach instead.
2270#
2271# Arguments:
2272#	none
2273#
2274# Results:
2275#
2276#	Defines some of the following vars:
2277#		HAVE_SYS_IOCTL_H
2278#		HAVE_SYS_FILIO_H
2279#		USE_FIONBIO
2280#		O_NONBLOCK
2281#
2282#--------------------------------------------------------------------
2283
2284AC_DEFUN(SC_BLOCKING_STYLE, [
2285    AC_CHECK_HEADERS(sys/ioctl.h)
2286    AC_CHECK_HEADERS(sys/filio.h)
2287    AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
2288    if test -f /usr/lib/NextStep/software_version; then
2289	system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
2290    else
2291	system=`uname -s`-`uname -r`
2292	if test "$?" -ne 0 ; then
2293	    system=unknown
2294	else
2295	    # Special check for weird MP-RAS system (uname returns weird
2296	    # results, and the version is kept in special file).
2297
2298	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
2299		system=MP-RAS-`awk '{print $3}' /etc/.relid'`
2300	    fi
2301	    if test "`uname -s`" = "AIX" ; then
2302		system=AIX-`uname -v`.`uname -r`
2303	    fi
2304	fi
2305    fi
2306    case $system in
2307	# There used to be code here to use FIONBIO under AIX.  However, it
2308	# was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
2309	# using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
2310	# code (JO, 5/31/97).
2311
2312	OSF*)
2313	    AC_DEFINE(USE_FIONBIO)
2314	    AC_MSG_RESULT(FIONBIO)
2315	    ;;
2316	SunOS-4*)
2317	    AC_DEFINE(USE_FIONBIO)
2318	    AC_MSG_RESULT(FIONBIO)
2319	    ;;
2320	ULTRIX-4.*)
2321	    AC_DEFINE(USE_FIONBIO)
2322	    AC_MSG_RESULT(FIONBIO)
2323	    ;;
2324	*)
2325	    AC_MSG_RESULT(O_NONBLOCK)
2326	    ;;
2327    esac
2328])
2329
2330#--------------------------------------------------------------------
2331# SC_HAVE_VFORK
2332#
2333#	Check to see whether the system provides a vfork kernel call.
2334#	If not, then use fork instead.  Also, check for a problem with
2335#	vforks and signals that can cause core dumps if a vforked child
2336#	resets a signal handler.  If the problem exists, then use fork
2337#	instead of vfork.
2338#
2339# Arguments:
2340#	none
2341#
2342# Results:
2343#
2344#	Defines some of the following vars:
2345#		vfork (=fork)
2346#
2347#--------------------------------------------------------------------
2348
2349AC_DEFUN(SC_HAVE_VFORK, [
2350    AC_TYPE_SIGNAL()
2351    AC_CHECK_FUNC(vfork, tcl_ok=1, tcl_ok=0)
2352    if test "$tcl_ok" = 1; then
2353	AC_MSG_CHECKING([vfork/signal bug]);
2354	AC_TRY_RUN([
2355#include <stdio.h>
2356#include <signal.h>
2357#include <sys/wait.h>
2358int gotSignal = 0;
2359sigProc(sig)
2360    int sig;
2361{
2362    gotSignal = 1;
2363}
2364main()
2365{
2366    int pid, sts;
2367    (void) signal(SIGCHLD, sigProc);
2368    pid = vfork();
2369    if (pid <  0) {
2370	exit(1);
2371    } else if (pid == 0) {
2372	(void) signal(SIGCHLD, SIG_DFL);
2373	_exit(0);
2374    } else {
2375	(void) wait(&sts);
2376    }
2377    exit((gotSignal) ? 0 : 1);
2378}], tcl_ok=1, tcl_ok=0, tcl_ok=0)
2379
2380	if test "$tcl_ok" = 1; then
2381	    AC_MSG_RESULT(ok)
2382	else
2383	    AC_MSG_RESULT([buggy, using fork instead])
2384	fi
2385    fi
2386    rm -f core
2387    if test "$tcl_ok" = 0; then
2388	AC_DEFINE(vfork, fork)
2389    fi
2390])
2391
2392#--------------------------------------------------------------------
2393# SC_TIME_HANLDER
2394#
2395#	Checks how the system deals with time.h, what time structures
2396#	are used on the system, and what fields the structures have.
2397#
2398# Arguments:
2399#	none
2400#
2401# Results:
2402#
2403#	Defines some of the following vars:
2404#		USE_DELTA_FOR_TZ
2405#		HAVE_TM_GMTOFF
2406#		HAVE_TM_TZADJ
2407#		HAVE_TIMEZONE_VAR
2408#
2409#--------------------------------------------------------------------
2410
2411AC_DEFUN(SC_TIME_HANDLER, [
2412    AC_CHECK_HEADERS(sys/time.h)
2413    AC_HEADER_TIME
2414    AC_STRUCT_TIMEZONE
2415
2416    AC_MSG_CHECKING([tm_tzadj in struct tm])
2417    AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
2418	    [AC_DEFINE(HAVE_TM_TZADJ)
2419	    AC_MSG_RESULT(yes)],
2420	    AC_MSG_RESULT(no))
2421
2422    AC_MSG_CHECKING([tm_gmtoff in struct tm])
2423    AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
2424	    [AC_DEFINE(HAVE_TM_GMTOFF)
2425	    AC_MSG_RESULT(yes)],
2426	    AC_MSG_RESULT(no))
2427
2428    #
2429    # Its important to include time.h in this check, as some systems
2430    # (like convex) have timezone functions, etc.
2431    #
2432    have_timezone=no
2433    AC_MSG_CHECKING([long timezone variable])
2434    AC_TRY_COMPILE([#include <time.h>],
2435	    [extern long timezone;
2436	    timezone += 1;
2437	    exit (0);],
2438	    [have_timezone=yes
2439	    AC_DEFINE(HAVE_TIMEZONE_VAR)
2440	    AC_MSG_RESULT(yes)],
2441	    AC_MSG_RESULT(no))
2442
2443    #
2444    # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
2445    #
2446    if test "$have_timezone" = no; then
2447    AC_MSG_CHECKING([time_t timezone variable])
2448    AC_TRY_COMPILE([#include <time.h>],
2449	    [extern time_t timezone;
2450	    timezone += 1;
2451	    exit (0);],
2452	    [AC_DEFINE(HAVE_TIMEZONE_VAR)
2453	    AC_MSG_RESULT(yes)],
2454	    AC_MSG_RESULT(no))
2455    fi
2456
2457    #
2458    # AIX does not have a timezone field in struct tm. When the AIX bsd
2459    # library is used, the timezone global and the gettimeofday methods are
2460    # to be avoided for timezone deduction instead, we deduce the timezone
2461    # by comparing the localtime result on a known GMT value.
2462    #
2463
2464    if test "`uname -s`" = "AIX" ; then
2465	AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes)
2466	if test $libbsd = yes; then
2467	    AC_DEFINE(USE_DELTA_FOR_TZ)
2468	fi
2469    fi
2470])
2471
2472#--------------------------------------------------------------------
2473# SC_BUGGY_STRTOD
2474#
2475#	Under Solaris 2.4, strtod returns the wrong value for the
2476#	terminating character under some conditions.  Check for this
2477#	and if the problem exists use a substitute procedure
2478#	"fixstrtod" (provided by Tcl) that corrects the error.
2479#
2480# Arguments:
2481#	none
2482#
2483# Results:
2484#
2485#	Might defines some of the following vars:
2486#		strtod (=fixstrtod)
2487#
2488#--------------------------------------------------------------------
2489
2490AC_DEFUN(SC_BUGGY_STRTOD, [
2491    AC_CHECK_FUNC(strtod, tk_strtod=1, tk_strtod=0)
2492    if test "$tk_strtod" = 1; then
2493	AC_MSG_CHECKING([for Solaris 2.4 strtod bug])
2494	AC_TRY_RUN([
2495	    extern double strtod();
2496	    int main()
2497	    {
2498		char *string = "NaN";
2499		char *term;
2500		strtod(string, &term);
2501		if ((term != string) && (term[-1] == 0)) {
2502		    exit(1);
2503		}
2504		exit(0);
2505	    }], tk_ok=1, tk_ok=0, tk_ok=0)
2506	if test "$tk_ok" = 1; then
2507	    AC_MSG_RESULT(ok)
2508	else
2509	    AC_MSG_RESULT(buggy)
2510	    AC_DEFINE(strtod, fixstrtod)
2511	fi
2512    fi
2513])
2514
2515#--------------------------------------------------------------------
2516# SC_TCL_LINK_LIBS
2517#
2518#	Search for the libraries needed to link the Tcl shell.
2519#	Things like the math library (-lm) and socket stuff (-lsocket vs.
2520#	-lnsl) are dealt with here.
2521#
2522# Arguments:
2523#	Requires the following vars to be set in the Makefile:
2524#		DL_LIBS
2525#		LIBS
2526#		MATH_LIBS
2527#
2528# Results:
2529#
2530#	Subst's the following var:
2531#		TCL_LIBS
2532#		MATH_LIBS
2533#
2534#	Might append to the following vars:
2535#		LIBS
2536#
2537#	Might define the following vars:
2538#		HAVE_NET_ERRNO_H
2539#
2540#--------------------------------------------------------------------
2541
2542AC_DEFUN(SC_TCL_LINK_LIBS, [
2543    #--------------------------------------------------------------------
2544    # On a few very rare systems, all of the libm.a stuff is
2545    # already in libc.a.  Set compiler flags accordingly.
2546    # Also, Linux requires the "ieee" library for math to work
2547    # right (and it must appear before "-lm").
2548    #--------------------------------------------------------------------
2549
2550    AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
2551    AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
2552
2553    #--------------------------------------------------------------------
2554    # On AIX systems, libbsd.a has to be linked in to support
2555    # non-blocking file IO.  This library has to be linked in after
2556    # the MATH_LIBS or it breaks the pow() function.  The way to
2557    # insure proper sequencing, is to add it to the tail of MATH_LIBS.
2558    # This library also supplies gettimeofday.
2559    #--------------------------------------------------------------------
2560
2561    libbsd=no
2562    if test "`uname -s`" = "AIX" ; then
2563	AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes)
2564	if test $libbsd = yes; then
2565	    MATH_LIBS="$MATH_LIBS -lbsd"
2566	fi
2567    fi
2568
2569
2570    #--------------------------------------------------------------------
2571    # Interactive UNIX requires -linet instead of -lsocket, plus it
2572    # needs net/errno.h to define the socket-related error codes.
2573    #--------------------------------------------------------------------
2574
2575    AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
2576    AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))
2577
2578    #--------------------------------------------------------------------
2579    #	Check for the existence of the -lsocket and -lnsl libraries.
2580    #	The order here is important, so that they end up in the right
2581    #	order in the command line generated by make.  Here are some
2582    #	special considerations:
2583    #	1. Use "connect" and "accept" to check for -lsocket, and
2584    #	   "gethostbyname" to check for -lnsl.
2585    #	2. Use each function name only once:  can't redo a check because
2586    #	   autoconf caches the results of the last check and won't redo it.
2587    #	3. Use -lnsl and -lsocket only if they supply procedures that
2588    #	   aren't already present in the normal libraries.  This is because
2589    #	   IRIX 5.2 has libraries, but they aren't needed and they're
2590    #	   bogus:  they goof up name resolution if used.
2591    #	4. On some SVR4 systems, can't use -lsocket without -lnsl too.
2592    #	   To get around this problem, check for both libraries together
2593    #	   if -lsocket doesn't work by itself.
2594    #--------------------------------------------------------------------
2595
2596    tcl_checkBoth=0
2597    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
2598    if test "$tcl_checkSocket" = 1; then
2599	AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tcl_checkBoth=1)
2600    fi
2601    if test "$tcl_checkBoth" = 1; then
2602	tk_oldLibs=$LIBS
2603	LIBS="$LIBS -lsocket -lnsl"
2604	AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
2605    fi
2606    AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main,
2607	    [LIBS="$LIBS -lnsl"]))
2608
2609    # Don't perform the eval of the libraries here because DL_LIBS
2610    # won't be set until we call SC_CONFIG_CFLAGS
2611
2612    TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
2613    AC_SUBST(TCL_LIBS)
2614    AC_SUBST(MATH_LIBS)
2615])
2616
2617#------------------------------------------------------------------------
2618# SC_MAKE_LIB --
2619#
2620#	Generate a line that can be used to build a shared/unshared library
2621#	in a platform independent manner.
2622#
2623# Arguments:
2624#	none
2625#
2626#	Requires:
2627#
2628# Results:
2629#
2630#	Defines the following vars:
2631#		MAKE_LIB	Makefile rule for building a library
2632#		MAKE_SHARED_LIB	Makefile rule for building a shared library
2633#		MAKE_UNSHARED_LIB	Makefile rule for building a static
2634#				library
2635#------------------------------------------------------------------------
2636
2637AC_DEFUN(SC_MAKE_LIB, [
2638    case "`uname -s`" in
2639	*win32* | *WIN32* | *CYGWIN_NT* |*CYGWIN_98*|*CYGWIN_95*)
2640	    if test "${CC-cc}" = "cl"; then
2641		MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(\[$]@_OBJECTS) "
2642		MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS} \$(LDFLAGS) -out:\[$]@ \$(\[$]@_OBJECTS) "
2643	    fi
2644	    ;;
2645	*)
2646	    MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(\[$]@_OBJECTS)"
2647	    MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(\[$]@_OBJECTS) \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS}"
2648	    ;;
2649    esac
2650
2651    if test "${SHARED_BUILD}" = "1" ; then
2652	MAKE_LIB=${MAKE_SHARED_LIB}
2653    else
2654	MAKE_LIB=${MAKE_STATIC_LIB}
2655    fi
2656
2657    AC_SUBST(MAKE_LIB)
2658    AC_SUBST(MAKE_SHARED_LIB)
2659    AC_SUBST(MAKE_STATIC_LIB)
2660])
2661
2662#------------------------------------------------------------------------
2663# SC_LIB_SPEC --
2664#
2665#	Compute the name of an existing object library located in libdir
2666#	from the given base name and produce the appropriate linker flags.
2667#
2668# Arguments:
2669#	basename	The base name of the library without version
2670#			numbers, extensions, or "lib" prefixes.
2671#	extra_dir	Extra directory in which to search for the
2672#			library.  This location is used first, then
2673#			$prefix/$exec-prefix, then some defaults.
2674#
2675# Requires:
2676#	CYGPATH		command used to generate native style paths
2677#
2678# Results:
2679#
2680#	Defines the following vars:
2681#		${basename}_LIB_NAME	The computed library name.
2682#		${basename}_LIB_SPEC	The computed linker flags.
2683#------------------------------------------------------------------------
2684
2685AC_DEFUN(SC_LIB_SPEC, [
2686    AC_MSG_CHECKING(for $1 library)
2687
2688    # Look in exec-prefix and prefix for the library.  If neither of
2689    # these were specified, look in libdir.  It doesn't matter if libdir
2690    # wasn't specified since a search in the unspecified directory will
2691    # fail (NONE/lib)
2692
2693    if test x"${exec_prefix}" != x"NONE" ; then
2694	sc_lib_name_dir="${exec_prefix}/lib"
2695    elif test x"${prefix}" != "NONE" ; then
2696	sc_lib_name_dir="${prefix}/lib"
2697    else
2698	eval "sc_lib_name_dir=${libdir}"
2699    fi
2700
2701    if test x"$2" != x ; then
2702	sc_extra_lib_dir=$2
2703    else
2704	sc_extra_lib_dir=NONE
2705    fi
2706
2707    for i in \
2708	    `ls -dr ${sc_extra_lib_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
2709	    `ls -dr ${sc_extra_lib_dir}/lib$1[[0-9]]* 2>/dev/null ` \
2710	    `ls -dr ${sc_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
2711	    `ls -dr ${sc_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
2712	    `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
2713	    `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
2714	    `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
2715	    `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
2716	if test -f "$i" ; then
2717
2718	    sc_lib_name_dir=`dirname $i`
2719	    $1_LIB_NAME=`basename $i`
2720	    $1_LIB_PATH_NAME=$i
2721	    break
2722	fi
2723    done
2724
2725    case "`uname -s`" in
2726	*win32* | *WIN32* | *CYGWIN_NT* |*CYGWIN_98*|*CYGWIN_95*)
2727	    $1_LIB_SPEC=\"`${CYGPATH} ${$1_LIB_PATH_NAME}`\"
2728	    ;;
2729	*)
2730	    # Strip off the leading "lib" and trailing ".a" or ".so"
2731
2732	    sc_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//'`
2733	    $1_LIB_SPEC="-L${sc_lib_name_dir} -l${sc_lib_name_lib}"
2734	    ;;
2735    esac
2736    if test "x$1_LIB_NAME" = x ; then
2737	AC_MSG_ERROR(not found)
2738    else
2739	AC_MSG_RESULT(${$1_LIB_SPEC})
2740    fi
2741])
2742
2743#------------------------------------------------------------------------
2744# SC_PRIVATE_TCL_HEADERS --
2745#
2746#	Locate the private Tcl include files
2747#
2748# Arguments:
2749#
2750#	Requires:
2751#		TCL_SRC_DIR	Assumes that SC_LOAD_TCLCONFIG has
2752#				 already been called.
2753#
2754# Results:
2755#
2756#	Substs the following vars:
2757#		TCL_TOP_DIR_NATIVE
2758#		TCL_GENERIC_DIR_NATIVE
2759#		TCL_UNIX_DIR_NATIVE
2760#		TCL_WIN_DIR_NATIVE
2761#		TCL_BMAP_DIR_NATIVE
2762#		TCL_TOOL_DIR_NATIVE
2763#		TCL_PLATFORM_DIR_NATIVE
2764#		TCL_BIN_DIR_NATIVE
2765#		TCL_INCLUDES
2766#------------------------------------------------------------------------
2767
2768AC_DEFUN(SC_PRIVATE_TCL_HEADERS, [
2769    AC_MSG_CHECKING(for Tcl private include files)
2770
2771    case "`uname -s`" in
2772	*win32* | *WIN32* | *CYGWIN_NT* |*CYGWIN_98*|*CYGWIN_95*)
2773	    TCL_TOP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/..`\"
2774	    TCL_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../generic`\"
2775	    TCL_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../unix`\"
2776	    TCL_WIN_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../win`\"
2777	    TCL_BMAP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../bitmaps`\"
2778	    TCL_TOOL_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../tools`\"
2779	    TCL_COMPAT_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/../compat`\"
2780	    TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
2781	;;
2782	*)
2783	    TCL_TOP_DIR_NATIVE='$(TCL_SRC_DIR)'
2784	    TCL_GENERIC_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/generic'
2785	    TCL_UNIX_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/unix'
2786	    TCL_WIN_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/win'
2787	    TCL_BMAP_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/bitmaps'
2788	    TCL_TOOL_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/tools'
2789	    TCL_COMPAT_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/compat'
2790	    TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
2791	;;
2792    esac
2793
2794    AC_SUBST(TCL_TOP_DIR_NATIVE)
2795    AC_SUBST(TCL_GENERIC_DIR_NATIVE)
2796    AC_SUBST(TCL_UNIX_DIR_NATIVE)
2797    AC_SUBST(TCL_WIN_DIR_NATIVE)
2798    AC_SUBST(TCL_BMAP_DIR_NATIVE)
2799    AC_SUBST(TCL_TOOL_DIR_NATIVE)
2800    AC_SUBST(TCL_PLATFORM_DIR_NATIVE)
2801
2802    TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
2803    AC_SUBST(TCL_INCLUDES)
2804    AC_MSG_RESULT(Using srcdir found in tclConfig.sh)
2805])
2806
2807#------------------------------------------------------------------------
2808# SC_PUBLIC_TCL_HEADERS --
2809#
2810#	Locate the installed public Tcl header files
2811#
2812# Arguments:
2813#	None.
2814#
2815# Requires:
2816#	CYGPATH must be set
2817#
2818# Results:
2819#
2820#	Adds a --with-tclinclude switch to configure.
2821#	Result is cached.
2822#
2823#	Substs the following vars:
2824#		TCL_INCLUDES
2825#------------------------------------------------------------------------
2826
2827AC_DEFUN(SC_PUBLIC_TCL_HEADERS, [
2828    AC_MSG_CHECKING(for Tcl public headers)
2829
2830    AC_ARG_WITH(tclinclude, [ --with-tclinclude      directory containing the public Tcl header files.], with_tclinclude=${withval})
2831
2832    if test x"${with_tclinclude}" != x ; then
2833	if test -f "${with_tclinclude}/tcl.h" ; then
2834	    ac_cv_c_tclh=${with_tclinclude}
2835	else
2836	    AC_MSG_ERROR([${with_tclinclude} directory does not contain Tcl public header file tcl.h])
2837	fi
2838    else
2839	AC_CACHE_VAL(ac_cv_c_tclh, [
2840	    # Use the value from --with-tclinclude, if it was given
2841
2842	    if test x"${with_tclinclude}" != x ; then
2843		ac_cv_c_tclh=${with_tclinclude}
2844	    else
2845		# Check in the includedir, if --prefix was specified
2846
2847		eval "temp_includedir=${includedir}"
2848		for i in \
2849			`ls -d ${temp_includedir} 2>/dev/null` \
2850			/usr/local/include /usr/include ; do
2851		    if test -f "$i/tcl.h" ; then
2852			ac_cv_c_tclh=$i
2853			break
2854		    fi
2855		done
2856	    fi
2857	])
2858    fi
2859
2860    # Print a message based on how we determined the include path
2861
2862    if test x"${ac_cv_c_tclh}" = x ; then
2863	AC_MSG_ERROR(tcl.h not found.  Please specify its location with --with-tclinclude)
2864    else
2865	AC_MSG_RESULT(${ac_cv_c_tclh})
2866    fi
2867
2868    # Convert to a native path and substitute into the output files.
2869
2870    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}`
2871
2872    TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
2873
2874    AC_SUBST(TCL_INCLUDES)
2875])
2876
2877#------------------------------------------------------------------------
2878# SC_PRIVATE_TK_HEADERS --
2879#
2880#	Locate the private Tk include files
2881#
2882# Arguments:
2883#
2884#	Requires:
2885#		TK_SRC_DIR	Assumes that SC_LOAD_TKCONFIG has
2886#				 already been called.
2887#
2888# Results:
2889#
2890#	Substs the following vars:
2891#		TK_INCLUDES
2892#------------------------------------------------------------------------
2893
2894AC_DEFUN(SC_PRIVATE_TK_HEADERS, [
2895    AC_MSG_CHECKING(for Tk private include files)
2896
2897    case "`uname -s`" in
2898	*win32* | *WIN32* | *CYGWIN_NT* |*CYGWIN_98*|*CYGWIN_95*)
2899	    TK_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/../unix`\"
2900	    TK_WIN_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/../win`\"
2901	    TK_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/../generic`\"
2902	    TK_XLIB_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/../xlib`\"
2903	    TK_PLATFORM_DIR_NATIVE=${TK_WIN_DIR_NATIVE}
2904
2905	    TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE} -I${TK_XLIB_DIR_NATIVE}"
2906	;;
2907	*)
2908	    TK_GENERIC_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/generic'
2909	    TK_UNIX_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/unix'
2910	    TK_WIN_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/win'
2911	    TK_PLATFORM_DIR_NATIVE=${TK_UNIX_DIR_NATIVE}
2912
2913	    TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
2914	;;
2915    esac
2916
2917    AC_SUBST(TK_UNIX_DIR_NATIVE)
2918    AC_SUBST(TK_WIN_DIR_NATIVE)
2919    AC_SUBST(TK_GENERIC_DIR_NATIVE)
2920    AC_SUBST(TK_XLIB_DIR_NATIVE)
2921    AC_SUBST(TK_PLATFORM_DIR_NATIVE)
2922
2923    AC_SUBST(TK_INCLUDES)
2924    AC_MSG_RESULT(Using srcdir found in tkConfig.sh)
2925])
2926
2927#------------------------------------------------------------------------
2928# SC_PUBLIC_TK_HEADERS --
2929#
2930#	Locate the installed public Tk header files
2931#
2932# Arguments:
2933#	None.
2934#
2935# Requires:
2936#	CYGPATH must be set
2937#
2938# Results:
2939#
2940#	Adds a --with-tkinclude switch to configure.
2941#	Result is cached.
2942#
2943#	Substs the following vars:
2944#		TK_INCLUDES
2945#------------------------------------------------------------------------
2946
2947AC_DEFUN(SC_PUBLIC_TK_HEADERS, [
2948    AC_MSG_CHECKING(for Tk public headers)
2949
2950    AC_ARG_WITH(tkinclude, [ --with-tkinclude      directory containing the public Tk header files.], with_tkinclude=${withval})
2951
2952    if test x"${with_tkinclude}" != x ; then
2953	if test -f "${with_tkinclude}/tk.h" ; then
2954	    ac_cv_c_tkh=${with_tkinclude}
2955	else
2956	    AC_MSG_ERROR([${with_tkinclude} directory does not contain Tk public header file tk.h])
2957	fi
2958    else
2959	AC_CACHE_VAL(ac_cv_c_tkh, [
2960	    # Use the value from --with-tkinclude, if it was given
2961
2962	    if test x"${with_tkinclude}" != x ; then
2963		ac_cv_c_tkh=${with_tkinclude}
2964	    else
2965		# Check in the includedir, if --prefix was specified
2966
2967		eval "temp_includedir=${includedir}"
2968		for i in \
2969			`ls -d ${temp_includedir} 2>/dev/null` \
2970			/usr/local/include /usr/include ; do
2971		    if test -f "$i/tk.h" ; then
2972			ac_cv_c_tkh=$i
2973			break
2974		    fi
2975		done
2976	    fi
2977	])
2978    fi
2979
2980    # Print a message based on how we determined the include path
2981
2982    if test x"${ac_cv_c_tkh}" = x ; then
2983	AC_MSG_ERROR(tk.h not found.  Please specify its location with --with-tkinclude)
2984    else
2985	AC_MSG_RESULT(${ac_cv_c_tkh})
2986    fi
2987
2988    # Convert to a native path and substitute into the output files.
2989
2990    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}`
2991
2992    TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
2993
2994    AC_SUBST(TK_INCLUDES)
2995])
2996
2997#------------------------------------------------------------------------
2998# SC_SIMPLE_EXEEXT
2999#	Select the executable extension based on the host type.  This
3000#	is a lightweight replacement for AC_EXEEXT that doesn't require
3001#	a compiler.
3002#
3003# Arguments
3004#	none
3005#
3006# Results
3007#	Subst's the following values:
3008#		EXEEXT
3009#------------------------------------------------------------------------
3010
3011AC_DEFUN(SC_SIMPLE_EXEEXT, [
3012    AC_MSG_CHECKING(executable extension based on host type)
3013
3014    case "`uname -s`" in
3015	*win32* | *WIN32* | *CYGWIN_NT* |*CYGWIN_98*|*CYGWIN_95*)
3016	    EXEEXT=".exe"
3017	;;
3018	*)
3019	    EXEEXT=""
3020	;;
3021    esac
3022
3023    AC_MSG_RESULT(${EXEEXT})
3024    AC_SUBST(EXEEXT)
3025])
3026
3027#------------------------------------------------------------------------
3028# SC_PROG_TCLSH
3029#	Locate a tclsh shell in the following directories:
3030#		${exec_prefix}/bin
3031#		${prefix}/bin
3032#		${TCL_BIN_DIR}
3033#		${TCL_BIN_DIR}/../bin
3034#		${PATH}
3035#
3036# Arguments
3037#	none
3038#
3039# Results
3040#	Subst's the following values:
3041#		TCLSH_PROG
3042#------------------------------------------------------------------------
3043
3044AC_DEFUN(SC_PROG_TCLSH, [
3045    AC_MSG_CHECKING([for tclsh])
3046
3047    AC_CACHE_VAL(ac_cv_path_tclsh, [
3048	search_path=`echo ${exec_prefix}/bin:${prefix}/bin:${TCL_BIN_DIR}:${TCL_BIN_DIR}/../bin:${PATH} | sed -e 's/:/ /g'`
3049	for dir in $search_path ; do
3050	    for j in `ls -r $dir/tclsh[[8-9]]*${EXEEXT} 2> /dev/null` \
3051		    `ls -r $dir/tclsh*${EXEEXT} 2> /dev/null` ; do
3052		if test x"$ac_cv_path_tclsh" = x ; then
3053		    if test -f "$j" ; then
3054			ac_cv_path_tclsh=$j
3055			break
3056		    fi
3057		fi
3058	    done
3059	done
3060    ])
3061
3062    if test -f "$ac_cv_path_tclsh" ; then
3063	TCLSH_PROG=$ac_cv_path_tclsh
3064	AC_MSG_RESULT($TCLSH_PROG)
3065    else
3066	AC_MSG_ERROR(No tclsh found in PATH:  $search_path)
3067    fi
3068    AC_SUBST(TCLSH_PROG)
3069])
3070
3071#------------------------------------------------------------------------
3072# SC_PROG_WISH
3073#	Locate a wish shell in the following directories:
3074#		${exec_prefix}/bin
3075#		${prefix}/bin
3076#		${TCL_BIN_DIR}
3077#		${TCL_BIN_DIR}/../bin
3078#		${PATH}
3079#
3080# Arguments
3081#	none
3082#
3083# Results
3084#	Subst's the following values:
3085#		WISH_PROG
3086#------------------------------------------------------------------------
3087
3088AC_DEFUN(SC_PROG_WISH, [
3089    AC_MSG_CHECKING([for wish])
3090
3091    AC_CACHE_VAL(ac_cv_path_wish, [
3092	search_path=`echo ${exec_prefix}/bin:${prefix}/bin:${TCL_BIN_DIR}:${TCL_BIN_DIR}/../bin:${PATH} | sed -e 's/:/ /g'`
3093	for dir in $search_path ; do
3094	    for j in `ls -r $dir/wish[[8-9]]*${EXEEXT} 2> /dev/null` \
3095		    `ls -r $dir/wish*${EXEEXT} 2> /dev/null` ; do
3096		if test x"$ac_cv_path_wish" = x ; then
3097		    if test -f "$j" ; then
3098			ac_cv_path_wish=$j
3099			break
3100		    fi
3101		fi
3102	    done
3103	done
3104    ])
3105
3106    if test -f "$ac_cv_path_wish" ; then
3107	WISH_PROG=$ac_cv_path_wish
3108	AC_MSG_RESULT($WISH_PROG)
3109    else
3110	AC_MSG_ERROR(No wish found in PATH:  $search_path)
3111    fi
3112    AC_SUBST(WISH_PROG)
3113])
3114
3115
3116