1 dnl AC_PATH_XREQUIRED() requires X libs. This frag has been
2 dnl lifted nearly "as is" from Postgresql's configure.in script.
4 AC_DEFUN([AC_PATH_XREQUIRED],
8 save_CPPFLAGS="$CPPFLAGS"
9 save_LDFLAGS="$LDFLAGS"
14 LIBS="$LIBS $X_EXTRA_LIBS"
15 CFLAGS="$CFLAGS $X_CFLAGS"
16 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
17 LDFLAGS="$LDFLAGS $X_LIBS"
19 dnl Check for X library
22 AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
23 if test "$X11_LIBS" = ""; then
24 dnl Not having X is bad news, period. Let the user fix this.
25 AC_MSG_ERROR([The X11 library '-lX11' could not be found,
26 so I won't go further. Please use the configure
27 options '--x-includes=DIR' and '--x-libraries=DIR'
28 to specify the X location. See the file 'config.log'
29 for further diagnostics.])
37 CPPFLAGS="$save_CPPFLAGS"
38 LDFLAGS="$save_LDFLAGS"
41 dnl AC_POSIX_SIGHANDLER() determines whether
42 dnl signal handlers are posix compliant. This frag
43 dnl has been adapted from readline's aclocal.m4.
45 AC_DEFUN([AC_POSIX_SIGHANDLER],
46 [AC_MSG_CHECKING([if signal handlers are posix compliant])
47 AC_CACHE_VAL(ac_cv_posix_sighandler,
48 [AC_TRY_COMPILE([#include <sys/types.h>
56 void (*signal(void))(void);],
57 [int i;], ac_cv_posix_sighandler=no, ac_cv_posix_sighandler=yes)])dnl
58 AC_MSG_RESULT($ac_cv_posix_sighandler)
59 if test $ac_cv_posix_sighandler = yes; then
60 AC_DEFINE(HAVE_POSIX_SIGHANDLER,1,[Kconfig])
64 #------------------------------------------------------------------------
65 # SC_PATH_TCLCONFIG --
67 # Locate the tclConfig.sh file and perform a sanity check on
68 # the Tcl compile flags
75 # Adds the following arguments to configure:
78 # Defines the following vars:
79 # TCL_BIN_DIR Full path to the directory containing
80 # the tclConfig.sh file
81 #------------------------------------------------------------------------
83 AC_DEFUN([SC_PATH_TCLCONFIG], [
85 # Ok, lets find the tcl configuration
86 # First, look for one uninstalled.
87 # the alternative search directory is invoked by --with-tcl
90 if test x"${no_tcl}" = x ; then
91 # we reset no_tcl in case something fails here
93 AC_ARG_WITH(tcl, [ --with-tcl directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
94 AC_MSG_CHECKING([for Tcl configuration])
95 AC_CACHE_VAL(ac_cv_c_tclconfig,[
97 # First check to see if --with-tcl was specified.
98 if test x"${with_tclconfig}" != x ; then
99 if test -f "${with_tclconfig}/tclConfig.sh" ; then
100 ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
102 AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
106 # then check for a private Tcl installation
107 if test x"${ac_cv_c_tclconfig}" = x ; then
110 `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
112 `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
114 `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
115 if test -f "$i/unix/tclConfig.sh" ; then
116 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
122 # check in a few common install locations
123 if test x"${ac_cv_c_tclconfig}" = x ; then
124 for i in ${prefix}/lib /usr/local/lib /usr/pkg/lib /usr/lib \
125 `ls -dr /usr/lib/tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
126 if test -f "$i/tclConfig.sh" ; then
127 ac_cv_c_tclconfig=`(cd $i; pwd)`
133 # check in a few other private locations
134 if test x"${ac_cv_c_tclconfig}" = x ; then
137 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
138 if test -f "$i/unix/tclConfig.sh" ; then
139 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
146 if test x"${ac_cv_c_tclconfig}" = x ; then
147 TCL_BIN_DIR="# no Tcl configs found"
148 AC_MSG_WARN(Can't find Tcl configuration definitions)
152 TCL_BIN_DIR=${ac_cv_c_tclconfig}
153 AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
158 #------------------------------------------------------------------------
159 # SC_PATH_TKCONFIG --
161 # Locate the tkConfig.sh file
168 # Adds the following arguments to configure:
171 # Defines the following vars:
172 # TK_BIN_DIR Full path to the directory containing
173 # the tkConfig.sh file
174 #------------------------------------------------------------------------
176 AC_DEFUN([SC_PATH_TKCONFIG], [
178 # Ok, lets find the tk configuration
179 # First, look for one uninstalled.
180 # the alternative search directory is invoked by --with-tk
183 if test x"${no_tk}" = x ; then
184 # we reset no_tk in case something fails here
186 AC_ARG_WITH(tk, [ --with-tk directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
187 AC_MSG_CHECKING([for Tk configuration])
188 AC_CACHE_VAL(ac_cv_c_tkconfig,[
190 # First check to see if --with-tkconfig was specified.
191 if test x"${with_tkconfig}" != x ; then
192 if test -f "${with_tkconfig}/tkConfig.sh" ; then
193 ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
195 AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
199 # then check for a private Tk library
200 if test x"${ac_cv_c_tkconfig}" = x ; then
203 `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
205 `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
207 `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
208 if test -f "$i/unix/tkConfig.sh" ; then
209 ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
214 # check in a few common install locations
215 if test x"${ac_cv_c_tkconfig}" = x ; then
216 for i in ${prefix}/lib /usr/local/lib /usr/pkg/lib /usr/lib \
217 `ls -dr /usr/lib/tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
218 if test -f "$i/tkConfig.sh" ; then
219 ac_cv_c_tkconfig=`(cd $i; pwd)`
224 # check in a few other private locations
225 if test x"${ac_cv_c_tkconfig}" = x ; then
228 `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
229 if test -f "$i/unix/tkConfig.sh" ; then
230 ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
236 if test x"${ac_cv_c_tkconfig}" = x ; then
237 TK_BIN_DIR="# no Tk configs found"
238 AC_MSG_WARN(Can't find Tk configuration definitions)
242 TK_BIN_DIR=${ac_cv_c_tkconfig}
243 AC_MSG_RESULT(found $TK_BIN_DIR/tkConfig.sh)
249 #------------------------------------------------------------------------
250 # SC_LOAD_TCLCONFIG --
252 # Load the tclConfig.sh file
256 # Requires the following vars to be set:
261 # Subst the following vars:
266 #------------------------------------------------------------------------
268 AC_DEFUN([SC_LOAD_TCLCONFIG], [
269 AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
271 if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
272 AC_MSG_RESULT([loading])
273 . $TCL_BIN_DIR/tclConfig.sh
275 AC_MSG_ERROR([not found])
278 AC_PATH_PROG(TCL_SCRIPT, tclsh${TCL_VERSION}, tclsh)
280 AC_SUBST(TCL_BIN_DIR)
281 AC_SUBST(TCL_SRC_DIR)
282 AC_SUBST(TCL_LIB_FILE)
285 AC_SUBST(TCL_SHLIB_LD_LIBS)
286 AC_SUBST(TCL_EXTRA_CFLAGS)
287 AC_SUBST(TCL_LD_FLAGS)
288 AC_SUBST(TCL_LIB_FILE)
289 AC_SUBST(TCL_STUB_LIB_FILE)
290 AC_SUBST(TCL_LIB_SPEC)
291 AC_SUBST(TCL_BUILD_LIB_SPEC)
292 AC_SUBST(TCL_STUB_LIB_SPEC)
293 AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
297 #------------------------------------------------------------------------
298 # SC_LOAD_TKCONFIG --
300 # Load the tkConfig.sh file
304 # Requires the following vars to be set:
309 # Sets the following vars that should be in tkConfig.sh:
311 #------------------------------------------------------------------------
313 AC_DEFUN([SC_LOAD_TKCONFIG], [
314 AC_MSG_CHECKING([for existence of $TK_BIN_DIR/tkConfig.sh])
316 if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
317 AC_MSG_RESULT([loading])
318 . $TK_BIN_DIR/tkConfig.sh
320 AC_MSG_ERROR([not found])
325 AC_SUBST(TK_LIB_FILE)
326 AC_SUBST(TK_LIB_FLAG)
327 AC_SUBST(TK_LIB_SPEC)
331 #------------------------------------------------------------------------
334 # Locate the Tix installation.
341 # Substs the following vars:
344 #------------------------------------------------------------------------
346 AC_DEFUN([SC_PATH_TIX], [
347 AC_MSG_CHECKING(for Tix's Tcl library)
349 AC_ARG_WITH(tixlibrary, [ --with-tixlibrary directory containing the Tix library files.], with_tixlibrary=${withval})
351 if test x"${with_tixlibrary}" != x ; then
352 if test -f "${with_tixlibrary}/Init.tcl" ; then
353 ac_cv_tix_libdir=${with_tixlibrary}
355 AC_MSG_ERROR([${with_tixlibrary} directory does not contain Tix's init file Init.tcl])
358 AC_CACHE_VAL(ac_cv_tix_libdir, [
360 `ls -dr /usr/local/lib/tix[[0-9]]* 2>/dev/null ` \
361 `ls -dr /usr/local/share/tix[[0-9]]* 2>/dev/null ` \
362 `ls -dr /usr/pkg/lib/tix[[0-9]]* 2>/dev/null ` \
363 `ls -dr /usr/lib/tix[[0-9]]* 2>/dev/null ` \
364 `ls -dr /usr/share/tix[[0-9]]* 2>/dev/null ` ; do
365 if test -f "$d/Init.tcl" ; then
373 AC_MSG_RESULT($ac_cv_tix_libdir)
374 TIX_TCL_LIB=$ac_cv_tix_libdir
375 AC_SUBST(TIX_TCL_LIB)
378 TIX_LIB_SPEC=$tix_LIB_SPEC
379 AC_SUBST(TIX_LIB_SPEC)
382 #------------------------------------------------------------------------
385 # Compute the name of an existing object library located in libdir
386 # from the given base name and produce the appropriate linker flags.
389 # basename The base name of the library without version
390 # numbers, extensions, or "lib" prefixes.
396 # Defines the following vars:
397 # ${basename}_LIB_NAME The computed library name.
398 # ${basename}_LIB_SPEC The computed linker flags.
399 #------------------------------------------------------------------------
401 AC_DEFUN([SC_LIB_SPEC], [
402 AC_MSG_CHECKING(for $1 library)
403 eval "sc_lib_name_dir=${libdir}"
405 `ls -dr ${sc_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \
406 `ls -dr ${sc_lib_name_dir}/lib$1.* 2>/dev/null ` \
407 `ls -dr ${sc_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \
408 `ls -dr /usr/pkg/*/lib$1.so 2>/dev/null ` \
409 `ls -dr /usr/pkg/*/lib$1[[0-9]]* 2>/dev/null ` \
410 `ls -dr /usr/pkg/lib/lib$1.so 2>/dev/null ` \
411 `ls -dr /usr/pkg/lib/lib$1[[0-9]]* 2>/dev/null ` \
412 `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
413 `ls -dr /usr/lib/lib$1.so 2>/dev/null ` \
414 `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
415 `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
416 `ls -dr /usr/local/lib/lib$1.so 2>/dev/null ` \
417 `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
418 if test -f "$i" ; then
419 sc_lib_name_dir=`dirname $i`
420 $1_LIB_NAME=`basename $i`
426 *win32* | *WIN32* | *CYGWIN_NT*)
427 $1_LIB_SPEC=${$1_LIB_NAME}
430 # Strip off the leading "lib" and trailing ".a" or ".so"
431 sc_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.so.*$//' -e 's/\.a$//'`
432 $1_LIB_SPEC="-L${sc_lib_name_dir} -l${sc_lib_name_lib}"
435 if test "x${sc_lib_name_lib}" = x ; then
436 AC_MSG_ERROR(not found)
438 AC_MSG_RESULT(${$1_LIB_SPEC})
442 #------------------------------------------------------------------------
443 # SC_PUBLIC_TCL_HEADERS --
445 # Locate the installed public Tcl header files
454 # Adds a --with-tclinclude switch to configure.
457 # Substs the following vars:
459 #------------------------------------------------------------------------
461 AC_DEFUN([SC_PUBLIC_TCL_HEADERS], [
462 AC_MSG_CHECKING(for Tcl public headers)
464 AC_ARG_WITH(tclinclude, [ --with-tclinclude directory containing the public Tcl header files.], with_tclinclude=${withval})
466 if test x"${with_tclinclude}" != x ; then
467 if test -f "${with_tclinclude}/tcl.h" ; then
468 ac_cv_c_tclh=${with_tclinclude}
470 AC_MSG_ERROR([${with_tclinclude} directory does not contain Tcl public header file tcl.h])
473 AC_CACHE_VAL(ac_cv_c_tclh, [
474 # Use the value from --with-tclinclude, if it was given
476 if test x"${with_tclinclude}" != x ; then
477 ac_cv_c_tclh=${with_tclinclude}
479 # Check in the includedir, if --prefix was specified
481 eval "temp_includedir=${includedir}"
483 ${temp_includedir} /usr/local/include /usr/include /usr/pkg/include \
484 `ls -dr /usr/include/tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
485 if test -f "$i/tcl.h" ; then
494 # Print a message based on how we determined the include path
496 if test x"${ac_cv_c_tclh}" = x ; then
497 AC_MSG_ERROR(tcl.h not found. Please specify its location with --with-tclinclude)
499 AC_MSG_RESULT(${ac_cv_c_tclh})
502 # Convert to a native path and substitute into the output files.
504 INCLUDE_DIR_NATIVE=`echo ${ac_cv_c_tclh}`
506 TCL_INCLUDES="-I${INCLUDE_DIR_NATIVE}"
508 AC_SUBST(TCL_INCLUDES)
511 #------------------------------------------------------------------------
512 # SC_PUBLIC_TK_HEADERS --
514 # Locate the installed public Tk header files
523 # Adds a --with-tkinclude switch to configure.
526 # Substs the following vars:
528 #------------------------------------------------------------------------
530 AC_DEFUN([SC_PUBLIC_TK_HEADERS], [
531 AC_MSG_CHECKING(for Tk public headers)
533 AC_ARG_WITH(tkinclude, [ --with-tkinclude directory containing the public Tk header files.], with_tkinclude=${withval})
535 if test x"${with_tkinclude}" != x ; then
536 if test -f "${with_tkinclude}/tk.h" ; then
537 ac_cv_c_tkh=${with_tkinclude}
539 AC_MSG_ERROR([${with_tkinclude} directory does not contain Tk public header file tk.h])
542 AC_CACHE_VAL(ac_cv_c_tkh, [
543 # Use the value from --with-tkinclude, if it was given
545 if test x"${with_tkinclude}" != x ; then
546 ac_cv_c_tkh=${with_tkinclude}
548 # Check in the includedir, if --prefix was specified
550 eval "temp_includedir=${includedir}"
552 ${temp_includedir} /usr/local/include /usr/include /usr/pkg/include \
553 `ls -dr /usr/include/tk[[8-9]].[[0-9]]* 2>/dev/null` \
554 `ls -dr /usr/include/tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
555 if test -f "$i/tk.h" ; then
564 # Print a message based on how we determined the include path
566 if test x"${ac_cv_c_tkh}" = x ; then
567 AC_MSG_ERROR(tk.h not found. Please specify its location with --with-tkinclude)
569 AC_MSG_RESULT(${ac_cv_c_tkh})
572 # Convert to a native path and substitute into the output files.
574 INCLUDE_DIR_NATIVE=`echo ${ac_cv_c_tkh}`
576 TK_INCLUDES="-I${INCLUDE_DIR_NATIVE}"
578 AC_SUBST(TK_INCLUDES)