3 # This file provides a set of autoconf macros to help TEA-enable
6 # Copyright (c) 1999 Scriptics Corporation.
8 # See the file "license.terms" for information on usage and redistribution
9 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 #------------------------------------------------------------------------
12 # SC_PATH_TCLCONFIG --
14 # Locate the tclConfig.sh file and perform a sanity check on
15 # the Tcl compile flags
22 # Adds the following arguments to configure:
25 # Defines the following vars:
26 # TCL_BIN_DIR Full path to the directory containing
27 # the tclConfig.sh file
28 #------------------------------------------------------------------------
30 AC_DEFUN(SC_PATH_TCLCONFIG, [
32 # Ok, lets find the tcl configuration
33 # First, look for one uninstalled.
34 # the alternative search directory is invoked by --with-tcl
37 if test x"${no_tcl}" = x ; then
38 # we reset no_tcl in case something fails here
40 AC_ARG_WITH(tcl, [ --with-tcl directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
41 AC_MSG_CHECKING([for Tcl configuration])
42 AC_CACHE_VAL(ac_cv_c_tclconfig,[
44 # First check to see if --with-tcl was specified.
45 if test x"${with_tclconfig}" != x ; then
46 if test -f "${with_tclconfig}/tclConfig.sh" ; then
47 ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
49 AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
53 # then check for a private Tcl installation
54 if test x"${ac_cv_c_tclconfig}" = x ; then
57 `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
59 `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
61 `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
62 if test -f "$i/unix/tclConfig.sh" ; then
63 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
66 if test -f "$i/win/tclConfig.sh" ; then
67 ac_cv_c_tclconfig=`(cd $i/win; pwd)`
73 # check in a few common install locations
74 if test x"${ac_cv_c_tclconfig}" = x ; then
75 for i in `ls -d ${prefix}/lib 2>/dev/null` \
76 `ls -d /usr/local/lib 2>/dev/null` ; do
77 if test -f "$i/tclConfig.sh" ; then
78 ac_cv_c_tclconfig=`(cd $i; pwd)`
84 # check in a few other private locations
85 if test x"${ac_cv_c_tclconfig}" = x ; then
88 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
89 if test -f "$i/unix/tclConfig.sh" ; then
90 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
93 if test -f "$i/win/tclConfig.sh" ; then
94 ac_cv_c_tclconfig=`(cd $i/win; pwd)`
101 if test x"${ac_cv_c_tclconfig}" = x ; then
102 TCL_BIN_DIR="# no Tcl configs found"
103 AC_MSG_ERROR(Can't find Tcl configuration definitions)
107 TCL_BIN_DIR=${ac_cv_c_tclconfig}
108 AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
113 #------------------------------------------------------------------------
114 # SC_PATH_TKCONFIG --
116 # Locate the tkConfig.sh file
123 # Adds the following arguments to configure:
126 # Defines the following vars:
127 # TK_BIN_DIR Full path to the directory containing
128 # the tkConfig.sh file
129 #------------------------------------------------------------------------
131 AC_DEFUN(SC_PATH_TKCONFIG, [
133 # Ok, lets find the tk configuration
134 # First, look for one uninstalled.
135 # the alternative search directory is invoked by --with-tk
138 if test x"${no_tk}" = x ; then
139 # we reset no_tk in case something fails here
141 AC_ARG_WITH(tk, [ --with-tk directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
142 AC_MSG_CHECKING([for Tk configuration])
143 AC_CACHE_VAL(ac_cv_c_tkconfig,[
145 # First check to see if --with-tkconfig was specified.
146 if test x"${with_tkconfig}" != x ; then
147 if test -f "${with_tkconfig}/tkConfig.sh" ; then
148 ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
150 AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
154 # then check for a private Tk library
155 if test x"${ac_cv_c_tkconfig}" = x ; then
158 `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
160 `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
162 `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
163 if test -f "$i/unix/tkConfig.sh" ; then
164 ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
167 if test -f "$i/win/tkConfig.sh" ; then
168 ac_cv_c_tkconfig=`(cd $i/win; pwd)`
173 # check in a few common install locations
174 if test x"${ac_cv_c_tkconfig}" = x ; then
175 for i in `ls -d ${prefix}/lib 2>/dev/null` \
176 `ls -d /usr/local/lib 2>/dev/null` ; do
177 if test -f "$i/tkConfig.sh" ; then
178 ac_cv_c_tkconfig=`(cd $i; pwd)`
183 # check in a few other private locations
184 if test x"${ac_cv_c_tkconfig}" = x ; then
187 `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
188 if test -f "$i/unix/tkConfig.sh" ; then
189 ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
192 if test -f "$i/win/tkConfig.sh" ; then
193 ac_cv_c_tkconfig=`(cd $i/win; pwd)`
199 if test x"${ac_cv_c_tkconfig}" = x ; then
200 TK_BIN_DIR="# no Tk configs found"
201 AC_MSG_ERROR(Can't find Tk configuration definitions)
205 TK_BIN_DIR=${ac_cv_c_tkconfig}
206 AC_MSG_RESULT(found $TK_BIN_DIR/tkConfig.sh)
212 #------------------------------------------------------------------------
213 # SC_LOAD_TCLCONFIG --
215 # Load the tclConfig.sh file
219 # Requires the following vars to be set:
224 # Subst the following vars:
229 #------------------------------------------------------------------------
231 AC_DEFUN(SC_LOAD_TCLCONFIG, [
232 AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
234 if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
235 AC_MSG_RESULT([loading])
236 . $TCL_BIN_DIR/tclConfig.sh
238 AC_MSG_RESULT([file not found])
242 # The eval is required to do the TCL_DBGX substitution in the
243 # TCL_LIB_FILE variable
246 eval TCL_LIB_FILE=${TCL_LIB_FILE}
247 eval TCL_LIB_FLAG=${TCL_LIB_FLAG}
250 AC_SUBST(TCL_BIN_DIR)
251 AC_SUBST(TCL_SRC_DIR)
252 AC_SUBST(TCL_LIB_FILE)
255 AC_SUBST(TCL_SHLIB_LD_LIBS)
256 AC_SUBST(TCL_EXTRA_CFLAGS)
257 AC_SUBST(TCL_LD_FLAGS)
258 AC_SUBST(TCL_LIB_FILE)
259 AC_SUBST(TCL_STUB_LIB_FILE)
260 AC_SUBST(TCL_LIB_SPEC)
261 AC_SUBST(TCL_BUILD_LIB_SPEC)
262 AC_SUBST(TCL_STUB_LIB_SPEC)
263 AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
266 #------------------------------------------------------------------------
267 # SC_LOAD_TKCONFIG --
269 # Load the tkConfig.sh file
273 # Requires the following vars to be set:
278 # Sets the following vars that should be in tkConfig.sh:
280 #------------------------------------------------------------------------
282 AC_DEFUN(SC_LOAD_TKCONFIG, [
283 AC_MSG_CHECKING([for existence of $TK_BIN_DIR/tkConfig.sh])
285 if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
286 AC_MSG_RESULT([loading])
287 . $TK_BIN_DIR/tkConfig.sh
289 AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
294 AC_SUBST(TK_LIB_FILE)
295 AC_SUBST(TK_XINCLUDES)
298 #------------------------------------------------------------------------
299 # SC_ENABLE_SHARED --
301 # Allows the building of shared libraries
308 # Adds the following arguments to configure:
309 # --enable-shared=yes|no
311 # Defines the following vars:
312 # STATIC_BUILD Used for building import/export libraries
315 # Sets the following vars:
316 # SHARED_BUILD Value of 1 or 0
317 #------------------------------------------------------------------------
319 AC_DEFUN(SC_ENABLE_SHARED, [
320 AC_MSG_CHECKING([how to build libraries])
321 AC_ARG_ENABLE(shared,
322 [ --enable-shared build and link with shared libraries [--enable-shared]],
323 [tcl_ok=$enableval], [tcl_ok=no])
327 *mingw32* | *windows32*)
328 # Default to shared build for Windows
329 if test "${enable_shared+set}" != set; then
336 if test "$tcl_ok" = "yes" ; then
337 AC_MSG_RESULT([shared])
340 AC_MSG_RESULT([static])
342 AC_DEFINE(STATIC_BUILD)
346 #------------------------------------------------------------------------
347 # SC_ENABLE_THREADS --
349 # Specify if thread support should be enabled
356 # Adds the following arguments to configure:
359 # Sets the following vars:
360 # THREADS_LIBS Thread library(s)
362 # Defines the following vars:
366 #------------------------------------------------------------------------
368 AC_DEFUN(SC_ENABLE_THREADS, [
369 AC_MSG_CHECKING(for building with threads)
370 AC_ARG_ENABLE(threads, [ --enable-threads build with threads],
371 [tcl_ok=$enableval], [tcl_ok=no])
373 if test "$tcl_ok" = "yes"; then
375 AC_DEFINE(TCL_THREADS)
376 AC_DEFINE(_REENTRANT)
379 *mingw32* | *windows32*)
383 AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
384 if test "$tcl_ok" = "yes"; then
385 # The space is needed
386 THREADS_LIBS=" -lpthread"
391 AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")
397 AC_MSG_RESULT(no (default))
402 #------------------------------------------------------------------------
403 # SC_ENABLE_SYMBOLS --
405 # Specify if debugging symbols should be used
410 # Requires the following vars to be set:
418 # Adds the following arguments to configure:
421 # Defines the following vars:
422 # CFLAGS_DEFAULT Sets to CFLAGS_DEBUG if true
423 # Sets to CFLAGS_OPTIMIZE if false
424 # LDFLAGS_DEFAULT Sets to LDFLAGS_DEBUG if true
425 # Sets to LDFLAGS_OPTIMIZE if false
426 # DBGX Debug library extension
428 #------------------------------------------------------------------------
430 AC_DEFUN(SC_ENABLE_SYMBOLS, [
432 *mingw32* | *windows32*)
440 AC_MSG_CHECKING([for build with symbols])
441 AC_ARG_ENABLE(symbols, [ --enable-symbols build with debugging symbols [--disable-symbols]], [tcl_ok=$enableval], [tcl_ok=no])
442 if test "$tcl_ok" = "yes"; then
443 CFLAGS_DEFAULT="${CFLAGS_DEBUG}"
444 LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}"
449 CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}"
450 LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}"
457 AC_SUBST(CFLAGS_DEFAULT)
458 AC_SUBST(LDFLAGS_DEFAULT)
461 #------------------------------------------------------------------------
464 # Generate a line that can be used to build a shared/unshared library
465 # in a platform independent manner.
474 # Defines the following vars:
475 # MAKE_LIB Makefile rule for building a library
476 # MAKE_SHARED_LIB Makefile rule for building a shared library
477 # MAKE_UNSHARED_LIB Makefile rule for building a static
479 #------------------------------------------------------------------------
481 AC_DEFUN(SC_MAKE_LIB, [
483 *mingw32* | *windows32*)
484 if test "${CC}" = "cl"; then
485 MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(\[$]@_OBJECTS) "
486 MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS} \$(LDFLAGS) -out:\[$]@ \$(\[$]@_OBJECTS) "
488 MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(\[$]@_OBJECTS) "
489 POST_MAKE_STATIC_LIB="\${RANLIB} \[$]@"
490 MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(\[$]@_OBJECTS) \${SHLIB_LDFLAGS} \$(LDFLAGS) \${SHLIB_LD_LIBS} -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\[$]@)"
494 MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(\[$]@_OBJECTS)"
495 POST_MAKE_STATIC_LIB="\${RANLIB} \[$]@"
496 MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(\[$]@_OBJECTS) \${SHLIB_LDFLAGS} \${SHLIB_LD_LIBS}"
500 if test "${SHARED_BUILD}" = "1" ; then
501 MAKE_LIB=${MAKE_SHARED_LIB}
503 MAKE_LIB=${MAKE_STATIC_LIB}
504 POST_MAKE_LIB=${POST_MAKE_STATIC_LIB}
508 AC_SUBST(MAKE_SHARED_LIB)
509 AC_SUBST(MAKE_STATIC_LIB)
510 AC_SUBST(POST_MAKE_LIB)
511 AC_SUBST(POST_MAKE_STATIC_LIB)
514 #------------------------------------------------------------------------
515 # SC_PRIVATE_TCL_HEADERS --
517 # Locate the private Tcl include files
522 # TCL_SRC_DIR Assumes that SC_LOAD_TCLCONFIG has
523 # already been called.
527 # Substs the following vars:
529 # TCL_GENERIC_DIR_NATIVE
530 # TCL_UNIX_DIR_NATIVE
532 # TCL_BMAP_DIR_NATIVE
533 # TCL_TOOL_DIR_NATIVE
534 # TCL_PLATFORM_DIR_NATIVE
537 #------------------------------------------------------------------------
539 AC_DEFUN(SC_PRIVATE_TCL_HEADERS, [
540 AC_MSG_CHECKING(for Tcl private include files)
543 *mingw32* | *windows32*)
544 TCL_TOP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}`\"
545 TCL_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/generic`\"
546 TCL_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/unix`\"
547 TCL_WIN_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/win`\"
548 TCL_BMAP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/bitmaps`\"
549 TCL_TOOL_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/tools`\"
550 TCL_COMPAT_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/compat`\"
551 TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
554 TCL_TOP_DIR_NATIVE='$(TCL_SRC_DIR)'
555 TCL_GENERIC_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/generic'
556 TCL_UNIX_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/unix'
557 TCL_WIN_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/win'
558 TCL_BMAP_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/bitmaps'
559 TCL_TOOL_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/tools'
560 TCL_COMPAT_DIR_NATIVE='$(TCL_TOP_DIR_NATIVE)/compat'
561 TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
565 AC_SUBST(TCL_TOP_DIR_NATIVE)
566 AC_SUBST(TCL_GENERIC_DIR_NATIVE)
567 AC_SUBST(TCL_UNIX_DIR_NATIVE)
568 AC_SUBST(TCL_WIN_DIR_NATIVE)
569 AC_SUBST(TCL_BMAP_DIR_NATIVE)
570 AC_SUBST(TCL_TOOL_DIR_NATIVE)
571 AC_SUBST(TCL_PLATFORM_DIR_NATIVE)
573 TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
574 AC_SUBST(TCL_INCLUDES)
575 AC_MSG_RESULT(Using srcdir found in tclConfig.sh: ${TCL_SRC_DIR})
578 #------------------------------------------------------------------------
579 # SC_PRIVATE_TK_HEADERS --
581 # Locate the private Tk include files
586 # TK_SRC_DIR Assumes that SC_LOAD_TKCONFIG has
587 # already been called.
591 # Substs the following vars:
593 #------------------------------------------------------------------------
595 AC_DEFUN(SC_PRIVATE_TK_HEADERS, [
596 AC_MSG_CHECKING(for Tk private include files)
599 *mingw32* | *windows32*)
600 TK_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/unix`\"
601 TK_WIN_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/win`\"
602 TK_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/generic`\"
603 TK_XLIB_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/xlib`\"
604 TK_PLATFORM_DIR_NATIVE=${TK_WIN_DIR_NATIVE}
606 TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE} -I${TK_XLIB_DIR_NATIVE}"
609 TK_GENERIC_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/generic'
610 TK_UNIX_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/unix'
611 TK_WIN_DIR_NATIVE='$(TK_TOP_DIR_NATIVE)/win'
612 TK_PLATFORM_DIR_NATIVE=${TK_UNIX_DIR_NATIVE}
614 TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
618 AC_SUBST(TK_UNIX_DIR_NATIVE)
619 AC_SUBST(TK_WIN_DIR_NATIVE)
620 AC_SUBST(TK_GENERIC_DIR_NATIVE)
621 AC_SUBST(TK_XLIB_DIR_NATIVE)
622 AC_SUBST(TK_PLATFORM_DIR_NATIVE)
624 AC_SUBST(TK_INCLUDES)
625 AC_MSG_RESULT(Using srcdir found in tkConfig.sh)