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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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/; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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  ; ${PWDCMD-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  ; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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[3456789]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}; ${PWDCMD-pwd})`
862  elif test -f ${with_tclinclude}/generic/tcl.h ; then
863    ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; ${PWDCMD-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; ${PWDCMD-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; ${PWDCMD-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}; ${PWDCMD-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            dnl need to test both unix and win directories, since 
963            dnl cygwin's tkConfig.sh could be in either directory depending
964            dnl on the cygwin port of tcl.
965            if test -f $srcdir/$i/unix/tclConfig.sh ; then
966                ac_cv_c_tclconfig=`(cd $srcdir/$i/unix; ${PWDCMD-pwd})`
967	        break
968            fi
969            if test -f $srcdir/$i/win/tclConfig.sh ; then
970                ac_cv_c_tclconfig=`(cd $srcdir/$i/win; ${PWDCMD-pwd})`
971	        break
972            fi
973        done
974    fi
975    dnl check in a few other locations
976    if test x"${ac_cv_c_tclconfig}" = x ; then
977        dnl find the top level Tcl source directory
978        for i in $dirlist; do
979            if test -n "`ls -dr $i/tcl* 2>/dev/null`" ; then
980	        tclconfpath=$i
981	        break
982	    fi
983        done
984
985        dnl find the exact Tcl dir. We do it this way, cause there
986        dnl might be multiple version of Tcl, and we want the most recent one.
987        for i in `ls -dr $tclconfpath/tcl* 2>/dev/null ` ; do
988            dnl need to test both unix and win directories, since 
989            dnl cygwin's tclConfig.sh could be in either directory depending
990            dnl on the cygwin port of tcl.
991            if test -f $i/unix/tclConfig.sh ; then
992                ac_cv_c_tclconfig=`(cd $i/unix; ${PWDCMD-pwd})`
993                break
994            fi
995            if test -f $i/win/tclConfig.sh ; then
996                ac_cv_c_tclconfig=`(cd $i/win; ${PWDCMD-pwd})`
997                break
998            fi
999        done
1000    fi
1001
1002    dnl Check to see if it's installed. We have to look in the $CC path
1003    dnl to find it, cause our $prefix may not match the compilers.
1004    if test x"${ac_cv_c_tclconfig}" = x ; then
1005        dnl Get the path to the compiler
1006	ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/lib
1007        if test -f $ccpath/tclConfig.sh; then
1008	    ac_cv_c_tclconfig=$ccpath
1009        fi
1010    fi
1011    ])	dnl end of cache_val
1012
1013    if test x"${ac_cv_c_tclconfig}" = x ; then
1014        TCLCONFIG=""
1015        AC_MSG_WARN(Can't find Tcl configuration definitions)
1016    else
1017        no_tcl=""
1018        TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
1019        AC_MSG_RESULT(${TCLCONFIG})
1020     fi
1021fi
1022AC_SUBST(TCLCONFIG)
1023])
1024
1025dnl Defined as a separate macro so we don't have to cache the values
1026dnl from PATH_TCLCONFIG (because this can also be cached).
1027AC_DEFUN([CYG_AC_LOAD_TCLCONFIG], [
1028    . $TCLCONFIG
1029
1030dnl AC_SUBST(TCL_VERSION)
1031dnl AC_SUBST(TCL_MAJOR_VERSION)
1032dnl AC_SUBST(TCL_MINOR_VERSION)
1033dnl AC_SUBST(TCL_CC)
1034    AC_SUBST(TCL_DEFS)
1035
1036dnl not used, don't export to save symbols
1037    AC_SUBST(TCL_LIB_FILE)
1038    AC_SUBST(TCL_LIB_FULL_PATH)
1039    AC_SUBST(TCL_LIBS)
1040dnl not used, don't export to save symbols
1041dnl    AC_SUBST(TCL_PREFIX)
1042
1043    AC_SUBST(TCL_CFLAGS)
1044
1045dnl not used, don't export to save symbols
1046dnl    AC_SUBST(TCL_EXEC_PREFIX)
1047
1048    AC_SUBST(TCL_SHLIB_CFLAGS)
1049    AC_SUBST(TCL_SHLIB_LD)
1050dnl don't export, not used outside of configure
1051dnl AC_SUBST(TCL_SHLIB_LD_LIBS)
1052dnl AC_SUBST(TCL_SHLIB_SUFFIX)
1053dnl not used, don't export to save symbols
1054dnl AC_SUBST(TCL_DL_LIBS)
1055    AC_SUBST(TCL_LD_FLAGS)
1056    AC_SUBST(TCL_LD_SEARCH_FLAGS)
1057dnl don't export, not used outside of configure
1058dnl AC_SUBST(TCL_COMPAT_OBJS)
1059    AC_SUBST(TCL_RANLIB)
1060    AC_SUBST(TCL_BUILD_LIB_SPEC)
1061    AC_SUBST(TCL_LIB_SPEC)
1062    AC_SUBST(TCL_BIN_DIR)
1063dnl AC_SUBST(TCL_LIB_VERSIONS_OK)
1064
1065dnl not used, don't export to save symbols
1066dnl    AC_SUBST(TCL_SHARED_LIB_SUFFIX)
1067
1068dnl not used, don't export to save symbols
1069dnl    AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
1070])
1071
1072dnl ====================================================================
1073AC_DEFUN([CYG_AC_PATH_TK], [
1074    CYG_AC_PATH_TKH
1075    CYG_AC_PATH_TKCONFIG
1076    CYG_AC_LOAD_TKCONFIG
1077])
1078AC_DEFUN([CYG_AC_PATH_TKH], [
1079#
1080# Ok, lets find the tk source trees so we can use the headers
1081# If the directory (presumably symlink) named "tk" exists, use that one
1082# in preference to any others.  Same logic is used when choosing library
1083# and again with Tcl. The search order is the best place to look first, then in
1084# decreasing significance. The loop breaks if the trigger file is found.
1085# Note the gross little conversion here of srcdir by cd'ing to the found
1086# directory. This converts the path from a relative to an absolute, so
1087# recursive cache variables for the path will work right. We check all
1088# the possible paths in one loop rather than many separate loops to speed
1089# things up.
1090# the alternative search directory is involked by --with-tkinclude
1091#
1092dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1093no_tk=true
1094AC_MSG_CHECKING(for Tk headers in the source tree)
1095AC_ARG_WITH(tkinclude, [  --with-tkinclude       directory where tk headers are], with_tkinclude=${withval})
1096AC_CACHE_VAL(ac_cv_c_tkh,[
1097dnl first check to see if --with-tkinclude was specified
1098if test x"${with_tkinclude}" != x ; then
1099  if test -f ${with_tkinclude}/tk.h ; then
1100    ac_cv_c_tkh=`(cd ${with_tkinclude}; ${PWDCMD-pwd})`
1101  elif test -f ${with_tkinclude}/generic/tk.h ; then
1102    ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; ${PWDCMD-pwd})`
1103  else
1104    AC_MSG_ERROR([${with_tkinclude} directory doesn't contain headers])
1105  fi
1106fi
1107
1108dnl next check if it came with Tk configuration file
1109if test x"${ac_cv_c_tkconfig}" != x ; then
1110  for i in $dirlist; do
1111    if test -f $ac_cv_c_tkconfig/$i/generic/tk.h ; then
1112      ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/$i/generic; ${PWDCMD-pwd})`
1113      break
1114    fi
1115  done
1116fi
1117
1118dnl next check in private source directory
1119dnl since ls returns lowest version numbers first, reverse its output
1120if test x"${ac_cv_c_tkh}" = x ; then
1121    dnl find the top level Tk source directory
1122    for i in $dirlist; do
1123        if test -n "`ls -dr $srcdir/$i/tk* 2>/dev/null`" ; then
1124	    tkpath=$srcdir/$i
1125	    break
1126	fi
1127    done
1128
1129    dnl find the exact Tk source dir. We do it this way, cause there
1130    dnl might be multiple version of Tk, and we want the most recent one.
1131    for i in `ls -dr $tkpath/tk* 2>/dev/null ` ; do
1132        if test -f $i/generic/tk.h ; then
1133          ac_cv_c_tkh=`(cd $i/generic; ${PWDCMD-pwd})`
1134          break
1135        fi
1136    done
1137fi
1138
1139dnl see if one is installed
1140if test x"${ac_cv_c_tkh}" = x ; then
1141    AC_MSG_RESULT(none)
1142    dnl Get the path to the compiler. We do it this way instead of using
1143    dnl AC_CHECK_HEADER, cause this doesn't depend in having X configured.
1144    ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/include
1145    if test -f $ccpath/tk.h; then
1146	ac_cv_c_tkh=$ccpath
1147    fi
1148else
1149   AC_MSG_RESULT(${ac_cv_c_tkh})
1150fi
1151])
1152  TKHDIR=""
1153if test x"${ac_cv_c_tkh}" = x ; then
1154    AC_MSG_ERROR([Can't find any Tk headers])
1155fi
1156if test x"${ac_cv_c_tkh}" != x ; then
1157    no_tk=""
1158    if test x"${ac_cv_c_tkh}" != x"installed" ; then
1159	if test x"${CC}" = xcl ; then
1160	    tmp="`cygpath --windows ${ac_cv_c_tkh}`"
1161	    ac_cv_c_tkh="`echo $tmp | sed -e s#\\\\\\\\#/#g`"
1162	fi
1163        AC_MSG_RESULT([found in ${ac_cv_c_tkh}])
1164        TKHDIR="-I${ac_cv_c_tkh}"
1165    fi
1166fi
1167
1168AC_SUBST(TKHDIR)
1169])
1170
1171AC_DEFUN([CYG_AC_PATH_TKCONFIG], [
1172dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1173dnl First, look for one uninstalled.  
1174dnl the alternative search directory is invoked by --with-tkconfig
1175if test x"${no_tk}" = x ; then
1176  dnl we reset no_tk in case something fails here
1177    no_tk=true
1178    AC_ARG_WITH(tkconfig, [  --with-tkconfig           directory containing tk configuration (tkConfig.sh)],
1179         with_tkconfig=${withval})
1180    AC_MSG_CHECKING([for Tk configuration script])
1181    AC_CACHE_VAL(ac_cv_c_tkconfig,[
1182
1183    dnl First check to see if --with-tkconfig was specified.
1184    if test x"${with_tkconfig}" != x ; then
1185        if test -f "${with_tkconfig}/tkConfig.sh" ; then
1186            ac_cv_c_tkconfig=`(cd ${with_tkconfig}; ${PWDCMD-pwd})`
1187        else
1188            AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
1189        fi
1190    fi
1191
1192    dnl next check if it came with Tk configuration file in the source tree
1193    if test x"${ac_cv_c_tkconfig}" = x ; then
1194        for i in $dirlist; do
1195            dnl need to test both unix and win directories, since 
1196            dnl cygwin's tkConfig.sh could be in either directory depending
1197            dnl on the cygwin port of tk.
1198            if test -f $srcdir/$i/unix/tkConfig.sh ; then
1199                ac_cv_c_tkconfig=`(cd $srcdir/$i/unix; ${PWDCMD-pwd})`
1200	        break
1201            fi
1202            if test -f $srcdir/$i/win/tkConfig.sh ; then
1203                ac_cv_c_tkconfig=`(cd $srcdir/$i/unix; ${PWDCMD-pwd})`
1204	        break
1205            fi
1206        done
1207    fi
1208    dnl check in a few other locations
1209    if test x"${ac_cv_c_tkconfig}" = x ; then
1210        dnl find the top level Tk source directory
1211        for i in $dirlist; do
1212            if test -n "`ls -dr $i/tk* 2>/dev/null`" ; then
1213	        tkconfpath=$i
1214	        break
1215	    fi
1216        done
1217
1218        dnl find the exact Tk dir. We do it this way, cause there
1219        dnl might be multiple version of Tk, and we want the most recent one.
1220        for i in `ls -dr $tkconfpath/tk* 2>/dev/null ` ; do
1221            dnl need to test both unix and win directories, since 
1222            dnl cygwin's tkConfig.sh could be in either directory depending
1223            dnl on the cygwin port of tk.
1224            if test -f $i/unix/tkConfig.sh ; then
1225                ac_cv_c_tkconfig=`(cd $i/unix; ${PWDCMD-pwd})`
1226                break
1227            fi
1228            if test -f $i/win/tkConfig.sh ; then
1229                ac_cv_c_tkconfig=`(cd $i/win; ${PWDCMD-pwd})`
1230                break
1231            fi
1232        done
1233    fi
1234
1235    dnl Check to see if it's installed. We have to look in the $CC path
1236    dnl to find it, cause our $prefix may not match the compilers.
1237    if test x"${ac_cv_c_tkconfig}" = x ; then
1238        dnl Get the path to the compiler
1239	ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/lib
1240        if test -f $ccpath/tkConfig.sh; then
1241	    ac_cv_c_tkconfig=$ccpath
1242        fi
1243    fi
1244    ])	dnl end of cache_val
1245
1246    if test x"${ac_cv_c_tkconfig}" = x ; then
1247        TKCONFIG=""
1248        AC_MSG_WARN(Can't find Tk configuration definitions)
1249    else
1250        no_tk=""
1251        TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
1252        AC_MSG_RESULT(${TKCONFIG})
1253     fi
1254fi
1255AC_SUBST(TKCONFIG)
1256])
1257
1258dnl Defined as a separate macro so we don't have to cache the values
1259dnl from PATH_TKCONFIG (because this can also be cached).
1260AC_DEFUN([CYG_AC_LOAD_TKCONFIG], [
1261    if test -f "$TKCONFIG" ; then
1262      . $TKCONFIG
1263    fi
1264
1265    AC_SUBST(TK_VERSION)
1266dnl not actually used, don't export to save symbols
1267dnl    AC_SUBST(TK_MAJOR_VERSION)
1268dnl    AC_SUBST(TK_MINOR_VERSION)
1269    AC_SUBST(TK_DEFS)
1270
1271dnl not used, don't export to save symbols
1272    AC_SUBST(TK_LIB_FILE)
1273    AC_SUBST(TK_LIB_FULL_PATH)
1274    AC_SUBST(TK_LIBS)
1275dnl not used, don't export to save symbols
1276dnl    AC_SUBST(TK_PREFIX)
1277
1278dnl not used, don't export to save symbols
1279dnl    AC_SUBST(TK_EXEC_PREFIX)
1280    AC_SUBST(TK_BUILD_INCLUDES)
1281    AC_SUBST(TK_XINCLUDES)
1282    AC_SUBST(TK_XLIBSW)
1283    AC_SUBST(TK_BUILD_LIB_SPEC)
1284    AC_SUBST(TK_LIB_SPEC)
1285])
1286
1287dnl ====================================================================
1288dnl Ok, lets find the itcl source trees so we can use the headers
1289dnl the alternative search directory is involked by --with-itclinclude
1290AC_DEFUN([CYG_AC_PATH_ITCL], [
1291    CYG_AC_PATH_ITCLH
1292    CYG_AC_PATH_ITCLLIB
1293    CYG_AC_PATH_ITCLSH
1294    CYG_AC_PATH_ITCLMKIDX
1295])
1296AC_DEFUN([CYG_AC_PATH_ITCLH], [
1297dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1298no_itcl=true
1299AC_MSG_CHECKING(for Itcl headers in the source tree)
1300AC_ARG_WITH(itclinclude, [  --with-itclinclude       directory where itcl headers are], with_itclinclude=${withval})
1301AC_CACHE_VAL(ac_cv_c_itclh,[
1302dnl first check to see if --with-itclinclude was specified
1303if test x"${with_itclinclude}" != x ; then
1304  if test -f ${with_itclinclude}/itcl.h ; then
1305    ac_cv_c_itclh=`(cd ${with_itclinclude}; ${PWDCMD-pwd})`
1306  elif test -f ${with_itclinclude}/src/itcl.h ; then
1307    ac_cv_c_itclh=`(cd ${with_itclinclude}/src; ${PWDCMD-pwd})`
1308  else
1309    AC_MSG_ERROR([${with_itclinclude} directory doesn't contain headers])
1310  fi
1311fi
1312
1313dnl next check if it came with Itcl configuration file
1314if test x"${ac_cv_c_itclconfig}" != x ; then
1315  for i in $dirlist; do
1316    if test -f $ac_cv_c_itclconfig/$i/src/itcl.h ; then
1317      ac_cv_c_itclh=`(cd $ac_cv_c_itclconfig/$i/src; ${PWDCMD-pwd})`
1318      break
1319    fi
1320  done
1321fi
1322
1323dnl next check in private source directory
1324dnl since ls returns lowest version numbers first, reverse its output
1325if test x"${ac_cv_c_itclh}" = x ; then
1326    dnl find the top level Itcl source directory
1327    for i in $dirlist; do
1328        if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
1329	    itclpath=$srcdir/$i
1330	    break
1331	fi
1332    done
1333
1334    dnl find the exact Itcl source dir. We do it this way, cause there
1335    dnl might be multiple version of Itcl, and we want the most recent one.
1336    for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
1337        if test -f $i/src/itcl.h ; then
1338          ac_cv_c_itclh=`(cd $i/src; ${PWDCMD-pwd})`
1339          break
1340        fi
1341    done
1342fi
1343
1344dnl see if one is installed
1345if test x"${ac_cv_c_itclh}" = x ; then
1346   AC_MSG_RESULT(none)
1347   AC_CHECK_HEADER(itcl.h, ac_cv_c_itclh=installed, ac_cv_c_itclh="")
1348else
1349   AC_MSG_RESULT(${ac_cv_c_itclh})
1350fi
1351])
1352  ITCLHDIR=""
1353if test x"${ac_cv_c_itclh}" = x ; then
1354    AC_MSG_ERROR([Can't find any Itcl headers])
1355fi
1356if test x"${ac_cv_c_itclh}" != x ; then
1357    no_itcl=""
1358    if test x"${ac_cv_c_itclh}" != x"installed" ; then
1359        AC_MSG_RESULT(${ac_cv_c_itclh})
1360        ITCLHDIR="-I${ac_cv_c_itclh}"
1361    fi
1362fi
1363
1364AC_SUBST(ITCLHDIR)
1365])
1366
1367dnl Ok, lets find the itcl library
1368dnl First, look for one uninstalled.  
1369dnl the alternative search directory is invoked by --with-itcllib
1370AC_DEFUN([CYG_AC_PATH_ITCLLIB], [
1371dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1372if test x"${no_itcl}" = x ; then
1373    dnl we reset no_itcl incase something fails here
1374    no_itcl=true
1375    AC_ARG_WITH(itcllib,
1376	[  --with-itcllib           directory where the itcl library is],
1377        with_itcllib=${withval})
1378    AC_MSG_CHECKING([for Itcl library])
1379    AC_CACHE_VAL(ac_cv_c_itcllib,[
1380    dnl First check to see if --with-itcllib was specified.
1381    if test x"${with_itcllib}" != x ; then
1382        if test -f "${with_itcllib}/libitcl$TCL_SHARED_LIB_SUFFIX" ; then
1383            ac_cv_c_itcllib=`(cd ${with_itcllib}; ${PWDCMD-pwd})`/libitcl$TCL_SHARED_LIB_SUFFIX
1384	else
1385	    if test -f "${with_itcllib}/libitcl$TCL_UNSHARED_LIB_SUFFIX"; then
1386	 	ac_cv_c_itcllib=`(cd ${with_itcllib}; ${PWDCMD-pwd})`/libitcl$TCL_UNSHARED_LIB_SUFFIX
1387	    fi
1388	fi
1389    fi
1390    dnl then check for a  Itcl library. Since these are uninstalled,
1391    dnl use the simple lib name root. 
1392    if test x"${ac_cv_c_itcllib}" = x ; then
1393        dnl find the top level Itcl build directory
1394        for i in $dirlist; do
1395            if test -n "`ls -dr $i/itcl* 2>/dev/null`" ; then
1396	        itclpath=$i/itcl
1397	        break
1398	    fi
1399        done
1400        dnl Itcl 7.5 and greater puts library in subdir.  Look there first.
1401        if test -f "$itclpath/src/libitcl.$TCL_SHLIB_SUFFIX" ; then
1402	     ac_cv_c_itcllib=`(cd $itclpath/src; ${PWDCMD-pwd})`
1403        elif test -f "$itclpath/src/libitcl.a"; then
1404	     ac_cv_c_itcllib=`(cd $itclpath/src; ${PWDCMD-pwd})`
1405	fi
1406    fi
1407    dnl check in a few other private locations
1408    if test x"${ac_cv_c_itcllib}" = x ; then
1409        for i in ${dirlist}; do
1410            if test -n "`ls -dr ${srcdir}/$i/itcl* 2>/dev/null`" ; then
1411	        itclpath=${srcdir}/$i
1412	        break
1413	    fi
1414        done
1415        for i in `ls -dr ${itclpath}/itcl* 2>/dev/null` ; do
1416            dnl Itcl 7.5 and greater puts library in subdir.  Look there first.
1417            if test -f "$i/src/libitcl$TCL_SHLIB_SUFFIX" ; then
1418	        ac_cv_c_itcllib=`(cd $i/src; ${PWDCMD-pwd})`
1419	        break
1420            elif test -f "$i/src/libitcl.a"; then
1421	        ac_cv_c_itcllib=`(cd $i/src; ${PWDCMD-pwd})`
1422	        break
1423	    fi	
1424        done
1425    fi
1426
1427    dnl see if one is conveniently installed with the compiler
1428    if test x"${ac_cv_c_itcllib}" = x ; then
1429        dnl Get the path to the compiler
1430	ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/lib
1431        dnl Itcl 7.5 and greater puts library in subdir.  Look there first.
1432        if test -f "${ccpath}/libitcl$TCL_SHLIB_SUFFIX" ; then
1433	    ac_cv_c_itcllib=`(cd ${ccpath}; ${PWDCMD-pwd})`
1434        elif test -f "${ccpath}/libitcl.a"; then
1435	    ac_cv_c_itcllib=`(cd ${ccpath}; ${PWDCMD-pwd})`
1436        fi
1437    fi
1438    ])
1439    if test x"${ac_cv_c_itcllib}" = x ; then
1440        ITCLLIB=""
1441        AC_MSG_WARN(Can't find Itcl library)
1442    else
1443        ITCLLIB="-L${ac_cv_c_itcllib}"
1444        AC_MSG_RESULT(${ac_cv_c_itcllib})
1445        no_itcl=""
1446    fi
1447fi
1448
1449AC_PROVIDE([$0])
1450AC_SUBST(ITCLLIB)
1451])
1452
1453
1454dnl ====================================================================
1455dnl Ok, lets find the itcl source trees so we can use the itcl_sh script
1456dnl the alternative search directory is involked by --with-itclinclude
1457AC_DEFUN([CYG_AC_PATH_ITCLSH], [
1458dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1459no_itcl=true
1460AC_MSG_CHECKING(for the itcl_sh script)
1461AC_ARG_WITH(itclinclude, [  --with-itclinclude       directory where itcl headers are], with_itclinclude=${withval})
1462AC_CACHE_VAL(ac_cv_c_itclsh,[
1463dnl first check to see if --with-itclinclude was specified
1464if test x"${with_itclinclude}" != x ; then
1465  if test -f ${with_itclinclude}/itcl_sh ; then
1466    ac_cv_c_itclsh=`(cd ${with_itclinclude}; ${PWDCMD-pwd})`
1467  elif test -f ${with_itclinclude}/src/itcl_sh ; then
1468    ac_cv_c_itclsh=`(cd ${with_itclinclude}/src; ${PWDCMD-pwd})`
1469  else
1470    AC_MSG_ERROR([${with_itclinclude} directory doesn't contain itcl_sh])
1471  fi
1472fi
1473
1474dnl next check in private source directory
1475dnl since ls returns lowest version numbers first, reverse its output
1476if test x"${ac_cv_c_itclsh}" = x ; then
1477    dnl find the top level Itcl source directory
1478    for i in $dirlist; do
1479        if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
1480	    itclpath=$srcdir/$i
1481	    break
1482	fi
1483    done
1484
1485    dnl find the exact Itcl source dir. We do it this way, cause there
1486    dnl might be multiple version of Itcl, and we want the most recent one.
1487    for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
1488        if test -f $i/src/itcl_sh ; then
1489          ac_cv_c_itclsh=`(cd $i/src; ${PWDCMD-pwd})`/itcl_sh
1490          break
1491        fi
1492    done
1493fi
1494
1495dnl see if one is installed
1496if test x"${ac_cv_c_itclsh}" = x ; then
1497   AC_MSG_RESULT(none)
1498   AC_PATH_PROG(ac_cv_c_itclsh, itcl_sh)
1499else
1500   AC_MSG_RESULT(${ac_cv_c_itclsh})
1501fi
1502])
1503
1504if test x"${ac_cv_c_itclsh}" = x ; then
1505    AC_MSG_ERROR([Can't find the itcl_sh script])
1506fi
1507if test x"${ac_cv_c_itclsh}" != x ; then
1508    no_itcl=""
1509    AC_MSG_RESULT(${ac_cv_c_itclsh})
1510    ITCLSH="${ac_cv_c_itclsh}"
1511fi
1512AC_SUBST(ITCLSH)
1513])
1514
1515
1516dnl ====================================================================
1517dnl Ok, lets find the itcl source trees so we can use the itcl_sh script
1518dnl the alternative search directory is involked by --with-itclinclude
1519AC_DEFUN([CYG_AC_PATH_ITCLMKIDX], [
1520dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1521no_itcl=true
1522AC_MSG_CHECKING(for itcl_mkindex.tcl script)
1523AC_ARG_WITH(itclinclude, [  --with-itclinclude       directory where itcl headers are], with_itclinclude=${withval})
1524AC_CACHE_VAL(ac_cv_c_itclmkidx,[
1525dnl first check to see if --with-itclinclude was specified
1526if test x"${with_itclinclude}" != x ; then
1527  if test -f ${with_itclinclude}/itcl_sh ; then
1528    ac_cv_c_itclmkidx=`(cd ${with_itclinclude}; ${PWDCMD-pwd})`
1529  elif test -f ${with_itclinclude}/src/itcl_sh ; then
1530    ac_cv_c_itclmkidx=`(cd ${with_itclinclude}/src; ${PWDCMD-pwd})`
1531  else
1532    AC_MSG_ERROR([${with_itclinclude} directory doesn't contain itcl_sh])
1533  fi
1534fi
1535
1536dnl next check in private source directory
1537dnl since ls returns lowest version numbers first, reverse its output
1538if test x"${ac_cv_c_itclmkidx}" = x ; then
1539    dnl find the top level Itcl source directory
1540    for i in $dirlist; do
1541        if test -n "`ls -dr $srcdir/$i/itcl* 2>/dev/null`" ; then
1542	    itclpath=$srcdir/$i
1543	    break
1544	fi
1545    done
1546
1547    dnl find the exact Itcl source dir. We do it this way, cause there
1548    dnl might be multiple version of Itcl, and we want the most recent one.
1549    for i in `ls -dr $itclpath/itcl* 2>/dev/null ` ; do
1550        if test -f $i/library/itcl_mkindex.tcl ; then
1551          ac_cv_c_itclmkidx=`(cd $i/library; ${PWDCMD-pwd})`/itcl_mkindex.tcl
1552          break
1553        fi
1554    done
1555fi
1556if test x"${ac_cv_c_itclmkidx}" = x ; then
1557    dnl Get the path to the compiler
1558    ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/share
1559    dnl Itcl 7.5 and greater puts library in subdir.  Look there first.
1560    for i in `ls -dr $ccpath/itcl* 2>/dev/null ` ; do
1561        if test -f $i/itcl_mkindex.tcl ; then
1562            ac_cv_c_itclmkidx=`(cd $i; ${PWDCMD-pwd})`/itcl_mkindex.tcl
1563            break
1564        fi
1565    done
1566fi
1567])
1568
1569if test x"${ac_cv_c_itclmkidx}" = x ; then
1570    AC_MSG_ERROR([Can't find the itcl_mkindex.tcl script])
1571fi
1572if test x"${ac_cv_c_itclmkidx}" != x ; then
1573    no_itcl=""
1574    AC_MSG_RESULT(${ac_cv_c_itclmkidx})
1575    ITCLMKIDX="${ac_cv_c_itclmkidx}"
1576else
1577   AC_MSG_RESULT(none)
1578fi
1579AC_SUBST(ITCLMKIDX)
1580])
1581
1582dnl ====================================================================
1583dnl Ok, lets find the tix source trees so we can use the headers
1584dnl the alternative search directory is involked by --with-tixinclude
1585AC_DEFUN([CYG_AC_PATH_TIX], [
1586    CYG_AC_PATH_TIXH
1587    CYG_AC_PATH_TIXLIB
1588])
1589AC_DEFUN([CYG_AC_PATH_TIXH], [
1590dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
1591no_tix=true
1592AC_MSG_CHECKING(for Tix headers in the source tree)
1593AC_ARG_WITH(tixinclude, [  --with-tixinclude       directory where tix headers are], with_tixinclude=${withval})
1594AC_CACHE_VAL(ac_cv_c_tixh,[
1595dnl first check to see if --with-tixinclude was specified
1596if test x"${with_tixinclude}" != x ; then
1597  if test -f ${with_tixinclude}/tix.h ; then
1598    ac_cv_c_tixh=`(cd ${with_tixinclude}; ${PWDCMD-pwd})`
1599  elif test -f ${with_tixinclude}/generic/tix.h ; then
1600    ac_cv_c_tixh=`(cd ${with_tixinclude}/generic; ${PWDCMD-pwd})`
1601  else
1602    AC_MSG_ERROR([${with_tixinclude} directory doesn't contain headers])
1603  fi
1604fi
1605
1606dnl next check if it came with Tix configuration file
1607if test x"${ac_cv_c_tixconfig}" != x ; then
1608  for i in $dirlist; do
1609    if test -f $ac_cv_c_tixconfig/$i/generic/tix.h ; then
1610      ac_cv_c_tixh=`(cd $ac_cv_c_tixconfig/$i/generic; ${PWDCMD-pwd})`
1611      break
1612    fi
1613  done
1614fi
1615
1616dnl next check in private source directory
1617dnl since ls returns lowest version numbers first, reverse its output
1618if test x"${ac_cv_c_tixh}" = x ; then
1619    dnl find the top level Tix source directory
1620    for i in $dirlist; do
1621        if test -n "`ls -dr $srcdir/$i/tix* 2>/dev/null`" ; then
1622	    tixpath=$srcdir/$i
1623	    break
1624	fi
1625    done
1626
1627    dnl find the exact Tix source dir. We do it this way, cause there
1628    dnl might be multiple version of Tix, and we want the most recent one.
1629    for i in `ls -dr $tixpath/tix* 2>/dev/null ` ; do
1630        if test -f $i/generic/tix.h ; then
1631          ac_cv_c_tixh=`(cd $i/generic; ${PWDCMD-pwd})`
1632          break
1633        fi
1634    done
1635fi
1636
1637dnl see if one is installed
1638if test x"${ac_cv_c_tixh}" = x ; then
1639    AC_MSG_RESULT(none)
1640    dnl Get the path to the compiler
1641
1642   dnl Get the path to the compiler. We do it this way instead of using
1643    dnl AC_CHECK_HEADER, cause this doesn't depend in having X configured.
1644    ccpath=`which ${CC}  | sed -e 's:/bin/.*::'`/include
1645    if test -f $ccpath/tix.h; then
1646	ac_cv_c_tixh=installed
1647    fi
1648else
1649   AC_MSG_RESULT(${ac_cv_c_tixh})
1650fi
1651])
1652if test x"${ac_cv_c_tixh}" = x ; then
1653    AC_MSG_ERROR([Can't find any Tix headers])
1654fi
1655if test x"${ac_cv_c_tixh}" != x ; then
1656    no_tix=""
1657    AC_MSG_RESULT(${ac_cv_c_tixh})
1658    if test x"${ac_cv_c_tixh}" != x"installed" ; then
1659        TIXHDIR="-I${ac_cv_c_tixh}"
1660    fi
1661fi
1662
1663AC_SUBST(TIXHDIR)
1664])
1665
1666AC_DEFUN([CYG_AC_PATH_TIXCONFIG], [
1667#
1668# Ok, lets find the tix configuration
1669# First, look for one uninstalled.  
1670# the alternative search directory is invoked by --with-tixconfig
1671#
1672
1673if test x"${no_tix}" = x ; then
1674  # we reset no_tix in case something fails here
1675  no_tix=true
1676  AC_ARG_WITH(tixconfig, [  --with-tixconfig           directory containing tix configuration (tixConfig.sh)],
1677         with_tixconfig=${withval})
1678  AC_MSG_CHECKING([for Tix configuration])
1679  AC_CACHE_VAL(ac_cv_c_tixconfig,[
1680
1681  # First check to see if --with-tixconfig was specified.
1682  if test x"${with_tixconfig}" != x ; then
1683    if test -f "${with_tixconfig}/tixConfig.sh" ; then
1684      ac_cv_c_tixconfig=`(cd ${with_tixconfig}; ${PWDCMD-pwd})`
1685    else
1686      AC_MSG_ERROR([${with_tixconfig} directory doesn't contain tixConfig.sh])
1687    fi
1688  fi
1689
1690  # then check for a private Tix library
1691  if test x"${ac_cv_c_tixconfig}" = x ; then
1692    for i in \
1693		../tix \
1694		`ls -dr ../tix[[4]]* 2>/dev/null` \
1695		../../tix \
1696		`ls -dr ../../tix[[4]]* 2>/dev/null` \
1697		../../../tix \
1698		`ls -dr ../../../tix[[4]]* 2>/dev/null` ; do
1699      if test -f "$i/tixConfig.sh" ; then
1700        ac_cv_c_tixconfig=`(cd $i; ${PWDCMD-pwd})`
1701	break
1702      fi
1703    done
1704  fi
1705  # check in a few common install locations
1706  if test x"${ac_cv_c_tixconfig}" = x ; then
1707    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
1708      if test -f "$i/tixConfig.sh" ; then
1709        ac_cv_c_tkconfig=`(cd $i; ${PWDCMD-pwd})`
1710	break
1711      fi
1712    done
1713  fi
1714  # check in a few other private locations
1715  if test x"${ac_cv_c_tixconfig}" = x ; then
1716    for i in \
1717		${srcdir}/../tix \
1718		`ls -dr ${srcdir}/../tix[[4-9]]* 2>/dev/null` ; do
1719      if test -f "$i/tixConfig.sh" ; then
1720        ac_cv_c_tixconfig=`(cd $i; ${PWDCMD-pwd})`
1721	break
1722      fi
1723    done
1724  fi
1725  ])
1726  if test x"${ac_cv_c_tixconfig}" = x ; then
1727    TIXCONFIG="# no Tix configs found"
1728    AC_MSG_WARN(Can't find Tix configuration definitions)
1729  else
1730    no_tix=
1731    TIXCONFIG=${ac_cv_c_tixconfig}/tixConfig.sh
1732    AC_MSG_RESULT(found $TIXCONFIG)
1733  fi
1734fi
1735
1736])
1737
1738# Defined as a separate macro so we don't have to cache the values
1739# from PATH_TIXCONFIG (because this can also be cached).
1740AC_DEFUN([CYG_AC_LOAD_TIXCONFIG], [
1741    if test -f "$TIXCONFIG" ; then
1742      . $TIXCONFIG
1743    fi
1744
1745    AC_SUBST(TIX_BUILD_LIB_SPEC)
1746    AC_SUBST(TIX_LIB_FULL_PATH)
1747])
1748
1749AC_DEFUN([CYG_AC_PATH_ITCLCONFIG], [
1750#
1751# Ok, lets find the itcl configuration
1752# First, look for one uninstalled.  
1753# the alternative search directory is invoked by --with-itclconfig
1754#
1755
1756if test x"${no_itcl}" = x ; then
1757  # we reset no_itcl in case something fails here
1758  no_itcl=true
1759  AC_ARG_WITH(itclconfig, [  --with-itclconfig           directory containing itcl configuration (itclConfig.sh)],
1760         with_itclconfig=${withval})
1761  AC_MSG_CHECKING([for Itcl configuration])
1762  AC_CACHE_VAL(ac_cv_c_itclconfig,[
1763
1764  # First check to see if --with-itclconfig was specified.
1765  if test x"${with_itclconfig}" != x ; then
1766    if test -f "${with_itclconfig}/itclConfig.sh" ; then
1767      ac_cv_c_itclconfig=`(cd ${with_itclconfig}; ${PWDCMD-pwd})`
1768    else
1769      AC_MSG_ERROR([${with_itclconfig} directory doesn't contain itclConfig.sh])
1770    fi
1771  fi
1772
1773  # then check for a private itcl library
1774  if test x"${ac_cv_c_itclconfig}" = x ; then
1775    for i in \
1776		../itcl/itcl \
1777		`ls -dr ../itcl/itcl[[3]]* 2>/dev/null` \
1778		../../itcl/itcl \
1779		`ls -dr ../../itcl/itcl[[3]]* 2>/dev/null` \
1780		../../../itcl/itcl \
1781		`ls -dr ../../../itcl/itcl[[3]]* 2>/dev/null` ; do
1782      if test -f "$i/itclConfig.sh" ; then
1783        ac_cv_c_itclconfig=`(cd $i; ${PWDCMD-pwd})`
1784	break
1785      fi
1786    done
1787  fi
1788  # check in a few common install locations
1789  if test x"${ac_cv_c_itclconfig}" = x ; then
1790    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
1791      if test -f "$i/itclConfig.sh" ; then
1792        ac_cv_c_itclconfig=`(cd $i; ${PWDCMD-pwd})`
1793	break
1794      fi
1795    done
1796  fi
1797  # check in a few other private locations
1798  if test x"${ac_cv_c_itclconfig}" = x ; then
1799    for i in \
1800		${srcdir}/../itcl/itcl \
1801		`ls -dr ${srcdir}/../itcl/itcl[[3]]* 2>/dev/null` ; do
1802      if test -f "$i/itcl/itclConfig.sh" ; then
1803        ac_cv_c_itclconfig=`(cd $i; ${PWDCMD-pwd})`
1804	break
1805      fi
1806    done
1807  fi
1808  ])
1809  if test x"${ac_cv_c_itclconfig}" = x ; then
1810    ITCLCONFIG="# no itcl configs found"
1811    AC_MSG_WARN(Can't find itcl configuration definitions)
1812  else
1813    no_itcl=
1814    ITCLCONFIG=${ac_cv_c_itclconfig}/itclConfig.sh
1815    AC_MSG_RESULT(found $ITCLCONFIG)
1816  fi
1817fi
1818
1819])
1820
1821# Defined as a separate macro so we don't have to cache the values
1822# from PATH_ITCLCONFIG (because this can also be cached).
1823AC_DEFUN([CYG_AC_LOAD_ITCLCONFIG], [
1824    if test -f "$ITCLCONFIG" ; then
1825      . $ITCLCONFIG
1826    fi
1827
1828    AC_SUBST(ITCL_BUILD_LIB_SPEC)
1829    AC_SUBST(ITCL_SH)
1830    AC_SUBST(ITCL_LIB_FILE)
1831    AC_SUBST(ITCL_LIB_FULL_PATH)
1832
1833])
1834
1835
1836AC_DEFUN([CYG_AC_PATH_ITKCONFIG], [
1837#
1838# Ok, lets find the itk configuration
1839# First, look for one uninstalled.  
1840# the alternative search directory is invoked by --with-itkconfig
1841#
1842
1843if test x"${no_itk}" = x ; then
1844  # we reset no_itk in case something fails here
1845  no_itk=true
1846  AC_ARG_WITH(itkconfig, [  --with-itkconfig           directory containing itk configuration (itkConfig.sh)],
1847         with_itkconfig=${withval})
1848  AC_MSG_CHECKING([for Itk configuration])
1849  AC_CACHE_VAL(ac_cv_c_itkconfig,[
1850
1851  # First check to see if --with-itkconfig was specified.
1852  if test x"${with_itkconfig}" != x ; then
1853    if test -f "${with_itkconfig}/itkConfig.sh" ; then
1854      ac_cv_c_itkconfig=`(cd ${with_itkconfig}; ${PWDCMD-pwd})`
1855    else
1856      AC_MSG_ERROR([${with_itkconfig} directory doesn't contain itkConfig.sh])
1857    fi
1858  fi
1859
1860  # then check for a private itk library
1861  if test x"${ac_cv_c_itkconfig}" = x ; then
1862    for i in \
1863		../itcl/itk \
1864		`ls -dr ../itcl/itk[[3]]* 2>/dev/null` \
1865		../../itcl/itk \
1866		`ls -dr ../../itcl/itk[[3]]* 2>/dev/null` \
1867		../../../itcl/itk \
1868		`ls -dr ../../../itcl/itk[[3]]* 2>/dev/null` ; do
1869      if test -f "$i/itkConfig.sh" ; then
1870        ac_cv_c_itkconfig=`(cd $i; ${PWDCMD-pwd})`
1871	break
1872      fi
1873    done
1874  fi
1875  # check in a few common install locations
1876  if test x"${ac_cv_c_itkconfig}" = x ; then
1877    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
1878      if test -f "$i/itcl/itkConfig.sh" ; then
1879        ac_cv_c_itkconfig=`(cd $i; ${PWDCMD-pwd})`
1880	break
1881      fi
1882    done
1883  fi
1884  # check in a few other private locations
1885  if test x"${ac_cv_c_itkconfig}" = x ; then
1886    for i in \
1887		${srcdir}/../itcl/itk \
1888		`ls -dr ${srcdir}/../itcl/itk[[3]]* 2>/dev/null` ; do
1889      if test -f "$i/itkConfig.sh" ; then
1890        ac_cv_c_itkconfig=`(cd $i; ${PWDCMD-pwd})`
1891	break
1892      fi
1893    done
1894  fi
1895  ])
1896  if test x"${ac_cv_c_itkconfig}" = x ; then
1897    ITCLCONFIG="# no itk configs found"
1898    AC_MSG_WARN(Can't find itk configuration definitions)
1899  else
1900    no_itk=
1901    ITKCONFIG=${ac_cv_c_itkconfig}/itkConfig.sh
1902    AC_MSG_RESULT(found $ITKCONFIG)
1903  fi
1904fi
1905
1906])
1907
1908# Defined as a separate macro so we don't have to cache the values
1909# from PATH_ITKCONFIG (because this can also be cached).
1910AC_DEFUN([CYG_AC_LOAD_ITKCONFIG], [
1911    if test -f "$ITKCONFIG" ; then
1912      . $ITKCONFIG
1913    fi
1914
1915    AC_SUBST(ITK_BUILD_LIB_SPEC)
1916    AC_SUBST(ITK_LIB_FILE)
1917    AC_SUBST(ITK_LIB_FULL_PATH)
1918])
1919
1920
1921dnl ====================================================================
1922dnl Ok, lets find the libgui source trees so we can use the headers
1923dnl the alternative search directory is involked by --with-libguiinclude
1924AC_DEFUN([CYG_AC_PATH_LIBGUI], [
1925    CYG_AC_PATH_LIBGUIH
1926    CYG_AC_PATH_LIBGUILIB
1927])
1928AC_DEFUN([CYG_AC_PATH_LIBGUIH], [
1929dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../..../../../../../../../../../../.."
1930no_libgui=true
1931AC_MSG_CHECKING(for Libgui headers in the source tree)
1932AC_ARG_WITH(libguiinclude, [  --with-libguiinclude       directory where libgui headers are], with_libguiinclude=${withval})
1933AC_CACHE_VAL(ac_cv_c_libguih,[
1934dnl first check to see if --with-libguiinclude was specified
1935if test x"${with_libguiinclude}" != x ; then
1936  if test -f ${with_libguiinclude}/guitcl.h ; then
1937    ac_cv_c_libguih=`(cd ${with_libguiinclude}; ${PWDCMD-pwd})`
1938  elif test -f ${with_libguiinclude}/src/guitcl.h ; then
1939    ac_cv_c_libguih=`(cd ${with_libguiinclude}/src; ${PWDCMD-pwd})`
1940  else
1941    AC_MSG_ERROR([${with_libguiinclude} directory doesn't contain headers])
1942  fi
1943fi
1944
1945dnl next check if it came with Libgui configuration file
1946if test x"${ac_cv_c_libguiconfig}" != x ; then
1947  for i in $dirlist; do
1948    if test -f $ac_cv_c_libguiconfig/$i/src/guitcl.h ; then
1949      ac_cv_c_libguih=`(cd $ac_cv_c_libguiconfig/$i/src; ${PWDCMD-pwd})`
1950      break
1951    fi
1952  done
1953fi
1954
1955dnl next check in private source directory
1956dnl since ls returns lowest version numbers first, reverse its output
1957if test x"${ac_cv_c_libguih}" = x ; then
1958    dnl find the top level Libgui source directory
1959    for i in $dirlist; do
1960        if test -n "`ls -dr $srcdir/$i/libgui* 2>/dev/null`" ; then
1961	    libguipath=$srcdir/$i
1962	    break
1963	fi
1964    done
1965
1966    dnl find the exact Libgui source dir. We do it this way, cause there
1967    dnl might be multiple version of Libgui, and we want the most recent one.
1968    for i in `ls -dr $libguipath/libgui* 2>/dev/null ` ; do
1969        if test -f $i/src/guitcl.h ; then
1970          ac_cv_c_libguih=`(cd $i/src; ${PWDCMD-pwd})`
1971          break
1972        fi
1973    done
1974fi
1975
1976dnl see if one is installed
1977if test x"${ac_cv_c_libguih}" = x ; then
1978   AC_MSG_RESULT(none)
1979   AC_CHECK_HEADER(guitcl.h, ac_cv_c_libguih=installed, ac_cv_c_libguih="")
1980fi
1981])
1982LIBGUIHDIR=""
1983if test x"${ac_cv_c_libguih}" = x ; then
1984    AC_MSG_WARN([Can't find any Libgui headers])
1985fi
1986if test x"${ac_cv_c_libguih}" != x ; then
1987    no_libgui=""
1988    if test x"${ac_cv_c_libguih}" != x"installed" ; then
1989        LIBGUIHDIR="-I${ac_cv_c_libguih}"
1990    fi
1991fi
1992AC_MSG_RESULT(${ac_cv_c_libguih})
1993AC_SUBST(LIBGUIHDIR)
1994])
1995
1996dnl ====================================================================
1997dnl find the GUI library
1998AC_DEFUN([CYG_AC_PATH_LIBGUILIB], [
1999AC_MSG_CHECKING(for GUI library  in the build tree)
2000dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.."
2001dnl look for the library
2002AC_MSG_CHECKING(for GUI library)
2003AC_CACHE_VAL(ac_cv_c_libguilib,[
2004if test x"${ac_cv_c_libguilib}" = x ; then
2005    for i in $dirlist; do
2006      if test -f "$i/libgui/src/Makefile" ; then
2007        ac_cv_c_libguilib=`(cd $i/libgui/src; ${PWDCMD-pwd})`
2008        break
2009      fi
2010    done
2011fi
2012]) 
2013if test x"${ac_cv_c_libguilib}" != x ; then
2014     GUILIB="${GUILIB} -L${ac_cv_c_libguilib}"
2015     LIBGUILIB="-lgui"
2016     AC_MSG_RESULT(${ac_cv_c_libguilib})
2017else
2018     AC_MSG_RESULT(none)
2019fi
2020
2021AC_SUBST(GUILIB)
2022AC_SUBST(LIBGUILIB)
2023])
2024