]> www.wagner.pp.ru Git - oss/fgis.git/blob - acsite.m4
Added logic to find GDAL installation.
[oss/fgis.git] / acsite.m4
1 dnl ---------------------------------------------------------------------------
2 dnl Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva
3 dnl
4 dnl Synopsis
5 dnl
6 dnl AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
7 dnl
8 dnl Description
9 dnl
10 dnl This macro substitutes (with AC_SUBST) VARNAME with the expansion of
11 dnl itself or the DIR variable if specified, taking care of fixing up
12 dnl ${prefix} and such.
13 dnl
14 dnl Side effect: VARNAME is replaced with the expansion.
15 dnl
16 dnl AC_SUBST_DIR bases on Alexandre Oliva's AC_DEFINE_DIR macro. 
17 dnl
18 dnl http://ac-archive.sourceforge.net/Miscellaneous/ac_define_dir.html
19 dnl ---------------------------------------------------------------------------
20
21 AC_DEFUN([AC_DEFINE_DIR], [
22   test "x$prefix" = xNONE && prefix="$ac_default_prefix"
23   test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
24   ac_define_dir=`eval echo [$]$2`
25   ac_define_dir=`eval echo [$]ac_define_dir`
26   ifelse($3, ,
27     [AC_DEFINE_UNQUOTED($1, "$ac_define_dir")],
28     [AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])])
29 ])
30
31 dnl ---------------------------------------------------------------------------
32 dnl Mathias Hasselmann <mathias.hasselmann@gmx.de> with modifications
33 dnl by Andrey Kiselev <dron@remotesensing.org>
34 dnl
35 dnl Synopsis
36 dnl
37 dnl AC_SUBST_DIR(VARNAME, [DIR])
38 dnl
39 dnl Description
40 dnl
41 dnl This macro substitutes (with AC_SUBST) VARNAME with the expansion of itself
42 dnl or the DIR variable if specified, taking care of fixing up ${prefix}
43 dnl and such.
44 dnl
45 dnl Side effect: VARNAME is replaced with the expansion.
46 dnl
47 dnl AC_SUBST_DIR bases on Alexandre Oliva's AC_DEFINE_DIR macro.
48 dnl
49 dnl http://ac-archive.sourceforge.net/Miscellaneous/ac_subst_dir.html
50 dnl ---------------------------------------------------------------------------
51
52 AC_DEFUN([AC_SUBST_DIR], [
53         ifelse($2, , , $1=[$]$2)
54         test "x$prefix" = xNONE && prefix="$ac_default_prefix"
55         test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
56         $1=`eval echo [$]$1`
57         $1=`eval echo [$]$1`
58         AC_SUBST($1)
59 ])
60
61 dnl ---------------------------------------------------------------------------
62 dnl Following macros for Tcl and Tk searching copied from Expect package
63 dnl Several Debian-specific additions by
64 dnl Andrey Kiselev <dron@remotesensing.org>
65 dnl ---------------------------------------------------------------------------
66
67 AC_DEFUN(CY_AC_PATH_TCLH, [
68 #
69 # Ok, lets find the tcl source trees so we can use the headers
70 # Warning: transition of version 9 to 10 will break this algorithm
71 # because 10 sorts before 9. We also look for just tcl. We have to
72 # be careful that we don't match stuff like tclX by accident.
73 # the alternative search directory is involked by --with-tclinclude
74 #
75 no_tcl=true
76 AC_MSG_CHECKING(for Tcl private headers)
77 AC_ARG_WITH(tclinclude, [  --with-tclinclude[=DIR]   directory where tcl private headers are], with_tclinclude=${withval})
78 AC_CACHE_VAL(ac_cv_c_tclh,[
79 # first check to see if --with-tclinclude was specified
80 if test x"${with_tclinclude}" != x ; then
81   if test -f ${with_tclinclude}/tclInt.h ; then
82     ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
83   elif test -f ${with_tclinclude}/generic/tclInt.h ; then
84     ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
85   else
86     AC_MSG_ERROR([${with_tclinclude} directory doesn't contain private headers])
87   fi
88 fi
89
90 # next check if it came with Tcl configuration file
91 if test x"${ac_cv_c_tclconfig}" != x ; then
92   if test -f $ac_cv_c_tclconfig/../generic/tclInt.h ; then
93     ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/../generic; pwd)`
94   fi
95 fi
96
97 # next check in private source directory
98 #
99 # since ls returns lowest version numbers first, reverse its output
100 if test x"${ac_cv_c_tclh}" = x ; then
101   for i in \
102                 ${srcdir}/../tcl \
103                 `ls -dr ${srcdir}/../tcl[[9]].[[0-9]].[[0-9]] ${srcdir}/../tcl[[9]].[[0-9]] 2>/dev/null` \
104                 `ls -dr ${srcdir}/../tcl[[8]].[[2-9]].[[0-9]] ${srcdir}/../tcl[[8]].[[2-9]] 2>/dev/null` \
105                 ${srcdir}/../../tcl \
106                 `ls -dr ${srcdir}/../../tcl[[9]].[[0-9]].[[0-9]] ${srcdir}/../../tcl[[9]].[[0-9]] 2>/dev/null` \
107                 `ls -dr ${srcdir}/../../tcl[[8]].[[2-9]].[[0-9]] ${srcdir}/../../tcl[[8]].[[2-9]] 2>/dev/null` \
108                 ${srcdir}/../../../tcl \
109                 `ls -dr ${srcdir}/../../../tcl[[9]].[[0-9]].[[0-9]] ${srcdir}/../../../tcl[[9]].[[0-9]] 2>/dev/null ` \
110                 `ls -dr ${srcdir}/../../../tcl[[8]].[[2-9]].[[0-9]] ${srcdir}/../../../tcl[[8]].[[2-9]] 2>/dev/null ` ; do
111     if test -f $i/generic/tclInt.h ; then
112       ac_cv_c_tclh=`(cd $i/generic; pwd)`
113       break
114     fi
115   done
116 fi
117
118 # check Debian-specific locations
119 if test x"${ac_cv_c_tclh}" = x ; then
120   for i in \
121                 `ls -dr /usr/include/tcl[[9]].[[0-9]].[[0-9]]/tcl-private /usr/include/tcl[[9]].[[0-9]]/tcl-private 2>/dev/null` \
122                 `ls -dr /usr/include/tcl[[8]].[[2-9]].[[0-9]]/tcl-private /usr/include/tcl[[8]].[[2-9]]/tcl-private 2>/dev/null`; do
123     if test -f $i/generic/tclInt.h ; then
124       ac_cv_c_tclh=`(cd $i/generic; pwd)`
125       break
126     fi
127   done
128 fi
129
130 # finally check in a few common install locations
131 #
132 # since ls returns lowest version numbers first, reverse its output
133 if test x"${ac_cv_c_tclh}" = x ; then
134   for i in \
135                 `ls -dr /usr/lib/tcl[[9]].[[0-9]].[[0-9]]/tcl-private /usr/lib/tcl[[9]].[[0-9]]/tcl-private 2>/dev/null` \
136                 `ls -dr /usr/lib/tcl[[8]].[[2-9]].[[0-9]]/tcl-private /usr/lib/tcl[[8]].[[2-9]]/tcl-private 2>/dev/null` \
137                 `ls -dr /usr/local/src/tcl[[9]].[[0-9]].[[0-9]] /usr/local/src/tcl[[9]].[[0-9]] 2>/dev/null` \
138                 `ls -dr /usr/local/src/tcl[[8]].[[2-9]].[[0-9]] /usr/local/src/tcl[[8]].[[2-9]] 2>/dev/null` \
139                 `ls -dr /usr/local/lib/tcl[[9]].[[0-9]].[[0-9]] /usr/local/lib/tcl[[9]].[[0-9]] 2>/dev/null` \
140                 `ls -dr /usr/local/lib/tcl[[8]].[[2-9]].[[0-9]] /usr/local/lib/tcl[[8]].[[2-9]] 2>/dev/null` \
141                 /usr/local/src/tcl \
142                 /usr/local/lib/tcl \
143                 ${prefix}/include ; do
144     if test -f $i/generic/tclInt.h ; then
145       ac_cv_c_tclh=`(cd $i/generic; pwd)`
146       break
147     fi
148   done
149 fi
150 # see if one is installed
151 if test x"${ac_cv_c_tclh}" = x ; then
152    AC_HEADER_CHECK(tclInt.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
153 fi
154 ])
155 if test x"${ac_cv_c_tclh}" = x ; then
156   TCLHDIR="# no Tcl private headers found"
157   TCLHDIRDASHI="# no Tcl private headers found"
158   AC_MSG_ERROR([Can't find Tcl private headers])
159 fi
160 if test x"${ac_cv_c_tclh}" != x ; then
161   no_tcl=""
162   if test x"${ac_cv_c_tclh}" = x"installed" ; then
163     AC_MSG_RESULT([is installed])
164     TCLHDIR=""
165     TCLHDIRDASHI=""
166     TCL_LIBRARY=""
167   else
168     AC_MSG_RESULT([found in ${ac_cv_c_tclh}])
169     # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
170     TCLHDIR="${ac_cv_c_tclh}"
171     TCLHDIRDASHI="-I${ac_cv_c_tclh}"
172     TCL_LIBRARY=`echo $TCLHDIR | sed -e 's/generic//'`library
173   fi
174 fi
175
176 AC_SUBST(TCLHDIR)
177 AC_SUBST(TCLHDIRDASHI)
178 AC_SUBST(TCL_LIBRARY)
179 ])
180
181
182 AC_DEFUN(CY_AC_PATH_TCLCONFIG, [
183 #
184 # Ok, lets find the tcl configuration
185 # First, look for one uninstalled.  
186 # the alternative search directory is invoked by --with-tcl
187 #
188
189 if test x"${no_tcl}" = x ; then
190   # we reset no_tcl in case something fails here
191   no_tcl=true
192   AC_ARG_WITH(tcl, [  --with-tcl[=DIR]          directory containing tcl configuration (tclConfig.sh)],
193          with_tclconfig=${withval})
194   AC_MSG_CHECKING([for Tcl configuration])
195   AC_CACHE_VAL(ac_cv_c_tclconfig,[
196
197   # First check to see if --with-tcl was specified.
198   if test x"${with_tclconfig}" != x ; then
199     if test -f "${with_tclconfig}/tclConfig.sh" ; then
200       ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
201     else
202       AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
203     fi
204   fi
205
206   # then check for a private Tcl installation
207   if test x"${ac_cv_c_tclconfig}" = x ; then
208     for i in \
209                 ../tcl \
210                 `ls -dr ../tcl[[9]].[[0-9]].[[0-9]] ../tcl[[9]].[[0-9]] 2>/dev/null` \
211                 `ls -dr ../tcl[[8]].[[2-9]].[[0-9]] ../tcl[[8]].[[2-9]] 2>/dev/null` \
212                 ../../tcl \
213                 `ls -dr ../../tcl[[9]].[[0-9]].[[0-9]] ../../tcl[[9]].[[0-9]] 2>/dev/null` \
214                 `ls -dr ../../tcl[[8]].[[2-9]].[[0-9]] ../../tcl[[8]].[[2-9]] 2>/dev/null` \
215                 ../../../tcl \
216                 `ls -dr ../../../tcl[[9]].[[0-9]].[[0-9]] ../../../tcl[[9]].[[0-9]] 2>/dev/null` \
217                 `ls -dr ../../../tcl[[8]].[[2-9]].[[0-9]] ../../../tcl[[8]].[[2-9]] 2>/dev/null` ; do
218       if test -f "$i/unix/tclConfig.sh" ; then
219         ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
220         break
221       fi
222     done
223   fi
224   # check in a few common install locations
225   if test x"${ac_cv_c_tclconfig}" = x ; then
226     for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
227       if test -f "$i/tclConfig.sh" ; then
228         ac_cv_c_tclconfig=`(cd $i; pwd)`
229         break
230       fi
231     done
232   fi
233   
234   # check Debian-specific locations
235   if test x"${ac_cv_c_tclconfig}" = x ; then
236     for i in \
237                 `ls -dr /usr/lib/tcl[[9]].[[0-9]].[[0-9]] /usr/lib/tcl[[9]].[[0-9]] 2>/dev/null` \
238                 `ls -dr /usr/lib/tcl[[8]].[[2-9]].[[0-9]] /usr/lib/tcl[[8]].[[2-9]] 2>/dev/null` ; do
239       if test -f "$i/tclConfig.sh" ; then
240         ac_cv_c_tclconfig=`(cd $i; pwd)`
241         break
242       fi
243     done
244   fi
245
246   # check in a few other private locations
247   if test x"${ac_cv_c_tclconfig}" = x ; then
248     for i in \
249                 ${srcdir}/../tcl \
250                 `ls -dr ${srcdir}/../tcl[[9]].[[0-9]].[[0-9]] ${srcdir}/../tcl[[9]].[[0-9]] 2>/dev/null` \
251                 `ls -dr ${srcdir}/../tcl[[8]].[[2-9]].[[0-9]] ${srcdir}/../tcl[[8]].[[2-9]] 2>/dev/null` ; do
252       if test -f "$i/unix/tclConfig.sh" ; then
253         ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
254         break
255       fi
256     done
257   fi
258   ])
259   if test x"${ac_cv_c_tclconfig}" = x ; then
260     TCLCONFIG="# no Tcl configs found"
261     AC_MSG_WARN(Can't find Tcl configuration definitions)
262   else
263     no_tcl=
264     TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
265     AC_MSG_RESULT(found $TCLCONFIG)
266   fi
267 fi
268 ])
269
270 # Defined as a separate macro so we don't have to cache the values
271 # from PATH_TCLCONFIG (because this can also be cached).
272 AC_DEFUN(CY_AC_LOAD_TCLCONFIG, [
273     . $TCLCONFIG
274
275 dnl AC_SUBST(TCL_VERSION)
276 dnl AC_SUBST(TCL_MAJOR_VERSION)
277 dnl AC_SUBST(TCL_MINOR_VERSION)
278 dnl AC_SUBST(TCL_CC)
279     AC_SUBST(TCL_DEFS)
280 dnl following is just to test if missing symbol can be handled by configure
281     AC_SUBST(TCL_DELETEME)
282     AC_SUBST(TCL_DBGX)
283
284 dnl not used, don't export to save symbols
285 dnl    AC_SUBST(TCL_LIB_FILE)
286
287 dnl don't export, not used outside of configure
288 dnl     AC_SUBST(TCL_LIBS)
289 dnl not used, don't export to save symbols
290 dnl    AC_SUBST(TCL_PREFIX)
291
292     AC_SUBST(TCL_EXEC_PREFIX)
293
294 dnl not used, don't export to save symbols
295 dnl AC_SUBST(TCL_SHLIB_CFLAGS)
296     AC_SUBST(TCL_SHLIB_LD)
297 dnl don't export, not used outside of configure
298 dnl AC_SUBST(TCL_SHLIB_LD_LIBS)
299
300 # Tcl defines TCL_SHLIB_SUFFIX but TCL_SHARED_LIB_SUFFIX then looks for it
301 # as just SHLIB_SUFFIX.  How bizarre.
302     SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
303     AC_SUBST(SHLIB_SUFFIX)
304
305 dnl not used, don't export to save symbols
306 dnl AC_SUBST(TCL_DL_LIBS)
307     AC_SUBST(TCL_LD_FLAGS)
308 dnl don't export, not used outside of configure
309 dnl AC_SUBST(TCL_LD_SEARCH_FLAGS)
310 dnl AC_SUBST(TCL_COMPAT_OBJS)
311 dnl AC_SUBST(TCL_RANLIB)
312
313 # if Tcl's build directory has been removed, TCL_LIB_SPEC should
314 # be used instead of TCL_BUILD_LIB_SPEC
315 SAVELIBS=$LIBS
316 # eval used to expand out TCL_DBGX
317 eval "LIBS=\"$TCL_BUILD_LIB_SPEC $TCL_LIBS\""
318 AC_MSG_CHECKING([Tcl build library])
319 AC_MSG_RESULT($LIBS)
320
321 AC_CHECK_FUNC(Tcl_CreateCommand,[
322         AC_MSG_CHECKING([if Tcl library build specification is valid])
323         AC_MSG_RESULT(yes)
324 ],[
325         TCL_BUILD_LIB_SPEC=$TCL_LIB_SPEC
326         # Can't pull the following CHECKING call out since it will be
327         # broken up by the CHECK_FUNC just above.
328         AC_MSG_CHECKING([if Tcl library build specification is valid])
329         AC_MSG_RESULT(no)
330 ])
331 LIBS=$SAVELIBS
332
333     AC_SUBST(TCL_BUILD_LIB_SPEC)
334     AC_SUBST(TCL_LIB_SPEC)
335 dnl AC_SUBST(TCL_LIB_VERSIONS_OK)
336
337     AC_SUBST(TCL_SHARED_LIB_SUFFIX)
338
339 dnl not used, don't export to save symbols
340 dnl    AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
341 ])
342
343 # Warning: Tk definitions are very similar to Tcl definitions but
344 # are not precisely the same.  There are a couple of differences,
345 # so don't do changes to Tcl thinking you can cut and paste it do 
346 # the Tk differences and later simply substitute "Tk" for "Tcl".
347 # Known differences:
348 #  - Acceptable Tcl major version #s is 8.2-9.* while Tk is 8.2-9.*
349 #  - Searching for Tcl includes looking for tclInt.h, Tk looks for tk.h
350 #  - Computing major/minor versions is different because Tk depends on
351 #    headers to Tcl, Tk, and X.
352 #  - Symbols in tkConfig.sh are different than tclConfig.sh
353 #  - Acceptable for Tk to be missing but not Tcl.
354
355 AC_DEFUN(CY_AC_PATH_TKH, [
356 #
357 # Ok, lets find the tk source trees so we can use the headers
358 # If the directory (presumably symlink) named "tk" exists, use that one
359 # in preference to any others.  Same logic is used when choosing library
360 # and again with Tcl. The search order is the best place to look first, then in
361 # decreasing significance. The loop breaks if the trigger file is found.
362 # Note the gross little conversion here of srcdir by cd'ing to the found
363 # directory. This converts the path from a relative to an absolute, so
364 # recursive cache variables for the path will work right. We check all
365 # the possible paths in one loop rather than many seperate loops to speed
366 # things up.
367 # the alternative search directory is involked by --with-tkinclude
368 #
369 #no_tk=true
370 AC_MSG_CHECKING(for Tk private headers)
371 AC_ARG_WITH(tkinclude, [  --with-tkinclude[=DIR]    directory where tk private headers are], with_tkinclude=${withval})
372 AC_CACHE_VAL(ac_cv_c_tkh,[
373 # first check to see if --with-tkinclude was specified
374 if test x"${with_tkinclude}" != x ; then
375   if test -f ${with_tkinclude}/tk.h ; then
376     ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
377   elif test -f ${with_tkinclude}/generic/tk.h ; then
378     ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; pwd)`
379   else
380     AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers])
381   fi
382 fi
383
384 # next check if it came with Tk configuration file
385 if test x"${ac_cv_c_tkconfig}" != x ; then
386   if test -f $ac_cv_c_tkconfig/../generic/tk.h ; then
387     ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/../generic; pwd)`
388   fi
389 fi
390
391 # next check in private source directory
392 #
393 # since ls returns lowest version numbers first, reverse its output
394 if test x"${ac_cv_c_tkh}" = x ; then
395   for i in \
396                 ${srcdir}/../tk \
397                 `ls -dr ${srcdir}/../tk[[4-9]].[[0-9]].[[0-9]] ${srcdir}/../tk[[4-9]].[[0-9]] 2>/dev/null` \
398                 `ls -dr ${srcdir}/../tk[[4-9]].[[0-9]].[[0-9]] ${srcdir}/../tk[[4-9]].[[0-9]] 2>/dev/null` \
399                 ${srcdir}/../../tk \
400                 `ls -dr ${srcdir}/../../tk[[4-9]].[[0-9]].[[0-9]] ${srcdir}/../../tk[[4-9]].[[0-9]] 2>/dev/null` \
401                 `ls -dr ${srcdir}/../../tk[[4-9]].[[0-9]].[[0-9]] ${srcdir}/../../tk[[4-9]].[[0-9]] 2>/dev/null` \
402                 ${srcdir}/../../../tk \
403                 `ls -dr ${srcdir}/../../../tk[[4-9]].[[0-9]].[[0-9]] ${srcdir}/../../../tk[[4-9]].[[0-9]] 2>/dev/null ` \
404                 `ls -dr ${srcdir}/../../../tk[[4-9]].[[0-9]].[[0-9]] ${srcdir}/../../../tk[[4-9]].[[0-9]] 2>/dev/null ` ; do
405     if test -f $i/generic/tk.h ; then
406       ac_cv_c_tkh=`(cd $i/generic; pwd)`
407       break
408     fi
409   done
410 fi
411
412 # check Debian-specific locations
413 if test x"${ac_cv_c_tkh}" = x ; then
414   for i in \
415                 `ls -dr /usr/include/tcl[[9]].[[0-9]].[[0-9]]/tk-private /usr/include/tcl[[9]].[[0-9]]/tk-private 2>/dev/null` \
416                 `ls -dr /usr/include/tcl[[8]].[[2-9]].[[0-9]]/tk-private /usr/include/tcl[[8]].[[2-9]]/tk-private 2>/dev/null` ; do
417     if test -f $i/generic/tk.h ; then
418       ac_cv_c_tkh=`(cd $i/generic; pwd)`
419       break
420     fi
421   done
422 fi
423
424 # finally check in a few common install locations
425 #
426 # since ls returns lowest version numbers first, reverse its output
427 if test x"${ac_cv_c_tkh}" = x ; then
428   for i in \
429                 `ls -dr /usr/local/src/tk[[4-9]].[[0-9]].[[0-9]] /usr/local/src/tk[[4-9]].[[0-9]] 2>/dev/null` \
430                 `ls -dr /usr/local/src/tk[[4-9]].[[0-9]].[[0-9]] /usr/local/src/tk[[4-9]].[[0-9]] 2>/dev/null` \
431                 `ls -dr /usr/local/lib/tk[[4-9]].[[0-9]].[[0-9]] /usr/local/lib/tk[[4-9]].[[0-9]] 2>/dev/null` \
432                 `ls -dr /usr/local/lib/tk[[4-9]].[[0-9]].[[0-9]] /usr/local/lib/tk[[4-9]].[[0-9]] 2>/dev/null` \
433                 /usr/local/src/tk \
434                 /usr/local/lib/tk \
435                 ${prefix}/include ; do
436     if test -f $i/generic/tk.h ; then
437       ac_cv_c_tkh=`(cd $i/generic; pwd)`
438       break
439     fi
440   done
441 fi
442 # see if one is installed
443 if test x"${ac_cv_c_tkh}" = x ; then
444    AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed, ac_cv_c_tkh="")
445 fi
446 ])
447 if test x"${ac_cv_c_tkh}" != x ; then
448 #  no_tk=""
449   if test x"${ac_cv_c_tkh}" = x"installed" ; then
450     AC_MSG_RESULT([is installed])
451     TKHDIRDASHI=""
452   else
453     AC_MSG_RESULT([found in ${ac_cv_c_tkh}])
454     # this hack is cause the TKHDIRDASHI won't print if there is a "-I" in it.
455     TKHDIRDASHI="-I${ac_cv_c_tkh}"
456   fi
457 else
458   TKHDIRDASHI="# no Tk directory found"
459   AC_MSG_WARN([Can't find Tk private headers])
460   no_tk=true
461 fi
462
463 AC_SUBST(TKHDIRDASHI)
464 ])
465
466
467 AC_DEFUN(CY_AC_PATH_TKCONFIG, [
468 #
469 # Ok, lets find the tk configuration
470 # First, look for one uninstalled.  
471 # the alternative search directory is invoked by --with-tk
472 #
473
474 if test x"${no_tk}" = x ; then
475   # we reset no_tk in case something fails here
476   no_tk=true
477   AC_ARG_WITH(tk, [  --with-tk[=DIR]           directory containing tk configuration (tkConfig.sh)],
478          with_tkconfig=${withval})
479   AC_MSG_CHECKING([for Tk configuration])
480   AC_CACHE_VAL(ac_cv_c_tkconfig,[
481
482   # First check to see if --with-tk was specified.
483   if test x"${with_tkconfig}" != x ; then
484     if test -f "${with_tkconfig}/tkConfig.sh" ; then
485       ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
486     else
487       AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
488     fi
489   fi
490
491   # then check for a private Tk library
492   if test x"${ac_cv_c_tkconfig}" = x ; then
493     for i in \
494                 ../tk \
495                 `ls -dr ../tk[[4-9]].[[0-9]].[[0-9]] ../tk[[4-9]].[[0-9]] 2>/dev/null` \
496                 `ls -dr ../tk[[4-9]].[[0-9]].[[0-9]] ../tk[[4-9]].[[0-9]] 2>/dev/null` \
497                 ../../tk \
498                 `ls -dr ../../tk[[4-9]].[[0-9]].[[0-9]] ../../tk[[4-9]].[[0-9]] 2>/dev/null` \
499                 `ls -dr ../../tk[[4-9]].[[0-9]].[[0-9]] ../../tk[[4-9]].[[0-9]] 2>/dev/null` \
500                 ../../../tk \
501                 `ls -dr ../../../tk[[4-9]].[[0-9]].[[0-9]] ../../../tk[[4-9]].[[0-9]] 2>/dev/null` \
502                 `ls -dr ../../../tk[[4-9]].[[0-9]].[[0-9]] ../../../tk[[4-9]].[[0-9]] 2>/dev/null` ; do
503       if test -f "$i/unix/tkConfig.sh" ; then
504         ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
505         break
506       fi
507     done
508   fi
509   # check in a few common install locations
510   if test x"${ac_cv_c_tkconfig}" = x ; then
511     for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
512       if test -f "$i/tkConfig.sh" ; then
513         ac_cv_c_tkconfig=`(cd $i; pwd)`
514         break
515       fi
516     done
517   fi
518   # check Debian-specific locations
519   if test x"${ac_cv_c_tkconfig}" = x ; then
520     for i in \
521                 `ls -dr /usr/lib/tk[[4-9]].[[0-9]].[[0-9]] /usr/lib/tk[[4-9]].[[0-9]] 2>/dev/null` \
522                 `ls -dr /usr/lib/tk[[4-9]].[[0-9]].[[0-9]] /usr/lib/tk[[4-9]].[[0-9]] 2>/dev/null` ; do
523       if test -f "$i/tkConfig.sh" ; then
524         ac_cv_c_tkconfig=`(cd $i; pwd)`
525         break
526       fi
527     done
528   fi
529   # check in a few other private locations
530   if test x"${ac_cv_c_tkconfig}" = x ; then
531     for i in \
532                 ${srcdir}/../tk \
533                 `ls -dr ${srcdir}/../tk[[4-9]].[[0-9]].[[0-9]] ${srcdir}/../tk[[4-9]].[[0-9]] 2>/dev/null` \
534                 `ls -dr ${srcdir}/../tk[[4-9]].[[0-9]].[[0-9]] ${srcdir}/../tk[[4-9]].[[0-9]] 2>/dev/null` ; do
535       if test -f "$i/unix/tkConfig.sh" ; then
536         ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
537         break
538       fi
539     done
540   fi
541   ])
542   if test x"${ac_cv_c_tkconfig}" = x ; then
543     TKCONFIG="# no Tk configs found"
544     AC_MSG_WARN(Can't find Tk configuration definitions)
545   else
546     no_tk=
547     TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
548     AC_MSG_RESULT(found $TKCONFIG)
549   fi
550 fi
551
552 ])
553
554 # Defined as a separate macro so we don't have to cache the values
555 # from PATH_TKCONFIG (because this can also be cached).
556 AC_DEFUN(CY_AC_LOAD_TKCONFIG, [
557     if test -f "$TKCONFIG" ; then
558       . $TKCONFIG
559     fi
560
561     AC_SUBST(TK_VERSION)
562 dnl not actually used, don't export to save symbols
563 dnl    AC_SUBST(TK_MAJOR_VERSION)
564 dnl    AC_SUBST(TK_MINOR_VERSION)
565     AC_SUBST(TK_DEFS)
566
567     AC_SUBST(TK_DBGX)
568 dnl not used, don't export to save symbols
569     dnl AC_SUBST(TK_LIB_FILE)
570
571 dnl not used outside of configure
572 dnl    AC_SUBST(TK_LIBS)
573 dnl not used, don't export to save symbols
574 dnl    AC_SUBST(TK_PREFIX)
575
576 dnl not used, don't export to save symbols
577 dnl    AC_SUBST(TK_EXEC_PREFIX)
578
579     AC_SUBST(TK_XINCLUDES)
580     AC_SUBST(TK_XLIBSW)
581
582 # if Tk's build directory has been removed, TK_LIB_SPEC should
583 # be used instead of TK_BUILD_LIB_SPEC
584 SAVELIBS=$LIBS
585 # eval used to expand out TK_DBGX
586 eval "LIBS=\"$TK_BUILD_LIB_SPEC $TCL_BUILD_LIB_SPEC $TK_LIBS\""
587 AC_CHECK_FUNC(Tk_Init,[
588         AC_MSG_CHECKING([if Tk library build specification is valid])
589         AC_MSG_RESULT(yes)
590 ],[
591         TK_BUILD_LIB_SPEC=$TK_LIB_SPEC
592         # Can't pull the following CHECKING call out since it will be
593         # broken up by the CHECK_FUNC just above.
594         AC_MSG_CHECKING([if Tk library build specification is valid])
595         AC_MSG_RESULT(no)
596 ])
597 LIBS=$SAVELIBS
598
599     AC_SUBST(TK_BUILD_LIB_SPEC)
600     AC_SUBST(TK_LIB_SPEC)
601 ])
602