Debian Codegraph @

win/tcl.m4

raw
1 #------------------------------------------------------------------------
2 # SC_PATH_TCLCONFIG --
3 #
4 # Locate the tclConfig.sh file and perform a sanity check on
5 # the Tcl compile flags
6 #
7 # Arguments:
8 # none
9 #
10 # Results:
11 #
12 # Adds the following arguments to configure:
13 # --with-tcl=...
14 #
15 # Defines the following vars:
16 # TCL_BIN_DIR Full path to the directory containing
17 # the tclConfig.sh file
18 #------------------------------------------------------------------------
19
20 AC_DEFUN([SC_PATH_TCLCONFIG], [
21 #
22 # Ok, lets find the tcl configuration
23 # First, look for one uninstalled.
24 # the alternative search directory is invoked by --with-tcl
25 #
26
27 if test x"${no_tcl}" = x ; then
28 # we reset no_tcl in case something fails here
29 no_tcl=true
30 AC_ARG_WITH(tcl,
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,[
36
37 # First check to see if --with-tcl was specified.
38 if test x"${with_tclconfig}" != x ; then
39 case "${with_tclconfig}" in
40 */tclConfig.sh )
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$!!'`"
44 fi ;;
45 esac
46 if test -f "${with_tclconfig}/tclConfig.sh" ; then
47 ac_cv_c_tclconfig="`(cd "${with_tclconfig}"; pwd)`"
48 else
49 AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
50 fi
51 fi
52
53 # then check for a private Tcl installation
54 if test x"${ac_cv_c_tclconfig}" = x ; then
55 for i in \
56 ../tcl \
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` \
60 ../../tcl \
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` \
64 ../../../tcl \
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)`"
70 break
71 fi
72 done
73 fi
74
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` \
86 ; do
87 if test -f "$i/tclConfig.sh" ; then
88 ac_cv_c_tclconfig="`(cd $i; pwd)`"
89 break
90 fi
91 done
92 fi
93
94 # check in a few other private locations
95 if test x"${ac_cv_c_tclconfig}" = x ; then
96 for i in \
97 ${srcdir}/../tcl \
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)`"
103 break
104 fi
105 done
106 fi
107 ])
108
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])
112 else
113 no_tcl=
114 TCL_BIN_DIR="${ac_cv_c_tclconfig}"
115 AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
116 fi
117 fi
118 ])
119
120 #------------------------------------------------------------------------
121 # SC_PATH_TKCONFIG --
122 #
123 # Locate the tkConfig.sh file
124 #
125 # Arguments:
126 # none
127 #
128 # Results:
129 #
130 # Adds the following arguments to configure:
131 # --with-tk=...
132 #
133 # Defines the following vars:
134 # TK_BIN_DIR Full path to the directory containing
135 # the tkConfig.sh file
136 #------------------------------------------------------------------------
137
138 AC_DEFUN([SC_PATH_TKCONFIG], [
139 #
140 # Ok, lets find the tk configuration
141 # First, look for one uninstalled.
142 # the alternative search directory is invoked by --with-tk
143 #
144
145 if test x"${no_tk}" = x ; then
146 # we reset no_tk in case something fails here
147 no_tk=true
148 AC_ARG_WITH(tk,
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,[
154
155 # First check to see if --with-tkconfig was specified.
156 if test x"${with_tkconfig}" != x ; then
157 case "${with_tkconfig}" in
158 */tkConfig.sh )
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$!!'`"
162 fi ;;
163 esac
164 if test -f "${with_tkconfig}/tkConfig.sh" ; then
165 ac_cv_c_tkconfig="`(cd "${with_tkconfig}"; pwd)`"
166 else
167 AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
168 fi
169 fi
170
171 # then check for a private Tk library
172 if test x"${ac_cv_c_tkconfig}" = x ; then
173 for i in \
174 ../tk \
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` \
178 ../../tk \
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` \
182 ../../../tk \
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)`"
188 break
189 fi
190 done
191 fi
192
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` \
204 ; do
205 if test -f "$i/tkConfig.sh" ; then
206 ac_cv_c_tkconfig="`(cd $i; pwd)`"
207 break
208 fi
209 done
210 fi
211
212 # check in a few other private locations
213 if test x"${ac_cv_c_tkconfig}" = x ; then
214 for i in \
215 ${srcdir}/../tk \
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)`"
221 break
222 fi
223 done
224 fi
225 ])
226
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])
230 else
231 no_tk=
232 TK_BIN_DIR="${ac_cv_c_tkconfig}"
233 AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
234 fi
235 fi
236 ])
237
238 #------------------------------------------------------------------------
239 # SC_LOAD_TCLCONFIG --
240 #
241 # Load the tclConfig.sh file.
242 #
243 # Arguments:
244 #
245 # Requires the following vars to be set:
246 # TCL_BIN_DIR
247 #
248 # Results:
249 #
250 # Substitutes the following vars:
251 # TCL_BIN_DIR
252 # TCL_SRC_DIR
253 # TCL_LIB_FILE
254 #
255 #------------------------------------------------------------------------
256
257 AC_DEFUN([SC_LOAD_TCLCONFIG], [
258 AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
259
260 if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
261 AC_MSG_RESULT([loading])
262 . "${TCL_BIN_DIR}/tclConfig.sh"
263 else
264 AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
265 fi
266
267 #
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.
274 #
275
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}
280 fi
281
282 #
283 # eval is required to do the TCL_DBGX substitution
284 #
285
286 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
287 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
288 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
289
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}\""
293
294 AC_SUBST(TCL_VERSION)
295 AC_SUBST(TCL_BIN_DIR)
296 AC_SUBST(TCL_SRC_DIR)
297
298 AC_SUBST(TCL_LIB_FILE)
299 AC_SUBST(TCL_LIB_FLAG)
300 AC_SUBST(TCL_LIB_SPEC)
301
302 AC_SUBST(TCL_STUB_LIB_FILE)
303 AC_SUBST(TCL_STUB_LIB_FLAG)
304 AC_SUBST(TCL_STUB_LIB_SPEC)
305
306 AC_SUBST(TCL_DEFS)
307 ])
308
309 #------------------------------------------------------------------------
310 # SC_LOAD_TKCONFIG --
311 #
312 # Load the tkConfig.sh file
313 #
314 # Arguments:
315 #
316 # Requires the following vars to be set:
317 # TK_BIN_DIR
318 #
319 # Results:
320 #
321 # Sets the following vars that should be in tkConfig.sh:
322 # TK_BIN_DIR
323 #------------------------------------------------------------------------
324
325 AC_DEFUN([SC_LOAD_TKCONFIG], [
326 AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
327
328 if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
329 AC_MSG_RESULT([loading])
330 . "${TK_BIN_DIR}/tkConfig.sh"
331 else
332 AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
333 fi
334
335
336 AC_SUBST(TK_BIN_DIR)
337 AC_SUBST(TK_SRC_DIR)
338 AC_SUBST(TK_LIB_FILE)
339 ])
340
341 #------------------------------------------------------------------------
342 # SC_ENABLE_SHARED --
343 #
344 # Allows the building of shared libraries
345 #
346 # Arguments:
347 # none
348 #
349 # Results:
350 #
351 # Adds the following arguments to configure:
352 # --enable-shared=yes|no
353 #
354 # Defines the following vars:
355 # STATIC_BUILD Used for building import/export libraries
356 # on Windows.
357 #
358 # Sets the following vars:
359 # SHARED_BUILD Value of 1 or 0
360 #------------------------------------------------------------------------
361
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])
369 SHARED_BUILD=1
370 else
371 AC_MSG_RESULT([static])
372 SHARED_BUILD=0
373 AC_DEFINE(STATIC_BUILD, 1, [Is this a static build?])
374 fi
375 ])
376
377 #------------------------------------------------------------------------
378 # SC_ENABLE_THREADS --
379 #
380 # Specify if thread support should be enabled
381 #
382 # Arguments:
383 # none
384 #
385 # Results:
386 #
387 # Adds the following arguments to configure:
388 # --enable-threads=yes|no
389 #
390 # Defines the following vars:
391 # TCL_THREADS
392 #------------------------------------------------------------------------
393
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])
398
399 if test "$tcl_ok" = "yes"; then
400 AC_MSG_RESULT([yes (default)])
401 TCL_THREADS=1
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)
406 else
407 TCL_THREADS=0
408 AC_MSG_RESULT(no)
409 fi
410 AC_SUBST(TCL_THREADS)
411 ])
412
413 #------------------------------------------------------------------------
414 # SC_ENABLE_SYMBOLS --
415 #
416 # Specify if debugging symbols should be used.
417 # Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
418 # can also be enabled.
419 #
420 # Arguments:
421 # none
422 #
423 # Requires the following vars to be set in the Makefile:
424 # CFLAGS_DEBUG
425 # CFLAGS_OPTIMIZE
426 #
427 # Results:
428 #
429 # Adds the following arguments to configure:
430 # --enable-symbols
431 #
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
438 #
439 #------------------------------------------------------------------------
440
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)'
448 DBGX=""
449 AC_DEFINE(NDEBUG, 1, [Is no debugging enabled?])
450 AC_MSG_RESULT([no])
451
452 AC_DEFINE(TCL_CFG_OPTIMIZED)
453 else
454 CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
455 LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
456 DBGX=g
457 if test "$tcl_ok" = "yes"; then
458 AC_MSG_RESULT([yes (standard debugging)])
459 fi
460 fi
461 AC_SUBST(CFLAGS_DEFAULT)
462 AC_SUBST(LDFLAGS_DEFAULT)
463
464 if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
465 AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?])
466 fi
467
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?])
471 fi
472
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])
476 else
477 AC_MSG_RESULT([enabled $tcl_ok debugging])
478 fi
479 fi
480 ])
481
482 #--------------------------------------------------------------------
483 # SC_CONFIG_CFLAGS
484 #
485 # Try to determine the proper flags to pass to the compiler
486 # for building shared libraries and other such nonsense.
487 #
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.
491 #
492 # Arguments:
493 # none
494 #
495 # Results:
496 #
497 # Can the following vars:
498 # EXTRA_CFLAGS
499 # CFLAGS_DEBUG
500 # CFLAGS_OPTIMIZE
501 # CFLAGS_WARNING
502 # CFLAGS_NOLTO
503 # LDFLAGS_DEBUG
504 # LDFLAGS_OPTIMIZE
505 # LDFLAGS_CONSOLE
506 # LDFLAGS_WINDOW
507 # CC_OBJNAME
508 # CC_EXENAME
509 # CYGPATH
510 # STLIB_LD
511 # SHLIB_LD
512 # SHLIB_LD_LIBS
513 # LIBS
514 # AR
515 # RC
516 # RES
517 #
518 # MAKE_LIB
519 # MAKE_STUB_LIB
520 # MAKE_EXE
521 # MAKE_DLL
522 #
523 # LIBSUFFIX
524 # LIBFLAGSUFFIX
525 # LIBPREFIX
526 # LIBRARIES
527 # EXESUFFIX
528 # DLLSUFFIX
529 #
530 #--------------------------------------------------------------------
531
532 AC_DEFUN([SC_CONFIG_CFLAGS], [
533
534 # Step 0: Enable 64 bit support?
535
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)
539
540 # Cross-compiling options for Windows/CE builds
541
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)
545
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])
550
551 # Set some defaults (may get changed below)
552 EXTRA_CFLAGS=""
553 AC_DEFINE(MODULE_SCOPE, [extern], [No need to mark inidividual symbols as hidden])
554
555 AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo)
556 AC_CHECK_PROG(WINE, wine, wine,)
557
558 SHLIB_SUFFIX=".dll"
559
560 # MACHINE is IX86 for LINK, but this is used by the manifest,
561 # which requires x86|amd64|arm64|ia64.
562 MACHINE="X86"
563
564 if test "$GCC" = "yes"; then
565
566 AC_CACHE_CHECK(for cross-compile version of gcc,
567 ac_cv_cross,
568 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
569 #ifndef _WIN32
570 #error cross-compiler
571 #endif
572 ]], [[]])],
573 [ac_cv_cross=no],
574 [ac_cv_cross=yes])
575 )
576
577 if test "$ac_cv_cross" = "yes"; then
578 case "$do64bit" in
579 amd64|x64|yes)
580 CC="x86_64-w64-mingw32-${CC}"
581 LD="x86_64-w64-mingw32-ld"
582 AR="x86_64-w64-mingw32-ar"
583 RANLIB="x86_64-w64-mingw32-ranlib"
584 RC="x86_64-w64-mingw32-windres"
585 ;;
586 arm64|aarch64)
587 CC="aarch64-w64-mingw32-${CC}"
588 LD="aarch64-w64-mingw32-ld"
589 AR="aarch64-w64-mingw32-ar"
590 RANLIB="aarch64-w64-mingw32-ranlib"
591 RC="aarch64-w64-mingw32-windres"
592 ;;
593 *)
594 CC="i686-w64-mingw32-${CC}"
595 LD="i686-w64-mingw32-ld"
596 AR="i686-w64-mingw32-ar"
597 RANLIB="i686-w64-mingw32-ranlib"
598 RC="i686-w64-mingw32-windres"
599 ;;
600 esac
601 fi
602 fi
603
604 # Check for a bug in gcc's windres that causes the
605 # compile to fail when a Windows native path is
606 # passed into windres. The mingw toolchain requires
607 # Windows native paths while Cygwin should work
608 # with both. Avoid the bug by passing a POSIX
609 # path when using the Cygwin toolchain.
610
611 if test "$GCC" = "yes" && test "$CYGPATH" != "echo" ; then
612 conftest=/tmp/conftest.rc
613 echo "STRINGTABLE BEGIN" > $conftest
614 echo "101 \"name\"" >> $conftest
615 echo "END" >> $conftest
616
617 AC_MSG_CHECKING([for Windows native path bug in windres])
618 cyg_conftest=`$CYGPATH $conftest`
619 if AC_TRY_COMMAND($RC -o conftest.res.o $cyg_conftest) ; then
620 AC_MSG_RESULT([no])
621 else
622 AC_MSG_RESULT([yes])
623 CYGPATH=echo
624 fi
625 conftest=
626 cyg_conftest=
627 fi
628
629 if test "$CYGPATH" = "echo"; then
630 DEPARG='"$<"'
631 else
632 DEPARG='"$(shell $(CYGPATH) $<)"'
633 fi
634
635 # set various compiler flags depending on whether we are using gcc or cl
636
637 if test "${GCC}" = "yes" ; then
638 extra_cflags="-pipe"
639 extra_ldflags="-pipe -static-libgcc"
640 AC_CACHE_CHECK(for mingw32 version of gcc,
641 ac_cv_win32,
642 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
643 #ifdef _WIN32
644 #error win32
645 #endif
646 ]], [[]])],
647 [ac_cv_win32=no],
648 [ac_cv_win32=yes])
649 )
650 if test "$ac_cv_win32" != "yes"; then
651 AC_MSG_ERROR([${CC} cannot produce win32 executables.])
652 fi
653 if test "$do64bit" != "arm64" -a "$do64bit" != "aarch64"; then
654 extra_cflags="$extra_cflags -DHAVE_CPUID=1"
655 fi
656
657 hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -mwindows -municode -Dmain=xxmain"
658 AC_CACHE_CHECK(for working -municode linker flag,
659 ac_cv_municode,
660 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
661 #include <windows.h>
662 int APIENTRY wWinMain(HINSTANCE a, HINSTANCE b, LPWSTR c, int d) {return 0;}
663 ]], [[]])],
664 [ac_cv_municode=yes],
665 [ac_cv_municode=no])
666 )
667 CFLAGS=$hold_cflags
668 if test "$ac_cv_municode" = "yes" ; then
669 extra_ldflags="$extra_ldflags -municode"
670 else
671 extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
672 fi
673 hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fno-lto"
674 AC_CACHE_CHECK(for working -fno-lto,
675 ac_cv_nolto,
676 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
677 [ac_cv_nolto=yes],
678 [ac_cv_nolto=no])
679 )
680 CFLAGS=$hold_cflags
681 if test "$ac_cv_nolto" = "yes" ; then
682 CFLAGS_NOLTO="-fno-lto"
683 else
684 CFLAGS_NOLTO=""
685 fi
686
687 AC_CACHE_CHECK([if the linker understands --disable-high-entropy-va],
688 tcl_cv_ld_high_entropy, [
689 hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Wl,--disable-high-entropy-va"
690 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[tcl_cv_ld_high_entropy=yes],[tcl_cv_ld_high_entropy=no])
691 CFLAGS=$hold_cflags])
692 if test $tcl_cv_ld_high_entropy = yes; then
693 extra_ldflags="$extra_ldflags -Wl,--disable-high-entropy-va"
694 fi
695 fi
696
697 hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Wl,--enable-auto-image-base"
698 AC_CACHE_CHECK(for working --enable-auto-image-base,
699 ac_cv_enable_auto_image_base,
700 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
701 [ac_cv_enable_auto_image_base=yes],
702 [ac_cv_enable_auto_image_base=no])
703 )
704 CFLAGS=$hold_cflags
705 if test "$ac_cv_enable_auto_image_base" = "yes" ; then
706 extra_ldflags="$extra_ldflags -Wl,--enable-auto-image-base"
707 fi
708
709 AC_MSG_CHECKING([compiler flags])
710 if test "${GCC}" = "yes" ; then
711 SHLIB_LD=""
712 SHLIB_LD_LIBS='${LIBS}'
713 LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32"
714 # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
715 LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32"
716 STLIB_LD='${AR} cr'
717 RC_OUT=-o
718 RC_TYPE=
719 RC_INCLUDE=--include
720 RC_DEFINE=--define
721 RES=res.o
722 MAKE_LIB="\${STLIB_LD} \[$]@"
723 MAKE_STUB_LIB="\${STLIB_LD} \[$]@"
724 POST_MAKE_LIB="\${RANLIB} \[$]@"
725 MAKE_EXE="\${CC} -o \[$]@"
726 LIBPREFIX="lib"
727
728 if test "${SHARED_BUILD}" = "0" ; then
729 # static
730 AC_MSG_RESULT([using static flags])
731 runtime=
732 LIBRARIES="\${STATIC_LIBRARIES}"
733 EXESUFFIX="s\${DBGX}.exe"
734 else
735 # dynamic
736 AC_MSG_RESULT([using shared flags])
737
738 # ad-hoc check to see if CC supports -shared.
739 if "${CC}" -shared 2>&1 | egrep ': -shared not supported' >/dev/null; then
740 AC_MSG_ERROR([${CC} does not support the -shared option.
741 You will need to upgrade to a newer version of the toolchain.])
742 fi
743
744 runtime=
745 # Add SHLIB_LD_LIBS to the Make rule, not here.
746
747 EXESUFFIX="\${DBGX}.exe"
748 LIBRARIES="\${SHARED_LIBRARIES}"
749 fi
750 # Link with gcc since ld does not link to default libs like
751 # -luser32 and -lmsvcrt by default.
752 SHLIB_LD='${CC} -shared'
753 SHLIB_LD_LIBS='${LIBS}'
754 MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \[$]@ ${extra_ldflags} \
755 -Wl,--out-implib,\$(patsubst %.dll,lib%.dll.a,\[$]@)"
756 # DLLSUFFIX is separate because it is the building block for
757 # users of tclConfig.sh that may build shared or static.
758 DLLSUFFIX="\${DBGX}.dll"
759 LIBSUFFIX="\${DBGX}.a"
760 LIBFLAGSUFFIX="\${DBGX}"
761 SHLIB_SUFFIX=.dll
762
763 EXTRA_CFLAGS="${extra_cflags}"
764
765 CFLAGS_DEBUG=-g
766 CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
767 CFLAGS_WARNING="-Wall -Wpointer-arith"
768 LDFLAGS_DEBUG=
769 LDFLAGS_OPTIMIZE=
770
771 case "${CC}" in
772 *++)
773 CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
774 ;;
775 *)
776 CFLAGS_WARNING="${CFLAGS_WARNING} -Wdeclaration-after-statement"
777 ;;
778 esac
779
780 # Specify the CC output file names based on the target name
781 CC_OBJNAME="-o \[$]@"
782 CC_EXENAME="-o \[$]@"
783
784 # Specify linker flags depending on the type of app being
785 # built -- Console vs. Window.
786 #
787 # ORIGINAL COMMENT:
788 # We need to pass -e _WinMain@16 so that ld will use
789 # WinMain() instead of main() as the entry point. We can't
790 # use autoconf to check for this case since it would need
791 # to run an executable and that does not work when
792 # cross compiling. Remove this -e workaround once we
793 # require a gcc that does not have this bug.
794 #
795 # MK NOTE: Tk should use a different mechanism. This causes
796 # interesting problems, such as wish dying at startup.
797 #LDFLAGS_WINDOW="-mwindows -e _WinMain@16 ${extra_ldflags}"
798 LDFLAGS_CONSOLE="-mconsole ${extra_ldflags}"
799 LDFLAGS_WINDOW="-mwindows ${extra_ldflags}"
800
801 case "$do64bit" in
802 amd64|x64|yes)
803 MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
804 AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
805 ;;
806 arm64|aarch64)
807 MACHINE="ARM64"
808 AC_MSG_RESULT([ Using ARM64 $MACHINE mode])
809 ;;
810 ia64)
811 MACHINE="IA64"
812 AC_MSG_RESULT([ Using IA64 $MACHINE mode])
813 ;;
814 *)
815 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
816 #ifndef _WIN64
817 #error 32-bit
818 #endif
819 ]], [[]])],
820 [tcl_win_64bit=yes],
821 [tcl_win_64bit=no]
822 )
823 if test "$tcl_win_64bit" = "yes" ; then
824 do64bit=amd64
825 MACHINE="AMD64"
826 AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
827 fi
828 ;;
829 esac
830 else
831 if test "${SHARED_BUILD}" = "0" ; then
832 # static
833 AC_MSG_RESULT([using static flags])
834 runtime=-MT
835 LIBRARIES="\${STATIC_LIBRARIES}"
836 EXESUFFIX="s\${DBGX}.exe"
837 else
838 # dynamic
839 AC_MSG_RESULT([using shared flags])
840 runtime=-MD
841 # Add SHLIB_LD_LIBS to the Make rule, not here.
842 LIBRARIES="\${SHARED_LIBRARIES}"
843 EXESUFFIX="\${DBGX}.exe"
844 case "x`echo \${VisualStudioVersion}`" in
845 x1[[4-9]]*)
846 lflags="${lflags} -nodefaultlib:ucrt.lib"
847 ;;
848 *)
849 ;;
850 esac
851 fi
852 MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -out:\[$]@"
853 # DLLSUFFIX is separate because it is the building block for
854 # users of tclConfig.sh that may build shared or static.
855 DLLSUFFIX="\${DBGX}.dll"
856 LIBSUFFIX="\${DBGX}.lib"
857 LIBFLAGSUFFIX="\${DBGX}"
858
859 if test "$do64bit" != "no" ; then
860 case "$do64bit" in
861 amd64|x64|yes)
862 MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
863 ;;
864 arm64|aarch64)
865 MACHINE="ARM64"
866 ;;
867 ia64)
868 MACHINE="IA64"
869 ;;
870 esac
871 AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
872 fi
873
874 LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib"
875
876 case "x`echo \${VisualStudioVersion}`" in
877 x1[[4-9]]*)
878 LIBS="$LIBS ucrt.lib"
879 ;;
880 *)
881 ;;
882 esac
883
884 if test "$do64bit" != "no" ; then
885 RC="rc"
886 CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
887 CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
888 lflags="${lflags} -nologo -MACHINE:${MACHINE}"
889 LINKBIN="link"
890 # Avoid 'unresolved external symbol __security_cookie' errors.
891 # c.f. http://support.microsoft.com/?id=894573
892 LIBS="$LIBS bufferoverflowU.lib"
893 else
894 RC="rc"
895 # -Od - no optimization
896 # -WX - warnings as errors
897 CFLAGS_DEBUG="-nologo -Z7 -Od -WX ${runtime}d"
898 # -O2 - create fast code (/Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy)
899 CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
900 lflags="${lflags} -nologo"
901 LINKBIN="link"
902 fi
903
904 if test "$doWince" != "no" ; then
905 # Set defaults for common evc4/PPC2003 setup
906 # Currently Tcl requires 300+, possibly 420+ for sockets
907 CEVERSION=420; # could be 211 300 301 400 420 ...
908 TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ...
909 ARCH=ARM; # could be ARM MIPS X86EM ...
910 PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002"
911 if test "$doWince" != "yes"; then
912 # If !yes then the user specified something
913 # Reset ARCH to allow user to skip specifying it
914 ARCH=
915 eval `echo $doWince | awk -F "," '{ \
916 if (length([$]1)) { printf "CEVERSION=\"%s\"\n", [$]1; \
917 if ([$]1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \
918 if (length([$]2)) { printf "TARGETCPU=\"%s\"\n", toupper([$]2) }; \
919 if (length([$]3)) { printf "ARCH=\"%s\"\n", toupper([$]3) }; \
920 if (length([$]4)) { printf "PLATFORM=\"%s\"\n", [$]4 }; \
921 }'`
922 if test "x${ARCH}" = "x" ; then
923 ARCH=$TARGETCPU;
924 fi
925 fi
926 OSVERSION=WCE$CEVERSION;
927 if test "x${WCEROOT}" = "x" ; then
928 WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0"
929 if test ! -d "${WCEROOT}" ; then
930 WCEROOT="C:/Program Files/Microsoft eMbedded Tools"
931 fi
932 fi
933 if test "x${SDKROOT}" = "x" ; then
934 SDKROOT="C:/Program Files/Windows CE Tools"
935 if test ! -d "${SDKROOT}" ; then
936 SDKROOT="C:/Windows CE Tools"
937 fi
938 fi
939 # The space-based-path will work for the Makefile, but will
940 # not work if AC_TRY_COMPILE is called.
941 WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'`
942 SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'`
943 CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'`
944 if test ! -d "${CELIB_DIR}/inc"; then
945 AC_MSG_ERROR([Invalid celib directory "${CELIB_DIR}"])
946 fi
947 if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"\
948 -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
949 AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]])
950 else
951 CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include"
952 if test -d "${CEINCLUDE}/${TARGETCPU}" ; then
953 CEINCLUDE="${CEINCLUDE}/${TARGETCPU}"
954 fi
955 CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"
956 fi
957 fi
958
959 if test "$doWince" != "no" ; then
960 CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin"
961 if test "${TARGETCPU}" = "X86"; then
962 CC="${CEBINROOT}/cl.exe"
963 else
964 CC="${CEBINROOT}/cl${ARCH}.exe"
965 fi
966 CC="\"${CC}\" -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
967 RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
968 arch=`echo ${ARCH} | awk '{print tolower([$]0)}'`
969 defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _DLL _WINDOWS"
970 for i in $defs ; do
971 AC_DEFINE_UNQUOTED($i)
972 done
973 # if test "${ARCH}" = "X86EM"; then
974 # AC_DEFINE_UNQUOTED(_WIN32_WCE_EMULATION)
975 # fi
976 AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION)
977 AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION)
978 CFLAGS_DEBUG="-nologo -Zi -Od"
979 CFLAGS_OPTIMIZE="-nologo -O2"
980 lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'`
981 lflags="-nodefaultlib -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo"
982 LINKBIN="\"${CEBINROOT}/link.exe\""
983 AC_SUBST(CELIB_DIR)
984 if test "${CEVERSION}" -lt 400 ; then
985 LIBS="coredll.lib corelibc.lib winsock.lib"
986 else
987 LIBS="coredll.lib corelibc.lib ws2.lib"
988 fi
989 # celib currently stuck at wce300 status
990 #LIBS="$LIBS \${CELIB_DIR}/wince-${ARCH}-pocket-${OSVERSION}-release/celib.lib"
991 LIBS="$LIBS \"\${CELIB_DIR}/wince-${ARCH}-pocket-wce300-release/celib.lib\""
992 LIBS_GUI="commctrl.lib commdlg.lib"
993 else
994 LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib"
995 fi
996
997 SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}"
998 SHLIB_LD_LIBS='${LIBS}'
999 # link -lib only works when -lib is the first arg
1000 STLIB_LD="${LINKBIN} -lib ${lflags}"
1001 RC_OUT=-fo
1002 RC_TYPE=-r
1003 RC_INCLUDE=-i
1004 RC_DEFINE=-d
1005 RES=res
1006 MAKE_LIB="\${STLIB_LD} -out:\[$]@"
1007 MAKE_STUB_LIB="\${STLIB_LD} -nodefaultlib -out:\[$]@"
1008 POST_MAKE_LIB=
1009 MAKE_EXE="\${CC} -Fe\[$]@"
1010 LIBPREFIX=""
1011
1012 CFLAGS_DEBUG="${CFLAGS_DEBUG} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE"
1013 CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE"
1014
1015 EXTRA_CFLAGS=""
1016 CFLAGS_WARNING="-W3"
1017 LDFLAGS_DEBUG="-debug"
1018 LDFLAGS_OPTIMIZE="-release"
1019
1020 # Specify the CC output file names based on the target name
1021 CC_OBJNAME="-Fo\[$]@"
1022 CC_EXENAME="-Fe\"\$(shell \$(CYGPATH) '\[$]@')\""
1023
1024 # Specify linker flags depending on the type of app being
1025 # built -- Console vs. Window.
1026 if test "$doWince" != "no" -a "${TARGETCPU}" != "X86"; then
1027 LDFLAGS_CONSOLE="-link ${lflags}"
1028 LDFLAGS_WINDOW=${LDFLAGS_CONSOLE}
1029 else
1030 LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
1031 LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
1032 fi
1033 fi
1034
1035 if test "$do64bit" != "no" ; then
1036 AC_DEFINE(TCL_CFG_DO64BIT)
1037 fi
1038
1039 if test "${GCC}" = "yes" ; then
1040 AC_CACHE_CHECK(for SEH support in compiler,
1041 tcl_cv_seh,
1042 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1043 #define WIN32_LEAN_AND_MEAN
1044 #include <windows.h>
1045 #undef WIN32_LEAN_AND_MEAN
1046
1047 int main(int argc, char** argv) {
1048 int a, b = 0;
1049 __try {
1050 a = 666 / b;
1051 }
1052 __except (EXCEPTION_EXECUTE_HANDLER) {
1053 return 0;
1054 }
1055 return 1;
1056 }
1057 ]])],
1058 [tcl_cv_seh=yes],
1059 [tcl_cv_seh=no],
1060 [tcl_cv_seh=no])
1061 )
1062 if test "$tcl_cv_seh" = "no" ; then
1063 AC_DEFINE(HAVE_NO_SEH, 1,
1064 [Defined when mingw does not support SEH])
1065 fi
1066
1067 #
1068 # Check to see if the excpt.h include file provided contains the
1069 # definition for EXCEPTION_DISPOSITION; if not, which is the case
1070 # with Cygwin's version as of 2002-04-10, define it to be int,
1071 # sufficient for getting the current code to work.
1072 #
1073 AC_CACHE_CHECK(for EXCEPTION_DISPOSITION support in include files,
1074 tcl_cv_eh_disposition,
1075 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1076 # define WIN32_LEAN_AND_MEAN
1077 # include <windows.h>
1078 # undef WIN32_LEAN_AND_MEAN
1079 ]], [[
1080 EXCEPTION_DISPOSITION x;
1081 ]])],
1082 [tcl_cv_eh_disposition=yes],
1083 [tcl_cv_eh_disposition=no])
1084 )
1085 if test "$tcl_cv_eh_disposition" = "no" ; then
1086 AC_DEFINE(EXCEPTION_DISPOSITION, int,
1087 [Defined when cygwin/mingw does not support EXCEPTION DISPOSITION])
1088 fi
1089
1090 # Check to see if winnt.h defines CHAR, SHORT, and LONG
1091 # even if VOID has already been #defined. The win32api
1092 # used by mingw and cygwin is known to do this.
1093
1094 AC_CACHE_CHECK(for winnt.h that ignores VOID define,
1095 tcl_cv_winnt_ignore_void,
1096 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1097 #define VOID void
1098 #define WIN32_LEAN_AND_MEAN
1099 #include <windows.h>
1100 #undef WIN32_LEAN_AND_MEAN
1101 ]], [[
1102 CHAR c;
1103 SHORT s;
1104 LONG l;
1105 ]])],
1106 [tcl_cv_winnt_ignore_void=yes],
1107 [tcl_cv_winnt_ignore_void=no])
1108 )
1109 if test "$tcl_cv_winnt_ignore_void" = "yes" ; then
1110 AC_DEFINE(HAVE_WINNT_IGNORE_VOID, 1,
1111 [Defined when cygwin/mingw ignores VOID define in winnt.h])
1112 fi
1113
1114 # See if the compiler supports casting to a union type.
1115 # This is used to stop gcc from printing a compiler
1116 # warning when initializing a union member.
1117
1118 AC_CACHE_CHECK(for cast to union support,
1119 tcl_cv_cast_to_union,
1120 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1121 union foo { int i; double d; };
1122 union foo f = (union foo) (int) 0;
1123 ]])],
1124 [tcl_cv_cast_to_union=yes],
1125 [tcl_cv_cast_to_union=no])
1126 )
1127 if test "$tcl_cv_cast_to_union" = "yes"; then
1128 AC_DEFINE(HAVE_CAST_TO_UNION, 1,
1129 [Defined when compiler supports casting to union type.])
1130 fi
1131 fi
1132
1133 # DL_LIBS is empty, but then we match the Unix version
1134 AC_SUBST(DL_LIBS)
1135 AC_SUBST(CFLAGS_DEBUG)
1136 AC_SUBST(CFLAGS_OPTIMIZE)
1137 AC_SUBST(CFLAGS_WARNING)
1138 AC_SUBST(CFLAGS_NOLTO)
1139 ])
1140
1141 #------------------------------------------------------------------------
1142 # SC_WITH_TCL --
1143 #
1144 # Location of the Tcl build directory.
1145 #
1146 # Arguments:
1147 # none
1148 #
1149 # Results:
1150 #
1151 # Adds the following arguments to configure:
1152 # --with-tcl=...
1153 #
1154 # Defines the following vars:
1155 # TCL_BIN_DIR Full path to the tcl build dir.
1156 #------------------------------------------------------------------------
1157
1158 AC_DEFUN([SC_WITH_TCL], [
1159 if test -d ../../tcl8.6$1/win; then
1160 TCL_BIN_DEFAULT=../../tcl8.6$1/win
1161 else
1162 TCL_BIN_DEFAULT=../../tcl8.6/win
1163 fi
1164
1165 AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.6 binaries from DIR],
1166 TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DEFAULT; pwd`)
1167 if test ! -d $TCL_BIN_DIR; then
1168 AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
1169 fi
1170 if test ! -f $TCL_BIN_DIR/Makefile; then
1171 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?)
1172 else
1173 echo "building against Tcl binaries in: $TCL_BIN_DIR"
1174 fi
1175 AC_SUBST(TCL_BIN_DIR)
1176 ])
1177
1178 #------------------------------------------------------------------------
1179 # SC_PROG_TCLSH
1180 # Locate a tclsh shell installed on the system path. This macro
1181 # will only find a Tcl shell that already exists on the system.
1182 # It will not find a Tcl shell in the Tcl build directory or
1183 # a Tcl shell that has been installed from the Tcl build directory.
1184 # If a Tcl shell can't be located on the PATH, then TCLSH_PROG will
1185 # be set to "". Extensions should take care not to create Makefile
1186 # rules that are run by default and depend on TCLSH_PROG. An
1187 # extension can't assume that an executable Tcl shell exists at
1188 # build time.
1189 #
1190 # Arguments
1191 # none
1192 #
1193 # Results
1194 # Substitutes the following values:
1195 # TCLSH_PROG
1196 #------------------------------------------------------------------------
1197
1198 AC_DEFUN([SC_PROG_TCLSH], [
1199 AC_MSG_CHECKING([for tclsh])
1200
1201 AC_CACHE_VAL(ac_cv_path_tclsh, [
1202 search_path=`echo ${PATH} | sed -e 's/:/ /g'`
1203 for dir in $search_path ; do
1204 for j in `ls -r $dir/tclsh[[8-9]]*.exe 2> /dev/null` \
1205 `ls -r $dir/tclsh* 2> /dev/null` ; do
1206 if test x"$ac_cv_path_tclsh" = x ; then
1207 if test -f "$j" ; then
1208 ac_cv_path_tclsh=$j
1209 break
1210 fi
1211 fi
1212 done
1213 done
1214 ])
1215
1216 if test -f "$ac_cv_path_tclsh" ; then
1217 TCLSH_PROG="$ac_cv_path_tclsh"
1218 AC_MSG_RESULT($TCLSH_PROG)
1219 else
1220 # It is not an error if an installed version of Tcl can't be located.
1221 TCLSH_PROG=""
1222 AC_MSG_RESULT([No tclsh found on PATH])
1223 fi
1224 AC_SUBST(TCLSH_PROG)
1225 ])
1226
1227 #------------------------------------------------------------------------
1228 # SC_BUILD_TCLSH
1229 # Determine the fully qualified path name of the tclsh executable
1230 # in the Tcl build directory. This macro will correctly determine
1231 # the name of the tclsh executable even if tclsh has not yet
1232 # been built in the build directory. The build tclsh must be used
1233 # when running tests from an extension build directory. It is not
1234 # correct to use the TCLSH_PROG in cases like this.
1235 #
1236 # Arguments
1237 # none
1238 #
1239 # Results
1240 # Substitutes the following values:
1241 # BUILD_TCLSH
1242 #------------------------------------------------------------------------
1243
1244 AC_DEFUN([SC_BUILD_TCLSH], [
1245 AC_MSG_CHECKING([for tclsh in Tcl build directory])
1246 BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}\${EXESUFFIX}
1247 AC_MSG_RESULT($BUILD_TCLSH)
1248 AC_SUBST(BUILD_TCLSH)
1249 ])
1250
1251 #--------------------------------------------------------------------
1252 # SC_TCL_CFG_ENCODING TIP #59
1253 #
1254 # Declare the encoding to use for embedded configuration information.
1255 #
1256 # Arguments:
1257 # None.
1258 #
1259 # Results:
1260 # Might append to the following vars:
1261 # DEFS (implicit)
1262 #
1263 # Will define the following vars:
1264 # TCL_CFGVAL_ENCODING
1265 #
1266 #--------------------------------------------------------------------
1267
1268 AC_DEFUN([SC_TCL_CFG_ENCODING], [
1269 AC_ARG_WITH(encoding, [ --with-encoding encoding for configuration values], with_tcencoding=${withval})
1270
1271 if test x"${with_tcencoding}" != x ; then
1272 AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}")
1273 else
1274 # Default encoding on windows is not "iso8859-1"
1275 AC_DEFINE(TCL_CFGVAL_ENCODING,"cp1252")
1276 fi
1277 ])
1278
1279 #--------------------------------------------------------------------
1280 # SC_EMBED_MANIFEST
1281 #
1282 # Figure out if we can embed the manifest where necessary
1283 #
1284 # Arguments:
1285 # An optional manifest to merge into DLL/EXE.
1286 #
1287 # Results:
1288 # Will define the following vars:
1289 # VC_MANIFEST_EMBED_DLL
1290 # VC_MANIFEST_EMBED_EXE
1291 #
1292 #--------------------------------------------------------------------
1293
1294 AC_DEFUN([SC_EMBED_MANIFEST], [
1295 AC_MSG_CHECKING(whether to embed manifest)
1296 AC_ARG_ENABLE(embedded-manifest,
1297 AS_HELP_STRING([--enable-embedded-manifest],
1298 [embed manifest if possible (default: yes)]),
1299 [embed_ok=$enableval], [embed_ok=yes])
1300
1301 VC_MANIFEST_EMBED_DLL=
1302 VC_MANIFEST_EMBED_EXE=
1303 result=no
1304 if test "$embed_ok" = "yes" -a "${SHARED_BUILD}" = "1" \
1305 -a "$GCC" != "yes" ; then
1306 # Add the magic to embed the manifest into the dll/exe
1307 AC_EGREP_CPP([manifest needed], [
1308 #if defined(_MSC_VER) && _MSC_VER >= 1400
1309 print("manifest needed")
1310 #endif
1311 ], [
1312 # Could do a CHECK_PROG for mt, but should always be with MSVC8+
1313 # Could add 'if test -f' check, but manifest should be created
1314 # in this compiler case
1315 # Add in a manifest argument that may be specified
1316 # XXX Needs improvement so that the test for existence accounts
1317 # XXX for a provided (known) manifest
1318 VC_MANIFEST_EMBED_DLL="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest $1 -outputresource:\[$]@\;2 ; fi"
1319 VC_MANIFEST_EMBED_EXE="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest $1 -outputresource:\[$]@\;1 ; fi"
1320 result=yes
1321 if test "x$1" != x ; then
1322 result="yes ($1)"
1323 fi
1324 ])
1325 fi
1326 AC_MSG_RESULT([$result])
1327 AC_SUBST(VC_MANIFEST_EMBED_DLL)
1328 AC_SUBST(VC_MANIFEST_EMBED_EXE)
1329 ])