[Libreoffice-commits] core.git: 10 commits - config_host.mk.in configure.ac cppunit/ExternalPackage_cppunit.mk cppunit/ExternalProject_cppunit.mk curl/curl-7.26.0_win.patch curl/ExternalProject_curl.mk embedserv/Library_emser.mk extensions/Library_oleautobridge.mk extensions/Library_so_activex.mk extensions/Library_so_activex_x64.mk extensions/source external/Module_external.mk external/Package_msvc_dlls_debug.mk icu/ExternalPackage_icu.mk icu/ExternalProject_icu.mk lcms2/ExternalPackage_lcms2.mk lcms2/ExternalProject_lcms2.mk liborcus/ExternalProject_liborcus.mk libxml2/ExternalProject_xml2.mk libxmlsec/xmlsec1-vc.patch libxslt/ExternalProject_xslt.mk lpsolve/ExternalProject_lpsolve.mk lpsolve/lp_solve_5.5-windows.patch nss/ExternalProject_nss.mk nss/nss.patch openssl/opensslwnt.patch python3/ExternalPackage_python3.mk python3/ExternalProject_python3.mk redland/redland redland/UnpackedTarball_redland.mk RepositoryExternal.mk RepositoryFixes.mk sal/osl scp2/InstallModule_ooo.mk scp2/Insta llModule_python.mk scp2/source setup_native/Library_instooofiltmsi.mk setup_native/Library_qslnkmsi.mk setup_native/Library_reg4allmsdoc.mk setup_native/Library_regactivex.mk setup_native/Library_regpatchactivex.mk setup_native/Library_sdqsmsi.mk setup_native/Library_sellangmsi.mk setup_native/Library_shlxtmsi.mk setup_native/Library_sn_tools.mk setup_native/StaticLibrary_quickstarter.mk setup_native/StaticLibrary_seterror.mk solenv/gbuild solenv/gcc-wrappers

Michael Stahl mstahl at redhat.com
Mon Apr 15 06:33:01 PDT 2013


 RepositoryExternal.mk                                     |    2 
 RepositoryFixes.mk                                        |    8 ++-
 config_host.mk.in                                         |    3 +
 configure.ac                                              |   18 ++++++
 cppunit/ExternalPackage_cppunit.mk                        |    6 +-
 cppunit/ExternalProject_cppunit.mk                        |   10 +--
 curl/ExternalProject_curl.mk                              |    3 -
 curl/curl-7.26.0_win.patch                                |    9 +++
 embedserv/Library_emser.mk                                |    8 ---
 extensions/Library_oleautobridge.mk                       |    8 ---
 extensions/Library_so_activex.mk                          |    8 ---
 extensions/Library_so_activex_x64.mk                      |    8 ---
 extensions/source/activex/SOActionsApproval.h             |    4 -
 extensions/source/activex/SOActiveX.h                     |    3 -
 extensions/source/activex/SOComWindowPeer.h               |    3 -
 extensions/source/activex/SODispatchInterceptor.h         |    3 -
 extensions/source/activex/StdAfx2.cxx                     |    4 -
 extensions/source/ole/oledll.cxx                          |    3 -
 extensions/source/ole/wincrap.hxx                         |    4 -
 external/Module_external.mk                               |    1 
 external/Package_msvc_dlls_debug.mk                       |   16 ++++++
 icu/ExternalPackage_icu.mk                                |   20 +++----
 icu/ExternalProject_icu.mk                                |    6 +-
 lcms2/ExternalPackage_lcms2.mk                            |    6 +-
 lcms2/ExternalProject_lcms2.mk                            |    7 +-
 liborcus/ExternalProject_liborcus.mk                      |    2 
 libxml2/ExternalProject_xml2.mk                           |    3 -
 libxmlsec/xmlsec1-vc.patch                                |    5 +
 libxslt/ExternalProject_xslt.mk                           |    1 
 lpsolve/ExternalProject_lpsolve.mk                        |    3 -
 lpsolve/lp_solve_5.5-windows.patch                        |    2 
 nss/ExternalProject_nss.mk                                |    2 
 nss/nss.patch                                             |    8 ++-
 openssl/opensslwnt.patch                                  |    2 
 python3/ExternalPackage_python3.mk                        |   37 +++++++-------
 python3/ExternalProject_python3.mk                        |   13 +++-
 redland/UnpackedTarball_redland.mk                        |    1 
 redland/redland/redland-query-rasqal-avoid-assert.patch.1 |   17 ++++++
 sal/osl/w32/system.h                                      |    2 
 scp2/InstallModule_ooo.mk                                 |    1 
 scp2/InstallModule_python.mk                              |    3 -
 scp2/source/ooo/file_library_ooo.scp                      |   16 ++++++
 scp2/source/python/file_python.scp                        |    2 
 setup_native/Library_instooofiltmsi.mk                    |    2 
 setup_native/Library_qslnkmsi.mk                          |    2 
 setup_native/Library_reg4allmsdoc.mk                      |    2 
 setup_native/Library_regactivex.mk                        |    2 
 setup_native/Library_regpatchactivex.mk                   |    2 
 setup_native/Library_sdqsmsi.mk                           |    2 
 setup_native/Library_sellangmsi.mk                        |    2 
 setup_native/Library_shlxtmsi.mk                          |    2 
 setup_native/Library_sn_tools.mk                          |    2 
 setup_native/StaticLibrary_quickstarter.mk                |    2 
 setup_native/StaticLibrary_seterror.mk                    |    2 
 solenv/gbuild/LinkTarget.mk                               |   14 ++++-
 solenv/gbuild/gbuild.mk                                   |    7 +-
 solenv/gbuild/platform/com_GCC_class.mk                   |    4 +
 solenv/gbuild/platform/com_MSC_class.mk                   |   11 +++-
 solenv/gbuild/platform/com_MSC_defs.mk                    |    7 +-
 solenv/gbuild/platform/macosx.mk                          |   15 +++++
 solenv/gbuild/platform/solaris.mk                         |    8 +++
 solenv/gbuild/platform/unxgcc.mk                          |    9 +++
 solenv/gcc-wrappers/wrapper.cxx                           |    6 +-
 63 files changed, 261 insertions(+), 133 deletions(-)

New commits:
commit a5a5104cae175f6b9a8cb4bbaccb69f0276783e3
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Apr 9 23:07:16 2013 +0200

    gbuild: --enable-dbgutil: enable STL assertions for Mac OS X
    
    Works here with Apple llvm-g++ 4.2.1; cannot run "subsequentcheck"
    due to remote login.
    
    Change-Id: I187620b65f82095b5e9b7433c01ede429a27c719

diff --git a/cppunit/ExternalProject_cppunit.mk b/cppunit/ExternalProject_cppunit.mk
index 715d157..1617ecd 100644
--- a/cppunit/ExternalProject_cppunit.mk
+++ b/cppunit/ExternalProject_cppunit.mk
@@ -48,7 +48,7 @@ $(call gb_ExternalProject_get_state_target,cppunit,build) :
 			$(if $(filter WNT,$(OS)),LDFLAGS="-Wl$(COMMA)--enable-runtime-pseudo-reloc-v2") \
 			$(if $(filter SOLARIS,$(OS)),LIBS="-lm") \
 			$(if $(filter ANDROID,$(OS)),LIBS="-lgnustl_shared -lm") \
-			CXXFLAGS="$(if $(filter GCC,$(COM)),$(if $(filter LINUX FREEBSD OPENBSD NETBSD DRAGONFLY ANDROID,$(OS)),$(if $(filter TRUE,$(ENABLE_DBGUTIL)),-D_GLIBCXX_DEBUG),$(if $(filter WNT,$(OS)),-mthreads))) \
+			CXXFLAGS="$(if $(filter GCC,$(COM)),$(if $(filter LINUX FREEBSD OPENBSD NETBSD DRAGONFLY ANDROID MACOSX,$(OS)),$(if $(filter TRUE,$(ENABLE_DBGUTIL)),-D_GLIBCXX_DEBUG),$(if $(filter WNT,$(OS)),-mthreads))) \
 			$(if $(debug),-g)" \
 		&& cd src \
 		&& $(MAKE) \
diff --git a/liborcus/ExternalProject_liborcus.mk b/liborcus/ExternalProject_liborcus.mk
index 08f4efb..47e5cf5 100644
--- a/liborcus/ExternalProject_liborcus.mk
+++ b/liborcus/ExternalProject_liborcus.mk
@@ -50,7 +50,7 @@ endif
 ifeq ($(SYSTEM_ZLIB),NO)
 liborcus_CPPFLAGS+=-I$(OUTDIR)/inc/external/zlib
 endif
-ifneq (,$(filter LINUX FREEBSD OPENBSD NETBSD DRAGONFLY ANDROID,$(OS)))
+ifneq (,$(filter LINUX FREEBSD OPENBSD NETBSD DRAGONFLY ANDROID MACOSX,$(OS)))
 ifneq (,$(gb_ENABLE_DBGUTIL))
 liborcus_CPPFLAGS+=-D_GLIBCXX_DEBUG
 endif
diff --git a/solenv/gbuild/platform/macosx.mk b/solenv/gbuild/platform/macosx.mk
index 011aaae..5d94b4a 100644
--- a/solenv/gbuild/platform/macosx.mk
+++ b/solenv/gbuild/platform/macosx.mk
@@ -77,6 +77,13 @@ gb_COMPILERDEFS += \
 
 endif
 
+# enable debug STL
+ifeq ($(gb_ENABLE_DBGUTIL),$(true))
+gb_COMPILERDEFS += \
+	-D_GLIBCXX_DEBUG \
+
+endif
+
 ifeq ($(HAVE_GCC_NO_LONG_DOUBLE),TRUE)
 gb_CXXFLAGS += -Wno-long-double
 endif
