OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / win / tcl.m4
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
557     SHLIB_SUFFIX=".dll"
558
559     # MACHINE is IX86 for LINK, but this is used by the manifest,
560     # which requires x86|amd64|ia64.
561     MACHINE="X86"
562
563     if test "$GCC" = "yes"; then
564
565       AC_CACHE_CHECK(for cross-compile version of gcc,
566         ac_cv_cross,
567         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
568             #ifndef _WIN32
569                 #error cross-compiler
570             #endif
571         ]], [[]])],
572         [ac_cv_cross=no],
573         [ac_cv_cross=yes])
574       )
575
576       if test "$ac_cv_cross" = "yes"; then
577         case "$do64bit" in
578             amd64|x64|yes)
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"
584             ;;
585             *)
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"
591             ;;
592         esac
593       fi
594     fi
595
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.
602
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
608
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
612             AC_MSG_RESULT([no])
613         else
614             AC_MSG_RESULT([yes])
615             CYGPATH=echo
616         fi
617         conftest=
618         cyg_conftest=
619     fi
620
621     if test "$CYGPATH" = "echo"; then
622         DEPARG='"$<"'
623     else
624         DEPARG='"$(shell $(CYGPATH) $<)"'
625     fi
626
627     # set various compiler flags depending on whether we are using gcc or cl
628
629     if test "${GCC}" = "yes" ; then
630         extra_cflags="-pipe"
631         extra_ldflags="-pipe -static-libgcc"
632         AC_CACHE_CHECK(for mingw32 version of gcc,
633             ac_cv_win32,
634             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
635                 #ifdef _WIN32
636                     #error win32
637                 #endif
638             ]], [[]])],
639             [ac_cv_win32=no],
640             [ac_cv_win32=yes])
641         )
642         if test "$ac_cv_win32" != "yes"; then
643             AC_MSG_ERROR([${CC} cannot produce win32 executables.])
644         fi
645
646         hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -mwindows -municode -Dmain=xxmain"
647         AC_CACHE_CHECK(for working -municode linker flag,
648             ac_cv_municode,
649         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
650         #include <windows.h>
651         int APIENTRY wWinMain(HINSTANCE a, HINSTANCE b, LPWSTR c, int d) {return 0;}
652         ]], [[]])],
653             [ac_cv_municode=yes],
654             [ac_cv_municode=no])
655         )
656         CFLAGS=$hold_cflags
657         if test "$ac_cv_municode" = "yes" ; then
658             extra_ldflags="$extra_ldflags -municode"
659         else
660             extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
661         fi
662         AC_CACHE_CHECK(for working -fno-lto,
663             ac_cv_nolto,
664         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
665             [ac_cv_nolto=yes],
666             [ac_cv_nolto=no])
667         )
668         CFLAGS=$hold_cflags
669         if test "$ac_cv_nolto" = "yes" ; then
670             CFLAGS_NOLTO="-fno-lto"
671         else
672             CFLAGS_NOLTO=""
673         fi
674     fi
675
676     AC_MSG_CHECKING([compiler flags])
677     if test "${GCC}" = "yes" ; then
678         SHLIB_LD=""
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"
683         STLIB_LD='${AR} cr'
684         RC_OUT=-o
685         RC_TYPE=
686         RC_INCLUDE=--include
687         RC_DEFINE=--define
688         RES=res.o
689         MAKE_LIB="\${STLIB_LD} \[$]@"
690         MAKE_STUB_LIB="\${STLIB_LD} \[$]@"
691         POST_MAKE_LIB="\${RANLIB} \[$]@"
692         MAKE_EXE="\${CC} -o \[$]@"
693         LIBPREFIX="lib"
694
695         if test "${SHARED_BUILD}" = "0" ; then
696             # static
697             AC_MSG_RESULT([using static flags])
698             runtime=
699             LIBRARIES="\${STATIC_LIBRARIES}"
700             EXESUFFIX="s\${DBGX}.exe"
701         else
702             # dynamic
703             AC_MSG_RESULT([using shared flags])
704
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.])
709             fi
710
711             runtime=
712             # Add SHLIB_LD_LIBS to the Make rule, not here.
713
714             EXESUFFIX="\${DBGX}.exe"
715             LIBRARIES="\${SHARED_LIBRARIES}"
716         fi
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}"
728         SHLIB_SUFFIX=.dll
729
730         EXTRA_CFLAGS="${extra_cflags}"
731
732         CFLAGS_DEBUG=-g
733         CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
734         CFLAGS_WARNING="-Wall -Wpointer-arith"
735         LDFLAGS_DEBUG=
736         LDFLAGS_OPTIMIZE=
737
738         case "${CC}" in
739             *++)
740                 CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
741                 ;;
742             *)
743                 CFLAGS_WARNING="${CFLAGS_WARNING} -Wdeclaration-after-statement"
744                 ;;
745         esac
746
747         # Specify the CC output file names based on the target name
748         CC_OBJNAME="-o \[$]@"
749         CC_EXENAME="-o \[$]@"
750
751         # Specify linker flags depending on the type of app being
752         # built -- Console vs. Window.
753         #
754         # ORIGINAL COMMENT:
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.
761         #
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}"
767
768         case "$do64bit" in
769             amd64|x64|yes)
770                 MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
771                 AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
772                 ;;
773             ia64)
774                 MACHINE="IA64"
775                 AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
776                 ;;
777             *)
778                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
779                     #ifndef _WIN64
780                         #error 32-bit
781                     #endif
782                 ]], [[]])],
783                         [tcl_win_64bit=yes],
784                         [tcl_win_64bit=no]
785                 )
786                 if test "$tcl_win_64bit" = "yes" ; then
787                         do64bit=amd64
788                         MACHINE="AMD64"
789                         AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
790                 fi
791                 ;;
792         esac
793     else
794         if test "${SHARED_BUILD}" = "0" ; then
795             # static
796             AC_MSG_RESULT([using static flags])
797             runtime=-MT
798             LIBRARIES="\${STATIC_LIBRARIES}"
799             EXESUFFIX="s\${DBGX}.exe"
800         else
801             # dynamic
802             AC_MSG_RESULT([using shared flags])
803             runtime=-MD
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
808                 x1[[4-9]]*)
809                     lflags="${lflags} -nodefaultlib:libucrt.lib"
810                     ;;
811                 *)
812                     ;;
813             esac
814         fi
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}"
821
822         if test "$do64bit" != "no" ; then
823             case "$do64bit" in
824                 amd64|x64|yes)
825                     MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
826                     ;;
827                 ia64)
828                     MACHINE="IA64"
829                     ;;
830             esac
831             AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
832         fi
833
834         LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib"
835
836         case "x`echo \${VisualStudioVersion}`" in
837                 x1[[4-9]]*)
838                     LIBS="$LIBS ucrt.lib"
839                     ;;
840                 *)
841                     ;;
842         esac
843
844         if test "$do64bit" != "no" ; then
845             RC="rc"
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}"
850             LINKBIN="link"
851             # Avoid 'unresolved external symbol __security_cookie' errors.
852             # c.f. http://support.microsoft.com/?id=894573
853             LIBS="$LIBS bufferoverflowU.lib"
854         else
855             RC="rc"
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"
862             LINKBIN="link"
863         fi
864
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
875                 ARCH=
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 }; \
882                 }'`
883                 if test "x${ARCH}" = "x" ; then
884                     ARCH=$TARGETCPU;
885                 fi
886             fi
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"
892                 fi
893             fi
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"
898                 fi
899             fi
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}"])
907             fi
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]])
911             else
912                 CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include"
913                 if test -d "${CEINCLUDE}/${TARGETCPU}" ; then
914                     CEINCLUDE="${CEINCLUDE}/${TARGETCPU}"
915                 fi
916                 CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"
917             fi
918         fi
919
920         if test "$doWince" != "no" ; then
921             CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin"
922             if test "${TARGETCPU}" = "X86"; then
923                 CC="${CEBINROOT}/cl.exe"
924             else
925                 CC="${CEBINROOT}/cl${ARCH}.exe"
926             fi
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"
931             for i in $defs ; do
932                 AC_DEFINE_UNQUOTED($i)
933             done
934 #           if test "${ARCH}" = "X86EM"; then
935 #               AC_DEFINE_UNQUOTED(_WIN32_WCE_EMULATION)
936 #           fi
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\""
944             AC_SUBST(CELIB_DIR)
945             if test "${CEVERSION}" -lt 400 ; then
946                 LIBS="coredll.lib corelibc.lib winsock.lib"
947             else
948                 LIBS="coredll.lib corelibc.lib ws2.lib"
949             fi
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"
954         else
955             LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib"
956         fi
957
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}"
962         RC_OUT=-fo
963         RC_TYPE=-r
964         RC_INCLUDE=-i
965         RC_DEFINE=-d
966         RES=res
967         MAKE_LIB="\${STLIB_LD} -out:\[$]@"
968         MAKE_STUB_LIB="\${STLIB_LD} -nodefaultlib -out:\[$]@"
969         POST_MAKE_LIB=
970         MAKE_EXE="\${CC} -Fe\[$]@"
971         LIBPREFIX=""
972
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"
975
976         EXTRA_CFLAGS=""
977         CFLAGS_WARNING="-W3"
978         LDFLAGS_DEBUG="-debug"
979         LDFLAGS_OPTIMIZE="-release"
980
981         # Specify the CC output file names based on the target name
982         CC_OBJNAME="-Fo\[$]@"
983         CC_EXENAME="-Fe\"\$(shell \$(CYGPATH) '\[$]@')\""
984
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}
990         else
991             LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
992             LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
993         fi
994     fi
995
996     if test "$do64bit" != "no" ; then
997         AC_DEFINE(TCL_CFG_DO64BIT)
998     fi
999
1000     if test "${GCC}" = "yes" ; then
1001         AC_CACHE_CHECK(for SEH support in compiler,
1002             tcl_cv_seh,
1003         AC_RUN_IFELSE([AC_LANG_SOURCE([[
1004             #define WIN32_LEAN_AND_MEAN
1005             #include <windows.h>
1006             #undef WIN32_LEAN_AND_MEAN
1007
1008             int main(int argc, char** argv) {
1009                 int a, b = 0;
1010                 __try {
1011                     a = 666 / b;
1012                 }
1013                 __except (EXCEPTION_EXECUTE_HANDLER) {
1014                     return 0;
1015                 }
1016                 return 1;
1017             }
1018         ]])],
1019             [tcl_cv_seh=yes],
1020             [tcl_cv_seh=no],
1021             [tcl_cv_seh=no])
1022         )
1023         if test "$tcl_cv_seh" = "no" ; then
1024             AC_DEFINE(HAVE_NO_SEH, 1,
1025                     [Defined when mingw does not support SEH])
1026         fi
1027
1028         #
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.
1033         #
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
1040             ]], [[
1041                 EXCEPTION_DISPOSITION x;
1042             ]])],
1043                 [tcl_cv_eh_disposition=yes],
1044                 [tcl_cv_eh_disposition=no])
1045         )
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])
1049         fi
1050
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.
1054
1055         AC_CACHE_CHECK(for winnt.h that ignores VOID define,
1056             tcl_cv_winnt_ignore_void,
1057             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1058                 #define VOID void
1059                 #define WIN32_LEAN_AND_MEAN
1060                 #include <windows.h>
1061                 #undef WIN32_LEAN_AND_MEAN
1062             ]], [[
1063                 CHAR c;
1064                 SHORT s;
1065                 LONG l;
1066             ]])],
1067             [tcl_cv_winnt_ignore_void=yes],
1068             [tcl_cv_winnt_ignore_void=no])
1069         )
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])
1073         fi
1074
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.
1078
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;
1084             ]])],
1085             [tcl_cv_cast_to_union=yes],
1086             [tcl_cv_cast_to_union=no])
1087         )
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.])
1091         fi
1092     fi
1093
1094     # DL_LIBS is empty, but then we match the Unix version
1095     AC_SUBST(DL_LIBS)
1096     AC_SUBST(CFLAGS_DEBUG)
1097     AC_SUBST(CFLAGS_OPTIMIZE)
1098     AC_SUBST(CFLAGS_WARNING)
1099     AC_SUBST(CFLAGS_NOLTO)
1100 ])
1101
1102 #------------------------------------------------------------------------
1103 # SC_WITH_TCL --
1104 #
1105 #       Location of the Tcl build directory.
1106 #
1107 # Arguments:
1108 #       none
1109 #
1110 # Results:
1111 #
1112 #       Adds the following arguments to configure:
1113 #               --with-tcl=...
1114 #
1115 #       Defines the following vars:
1116 #               TCL_BIN_DIR     Full path to the tcl build dir.
1117 #------------------------------------------------------------------------
1118
1119 AC_DEFUN([SC_WITH_TCL], [
1120     if test -d ../../tcl8.6$1/win;  then
1121         TCL_BIN_DEFAULT=../../tcl8.6$1/win
1122     else
1123         TCL_BIN_DEFAULT=../../tcl8.6/win
1124     fi
1125
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)
1130     fi
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?)
1133     else
1134         echo "building against Tcl binaries in: $TCL_BIN_DIR"
1135     fi
1136     AC_SUBST(TCL_BIN_DIR)
1137 ])
1138
1139 #------------------------------------------------------------------------
1140 # SC_PROG_TCLSH
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
1149 #       build time.
1150 #
1151 # Arguments
1152 #       none
1153 #
1154 # Results
1155 #       Subst's the following values:
1156 #               TCLSH_PROG
1157 #------------------------------------------------------------------------
1158
1159 AC_DEFUN([SC_PROG_TCLSH], [
1160     AC_MSG_CHECKING([for tclsh])
1161
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
1169                         ac_cv_path_tclsh=$j
1170                         break
1171                     fi
1172                 fi
1173             done
1174         done
1175     ])
1176
1177     if test -f "$ac_cv_path_tclsh" ; then
1178         TCLSH_PROG="$ac_cv_path_tclsh"
1179         AC_MSG_RESULT($TCLSH_PROG)
1180     else
1181         # It is not an error if an installed version of Tcl can't be located.
1182         TCLSH_PROG=""
1183         AC_MSG_RESULT([No tclsh found on PATH])
1184     fi
1185     AC_SUBST(TCLSH_PROG)
1186 ])
1187
1188 #------------------------------------------------------------------------
1189 # SC_BUILD_TCLSH
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.
1196 #
1197 # Arguments
1198 #       none
1199 #
1200 # Results
1201 #       Subst's the following values:
1202 #               BUILD_TCLSH
1203 #------------------------------------------------------------------------
1204
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)
1210 ])
1211
1212 #--------------------------------------------------------------------
1213 # SC_TCL_CFG_ENCODING   TIP #59
1214 #
1215 #       Declare the encoding to use for embedded configuration information.
1216 #
1217 # Arguments:
1218 #       None.
1219 #
1220 # Results:
1221 #       Might append to the following vars:
1222 #               DEFS    (implicit)
1223 #
1224 #       Will define the following vars:
1225 #               TCL_CFGVAL_ENCODING
1226 #
1227 #--------------------------------------------------------------------
1228
1229 AC_DEFUN([SC_TCL_CFG_ENCODING], [
1230     AC_ARG_WITH(encoding, [  --with-encoding         encoding for configuration values], with_tcencoding=${withval})
1231
1232     if test x"${with_tcencoding}" != x ; then
1233         AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}")
1234     else
1235         # Default encoding on windows is not "iso8859-1"
1236         AC_DEFINE(TCL_CFGVAL_ENCODING,"cp1252")
1237     fi
1238 ])
1239
1240 #--------------------------------------------------------------------
1241 # SC_EMBED_MANIFEST
1242 #
1243 #       Figure out if we can embed the manifest where necessary
1244 #
1245 # Arguments:
1246 #       An optional manifest to merge into DLL/EXE.
1247 #
1248 # Results:
1249 #       Will define the following vars:
1250 #               VC_MANIFEST_EMBED_DLL
1251 #               VC_MANIFEST_EMBED_EXE
1252 #
1253 #--------------------------------------------------------------------
1254
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])
1261
1262     VC_MANIFEST_EMBED_DLL=
1263     VC_MANIFEST_EMBED_EXE=
1264     result=no
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")
1271 #endif
1272         ], [
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"
1281         result=yes
1282         if test "x$1" != x ; then
1283             result="yes ($1)"
1284         fi
1285         ])
1286     fi
1287     AC_MSG_RESULT([$result])
1288     AC_SUBST(VC_MANIFEST_EMBED_DLL)
1289     AC_SUBST(VC_MANIFEST_EMBED_EXE)
1290 ])