acinclude.m4 revision 60484
1dnl This file is included into all any other acinclude file that needs
2dnl to use these macros.
3
4dnl This is copied from autoconf 2.12, but does calls our own AC_PROG_CC_WORKS,
5dnl and doesn't call AC_PROG_CXX_GNU, cause we test for that in  AC_PROG_CC_WORKS.
6dnl We are probably using a cross compiler, which will not be able to fully
7dnl link an executable.  This should really be fixed in autoconf itself.
8dnl Find a working G++ cross compiler. This only works for the GNU C++ compiler.
9AC_DEFUN(CYG_AC_PROG_CXX_CROSS,
10[AC_BEFORE([$0], [AC_PROG_CXXCPP])
11AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
12
13CYG_AC_PROG_GXX_WORKS
14
15if test $ac_cv_prog_gxx = yes; then
16  GXX=yes
17dnl Check whether -g works, even if CXXFLAGS is set, in case the package
18dnl plays around with CXXFLAGS (such as to build both debugging and
19dnl normal versions of a library), tasteless as that idea is.
20  ac_test_CXXFLAGS="${CXXFLAGS+set}"
21  ac_save_CXXFLAGS="$CXXFLAGS"
22  CXXFLAGS=
23  AC_PROG_CXX_G
24  if test "$ac_test_CXXFLAGS" = set; then
25    CXXFLAGS="$ac_save_CXXFLAGS"
26  elif test $ac_cv_prog_cxx_g = yes; then
27    CXXFLAGS="-g -O2"
28  else
29    CXXFLAGS="-O2"
30  fi
31else
32  GXX=
33  test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
34fi
35])
36
37dnl See if the G++ compiler we found works.
38AC_DEFUN(CYG_AC_PROG_GXX_WORKS,
39[AC_MSG_CHECKING([whether the G++ compiler ($CXX $CXXFLAGS $LDFLAGS) actually works])
40AC_LANG_SAVE
41AC_LANG_CPLUSPLUS
42dnl Try a test case. We only compile, because it's close to impossible
43dnl to get a correct fully linked executable with a cross compiler. For
44dnl most cross compilers, this test is bogus. For G++, we can use various
45dnl other compile line options to get a decent idea that the cross compiler
46dnl actually does work, even though we can't produce an executable without
47dnl more info about the target it's being compiled for. This only works
48dnl for the GNU C++ compiler.
49
50dnl Transform the name of the compiler to it's cross variant, unless
51dnl CXX is set. This is also what CXX gets set to in the generated
52dnl Makefile.
53if test x"${CXX}" = xc++ ; then
54    CXX=`echo gcc | sed -e "${program_transform_name}"`
55fi
56
57dnl Get G++'s full path to libgcc.a
58libgccpath=`${CXX} --print-libgcc`
59
60dnl If we don't have a path with libgcc.a on the end, this isn't G++.
61if test `echo $libgccpath | sed -e 's:/.*/::'` = libgcc.a ; then
62   ac_cv_prog_gxx=yes
63else
64   ac_cv_prog_gxx=no
65fi
66
67dnl If we are using G++, look for the files that need to exist if this
68dnl compiler works.
69if test x"${ac_cv_prog_gxx}" = xyes ; then
70    gccfiles=`echo $libgccpath | sed -e 's:/libgcc.a::'`
71    if test -f ${gccfiles}/specs -a -f ${gccfiles}/cpp -a -f ${gccfiles}/cc1plus; then
72	gccfiles=yes
73    else
74	gccfiles=no
75    fi
76    gcclibs=`echo $libgccpath | sed -e 's:lib/gcc-lib/::' -e 's:/libgcc.a::' -e 's,\(.*\)/.*,\1,g'`/lib
77    if test -d ${gcclibs}/ldscripts -a -f ${gcclibs}/libc.a -a -f ${gcclibs}/libstdc++.a ; then
78	gcclibs=yes
79    else
80	gcclibs=no
81    fi
82fi
83
84dnl If everything is OK, then we can safely assume the compiler works.
85if test x"${gccfiles}" = xno -o x"${gcclibs}" = xno; then
86    ac_cv_prog_cxx_works=no
87    AC_MSG_ERROR(${CXX} is a non-working cross compiler)
88else
89   ac_cv_prog_cxx_works=yes 
90fi
91
92AC_LANG_RESTORE
93AC_MSG_RESULT($ac_cv_prog_cxx_works)
94if test x"$ac_cv_prog_cxx_works" = xno; then
95  AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
96fi
97AC_MSG_CHECKING([whether the G++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
98AC_MSG_RESULT($ac_cv_prog_cxx_cross)
99cross_compiling=$ac_cv_prog_cxx_cross
100AC_SUBST(CXX)
101])
102
103dnl ====================================================================
104dnl Find a working GCC cross compiler. This only works for the GNU gcc compiler.
105dnl This is based on the macros above for G++.
106AC_DEFUN(CYG_AC_PROG_CC_CROSS,
107[AC_BEFORE([$0], [AC_PROG_CCPP])
108AC_CHECK_PROGS(CC, cc, gcc)
109
110CYG_AC_PROG_GCC_WORKS
111
112if test $ac_cv_prog_gcc = yes; then
113  GCC=yes
114dnl Check whether -g works, even if CFLAGS is set, in case the package
115dnl plays around with CFLAGS (such as to build both debugging and
116dnl normal versions of a library), tasteless as that idea is.
117  ac_test_CFLAGS="${CFLAGS+set}"
118  ac_save_CFLAGS="$CFLAGS"
119  CFLAGS=
120  AC_PROG_CC_G
121  if test "$ac_test_CFLAGS" = set; then
122    CFLAGS="$ac_save_CFLAGS"
123  elif test $ac_cv_prog_cc_g = yes; then
124    CFLAGS="-g -O2"
125  else
126    CFLAGS="-O2"
127  fi
128else
129  GXX=
130  test "${CFLAGS+set}" = set || CFLAGS="-g"
131fi
132])
133
134dnl See if the GCC compiler we found works.
135AC_DEFUN(CYG_AC_PROG_GCC_WORKS,
136[AC_MSG_CHECKING([whether the Gcc compiler ($CC $CFLAGS $LDFLAGS) actually works])
137AC_LANG_SAVE
138AC_LANG_C
139dnl Try a test case. We only compile, because it's close to impossible
140dnl to get a correct fully linked executable with a cross
141dnl compiler. For most cross compilers, this test is bogus. For G++,
142dnl we can use various other compile line options to get a decent idea
143dnl that the cross compiler actually does work, even though we can't
144dnl produce an executable without more info about the target it's
145dnl being compiled for. This only works for the GNU C++ compiler.
146
147dnl Transform the name of the compiler to it's cross variant, unless
148dnl CXX is set. This is also what CC gets set to in the generated Makefile.
149if test x"${CC}" = xcc ; then
150    CC=`echo gcc | sed -e "${program_transform_name}"`
151fi
152
153dnl Get Gcc's full path to libgcc.a
154libgccpath=`${CC} --print-libgcc`
155
156dnl If we don't have a path with libgcc.a on the end, this isn't G++.
157if test `echo $libgccpath | sed -e 's:/.*/::'` = libgcc.a ; then
158   ac_cv_prog_gcc=yes
159else
160   ac_cv_prog_gcc=no
161fi
162
163dnl If we are using Gcc, look for the files that need to exist if this
164dnl compiler works.
165if test x"${ac_cv_prog_gcc}" = xyes ; then
166    gccfiles=`echo $libgccpath | sed -e 's:/libgcc.a::'`
167    if test -f ${gccfiles}/specs -a -f ${gccfiles}/cpp -a -f ${gccfiles}/cc1plus; then
168	gccfiles=yes
169    else
170	gccfiles=no
171    fi
172    gcclibs=`echo $libgccpath | sed -e 's:lib/gcc-lib/::' -e 's:/libgcc.a::' -e 's,\(.*\)/.*,\1,g'`/lib
173    if test -d ${gcclibs}/ldscripts -a -f ${gcclibs}/libc.a -a -f ${gcclibs}/libstdc++.a ; then
174	gcclibs=yes
175    else
176	gcclibs=no
177    fi
178fi
179
180dnl If everything is OK, then we can safely assume the compiler works.
181if test x"${gccfiles}" = xno -o x"${gcclibs}" = xno; then
182    ac_cv_prog_cc_works=no
183    AC_MSG_ERROR(${CC} is a non-working cross compiler)    
184else
185    ac_cv_prog_cc_works=yes
186fi
187
188AC_LANG_RESTORE
189AC_MSG_RESULT($ac_cv_prog_cc_works)
190if test x"$ac_cv_prog_cc_works" = xno; then
191  AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
192fi
193AC_MSG_CHECKING([whether the Gcc compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler])
194AC_MSG_RESULT($ac_cv_prog_cc_cross)
195cross_compiling=$ac_cv_prog_cc_cross
196AC_SUBST(CC)
197])
198
199dnl ====================================================================
200dnl Find the BFD library in the build tree. This is used to access and
201dnl manipulate object or executable files.
202AC_DEFUN(CYG_AC_PATH_BFD, [
203AC_MSG_CHECKING(for the bfd header in the build tree)
204dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
205dnl Look for the header file
206AC_CACHE_VAL(ac_cv_c_bfdh,[
207for i in $dirlist; do
208    if test -f "$i/bfd/bfd.h" ; then
209	ac_cv_c_bfdh=`(cd $i/bfd; pwd)`
210	break
211    fi
212done
213])
214if test x"${ac_cv_c_bfdh}" != x; then
215    BFDHDIR="-I${ac_cv_c_bfdh}"
216    AC_MSG_RESULT(${ac_cv_c_bfdh})
217else
218    AC_MSG_RESULT(none)
219fi
220AC_SUBST(BFDHDIR)
221
222dnl Look for the library
223AC_MSG_CHECKING(for the bfd library in the build tree)
224AC_CACHE_VAL(ac_cv_c_bfdlib,[
225for i in $dirlist; do
226    if test -f "$i/bfd/Makefile" ; then
227	ac_cv_c_bfdlib=`(cd $i/bfd; pwd)`
228    fi
229done
230])
231dnl We list two directories cause bfd now uses libtool
232if test x"${ac_cv_c_bfdlib}" != x; then
233    BFDLIB="-L${ac_cv_c_bfdlib} -L${ac_cv_c_bfdlib}/.libs"
234    AC_MSG_RESULT(${ac_cv_c_bfdlib})
235else
236    AC_MSG_RESULT(none)
237fi
238AC_SUBST(BFDLIB)
239])
240
241dnl ====================================================================
242dnl Find the libiberty library. This defines many commonly used C
243dnl functions that exists in various states based on the underlying OS.
244AC_DEFUN(CYG_AC_PATH_LIBERTY, [
245AC_MSG_CHECKING(for the liberty library in the build tree)
246dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
247AC_CACHE_VAL(ac_cv_c_liberty,[
248for i in $dirlist; do
249    if test -f "$i/libiberty/Makefile" ; then
250	ac_cv_c_liberty=`(cd $i/libiberty; pwd)`
251    fi
252done
253])
254if test x"${ac_cv_c_liberty}" != x; then
255    LIBERTY="-L${ac_cv_c_liberty}"
256    AC_MSG_RESULT(${ac_cv_c_liberty})
257else
258    AC_MSG_RESULT(none)
259fi
260AC_SUBST(LIBERTY)
261])
262
263dnl ====================================================================
264dnl Find the opcodes library. This is used to do dissasemblies.
265AC_DEFUN(CYG_AC_PATH_OPCODES, [
266AC_MSG_CHECKING(for the opcodes library in the build tree)
267dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
268AC_CACHE_VAL(ac_cv_c_opc,[
269for i in $dirlist; do
270    if test -f "$i/opcodes/Makefile" ; then
271	ac_cv_c_opc=`(cd $i/opcodes; pwd)`
272    fi
273done
274])
275if test x"${ac_cv_c_opc}" != x; then
276    OPCODESLIB="-L${ac_cv_c_opc}"
277    AC_MSG_RESULT(${ac_cv_c_opc})
278else
279    AC_MSG_RESULT(none)
280fi
281AC_SUBST(OPCODESLIB)
282])
283
284dnl ====================================================================
285dnl Look for the DejaGnu header file in the source tree. This file
286dnl defines the functions used to testing support.
287AC_DEFUN(CYG_AC_PATH_DEJAGNU, [
288AC_MSG_CHECKING(for the testing support files in the source tree)
289dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
290AC_CACHE_VAL(ac_cv_c_dejagnu,[
291for i in $dirlist; do
292    if test -f "$srcdir/$i/ecc/ecc/infra/testlib/current/include/dejagnu.h" ; then
293	ac_cv_c_dejagnu=`(cd $srcdir/$i/ecc/ecc/infra/testlib/current/include; pwd)`
294    fi
295done
296])
297if test x"${ac_cv_c_dejagnu}" != x; then
298    DEJAGNUHDIR="-I${ac_cv_c_dejagnu}"
299    AC_MSG_RESULT(${ac_cv_c_dejagnu})
300else
301    AC_MSG_RESULT(none)
302fi
303AC_CACHE_VAL(ac_cv_c_dejagnulib,[
304for i in $dirlist; do
305    if test -f "$srcdir/$i/infra/testlib/current/lib/hostutil.exp" ; then
306	ac_cv_c_dejagnulib=`(cd $srcdir/$i/infra/testlib/current/lib; pwd)`
307    fi
308done
309])
310if test x"${ac_cv_c_dejagnulib}" != x; then
311    DEJAGNULIB="${ac_cv_c_dejagnulib}"
312else
313    DEJAGNULIB=""
314fi
315AC_MSG_CHECKING(for runtest in the source tree)
316AC_CACHE_VAL(ac_cv_c_runtest,[
317for i in $dirlist; do
318    if test -f "$srcdir/$i/dejagnu/runtest" ; then
319	ac_cv_c_runtest=`(cd $srcdir/$i/dejagnu; pwd)`
320    fi
321done
322])
323if test x"${ac_cv_c_runtest}" != x; then
324    RUNTESTDIR="${ac_cv_c_runtest}"
325   AC_MSG_RESULT(${ac_cv_c_runtest})
326else
327    RUNTESTDIR=""
328    AC_MSG_RESULT(none)
329fi
330AC_SUBST(RUNTESTDIR)
331AC_SUBST(DEJAGNULIB)
332AC_SUBST(DEJAGNUHDIR)
333])
334
335dnl ====================================================================
336dnl Find the libintl library in the build tree. This is for
337dnl  internationalization support.
338AC_DEFUN(CYG_AC_PATH_INTL, [
339AC_MSG_CHECKING(for the intl header in the build tree)
340dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
341dnl Look for the header file
342AC_CACHE_VAL(ac_cv_c_intlh,[
343for i in $dirlist; do
344    if test -f "$i/intl/libintl.h" ; then
345	ac_cv_c_intlh=`(cd $i/intl; pwd)`
346	break
347    fi
348done
349])
350if test x"${ac_cv_c_intlh}" != x; then
351    INTLHDIR="-I${ac_cv_c_intlh}"
352    AC_MSG_RESULT(${ac_cv_c_intlh})
353else
354    AC_MSG_RESULT(none)
355fi
356AC_SUBST(INTLHDIR)
357
358dnl Look for the library
359AC_MSG_CHECKING(for the libintl library in the build tree)
360AC_CACHE_VAL(ac_cv_c_intllib,[
361for i in $dirlist; do
362    if test -f "$i/intl/Makefile" ; then
363	ac_cv_c_intllib=`(cd $i/intl; pwd)`
364    fi
365done
366])
367if test x"${ac_cv_c_intllib}" != x; then
368    INTLLIB="-L${ac_cv_c_intllib} -lintl"
369    AC_MSG_RESULT(${ac_cv_c_intllib})
370else
371    AC_MSG_RESULT(none)
372fi
373AC_SUBST(INTLLIB)
374])
375
376dnl ====================================================================
377dnl Find the simulator library.
378AC_DEFUN(CYG_AC_PATH_SIM, [
379dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.. ../../../../../../../../../.."
380case "$target_cpu" in
381    powerpc)	target_dir=ppc ;;
382    sparc*)	target_dir=erc32 ;;
383    mips*)	target_dir=mips ;;
384    *)		target_dir=$target_cpu ;;
385esac
386dnl First look for the header file
387AC_MSG_CHECKING(for the simulator header file)
388AC_CACHE_VAL(ac_cv_c_simh,[
389for i in $dirlist; do
390    if test -f "${srcdir}/$i/include/remote-sim.h" ; then
391	ac_cv_c_simh=`(cd ${srcdir}/$i/include; pwd)`
392	break
393    fi
394done
395])
396if test x"${ac_cv_c_simh}" != x; then
397    SIMHDIR="-I${ac_cv_c_simh}"
398    AC_MSG_RESULT(${ac_cv_c_simh})
399else
400    AC_MSG_RESULT(none)
401fi
402AC_SUBST(SIMHDIR)
403
404dnl See whether it's a devo or Foundry branch simulator
405AC_MSG_CHECKING(Whether this is a devo simulator )
406AC_CACHE_VAL(ac_cv_c_simdevo,[
407    CPPFLAGS="$CPPFLAGS $SIMHDIR"
408    AC_EGREP_HEADER([SIM_DESC sim_open.*struct _bfd], remote-sim.h,
409        ac_cv_c_simdevo=yes,
410        ac_cv_c_simdevo=no)
411])
412if test x"$ac_cv_c_simdevo" = x"yes" ; then
413    AC_DEFINE(HAVE_DEVO_SIM)
414fi
415AC_MSG_RESULT(${ac_cv_c_simdevo})
416AC_SUBST(HAVE_DEVO_SIM)
417
418dnl Next look for the library
419AC_MSG_CHECKING(for the simulator library)
420AC_CACHE_VAL(ac_cv_c_simlib,[
421for i in $dirlist; do
422    if test -f "$i/sim/$target_dir/Makefile" ; then
423	ac_cv_c_simlib=`(cd $i/sim/$target_dir; pwd)`
424    fi
425done
426])
427if test x"${ac_cv_c_simlib}" != x; then
428    SIMLIB="-L${ac_cv_c_simlib}"
429else
430    AC_MSG_RESULT(none)
431    dnl FIXME: this is kinda bogus, cause umtimately the TM will build
432    dnl all the libraries for several architectures. But for now, this
433    dnl will work till then.
434dnl     AC_MSG_CHECKING(for the simulator installed with the compiler libraries)
435    dnl Transform the name of the compiler to it's cross variant, unless
436    dnl CXX is set. This is also what CXX gets set to in the generated
437    dnl Makefile.
438    CROSS_GCC=`echo gcc | sed -e "s/^/$target/"`
439
440    dnl Get G++'s full path to libgcc.a
441changequote(,)
442    gccpath=`${CROSS_GCC} --print-libgcc | sed -e 's:[a-z0-9A-Z\.\-]*/libgcc.a::' -e 's:lib/gcc-lib/::'`lib
443changequote([,])
444    if test -f $gccpath/libsim.a -o -f $gccpath/libsim.so ; then
445        ac_cv_c_simlib="$gccpath/"
446        SIMLIB="-L${ac_cv_c_simlib}"
447	AC_MSG_RESULT(${ac_cv_c_simlib})
448    else
449        AM_CONDITIONAL(PSIM, test x$psim = xno)
450	SIMLIB=""
451	AC_MSG_RESULT(none)
452dnl         ac_cv_c_simlib=none
453    fi
454fi
455AC_SUBST(SIMLIB)
456])
457
458dnl ====================================================================
459dnl Find the libiberty library.
460AC_DEFUN(CYG_AC_PATH_LIBIBERTY, [
461AC_MSG_CHECKING(for the libiberty library in the build tree)
462dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
463AC_CACHE_VAL(ac_cv_c_libib,[
464for i in $dirlist; do
465    if test -f "$i/libiberty/Makefile" ; then
466	ac_cv_c_libib=`(cd $i/libiberty/; pwd)`
467    fi
468done
469])
470if test x"${ac_cv_c_libib}" != x; then
471    LIBIBERTY="-L${ac_cv_c_libib}"
472    AC_MSG_RESULT(${ac_cv_c_libib})
473else
474    AC_MSG_RESULT(none)
475fi
476AC_SUBST(LIBIBERTY)
477])
478
479dnl ====================================================================
480AC_DEFUN(CYG_AC_PATH_DEVO, [
481AC_MSG_CHECKING(for devo headers in the source tree)
482dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
483AC_CACHE_VAL(ac_cv_c_devoh,[
484for i in $dirlist; do
485    if test -f "${srcdir}/$i/include/remote-sim.h" ; then
486	ac_cv_c_devoh=`(cd ${srcdir}/$i/include; pwd)`
487    fi
488done
489])
490if test x"${ac_cv_c_devoh}" != x; then
491    DEVOHDIR="-I${ac_cv_c_devoh}"
492    AC_MSG_RESULT(${ac_cv_c_devoh})
493else
494    AC_MSG_RESULT(none)
495fi
496AC_SUBST(DEVOHDIR)
497])
498
499dnl ====================================================================
500dnl find the IDE library and headers.
501AC_DEFUN(CYG_AC_PATH_IDE, [
502AC_MSG_CHECKING(for IDE headers in the source tree)
503dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
504IDEHDIR=
505IDELIB=
506AC_CACHE_VAL(ac_cv_c_ideh,[
507for i in $dirlist; do
508    if test -f "${srcdir}/$i/libide/src/event.h" ; then
509	ac_cv_c_ideh=`(cd ${srcdir}/$i/libide/src; pwd)`;
510    fi
511done
512])
513if test x"${ac_cv_c_ideh}" != x; then
514    IDEHDIR="-I${ac_cv_c_ideh}"
515    AC_MSG_RESULT(${ac_cv_c_ideh})
516else
517    AC_MSG_RESULT(none)
518fi
519
520AC_MSG_CHECKING(for LIBIDE TCL headers in the source tree)
521AC_CACHE_VAL(ac_cv_c_idetclh,[
522for i in $dirlist; do
523    if test -f "${srcdir}/$i/libidetcl/src/idetcl.h" ; then
524	ac_cv_c_idetclh=`(cd ${srcdir}/$i/libidetcl/src; pwd)`;
525    fi
526done
527])
528if test x"${ac_cv_c_idetclh}" != x; then
529    IDEHDIR="${IDEHDIR} -I${ac_cv_c_idetclh}"
530    AC_MSG_RESULT(${ac_cv_c_idetclh})
531else
532    AC_MSG_RESULT(none)
533fi
534
535AC_MSG_CHECKING(for IDE headers in the build tree)
536AC_CACHE_VAL(ac_cv_c_ideh2,[
537for i in $dirlist; do
538    if test -f "$i/libide/src/Makefile" ; then
539	ac_cv_c_ideh2=`(cd $i/libide/src; pwd)`;
540    fi
541done
542])
543if test x"${ac_cv_c_ideh2}" != x; then
544    IDEHDIR="${IDEHDIR} -I${ac_cv_c_ideh2}"
545    AC_MSG_RESULT(${ac_cv_c_ideh2})
546else
547    AC_MSG_RESULT(none)
548fi
549
550dnl look for the library
551AC_MSG_CHECKING(for IDE library)
552AC_CACHE_VAL(ac_cv_c_idelib,[
553if test x"${ac_cv_c_idelib}" = x ; then
554    for i in $dirlist; do
555      if test -f "$i/libide/src/Makefile" ; then
556        ac_cv_c_idelib=`(cd $i/libide/src; pwd)`
557        break
558      fi
559    done
560fi]) 
561if test x"${ac_cv_c_idelib}" != x ; then
562     IDELIB="-L${ac_cv_c_idelib}"
563     AC_MSG_RESULT(${ac_cv_c_idelib})
564else
565     AC_MSG_RESULT(none)
566fi
567
568dnl find libiddetcl.a if it exists
569AC_MSG_CHECKING(for IDE TCL library)
570AC_CACHE_VAL(ac_cv_c_idetcllib,[
571if test x"${ac_cv_c_idetcllib}" = x ; then
572    for i in $dirlist; do
573      if test -f "$i/libidetcl/src/Makefile" ; then
574        ac_cv_c_idetcllib=`(cd $i/libidetcl/src; pwd)`
575        break
576      fi
577    done
578fi
579]) 
580if test x"${ac_cv_c_idetcllib}" != x ; then
581     IDELIB="${IDELIB} -L${ac_cv_c_idetcllib}"
582     IDETCLLIB="-lidetcl"
583     AC_MSG_RESULT(${ac_cv_c_idetcllib})
584else
585     AC_MSG_RESULT(none)
586fi
587AC_SUBST(IDEHDIR)
588AC_SUBST(IDELIB)
589AC_SUBST(IDETCLLIB)
590])
591
592dnl ====================================================================
593dnl Find all the ILU headers and libraries
594AC_DEFUN(CYG_AC_PATH_ILU, [
595AC_MSG_CHECKING(for ILU kernel headers in the source tree)
596dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
597AC_CACHE_VAL(ac_cv_c_iluh,[
598for i in $dirlist; do
599    if test -f "${srcdir}/$i/ilu/runtime/kernel/method.h" ; then
600	ac_cv_c_iluh=`(cd ${srcdir}/$i/ilu/runtime/kernel; pwd)`
601    fi
602done
603])
604if test x"${ac_cv_c_iluh}" != x; then
605    ILUHDIR="-I${ac_cv_c_iluh}"
606    AC_MSG_RESULT(${ac_cv_c_iluh})
607else
608    AC_MSG_RESULT(none)
609fi
610
611AC_MSG_CHECKING(for ILU kernel headers in the build tree)
612dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
613AC_CACHE_VAL(ac_cv_c_iluh5,[
614for i in $dirlist; do
615    if test -f "$i/ilu/runtime/kernel/iluconf.h" ; then
616	ac_cv_c_iluh5=`(cd $i/ilu/runtime/kernel; pwd)`
617    fi
618done
619])
620if test x"${ac_cv_c_iluh5}" != x; then
621    ILUHDIR="${ILUHDIR} -I${ac_cv_c_iluh5}"
622    AC_MSG_RESULT(${ac_cv_c_iluh5})
623else
624    AC_MSG_RESULT(none)
625fi
626
627AC_MSG_CHECKING(for ILU C++ headers in the source tree)
628AC_CACHE_VAL(ac_cv_c_iluh2,[
629for i in $dirlist; do
630    if test -f "${srcdir}/$i/ilu/stubbers/cpp/resource.h" ; then
631	ac_cv_c_iluh2=`(cd ${srcdir}/$i/ilu/stubbers/cpp; pwd)`
632    fi
633done
634])
635if test x"${ac_cv_c_iluh2}" != x; then
636    ILUHDIR="${ILUHDIR} -I${ac_cv_c_iluh2}"
637    AC_MSG_RESULT(${ac_cv_c_iluh2})
638else
639    AC_MSG_RESULT(none)
640fi
641
642AC_MSG_CHECKING(for ILU C headers)
643AC_CACHE_VAL(ac_cv_c_iluh3,[
644for i in $dirlist; do
645    if test -f "${srcdir}/$i/ilu/stubbers/c/resource.h" ; then
646	ac_cv_c_iluh3=`(cd ${srcdir}/$i/ilu/stubbers/c  ; pwd)`
647    fi
648done
649])
650if test x"${ac_cv_c_iluh3}" != x; then
651    ILUHDIR="${ILUHDIR} -I${ac_cv_c_iluh3}"
652    AC_MSG_RESULT(${ac_cv_c_iluh3})
653else
654    AC_MSG_RESULT(none)
655fi
656
657AC_MSG_CHECKING(for ILU C runtime headers)
658AC_CACHE_VAL(ac_cv_c_iluh4,[
659for i in $dirlist; do
660    if test -f "${srcdir}/$i/ilu/runtime/c/ilucstub.h" ; then
661	ac_cv_c_iluh4=`(cd ${srcdir}/$i/ilu/runtime/c  ; pwd)`
662    fi
663done
664])
665if test x"${ac_cv_c_iluh4}" != x; then
666    ILUHDIR="${ILUHDIR} -I${ac_cv_c_iluh4}"
667    AC_MSG_RESULT(${ac_cv_c_iluh4})
668else
669    AC_MSG_RESULT(none)
670fi
671
672AC_CACHE_VAL(ac_cv_c_ilupath,[
673for i in $dirlist; do
674    if test -f "$i/ilu/Makefile" ; then
675	ac_cv_c_ilupath=`(cd $i/ilu; pwd)`
676	break
677    fi
678done
679])
680ILUTOP=${ac_cv_c_ilupath}
681
682AC_MSG_CHECKING(for the ILU library in the build tree)
683AC_CACHE_VAL(ac_cv_c_ilulib,[
684if test -f "$ac_cv_c_ilupath/runtime/kernel/Makefile" ; then
685    ac_cv_c_ilulib=`(cd $ac_cv_c_ilupath/runtime/kernel; pwd)`
686    AC_MSG_RESULT(found ${ac_cv_c_ilulib}/libilu.a)
687else
688    AC_MSG_RESULT(no)
689fi])
690   
691AC_MSG_CHECKING(for the ILU C++ bindings library in the build tree)
692AC_CACHE_VAL(ac_cv_c_ilulib2,[
693if test -f "$ac_cv_c_ilupath/runtime/cpp/Makefile" ; then
694    ac_cv_c_ilulib2=`(cd $ac_cv_c_ilupath/runtime/cpp; pwd)`
695    AC_MSG_RESULT(found ${ac_cv_c_ilulib2}/libilu-c++.a)
696else
697    AC_MSG_RESULT(no)
698fi])
699
700AC_MSG_CHECKING(for the ILU C bindings library in the build tree)
701AC_CACHE_VAL(ac_cv_c_ilulib3,[
702if test -f "$ac_cv_c_ilupath/runtime/c/Makefile" ; then
703    ac_cv_c_ilulib3=`(cd $ac_cv_c_ilupath/runtime/c; pwd)`
704    AC_MSG_RESULT(found ${ac_cv_c_ilulib3}/libilu-c.a)
705else
706    AC_MSG_RESULT(no)
707fi])
708
709AC_MSG_CHECKING(for the ILU Tk bindings library in the build tree)
710AC_CACHE_VAL(ac_cv_c_ilulib4,[
711if test -f "$ac_cv_c_ilupath/runtime/mainloop/Makefile" ; then
712    ac_cv_c_ilulib4=`(cd $ac_cv_c_ilupath/runtime/mainloop; pwd)`
713    AC_MSG_RESULT(found ${ac_cv_c_ilulib4}/libilu-tk.a)
714else
715    AC_MSG_RESULT(no)
716fi])
717
718if test x"${ac_cv_c_ilulib}" = x -a x"${ac_cv_c_ilulib2}" = x; then
719  ILUHDIR=""
720fi
721
722if test x"${ac_cv_c_ilulib}" != x -a x"${ac_cv_c_ilulib2}" != x; then
723    ILULIB="-L${ac_cv_c_ilulib} -L${ac_cv_c_ilulib2} -L${ac_cv_c_ilulib3} -L${ac_cv_c_ilulib4}"
724else
725    ILULIB=""
726fi
727
728if test x"${ILULIB}" = x; then
729    AC_MSG_CHECKING(for ILU libraries installed with the compiler)
730    AC_CACHE_VAL(ac_cv_c_ilulib5,[
731    NATIVE_GCC=`echo gcc | sed -e "${program_transform_name}"`
732
733    dnl Get G++'s full path to it's libraries
734    ac_cv_c_ilulib5=`${NATIVE_GCC} --print-libgcc | sed -e 's:lib/gcc-lib/.*::'`lib
735    if test -f $ac_cv_c_ilulib5/libilu-c.a -o -f $ac_cv_c_ilulib5/libilu-c.so ; then
736        if test x"${ILUHDIR}" = x; then
737               ILUHDIR="-I${ac_cv_c_ilulib5}/../include"
738        fi
739        ILULIB="-L${ac_cv_c_ilulib5}"
740        AC_MSG_RESULT(${ac_cv_c_ilulib5})
741    else
742        ac_cv_c_ilulib=none
743        AC_MSG_RESULT(none)
744    fi
745fi])
746AC_SUBST(ILUHDIR)
747AC_SUBST(ILULIB)
748AC_SUBST(ILUTOP)
749])
750
751dnl ====================================================================
752dnl This defines the byte order for the host. We can't use
753dnl AC_C_BIGENDIAN, cause we want to create a config file and
754dnl substitue the real value, so the header files work right
755AC_DEFUN(CYG_AC_C_ENDIAN, [
756AC_MSG_CHECKING(to see if this is a little endian host)
757AC_CACHE_VAL(ac_cv_c_little_endian, [
758ac_cv_c_little_endian=unknown
759# See if sys/param.h defines the BYTE_ORDER macro.
760AC_TRY_COMPILE([#include <sys/types.h>
761#include <sys/param.h>], [
762#if !BYTE_ORDER || !_BIG_ENDIAN || !_LITTLE_ENDIAN
763 bogus endian macros
764#endif], [# It does; now see whether it defined to _LITTLE_ENDIAN or not.
765AC_TRY_COMPILE([#include <sys/types.h>
766#include <sys/param.h>], [
767#if BYTE_ORDER != _LITTLE_ENDIAN
768 not big endian
769#endif], ac_cv_c_little_endian=yes, ac_cv_c_little_endian=no)
770])
771if test ${ac_cv_c_little_endian} = unknown; then
772old_cflags=$CFLAGS
773CFLAGS=-g
774AC_TRY_RUN([
775main () {
776  /* Are we little or big endian?  From Harbison&Steele.  */
777  union
778  {
779    long l;
780    char c[sizeof (long)];
781  } u;
782  u.l = 1;
783  exit (u.c[0] == 1);
784}],
785ac_cv_c_little_endian=no,
786ac_cv_c_little_endian=yes,[
787dnl Yes, this is ugly, and only used for a canadian cross anyway. This
788dnl is just to keep configure from stopping here.
789case "${host}" in
790changequote(,)
791   i[3456]86-*-*) ac_cv_c_little_endian=yes ;;
792   sparc*-*-*)    ac_cv_c_little_endian=no ;;
793changequote([,])
794  *)    AC_MSG_WARN(Can't cross compile this test) ;;
795esac])
796CFLAGS=$old_cflags
797fi])
798
799if test x"${ac_cv_c_little_endian}" = xyes; then
800    AC_DEFINE(LITTLE_ENDIAN_HOST)
801    ENDIAN="CYG_LSBFIRST";
802else
803    ENDIAN="CYG_MSBFIRST";
804fi
805AC_MSG_RESULT(${ac_cv_c_little_endian})
806AC_SUBST(ENDIAN)
807])
808
809dnl ====================================================================
810dnl Look for the path to libgcc, so we can use it to directly link
811dnl in libgcc.a with LD.
812AC_DEFUN(CYG_AC_PATH_LIBGCC,
813[AC_MSG_CHECKING([Looking for the path to libgcc.a])
814AC_LANG_SAVE
815AC_LANG_C
816
817dnl Get Gcc's full path to libgcc.a
818libgccpath=`${CC} --print-libgcc`
819
820dnl If we don't have a path with libgcc.a on the end, this isn't G++.
821if test `echo $libgccpath | sed -e 's:/.*/::'` = libgcc.a ; then
822   ac_cv_prog_gcc=yes
823else
824   ac_cv_prog_gcc=no
825fi
826
827dnl 
828if test x"${ac_cv_prog_gcc}" = xyes ; then
829   gccpath=`echo $libgccpath | sed -e 's:/libgcc.a::'`
830   LIBGCC="-L${gccpath}"
831   AC_MSG_RESULT(${gccpath})
832else
833   LIBGCC=""
834   AC_MSG_ERROR(Not using gcc)
835fi
836
837AC_LANG_RESTORE
838AC_SUBST(LIBGCC)
839])
840
841dnl ====================================================================
842dnl Ok, lets find the tcl source trees so we can use the headers
843dnl Warning: transition of version 9 to 10 will break this algorithm
844dnl because 10 sorts before 9. We also look for just tcl. We have to
845dnl be careful that we don't match stuff like tclX by accident.
846dnl the alternative search directory is involked by --with-tclinclude
847AC_DEFUN(CYG_AC_PATH_TCL, [
848    CYG_AC_PATH_TCLH
849    CYG_AC_PATH_TCLCONFIG
850    CYG_AC_LOAD_TCLCONFIG
851])
852AC_DEFUN(CYG_AC_PATH_TCLH, [
853dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
854no_tcl=true
855AC_MSG_CHECKING(for Tcl headers in the source tree)
856AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory where tcl headers are], with_tclinclude=${withval})
857AC_CACHE_VAL(ac_cv_c_tclh,[
858dnl first check to see if --with-tclinclude was specified
859if test x"${with_tclinclude}" != x ; then
860  if test -f ${with_tclinclude}/tcl.h ; then
861    ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
862  elif test -f ${with_tclinclude}/generic/tcl.h ; then
863    ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
864  else
865    AC_MSG_ERROR([${with_tclinclude} directory doesn't contain headers])
866  fi
867fi
868
869dnl next check if it came with Tcl configuration file
870if test x"${ac_cv_c_tclconfig}" != x ; then
871  for i in $dirlist; do
872    if test -f $ac_cv_c_tclconfig/$i/generic/tcl.h ; then
873      ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/$i/generic; pwd)`
874      break
875    fi
876  done
877fi
878
879dnl next check in private source directory
880dnl since ls returns lowest version numbers first, reverse its output
881if test x"${ac_cv_c_tclh}" = x ; then
882    dnl find the top level Tcl source directory
883    for i in $dirlist; do
884        if test -n "`ls -dr $srcdir/$i/tcl* 2>/dev/null`" ; then
885	    tclpath=$srcdir/$i
886	    break
887	fi
888    done
889
890    dnl find the exact Tcl source dir. We do it this way, cause there
891    dnl might be multiple version of Tcl, and we want the most recent one.
892    for i in `ls -dr $tclpath/tcl* 2>/dev/null ` ; do
893        if test -f $i/generic/tcl.h ; then
894          ac_cv_c_tclh=`(cd $i/generic; pwd)`
895          break
896        fi
897    done
898fi
899
900dnl check if its installed with the compiler
901if test x"${ac_cv_c_tclh}" = x ; then
902    dnl Get the path to the compiler
903    ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/include
904    if test -f $ccpath/tcl.h; then
905        ac_cv_c_tclh=$ccpath
906    fi
907fi
908
909dnl see if one is installed
910if test x"${ac_cv_c_tclh}" = x ; then
911   AC_MSG_RESULT(none)
912   AC_CHECK_HEADER(tcl.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
913else
914   AC_MSG_RESULT(${ac_cv_c_tclh})
915fi
916])
917  TCLHDIR=""
918if test x"${ac_cv_c_tclh}" = x ; then
919    AC_MSG_ERROR([Can't find any Tcl headers])
920fi
921if test x"${ac_cv_c_tclh}" != x ; then
922    no_tcl=""
923    if test x"${ac_cv_c_tclh}" != x"installed" ; then
924	if test x"${CC}" = xcl ; then
925	    tmp="`cygpath --windows ${ac_cv_c_tclh}`"
926	    ac_cv_c_tclh="`echo $tmp | sed -e s#\\\\\\\\#/#g`"
927	fi
928        AC_MSG_RESULT(${ac_cv_c_tclh})
929        TCLHDIR="-I${ac_cv_c_tclh}"
930    fi
931fi
932
933AC_SUBST(TCLHDIR)
934])
935
936dnl ====================================================================
937dnl Ok, lets find the tcl configuration
938AC_DEFUN(CYG_AC_PATH_TCLCONFIG, [
939dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
940dnl First, look for one uninstalled.  
941dnl the alternative search directory is invoked by --with-tclconfig
942if test x"${no_tcl}" = x ; then
943  dnl we reset no_tcl in case something fails here
944    no_tcl=true
945    AC_ARG_WITH(tclconfig, [  --with-tclconfig           directory containing tcl configuration (tclConfig.sh)],
946         with_tclconfig=${withval})
947    AC_MSG_CHECKING([for Tcl configuration script])
948    AC_CACHE_VAL(ac_cv_c_tclconfig,[
949
950    dnl First check to see if --with-tclconfig was specified.
951    if test x"${with_tclconfig}" != x ; then
952        if test -f "${with_tclconfig}/tclConfig.sh" ; then
953            ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
954        else
955            AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
956        fi
957    fi
958
959    dnl next check if it came with Tcl configuration file in the source tree
960    if test x"${ac_cv_c_tclconfig}" = x ; then
961        for i in $dirlist; do
962            if test -f $srcdir/$i/unix/tclConfig.sh ; then
963                ac_cv_c_tclconfig=`(cd $srcdir/$i/unix; pwd)`
964	        break
965            fi
966        done
967    fi
968    dnl check in a few other locations
969    if test x"${ac_cv_c_tclconfig}" = x ; then
970        dnl find the top level Tcl source directory
971        for i in $dirlist; do
972            if test -n "`ls -dr $i/tcl* 2>/dev/null`" ; then
973	        tclconfpath=$i
974	        break
975	    fi
976        done
977
978        dnl find the exact Tcl dir. We do it this way, cause there
979        dnl might be multiple version of Tcl, and we want the most recent one.
980        for i in `ls -dr $tclconfpath/tcl* 2>/dev/null ` ; do
981            if test -f $i/unix/tclConfig.sh ; then
982                ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
983                break
984            fi
985        done
986    fi
987
988    dnl Check to see if it's installed. We have to look in the $CC path
989    dnl to find it, cause our $prefix may not match the compilers.
990    if test x"${ac_cv_c_tclconfig}" = x ; then
991        dnl Get the path to the compiler
992	ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/lib
993        if test -f $ccpath/tclConfig.sh; then
994	    ac_cv_c_tclconfig=$ccpath
995        fi
996    fi
997    ])	dnl end of cache_val
998
999    if test x"${ac_cv_c_tclconfig}" = x ; then
1000        TCLCONFIG=""
1001        AC_MSG_WARN(Can't find Tcl configuration definitions)
1002    else
1003        no_tcl=""
1004        TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
1005        AC_MSG_RESULT(${TCLCONFIG})
1006     fi
1007fi
1008AC_SUBST(TCLCONFIG)
1009])
1010
1011dnl Defined as a separate macro so we don't have to cache the values
1012dnl from PATH_TCLCONFIG (because this can also be cached).
1013AC_DEFUN(CYG_AC_LOAD_TCLCONFIG, [
1014    . $TCLCONFIG
1015
1016dnl AC_SUBST(TCL_VERSION)
1017dnl AC_SUBST(TCL_MAJOR_VERSION)
1018dnl AC_SUBST(TCL_MINOR_VERSION)
1019dnl AC_SUBST(TCL_CC)
1020    AC_SUBST(TCL_DEFS)
1021
1022dnl not used, don't export to save symbols
1023    AC_SUBST(TCL_LIB_FILE)
1024    AC_SUBST(TCL_LIB_FULL_PATH)
1025    AC_SUBST(TCL_LIBS)
1026dnl not used, don't export to save symbols
1027dnl    AC_SUBST(TCL_PREFIX)
1028
1029    AC_SUBST(TCL_CFLAGS)
1030
1031dnl not used, don't export to save symbols
1032dnl    AC_SUBST(TCL_EXEC_PREFIX)
1033
1034    AC_SUBST(TCL_SHLIB_CFLAGS)
1035    AC_SUBST(TCL_SHLIB_LD)
1036dnl don't export, not used outside of configure
1037dnl AC_SUBST(TCL_SHLIB_LD_LIBS)
1038dnl AC_SUBST(TCL_SHLIB_SUFFIX)
1039dnl not used, don't export to save symbols
1040dnl AC_SUBST(TCL_DL_LIBS)
1041    AC_SUBST(TCL_LD_FLAGS)
1042    AC_SUBST(TCL_LD_SEARCH_FLAGS)
1043dnl don't export, not used outside of configure
1044dnl AC_SUBST(TCL_COMPAT_OBJS)
1045    AC_SUBST(TCL_RANLIB)
1046    AC_SUBST(TCL_BUILD_LIB_SPEC)
1047    AC_SUBST(TCL_LIB_SPEC)
1048dnl AC_SUBST(TCL_LIB_VERSIONS_OK)
1049
1050dnl not used, don't export to save symbols
1051dnl    AC_SUBST(TCL_SHARED_LIB_SUFFIX)
1052
1053dnl not used, don't export to save symbols
1054dnl    AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
1055])
1056
1057dnl ====================================================================
1058AC_DEFUN(CYG_AC_PATH_TK, [
1059    CYG_AC_PATH_TKH
1060    CYG_AC_PATH_TKCONFIG
1061    CYG_AC_LOAD_TKCONFIG
1062])
1063AC_DEFUN(CYG_AC_PATH_TKH, [
1064#
1065# Ok, lets find the tk source trees so we can use the headers
1066# If the directory (presumably symlink) named "tk" exists, use that one
1067# in preference to any others.  Same logic is used when choosing library
1068# and again with Tcl. The search order is the best place to look first, then in
1069# decreasing significance. The loop breaks if the trigger file is found.
1070# Note the gross little conversion here of srcdir by cd'ing to the found
1071# directory. This converts the path from a relative to an absolute, so
1072# recursive cache variables for the path will work right. We check all
1073# the possible paths in one loop rather than many seperate loops to speed
1074# things up.
1075# the alternative search directory is involked by --with-tkinclude
1076#
1077dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1078no_tk=true
1079AC_MSG_CHECKING(for Tk headers in the source tree)
1080AC_ARG_WITH(tkinclude, [  --with-tkinclude       directory where tk headers are], with_tkinclude=${withval})
1081AC_CACHE_VAL(ac_cv_c_tkh,[
1082dnl first check to see if --with-tkinclude was specified
1083if test x"${with_tkinclude}" != x ; then
1084  if test -f ${with_tkinclude}/tk.h ; then
1085    ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
1086  elif test -f ${with_tkinclude}/generic/tk.h ; then
1087    ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; pwd)`
1088  else
1089    AC_MSG_ERROR([${with_tkinclude} directory doesn't contain headers])
1090  fi
1091fi
1092
1093dnl next check if it came with Tk configuration file
1094if test x"${ac_cv_c_tkconfig}" != x ; then
1095  for i in $dirlist; do
1096    if test -f $ac_cv_c_tkconfig/$i/generic/tk.h ; then
1097      ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/$i/generic; pwd)`
1098      break
1099    fi
1100  done
1101fi
1102
1103dnl next check in private source directory
1104dnl since ls returns lowest version numbers first, reverse its output
1105if test x"${ac_cv_c_tkh}" = x ; then
1106    dnl find the top level Tk source directory
1107    for i in $dirlist; do
1108        if test -n "`ls -dr $srcdir/$i/tk* 2>/dev/null`" ; then
1109	    tkpath=$srcdir/$i
1110	    break
1111	fi
1112    done
1113
1114    dnl find the exact Tk source dir. We do it this way, cause there
1115    dnl might be multiple version of Tk, and we want the most recent one.
1116    for i in `ls -dr $tkpath/tk* 2>/dev/null ` ; do
1117        if test -f $i/generic/tk.h ; then
1118          ac_cv_c_tkh=`(cd $i/generic; pwd)`
1119          break
1120        fi
1121    done
1122fi
1123
1124dnl see if one is installed
1125if test x"${ac_cv_c_tkh}" = x ; then
1126    AC_MSG_RESULT(none)
1127    dnl Get the path to the compiler. We do it this way instead of using
1128    dnl AC_CHECK_HEADER, cause this doesn't depend in having X configured.
1129    ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/include
1130    if test -f $ccpath/tk.h; then
1131	ac_cv_c_tkh=$ccpath
1132    fi
1133else
1134   AC_MSG_RESULT(${ac_cv_c_tkh})
1135fi
1136])
1137  TKHDIR=""
1138if test x"${ac_cv_c_tkh}" = x ; then
1139    AC_MSG_ERROR([Can't find any Tk headers])
1140fi
1141if test x"${ac_cv_c_tkh}" != x ; then
1142    no_tk=""
1143    if test x"${ac_cv_c_tkh}" != x"installed" ; then
1144	if test x"${CC}" = xcl ; then
1145	    tmp="`cygpath --windows ${ac_cv_c_tkh}`"
1146	    ac_cv_c_tkh="`echo $tmp | sed -e s#\\\\\\\\#/#g`"
1147	fi
1148        AC_MSG_RESULT([found in ${ac_cv_c_tkh}])
1149        TKHDIR="-I${ac_cv_c_tkh}"
1150    fi
1151fi
1152
1153AC_SUBST(TKHDIR)
1154])
1155
1156AC_DEFUN(CYG_AC_PATH_TKCONFIG, [
1157dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1158dnl First, look for one uninstalled.  
1159dnl the alternative search directory is invoked by --with-tkconfig
1160if test x"${no_tk}" = x ; then
1161  dnl we reset no_tk in case something fails here
1162    no_tk=true
1163    AC_ARG_WITH(tkconfig, [  --with-tkconfig           directory containing tk configuration (tkConfig.sh)],
1164         with_tkconfig=${withval})
1165    AC_MSG_CHECKING([for Tk configuration script])
1166    AC_CACHE_VAL(ac_cv_c_tkconfig,[
1167
1168    dnl First check to see if --with-tkconfig was specified.
1169    if test x"${with_tkconfig}" != x ; then
1170        if test -f "${with_tkconfig}/tkConfig.sh" ; then
1171            ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
1172        else
1173            AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
1174        fi
1175    fi
1176
1177    dnl next check if it came with Tk configuration file in the source tree
1178    if test x"${ac_cv_c_tkconfig}" = x ; then
1179        for i in $dirlist; do
1180            if test -f $srcdir/$i/unix/tkConfig.sh ; then
1181                ac_cv_c_tkconfig=`(cd $srcdir/$i/unix; pwd)`
1182	        break
1183            fi
1184        done
1185    fi
1186    dnl check in a few other locations
1187    if test x"${ac_cv_c_tkconfig}" = x ; then
1188        dnl find the top level Tk source directory
1189        for i in $dirlist; do
1190            if test -n "`ls -dr $i/tk* 2>/dev/null`" ; then
1191	        tkconfpath=$i
1192	        break
1193	    fi
1194        done
1195
1196        dnl find the exact Tk dir. We do it this way, cause there
1197        dnl might be multiple version of Tk, and we want the most recent one.
1198        for i in `ls -dr $tkconfpath/tk* 2>/dev/null ` ; do
1199            if test -f $i/unix/tkConfig.sh ; then
1200                ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
1201                break
1202            fi
1203        done
1204    fi
1205
1206    dnl Check to see if it's installed. We have to look in the $CC path
1207    dnl to find it, cause our $prefix may not match the compilers.
1208    if test x"${ac_cv_c_tkconfig}" = x ; then
1209        dnl Get the path to the compiler
1210	ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/lib
1211        if test -f $ccpath/tkConfig.sh; then
1212	    ac_cv_c_tkconfig=$ccpath
1213        fi
1214    fi
1215    ])	dnl end of cache_val
1216
1217    if test x"${ac_cv_c_tkconfig}" = x ; then
1218        TKCONFIG=""
1219        AC_MSG_WARN(Can't find Tk configuration definitions)
1220    else
1221        no_tk=""
1222        TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
1223        AC_MSG_RESULT(${TKCONFIG})
1224     fi
1225fi
1226AC_SUBST(TKCONFIG)
1227])
1228
1229dnl Defined as a separate macro so we don't have to cache the values
1230dnl from PATH_TKCONFIG (because this can also be cached).
1231AC_DEFUN(CYG_AC_LOAD_TKCONFIG, [
1232    if test -f "$TKCONFIG" ; then
1233      . $TKCONFIG
1234    fi
1235
1236    AC_SUBST(TK_VERSION)
1237dnl not actually used, don't export to save symbols
1238dnl    AC_SUBST(TK_MAJOR_VERSION)
1239dnl    AC_SUBST(TK_MINOR_VERSION)
1240    AC_SUBST(TK_DEFS)
1241
1242dnl not used, don't export to save symbols
1243    AC_SUBST(TK_LIB_FILE)
1244    AC_SUBST(TK_LIB_FULL_PATH)
1245    AC_SUBST(TK_LIBS)
1246dnl not used, don't export to save symbols
1247dnl    AC_SUBST(TK_PREFIX)
1248
1249dnl not used, don't export to save symbols
1250dnl    AC_SUBST(TK_EXEC_PREFIX)
1251    AC_SUBST(TK_BUILD_INCLUDES)
1252    AC_SUBST(TK_XINCLUDES)
1253    AC_SUBST(TK_XLIBSW)
1254    AC_SUBST(TK_BUILD_LIB_SPEC)
1255    AC_SUBST(TK_LIB_SPEC)
1256])
1257
1258dnl ====================================================================
1259dnl Ok, lets find the itcl source trees so we can use the headers
1260dnl the alternative search directory is involked by --with-itclinclude
1261AC_DEFUN(CYG_AC_PATH_ITCL, [
1262    CYG_AC_PATH_ITCLH
1263    CYG_AC_PATH_ITCLLIB
1264    CYG_AC_PATH_ITCLSH
1265    CYG_AC_PATH_ITCLMKIDX
1266])
1267AC_DEFUN(CYG_AC_PATH_ITCLH, [
1268dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1269no_itcl=true
1270AC_MSG_CHECKING(for Itcl headers in the source tree)
1271AC_ARG_WITH(itclinclude, [  --with-itclinclude       directory where itcl headers are], with_itclinclude=${withval})
1272AC_CACHE_VAL(ac_cv_c_itclh,[
1273dnl first check to see if --with-itclinclude was specified
1274if test x"${with_itclinclude}" != x ; then
1275  if test -f ${with_itclinclude}/itcl.h ; then
1276    ac_cv_c_itclh=`(cd ${with_itclinclude}; pwd)`
1277  elif test -f ${with_itclinclude}/src/itcl.h ; then
1278    ac_cv_c_itclh=`(cd ${with_itclinclude}/src; pwd)`
1279  else
1280    AC_MSG_ERROR([${with_itclinclude} directory doesn't contain headers])
1281  fi
1282fi
1283
1284dnl next check if it came with Itcl configuration file
1285if test x"${ac_cv_c_itclconfig}" != x ; then
1286  for i in $dirlist; do
1287    if test -f $ac_cv_c_itclconfig/$i/src/itcl.h ; then
1288      ac_cv_c_itclh=`(cd $ac_cv_c_itclconfig/$i/src; pwd)`
1289      break
1290    fi
1291  done
1292fi
1293
1294dnl next check in private source directory
1295dnl since ls returns lowest version numbers first, reverse its output
1296if test x"${ac_cv_c_itclh}" = x ; then
1297    dnl find the top level Itcl source directory
1298    for i in $dirlist; do
1299        if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
1300	    itclpath=$srcdir/$i
1301	    break
1302	fi
1303    done
1304
1305    dnl find the exact Itcl source dir. We do it this way, cause there
1306    dnl might be multiple version of Itcl, and we want the most recent one.
1307    for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
1308        if test -f $i/src/itcl.h ; then
1309          ac_cv_c_itclh=`(cd $i/src; pwd)`
1310          break
1311        fi
1312    done
1313fi
1314
1315dnl see if one is installed
1316if test x"${ac_cv_c_itclh}" = x ; then
1317   AC_MSG_RESULT(none)
1318   AC_CHECK_HEADER(itcl.h, ac_cv_c_itclh=installed, ac_cv_c_itclh="")
1319else
1320   AC_MSG_RESULT(${ac_cv_c_itclh})
1321fi
1322])
1323  ITCLHDIR=""
1324if test x"${ac_cv_c_itclh}" = x ; then
1325    AC_MSG_ERROR([Can't find any Itcl headers])
1326fi
1327if test x"${ac_cv_c_itclh}" != x ; then
1328    no_itcl=""
1329    if test x"${ac_cv_c_itclh}" != x"installed" ; then
1330        AC_MSG_RESULT(${ac_cv_c_itclh})
1331        ITCLHDIR="-I${ac_cv_c_itclh}"
1332    fi
1333fi
1334
1335AC_SUBST(ITCLHDIR)
1336])
1337
1338dnl Ok, lets find the itcl library
1339dnl First, look for one uninstalled.  
1340dnl the alternative search directory is invoked by --with-itcllib
1341AC_DEFUN(CYG_AC_PATH_ITCLLIB, [
1342dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1343if test x"${no_itcl}" = x ; then
1344    dnl we reset no_itcl incase something fails here
1345    no_itcl=true
1346    AC_ARG_WITH(itcllib,
1347	[  --with-itcllib           directory where the itcl library is],
1348        with_itcllib=${withval})
1349    AC_MSG_CHECKING([for Itcl library])
1350    AC_CACHE_VAL(ac_cv_c_itcllib,[
1351    dnl First check to see if --with-itcllib was specified.
1352    if test x"${with_itcllib}" != x ; then
1353        if test -f "${with_itcllib}/libitcl$TCL_SHARED_LIB_SUFFIX" ; then
1354            ac_cv_c_itcllib=`(cd ${with_itcllib}; pwd)`/libitcl$TCL_SHARED_LIB_SUFFIX
1355	else
1356	    if test -f "${with_itcllib}/libitcl$TCL_UNSHARED_LIB_SUFFIX"; then
1357	 	ac_cv_c_itcllib=`(cd ${with_itcllib}; pwd)`/libitcl$TCL_UNSHARED_LIB_SUFFIX
1358	    fi
1359	fi
1360    fi
1361    dnl then check for a  Itcl library. Since these are uninstalled,
1362    dnl use the simple lib name root. 
1363    if test x"${ac_cv_c_itcllib}" = x ; then
1364        dnl find the top level Itcl build directory
1365        for i in $dirlist; do
1366            if test -n "`ls -dr $i/itcl* 2>/dev/null`" ; then
1367	        itclpath=$i/itcl
1368	        break
1369	    fi
1370        done
1371        dnl Itcl 7.5 and greater puts library in subdir.  Look there first.
1372        if test -f "$itclpath/src/libitcl.$TCL_SHLIB_SUFFIX" ; then
1373	     ac_cv_c_itcllib=`(cd $itclpath/src; pwd)`
1374        elif test -f "$itclpath/src/libitcl.a"; then
1375	     ac_cv_c_itcllib=`(cd $itclpath/src; pwd)`
1376	fi
1377    fi
1378    dnl check in a few other private locations
1379    if test x"${ac_cv_c_itcllib}" = x ; then
1380        for i in ${dirlist}; do
1381            if test -n "`ls -dr ${srcdir}/$i/itcl* 2>/dev/null`" ; then
1382	        itclpath=${srcdir}/$i
1383	        break
1384	    fi
1385        done
1386        for i in `ls -dr ${itclpath}/itcl* 2>/dev/null` ; do
1387            dnl Itcl 7.5 and greater puts library in subdir.  Look there first.
1388            if test -f "$i/src/libitcl$TCL_SHLIB_SUFFIX" ; then
1389	        ac_cv_c_itcllib=`(cd $i/src; pwd)`
1390	        break
1391            elif test -f "$i/src/libitcl.a"; then
1392	        ac_cv_c_itcllib=`(cd $i/src; pwd)`
1393	        break
1394	    fi	
1395        done
1396    fi
1397
1398    dnl see if one is conveniently installed with the compiler
1399    if test x"${ac_cv_c_itcllib}" = x ; then
1400        dnl Get the path to the compiler
1401	ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/lib
1402        dnl Itcl 7.5 and greater puts library in subdir.  Look there first.
1403        if test -f "${ccpath}/libitcl$TCL_SHLIB_SUFFIX" ; then
1404	    ac_cv_c_itcllib=`(cd ${ccpath}; pwd)`
1405        elif test -f "${ccpath}/libitcl.a"; then
1406	    ac_cv_c_itcllib=`(cd ${ccpath}; pwd)`
1407        fi
1408    fi
1409    ])
1410    if test x"${ac_cv_c_itcllib}" = x ; then
1411        ITCLLIB=""
1412        AC_MSG_WARN(Can't find Itcl library)
1413    else
1414        ITCLLIB="-L${ac_cv_c_itcllib}"
1415        AC_MSG_RESULT(${ac_cv_c_itcllib})
1416        no_itcl=""
1417    fi
1418fi
1419
1420AC_PROVIDE([$0])
1421AC_SUBST(ITCLLIB)
1422])
1423
1424
1425dnl ====================================================================
1426dnl Ok, lets find the itcl source trees so we can use the itcl_sh script
1427dnl the alternative search directory is involked by --with-itclinclude
1428AC_DEFUN(CYG_AC_PATH_ITCLSH, [
1429dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1430no_itcl=true
1431AC_MSG_CHECKING(for the itcl_sh script)
1432AC_ARG_WITH(itclinclude, [  --with-itclinclude       directory where itcl headers are], with_itclinclude=${withval})
1433AC_CACHE_VAL(ac_cv_c_itclsh,[
1434dnl first check to see if --with-itclinclude was specified
1435if test x"${with_itclinclude}" != x ; then
1436  if test -f ${with_itclinclude}/itcl_sh ; then
1437    ac_cv_c_itclsh=`(cd ${with_itclinclude}; pwd)`
1438  elif test -f ${with_itclinclude}/src/itcl_sh ; then
1439    ac_cv_c_itclsh=`(cd ${with_itclinclude}/src; pwd)`
1440  else
1441    AC_MSG_ERROR([${with_itclinclude} directory doesn't contain itcl_sh])
1442  fi
1443fi
1444
1445dnl next check in private source directory
1446dnl since ls returns lowest version numbers first, reverse its output
1447if test x"${ac_cv_c_itclsh}" = x ; then
1448    dnl find the top level Itcl source directory
1449    for i in $dirlist; do
1450        if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
1451	    itclpath=$srcdir/$i
1452	    break
1453	fi
1454    done
1455
1456    dnl find the exact Itcl source dir. We do it this way, cause there
1457    dnl might be multiple version of Itcl, and we want the most recent one.
1458    for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
1459        if test -f $i/src/itcl_sh ; then
1460          ac_cv_c_itclsh=`(cd $i/src; pwd)`/itcl_sh
1461          break
1462        fi
1463    done
1464fi
1465
1466dnl see if one is installed
1467if test x"${ac_cv_c_itclsh}" = x ; then
1468   AC_MSG_RESULT(none)
1469   AC_PATH_PROG(ac_cv_c_itclsh, itcl_sh)
1470else
1471   AC_MSG_RESULT(${ac_cv_c_itclsh})
1472fi
1473])
1474
1475if test x"${ac_cv_c_itclsh}" = x ; then
1476    AC_MSG_ERROR([Can't find the itcl_sh script])
1477fi
1478if test x"${ac_cv_c_itclsh}" != x ; then
1479    no_itcl=""
1480    AC_MSG_RESULT(${ac_cv_c_itclsh})
1481    ITCLSH="${ac_cv_c_itclsh}"
1482fi
1483AC_SUBST(ITCLSH)
1484])
1485
1486
1487dnl ====================================================================
1488dnl Ok, lets find the itcl source trees so we can use the itcl_sh script
1489dnl the alternative search directory is involked by --with-itclinclude
1490AC_DEFUN(CYG_AC_PATH_ITCLMKIDX, [
1491dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1492no_itcl=true
1493AC_MSG_CHECKING(for itcl_mkindex.tcl script)
1494AC_ARG_WITH(itclinclude, [  --with-itclinclude       directory where itcl headers are], with_itclinclude=${withval})
1495AC_CACHE_VAL(ac_cv_c_itclmkidx,[
1496dnl first check to see if --with-itclinclude was specified
1497if test x"${with_itclinclude}" != x ; then
1498  if test -f ${with_itclinclude}/itcl_sh ; then
1499    ac_cv_c_itclmkidx=`(cd ${with_itclinclude}; pwd)`
1500  elif test -f ${with_itclinclude}/src/itcl_sh ; then
1501    ac_cv_c_itclmkidx=`(cd ${with_itclinclude}/src; pwd)`
1502  else
1503    AC_MSG_ERROR([${with_itclinclude} directory doesn't contain itcl_sh])
1504  fi
1505fi
1506
1507dnl next check in private source directory
1508dnl since ls returns lowest version numbers first, reverse its output
1509if test x"${ac_cv_c_itclmkidx}" = x ; then
1510    dnl find the top level Itcl source directory
1511    for i in $dirlist; do
1512        if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
1513	    itclpath=$srcdir/$i
1514	    break
1515	fi
1516    done
1517
1518    dnl find the exact Itcl source dir. We do it this way, cause there
1519    dnl might be multiple version of Itcl, and we want the most recent one.
1520    for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
1521        if test -f $i/library/itcl_mkindex.tcl ; then
1522          ac_cv_c_itclmkidx=`(cd $i/library; pwd)`/itcl_mkindex.tcl
1523          break
1524        fi
1525    done
1526fi
1527if test x"${ac_cv_c_itclmkidx}" = x ; then
1528    dnl Get the path to the compiler
1529    ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/share
1530    dnl Itcl 7.5 and greater puts library in subdir.  Look there first.
1531    for i in `ls -dr $ccpath/itcl* 2>/dev/null ` ; do
1532        if test -f $i/itcl_mkindex.tcl ; then
1533            ac_cv_c_itclmkidx=`(cd $i; pwd)`/itcl_mkindex.tcl
1534            break
1535        fi
1536    done
1537fi
1538])
1539
1540if test x"${ac_cv_c_itclmkidx}" = x ; then
1541    AC_MSG_ERROR([Can't find the itcl_mkindex.tcl script])
1542fi
1543if test x"${ac_cv_c_itclmkidx}" != x ; then
1544    no_itcl=""
1545    AC_MSG_RESULT(${ac_cv_c_itclmkidx})
1546    ITCLMKIDX="${ac_cv_c_itclmkidx}"
1547else
1548   AC_MSG_RESULT(none)
1549fi
1550AC_SUBST(ITCLMKIDX)
1551])
1552
1553dnl ====================================================================
1554dnl Ok, lets find the tix source trees so we can use the headers
1555dnl the alternative search directory is involked by --with-tixinclude
1556AC_DEFUN(CYG_AC_PATH_TIX, [
1557    CYG_AC_PATH_TIXH
1558    CYG_AC_PATH_TIXLIB
1559])
1560AC_DEFUN(CYG_AC_PATH_TIXH, [
1561dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1562no_tix=true
1563AC_MSG_CHECKING(for Tix headers in the source tree)
1564AC_ARG_WITH(tixinclude, [  --with-tixinclude       directory where tix headers are], with_tixinclude=${withval})
1565AC_CACHE_VAL(ac_cv_c_tixh,[
1566dnl first check to see if --with-tixinclude was specified
1567if test x"${with_tixinclude}" != x ; then
1568  if test -f ${with_tixinclude}/tix.h ; then
1569    ac_cv_c_tixh=`(cd ${with_tixinclude}; pwd)`
1570  elif test -f ${with_tixinclude}/generic/tix.h ; then
1571    ac_cv_c_tixh=`(cd ${with_tixinclude}/generic; pwd)`
1572  else
1573    AC_MSG_ERROR([${with_tixinclude} directory doesn't contain headers])
1574  fi
1575fi
1576
1577dnl next check if it came with Tix configuration file
1578if test x"${ac_cv_c_tixconfig}" != x ; then
1579  for i in $dirlist; do
1580    if test -f $ac_cv_c_tixconfig/$i/generic/tix.h ; then
1581      ac_cv_c_tixh=`(cd $ac_cv_c_tixconfig/$i/generic; pwd)`
1582      break
1583    fi
1584  done
1585fi
1586
1587dnl next check in private source directory
1588dnl since ls returns lowest version numbers first, reverse its output
1589if test x"${ac_cv_c_tixh}" = x ; then
1590    dnl find the top level Tix source directory
1591    for i in $dirlist; do
1592        if test -n "`ls -dr $srcdir/$i/tix* 2>/dev/null`" ; then
1593	    tixpath=$srcdir/$i
1594	    break
1595	fi
1596    done
1597
1598    dnl find the exact Tix source dir. We do it this way, cause there
1599    dnl might be multiple version of Tix, and we want the most recent one.
1600    for i in `ls -dr $tixpath/tix* 2>/dev/null ` ; do
1601        if test -f $i/generic/tix.h ; then
1602          ac_cv_c_tixh=`(cd $i/generic; pwd)`
1603          break
1604        fi
1605    done
1606fi
1607
1608dnl see if one is installed
1609if test x"${ac_cv_c_tixh}" = x ; then
1610    AC_MSG_RESULT(none)
1611    dnl Get the path to the compiler
1612
1613   dnl Get the path to the compiler. We do it this way instead of using
1614    dnl AC_CHECK_HEADER, cause this doesn't depend in having X configured.
1615    ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/include
1616    if test -f $ccpath/tix.h; then
1617	ac_cv_c_tixh=installed
1618    fi
1619else
1620   AC_MSG_RESULT(${ac_cv_c_tixh})
1621fi
1622])
1623if test x"${ac_cv_c_tixh}" = x ; then
1624    AC_MSG_ERROR([Can't find any Tix headers])
1625fi
1626if test x"${ac_cv_c_tixh}" != x ; then
1627    no_tix=""
1628    AC_MSG_RESULT(${ac_cv_c_tixh})
1629    if test x"${ac_cv_c_tixh}" != x"installed" ; then
1630        TIXHDIR="-I${ac_cv_c_tixh}"
1631    fi
1632fi
1633
1634AC_SUBST(TIXHDIR)
1635])
1636
1637AC_DEFUN(CYG_AC_PATH_TIXCONFIG, [
1638#
1639# Ok, lets find the tix configuration
1640# First, look for one uninstalled.  
1641# the alternative search directory is invoked by --with-tixconfig
1642#
1643
1644if test x"${no_tix}" = x ; then
1645  # we reset no_tix in case something fails here
1646  no_tix=true
1647  AC_ARG_WITH(tixconfig, [  --with-tixconfig           directory containing tix configuration (tixConfig.sh)],
1648         with_tixconfig=${withval})
1649  AC_MSG_CHECKING([for Tix configuration])
1650  AC_CACHE_VAL(ac_cv_c_tixconfig,[
1651
1652  # First check to see if --with-tixconfig was specified.
1653  if test x"${with_tixconfig}" != x ; then
1654    if test -f "${with_tixconfig}/tixConfig.sh" ; then
1655      ac_cv_c_tixconfig=`(cd ${with_tixconfig}; pwd)`
1656    else
1657      AC_MSG_ERROR([${with_tixconfig} directory doesn't contain tixConfig.sh])
1658    fi
1659  fi
1660
1661  # then check for a private Tix library
1662  if test x"${ac_cv_c_tixconfig}" = x ; then
1663    for i in \
1664		../tix \
1665		`ls -dr ../tix[[4]]* 2>/dev/null` \
1666		../../tix \
1667		`ls -dr ../../tix[[4]]* 2>/dev/null` \
1668		../../../tix \
1669		`ls -dr ../../../tix[[4]]* 2>/dev/null` ; do
1670      if test -f "$i/tixConfig.sh" ; then
1671        ac_cv_c_tixconfig=`(cd $i; pwd)`
1672	break
1673      fi
1674    done
1675  fi
1676  # check in a few common install locations
1677  if test x"${ac_cv_c_tixconfig}" = x ; then
1678    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
1679      if test -f "$i/tixConfig.sh" ; then
1680        ac_cv_c_tkconfig=`(cd $i; pwd)`
1681	break
1682      fi
1683    done
1684  fi
1685  # check in a few other private locations
1686  if test x"${ac_cv_c_tixconfig}" = x ; then
1687    for i in \
1688		${srcdir}/../tix \
1689		`ls -dr ${srcdir}/../tix[[4-9]]* 2>/dev/null` ; do
1690      if test -f "$i/tixConfig.sh" ; then
1691        ac_cv_c_tixconfig=`(cd $i; pwd)`
1692	break
1693      fi
1694    done
1695  fi
1696  ])
1697  if test x"${ac_cv_c_tixconfig}" = x ; then
1698    TIXCONFIG="# no Tix configs found"
1699    AC_MSG_WARN(Can't find Tix configuration definitions)
1700  else
1701    no_tix=
1702    TIXCONFIG=${ac_cv_c_tixconfig}/tixConfig.sh
1703    AC_MSG_RESULT(found $TIXCONFIG)
1704  fi
1705fi
1706
1707])
1708
1709# Defined as a separate macro so we don't have to cache the values
1710# from PATH_TIXCONFIG (because this can also be cached).
1711AC_DEFUN(CYG_AC_LOAD_TIXCONFIG, [
1712    if test -f "$TIXCONFIG" ; then
1713      . $TIXCONFIG
1714    fi
1715
1716    AC_SUBST(TIX_BUILD_LIB_SPEC)
1717    AC_SUBST(TIX_LIB_FULL_PATH)
1718])
1719
1720AC_DEFUN(CYG_AC_PATH_ITCLCONFIG, [
1721#
1722# Ok, lets find the itcl configuration
1723# First, look for one uninstalled.  
1724# the alternative search directory is invoked by --with-itclconfig
1725#
1726
1727if test x"${no_itcl}" = x ; then
1728  # we reset no_itcl in case something fails here
1729  no_itcl=true
1730  AC_ARG_WITH(itclconfig, [  --with-itclconfig           directory containing itcl configuration (itclConfig.sh)],
1731         with_itclconfig=${withval})
1732  AC_MSG_CHECKING([for Itcl configuration])
1733  AC_CACHE_VAL(ac_cv_c_itclconfig,[
1734
1735  # First check to see if --with-itclconfig was specified.
1736  if test x"${with_itclconfig}" != x ; then
1737    if test -f "${with_itclconfig}/itclConfig.sh" ; then
1738      ac_cv_c_itclconfig=`(cd ${with_itclconfig}; pwd)`
1739    else
1740      AC_MSG_ERROR([${with_itclconfig} directory doesn't contain itclConfig.sh])
1741    fi
1742  fi
1743
1744  # then check for a private itcl library
1745  if test x"${ac_cv_c_itclconfig}" = x ; then
1746    for i in \
1747		../itcl/itcl \
1748		`ls -dr ../itcl/itcl[[3]]* 2>/dev/null` \
1749		../../itcl/itcl \
1750		`ls -dr ../../itcl/itcl[[3]]* 2>/dev/null` \
1751		../../../itcl/itcl \
1752		`ls -dr ../../../itcl/itcl[[3]]* 2>/dev/null` ; do
1753      if test -f "$i/itclConfig.sh" ; then
1754        ac_cv_c_itclconfig=`(cd $i; pwd)`
1755	break
1756      fi
1757    done
1758  fi
1759  # check in a few common install locations
1760  if test x"${ac_cv_c_itclconfig}" = x ; then
1761    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
1762      if test -f "$i/itclConfig.sh" ; then
1763        ac_cv_c_itclconfig=`(cd $i; pwd)`
1764	break
1765      fi
1766    done
1767  fi
1768  # check in a few other private locations
1769  if test x"${ac_cv_c_itclconfig}" = x ; then
1770    for i in \
1771		${srcdir}/../itcl/itcl \
1772		`ls -dr ${srcdir}/../itcl/itcl[[3]]* 2>/dev/null` ; do
1773      if test -f "$i/itcl/itclConfig.sh" ; then
1774        ac_cv_c_itclconfig=`(cd $i; pwd)`
1775	break
1776      fi
1777    done
1778  fi
1779  ])
1780  if test x"${ac_cv_c_itclconfig}" = x ; then
1781    ITCLCONFIG="# no itcl configs found"
1782    AC_MSG_WARN(Can't find itcl configuration definitions)
1783  else
1784    no_itcl=
1785    ITCLCONFIG=${ac_cv_c_itclconfig}/itclConfig.sh
1786    AC_MSG_RESULT(found $ITCLCONFIG)
1787  fi
1788fi
1789
1790])
1791
1792# Defined as a separate macro so we don't have to cache the values
1793# from PATH_ITCLCONFIG (because this can also be cached).
1794AC_DEFUN(CYG_AC_LOAD_ITCLCONFIG, [
1795    if test -f "$ITCLCONFIG" ; then
1796      . $ITCLCONFIG
1797    fi
1798
1799    AC_SUBST(ITCL_BUILD_LIB_SPEC)
1800    AC_SUBST(ITCL_SH)
1801    AC_SUBST(ITCL_LIB_FILE)
1802    AC_SUBST(ITCL_LIB_FULL_PATH)
1803
1804])
1805
1806
1807AC_DEFUN(CYG_AC_PATH_ITKCONFIG, [
1808#
1809# Ok, lets find the itk configuration
1810# First, look for one uninstalled.  
1811# the alternative search directory is invoked by --with-itkconfig
1812#
1813
1814if test x"${no_itk}" = x ; then
1815  # we reset no_itk in case something fails here
1816  no_itk=true
1817  AC_ARG_WITH(itkconfig, [  --with-itkconfig           directory containing itk configuration (itkConfig.sh)],
1818         with_itkconfig=${withval})
1819  AC_MSG_CHECKING([for Itk configuration])
1820  AC_CACHE_VAL(ac_cv_c_itkconfig,[
1821
1822  # First check to see if --with-itkconfig was specified.
1823  if test x"${with_itkconfig}" != x ; then
1824    if test -f "${with_itkconfig}/itkConfig.sh" ; then
1825      ac_cv_c_itkconfig=`(cd ${with_itkconfig}; pwd)`
1826    else
1827      AC_MSG_ERROR([${with_itkconfig} directory doesn't contain itkConfig.sh])
1828    fi
1829  fi
1830
1831  # then check for a private itk library
1832  if test x"${ac_cv_c_itkconfig}" = x ; then
1833    for i in \
1834		../itcl/itk \
1835		`ls -dr ../itcl/itk[[3]]* 2>/dev/null` \
1836		../../itcl/itk \
1837		`ls -dr ../../itcl/itk[[3]]* 2>/dev/null` \
1838		../../../itcl/itk \
1839		`ls -dr ../../../itcl/itk[[3]]* 2>/dev/null` ; do
1840      if test -f "$i/itkConfig.sh" ; then
1841        ac_cv_c_itkconfig=`(cd $i; pwd)`
1842	break
1843      fi
1844    done
1845  fi
1846  # check in a few common install locations
1847  if test x"${ac_cv_c_itkconfig}" = x ; then
1848    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
1849      if test -f "$i/itcl/itkConfig.sh" ; then
1850        ac_cv_c_itkconfig=`(cd $i; pwd)`
1851	break
1852      fi
1853    done
1854  fi
1855  # check in a few other private locations
1856  if test x"${ac_cv_c_itkconfig}" = x ; then
1857    for i in \
1858		${srcdir}/../itcl/itk \
1859		`ls -dr ${srcdir}/../itcl/itk[[3]]* 2>/dev/null` ; do
1860      if test -f "$i/itkConfig.sh" ; then
1861        ac_cv_c_itkconfig=`(cd $i; pwd)`
1862	break
1863      fi
1864    done
1865  fi
1866  ])
1867  if test x"${ac_cv_c_itkconfig}" = x ; then
1868    ITCLCONFIG="# no itk configs found"
1869    AC_MSG_WARN(Can't find itk configuration definitions)
1870  else
1871    no_itk=
1872    ITKCONFIG=${ac_cv_c_itkconfig}/itkConfig.sh
1873    AC_MSG_RESULT(found $ITKCONFIG)
1874  fi
1875fi
1876
1877])
1878
1879# Defined as a separate macro so we don't have to cache the values
1880# from PATH_ITKCONFIG (because this can also be cached).
1881AC_DEFUN(CYG_AC_LOAD_ITKCONFIG, [
1882    if test -f "$ITKCONFIG" ; then
1883      . $ITKCONFIG
1884    fi
1885
1886    AC_SUBST(ITK_BUILD_LIB_SPEC)
1887    AC_SUBST(ITK_LIB_FILE)
1888    AC_SUBST(ITK_LIB_FULL_PATH)
1889])
1890
1891
1892dnl ====================================================================
1893dnl Ok, lets find the libgui source trees so we can use the headers
1894dnl the alternative search directory is involked by --with-libguiinclude
1895AC_DEFUN(CYG_AC_PATH_LIBGUI, [
1896    CYG_AC_PATH_LIBGUIH
1897    CYG_AC_PATH_LIBGUILIB
1898])
1899AC_DEFUN(CYG_AC_PATH_LIBGUIH, [
1900dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../..../../../../../../../../../../.."
1901no_libgui=true
1902AC_MSG_CHECKING(for Libgui headers in the source tree)
1903AC_ARG_WITH(libguiinclude, [  --with-libguiinclude       directory where libgui headers are], with_libguiinclude=${withval})
1904AC_CACHE_VAL(ac_cv_c_libguih,[
1905dnl first check to see if --with-libguiinclude was specified
1906if test x"${with_libguiinclude}" != x ; then
1907  if test -f ${with_libguiinclude}/guitcl.h ; then
1908    ac_cv_c_libguih=`(cd ${with_libguiinclude}; pwd)`
1909  elif test -f ${with_libguiinclude}/src/guitcl.h ; then
1910    ac_cv_c_libguih=`(cd ${with_libguiinclude}/src; pwd)`
1911  else
1912    AC_MSG_ERROR([${with_libguiinclude} directory doesn't contain headers])
1913  fi
1914fi
1915
1916dnl next check if it came with Libgui configuration file
1917if test x"${ac_cv_c_libguiconfig}" != x ; then
1918  for i in $dirlist; do
1919    if test -f $ac_cv_c_libguiconfig/$i/src/guitcl.h ; then
1920      ac_cv_c_libguih=`(cd $ac_cv_c_libguiconfig/$i/src; pwd)`
1921      break
1922    fi
1923  done
1924fi
1925
1926dnl next check in private source directory
1927dnl since ls returns lowest version numbers first, reverse its output
1928if test x"${ac_cv_c_libguih}" = x ; then
1929    dnl find the top level Libgui source directory
1930    for i in $dirlist; do
1931        if test -n "`ls -dr $srcdir/$i/libgui* 2>/dev/null`" ; then
1932	    libguipath=$srcdir/$i
1933	    break
1934	fi
1935    done
1936
1937    dnl find the exact Libgui source dir. We do it this way, cause there
1938    dnl might be multiple version of Libgui, and we want the most recent one.
1939    for i in `ls -dr $libguipath/libgui* 2>/dev/null ` ; do
1940        if test -f $i/src/guitcl.h ; then
1941          ac_cv_c_libguih=`(cd $i/src; pwd)`
1942          break
1943        fi
1944    done
1945fi
1946
1947dnl see if one is installed
1948if test x"${ac_cv_c_libguih}" = x ; then
1949   AC_MSG_RESULT(none)
1950   AC_CHECK_HEADER(guitcl.h, ac_cv_c_libguih=installed, ac_cv_c_libguih="")
1951fi
1952])
1953LIBGUIHDIR=""
1954if test x"${ac_cv_c_libguih}" = x ; then
1955    AC_MSG_WARN([Can't find any Libgui headers])
1956fi
1957if test x"${ac_cv_c_libguih}" != x ; then
1958    no_libgui=""
1959    if test x"${ac_cv_c_libguih}" != x"installed" ; then
1960        LIBGUIHDIR="-I${ac_cv_c_libguih}"
1961    fi
1962fi
1963AC_MSG_RESULT(${ac_cv_c_libguih})
1964AC_SUBST(LIBGUIHDIR)
1965])
1966
1967dnl ====================================================================
1968dnl find the GUI library
1969AC_DEFUN(CYG_AC_PATH_LIBGUILIB, [
1970AC_MSG_CHECKING(for GUI library  in the build tree)
1971dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1972dnl look for the library
1973AC_MSG_CHECKING(for GUI library)
1974AC_CACHE_VAL(ac_cv_c_libguilib,[
1975if test x"${ac_cv_c_libguilib}" = x ; then
1976    for i in $dirlist; do
1977      if test -f "$i/libgui/src/Makefile" ; then
1978        ac_cv_c_libguilib=`(cd $i/libgui/src; pwd)`
1979        break
1980      fi
1981    done
1982fi
1983]) 
1984if test x"${ac_cv_c_libguilib}" != x ; then
1985     GUILIB="${GUILIB} -L${ac_cv_c_libguilib}"
1986     LIBGUILIB="-lgui"
1987     AC_MSG_RESULT(${ac_cv_c_libguilib})
1988else
1989     AC_MSG_RESULT(none)
1990fi
1991
1992AC_SUBST(GUILIB)
1993AC_SUBST(LIBGUILIB)
1994])
1995