commit f14f7a2e4568e3e85a0c8860beebd0376c5a8b51
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Apr 14 19:15:45 2013 +0200

    MSVC: --enable-dbgutil uses debug runtimes
    
    Works here with MSVC 2008, make check passes successfully.
    
    Change-Id: Id02ab357ea93bddd241c7801c0d7b9b4be83b7b4

diff --git a/configure.ac b/configure.ac
index 37f200f..88528d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3219,7 +3219,7 @@ if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
     ENABLE_DBGUTIL="TRUE"
     # this is an extra var so it can have different default on different MSVC
     # versions (in case there are version specific problems with it)
-    MSVC_USE_DEBUG_RUNTIME=""
+    MSVC_USE_DEBUG_RUNTIME="TRUE"
     PROEXT=""
     PRODUCT=""
 
commit 4811c2dc9f94929b60e7e2e0077871aad14fdc3a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Apr 14 13:52:56 2013 +0200

    adapt all externals to build against MSVC debug runtime
    
    Add patches and/or tweaks to the following modules:
    curl, cppunit, icu, lcms2, libxml2, libxslt, libxmlsec,
    lpsolve, nss, openssl, python3
    
    lcms2 has an inconsistency where the .lib and the .dll don't agree on
    the .dll name.
    
    openssl gets a honorable mention because apparently it's undocumented
    custom build system can build with /MDd if one picks the right
    configuration but i couldn't figure out how to do that in an hour of
    trying, and just patched the release config instead.
    
    Change-Id: I7854a0fc85247e398d561b4f513d09fe2d1ebb3c

diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 80f89a9..315dbe9 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -2299,7 +2299,7 @@ $(call gb_LinkTarget__use_python_headers,$(1))
 
 ifeq ($(OS),WNT)
 $(call gb_LinkTarget_add_libs,$(1),\
-	python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR).lib \
+	python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR)$(if $(MSVC_USE_DEBUG_RUNTIME),_d).lib \
 )
 else ifeq ($(OS),MACOSX)
 $(call gb_LinkTarget_add_libs,$(1),\
diff --git a/RepositoryFixes.mk b/RepositoryFixes.mk
index 2a4969e..2428948 100644
--- a/RepositoryFixes.mk
+++ b/RepositoryFixes.mk
@@ -107,11 +107,13 @@ gb_Library_FILENAMES := $(patsubst xmlsec1-nss:ixmlsec1-nss%,xmlsec1-nss:libxmls
 gb_Library_FILENAMES := $(patsubst z:z%,z:zlib%,$(gb_Library_FILENAMES))
 
 
+gb_Library_NOILIBFILENAMES_D := \
+    icudt icuin icule icuuc \
+    lcms2 \
+
 # change the names of all import libraries that don't have an "i" prefix as in our standard naming schema
 gb_Library_NOILIBFILENAMES := \
-    icudt icuin icule icuuc \
     langtag \
-    lcms2 \
     lpsolve55 \
     xpcom \
     xpcom_core \
@@ -129,10 +131,12 @@ gb_Library_LIBLIBFILENAMES := \
 
 gb_Library_FILENAMES := \
 	$(filter-out $(foreach lib,$(gb_Library_NOILIBFILENAMES),$(lib):%) \
+				 $(foreach lib,$(gb_Library_NOILIBFILENAMES_D),$(lib):%) \
 				 $(foreach lib,$(gb_Library_LIBLIBFILENAMES),$(lib):%) \
 		,$(gb_Library_FILENAMES))
 gb_Library_FILENAMES += \
 	$(foreach lib,$(gb_Library_NOILIBFILENAMES),$(lib):$(lib)$(gb_Library_PLAINEXT)) \
+	$(foreach lib,$(gb_Library_NOILIBFILENAMES_D),$(lib):$(lib)d$(gb_Library_PLAINEXT)) \
 	$(foreach lib,$(gb_Library_LIBLIBFILENAMES),$(lib):lib$(lib)$(gb_Library_PLAINEXT))
 
 endif # ifeq ($(COM),GCC)
diff --git a/cppunit/ExternalPackage_cppunit.mk b/cppunit/ExternalPackage_cppunit.mk
index 6ebe243..d900e22 100644
--- a/cppunit/ExternalPackage_cppunit.mk
+++ b/cppunit/ExternalPackage_cppunit.mk
@@ -12,9 +12,9 @@ $(eval $(call gb_ExternalPackage_use_external_project,cppunit,cppunit))
 
 ifeq ($(OS),WNT)
 ifeq ($(COM),MSC)
-$(eval $(call gb_ExternalPackage_add_file,cppunit,bin/cppunit_dll.dll,src/cppunit/ReleaseDll/cppunit_dll.dll))
-$(eval $(call gb_ExternalPackage_add_file,cppunit,lib/icppunit_dll.lib,src/cppunit/ReleaseDll/cppunit_dll.lib))
-$(eval $(call gb_ExternalPackage_add_file,cppunit,bin/DllPlugInTester_dll.exe,src/DllPlugInTester/ReleaseDll/DllPlugInTester_dll.exe))
+$(eval $(call gb_ExternalPackage_add_file,cppunit,bin/$(if $(MSVC_USE_DEBUG_RUNTIME),cppunitd_dll.dll,cppunit_dll.dll),src/cppunit/$(if $(MSVC_USE_DEBUG_RUNTIME),DebugDll/cppunitd_dll.dll,ReleaseDll/cppunit_dll.dll)))
+$(eval $(call gb_ExternalPackage_add_file,cppunit,lib/icppunit_dll.lib,src/cppunit/$(if $(MSVC_USE_DEBUG_RUNTIME),DebugDll/cppunitd_dll.lib,ReleaseDll/cppunit_dll.lib)))
+$(eval $(call gb_ExternalPackage_add_file,cppunit,bin/DllPlugInTester_dll.exe,src/DllPlugInTester/$(if $(MSVC_USE_DEBUG_RUNTIME),DebugDll/DllPlugInTesterd_dll.exe,ReleaseDll/DllPlugInTester_dll.exe)))
 else
 $(eval $(call gb_ExternalPackage_add_file,cppunit,bin/libcppunit-1-13-0.dll,src/cppunit/.libs/libcppunit-1-13-0.dll))
 $(eval $(call gb_ExternalPackage_add_file,cppunit,lib/libcppunit.dll.a,src/cppunit/.libs/libcppunit.dll.a))
diff --git a/cppunit/ExternalProject_cppunit.mk b/cppunit/ExternalProject_cppunit.mk
index 45ed225..715d157 100644
--- a/cppunit/ExternalProject_cppunit.mk
+++ b/cppunit/ExternalProject_cppunit.mk
@@ -20,17 +20,17 @@ ifeq ($(OS)$(COM),WNTMSC)
 ifeq ($(VCVER),90)
 $(call gb_ExternalProject_get_state_target,cppunit,build) :
 	$(call gb_ExternalProject_run,build,\
-		$(COMPATH)/vcpackages/vcbuild.exe cppunit_dll.vcproj "Release|Win32" \
+		$(COMPATH)/vcpackages/vcbuild.exe cppunit_dll.vcproj "$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release)|Win32" \
 		&& cd ../DllPlugInTester \
-		&& $(COMPATH)/vcpackages/vcbuild.exe DllPlugInTester.vcproj "Release|Win32" \
+		&& $(COMPATH)/vcpackages/vcbuild.exe DllPlugInTester.vcproj "$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release)|Win32" \
 	,src/cppunit)
 else
 $(call gb_ExternalProject_get_state_target,cppunit,build) :
 	$(call gb_ExternalProject_run,build,\
-		msbuild.exe cppunit_dll.vcxproj /p:Configuration=Release \
+		msbuild.exe cppunit_dll.vcxproj /p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
 		$(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110 /p:VisualStudioVersion=11.0) \
 		&& cd ../DllPlugInTester \
-		&& msbuild.exe DllPlugInTester.vcxproj /p:Configuration=Release \
+		&& msbuild.exe DllPlugInTester.vcxproj /p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
 		$(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110 /p:VisualStudioVersion=11.0) \
 	,src/cppunit)
 endif
diff --git a/curl/ExternalProject_curl.mk b/curl/ExternalProject_curl.mk
index a503c15..bbb2b1c 100644
--- a/curl/ExternalProject_curl.mk
+++ b/curl/ExternalProject_curl.mk
@@ -49,7 +49,8 @@ else ifeq ($(COM),MSC)
 
 $(call gb_ExternalProject_get_state_target,curl,build):
 	$(call gb_ExternalProject_run,build,\
-		MAKEFLAGS= LIB="$(ILIB)" nmake -f Makefile.vc9 cfg=release-dll \
+		MAKEFLAGS= LIB="$(ILIB)" nmake -f Makefile.vc9 \
+			cfg=$(if $(MSVC_USE_DEBUG_RUNTIME),debug-dll,release-dll) \
 			EXCFLAGS="/EHa /Zc:wchar_t- /D_CRT_SECURE_NO_DEPRECATE /DUSE_WINDOWS_SSPI $(SOLARINC)" $(if $(filter X86_64,$(CPUNAME)),MACHINE=X64) \
 	,lib)
 
diff --git a/curl/curl-7.26.0_win.patch b/curl/curl-7.26.0_win.patch
index bcc357c..0b3eed2 100644
--- a/curl/curl-7.26.0_win.patch
+++ b/curl/curl-7.26.0_win.patch
@@ -43,7 +43,14 @@
  
  CFGSET     = FALSE
  
-@@ -620,5 +620,5 @@
+@@ -620,11 +620,11 @@
+ debug-dll-ssl-dll\libcurl.res \
+ debug-dll-zlib-dll\libcurl.res \
+ debug-dll-ssl-dll-zlib-dll\libcurl.res: libcurl.rc
+-	rc /dDEBUGBUILD=1 /Fo $@ libcurl.rc
++	rc $(SOLARINC) /dDEBUGBUILD=1 /Fo $@ libcurl.rc
+
+ release-dll\libcurl.res \
  release-dll-ssl-dll\libcurl.res \
  release-dll-zlib-dll\libcurl.res \
  release-dll-ssl-dll-zlib-dll\libcurl.res: libcurl.rc
diff --git a/icu/ExternalPackage_icu.mk b/icu/ExternalPackage_icu.mk
index 785194e..169e81c 100644
--- a/icu/ExternalPackage_icu.mk
+++ b/icu/ExternalPackage_icu.mk
@@ -33,18 +33,18 @@ $(eval $(call gb_ExternalPackage_add_files,icu,bin,\
 
 else
 $(eval $(call gb_ExternalPackage_add_files,icu,lib,\
-	source/lib/icudt.lib \
-	source/lib/icuuc.lib \
-	source/lib/icuin.lib \
-	source/lib/icule.lib \
-	source/lib/icutu.lib\
+	source/lib/icudt$(if $(MSVC_USE_DEBUG_RUNTIME),d).lib \
+	source/lib/icuuc$(if $(MSVC_USE_DEBUG_RUNTIME),d).lib \
+	source/lib/icuin$(if $(MSVC_USE_DEBUG_RUNTIME),d).lib \
+	source/lib/icule$(if $(MSVC_USE_DEBUG_RUNTIME),d).lib \
+	source/lib/icutu$(if $(MSVC_USE_DEBUG_RUNTIME),d).lib\
 ))
 $(eval $(call gb_ExternalPackage_add_files,icu,bin,\
-	source/lib/icudt$(ICU_MAJOR).dll \
-	source/lib/icuuc$(ICU_MAJOR).dll \
-	source/lib/icuin$(ICU_MAJOR).dll \
-	source/lib/icule$(ICU_MAJOR).dll \
-	source/lib/icutu$(ICU_MAJOR).dll \
+	source/lib/icudt$(if $(MSVC_USE_DEBUG_RUNTIME),d)$(ICU_MAJOR).dll \
+	source/lib/icuuc$(if $(MSVC_USE_DEBUG_RUNTIME),d)$(ICU_MAJOR).dll \
+	source/lib/icuin$(if $(MSVC_USE_DEBUG_RUNTIME),d)$(ICU_MAJOR).dll \
+	source/lib/icule$(if $(MSVC_USE_DEBUG_RUNTIME),d)$(ICU_MAJOR).dll \
+	source/lib/icutu$(if $(MSVC_USE_DEBUG_RUNTIME),d)$(ICU_MAJOR).dll \
 	source/bin/genccode.exe \
 	source/bin/genbrk.exe \
 	source/bin/gencmn.exe \
diff --git a/icu/ExternalProject_icu.mk b/icu/ExternalProject_icu.mk
index ecf97ec..2df3011 100644
--- a/icu/ExternalProject_icu.mk
+++ b/icu/ExternalProject_icu.mk
@@ -19,11 +19,15 @@ icu_CPPFLAGS:="-DHAVE_GCC_ATOMICS=$(if $(filter TRUE,$(GCC_HAVE_BUILTIN_ATOMIC))
 
 ifeq ($(OS),WNT)
 
+# Note: runConfigureICU ignores everything following the platform name!
 ifeq ($(COM),MSC)
 $(call gb_ExternalProject_get_state_target,icu,build) :
 	$(call gb_ExternalProject_run,build,\
 		export LIB="$(ILIB)" \
-		&& CFLAGS="$(SOLARINC)" CPPFLAGS="$(SOLARINC)" CXXFLAGS="$(SOLARINC)" ./runConfigureICU Cygwin/MSVC \
+		&& CFLAGS="$(SOLARINC)" CPPFLAGS="$(SOLARINC)" CXXFLAGS="$(SOLARINC)" \
+			./runConfigureICU \
+			$(if $(MSVC_USE_DEBUG_RUNTIME),--enable-debug --disable-release) \
+			Cygwin/MSVC \
 		&& $(MAKE) \
 	,source)
 else
diff --git a/lcms2/ExternalPackage_lcms2.mk b/lcms2/ExternalPackage_lcms2.mk
index 7c2a75a..c2d5c5a 100644
--- a/lcms2/ExternalPackage_lcms2.mk
+++ b/lcms2/ExternalPackage_lcms2.mk
@@ -20,8 +20,10 @@ ifeq ($(COM),GCC)
 $(eval $(call gb_ExternalPackage_add_file,lcms2,lib/liblcms2.dll.a,src/.libs/liblcms2.dll.a))
 $(eval $(call gb_ExternalPackage_add_file,lcms2,bin/liblcms2-2.dll,src/.libs/liblcms2-2.dll))
 else ifeq ($(COM),MSC)
-$(eval $(call gb_ExternalPackage_add_file,lcms2,lib/lcms2.lib,bin/lcms2.lib))
-$(eval $(call gb_ExternalPackage_add_file,lcms2,bin/lcms2.dll,bin/lcms2.dll))
+$(eval $(call gb_ExternalPackage_add_file,lcms2,lib/lcms2$(if $(MSVC_USE_DEBUG_RUNTIME),d).lib,bin/lcms2$(if $(MSVC_USE_DEBUG_RUNTIME),d).lib))
+# note: the lcms2d.lib references LCMS2.DLL (without D!) but the dll is
+# actually called LCMS2D.DLL then
+$(eval $(call gb_ExternalPackage_add_file,lcms2,bin/lcms2.dll,bin/lcms2$(if $(MSVC_USE_DEBUG_RUNTIME),d).dll))
 endif
 else
 $(eval $(call gb_ExternalPackage_add_file,lcms2,lib/liblcms2.so,src/.libs/liblcms2.so))
diff --git a/lcms2/ExternalProject_lcms2.mk b/lcms2/ExternalProject_lcms2.mk
index d76049e..dc77783 100644
--- a/lcms2/ExternalProject_lcms2.mk
+++ b/lcms2/ExternalProject_lcms2.mk
@@ -20,13 +20,16 @@ ifeq ($(COM),MSC)
 ifeq ($(filter-out 14 13,$(COMEX)),)
 $(call gb_ExternalProject_get_state_target,lcms2,build):
 	$(call gb_ExternalProject_run,build,\
-		MSBuild.exe lcms2_DLL.vcxproj /p:Configuration=Release /p:Platform=Win32 /p:TargetName=lcms2 \
+		MSBuild.exe lcms2_DLL.vcxproj \
+			/p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
+			/p:Platform=Win32 /p:TargetName=lcms2 \
 			$(if $(filter 14,$(COMEX)),/p:PlatformToolset=v110 /p:VisualStudioVersion=11.0) \
 	,Projects/VC2010/lcms2_DLL)
 else
 $(call gb_ExternalProject_get_state_target,lcms2,build):
 	$(call gb_ExternalProject_run,build,\
-		$(COMPATH)/vcpackages/vcbuild.exe lcms2_DLL.vcproj "Release|Win32" \
+		$(COMPATH)/vcpackages/vcbuild.exe lcms2_DLL.vcproj \
+			"$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release)|Win32" \
 	,Projects/VC2008/lcms2_DLL)
 endif
 else
diff --git a/libxml2/ExternalProject_xml2.mk b/libxml2/ExternalProject_xml2.mk
index 8d7f00c..5ea4682 100644
--- a/libxml2/ExternalProject_xml2.mk
+++ b/libxml2/ExternalProject_xml2.mk
@@ -31,7 +31,8 @@ $(call gb_ExternalProject_get_state_target,xml2,build):
 else # COM=MSC
 $(call gb_ExternalProject_get_state_target,xml2,build):
 	$(call gb_ExternalProject_run,build,\
-		cscript configure.js iconv=no sax1=yes \
+		cscript configure.js \
+			iconv=no sax1=yes $(if $(MSVC_USE_DEBUG_RUNTIME),cruntime=/MDd) \
 		&& unset MAKEFLAGS \
 		&& LIB="$(ILIB)" nmake \
 	,win32)
diff --git a/libxmlsec/xmlsec1-vc.patch b/libxmlsec/xmlsec1-vc.patch
index 7cd8c4f..f996b8b 100644
--- a/libxmlsec/xmlsec1-vc.patch
+++ b/libxmlsec/xmlsec1-vc.patch
@@ -15,11 +15,14 @@
  SOLIBS 			= $(LIBS) libxml2.lib 
 --- build/xmlsec/win32/Makefile.msvc.old	2012-11-30 11:09:23.130479800 -0500
 +++ build/xmlsec/win32/Makefile.msvc	2012-11-30 11:11:06.037550700 -0500
-@@ -301,6 +301,7 @@
+@@ -301,6 +301,10 @@
  CFLAGS 			= $(CFLAGS) /D "HAVE_STDIO_H" /D "HAVE_STDLIB_H"
  CFLAGS 			= $(CFLAGS) /D "HAVE_STRING_H" /D "HAVE_CTYPE_H"
  CFLAGS 			= $(CFLAGS) /D "HAVE_MALLOC_H" /D "HAVE_MEMORY_H"
 +CFLAGS 			= $(CFLAGS) $(SOLARINC) -I$(WORKDIR)\UnpackedTarball\xml2\include
++!if "$(MSVC_USE_DEBUG_RUNTIME)" != ""
++CFLAGS 			= $(CFLAGS) /MDd
++!endif
  
  # Optimisation and debug symbols.
  !if "$(DEBUG)" == "1"
diff --git a/libxslt/ExternalProject_xslt.mk b/libxslt/ExternalProject_xslt.mk
index 357ae78..46af1bd 100644
--- a/libxslt/ExternalProject_xslt.mk
+++ b/libxslt/ExternalProject_xslt.mk
@@ -33,6 +33,7 @@ else # COM=MSC
 $(call gb_ExternalProject_get_state_target,xslt,build):
 	$(call gb_ExternalProject_run,build,\
 		cscript configure.js \
+			$(if $(MSVC_USE_DEBUG_RUNTIME),cruntime=/MDd) \
 		&& unset MAKEFLAGS \
 		&& LIB="$(ILIB)" nmake \
 	,win32)
diff --git a/lpsolve/ExternalProject_lpsolve.mk b/lpsolve/ExternalProject_lpsolve.mk
index 7de29e5..0cf95dd 100644
--- a/lpsolve/ExternalProject_lpsolve.mk
+++ b/lpsolve/ExternalProject_lpsolve.mk
@@ -27,7 +27,8 @@ $(call gb_ExternalProject_get_state_target,lpsolve,build):
 else # $(COM)!=GCC
 $(call gb_ExternalProject_get_state_target,lpsolve,build):
 	$(call gb_ExternalProject_run,build,\
-		LIB="$(ILIB)" cmd /c cvc6.bat \
+		LIB="$(ILIB)" RUNTIME_FLAG="$(if $(MSVC_USE_DEBUG_RUNTIME),/MDd,/MD)" \
+		cmd /c cvc6.bat \
 	,lpsolve55)
 endif # $(COM)
 else # $(OS)!=WNT
diff --git a/lpsolve/lp_solve_5.5-windows.patch b/lpsolve/lp_solve_5.5-windows.patch
index 28f7c71..d7c44e6 100644
--- a/lpsolve/lp_solve_5.5-windows.patch
+++ b/lpsolve/lp_solve_5.5-windows.patch
@@ -46,7 +46,7 @@
 -rc lpsolve.rc
 +rc %SOLARINC% lpsolve.rc
 -%c% -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd /LD /MD /O1 /Zp8 /Gz -D_WINDLL -D_USRDLL -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine %src% lpsolve.res ..\lp_solve.def -o lpsolve55.dll
-+%c% -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd %SOLARINC% /LD /MD /O1 /Zp8 /Gz -D_WINDLL -D_USRDLL -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine %src% lpsolve.res ..\lp_solve.def -Felpsolve55.dll
++%c% -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd %SOLARINC% /LD %RUNTIME_FLAG% /O1 /Zp8 /Gz -D_WINDLL -D_USRDLL -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine %src% lpsolve.res ..\lp_solve.def -Felpsolve55.dll
 -rem /link /LINK50COMPAT
 -
 -if exist a.obj del a.obj
diff --git a/nss/ExternalProject_nss.mk b/nss/ExternalProject_nss.mk
index c853d89..be16385 100644
--- a/nss/ExternalProject_nss.mk
+++ b/nss/ExternalProject_nss.mk
@@ -40,7 +40,7 @@ ifeq ($(OS),WNT)
 ifeq ($(COM),MSC)
 $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject_get_state_target,nss,configure) $(call gb_ExternalExecutable_get_dependencies,python)
 	$(call gb_ExternalProject_run,build,\
-		$(if $(debug),,BUILD_OPT=1) \
+		$(if $(MSVC_USE_DEBUG_RUNTIME),USE_DEBUG_RTL=1,BUILD_OPT=1) \
 		MOZ_MSVCVERSION=9 OS_TARGET=WIN95 \
 		$(if $(filter X,$(CPU)),USE_64=1) \
 		LIB="$(ILIB)" \
diff --git a/nss/nss.patch b/nss/nss.patch
index d0e3318..ca81061 100644
--- a/nss/nss.patch
+++ b/nss/nss.patch
@@ -120,7 +120,7 @@
  	ifndef BUILD_OPT
 --- misc/nss-3.13.5/mozilla/security/coreconf/arch.mk	2009-06-05 04:14:49.000000000 +0200
 +++ misc/build/nss-3.13.5/mozilla/security/coreconf/arch.mk	2010-06-11 16:35:54.990913282 +0200
-@@ -324,7 +324,12 @@
+@@ -324,10 +324,15 @@
  # IMPL_STRATEGY may be defined too.
  #
  
@@ -133,7 +133,11 @@
 +OBJDIR_NAME = out
  
  ifeq (,$(filter-out WIN%,$(OS_TARGET)))
- ifndef BUILD_OPT
+-ifndef BUILD_OPT
++ifdef THIS_HAS_BEEN_DISABLED_TO_GET_out
+ #
+ # Define USE_DEBUG_RTL if you want to use the debug runtime library
+ # (RTL) in the debug build
 --- misc/nss-3.13.5/mozilla/security/nss/cmd/platlibs.mk	2010-02-04 19:59:10.000000000 +0100
 +++ misc/build/nss-3.13.5/mozilla/security/nss/cmd/platlibs.mk	2010-06-11 16:35:55.004869805 +0200
 @@ -41,27 +41,32 @@
diff --git a/openssl/opensslwnt.patch b/openssl/opensslwnt.patch
index ac9aff2..a28a24f 100644
--- a/openssl/opensslwnt.patch
+++ b/openssl/opensslwnt.patch
@@ -127,7 +127,7 @@
 -    $lib_cflag='/Zl' if (!$shlib);	# remove /DEFAULTLIBs from static lib
 -    $opt_cflags=$f.' /Ox /O2 /Ob2';
 -    $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
-+    my $f = $shlib || $fips ?' -MD':' -MT';
++    my $f = $shlib || $fips ? (($ENV{MSVC_USE_DEBUG_RUNTIME} eq "TRUE") ? ' -MDd' : ' -MD' ):' -MT';
 +    $lib_cflag='-Zl' if (!$shlib);	# remove /DEFAULTLIBs from static lib
 +    $opt_cflags=$f.' -Ox -O2 -Ob2';
 +    $dbg_cflags=$f.'d -Od -DDEBUG -D_DEBUG';
diff --git a/python3/ExternalPackage_python3.mk b/python3/ExternalPackage_python3.mk
index 3dc4dfd..16e270b 100644
--- a/python3/ExternalPackage_python3.mk
+++ b/python3/ExternalPackage_python3.mk
@@ -15,27 +15,28 @@ ifeq ($(OS)-$(COM),WNT-MSC)
 ifeq ($(CPUNAME),X86_64)
 python_arch_subdir=amd64/
 endif
-$(eval $(call gb_ExternalPackage_add_file,python3,bin/python.exe,LO_lib/$(python_arch_subdir)python.exe))
+$(eval $(call gb_ExternalPackage_add_file,python3,bin/python.exe,LO_lib/$(python_arch_subdir)python$(if $(MSVC_USE_DEBUG_RUNTIME),_d).exe))
+$(eval $(call gb_ExternalPackage_add_file,python3,bin/python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR)$(if $(MSVC_USE_DEBUG_RUNTIME),_d).dll,LO_lib/$(python_arch_subdir)python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR)$(if $(MSVC_USE_DEBUG_RUNTIME),_d).dll))
+$(eval $(call gb_ExternalPackage_add_file,python3,lib/python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR)$(if $(MSVC_USE_DEBUG_RUNTIME),_d).lib,LO_lib/$(python_arch_subdir)python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR)$(if $(MSVC_USE_DEBUG_RUNTIME),_d).lib))
+ifeq ($(MSVC_USE_DEBUG_RUNTIME),)
 $(eval $(call gb_ExternalPackage_add_file,python3,bin/python$(PYTHON_VERSION_MAJOR).dll,LO_lib/$(python_arch_subdir)python$(PYTHON_VERSION_MAJOR).dll))
-$(eval $(call gb_ExternalPackage_add_file,python3,bin/python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR).dll,LO_lib/$(python_arch_subdir)python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR).dll))
 $(eval $(call gb_ExternalPackage_add_file,python3,lib/python$(PYTHON_VERSION_MAJOR).lib,LO_lib/$(python_arch_subdir)python$(PYTHON_VERSION_MAJOR).lib))
