summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortreectrl <treectrl>2008-02-09 03:46:01 (GMT)
committertreectrl <treectrl>2008-02-09 03:46:01 (GMT)
commitcc0ebd8c98554e1de39557862b280a3418d34044 (patch)
treee56561061f8515dfc82e79e8f7ab1d191ff92920
parent7a1e077388a7641702c89397641c28fb3c130536 (diff)
downloadtktreectrl-cc0ebd8c98554e1de39557862b280a3418d34044.zip
tktreectrl-cc0ebd8c98554e1de39557862b280a3418d34044.tar.gz
tktreectrl-cc0ebd8c98554e1de39557862b280a3418d34044.tar.bz2
Added a Win32 .manifest file and associated .rc file to load version 6 of comctl32.dll for visual themes. Added winrc.m4 for rules to compile the .rc file. Changed the Makefile to merge in any Microsoft-compiler-created manifest file (for picking the correct MSVCRT). Changed the theme init code to properly check that comctl32.dll version 6 is actually being used.
-rw-r--r--Makefile.in19
-rw-r--r--aclocal.m43
-rw-r--r--configure187
-rw-r--r--configure.ac25
-rw-r--r--generic/tkTreeTheme.c133
-rw-r--r--treectrl.dll.manifest.in15
-rw-r--r--treectrl.rc12
-rw-r--r--winrc.m4102
8 files changed, 485 insertions, 11 deletions
diff --git a/Makefile.in b/Makefile.in
index 4352ee3..c13a01f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: Makefile.in,v 1.13 2008/01/22 20:43:28 hobbs2 Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.14 2008/02/09 03:46:02 treectrl Exp $
#========================================================================
# Edit the following few lines when writing a new extension
@@ -248,12 +248,24 @@ depend:
# The $(PKG_OBJECTS) objects are created and linked into the final
# library. In most cases these object files will correspond to the
# source files above.
+#
+# NOTE regarding the manifest(s): When building on a non-Windows box the
+# treectrlNN.dll.manifest file should not exist. When building with
+# MingW GCC the manifest will also not exist. Only when building with
+# a Microsoft compiler that auto-generates a manifest (to pick the correct
+# MSVCRT runtime) will $@.manifest exist; in this case mt.exe should
+# also exist. If mt.exe is used there is actually no need for treectrl.rc
+# to include treectrl.dll.manifest since mt.exe will clobber that resource
+# with the merged manifests.
#========================================================================
$(PKG_LIB_FILE): $(PKG_OBJECTS)
-rm -f $(PKG_LIB_FILE)
${MAKE_LIB}
$(RANLIB) $(PKG_LIB_FILE)
+ if test -f $@.manifest; then \
+ mt -nologo -manifest $@.manifest treectrl.dll.manifest "-outputresource:$@;#2"; \
+ fi;
#========================================================================
# In the following lines, $(srcdir) refers to the toplevel directory
@@ -274,6 +286,9 @@ VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win
.c.@OBJEXT@:
$(COMPILE) -c `@CYGPATH@ $<` -o $@
+.rc.@RES@:
+ @RC@ @RC_OUT@ $@ @RC_INCLUDE@ "$(srcdir)" @RC_DEPARG@
+
#========================================================================
# Create the pkgIndex.tcl file.
#========================================================================
@@ -506,6 +521,8 @@ install-bin-binaries:
done
.SUFFIXES: .c .$(OBJEXT)
+.SUFFIXES: .@RES@
+.SUFFIXES: .rc
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
diff --git a/aclocal.m4 b/aclocal.m4
index 0b05739..5e467b5 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -7,3 +7,6 @@ builtin(include,tclconfig/tcl.m4)
#
# Add here whatever m4 macros you want to define for your package
#
+
+builtin(include,winrc.m4)
+
diff --git a/configure b/configure
index 520777c..3cadb5e 100644
--- a/configure
+++ b/configure
@@ -705,6 +705,14 @@ TK_PLATFORM_DIR_NATIVE
TK_INCLUDES
XMKMF
subdirs
+RC
+RC_OUT
+RC_TYPE
+RC_INCLUDE
+RC_DEFINE
+RC_DEPARG
+RES
+MACHINE
CLEANFILES
TCL_THREADS
SHARED_BUILD
@@ -8406,12 +8414,14 @@ esac
# your system.
#--------------------------------------------------------------------
+OUTPUTFILES=Makefile
+
if test "${TEA_PLATFORM}" = "windows" ; then
cat >>confdefs.h <<\_ACEOF
#define BUILD_treectrl 1
_ACEOF
- CLEANFILES="pkgIndex.tcl *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
+ CLEANFILES="pkgIndex.tcl *.manifest *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
vars="gdi32.lib user32.lib"
for i in $vars; do
@@ -8435,6 +8445,167 @@ fi
subdirs="$subdirs shellicon"
fi
+
+ # Find rc.exe or windres.exe.
+ # Defined in winrc.m4.
+
+
+# AC_MSG_CHECKING([for windows resource compiler])
+ if test "${GCC}" = "yes" ; then
+ # Extract the first word of "windres", so it can be a program name with args.
+set dummy windres; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_RC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$RC"; then
+ ac_cv_prog_RC="$RC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_RC="windres"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+RC=$ac_cv_prog_RC
+if test -n "$RC"; then
+ { echo "$as_me:$LINENO: result: $RC" >&5
+echo "${ECHO_T}$RC" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ if test "${RC}" = "" ; then
+ { { echo "$as_me:$LINENO: error: Required resource tool 'windres' not found on PATH." >&5
+echo "$as_me: error: Required resource tool 'windres' not found on PATH." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ RC_OUT=-o
+ RC_TYPE=
+ RC_INCLUDE=--include
+ RC_DEFINE=--define
+ RC_DEPARG='"$<"'
+ RES=res.o
+
+ # Check for a bug in gcc's windres that causes the
+ # compile to fail when a Windows native path is
+ # passed into windres. The mingw toolchain requires
+ # Windows native paths while Cygwin should work
+ # with both. Avoid the bug by passing a POSIX
+ # path when using the Cygwin toolchain.
+
+ if test "$ac_cv_cygwin" = "yes"; then
+ RC_DEPARG='"$<"'
+ elif test "$CYGPATH" != "echo" ; then
+ conftest=/tmp/conftest.rc
+ echo "STRINGTABLE BEGIN" > $conftest
+ echo "101 \"name\"" >> $conftest
+ echo "END" >> $conftest
+
+ { echo "$as_me:$LINENO: checking for Windows native path bug in windres" >&5
+echo $ECHO_N "checking for Windows native path bug in windres... $ECHO_C" >&6; }
+ cyg_conftest=`$CYGPATH $conftest`
+ if { ac_try='$RC -o conftest.res.o $cyg_conftest'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } ; then
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+ RC_DEPARG='"$(shell $(CYGPATH) $<)"'
+ else
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+ fi
+ conftest=
+ cyg_conftest=
+ fi
+
+ else
+ if test "$do64bit" != "no" ; then
+ RC="\"${MSSDK}/bin/rc.exe\""
+ elif test "$doWince" != "no" ; then
+ RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
+ else
+ RC="rc"
+ fi
+ RC_OUT=-fo
+ RC_TYPE=-r
+ RC_INCLUDE=-i
+ RC_DEFINE=-d
+ RC_DEPARG=='"$<"'
+ RES=res
+ fi
+
+
+
+
+
+
+
+
+
+
+ # X86|AMD64|IA64 for manifest
+
+
+ # Create treectrl.dll.manifest from treectrl.dll.manifest.in.
+ # treectrl.dll.manifest is included by treectrl.rc.
+ # If building with a Microsoft compiler that generates
+ # treectrlNN.dll.manifest (to pick the correct MSVCRT runtime) then
+ # that manifest is merged with mine using mt.exe (see the Makefile
+ # rule for PKG_LIB_FILE).
+ OUTPUTFILES="Makefile treectrl.dll.manifest"
+
+
+ vars="treectrl.rc"
+ for i in $vars; do
+ case $i in
+ \$*)
+ # allow $-var names
+ PKG_SOURCES="$PKG_SOURCES $i"
+ PKG_OBJECTS="$PKG_OBJECTS $i"
+ ;;
+ *)
+ # check for existence - allows for generic/win/unix VPATH
+ if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
+ -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
+ ; then
+ { { echo "$as_me:$LINENO: error: could not find source file '$i'" >&5
+echo "$as_me: error: could not find source file '$i'" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ PKG_SOURCES="$PKG_SOURCES $i"
+ # this assumes it is in a VPATH dir
+ i=`basename $i`
+ # handle user calling this before or after TEA_SETUP_COMPILER
+ if test x"${RES}" != x ; then
+ j="`echo $i | sed -e 's/\.[^.]*$//'`.${RES}"
+ else
+ j="`echo $i | sed -e 's/\.[^.]*$//'`.\${RES}"
+ fi
+ PKG_OBJECTS="$PKG_OBJECTS $j"
+ ;;
+ esac
+ done
+
+
+
else
CLEANFILES="pkgIndex.tcl"
fi
@@ -12134,7 +12305,7 @@ echo "${ECHO_T}${WISH_PROG}" >&6; }
# which require substituting th AC variables in. Include these here.
#--------------------------------------------------------------------
-ac_config_files="$ac_config_files Makefile"
+ac_config_files="$ac_config_files $OUTPUTFILES"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -12691,7 +12862,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
- "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "$OUTPUTFILES") CONFIG_FILES="$CONFIG_FILES $OUTPUTFILES" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -12901,6 +13072,14 @@ TK_PLATFORM_DIR_NATIVE!$TK_PLATFORM_DIR_NATIVE$ac_delim
TK_INCLUDES!$TK_INCLUDES$ac_delim
XMKMF!$XMKMF$ac_delim
subdirs!$subdirs$ac_delim
+RC!$RC$ac_delim
+RC_OUT!$RC_OUT$ac_delim
+RC_TYPE!$RC_TYPE$ac_delim
+RC_INCLUDE!$RC_INCLUDE$ac_delim
+RC_DEFINE!$RC_DEFINE$ac_delim
+RC_DEPARG!$RC_DEPARG$ac_delim
+RES!$RES$ac_delim
+MACHINE!$MACHINE$ac_delim
CLEANFILES!$CLEANFILES$ac_delim
TCL_THREADS!$TCL_THREADS$ac_delim
SHARED_BUILD!$SHARED_BUILD$ac_delim
@@ -12929,7 +13108,7 @@ WISH_PROG!$WISH_PROG$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 37; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 45; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.ac b/configure.ac
index e96871d..7068b3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tcl installation
dnl to configure the system for the local environment.
#
-# RCS: @(#) $Id: configure.ac,v 1.22 2008/01/22 00:03:58 treectrl Exp $
+# RCS: @(#) $Id: configure.ac,v 1.23 2008/02/09 03:46:02 treectrl Exp $
#-----------------------------------------------------------------------
# Sample configure.in for Tcl Extensions.
@@ -117,9 +117,11 @@ AC_C_BIGENDIAN
# your system.
#--------------------------------------------------------------------
+OUTPUTFILES=Makefile
+
if test "${TEA_PLATFORM}" = "windows" ; then
AC_DEFINE(BUILD_treectrl)
- CLEANFILES="pkgIndex.tcl *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
+ CLEANFILES="pkgIndex.tcl *.manifest *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
TEA_ADD_LIBS([gdi32.lib user32.lib])
AC_ARG_ENABLE(shellicon,
@@ -129,6 +131,23 @@ if test "${TEA_PLATFORM}" = "windows" ; then
if test "$tcl_ok" = "yes" ; then
AC_CONFIG_SUBDIRS(shellicon)
fi
+
+ # Find rc.exe or windres.exe.
+ # Defined in winrc.m4.
+ TREECTRL_PROG_RC
+
+ # X86|AMD64|IA64 for manifest
+ AC_SUBST(MACHINE)
+
+ # Create treectrl.dll.manifest from treectrl.dll.manifest.in.
+ # treectrl.dll.manifest is included by treectrl.rc.
+ # If building with a Microsoft compiler that generates
+ # treectrlNN.dll.manifest (to pick the correct MSVCRT runtime) then
+ # that manifest is merged with mine using mt.exe (see the Makefile
+ # rule for PKG_LIB_FILE).
+ OUTPUTFILES="Makefile treectrl.dll.manifest"
+
+ TREECTRL_ADD_RC([treectrl.rc])
else
CLEANFILES="pkgIndex.tcl"
fi
@@ -204,4 +223,4 @@ TEA_PROG_WISH
# which require substituting th AC variables in. Include these here.
#--------------------------------------------------------------------
-AC_OUTPUT([Makefile])
+AC_OUTPUT([$OUTPUTFILES])
diff --git a/generic/tkTreeTheme.c b/generic/tkTreeTheme.c
index d86fe97..ca3228d 100644
--- a/generic/tkTreeTheme.c
+++ b/generic/tkTreeTheme.c
@@ -3,13 +3,14 @@
*
* This module implements platform-specific visual themes.
*
- * Copyright (c) 2008 Tim Baker
+ * Copyright (c) 2006-2008 Tim Baker
*
- * RCS: @(#) $Id: tkTreeTheme.c,v 1.22 2008/01/22 01:03:02 treectrl Exp $
+ * RCS: @(#) $Id: tkTreeTheme.c,v 1.23 2008/02/09 03:46:02 treectrl Exp $
*/
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
#define WINVER 0x0501 /* Cygwin */
+#define _WIN32_WINNT 0x0501 /* ACTCTX stuff */
#endif
#include "tkTreeCtrl.h"
@@ -113,6 +114,126 @@ static XPThemeProcs *procs = NULL;
static XPThemeData *appThemeData = NULL;
TCL_DECLARE_MUTEX(themeMutex)
+/* Functions imported from kernel32.dll requiring windows XP or greater. */
+/* But I already link to GetVersionEx so is this importing needed? */
+typedef HANDLE (STDAPICALLTYPE CreateActCtxAProc)(PCACTCTXA pActCtx);
+typedef BOOL (STDAPICALLTYPE ActivateActCtxProc)(HANDLE hActCtx, ULONG_PTR *lpCookie);
+typedef BOOL (STDAPICALLTYPE DeactivateActCtxProc)(DWORD dwFlags, ULONG_PTR ulCookie);
+typedef VOID (STDAPICALLTYPE ReleaseActCtxProc)(HANDLE hActCtx);
+
+typedef struct
+{
+ CreateActCtxAProc *CreateActCtxA;
+ ActivateActCtxProc *ActivateActCtx;
+ DeactivateActCtxProc *DeactivateActCtx;
+ ReleaseActCtxProc *ReleaseActCtx;
+} ActCtxProcs;
+
+static ActCtxProcs *
+GetActCtxProcs(void)
+{
+ HINSTANCE hInst;
+ ActCtxProcs *procs = (ActCtxProcs *) ckalloc(sizeof(ActCtxProcs));
+
+ hInst = LoadLibrary("kernel32.dll"); // FIXME: leak?
+ if (hInst != 0)
+ {
+ #define LOADPROC(name) \
+ (0 != (procs->name = (name ## Proc *)GetProcAddress(hInst, #name) ))
+
+ if (LOADPROC(CreateActCtxA) &&
+ LOADPROC(ActivateActCtx) &&
+ LOADPROC(DeactivateActCtx) &&
+ LOADPROC(ReleaseActCtx))
+ {
+ return procs;
+ }
+
+#undef LOADPROC
+ }
+
+ ckfree((char*)procs);
+ return NULL;
+}
+
+/* Return the HMODULE for this treectrl.dll. */
+static HMODULE
+GetMyHandle(void)
+{
+ HMODULE hModule = NULL;
+
+ /* FIXME: Only >=NT so I shouldn't link to it? But I already linked to
+ * GetVersionEx so will it run on 95/98? */
+ GetModuleHandleEx(
+ GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ (LPCTSTR)&appThemeData,
+ &hModule);
+ return hModule;
+}
+
+static HANDLE
+ActivateManifestContext(ActCtxProcs *procs, ULONG_PTR *ulpCookie)
+{
+ ACTCTXA actctx;
+ HANDLE hCtx;
+#if 1
+ char myPath[1024];
+ DWORD len;
+
+ if (procs == NULL)
+ return INVALID_HANDLE_VALUE;
+
+ len = GetModuleFileName(GetMyHandle(),myPath,1024);
+ myPath[len] = 0;
+
+ ZeroMemory(&actctx, sizeof(actctx));
+ actctx.cbSize = sizeof(actctx);
+ actctx.lpSource = myPath;
+ actctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
+#else
+
+ if (procs == NULL)
+ return INVALID_HANDLE_VALUE;
+
+ ZeroMemory(&actctx, sizeof(actctx));
+ actctx.cbSize = sizeof(actctx);
+ actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID;
+ actctx.hModule = GetMyHandle();
+#endif
+ actctx.lpResourceName = MAKEINTRESOURCE(2);
+
+ hCtx = procs->CreateActCtxA(&actctx);
+ if (hCtx == INVALID_HANDLE_VALUE)
+ {
+ char msg[1024];
+ DWORD err = GetLastError();
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
+ FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)msg,
+ sizeof(msg), 0);
+ return INVALID_HANDLE_VALUE;
+ }
+
+ if (procs->ActivateActCtx(hCtx, ulpCookie))
+ return hCtx;
+
+ return INVALID_HANDLE_VALUE;
+}
+
+static void
+DeactivateManifestContext(ActCtxProcs *procs, HANDLE hCtx, ULONG_PTR ulpCookie)
+{
+ if (procs == NULL)
+ return;
+
+ if (hCtx != INVALID_HANDLE_VALUE)
+ {
+ procs->DeactivateActCtx(0, ulpCookie);
+ procs->ReleaseActCtx(hCtx);
+ }
+
+ ckfree((char*)procs);
+}
+
/* http://www.manbu.net/Lib/En/Class5/Sub16/1/29.asp */
static int
ComCtlVersionOK(void)
@@ -121,8 +242,14 @@ ComCtlVersionOK(void)
typedef HRESULT (STDAPICALLTYPE DllGetVersionProc)(DLLVERSIONINFO *);
DllGetVersionProc *pDllGetVersion;
int result = FALSE;
+ ActCtxProcs *procs;
+ HANDLE hCtx;
+ ULONG_PTR ulpCookie;
+ procs = GetActCtxProcs();
+ hCtx = ActivateManifestContext(procs, &ulpCookie);
handle = LoadLibrary("comctl32.dll");
+ DeactivateManifestContext(procs, hCtx, ulpCookie);
if (handle == NULL)
return FALSE;
pDllGetVersion = (DllGetVersionProc *) GetProcAddress(handle,
diff --git a/treectrl.dll.manifest.in b/treectrl.dll.manifest.in
new file mode 100644
index 0000000..37e5285
--- /dev/null
+++ b/treectrl.dll.manifest.in
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<dependency>
+<dependentAssembly>
+<assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="@MACHINE@"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+/>
+</dependentAssembly>
+</dependency>
+</assembly>
diff --git a/treectrl.rc b/treectrl.rc
new file mode 100644
index 0000000..82c76aa
--- /dev/null
+++ b/treectrl.rc
@@ -0,0 +1,12 @@
+//
+// This enables themed headers in XP by trying to use comctl32 v6.
+//
+
+#ifndef RT_MANIFEST
+#define RT_MANIFEST 24
+#endif
+#ifndef ISOLATIONAWARE_MANIFEST_RESOURCE_ID
+#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2
+#endif
+ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "treectrl.dll.manifest"
+
diff --git a/winrc.m4 b/winrc.m4
new file mode 100644
index 0000000..39dd55c
--- /dev/null
+++ b/winrc.m4
@@ -0,0 +1,102 @@
+# This was taken from Tk's configure.in and tcl.m4.
+AC_DEFUN([TREECTRL_PROG_RC], [
+
+# AC_MSG_CHECKING([for windows resource compiler])
+ if test "${GCC}" = "yes" ; then
+ AC_CHECK_PROG(RC, windres, windres)
+ if test "${RC}" = "" ; then
+ AC_MSG_ERROR([Required resource tool 'windres' not found on PATH.])
+ fi
+ RC_OUT=-o
+ RC_TYPE=
+ RC_INCLUDE=--include
+ RC_DEFINE=--define
+ RC_DEPARG='"$<"'
+ RES=res.o
+
+ # Check for a bug in gcc's windres that causes the
+ # compile to fail when a Windows native path is
+ # passed into windres. The mingw toolchain requires
+ # Windows native paths while Cygwin should work
+ # with both. Avoid the bug by passing a POSIX
+ # path when using the Cygwin toolchain.
+
+ if test "$ac_cv_cygwin" = "yes"; then
+ RC_DEPARG='"$<"'
+ elif test "$CYGPATH" != "echo" ; then
+ conftest=/tmp/conftest.rc
+ echo "STRINGTABLE BEGIN" > $conftest
+ echo "101 \"name\"" >> $conftest
+ echo "END" >> $conftest
+
+ AC_MSG_CHECKING([for Windows native path bug in windres])
+ cyg_conftest=`$CYGPATH $conftest`
+ if AC_TRY_COMMAND($RC -o conftest.res.o $cyg_conftest) ; then
+ AC_MSG_RESULT([no])
+ RC_DEPARG='"$(shell $(CYGPATH) $<)"'
+ else
+ AC_MSG_RESULT([yes])
+ fi
+ conftest=
+ cyg_conftest=
+ fi
+
+ else
+ if test "$do64bit" != "no" ; then
+ RC="\"${MSSDK}/bin/rc.exe\""
+ elif test "$doWince" != "no" ; then
+ RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
+ else
+ RC="rc"
+ fi
+ RC_OUT=-fo
+ RC_TYPE=-r
+ RC_INCLUDE=-i
+ RC_DEFINE=-d
+ RC_DEPARG=='"$<"'
+ RES=res
+ fi
+
+ AC_SUBST(RC)
+ AC_SUBST(RC_OUT)
+ AC_SUBST(RC_TYPE)
+ AC_SUBST(RC_INCLUDE)
+ AC_SUBST(RC_DEFINE)
+ AC_SUBST(RC_DEPARG)
+ AC_SUBST(RES)
+])
+
+# This is basically TEA_ADD_SOURCES but sets the object file extension to
+# $RES instead of $OBJ.
+AC_DEFUN([TREECTRL_ADD_RC], [
+ vars="$@"
+ for i in $vars; do
+ case $i in
+ [\$]*)
+ # allow $-var names
+ PKG_SOURCES="$PKG_SOURCES $i"
+ PKG_OBJECTS="$PKG_OBJECTS $i"
+ ;;
+ *)
+ # check for existence - allows for generic/win/unix VPATH
+ if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
+ -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
+ ; then
+ AC_MSG_ERROR([could not find source file '$i'])
+ fi
+ PKG_SOURCES="$PKG_SOURCES $i"
+ # this assumes it is in a VPATH dir
+ i=`basename $i`
+ # handle user calling this before or after TEA_SETUP_COMPILER
+ if test x"${RES}" != x ; then
+ j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${RES}"
+ else
+ j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${RES}"
+ fi
+ PKG_OBJECTS="$PKG_OBJECTS $j"
+ ;;
+ esac
+ done
+ AC_SUBST(PKG_SOURCES)
+ AC_SUBST(PKG_OBJECTS)
+])