1 #------------------------------------------------------------------------
4 # Locate the tclConfig.sh file and perform a sanity check on
5 # the Tcl compile flags
12 # Adds the following arguments to configure:
15 # Defines the following vars:
16 # TCL_BIN_DIR Full path to the directory containing
17 # the tclConfig.sh file
18 #------------------------------------------------------------------------
20 AC_DEFUN([SC_PATH_TCLCONFIG], [
22 # Ok, lets find the tcl configuration
23 # First, look for one uninstalled.
24 # the alternative search directory is invoked by --with-tcl
27 if test x"${no_tcl}" = x ; then
28 # we reset no_tcl in case something fails here
31 AS_HELP_STRING([--with-tcl],
32 [directory containing tcl configuration (tclConfig.sh)]),
33 with_tclconfig="${withval}")
34 AC_MSG_CHECKING([for Tcl configuration])
35 AC_CACHE_VAL(ac_cv_c_tclconfig,[
37 # First check to see if --with-tcl was specified.
38 if test x"${with_tclconfig}" != x ; then
39 case "${with_tclconfig}" in
41 if test -f "${with_tclconfig}"; then
42 AC_MSG_WARN([--with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself])
43 with_tclconfig="`echo "${with_tclconfig}" | sed 's!/tclConfig\.sh$!!'`"
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]].[[0-9]]* 2>/dev/null` \
58 `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]].[[0-9]]* 2>/dev/null` \
62 `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
63 `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
65 `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
66 `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
67 `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
68 if test -f "$i/win/tclConfig.sh" ; then
69 ac_cv_c_tclconfig="`(cd $i/win; pwd)`"
75 # check in a few common install locations
76 if test x"${ac_cv_c_tclconfig}" = x ; then
77 for i in `ls -d ${libdir} 2>/dev/null` \
78 `ls -d ${exec_prefix}/lib 2>/dev/null` \
79 `ls -d ${prefix}/lib 2>/dev/null` \
80 `ls -d /cygdrive/c/Tcl/lib 2>/dev/null` \
81 `ls -d /cygdrive/c/Progra~1/Tcl/lib 2>/dev/null` \
82 `ls -d /c/Tcl/lib 2>/dev/null` \
83 `ls -d /c/Progra~1/Tcl/lib 2>/dev/null` \
84 `ls -d C:/Tcl/lib 2>/dev/null` \
85 `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
87 if test -f "$i/tclConfig.sh" ; then
88 ac_cv_c_tclconfig="`(cd $i; pwd)`"
94 # check in a few other private locations
95 if test x"${ac_cv_c_tclconfig}" = x ; then
98 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
99 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
100 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
101 if test -f "$i/win/tclConfig.sh" ; then
102 ac_cv_c_tclconfig="`(cd $i/win; pwd)`"
109 if test x"${ac_cv_c_tclconfig}" = x ; then
110 TCL_BIN_DIR="# no Tcl configs found"
111 AC_MSG_ERROR([Can't find Tcl configuration definitions. Use --with-tcl to specify a directory containing tclConfig.sh])
114 TCL_BIN_DIR="${ac_cv_c_tclconfig}"
115 AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
120 #------------------------------------------------------------------------
121 # SC_PATH_TKCONFIG --
123 # Locate the tkConfig.sh file
130 # Adds the following arguments to configure:
133 # Defines the following vars:
134 # TK_BIN_DIR Full path to the directory containing
135 # the tkConfig.sh file
136 #------------------------------------------------------------------------
138 AC_DEFUN([SC_PATH_TKCONFIG], [
140 # Ok, lets find the tk configuration
141 # First, look for one uninstalled.
142 # the alternative search directory is invoked by --with-tk
145 if test x"${no_tk}" = x ; then
146 # we reset no_tk in case something fails here
149 AS_HELP_STRING([--with-tk],
150 [directory containing tk configuration (tkConfig.sh)]),
151 with_tkconfig="${withval}")
152 AC_MSG_CHECKING([for Tk configuration])
153 AC_CACHE_VAL(ac_cv_c_tkconfig,[
155 # First check to see if --with-tkconfig was specified.
156 if test x"${with_tkconfig}" != x ; then
157 case "${with_tkconfig}" in
159 if test -f "${with_tkconfig}"; then
160 AC_MSG_WARN([--with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself])
161 with_tkconfig="`echo "${with_tkconfig}" | sed 's!/tkConfig\.sh$!!'`"
164 if test -f "${with_tkconfig}/tkConfig.sh" ; then
165 ac_cv_c_tkconfig="`(cd "${with_tkconfig}"; pwd)`"
167 AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
171 # then check for a private Tk library
172 if test x"${ac_cv_c_tkconfig}" = x ; then
175 `ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
176 `ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
177 `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
179 `ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
180 `ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
181 `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
183 `ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
184 `ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
185 `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
186 if test -f "$i/win/tkConfig.sh" ; then
187 ac_cv_c_tkconfig="`(cd $i/win; pwd)`"
193 # check in a few common install locations
194 if test x"${ac_cv_c_tkconfig}" = x ; then
195 for i in `ls -d ${libdir} 2>/dev/null` \
196 `ls -d ${exec_prefix}/lib 2>/dev/null` \
197 `ls -d ${prefix}/lib 2>/dev/null` \
198 `ls -d /cygdrive/c/Tcl/lib 2>/dev/null` \
199 `ls -d /cygdrive/c/Progra~1/Tcl/lib 2>/dev/null` \
200 `ls -d /c/Tcl/lib 2>/dev/null` \
201 `ls -d /c/Progra~1/Tcl/lib 2>/dev/null` \
202 `ls -d C:/Tcl/lib 2>/dev/null` \
203 `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
205 if test -f "$i/tkConfig.sh" ; then
206 ac_cv_c_tkconfig="`(cd $i; pwd)`"
212 # check in a few other private locations
213 if test x"${ac_cv_c_tkconfig}" = x ; then
216 `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
217 `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
218 `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
219 if test -f "$i/win/tkConfig.sh" ; then
220 ac_cv_c_tkconfig="`(cd $i/win; pwd)`"
227 if test x"${ac_cv_c_tkconfig}" = x ; then
228 TK_BIN_DIR="# no Tk configs found"
229 AC_MSG_ERROR([Can't find Tk configuration definitions. Use --with-tk to specify a directory containing tkConfig.sh])
232 TK_BIN_DIR="${ac_cv_c_tkconfig}"
233 AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
238 #------------------------------------------------------------------------
239 # SC_LOAD_TCLCONFIG --
241 # Load the tclConfig.sh file.
245 # Requires the following vars to be set:
250 # Substitutes the following vars:
255 #------------------------------------------------------------------------
257 AC_DEFUN([SC_LOAD_TCLCONFIG], [
258 AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
260 if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
261 AC_MSG_RESULT([loading])
262 . "${TCL_BIN_DIR}/tclConfig.sh"
264 AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
268 # If the TCL_BIN_DIR is the build directory (not the install directory),
269 # then set the common variable name to the value of the build variables.
270 # For example, the variable TCL_LIB_SPEC will be set to the value
271 # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
272 # instead of TCL_BUILD_LIB_SPEC since it will work with both an
273 # installed and uninstalled version of Tcl.
276 if test -f $TCL_BIN_DIR/Makefile ; then
277 TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
278 TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
279 TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
283 # eval is required to do the TCL_DBGX substitution
286 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
287 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
288 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
290 eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
291 eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
292 eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
294 AC_SUBST(TCL_VERSION)
295 AC_SUBST(TCL_BIN_DIR)
296 AC_SUBST(TCL_SRC_DIR)
298 AC_SUBST(TCL_LIB_FILE)
299 AC_SUBST(TCL_LIB_FLAG)
300 AC_SUBST(TCL_LIB_SPEC)
302 AC_SUBST(TCL_STUB_LIB_FILE)
303 AC_SUBST(TCL_STUB_LIB_FLAG)
304 AC_SUBST(TCL_STUB_LIB_SPEC)
309 #------------------------------------------------------------------------
310 # SC_LOAD_TKCONFIG --
312 # Load the tkConfig.sh file
316 # Requires the following vars to be set:
321 # Sets the following vars that should be in tkConfig.sh:
323 #------------------------------------------------------------------------
325 AC_DEFUN([SC_LOAD_TKCONFIG], [
326 AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
328 if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
329 AC_MSG_RESULT([loading])
330 . "${TK_BIN_DIR}/tkConfig.sh"
332 AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
338 AC_SUBST(TK_LIB_FILE)
341 #------------------------------------------------------------------------
342 # SC_ENABLE_SHARED --
344 # Allows the building of shared libraries
351 # Adds the following arguments to configure:
352 # --enable-shared=yes|no
354 # Defines the following vars:
355 # STATIC_BUILD Used for building import/export libraries
358 # Sets the following vars:
359 # SHARED_BUILD Value of 1 or 0
360 #------------------------------------------------------------------------
362 AC_DEFUN([SC_ENABLE_SHARED], [
363 AC_MSG_CHECKING([how to build libraries])
364 AC_ARG_ENABLE(shared,
365 [ --enable-shared build and link with shared libraries (default: on)],
366 [tcl_ok=$enableval], [tcl_ok=yes])
367 if test "$tcl_ok" = "yes" ; then
368 AC_MSG_RESULT([shared])
371 AC_MSG_RESULT([static])
373 AC_DEFINE(STATIC_BUILD, 1, [Is this a static build?])
377 #------------------------------------------------------------------------
378 # SC_ENABLE_THREADS --
380 # Specify if thread support should be enabled
387 # Adds the following arguments to configure:
388 # --enable-threads=yes|no
390 # Defines the following vars:
392 #------------------------------------------------------------------------
394 AC_DEFUN([SC_ENABLE_THREADS], [
395 AC_MSG_CHECKING(for building with threads)
396 AC_ARG_ENABLE(threads, [ --enable-threads build with threads (default: on)],
397 [tcl_ok=$enableval], [tcl_ok=yes])
399 if test "$tcl_ok" = "yes"; then
400 AC_MSG_RESULT([yes (default)])
402 AC_DEFINE(TCL_THREADS)
403 # USE_THREAD_ALLOC tells us to try the special thread-based
404 # allocator that significantly reduces lock contention
405 AC_DEFINE(USE_THREAD_ALLOC)
410 AC_SUBST(TCL_THREADS)
413 #------------------------------------------------------------------------
414 # SC_ENABLE_SYMBOLS --
416 # Specify if debugging symbols should be used.
417 # Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
418 # can also be enabled.
423 # Requires the following vars to be set in the Makefile:
429 # Adds the following arguments to configure:
432 # Defines the following vars:
433 # CFLAGS_DEFAULT Sets to $(CFLAGS_DEBUG) if true
434 # Sets to $(CFLAGS_OPTIMIZE) if false
435 # LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
436 # Sets to $(LDFLAGS_OPTIMIZE) if false
437 # DBGX Debug library extension
439 #------------------------------------------------------------------------
441 AC_DEFUN([SC_ENABLE_SYMBOLS], [
442 AC_MSG_CHECKING([for build with symbols])
443 AC_ARG_ENABLE(symbols, [ --enable-symbols build with debugging symbols (default: off)], [tcl_ok=$enableval], [tcl_ok=no])
444 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
445 if test "$tcl_ok" = "no"; then
446 CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
447 LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
449 AC_DEFINE(NDEBUG, 1, [Is no debugging enabled?])
452 AC_DEFINE(TCL_CFG_OPTIMIZED)
454 CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
455 LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
457 if test "$tcl_ok" = "yes"; then
458 AC_MSG_RESULT([yes (standard debugging)])
461 AC_SUBST(CFLAGS_DEFAULT)
462 AC_SUBST(LDFLAGS_DEFAULT)
464 if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
465 AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?])
468 if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
469 AC_DEFINE(TCL_COMPILE_DEBUG, 1, [Is bytecode debugging enabled?])
470 AC_DEFINE(TCL_COMPILE_STATS, 1, [Are bytecode statistics enabled?])
473 if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
474 if test "$tcl_ok" = "all"; then
475 AC_MSG_RESULT([enabled symbols mem compile debugging])
477 AC_MSG_RESULT([enabled $tcl_ok debugging])
482 #--------------------------------------------------------------------
485 # Try to determine the proper flags to pass to the compiler
486 # for building shared libraries and other such nonsense.
488 # NOTE: The backslashes in quotes below are substituted twice
489 # due to the fact that they are in a macro and then inlined
490 # in the final configure script.
497 # Can the following vars:
530 #--------------------------------------------------------------------
532 AC_DEFUN([SC_CONFIG_CFLAGS], [
534 # Step 0: Enable 64 bit support?
536 AC_MSG_CHECKING([if 64bit support is requested])
537 AC_ARG_ENABLE(64bit,[ --enable-64bit enable 64bit support (where applicable)], [do64bit=$enableval], [do64bit=no])
538 AC_MSG_RESULT($do64bit)
540 # Cross-compiling options for Windows/CE builds
542 AC_MSG_CHECKING([if Windows/CE build is requested])
543 AC_ARG_ENABLE(wince,[ --enable-wince enable Win/CE support (where applicable)], [doWince=$enableval], [doWince=no])
544 AC_MSG_RESULT($doWince)
546 AC_MSG_CHECKING([for Windows/CE celib directory])
547 AC_ARG_WITH(celib,[ --with-celib=DIR use Windows/CE support library from DIR],
548 CELIB_DIR=$withval, CELIB_DIR=NO_CELIB)
549 AC_MSG_RESULT([$CELIB_DIR])
551 # Set some defaults (may get changed below)
553 AC_DEFINE(MODULE_SCOPE, [extern], [No need to mark inidividual symbols as hidden])
555 AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo)
559 # MACHINE is IX86 for LINK, but this is used by the manifest,
560 # which requires x86|amd64|ia64.
563 if test "$GCC" = "yes"; then
565 AC_CACHE_CHECK(for cross-compile version of gcc,
567 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
569 #error cross-compiler
576 if test "$ac_cv_cross" = "yes"; then
579 CC="x86_64-w64-mingw32-${CC}"
580 LD="x86_64-w64-mingw32-ld"
581 AR="x86_64-w64-mingw32-ar"
582 RANLIB="x86_64-w64-mingw32-ranlib"
583 RC="x86_64-w64-mingw32-windres"
586 CC="i686-w64-mingw32-${CC}"
587 LD="i686-w64-mingw32-ld"
588 AR="i686-w64-mingw32-ar"
589 RANLIB="i686-w64-mingw32-ranlib"
590 RC="i686-w64-mingw32-windres"
596 # Check for a bug in gcc's windres that causes the
597 # compile to fail when a Windows native path is
598 # passed into windres. The mingw toolchain requires
599 # Windows native paths while Cygwin should work
600 # with both. Avoid the bug by passing a POSIX
601 # path when using the Cygwin toolchain.
603 if test "$GCC" = "yes" && test "$CYGPATH" != "echo" ; then
604 conftest=/tmp/conftest.rc
605 echo "STRINGTABLE BEGIN" > $conftest
606 echo "101 \"name\"" >> $conftest
607 echo "END" >> $conftest
609 AC_MSG_CHECKING([for Windows native path bug in windres])
610 cyg_conftest=`$CYGPATH $conftest`
611 if AC_TRY_COMMAND($RC -o conftest.res.o $cyg_conftest) ; then
621 if test "$CYGPATH" = "echo"; then
624 DEPARG='"$(shell $(CYGPATH) $<)"'
627 # set various compiler flags depending on whether we are using gcc or cl
629 if test "${GCC}" = "yes" ; then
631 extra_ldflags="-pipe -static-libgcc"
632 AC_CACHE_CHECK(for mingw32 version of gcc,
634 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
642 if test "$ac_cv_win32" != "yes"; then
643 AC_MSG_ERROR([${CC} cannot produce win32 executables.])
646 hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -mwindows -municode -Dmain=xxmain"
647 AC_CACHE_CHECK(for working -municode linker flag,
649 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
651 int APIENTRY wWinMain(HINSTANCE a, HINSTANCE b, LPWSTR c, int d) {return 0;}
653 [ac_cv_municode=yes],
657 if test "$ac_cv_municode" = "yes" ; then
658 extra_ldflags="$extra_ldflags -municode"
660 extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
662 AC_CACHE_CHECK(for working -fno-lto,
664 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
669 if test "$ac_cv_nolto" = "yes" ; then
670 CFLAGS_NOLTO="-fno-lto"
676 AC_MSG_CHECKING([compiler flags])
677 if test "${GCC}" = "yes" ; then
679 SHLIB_LD_LIBS='${LIBS}'
680 LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32"
681 # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
682 LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32"
689 MAKE_LIB="\${STLIB_LD} \[$]@"
690 MAKE_STUB_LIB="\${STLIB_LD} \[$]@"
691 POST_MAKE_LIB="\${RANLIB} \[$]@"
692 MAKE_EXE="\${CC} -o \[$]@"
695 if test "${SHARED_BUILD}" = "0" ; then
697 AC_MSG_RESULT([using static flags])
699 LIBRARIES="\${STATIC_LIBRARIES}"
700 EXESUFFIX="s\${DBGX}.exe"
703 AC_MSG_RESULT([using shared flags])
705 # ad-hoc check to see if CC supports -shared.
706 if "${CC}" -shared 2>&1 | egrep ': -shared not supported' >/dev/null; then
707 AC_MSG_ERROR([${CC} does not support the -shared option.
708 You will need to upgrade to a newer version of the toolchain.])
712 # Add SHLIB_LD_LIBS to the Make rule, not here.
714 EXESUFFIX="\${DBGX}.exe"
715 LIBRARIES="\${SHARED_LIBRARIES}"
717 # Link with gcc since ld does not link to default libs like
718 # -luser32 and -lmsvcrt by default.
719 SHLIB_LD='${CC} -shared'
720 SHLIB_LD_LIBS='${LIBS}'
721 MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \[$]@ ${extra_ldflags} \
722 -Wl,--out-implib,\$(patsubst %.dll,lib%.dll.a,\[$]@)"
723 # DLLSUFFIX is separate because it is the building block for
724 # users of tclConfig.sh that may build shared or static.
725 DLLSUFFIX="\${DBGX}.dll"
726 LIBSUFFIX="\${DBGX}.a"
727 LIBFLAGSUFFIX="\${DBGX}"
730 EXTRA_CFLAGS="${extra_cflags}"
733 CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
734 CFLAGS_WARNING="-Wall -Wpointer-arith"
740 CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
743 CFLAGS_WARNING="${CFLAGS_WARNING} -Wdeclaration-after-statement"
747 # Specify the CC output file names based on the target name
748 CC_OBJNAME="-o \[$]@"
749 CC_EXENAME="-o \[$]@"
751 # Specify linker flags depending on the type of app being
752 # built -- Console vs. Window.
755 # We need to pass -e _WinMain@16 so that ld will use
756 # WinMain() instead of main() as the entry point. We can't
757 # use autoconf to check for this case since it would need
758 # to run an executable and that does not work when
759 # cross compiling. Remove this -e workaround once we
760 # require a gcc that does not have this bug.
762 # MK NOTE: Tk should use a different mechanism. This causes
763 # interesting problems, such as wish dying at startup.
764 #LDFLAGS_WINDOW="-mwindows -e _WinMain@16 ${extra_ldflags}"
765 LDFLAGS_CONSOLE="-mconsole ${extra_ldflags}"
766 LDFLAGS_WINDOW="-mwindows ${extra_ldflags}"
770 MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
771 AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
775 AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
778 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
786 if test "$tcl_win_64bit" = "yes" ; then
789 AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
794 if test "${SHARED_BUILD}" = "0" ; then
796 AC_MSG_RESULT([using static flags])
798 LIBRARIES="\${STATIC_LIBRARIES}"
799 EXESUFFIX="s\${DBGX}.exe"
802 AC_MSG_RESULT([using shared flags])
804 # Add SHLIB_LD_LIBS to the Make rule, not here.
805 LIBRARIES="\${SHARED_LIBRARIES}"
806 EXESUFFIX="\${DBGX}.exe"
807 case "x`echo \${VisualStudioVersion}`" in
809 lflags="${lflags} -nodefaultlib:libucrt.lib"
815 MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -out:\[$]@"
816 # DLLSUFFIX is separate because it is the building block for
817 # users of tclConfig.sh that may build shared or static.
818 DLLSUFFIX="\${DBGX}.dll"
819 LIBSUFFIX="\${DBGX}.lib"
820 LIBFLAGSUFFIX="\${DBGX}"
822 if test "$do64bit" != "no" ; then
825 MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
831 AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
834 LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib"
836 case "x`echo \${VisualStudioVersion}`" in
838 LIBS="$LIBS ucrt.lib"
844 if test "$do64bit" != "no" ; then
846 CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
847 # Do not use -O2 for Win64 - this has proved buggy in code gen.
848 CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
849 lflags="${lflags} -nologo -MACHINE:${MACHINE}"
851 # Avoid 'unresolved external symbol __security_cookie' errors.
852 # c.f. http://support.microsoft.com/?id=894573
853 LIBS="$LIBS bufferoverflowU.lib"
856 # -Od - no optimization
857 # -WX - warnings as errors
858 CFLAGS_DEBUG="-nologo -Z7 -Od -WX ${runtime}d"
859 # -O2 - create fast code (/Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy)
860 CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
861 lflags="${lflags} -nologo"
865 if test "$doWince" != "no" ; then
866 # Set defaults for common evc4/PPC2003 setup
867 # Currently Tcl requires 300+, possibly 420+ for sockets
868 CEVERSION=420; # could be 211 300 301 400 420 ...
869 TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ...
870 ARCH=ARM; # could be ARM MIPS X86EM ...
871 PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002"
872 if test "$doWince" != "yes"; then
873 # If !yes then the user specified something
874 # Reset ARCH to allow user to skip specifying it
876 eval `echo $doWince | awk -F "," '{ \
877 if (length([$]1)) { printf "CEVERSION=\"%s\"\n", [$]1; \
878 if ([$]1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \
879 if (length([$]2)) { printf "TARGETCPU=\"%s\"\n", toupper([$]2) }; \
880 if (length([$]3)) { printf "ARCH=\"%s\"\n", toupper([$]3) }; \
881 if (length([$]4)) { printf "PLATFORM=\"%s\"\n", [$]4 }; \
883 if test "x${ARCH}" = "x" ; then
887 OSVERSION=WCE$CEVERSION;
888 if test "x${WCEROOT}" = "x" ; then
889 WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0"
890 if test ! -d "${WCEROOT}" ; then
891 WCEROOT="C:/Program Files/Microsoft eMbedded Tools"
894 if test "x${SDKROOT}" = "x" ; then
895 SDKROOT="C:/Program Files/Windows CE Tools"
896 if test ! -d "${SDKROOT}" ; then
897 SDKROOT="C:/Windows CE Tools"
900 # The space-based-path will work for the Makefile, but will
901 # not work if AC_TRY_COMPILE is called.
902 WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'`
903 SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'`
904 CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'`
905 if test ! -d "${CELIB_DIR}/inc"; then
906 AC_MSG_ERROR([Invalid celib directory "${CELIB_DIR}"])
908 if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"\
909 -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
910 AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]])
912 CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include"
913 if test -d "${CEINCLUDE}/${TARGETCPU}" ; then
914 CEINCLUDE="${CEINCLUDE}/${TARGETCPU}"
916 CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"
920 if test "$doWince" != "no" ; then
921 CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin"
922 if test "${TARGETCPU}" = "X86"; then
923 CC="${CEBINROOT}/cl.exe"
925 CC="${CEBINROOT}/cl${ARCH}.exe"
927 CC="\"${CC}\" -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
928 RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
929 arch=`echo ${ARCH} | awk '{print tolower([$]0)}'`
930 defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _DLL _WINDOWS"
932 AC_DEFINE_UNQUOTED($i)
934 # if test "${ARCH}" = "X86EM"; then
935 # AC_DEFINE_UNQUOTED(_WIN32_WCE_EMULATION)
937 AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION)
938 AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION)
939 CFLAGS_DEBUG="-nologo -Zi -Od"
940 CFLAGS_OPTIMIZE="-nologo -O2"
941 lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'`
942 lflags="-nodefaultlib -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo"
943 LINKBIN="\"${CEBINROOT}/link.exe\""
945 if test "${CEVERSION}" -lt 400 ; then
946 LIBS="coredll.lib corelibc.lib winsock.lib"
948 LIBS="coredll.lib corelibc.lib ws2.lib"
950 # celib currently stuck at wce300 status
951 #LIBS="$LIBS \${CELIB_DIR}/wince-${ARCH}-pocket-${OSVERSION}-release/celib.lib"
952 LIBS="$LIBS \"\${CELIB_DIR}/wince-${ARCH}-pocket-wce300-release/celib.lib\""
953 LIBS_GUI="commctrl.lib commdlg.lib"
955 LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib"
958 SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}"
959 SHLIB_LD_LIBS='${LIBS}'
960 # link -lib only works when -lib is the first arg
961 STLIB_LD="${LINKBIN} -lib ${lflags}"
967 MAKE_LIB="\${STLIB_LD} -out:\[$]@"
968 MAKE_STUB_LIB="\${STLIB_LD} -nodefaultlib -out:\[$]@"
970 MAKE_EXE="\${CC} -Fe\[$]@"
973 CFLAGS_DEBUG="${CFLAGS_DEBUG} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE"
974 CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE"
978 LDFLAGS_DEBUG="-debug"
979 LDFLAGS_OPTIMIZE="-release"
981 # Specify the CC output file names based on the target name
982 CC_OBJNAME="-Fo\[$]@"
983 CC_EXENAME="-Fe\"\$(shell \$(CYGPATH) '\[$]@')\""
985 # Specify linker flags depending on the type of app being
986 # built -- Console vs. Window.
987 if test "$doWince" != "no" -a "${TARGETCPU}" != "X86"; then
988 LDFLAGS_CONSOLE="-link ${lflags}"
989 LDFLAGS_WINDOW=${LDFLAGS_CONSOLE}
991 LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
992 LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
996 if test "$do64bit" != "no" ; then
997 AC_DEFINE(TCL_CFG_DO64BIT)
1000 if test "${GCC}" = "yes" ; then
1001 AC_CACHE_CHECK(for SEH support in compiler,
1003 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1004 #define WIN32_LEAN_AND_MEAN
1005 #include <windows.h>
1006 #undef WIN32_LEAN_AND_MEAN
1008 int main(int argc, char** argv) {
1013 __except (EXCEPTION_EXECUTE_HANDLER) {
1023 if test "$tcl_cv_seh" = "no" ; then
1024 AC_DEFINE(HAVE_NO_SEH, 1,
1025 [Defined when mingw does not support SEH])
1029 # Check to see if the excpt.h include file provided contains the
1030 # definition for EXCEPTION_DISPOSITION; if not, which is the case
1031 # with Cygwin's version as of 2002-04-10, define it to be int,
1032 # sufficient for getting the current code to work.
1034 AC_CACHE_CHECK(for EXCEPTION_DISPOSITION support in include files,
1035 tcl_cv_eh_disposition,
1036 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1037 # define WIN32_LEAN_AND_MEAN
1038 # include <windows.h>
1039 # undef WIN32_LEAN_AND_MEAN
1041 EXCEPTION_DISPOSITION x;
1043 [tcl_cv_eh_disposition=yes],
1044 [tcl_cv_eh_disposition=no])
1046 if test "$tcl_cv_eh_disposition" = "no" ; then
1047 AC_DEFINE(EXCEPTION_DISPOSITION, int,
1048 [Defined when cygwin/mingw does not support EXCEPTION DISPOSITION])
1051 # Check to see if winnt.h defines CHAR, SHORT, and LONG
1052 # even if VOID has already been #defined. The win32api
1053 # used by mingw and cygwin is known to do this.
1055 AC_CACHE_CHECK(for winnt.h that ignores VOID define,
1056 tcl_cv_winnt_ignore_void,
1057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1059 #define WIN32_LEAN_AND_MEAN
1060 #include <windows.h>
1061 #undef WIN32_LEAN_AND_MEAN
1067 [tcl_cv_winnt_ignore_void=yes],
1068 [tcl_cv_winnt_ignore_void=no])
1070 if test "$tcl_cv_winnt_ignore_void" = "yes" ; then
1071 AC_DEFINE(HAVE_WINNT_IGNORE_VOID, 1,
1072 [Defined when cygwin/mingw ignores VOID define in winnt.h])
1075 # See if the compiler supports casting to a union type.
1076 # This is used to stop gcc from printing a compiler
1077 # warning when initializing a union member.
1079 AC_CACHE_CHECK(for cast to union support,
1080 tcl_cv_cast_to_union,
1081 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1082 union foo { int i; double d; };
1083 union foo f = (union foo) (int) 0;
1085 [tcl_cv_cast_to_union=yes],
1086 [tcl_cv_cast_to_union=no])
1088 if test "$tcl_cv_cast_to_union" = "yes"; then
1089 AC_DEFINE(HAVE_CAST_TO_UNION, 1,
1090 [Defined when compiler supports casting to union type.])
1094 # DL_LIBS is empty, but then we match the Unix version
1096 AC_SUBST(CFLAGS_DEBUG)
1097 AC_SUBST(CFLAGS_OPTIMIZE)
1098 AC_SUBST(CFLAGS_WARNING)
1099 AC_SUBST(CFLAGS_NOLTO)
1102 #------------------------------------------------------------------------
1105 # Location of the Tcl build directory.
1112 # Adds the following arguments to configure:
1115 # Defines the following vars:
1116 # TCL_BIN_DIR Full path to the tcl build dir.
1117 #------------------------------------------------------------------------
1119 AC_DEFUN([SC_WITH_TCL], [
1120 if test -d ../../tcl8.6$1/win; then
1121 TCL_BIN_DEFAULT=../../tcl8.6$1/win
1123 TCL_BIN_DEFAULT=../../tcl8.6/win
1126 AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.6 binaries from DIR],
1127 TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DEFAULT; pwd`)
1128 if test ! -d $TCL_BIN_DIR; then
1129 AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
1131 if test ! -f $TCL_BIN_DIR/Makefile; then
1132 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?)
1134 echo "building against Tcl binaries in: $TCL_BIN_DIR"
1136 AC_SUBST(TCL_BIN_DIR)
1139 #------------------------------------------------------------------------
1141 # Locate a tclsh shell installed on the system path. This macro
1142 # will only find a Tcl shell that already exists on the system.
1143 # It will not find a Tcl shell in the Tcl build directory or
1144 # a Tcl shell that has been installed from the Tcl build directory.
1145 # If a Tcl shell can't be located on the PATH, then TCLSH_PROG will
1146 # be set to "". Extensions should take care not to create Makefile
1147 # rules that are run by default and depend on TCLSH_PROG. An
1148 # extension can't assume that an executable Tcl shell exists at
1155 # Subst's the following values:
1157 #------------------------------------------------------------------------
1159 AC_DEFUN([SC_PROG_TCLSH], [
1160 AC_MSG_CHECKING([for tclsh])
1162 AC_CACHE_VAL(ac_cv_path_tclsh, [
1163 search_path=`echo ${PATH} | sed -e 's/:/ /g'`
1164 for dir in $search_path ; do
1165 for j in `ls -r $dir/tclsh[[8-9]]*.exe 2> /dev/null` \
1166 `ls -r $dir/tclsh* 2> /dev/null` ; do
1167 if test x"$ac_cv_path_tclsh" = x ; then
1168 if test -f "$j" ; then
1177 if test -f "$ac_cv_path_tclsh" ; then
1178 TCLSH_PROG="$ac_cv_path_tclsh"
1179 AC_MSG_RESULT($TCLSH_PROG)
1181 # It is not an error if an installed version of Tcl can't be located.
1183 AC_MSG_RESULT([No tclsh found on PATH])
1185 AC_SUBST(TCLSH_PROG)
1188 #------------------------------------------------------------------------
1190 # Determine the fully qualified path name of the tclsh executable
1191 # in the Tcl build directory. This macro will correctly determine
1192 # the name of the tclsh executable even if tclsh has not yet
1193 # been built in the build directory. The build tclsh must be used
1194 # when running tests from an extension build directory. It is not
1195 # correct to use the TCLSH_PROG in cases like this.
1201 # Subst's the following values:
1203 #------------------------------------------------------------------------
1205 AC_DEFUN([SC_BUILD_TCLSH], [
1206 AC_MSG_CHECKING([for tclsh in Tcl build directory])
1207 BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}\${EXESUFFIX}
1208 AC_MSG_RESULT($BUILD_TCLSH)
1209 AC_SUBST(BUILD_TCLSH)
1212 #--------------------------------------------------------------------
1213 # SC_TCL_CFG_ENCODING TIP #59
1215 # Declare the encoding to use for embedded configuration information.
1221 # Might append to the following vars:
1224 # Will define the following vars:
1225 # TCL_CFGVAL_ENCODING
1227 #--------------------------------------------------------------------
1229 AC_DEFUN([SC_TCL_CFG_ENCODING], [
1230 AC_ARG_WITH(encoding, [ --with-encoding encoding for configuration values], with_tcencoding=${withval})
1232 if test x"${with_tcencoding}" != x ; then
1233 AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}")
1235 # Default encoding on windows is not "iso8859-1"
1236 AC_DEFINE(TCL_CFGVAL_ENCODING,"cp1252")
1240 #--------------------------------------------------------------------
1243 # Figure out if we can embed the manifest where necessary
1246 # An optional manifest to merge into DLL/EXE.
1249 # Will define the following vars:
1250 # VC_MANIFEST_EMBED_DLL
1251 # VC_MANIFEST_EMBED_EXE
1253 #--------------------------------------------------------------------
1255 AC_DEFUN([SC_EMBED_MANIFEST], [
1256 AC_MSG_CHECKING(whether to embed manifest)
1257 AC_ARG_ENABLE(embedded-manifest,
1258 AS_HELP_STRING([--enable-embedded-manifest],
1259 [embed manifest if possible (default: yes)]),
1260 [embed_ok=$enableval], [embed_ok=yes])
1262 VC_MANIFEST_EMBED_DLL=
1263 VC_MANIFEST_EMBED_EXE=
1265 if test "$embed_ok" = "yes" -a "${SHARED_BUILD}" = "1" \
1266 -a "$GCC" != "yes" ; then
1267 # Add the magic to embed the manifest into the dll/exe
1268 AC_EGREP_CPP([manifest needed], [
1269 #if defined(_MSC_VER) && _MSC_VER >= 1400
1270 print("manifest needed")
1273 # Could do a CHECK_PROG for mt, but should always be with MSVC8+
1274 # Could add 'if test -f' check, but manifest should be created
1275 # in this compiler case
1276 # Add in a manifest argument that may be specified
1277 # XXX Needs improvement so that the test for existence accounts
1278 # XXX for a provided (known) manifest
1279 VC_MANIFEST_EMBED_DLL="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest $1 -outputresource:\[$]@\;2 ; fi"
1280 VC_MANIFEST_EMBED_EXE="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest $1 -outputresource:\[$]@\;1 ; fi"
1282 if test "x$1" != x ; then
1287 AC_MSG_RESULT([$result])
1288 AC_SUBST(VC_MANIFEST_EMBED_DLL)
1289 AC_SUBST(VC_MANIFEST_EMBED_EXE)