-$(eval $(call gb_ExternalPackage_add_file,python3,lib/python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR).lib,LO_lib/$(python_arch_subdir)python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR).lib))
+endif
 $(eval $(call gb_ExternalPackage_add_files,python3,lib/python,\
-	LO_lib/$(python_arch_subdir)_ctypes.pyd \
-	LO_lib/$(python_arch_subdir)_ctypes_test.pyd \
-	LO_lib/$(python_arch_subdir)_decimal.pyd \
-	LO_lib/$(python_arch_subdir)_elementtree.pyd \
-	LO_lib/$(python_arch_subdir)_msi.pyd \
-	LO_lib/$(python_arch_subdir)_multiprocessing.pyd \
-	LO_lib/$(python_arch_subdir)_socket.pyd \
-	LO_lib/$(python_arch_subdir)_ssl.pyd \
-	LO_lib/$(python_arch_subdir)_testbuffer.pyd \
-	LO_lib/$(python_arch_subdir)_testcapi.pyd \
-	LO_lib/$(python_arch_subdir)pyexpat.pyd \
-	LO_lib/$(python_arch_subdir)select.pyd \
-	LO_lib/$(python_arch_subdir)unicodedata.pyd \
-	LO_lib/$(python_arch_subdir)winsound.pyd \
-	LO_lib/$(python_arch_subdir)xxlimited.pyd \
+	LO_lib/$(python_arch_subdir)_ctypes$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_ctypes_test$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_decimal$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_elementtree$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_msi$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_multiprocessing$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_socket$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_ssl$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_testbuffer$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)_testcapi$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)pyexpat$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)select$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)unicodedata$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
+	LO_lib/$(python_arch_subdir)winsound$(if $(MSVC_USE_DEBUG_RUNTIME),_d).pyd \
 ))
 else ifeq ($(OS),WNT) # MinGW
 # TODO how are C modules called on this platform?
