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