Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/win/tcl.m4 @ 68

Last change on this file since 68 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 26.8 KB
Line 
1#------------------------------------------------------------------------
2# SC_PATH_TCLCONFIG --
3#
4#       Locate the tclConfig.sh file and perform a sanity check on
5#       the Tcl compile flags
6#       Currently a no-op for Windows
7#
8# Arguments:
9#       PATCH_LEVEL     The patch level for Tcl if any.
10#
11# Results:
12#
13#       Adds the following arguments to configure:
14#               --with-tcl=...
15#
16#       Sets the following vars:
17#               TCL_BIN_DIR     Full path to the tclConfig.sh file
18#------------------------------------------------------------------------
19
20AC_DEFUN([SC_PATH_TCLCONFIG], [
21    AC_MSG_CHECKING([the location of tclConfig.sh])
22
23    if test -d ../../tcl8.5$1/win;  then
24        TCL_BIN_DIR_DEFAULT=../../tcl8.5$1/win
25    elif test -d ../../tcl8.5/win;  then
26        TCL_BIN_DIR_DEFAULT=../../tcl8.5/win
27    else
28        TCL_BIN_DIR_DEFAULT=../../tcl/win
29    fi
30   
31    AC_ARG_WITH(tcl, [  --with-tcl=DIR          use Tcl 8.5 binaries from DIR],
32            TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DIR_DEFAULT; pwd`)
33    if test ! -d $TCL_BIN_DIR; then
34        AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
35    fi
36    if test ! -f $TCL_BIN_DIR/tclConfig.sh; then
37        AC_MSG_ERROR(There is no tclConfig.sh in $TCL_BIN_DIR:  perhaps you did not specify the Tcl *build* directory (not the toplevel Tcl directory) or you forgot to configure Tcl?)
38    fi
39    AC_MSG_RESULT($TCL_BIN_DIR/tclConfig.sh)
40])
41
42#------------------------------------------------------------------------
43# SC_PATH_TKCONFIG --
44#
45#       Locate the tkConfig.sh file
46#       Currently a no-op for Windows
47#
48# Arguments:
49#       none
50#
51# Results:
52#
53#       Adds the following arguments to configure:
54#               --with-tk=...
55#
56#       Sets the following vars:
57#               TK_BIN_DIR      Full path to the tkConfig.sh file
58#------------------------------------------------------------------------
59
60AC_DEFUN([SC_PATH_TKCONFIG], [
61    AC_MSG_CHECKING([the location of tkConfig.sh])
62
63    if test -d ../../tk8.5$1/win;  then
64        TK_BIN_DIR_DEFAULT=../../tk8.5$1/win
65    elif test -d ../../tk8.5/win;  then
66        TK_BIN_DIR_DEFAULT=../../tk8.5/win
67    else
68        TK_BIN_DIR_DEFAULT=../../tk/win
69    fi
70   
71    AC_ARG_WITH(tk, [  --with-tk=DIR          use Tk 8.5 binaries from DIR],
72            TK_BIN_DIR=$withval, TK_BIN_DIR=`cd $TK_BIN_DIR_DEFAULT; pwd`)
73    if test ! -d $TK_BIN_DIR; then
74        AC_MSG_ERROR(Tk directory $TK_BIN_DIR does not exist)
75    fi
76    if test ! -f $TK_BIN_DIR/tkConfig.sh; then
77        AC_MSG_ERROR(There is no tkConfig.sh in $TK_BIN_DIR:  perhaps you did not specify the Tk *build* directory (not the toplevel Tk directory) or you forgot to configure Tk?)
78    fi
79
80    AC_MSG_RESULT([$TK_BIN_DIR/tkConfig.sh])
81])
82
83#------------------------------------------------------------------------
84# SC_LOAD_TCLCONFIG --
85#
86#       Load the tclConfig.sh file.
87#
88# Arguments:
89#       
90#       Requires the following vars to be set:
91#               TCL_BIN_DIR
92#
93# Results:
94#
95#       Subst the following vars:
96#               TCL_BIN_DIR
97#               TCL_SRC_DIR
98#               TCL_LIB_FILE
99#
100#------------------------------------------------------------------------
101
102AC_DEFUN([SC_LOAD_TCLCONFIG], [
103    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
104
105    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
106        AC_MSG_RESULT([loading])
107        . $TCL_BIN_DIR/tclConfig.sh
108    else
109        AC_MSG_RESULT([file not found])
110    fi
111
112    #
113    # If the TCL_BIN_DIR is the build directory (not the install directory),
114    # then set the common variable name to the value of the build variables.
115    # For example, the variable TCL_LIB_SPEC will be set to the value
116    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
117    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
118    # installed and uninstalled version of Tcl.
119    #
120
121    if test -f $TCL_BIN_DIR/Makefile ; then
122        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
123        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
124        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
125    fi
126
127    #
128    # eval is required to do the TCL_DBGX substitution
129    #
130
131    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
132    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
133    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
134
135    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
136    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
137    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
138
139    AC_SUBST(TCL_VERSION)
140    AC_SUBST(TCL_BIN_DIR)
141    AC_SUBST(TCL_SRC_DIR)
142
143    AC_SUBST(TCL_LIB_FILE)
144    AC_SUBST(TCL_LIB_FLAG)
145    AC_SUBST(TCL_LIB_SPEC)
146
147    AC_SUBST(TCL_STUB_LIB_FILE)
148    AC_SUBST(TCL_STUB_LIB_FLAG)
149    AC_SUBST(TCL_STUB_LIB_SPEC)
150
151    AC_SUBST(TCL_DEFS)
152])
153
154#------------------------------------------------------------------------
155# SC_LOAD_TKCONFIG --
156#
157#       Load the tkConfig.sh file
158#       Currently a no-op for Windows
159#
160# Arguments:
161#       
162#       Requires the following vars to be set:
163#               TK_BIN_DIR
164#
165# Results:
166#
167#       Sets the following vars that should be in tkConfig.sh:
168#               TK_BIN_DIR
169#------------------------------------------------------------------------
170
171AC_DEFUN([SC_LOAD_TKCONFIG], [
172    AC_MSG_CHECKING([for existence of $TK_BIN_DIR/tkConfig.sh])
173
174    if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
175        AC_MSG_RESULT([loading])
176        . $TK_BIN_DIR/tkConfig.sh
177    else
178        AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
179    fi
180
181
182    AC_SUBST(TK_BIN_DIR)
183    AC_SUBST(TK_SRC_DIR)
184    AC_SUBST(TK_LIB_FILE)
185])
186
187#------------------------------------------------------------------------
188# SC_ENABLE_SHARED --
189#
190#       Allows the building of shared libraries
191#
192# Arguments:
193#       none
194#       
195# Results:
196#
197#       Adds the following arguments to configure:
198#               --enable-shared=yes|no
199#
200#       Defines the following vars:
201#               STATIC_BUILD    Used for building import/export libraries
202#                               on Windows.
203#
204#       Sets the following vars:
205#               SHARED_BUILD    Value of 1 or 0
206#------------------------------------------------------------------------
207
208AC_DEFUN([SC_ENABLE_SHARED], [
209    AC_MSG_CHECKING([how to build libraries])
210    AC_ARG_ENABLE(shared,
211        [  --enable-shared         build and link with shared libraries [--enable-shared]],
212    [tcl_ok=$enableval], [tcl_ok=yes])
213
214    if test "${enable_shared+set}" = set; then
215        enableval="$enable_shared"
216        tcl_ok=$enableval
217    else
218        tcl_ok=yes
219    fi
220
221    if test "$tcl_ok" = "yes" ; then
222        AC_MSG_RESULT([shared])
223        SHARED_BUILD=1
224    else
225        AC_MSG_RESULT([static])
226        SHARED_BUILD=0
227        AC_DEFINE(STATIC_BUILD)
228    fi
229])
230
231#------------------------------------------------------------------------
232# SC_ENABLE_THREADS --
233#
234#       Specify if thread support should be enabled
235#
236# Arguments:
237#       none
238#       
239# Results:
240#
241#       Adds the following arguments to configure:
242#               --enable-threads=yes|no
243#
244#       Defines the following vars:
245#               TCL_THREADS
246#------------------------------------------------------------------------
247
248AC_DEFUN([SC_ENABLE_THREADS], [
249    AC_MSG_CHECKING(for building with threads)
250    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
251        [tcl_ok=$enableval], [tcl_ok=no])
252
253    if test "$tcl_ok" = "yes"; then
254        AC_MSG_RESULT(yes)
255        TCL_THREADS=1
256        AC_DEFINE(TCL_THREADS)
257        # USE_THREAD_ALLOC tells us to try the special thread-based
258        # allocator that significantly reduces lock contention
259        AC_DEFINE(USE_THREAD_ALLOC)
260    else
261        TCL_THREADS=0
262        AC_MSG_RESULT([no (default)])
263    fi
264    AC_SUBST(TCL_THREADS)
265])
266
267#------------------------------------------------------------------------
268# SC_ENABLE_SYMBOLS --
269#
270#       Specify if debugging symbols should be used
271#       Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
272#       can also be enabled.
273#
274# Arguments:
275#       none
276#       
277#       Requires the following vars to be set in the Makefile:
278#               CFLAGS_DEBUG
279#               CFLAGS_OPTIMIZE
280#       
281# Results:
282#
283#       Adds the following arguments to configure:
284#               --enable-symbols
285#
286#       Defines the following vars:
287#               CFLAGS_DEFAULT  Sets to $(CFLAGS_DEBUG) if true
288#                               Sets to $(CFLAGS_OPTIMIZE) if false
289#               LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
290#                               Sets to $(LDFLAGS_OPTIMIZE) if false
291#               DBGX            Debug library extension
292#
293#------------------------------------------------------------------------
294
295AC_DEFUN([SC_ENABLE_SYMBOLS], [
296    AC_MSG_CHECKING([for build with symbols])
297    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
298# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
299    if test "$tcl_ok" = "no"; then
300        CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
301        LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
302        DBGX=""
303        AC_MSG_RESULT([no])
304
305        AC_DEFINE(TCL_CFG_OPTIMIZED)
306    else
307        CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
308        LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
309        DBGX=g
310        if test "$tcl_ok" = "yes"; then
311            AC_MSG_RESULT([yes (standard debugging)])
312        fi
313    fi
314    AC_SUBST(CFLAGS_DEFAULT)
315    AC_SUBST(LDFLAGS_DEFAULT)
316    AC_DEFINE(TCL_CFG_DEBUG)
317
318    if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
319        AC_DEFINE(TCL_MEM_DEBUG)
320    fi
321
322    if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
323        AC_DEFINE(TCL_COMPILE_DEBUG)
324        AC_DEFINE(TCL_COMPILE_STATS)
325    fi
326
327    if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
328        if test "$tcl_ok" = "all"; then
329            AC_MSG_RESULT([enabled symbols mem compile debugging])
330        else
331            AC_MSG_RESULT([enabled $tcl_ok debugging])
332        fi
333    fi
334])
335
336#--------------------------------------------------------------------
337# SC_CONFIG_CFLAGS
338#
339#       Try to determine the proper flags to pass to the compiler
340#       for building shared libraries and other such nonsense.
341#
342#       NOTE: The backslashes in quotes below are substituted twice
343#       due to the fact that they are in a macro and then inlined
344#       in the final configure script.
345#
346# Arguments:
347#       none
348#
349# Results:
350#
351#       Can the following vars:
352#               EXTRA_CFLAGS
353#               CFLAGS_DEBUG
354#               CFLAGS_OPTIMIZE
355#               CFLAGS_WARNING
356#               LDFLAGS_DEBUG
357#               LDFLAGS_OPTIMIZE
358#               LDFLAGS_CONSOLE
359#               LDFLAGS_WINDOW
360#               CC_OBJNAME
361#               CC_EXENAME
362#               CYGPATH
363#               STLIB_LD
364#               SHLIB_LD
365#               SHLIB_LD_LIBS
366#               LIBS
367#               AR
368#               RC
369#               RES
370#
371#               MAKE_LIB
372#               MAKE_EXE
373#               MAKE_DLL
374#
375#               LIBSUFFIX
376#               LIBPREFIX
377#               LIBRARIES
378#               EXESUFFIX
379#               DLLSUFFIX
380#
381#--------------------------------------------------------------------
382
383AC_DEFUN([SC_CONFIG_CFLAGS], [
384
385    # Step 0: Enable 64 bit support?
386
387    AC_MSG_CHECKING([if 64bit support is requested])
388    AC_ARG_ENABLE(64bit,[  --enable-64bit          enable 64bit support (where applicable)], [do64bit=$enableval], [do64bit=no])
389    AC_MSG_RESULT($do64bit)
390
391    # Cross-compiling options for Windows/CE builds
392
393    AC_MSG_CHECKING([if Windows/CE build is requested])
394    AC_ARG_ENABLE(wince,[  --enable-wince          enable Win/CE support (where applicable)], [doWince=$enableval], [doWince=no])
395    AC_MSG_RESULT($doWince)
396
397    AC_MSG_CHECKING([for Windows/CE celib directory])
398    AC_ARG_WITH(celib,[  --with-celib=DIR        use Windows/CE support library from DIR],
399            CELIB_DIR=$withval, CELIB_DIR=NO_CELIB)
400    AC_MSG_RESULT([$CELIB_DIR])
401
402    # Set some defaults (may get changed below)
403    EXTRA_CFLAGS=""
404
405    AC_CHECK_PROG(CYGPATH, cygpath, cygpath -w, echo)
406
407    SHLIB_SUFFIX=".dll"
408
409    # Check for a bug in gcc's windres that causes the
410    # compile to fail when a Windows native path is
411    # passed into windres. The mingw toolchain requires
412    # Windows native paths while Cygwin should work
413    # with both. Avoid the bug by passing a POSIX
414    # path when using the Cygwin toolchain.
415
416    if test "$GCC" = "yes" && test "$CYGPATH" != "echo" ; then
417        conftest=/tmp/conftest.rc
418        echo "STRINGTABLE BEGIN" > $conftest
419        echo "101 \"name\"" >> $conftest
420        echo "END" >> $conftest
421
422        AC_MSG_CHECKING([for Windows native path bug in windres])
423        cyg_conftest=`$CYGPATH $conftest`
424        if AC_TRY_COMMAND($RC -o conftest.res.o $cyg_conftest) ; then
425            AC_MSG_RESULT([no])
426        else
427            AC_MSG_RESULT([yes])
428            CYGPATH=echo
429        fi
430        conftest=
431        cyg_conftest=
432    fi
433
434    if test "$CYGPATH" = "echo" || test "$ac_cv_cygwin" = "yes"; then
435        DEPARG='"$<"'
436    else
437        DEPARG='"$(shell $(CYGPATH) $<)"'
438    fi
439
440    # set various compiler flags depending on whether we are using gcc or cl
441
442    AC_MSG_CHECKING([compiler flags])
443    if test "${GCC}" = "yes" ; then
444        if test "$do64bit" != "no" ; then
445            AC_MSG_WARN([64bit mode not supported with GCC on Windows])
446        fi
447        SHLIB_LD=""
448        SHLIB_LD_LIBS=""
449        LIBS="-lws2_32"
450        # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
451        LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32"
452        STLIB_LD='${AR} cr'
453        RC_OUT=-o
454        RC_TYPE=
455        RC_INCLUDE=--include
456        RC_DEFINE=--define
457        RES=res.o
458        MAKE_LIB="\${STLIB_LD} \[$]@"
459        POST_MAKE_LIB="\${RANLIB} \[$]@"
460        MAKE_EXE="\${CC} -o \[$]@"
461        LIBPREFIX="lib"
462
463        #if test "$ac_cv_cygwin" = "yes"; then
464        #    extra_cflags="-mno-cygwin"
465        #    extra_ldflags="-mno-cygwin"
466        #else
467        #    extra_cflags=""
468        #    extra_ldflags=""
469        #fi
470
471        if test "$ac_cv_cygwin" = "yes"; then
472          touch ac$$.c
473          if ${CC} -c -mwin32 ac$$.c >/dev/null 2>&1; then
474            case "$extra_cflags" in
475              *-mwin32*) ;;
476              *) extra_cflags="-mwin32 $extra_cflags" ;;
477            esac
478            case "$extra_ldflags" in
479              *-mwin32*) ;;
480              *) extra_ldflags="-mwin32 $extra_ldflags" ;;
481            esac
482          fi
483          rm -f ac$$.o ac$$.c
484        else
485          extra_cflags=''
486          extra_ldflags=''
487        fi
488
489        if test "${SHARED_BUILD}" = "0" ; then
490            # static
491            AC_MSG_RESULT([using static flags])
492            runtime=
493            MAKE_DLL="echo "
494            LIBSUFFIX="s\${DBGX}.a"
495            LIBFLAGSUFFIX="s\${DBGX}"
496            LIBRARIES="\${STATIC_LIBRARIES}"
497            EXESUFFIX="s\${DBGX}.exe"
498        else
499            # dynamic
500            AC_MSG_RESULT([using shared flags])
501
502            # ad-hoc check to see if CC supports -shared.
503            if "${CC}" -shared 2>&1 | egrep ': -shared not supported' >/dev/null; then
504                AC_MSG_ERROR([${CC} does not support the -shared option.
505                You will need to upgrade to a newer version of the toolchain.])
506            fi
507
508            runtime=
509            # Link with gcc since ld does not link to default libs like
510            # -luser32 and -lmsvcrt by default. Make sure CFLAGS is
511            # included so -mno-cygwin passed the correct libs to the linker.
512            SHLIB_LD='${CC} -shared ${CFLAGS}'
513            SHLIB_LD_LIBS='${LIBS}'
514            # Add SHLIB_LD_LIBS to the Make rule, not here.
515            MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \[$]@ ${extra_ldflags} \
516                -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\[$]@)"
517
518            LIBSUFFIX="\${DBGX}.a"
519            LIBFLAGSUFFIX="\${DBGX}"
520            EXESUFFIX="\${DBGX}.exe"
521            LIBRARIES="\${SHARED_LIBRARIES}"
522        fi
523        # DLLSUFFIX is separate because it is the building block for
524        # users of tclConfig.sh that may build shared or static.
525        DLLSUFFIX="\${DBGX}.dll"
526        SHLIB_SUFFIX=.dll
527
528        EXTRA_CFLAGS="${extra_cflags}"
529
530        CFLAGS_DEBUG=-g
531        CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
532        CFLAGS_WARNING="-Wall"
533        LDFLAGS_DEBUG=
534        LDFLAGS_OPTIMIZE=
535
536        # Specify the CC output file names based on the target name
537        CC_OBJNAME="-o \[$]@"
538        CC_EXENAME="-o \[$]@"
539
540        # Specify linker flags depending on the type of app being
541        # built -- Console vs. Window.
542        #
543        # ORIGINAL COMMENT:
544        # We need to pass -e _WinMain@16 so that ld will use
545        # WinMain() instead of main() as the entry point. We can't
546        # use autoconf to check for this case since it would need
547        # to run an executable and that does not work when
548        # cross compiling. Remove this -e workaround once we
549        # require a gcc that does not have this bug.
550        #
551        # MK NOTE: Tk should use a different mechanism. This causes
552        # interesting problems, such as wish dying at startup.
553        #LDFLAGS_WINDOW="-mwindows -e _WinMain@16 ${extra_ldflags}"
554        LDFLAGS_CONSOLE="-mconsole ${extra_ldflags}"
555        LDFLAGS_WINDOW="-mwindows ${extra_ldflags}"
556
557        # gcc under Windows supports only 32bit builds
558        MACHINE="X86"
559    else
560        if test "${SHARED_BUILD}" = "0" ; then
561            # static
562            AC_MSG_RESULT([using static flags])
563            runtime=-MT
564            MAKE_DLL="echo "
565            LIBSUFFIX="s\${DBGX}.lib"
566            LIBFLAGSUFFIX="s\${DBGX}"
567            LIBRARIES="\${STATIC_LIBRARIES}"
568            EXESUFFIX="s\${DBGX}.exe"
569            SHLIB_LD_LIBS=""
570        else
571            # dynamic
572            AC_MSG_RESULT([using shared flags])
573            runtime=-MD
574            # Add SHLIB_LD_LIBS to the Make rule, not here.
575            MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -out:\[$]@"
576            LIBSUFFIX="\${DBGX}.lib"
577            LIBFLAGSUFFIX="\${DBGX}"
578            EXESUFFIX="\${DBGX}.exe"
579            LIBRARIES="\${SHARED_LIBRARIES}"
580            SHLIB_LD_LIBS='${LIBS}'
581        fi
582        # DLLSUFFIX is separate because it is the building block for
583        # users of tclConfig.sh that may build shared or static.
584        DLLSUFFIX="\${DBGX}.dll"
585
586        # This is a 2-stage check to make sure we have the 64-bit SDK
587        # We have to know where the SDK is installed.
588        # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
589        # MACHINE is IX86 for LINK, but this is used by the manifest,
590        # which requires x86|amd64|ia64.
591        MACHINE="X86"
592        if test "$do64bit" != "no" ; then
593            if test "x${MSSDK}x" = "xx" ; then
594                MSSDK="C:/Progra~1/Microsoft Platform SDK"
595            fi
596            MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'`
597            PATH64=""
598            case "$do64bit" in
599              amd64|x64|yes)
600                MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
601                PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
602                ;;
603              ia64)
604                MACHINE="IA64"
605                PATH64="${MSSDK}/Bin/Win64"
606                ;;
607            esac
608            if test ! -d "${PATH64}" ; then
609                AC_MSG_WARN([Could not find 64-bit $MACHINE SDK to enable 64bit mode])
610                AC_MSG_WARN([Ensure latest Platform SDK is installed])
611                do64bit="no"
612            else
613                AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
614            fi
615        fi
616
617        LIBS="user32.lib advapi32.lib ws2_32.lib"
618        if test "$do64bit" != "no" ; then
619            # The space-based-path will work for the Makefile, but will
620            # not work if AC_TRY_COMPILE is called.  TEA has the
621            # TEA_PATH_NOSPACE to avoid this issue.
622            CC="\"${PATH64}/cl.exe\" -I\"${MSSDK}/Include\" \
623                -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\""
624            RC="\"${MSSDK}/bin/rc.exe\""
625            CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
626            # Do not use -O2 for Win64 - this has proved buggy in code gen.
627            CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
628            lflags="-nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
629            LINKBIN="\"${PATH64}/link.exe\""
630            # Avoid 'unresolved external symbol __security_cookie' errors.
631            # c.f. http://support.microsoft.com/?id=894573
632            LIBS="$LIBS bufferoverflowU.lib"
633        else
634            RC="rc"
635            # -Od - no optimization
636            # -WX - warnings as errors
637            CFLAGS_DEBUG="-nologo -Z7 -Od -WX ${runtime}d"
638            # -O2 - create fast code (/Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy)
639            CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
640            lflags="-nologo"
641            LINKBIN="link"
642        fi
643
644        if test "$doWince" != "no" ; then
645            # Set defaults for common evc4/PPC2003 setup
646            # Currently Tcl requires 300+, possibly 420+ for sockets
647            CEVERSION=420;              # could be 211 300 301 400 420 ...
648            TARGETCPU=ARMV4;    # could be ARMV4 ARM MIPS SH3 X86 ...
649            ARCH=ARM;           # could be ARM MIPS X86EM ...
650            PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002"
651            if test "$doWince" != "yes"; then
652                # If !yes then the user specified something
653                # Reset ARCH to allow user to skip specifying it
654                ARCH=
655                eval `echo $doWince | awk -F "," '{ \
656        if (length([$]1)) { printf "CEVERSION=\"%s\"\n", [$]1; \
657        if ([$]1 < 400)   { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \
658        if (length([$]2)) { printf "TARGETCPU=\"%s\"\n", toupper([$]2) }; \
659        if (length([$]3)) { printf "ARCH=\"%s\"\n", toupper([$]3) }; \
660        if (length([$]4)) { printf "PLATFORM=\"%s\"\n", [$]4 }; \
661                }'`
662                if test "x${ARCH}" = "x" ; then
663                    ARCH=$TARGETCPU;
664                fi
665            fi
666            OSVERSION=WCE$CEVERSION;
667            if test "x${WCEROOT}" = "x" ; then
668                WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0"
669                if test ! -d "${WCEROOT}" ; then
670                    WCEROOT="C:/Program Files/Microsoft eMbedded Tools"
671                fi
672            fi
673            if test "x${SDKROOT}" = "x" ; then
674                SDKROOT="C:/Program Files/Windows CE Tools"
675                if test ! -d "${SDKROOT}" ; then
676                    SDKROOT="C:/Windows CE Tools"
677                fi
678            fi
679            # The space-based-path will work for the Makefile, but will
680            # not work if AC_TRY_COMPILE is called.
681            WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'`
682            SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'`
683            CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'`
684            if test ! -d "${CELIB_DIR}/inc"; then
685                AC_MSG_ERROR([Invalid celib directory "${CELIB_DIR}"])
686            fi
687            if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"\
688                -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
689                AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]])
690            else
691                CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include"
692                if test -d "${CEINCLUDE}/${TARGETCPU}" ; then
693                    CEINCLUDE="${CEINCLUDE}/${TARGETCPU}"
694                fi
695                CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"
696            fi
697        fi
698
699        if test "$doWince" != "no" ; then
700            CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin"
701            if test "${TARGETCPU}" = "X86"; then
702                CC="${CEBINROOT}/cl.exe"
703            else
704                CC="${CEBINROOT}/cl${ARCH}.exe"
705            fi
706            CC="\"${CC}\" -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
707            RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
708            arch=`echo ${ARCH} | awk '{print tolower([$]0)}'`
709            defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _DLL _WINDOWS"
710            for i in $defs ; do
711                AC_DEFINE_UNQUOTED($i)
712            done
713#           if test "${ARCH}" = "X86EM"; then
714#               AC_DEFINE_UNQUOTED(_WIN32_WCE_EMULATION)
715#           fi
716            AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION)
717            AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION)
718            CFLAGS_DEBUG="-nologo -Zi -Od"
719            CFLAGS_OPTIMIZE="-nologo -O2"
720            lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'`
721            lflags="-nodefaultlib -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo"
722            LINKBIN="\"${CEBINROOT}/link.exe\""
723            AC_SUBST(CELIB_DIR)
724            if test "${CEVERSION}" -lt 400 ; then
725                LIBS="coredll.lib corelibc.lib winsock.lib"
726            else
727                LIBS="coredll.lib corelibc.lib ws2.lib"
728            fi
729            # celib currently stuck at wce300 status
730            #LIBS="$LIBS \${CELIB_DIR}/wince-${ARCH}-pocket-${OSVERSION}-release/celib.lib"
731            LIBS="$LIBS \"\${CELIB_DIR}/wince-${ARCH}-pocket-wce300-release/celib.lib\""
732            LIBS_GUI="commctrl.lib commdlg.lib"
733        else
734            LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib"
735        fi
736
737        SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}"
738        # link -lib only works when -lib is the first arg
739        STLIB_LD="${LINKBIN} -lib ${lflags}"
740        RC_OUT=-fo
741        RC_TYPE=-r
742        RC_INCLUDE=-i
743        RC_DEFINE=-d
744        RES=res
745        MAKE_LIB="\${STLIB_LD} -out:\[$]@"
746        POST_MAKE_LIB=
747        MAKE_EXE="\${CC} -Fe\[$]@"
748        LIBPREFIX=""
749
750        EXTRA_CFLAGS=""
751        CFLAGS_WARNING="-W3"
752        LDFLAGS_DEBUG="-debug:full"
753        LDFLAGS_OPTIMIZE="-release"
754       
755        # Specify the CC output file names based on the target name
756        CC_OBJNAME="-Fo\[$]@"
757        CC_EXENAME="-Fe\"\$(shell \$(CYGPATH) '\[$]@')\""
758
759        # Specify linker flags depending on the type of app being
760        # built -- Console vs. Window.
761        if test "$doWince" != "no" -a "${TARGETCPU}" != "X86"; then
762            LDFLAGS_CONSOLE="-link ${lflags}"
763            LDFLAGS_WINDOW=${LDFLAGS_CONSOLE}
764        else
765            LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}"
766            LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
767        fi
768    fi
769
770    if test "$do64bit" != "no" ; then
771        AC_DEFINE(TCL_CFG_DO64BIT)
772    fi
773
774    # DL_LIBS is empty, but then we match the Unix version
775    AC_SUBST(DL_LIBS)
776    AC_SUBST(CFLAGS_DEBUG)
777    AC_SUBST(CFLAGS_OPTIMIZE)
778    AC_SUBST(CFLAGS_WARNING)
779])
780
781#------------------------------------------------------------------------
782# SC_WITH_TCL --
783#
784#       Location of the Tcl build directory.
785#
786# Arguments:
787#       none
788#
789# Results:
790#
791#       Adds the following arguments to configure:
792#               --with-tcl=...
793#
794#       Defines the following vars:
795#               TCL_BIN_DIR     Full path to the tcl build dir.
796#------------------------------------------------------------------------
797
798AC_DEFUN([SC_WITH_TCL], [
799    if test -d ../../tcl8.5$1/win;  then
800        TCL_BIN_DEFAULT=../../tcl8.5$1/win
801    else
802        TCL_BIN_DEFAULT=../../tcl8.5/win
803    fi
804   
805    AC_ARG_WITH(tcl, [  --with-tcl=DIR          use Tcl 8.5 binaries from DIR],
806            TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DEFAULT; pwd`)
807    if test ! -d $TCL_BIN_DIR; then
808        AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
809    fi
810    if test ! -f $TCL_BIN_DIR/Makefile; then
811        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?)
812    else
813        echo "building against Tcl binaries in: $TCL_BIN_DIR"
814    fi
815    AC_SUBST(TCL_BIN_DIR)
816])
817
818#------------------------------------------------------------------------
819# SC_PROG_TCLSH
820#       Locate a tclsh shell installed on the system path. This macro
821#       will only find a Tcl shell that already exists on the system.
822#       It will not find a Tcl shell in the Tcl build directory or
823#       a Tcl shell that has been installed from the Tcl build directory.
824#       If a Tcl shell can't be located on the PATH, then TCLSH_PROG will
825#       be set to "". Extensions should take care not to create Makefile
826#       rules that are run by default and depend on TCLSH_PROG. An
827#       extension can't assume that an executable Tcl shell exists at
828#       build time.
829#
830# Arguments
831#       none
832#
833# Results
834#       Subst's the following values:
835#               TCLSH_PROG
836#------------------------------------------------------------------------
837
838AC_DEFUN([SC_PROG_TCLSH], [
839    AC_MSG_CHECKING([for tclsh])
840
841    AC_CACHE_VAL(ac_cv_path_tclsh, [
842        search_path=`echo ${PATH} | sed -e 's/:/ /g'`
843        for dir in $search_path ; do
844            for j in `ls -r $dir/tclsh[[8-9]]*.exe 2> /dev/null` \
845                    `ls -r $dir/tclsh* 2> /dev/null` ; do
846                if test x"$ac_cv_path_tclsh" = x ; then
847                    if test -f "$j" ; then
848                        ac_cv_path_tclsh=$j
849                        break
850                    fi
851                fi
852            done
853        done
854    ])
855
856    if test -f "$ac_cv_path_tclsh" ; then
857        TCLSH_PROG="$ac_cv_path_tclsh"
858        AC_MSG_RESULT($TCLSH_PROG)
859    else
860        # It is not an error if an installed version of Tcl can't be located.
861        TCLSH_PROG=""
862        AC_MSG_RESULT([No tclsh found on PATH])
863    fi
864    AC_SUBST(TCLSH_PROG)
865])
866
867#------------------------------------------------------------------------
868# SC_BUILD_TCLSH
869#       Determine the fully qualified path name of the tclsh executable
870#       in the Tcl build directory. This macro will correctly determine
871#       the name of the tclsh executable even if tclsh has not yet
872#       been built in the build directory. The build tclsh must be used
873#       when running tests from an extension build directory. It is not
874#       correct to use the TCLSH_PROG in cases like this.
875#
876# Arguments
877#       none
878#
879# Results
880#       Subst's the following values:
881#               BUILD_TCLSH
882#------------------------------------------------------------------------
883
884AC_DEFUN([SC_BUILD_TCLSH], [
885    AC_MSG_CHECKING([for tclsh in Tcl build directory])
886    BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}
887    AC_MSG_RESULT($BUILD_TCLSH)
888    AC_SUBST(BUILD_TCLSH)
889])
890
891#--------------------------------------------------------------------
892# SC_TCL_CFG_ENCODING   TIP #59
893#
894#       Declare the encoding to use for embedded configuration information.
895#
896# Arguments:
897#       None.
898#
899# Results:
900#       Might append to the following vars:
901#               DEFS    (implicit)
902#
903#       Will define the following vars:
904#               TCL_CFGVAL_ENCODING
905#
906#--------------------------------------------------------------------
907
908AC_DEFUN([SC_TCL_CFG_ENCODING], [
909    AC_ARG_WITH(encoding, [  --with-encoding              encoding for configuration values], with_tcencoding=${withval})
910
911    if test x"${with_tcencoding}" != x ; then
912        AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}")
913    else
914        # Default encoding on windows is not "iso8859-1"
915        AC_DEFINE(TCL_CFGVAL_ENCODING,"cp1252")
916    fi
917])
Note: See TracBrowser for help on using the repository browser.