diff --git a/python3/ExternalProject_python3.mk b/python3/ExternalProject_python3.mk
index 22a952c..9759623 100644
--- a/python3/ExternalProject_python3.mk
+++ b/python3/ExternalProject_python3.mk
@@ -29,19 +29,26 @@ ifeq ($(OS)$(COM),WNTMSC)
 $(call gb_ExternalProject_get_state_target,python3,build) :
 ifeq ($(VCVER),110)
 	$(call gb_ExternalProject_run,build,\
-	MAKEFLAGS= MSBuild.exe pcbuild.sln /t:Build /p:Configuration=Release /p:Platform=$(if $(filter INTEL,$(CPUNAME)),Win32,x64) /p:PlatformToolset=v110 /p:VisualStudioVersion=11.0 \
+	MAKEFLAGS= MSBuild.exe pcbuild.sln /t:Build \
+		/p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
+		/p:Platform=$(if $(filter INTEL,$(CPUNAME)),Win32,x64) \
+		/p:PlatformToolset=v110 /p:VisualStudioVersion=11.0 \
 	&& cd $(EXTERNAL_WORKDIR) \
 	&& ln -s PCbuild LO_lib \
 	,PCBuild)
 else ifeq ($(VCVER),100)
 	$(call gb_ExternalProject_run,build,\
-		MAKEFLAGS= MSBuild.exe pcbuild.sln /t:Build /p:Configuration=Release /p:Platform=$(if $(filter INTEL,$(CPUNAME)),Win32,x64) /ToolsVersion:4.0 \
+		MAKEFLAGS= MSBuild.exe pcbuild.sln /t:Build \
+			/p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
+			/p:Platform=$(if $(filter INTEL,$(CPUNAME)),Win32,x64) \
+			/ToolsVersion:4.0 \
 		&& cd $(EXTERNAL_WORKDIR) \
 		&& ln -s PCbuild LO_lib \
 	,PCBuild)
 else ifeq ($(VCVER),90)
 	$(call gb_ExternalProject_run,build,\
-		MAKEFLAGS= $(COMPATH)/vcpackages/vcbuild.exe pcbuild.sln "Release|$(if $(filter INTEL,$(CPUNAME)),Win32,x64)" \
+		MAKEFLAGS= $(COMPATH)/vcpackages/vcbuild.exe pcbuild.sln \
+			"$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release)|$(if $(filter INTEL,$(CPUNAME)),Win32,x64)" \
 		&& cd $(EXTERNAL_WORKDIR) \
 		&& ln -s PC/VS9.0 LO_lib \
 	,PC/VS9.0)
diff --git a/scp2/InstallModule_ooo.mk b/scp2/InstallModule_ooo.mk
index 3390f45..7069221 100644
--- a/scp2/InstallModule_ooo.mk
+++ b/scp2/InstallModule_ooo.mk
@@ -103,6 +103,7 @@ $(eval $(call gb_InstallModule_add_defs,scp2/ooo,\
 	$(if $(filter YES,$(SYSTEM_HSQLDB)),\
 		-DHSQLDB_JAR=\""$(call gb_Helper_make_path,$(HSQLDB_JAR))"\" \
 	) \
+	$(if $(filter MSC,$(COM)),$(if $(MSVC_USE_DEBUG_RUNTIME),-DMSVC_PKG_DEBUG_RUNTIME)) \
 ))
 
 ifeq ($(GUIBASE),unx)
diff --git a/scp2/InstallModule_python.mk b/scp2/InstallModule_python.mk
index 8b8af48..9839ef6 100644
--- a/scp2/InstallModule_python.mk
+++ b/scp2/InstallModule_python.mk
@@ -49,7 +49,8 @@ $(eval $(call gb_InstallModule_add_defs,scp2/python,\
 	-DPYVERSION=$(PYTHON_VERSION) \
 	-DPYMAJMIN=$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
 	-DPYMAJOR=$(PYTHON_VERSION_MAJOR) \
-	-DPY_FULL_DLL_NAME=$(if $(filter WNT-MSC,$(OS)-$(COM)),python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR).dll,libpython$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)m.so) \
+	-DPY_FULL_DLL_NAME=$(if $(filter WNT-MSC,$(OS)-$(COM)),python$(PYTHON_VERSION_MAJOR)$(PYTHON_VERSION_MINOR)$(if $(MSVC_USE_DEBUG_RUNTIME),_d).dll,libpython$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)m.so) \
+	$(if $(filter MSC,$(COM)),$(if $(MSVC_USE_DEBUG_RUNTIME),-DMSVC_PKG_DEBUG_RUNTIME)) \
 ))
 endif
 
diff --git a/scp2/source/ooo/file_library_ooo.scp b/scp2/source/ooo/file_library_ooo.scp
index b929801..5aafd04 100644
--- a/scp2/source/ooo/file_library_ooo.scp
+++ b/scp2/source/ooo/file_library_ooo.scp
@@ -595,7 +595,11 @@ File gid_File_Lib_Icudata
   #ifdef UNX
     Name = STRING(CONCAT6(libicudata,UNXSUFFIX,.,ICU_MAJOR,.,ICU_MINOR));
   #else
+  #ifdef MSVC_PKG_DEBUG_RUNTIME
+    Name = STRING(CONCAT3(icudtd,ICU_MAJOR,.dll));
+  #else
     Name = STRING(CONCAT3(icudt,ICU_MAJOR,.dll));
+  #endif // MSVC_PKG_DEBUG_RUNTIME
   #endif
     Dir = SCP2_OOO_BIN_DIR;
     Styles = (PACKED);
@@ -606,7 +610,11 @@ File gid_File_Lib_Icui18n
   #ifdef UNX
     Name = STRING(CONCAT6(libicui18n,UNXSUFFIX,.,ICU_MAJOR,.,ICU_MINOR));
   #else
+  #ifdef MSVC_PKG_DEBUG_RUNTIME
+    Name = STRING(CONCAT3(icuind,ICU_MAJOR,.dll));
+  #else
     Name = STRING(CONCAT3(icuin,ICU_MAJOR,.dll));
+  #endif // MSVC_PKG_DEBUG_RUNTIME
   #endif
     Dir = SCP2_OOO_BIN_DIR;
     Styles = (PACKED);
@@ -617,7 +625,11 @@ File gid_File_Lib_Icule
   #ifdef UNX
     Name = STRING(CONCAT6(libicule,UNXSUFFIX,.,ICU_MAJOR,.,ICU_MINOR));
   #else
+  #ifdef MSVC_PKG_DEBUG_RUNTIME
+    Name = STRING(CONCAT3(iculed,ICU_MAJOR,.dll));
+  #else
     Name = STRING(CONCAT3(icule,ICU_MAJOR,.dll));
+  #endif // MSVC_PKG_DEBUG_RUNTIME
   #endif
     Dir = SCP2_OOO_BIN_DIR;
     Styles = (PACKED);
@@ -628,7 +640,11 @@ File gid_File_Lib_Icuuc
   #ifdef UNX
     Name = STRING(CONCAT6(libicuuc,UNXSUFFIX,.,ICU_MAJOR,.,ICU_MINOR));
   #else
+  #ifdef MSVC_PKG_DEBUG_RUNTIME
+    Name = STRING(CONCAT3(icuucd,ICU_MAJOR,.dll));
+  #else
     Name = STRING(CONCAT3(icuuc,ICU_MAJOR,.dll));
+  #endif // MSVC_PKG_DEBUG_RUNTIME
   #endif
     Dir = SCP2_OOO_BIN_DIR;
     Styles = (PACKED);
diff --git a/scp2/source/python/file_python.scp b/scp2/source/python/file_python.scp
index 3390e67..ce892fd 100644
--- a/scp2/source/python/file_python.scp
+++ b/scp2/source/python/file_python.scp
@@ -167,6 +167,7 @@ File gid_File_Lib_Python_So
     Name = STRING(PY_FULL_DLL_NAME);
     Styles = (PACKED);
 End
+#ifndef MSVC_PKG_DEBUG_RUNTIME
 File gid_File_Lib_Python3_So
     LIB_FILE_BODY;
     Dir = gid_Brand_Dir_Program;
@@ -177,6 +178,7 @@ File gid_File_Lib_Python3_So
 #endif //UNX
     Styles = (PACKED);
 End
+#endif
 #else //MACOSX
 //directory entries solely to be able to create the symlinks
 Directory gid_Dir_PythonFramework
commit 3b65852f37f1c8daf8c5c0af1d810c68cc71d8e3
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Apr 11 14:43:19 2013 +0200

    gbuild: add support for building against MSVC debug runtime
    
    Mainly this means using /MDd instead of /MD and /MTd instead of /MT in
    the CFLAGS, and also re-mapping of .lib files to ones with "d".
    
    Change-Id: Ifc56b53a66d5eb522c1695a34d68b08cad1d8338

diff --git a/embedserv/Library_emser.mk b/embedserv/Library_emser.mk
index a4377f4..5e30bf8 100644
--- a/embedserv/Library_emser.mk
+++ b/embedserv/Library_emser.mk
@@ -58,15 +58,9 @@ $(eval $(call gb_Library_use_system_win32_libs,emser,\
 	uuid \
 ))
 
-ifeq ($(USE_DEBUG_RUNTIME),)
 $(eval $(call gb_Library_add_libs,emser,\
-	$(ATL_LIB)/atls.lib \
+	$(ATL_LIB)/$(if $(MSVC_USE_DEBUG_RUNTIME),atlsd.lib,atls.lib) \
 ))
