source: tol/tolbase/aclocal.m4 @ 0f71b65

1941-docker-image-to-testdevel
Last change on this file since 0f71b65 was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

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