1 #------------------------------------------------------------------------
4 # Locate the tclConfig.sh file and perform a sanity check on
5 # the Tcl compile flags
6 # Currently a no-op for Windows
9 # PATCH_LEVEL The patch level for Tcl if any.
13 # Adds the following arguments to configure:
16 # Sets the following vars:
17 # TCL_BIN_DIR Full path to the tclConfig.sh file
18 #------------------------------------------------------------------------
20 AC_DEFUN(SC_PATH_TCLCONFIG, [
21 AC_MSG_CHECKING([the location of tclConfig.sh])
24 if test -d ../../tcl8.1/win; then
25 TCL_BIN_DIR_DEFAULT=../../tcl8.1/win
27 TCL_BIN_DIR_DEFAULT=../../tcl/win
31 AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.3 binaries from DIR],
32 TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DIR_DEFAULT; pwd`)
33 if test ! -d $TCL_BIN_DIR; then
34 AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
36 if test ! -f $TCL_BIN_DIR/tclConfig.sh; then
37 AC_MSG_ERROR(There is no tclConfig.sh in $TCL_BIN_DIR: perhaps you did not specify the Tcl *build* directory (not the toplevel Tcl directory) or you forgot to configure Tcl?)
39 AC_MSG_RESULT($TCL_BIN_DIR/tclConfig.sh)
42 #------------------------------------------------------------------------
45 # Locate the tkConfig.sh file
46 # Currently a no-op for Windows
53 # Adds the following arguments to configure:
56 # Sets the following vars:
57 # TK_BIN_DIR Full path to the tkConfig.sh file
58 #------------------------------------------------------------------------
60 AC_DEFUN(SC_PATH_TKCONFIG, [
61 AC_MSG_CHECKING([the location of tkConfig.sh])
63 if test -d ../../tk8.3$1/win; then
64 TK_BIN_DIR_DEFAULT=../../tk8.3$1/win
66 TK_BIN_DIR_DEFAULT=../../tk8.3/win
69 AC_ARG_WITH(tk, [ --with-tk=DIR use Tk 8.3 binaries from DIR],
70 TK_BIN_DIR=$withval, TK_BIN_DIR=`cd $TK_BIN_DIR_DEFAULT; pwd`)
71 if test ! -d $TK_BIN_DIR; then
72 AC_MSG_ERROR(Tk directory $TK_BIN_DIR does not exist)
74 if test ! -f $TK_BIN_DIR/tkConfig.sh; then
75 AC_MSG_ERROR(There is no tkConfig.sh in $TK_BIN_DIR: perhaps you did not specify the Tk *build* directory (not the toplevel Tk directory) or you forgot to configure Tk?)
78 AC_MSG_RESULT([$TK_BIN_DIR/tkConfig.sh])
81 #------------------------------------------------------------------------
82 # SC_LOAD_TCLCONFIG --
84 # Load the tclConfig.sh file
85 # Currently a no-op for Windows
89 # Requires the following vars to be set:
94 # Subst the following vars:
99 #------------------------------------------------------------------------
101 AC_DEFUN(SC_LOAD_TCLCONFIG, [
102 AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
104 if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
105 AC_MSG_RESULT([loading])
106 . $TCL_BIN_DIR/tclConfig.sh
108 AC_MSG_RESULT([file not found])
111 # The eval is required to do the TCL_DBGX substitution in the
112 # TCL_LIB_FILE variable.
114 eval TCL_LIB_FILE=${TCL_LIB_FILE}
115 eval TCL_LIB_FLAG=${TCL_LIB_FLAG}
117 AC_SUBST(TCL_BIN_DIR)
118 AC_SUBST(TCL_SRC_DIR)
119 AC_SUBST(TCL_LIB_FILE)
122 #------------------------------------------------------------------------
123 # SC_LOAD_TKCONFIG --
125 # Load the tkConfig.sh file
126 # Currently a no-op for Windows
130 # Requires the following vars to be set:
135 # Sets the following vars that should be in tkConfig.sh:
137 #------------------------------------------------------------------------
139 AC_DEFUN(SC_LOAD_TKCONFIG, [
140 AC_MSG_CHECKING([for existence of $TCLCONFIG])
142 if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
143 AC_MSG_CHECKING([loading $TK_BIN_DIR/tkConfig.sh])
144 . $TK_BIN_DIR/tkConfig.sh
146 AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
152 AC_SUBST(TK_LIB_FILE)
155 #------------------------------------------------------------------------
156 # SC_ENABLE_SHARED --
158 # Allows the building of shared libraries
165 # Adds the following arguments to configure:
166 # --enable-shared=yes|no
168 # Defines the following vars:
169 # STATIC_BUILD Used for building import/export libraries
172 # Sets the following vars:
173 # SHARED_BUILD Value of 1 or 0
174 #------------------------------------------------------------------------
176 AC_DEFUN(SC_ENABLE_SHARED, [
177 AC_MSG_CHECKING([how to build libraries])
178 AC_ARG_ENABLE(shared,
179 [ --enable-shared build and link with shared libraries [--enable-shared]],
180 [tcl_ok=$enableval], [tcl_ok=yes])
182 if test "${enable_shared+set}" = set; then
183 enableval="$enable_shared"
189 if test "$tcl_ok" = "yes" ; then
190 AC_MSG_RESULT([shared])
193 AC_MSG_RESULT([static])
195 AC_DEFINE(STATIC_BUILD)
199 #------------------------------------------------------------------------
200 # SC_ENABLE_THREADS --
202 # Specify if thread support should be enabled
209 # Adds the following arguments to configure:
210 # --enable-threads=yes|no
212 # Defines the following vars:
214 #------------------------------------------------------------------------
216 AC_DEFUN(SC_ENABLE_THREADS, [
217 AC_MSG_CHECKING(for building with threads)
218 AC_ARG_ENABLE(threads, [ --enable-threads build with threads],
219 [tcl_ok=$enableval], [tcl_ok=no])
221 if test "$tcl_ok" = "yes"; then
224 AC_DEFINE(TCL_THREADS)
227 AC_MSG_RESULT([no (default)])
231 #------------------------------------------------------------------------
232 # SC_ENABLE_SYMBOLS --
234 # Specify if debugging symbols should be used
239 # Requires the following vars to be set in the Makefile:
247 # Adds the following arguments to configure:
250 # Defines the following vars:
251 # CFLAGS_DEFAULT Set to $(CFLAGS_DEBUG) if true
252 # Set to $(CFLAGS_OPTIMIZE) if false
253 # LDFLAGS_DEFAULT Set to $(LDFLAGS_DEBUG) if true
254 # Set to $(LDFLAGS_OPTIMIZE) if false
255 # DBGX Debug library extension
257 #------------------------------------------------------------------------
259 AC_DEFUN(SC_ENABLE_SYMBOLS, [
260 AC_MSG_CHECKING([for build with symbols])
261 AC_ARG_ENABLE(symbols, [ --enable-symbols build with debugging symbols [--disable-symbols]], [tcl_ok=$enableval], [tcl_ok=no])
263 if test "$tcl_ok" = "yes"; then
264 CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
265 LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
269 CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
270 LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
277 #--------------------------------------------------------------------
280 # Try to determine the proper flags to pass to the compiler
281 # for building shared libraries and other such nonsense.
283 # NOTE: The backslashes in quotes below are substituted twice
284 # due to the fact that they are in a macro and then inlined
285 # in the final configure script.
292 # Can set the following vars:
323 #--------------------------------------------------------------------
325 AC_DEFUN(SC_CONFIG_CFLAGS, [
326 TCL_LIB_VERSIONS_OK=nodots
328 AC_CHECK_PROG(CYGPATH, cygpath, cygpath -w, echo)
330 # Check for a bug in gcc's windres that causes the
331 # compile to fail when a Windows native path is
332 # passed into windres. The mingw toolchain requires
333 # Windows native paths while Cygwin should work
334 # with both. Avoid the bug by passing a POSIX
335 # path when using the Cygwin toolchain.
337 if test "$GCC" = "yes" && test "$CYGPATH" != "echo" ; then
338 conftest=/tmp/conftest.rc
339 echo "STRINGTABLE BEGIN" > $conftest
340 echo "101 \"name\"" >> $conftest
341 echo "END" >> $conftest
343 AC_MSG_CHECKING([for Windows native path bug in windres])
344 cyg_conftest=`$CYGPATH $conftest`
345 if AC_TRY_COMMAND($RC -o conftest.res.o $cyg_conftest) ; then
355 if test "$CYGPATH" = "echo" || test "$ac_cv_cygwin" = "yes"; then
358 DEPARG='"$(shell $(CYGPATH) $<)"'
365 # set various compiler flags depending on whether we are using gcc or cl
367 AC_MSG_CHECKING([compiler flags])
368 if test "${GCC}" = "yes" ; then
371 if test "$ac_cv_cygwin" = "yes" ; then
379 LIBS_GUI="-lgdi32 -lcomdlg32"
385 MAKE_LIB="\${STLIB_LD} \[$]@"
386 POST_MAKE_LIB="\${RANLIB} \[$]@"
387 MAKE_EXE="\${CC} -o \[$]@"
388 LIBPREFIX="lib${VENDORPREFIX}"
390 if test "${SHARED_BUILD}" = "0" ; then
392 AC_MSG_RESULT([using static flags])
395 LIBSUFFIX="s\${DBGX}.a"
396 LIBRARIES="\${STATIC_LIBRARIES}"
397 EXESUFFIX="s\${DBGX}.exe"
401 AC_MSG_RESULT([using shared flags])
403 # ad-hoc check to see if CC supports -shared.
404 if "${CC}" -shared 2>&1 | egrep ': -shared not supported' >/dev/null; then
405 AC_MSG_ERROR([${CC} does not support the -shared option.
406 You will need to upgrade to a newer version of the toolchain.])
410 # Link with gcc since ld does not link to default libs like
411 # -luser32 and -lmsvcrt. We also need to add CFLAGS so important
412 # flags like -mno-cygwin get passed in to CC.
413 SHLIB_LD='${CC} -shared ${CFLAGS}'
414 # Add SHLIB_LD_LIBS to the Make rule, not here.
415 MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \[$]@ ${extra_ldflags} \
416 -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\[$]@)"
417 TCL_DLL_BASE="-Wl,--image-base=0x66000000"
418 DDE_DLL_BASE="-Wl,--image-base=0x66100000"
419 REG_DLL_BASE="-Wl,--image-base=0x66200000"
421 LIBSUFFIX="\${DBGX}.a"
422 DLLSUFFIX="\${DBGX}.dll"
423 EXESUFFIX="\${DBGX}.exe"
424 LIBRARIES="\${SHARED_LIBRARIES}"
429 CFLAGS_WARNING="-Wall -Wconversion"
433 # Specify the CC output file names based on the target name
434 CC_OBJNAME="-o \[$]@"
435 CC_EXENAME="-o \[$]@"
437 # Specify linker flags depending on the type of app being
438 # built -- Console vs. Window.
439 LDFLAGS_CONSOLE="-mconsole ${extra_ldflags}"
440 LDFLAGS_WINDOW="-mwindows ${extra_ldflags}"
442 SHLIB_LD="link -dll -nologo"
443 SHLIB_LD_LIBS="user32.lib advapi32.lib"
444 LIBS="user32.lib advapi32.lib"
445 LIBS_GUI="gdi32.lib comdlg32.lib"
446 STLIB_LD="lib -nologo"
452 MAKE_LIB="\${STLIB_LD} -out:\[$]@"
454 MAKE_EXE="\${CC} -Fe\[$]@"
455 LIBPREFIX=${VENDORPREFIX}
457 if test "${SHARED_BUILD}" = "0" ; then
459 AC_MSG_RESULT([using static flags])
462 LIBSUFFIX="s\${DBGX}.lib"
463 LIBRARIES="\${STATIC_LIBRARIES}"
464 EXESUFFIX="s\${DBGX}.exe"
468 AC_MSG_RESULT([using shared flags])
470 # Add SHLIB_LD_LIBS to the Make rule, not here.
471 MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -out:\[$]@"
472 LIBSUFFIX="\${DBGX}.lib"
473 DLLSUFFIX="\${DBGX}.dll"
474 EXESUFFIX="\${DBGX}.exe"
475 LIBRARIES="\${SHARED_LIBRARIES}"
479 CFLAGS_DEBUG="-nologo -Z7 -Od -WX ${runtime}d"
480 # CFLAGS_OPTIMIZE="-nologo -O2 -Gs -GD ${runtime}"
481 CFLAGS_OPTIMIZE="-nologo -Oti -Gs -GD ${runtime}"
483 LDFLAGS_DEBUG="-debug:full -debugtype:cv"
484 LDFLAGS_OPTIMIZE="-release"
486 # Specify the CC output file names based on the target name
487 CC_OBJNAME="-Fo\[$]@"
488 CC_EXENAME="-Fe\"\$(shell \$(CYGPATH) '\[$]@')\""
490 # Specify linker flags depending on the type of app being
491 # built -- Console vs. Window.
492 LDFLAGS_CONSOLE="-link -subsystem:console"
493 LDFLAGS_WINDOW="-link -subsystem:windows"
496 # Define the same variables as used in tclConfig.sh so that macros
497 # that depend on these variables work for both Tcl and extensions.
498 TCL_LIB_SUFFIX=$LIBSUFFIX
499 TCL_VENDOR_PREFIX=$VENDORPREFIX
502 #------------------------------------------------------------------------
505 # Location of the Tcl build directory.
512 # Adds the following arguments to configure:
515 # Defines the following vars:
516 # TCL_BIN_DIR Full path to the tcl build dir.
517 #------------------------------------------------------------------------
519 AC_DEFUN(SC_WITH_TCL, [
520 if test -d ../../tcl8.3$1/win; then
521 TCL_BIN_DEFAULT=../../tcl8.3$1/win
523 TCL_BIN_DEFAULT=../../tcl8.3/win
526 AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.3 binaries from DIR],
527 TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DEFAULT; pwd`)
528 if test ! -d $TCL_BIN_DIR; then
529 AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
531 if test ! -f $TCL_BIN_DIR/Makefile; then
532 AC_MSG_ERROR(There is no Makefile in $TCL_BIN_DIR: perhaps you did not specify the Tcl *build* directory (not the toplevel Tcl directory) or you forgot to configure Tcl?)
534 echo "building against Tcl binaries in: $TCL_BIN_DIR"
536 AC_SUBST(TCL_BIN_DIR)
539 #--------------------------------------------------------------------
542 # Checks how the system deals with time.h, what time structures
543 # are used on the system, and what fields the structures have.
550 # Defines some of the following vars:
556 #--------------------------------------------------------------------
558 AC_DEFUN(SC_TIME_HANDLER, [
559 AC_CHECK_HEADERS(sys/time.h)
563 AC_MSG_CHECKING([tm_tzadj in struct tm])
564 AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
565 [AC_DEFINE(HAVE_TM_TZADJ)
569 AC_MSG_CHECKING([tm_gmtoff in struct tm])
570 AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
571 [AC_DEFINE(HAVE_TM_GMTOFF)
576 # Its important to include time.h in this check, as some systems
577 # (like convex) have timezone functions, etc.
580 AC_MSG_CHECKING([long timezone variable])
581 AC_TRY_COMPILE([#include <time.h>],
582 [extern long timezone;
586 AC_DEFINE(HAVE_TIMEZONE_VAR)
591 # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
593 if test "$have_timezone" = no; then
594 AC_MSG_CHECKING([time_t timezone variable])
595 AC_TRY_COMPILE([#include <time.h>],
596 [extern time_t timezone;
599 [AC_DEFINE(HAVE_TIMEZONE_VAR)
605 # On some systems (eg Solaris 2.5.1), timezone is not declared in
606 # time.h unless you jump through hoops. Instead of that, we just
607 # declare it ourselves when necessary.
609 if test "$have_timezone" = yes; then
610 AC_MSG_CHECKING(for timezone declaration)
612 tzrx='^[ ]*extern.*timezone'
614 AC_EGREP_HEADER($tzrx, time.h, [
615 AC_DEFINE(HAVE_TIMEZONE_DECL)
616 AC_MSG_RESULT(found)], AC_MSG_RESULT(missing))
620 # AIX does not have a timezone field in struct tm. When the AIX bsd
621 # library is used, the timezone global and the gettimeofday methods are
622 # to be avoided for timezone deduction instead, we deduce the timezone
623 # by comparing the localtime result on a known GMT value.
626 if test "`uname -s`" = "AIX" ; then
627 AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes)
628 if test $libbsd = yes; then
629 AC_DEFINE(USE_DELTA_FOR_TZ)