-else
-$(eval $(call gb_Library_add_libs,emser,\
-	$(ATL_LIB)/atlsd.lib \
-))
-endif
 
 $(eval $(call gb_Library_add_ldflags,emser,\
 	-LIBPATH:$(ATL_LIB) \
diff --git a/extensions/Library_oleautobridge.mk b/extensions/Library_oleautobridge.mk
index 32467f3..fd1ccb9 100644
--- a/extensions/Library_oleautobridge.mk
+++ b/extensions/Library_oleautobridge.mk
@@ -59,15 +59,9 @@ $(eval $(call gb_Library_use_system_win32_libs,oleautobridge,\
 ))
 
 ifeq ($(COM),MSC)
-ifneq ($(USE_DEBUG_RUNTIME),)
 $(eval $(call gb_Library_add_libs,oleautobridge,\
-	$(ATL_LIB)/atlsd.lib \
+	$(ATL_LIB)/$(if $(MSVC_USE_DEBUG_RUNTIME),atlsd.lib,atls.lib) \
 ))
-else
-$(eval $(call gb_Library_add_libs,oleautobridge,\
-	$(ATL_LIB)/atls.lib \
-))
-endif
 endif
 
 $(eval $(call gb_Library_add_exception_objects,oleautobridge,\
diff --git a/extensions/Library_so_activex.mk b/extensions/Library_so_activex.mk
index 603a79c..80571d8 100644
--- a/extensions/Library_so_activex.mk
+++ b/extensions/Library_so_activex.mk
@@ -65,14 +65,8 @@ $(eval $(call gb_Library_use_system_win32_libs,so_activex,\
 	uuid \
 ))
 
-ifneq ($(USE_DEBUG_RUNTIME),)
 $(eval $(call gb_Library_add_libs,so_activex,\
-	$(ATL_LIB)/atlsd.lib \
+	$(ATL_LIB)/$(if $(MSVC_USE_DEBUG_RUNTIME),atlsd.lib,atls.lib) \
 ))
-else
-$(eval $(call gb_Library_add_libs,so_activex,\
-	$(ATL_LIB)/atls.lib \
-))
-endif
 
 # vim:set noet sw=4 ts=4:
diff --git a/extensions/Library_so_activex_x64.mk b/extensions/Library_so_activex_x64.mk
index c4f9546..96ee19d 100644
--- a/extensions/Library_so_activex_x64.mk
+++ b/extensions/Library_so_activex_x64.mk
@@ -68,14 +68,8 @@ $(eval $(call gb_Library_use_system_win32_libs,so_activex_x64,\
 	uuid \
 ))
 
-ifneq ($(USE_DEBUG_RUNTIME),)
 $(eval $(call gb_Library_add_libs,so_activex_x64,\
-	$(ATL_LIB)/amd64/atlsd.lib \
+	$(ATL_LIB)/amd64/$(if $(MSVC_USE_DEBUG_RUNTIME),atlsd.lib,atls.lib) \
 ))
-else
-$(eval $(call gb_Library_add_libs,so_activex_x64,\
-	$(ATL_LIB)/amd64/atls.lib \
-))
-endif
 
 # vim:set noet sw=4 ts=4:
diff --git a/setup_native/Library_instooofiltmsi.mk b/setup_native/Library_instooofiltmsi.mk
index 677e590..a4c9fa8 100644
--- a/setup_native/Library_instooofiltmsi.mk
+++ b/setup_native/Library_instooofiltmsi.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,instooofiltmsi,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,instooofiltmsi,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,instooofiltmsi,\
diff --git a/setup_native/Library_qslnkmsi.mk b/setup_native/Library_qslnkmsi.mk
index 7f7bbb3..2e5e2fe 100644
--- a/setup_native/Library_qslnkmsi.mk
+++ b/setup_native/Library_qslnkmsi.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,qslnkmsi,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,qslnkmsi,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,qslnkmsi,\
diff --git a/setup_native/Library_reg4allmsdoc.mk b/setup_native/Library_reg4allmsdoc.mk
index 69f3903..6713176 100644
--- a/setup_native/Library_reg4allmsdoc.mk
+++ b/setup_native/Library_reg4allmsdoc.mk
@@ -16,7 +16,7 @@ $(eval $(call gb_Library_add_defs,reg4allmsdoc,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,reg4allmsdoc,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,reg4allmsdoc,\
diff --git a/setup_native/Library_regactivex.mk b/setup_native/Library_regactivex.mk
index 4f561a5..c823d7c 100644
--- a/setup_native/Library_regactivex.mk
+++ b/setup_native/Library_regactivex.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,regactivex,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,regactivex,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,regactivex,\
diff --git a/setup_native/Library_regpatchactivex.mk b/setup_native/Library_regpatchactivex.mk
index bd2669d..30bf07d 100644
--- a/setup_native/Library_regpatchactivex.mk
+++ b/setup_native/Library_regpatchactivex.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,regpatchactivex,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,regpatchactivex,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,regpatchactivex,\
diff --git a/setup_native/Library_sdqsmsi.mk b/setup_native/Library_sdqsmsi.mk
index 7375835..732159e 100644
--- a/setup_native/Library_sdqsmsi.mk
+++ b/setup_native/Library_sdqsmsi.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,sdqsmsi,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,sdqsmsi,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,sdqsmsi,\
diff --git a/setup_native/Library_sellangmsi.mk b/setup_native/Library_sellangmsi.mk
index 8411acd..2979f1e 100644
--- a/setup_native/Library_sellangmsi.mk
+++ b/setup_native/Library_sellangmsi.mk
@@ -18,7 +18,7 @@ $(eval $(call gb_Library_add_defs,sellangmsi,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,sellangmsi,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,sellangmsi,\
diff --git a/setup_native/Library_shlxtmsi.mk b/setup_native/Library_shlxtmsi.mk
index 28fcdce..84fbe72 100644
--- a/setup_native/Library_shlxtmsi.mk
+++ b/setup_native/Library_shlxtmsi.mk
@@ -16,7 +16,7 @@ $(eval $(call gb_Library_add_defs,shlxtmsi,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,shlxtmsi,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,shlxtmsi,\
diff --git a/setup_native/Library_sn_tools.mk b/setup_native/Library_sn_tools.mk
index da93c89..c857d0d 100644
--- a/setup_native/Library_sn_tools.mk
+++ b/setup_native/Library_sn_tools.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,sn_tools,\
 ))
 
 $(eval $(call gb_Library_add_cxxflags,sn_tools,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_Library_add_ldflags,sn_tools,\
diff --git a/setup_native/StaticLibrary_quickstarter.mk b/setup_native/StaticLibrary_quickstarter.mk
index 399f6af..0517a75 100644
--- a/setup_native/StaticLibrary_quickstarter.mk
+++ b/setup_native/StaticLibrary_quickstarter.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_StaticLibrary_add_defs,quickstarter,\
 ))
 
 $(eval $(call gb_StaticLibrary_add_cxxflags,quickstarter,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_StaticLibrary_add_exception_objects,quickstarter,\
diff --git a/setup_native/StaticLibrary_seterror.mk b/setup_native/StaticLibrary_seterror.mk
index bb6ccf9..9229769 100644
--- a/setup_native/StaticLibrary_seterror.mk
+++ b/setup_native/StaticLibrary_seterror.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_StaticLibrary_add_defs,seterror,\
 ))
 
 $(eval $(call gb_StaticLibrary_add_cxxflags,seterror,\
-	/MT \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
 ))
 
 $(eval $(call gb_StaticLibrary_add_exception_objects,seterror,\
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index 87a5c65..def5ff8 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -224,11 +224,10 @@ gb_GLOBALDEFS += \
 	-DLIBO_INTERNAL_ONLY \
 
 ifeq ($(gb_ENABLE_DBGUTIL),$(true))
-gb_GLOBALDEFS += -DDBG_UTIL \
-
-ifneq ($(COM),MSC)
-gb_GLOBALDEFS += -D_DEBUG \
+gb_GLOBALDEFS += -DDBG_UTIL
 
+ifneq ($(COM)-$(MSVC_USE_DEBUG_RUNTIME),MSC-)
+gb_GLOBALDEFS += -D_DEBUG
 endif
 endif
 
diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk
index 861626b..8b5421f 100755
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -218,8 +218,12 @@ $(call gb_Helper_abbreviate_dirs,\
 	; exit $$RC)
 endef
 
+define gb_MSVCRT_subst
+$(if $(MSVC_USE_DEBUG_RUNTIME),$(subst msvcrt,msvcrtd,$(subst msvcprt,msvcprtd,$(subst libcmt,libcmtd,$(subst libcpmt,libcpmtd,$(subst msvcmrt,msvcmrtd,$(1)))))),$(1))
+endef
+
 define gb_LinkTarget_use_system_win32_libs
-$(call gb_LinkTarget_add_libs,$(1),$(foreach lib,$(2),$(lib).lib))
+$(call gb_LinkTarget_add_libs,$(1),$(foreach lib,$(2),$(call gb_MSVCRT_subst,$(lib)).lib))
 endef
 
 # Flags common for PE executables (EXEs and DLLs) 
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk
index 18e1f0a..439afa5 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -148,7 +148,7 @@ gb_CFLAGS := \
 	-GR \
 	-Gs \
 	-GS \
-	-MD \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
 	-nologo \
 	-W4 \
 	-wd4127 \
@@ -181,7 +181,7 @@ gb_CXXFLAGS := \
 	-Gs \
 	-GS \
 	-Gy \
-	-MD \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
 	-nologo \
 	-W4 \
 	-wd4127 \
diff --git a/solenv/gcc-wrappers/wrapper.cxx b/solenv/gcc-wrappers/wrapper.cxx
index a768eef..151979c 100644
--- a/solenv/gcc-wrappers/wrapper.cxx
+++ b/solenv/gcc-wrappers/wrapper.cxx
@@ -72,7 +72,11 @@ string processccargs(vector<string> rawargs) {
     string args=" -nologo";
     // TODO: should these options be enabled globally?
     args.append(" -EHsc");
-    args.append(" -MD");
+    const char *const pDebugRuntime(getenv("MSVC_USE_DEBUG_RUNTIME"));
+    if (pDebugRuntime && !strcmp(pDebugRuntime, "TRUE"))
+        args.append(" -MDd");
+    else
+        args.append(" -MD");
     args.append(" -Gy");
     args.append(" -Zc:wchar_t-");
     args.append(" -Ob1 -Oxs -Oy-");
commit 54ba172dc13ababef911550a88083452832b4744
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Apr 14 19:05:46 2013 +0200

    configure: find the MSVC debug runtime libraries
    
    ... and copy them to solver bin in "external"
    
    Change-Id: I6850495d1abb848a3f6b17de6518d05890b13c32

diff --git a/config_host.mk.in b/config_host.mk.in
index a0f4675..4256fa7 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -354,6 +354,9 @@ export MSPUB_CFLAGS=$(gb_SPACE)@MSPUB_CFLAGS@
 export MSPUB_LIBS=$(gb_SPACE)@MSPUB_LIBS@
 export MSVC_DLLS=@MSVC_DLLS@
 export MSVC_DLL_PATH=@MSVC_DLL_PATH@
+export MSVC_DEBUG_DLLS=@MSVC_DEBUG_DLLS@
+export MSVC_DEBUG_DLL_PATH=@MSVC_DEBUG_DLL_PATH@
+export MSVC_USE_DEBUG_RUNTIME=@MSVC_USE_DEBUG_RUNTIME@
 export MSVC80_DLLS=@MSVC80_DLLS@
 export MSVC80_DLL_PATH=@MSVC80_DLL_PATH@
 export MWAW_CFLAGS=$(gb_SPACE)@MWAW_CFLAGS@
diff --git a/configure.ac b/configure.ac
index 1047839..37f200f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3217,6 +3217,9 @@ dnl ===================================================================
 AC_MSG_CHECKING([whether to build with additional debug utilities])
 if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
     ENABLE_DBGUTIL="TRUE"
+    # this is an extra var so it can have different default on different MSVC
+    # versions (in case there are version specific problems with it)
+    MSVC_USE_DEBUG_RUNTIME=""
     PROEXT=""
     PRODUCT=""
 
@@ -3249,12 +3252,14 @@ if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
     fi
 else
     ENABLE_DBGUTIL=""
+    MSVC_USE_DEBUG_RUNTIME=""
     # PRODUCT is old concept, still used by build.pl .
     PRODUCT="full"
     PROEXT=".pro"
     AC_MSG_RESULT([no])
 fi
 AC_SUBST(ENABLE_DBGUTIL)
+AC_SUBST(MSVC_USE_DEBUG_RUNTIME)
 AC_SUBST(PRODUCT)
 AC_SUBST(PROEXT)
 
@@ -4848,9 +4853,12 @@ find_msvc_dlls()
     fi
 
     msvcdllpath="$VC_PRODUCT_DIR/redist/$vsarch/Microsoft.VC${VCVER}.CRT"
+    MSVC_DEBUG_DLL_PATH="$VC_PRODUCT_DIR/redist/Debug_NonRedist/$vsarch/Microsoft.VC${VCVER}.DebugCRT"
     msvcdlls="msvcp${VCVER}.dll msvcr${VCVER}.dll"
+    MSVC_DEBUG_DLLS="msvcp${VCVER}d.dll msvcr${VCVER}d.dll"
     if test "$VCVER" = "90"; then
         msvcdlls="$msvcdlls msvcm90.dll Microsoft.VC90.CRT.manifest"
+        MSVC_DEBUG_DLLS="$MSVC_DEBUG_DLLS msvcm90d.dll Microsoft.VC90.DebugCRT.manifest"
     fi
 
     for dll in $msvcdlls; do
@@ -4858,6 +4866,14 @@ find_msvc_dlls()
             AC_MSG_ERROR([can not find $dll in $msvcdllpath])
         fi
     done
+    if test -n "$MSVC_USE_DEBUG_RUNTIME"; then
+        for dll in $MSVC_DEBUG_DLLS; do
+            if ! test -f "$MSVC_DEBUG_DLL_PATH/$dll"; then
+                AC_MSG_ERROR([can not find $dll in $MSVC_DEBUG_DLL_PATH])
+            fi
+        done
+    fi
+
 }
 
 if test "$build_os" = "cygwin"; then
@@ -6031,6 +6047,8 @@ if test $_os = "WINNT" -a "$WITH_MINGW" != yes; then
 fi
 AC_SUBST(MSVC_DLL_PATH)
 AC_SUBST(MSVC_DLLS)
+AC_SUBST(MSVC_DEBUG_DLL_PATH)
+AC_SUBST(MSVC_DEBUG_DLLS)
 AC_SUBST(MSM_PATH)
 AC_SUBST(MERGE_MODULES)
 
diff --git a/external/Module_external.mk b/external/Module_external.mk
index 33453c4..ee6e994 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_Module_add_targets,external,\
 	Package_dbghelp \
 	Package_msms \
 	Package_msvc_dlls \
+	$(if $(MSVC_USE_DEBUG_RUNTIME),Package_msvc_dlls_debug) \
 	Package_msvc80_dlls \
 ))
 endif
diff --git a/external/Package_msvc_dlls_debug.mk b/external/Package_msvc_dlls_debug.mk
new file mode 100644
index 0000000..3e84764
--- /dev/null
+++ b/external/Package_msvc_dlls_debug.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Package_Package,msvc_dlls,$(MSVC_DEBUG_DLL_PATH)))
+
+$(eval $(call gb_Package_add_files,msvc_dlls,bin,\
+	$(MSVC_DEBUG_DLLS) \
+))
+
+# vim:set shiftwidth=4 tabstop=4 noexpandtab:
commit 436c7a1f58d2d29bcbfd7ff9fc9d7bee8e8df0e5
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Apr 14 18:39:27 2013 +0200

    on WNT the gb_Helper_set_ld_path must contain backslashes
    
    ... or at least with forward slashes cppunittester doesn't run at all in
    an MSVC 2008 _DEBUG build.
    
    Change-Id: I889ff0375067877d42f11fad9773c476e9e5c52c

diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk
index 153b2fb..18e1f0a 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -291,6 +291,7 @@ gb_LTOFLAGS := $(if $(filter TRUE,$(ENABLE_LTO)),-GL)
 gb_Helper_OUTDIRLIBDIR := $(OUTDIR)/bin
 gb_Helper_OUTDIR_FOR_BUILDLIBDIR := $(OUTDIR_FOR_BUILD)/bin
 
-gb_Helper_set_ld_path := PATH="$${PATH}:$(shell cygpath -u $(OUTDIR)/bin)"
+# need windows path with backslashes here
+gb_Helper_set_ld_path := PATH="$(shell cygpath -w $(OUTDIR)/bin)"
 
 # vim: set noet sw=4:
commit 21edda30c6309a81b05c7b6759725bb0f4652eca
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Apr 14 17:45:40 2013 +0200

    redland: fix an assertion in MSVC _DEBUG build
    
    Change-Id: I66d6932b0fa9753c56e6b6fc9dc0dd5fcbba3b36

diff --git a/redland/UnpackedTarball_redland.mk b/redland/UnpackedTarball_redland.mk
index dd2a15c..f90702d 100644
--- a/redland/UnpackedTarball_redland.mk
+++ b/redland/UnpackedTarball_redland.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_UnpackedTarball_set_tarball,redland,$(REDLAND_TARBALL)))
 $(eval $(call gb_UnpackedTarball_add_file,redland,src/librdf.h,redland/redland/librdf.h))
 
 $(eval $(call gb_UnpackedTarball_add_patches,redland,\
+	redland/redland/redland-query-rasqal-avoid-assert.patch.1 \
 	redland/redland/redland-pkgconfig.patch.1 \
 	redland/redland/redland-freebsd.patch.1 \
 	redland/redland/redland-msvc.patch.1 \
diff --git a/redland/redland/redland-query-rasqal-avoid-assert.patch.1 b/redland/redland/redland-query-rasqal-avoid-assert.patch.1
new file mode 100644
index 0000000..f219060
--- /dev/null
+++ b/redland/redland/redland-query-rasqal-avoid-assert.patch.1
@@ -0,0 +1,17 @@
+avoid an assert inside rasqal_query_results_next_triple
+
+Happens on the "CONSTRUCT" query in the unordf test.
+
+--- redland/src/rdf_query_rasqal.c	2013-04-14 17:32:08.442000000 +0200
++++ redland/src/rdf_query_rasqal.c	2013-04-14 17:31:57.834000000 +0200
+@@ -1096,7 +1096,9 @@
+     scontext->statement=NULL;
+   }
+ 
+-  scontext->finished=rasqal_query_results_next_triple(scontext->qcontext->results);
++  scontext->finished = !scontext->qcontext->results;
++  if(!scontext->finished)
++    scontext->finished=rasqal_query_results_next_triple(scontext->qcontext->results);
+   if(!scontext->finished)
+     librdf_query_rasqal_query_results_update_statement(scontext);
+   
commit 9ad00439ae205d7e0eaa39a807daea8268a4ecd4
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Apr 14 14:42:18 2013 +0200

    tune up debug level required for popping up dialogs from MSVCRTD
    
    Change-Id: I3cfa050ecf5c3c2ec66b11519c30d48459a9cafe

diff --git a/sal/osl/w32/system.h b/sal/osl/w32/system.h
index f3f36f7..d74a587 100644
--- a/sal/osl/w32/system.h
+++ b/sal/osl/w32/system.h
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#if OSL_DEBUG_LEVEL == 0
+#if OSL_DEBUG_LEVEL <= 3
 #    define NO_DEBUG_CRT
 #endif
 
commit 099e517ead8501260e914e1374e85bc8491a81ac
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Apr 12 00:30:03 2013 +0200

    extensions: remove various #undef _DEBUG
    
    These came in on issue 10000 a decade ago.
    
    Change-Id: Iae1995daa413e644ad869a6f02521634af8425b6

diff --git a/extensions/source/activex/SOActionsApproval.h b/extensions/source/activex/SOActionsApproval.h
index de2cf52..d40c142 100644
--- a/extensions/source/activex/SOActionsApproval.h
+++ b/extensions/source/activex/SOActionsApproval.h
@@ -31,10 +31,6 @@
 #include <ExDisp.h>
 #include <shlguid.h>
 
-#ifdef _MSC_VER
-#undef _DEBUG
-#endif
-
 #include <atlctl.h>
 
 #include "so_activex.h"
diff --git a/extensions/source/activex/SOActiveX.h b/extensions/source/activex/SOActiveX.h
index 4bef47a..908abf8 100644
--- a/extensions/source/activex/SOActiveX.h
+++ b/extensions/source/activex/SOActiveX.h
@@ -34,9 +34,6 @@
 #include <ExDisp.h>
 #include <shlguid.h>
 
-#ifdef _MSC_VER
-#undef _DEBUG
-#endif
 #include <atlctl.h>
 
 #include "so_activex.h"
diff --git a/extensions/source/activex/SOComWindowPeer.h b/extensions/source/activex/SOComWindowPeer.h
index 0e8dc37..9816ad3 100644
--- a/extensions/source/activex/SOComWindowPeer.h
+++ b/extensions/source/activex/SOComWindowPeer.h
@@ -31,9 +31,6 @@
 #include <ExDisp.h>
 #include <shlguid.h>
 
-#ifdef _MSC_VER
-#undef _DEBUG
-#endif
 #include <atlctl.h>
 
 #include "so_activex.h"
diff --git a/extensions/source/activex/SODispatchInterceptor.h b/extensions/source/activex/SODispatchInterceptor.h
index d873c6b..ab67066 100644
--- a/extensions/source/activex/SODispatchInterceptor.h
+++ b/extensions/source/activex/SODispatchInterceptor.h
@@ -31,9 +31,6 @@
 #include <ExDisp.h>
 #include <shlguid.h>
 
-#ifdef _MSC_VER
-#undef _DEBUG
-#endif
 #include <atlctl.h>
 
 #include "so_activex.h"
diff --git a/extensions/source/activex/StdAfx2.cxx b/extensions/source/activex/StdAfx2.cxx
index 82a8f54..9418fbb 100644
--- a/extensions/source/activex/StdAfx2.cxx
+++ b/extensions/source/activex/StdAfx2.cxx
@@ -30,8 +30,4 @@
 #include <statreg.h>
 #endif
 
-#ifdef _MSC_VER
-#undef _DEBUG
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/oledll.cxx b/extensions/source/ole/oledll.cxx
index a4b7595..6269377 100644
--- a/extensions/source/ole/oledll.cxx
+++ b/extensions/source/ole/oledll.cxx
@@ -25,9 +25,6 @@
 #pragma warning (push,1)
 #pragma warning (disable:4548)
 
-#if defined(_MSC_VER) && !defined(_DEBUG_RUNTIME)
-#undef _DEBUG
-#endif
 #ifdef __MINGW32__
 #define _INIT_ATL_COMMON_VARS
 #endif
diff --git a/extensions/source/ole/wincrap.hxx b/extensions/source/ole/wincrap.hxx
index c77e52e..e7c3084 100644
--- a/extensions/source/ole/wincrap.hxx
+++ b/extensions/source/ole/wincrap.hxx
@@ -26,10 +26,6 @@
 // http://stackoverflow.com/questions/5839292/error-c1189-after-installing-visual-studio-2010
 #define _WIN32_WINNT 0x0403
 
-#ifdef _MSC_VER
-#undef _DEBUG // why?
-#endif
-
 #define STRICT
 
 #define _WIN32_DCOM
commit 3213cd54b76bc80a6f0516aac75a48ff3b2ad67c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 8 10:59:59 2013 +0200

    gbuild: LinkTarget: only re-link libraries if exported symbols change
    
    Write out the exported symbols of a Library to a "libfoo.so.exports"
    file, which is only touched when linking if the exported symbols
    actually change, and let dependent LinkTargets depend on this
    exports file instead of the library itself, for faster rebuilds.
    
    This is currently supposed to work on ELF and MacOSX platforms.
    
    Thanks to Ami Fischman of Chromium for the idea.
    
    Change-Id: Ie4b5da0853140709e517028b514800b044527e61

diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 98964d7..f5c16f3 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -402,6 +402,7 @@ $(call gb_LinkTarget_get_clean_target,%) :
 		$(call gb_LinkTarget_get_headers_target,$*) \
 		$(call gb_LinkTarget_get_external_headers_target,$*) \
 		$(call gb_LinkTarget_get_objects_list,$*) \
+		$(call gb_LinkTarget_get_target,$*).exports \
 		$(DLLTARGET) \
 		$(AUXTARGETS)) && \
 		cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -fr && \
@@ -442,6 +443,14 @@ mv $${TEMPFILE} $(call gb_LinkTarget_get_objects_list,$(2))
 
 endef
 
+# Target for the .exports of the shared library, to speed up incremental build.
+# This deliberately does nothing if the file exists; the file is actually
+# written in gb_LinkTarget__command_dynamiclink.
+# Put this pattern rule here so it overrides the one below.
+# (this is rather ugly: because of % the functions cannot be used)
+$(call gb_LinkTarget_get_target,Library/%.exports) : $(gb_Library_OUTDIRLOCATION)/%
+	$(if $(wildcard $@),true,touch $@)
+
 $(call gb_LinkTarget_get_target,%) : $(call gb_LinkTarget_get_headers_target,%) $(gb_Helper_MISCDUMMY)
 	$(call gb_LinkTarget__command,$@,$*)
 	$(call gb_LinkTarget__command_objectlist,$@,$*)
@@ -830,7 +839,10 @@ endif
 
 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $(3)
 
-$(call gb_LinkTarget_get_target,$(1)) : $(foreach lib,$(3),$(call gb_Library_get_target,$(lib)))
+# depend on the exports of the library, not on the library itself
+# for faster incremental builds when the ABI is unchanged
+$(call gb_LinkTarget_get_target,$(1)) : \
+	$(foreach lib,$(3),$(call gb_Library_get_exports_target,$(lib)))
 $(call gb_LinkTarget_get_external_headers_target,$(1)) : \
 	$(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
 
diff --git a/solenv/gbuild/platform/com_GCC_class.mk b/solenv/gbuild/platform/com_GCC_class.mk
index c8a8d33..4f30a50 100644
--- a/solenv/gbuild/platform/com_GCC_class.mk
+++ b/solenv/gbuild/platform/com_GCC_class.mk
@@ -240,6 +240,10 @@ $(call gb_Helper_abbreviate_dirs,\
 		)
 endef
 
+define gb_Library_get_exports_target
+$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktargetname,$(1))).exports
+endef
+
 # YaccTarget class
 
 ifeq ($(ANCIENT_BISON),YES)
diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk
index a14a871..861626b 100755
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -351,6 +351,11 @@ define gb_Library_get_dllname
 $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Library_DLLFILENAMES)))
 endef
 
+# this is nerfed, it just points to the library to disable the .exports
+define gb_Library_get_exports_target
+$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktargetname,$(1)))
+endef
+
 
 # StaticLibrary class
 
diff --git a/solenv/gbuild/platform/macosx.mk b/solenv/gbuild/platform/macosx.mk
index a780c59..011aaae 100644
--- a/solenv/gbuild/platform/macosx.mk
+++ b/solenv/gbuild/platform/macosx.mk
@@ -163,6 +163,14 @@ $(call gb_Helper_abbreviate_dirs,\
 	$(if $(MACOSX_CODESIGNING_IDENTITY), \
 		$(if $(filter Executable,$(TARGETTYPE)), \
 			codesign --timestamp=none --identifier=$(MACOSX_BUNDLE_IDENTIFIER).$(notdir $(1)) --sign $(MACOSX_CODESIGNING_IDENTITY) $(1) &&)) \
+	$(if $(filter Library,$(TARGETTYPE)),\
+		otool -l $(1) | grep -A 5 LC_ID_DYLIB > $(1).exports.tmp && \
+		$(NM) -g -P $(1) | cut -d' ' -f1-2 | grep -v U$$ \
+			>> $(1).exports.tmp && \
+		if cmp -s $(1).exports.tmp $(1).exports; \
+			then rm $(1).exports.tmp; \
+			else mv $(1).exports.tmp $(1).exports; touch -r $(1) $(1).exports; \
+		fi &&) \
 	:)
 endef
 
diff --git a/solenv/gbuild/platform/solaris.mk b/solenv/gbuild/platform/solaris.mk
index d4780aeb..cfcca9e 100644
--- a/solenv/gbuild/platform/solaris.mk
+++ b/solenv/gbuild/platform/solaris.mk
@@ -199,6 +199,14 @@ $(call gb_Helper_abbreviate_dirs,\
 		$(LIBS) \
 		$(patsubst lib%.a,-l%,$(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib))))) \
 		-o $(1))
+	$(if $(filter Library,$(TARGETTYPE)),\
+		$(NM) --extern-only --dynamic --format=posix $(1) \
+			| cut -d' ' -f1-2 | grep -v U$$ \
+			> $(1).exports.tmp && \
+		if cmp -s $(1).exports.tmp $(1).exports; \
+			then rm $(1).exports.tmp; \
+			else mv $(1).exports.tmp $(1).exports; touch -r $(1) $(1).exports; \
+		fi)
 endef
 
 define gb_LinkTarget__command_staticlink
diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk
index 01b0790..a327593 100644
--- a/solenv/gbuild/platform/unxgcc.mk
+++ b/solenv/gbuild/platform/unxgcc.mk
@@ -202,6 +202,15 @@ $(call gb_Helper_abbreviate_dirs,\
 		$(patsubst lib%.a,-l%,$(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib))))) \
 		-o $(if $(SOVERSION),$(1).$(SOVERSION),$(1)))
 	$(if $(SOVERSION),ln -sf $(notdir $(1)).$(SOVERSION) $(1))
+	$(if $(filter Library,$(TARGETTYPE)),\
+		readelf -d $(1) | grep SONAME > $(1).exports.tmp ; \
+		$(NM) --dynamic --extern-only --defined-only --format=posix $(1) \
+			| cut -d' ' -f1-2 \
+			>> $(1).exports.tmp && \
+		if cmp -s $(1).exports.tmp $(1).exports; \
+			then rm $(1).exports.tmp; \
+			else mv $(1).exports.tmp $(1).exports; touch -r $(1) $(1).exports; \
+		fi)
 endef
 
 define gb_LinkTarget__command_staticlink


More information about the Libreoffice-commits mailing list