[librsvg/nmake: 4/6] Visual Studio builds: Add a set of NMake Makefiles



commit 2ebbc10859c0922f7b728a5ee9b6ce499164a52e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jun 26 19:05:07 2019 +0800

    Visual Studio builds: Add a set of NMake Makefiles
    
    This adds a set of NMake Makefiles, which will replace the Visual Studio
    projects, so that we can have a more flexible build setup, and would be
    usable for Visual Studio 2013 and later.
    
    This also has the advantage to build optional items (such as rsvg-view-3,
    which requires GTK, and Introspection) on demand in one go.
    
    This will also enable the removal of the autotools 'dist hook'
    directives that are being used to generate the complete Visual Studio
    projects, as we are now able to share source listings with the autotools
    build files directly.

 win32/Makefile.am            |  12 ++-
 win32/Makefile.vc            |  70 ++++++++++++++++++
 win32/build-rules-msvc.mak   | 169 +++++++++++++++++++++++++++++++++++++++++++
 win32/config-msvc.mak        | 154 +++++++++++++++++++++++++++++++++++++++
 win32/create-lists-msvc.mak  |  89 +++++++++++++++++++++++
 win32/create-lists.bat       |  42 +++++++++++
 win32/detectenv-msvc.mak     |  22 ++++--
 win32/generate-msvc.mak      |  31 ++++++++
 win32/info-msvc.mak          | 104 ++++++++++++++++++++++++++
 win32/install.mak            |  21 ++++++
 win32/introspection-msvc.mak |  22 +++---
 win32/rsvg-rust.mak          |  13 +++-
 12 files changed, 724 insertions(+), 25 deletions(-)
---
diff --git a/win32/Makefile.am b/win32/Makefile.am
index fb64889c..f3591c66 100644
--- a/win32/Makefile.am
+++ b/win32/Makefile.am
@@ -24,10 +24,18 @@ GENERATED_ITEMS =
 endif
 
 EXTRA_DIST = \
-       rsvg-introspection-msvc.mak     \
-       introspection-msvc.mak  \
+       build-rules-msvc.mak    \
+       config-msvc.mak         \
+       create-lists.bat        \
+       create-lists-msvc.mak   \
        detectenv-msvc.mak      \
+       generate-msvc.mak       \
+       info-msvc.mak           \
+       install-msvc.mak        \
+       introspection-msvc.mak  \
+       Makefile.vc             \
        rsvg-rust.mak           \
+       rsvg-introspection-msvc.mak     \
        pc_base.py              \
        replace.py              \
        rsvgpc.py               \
diff --git a/win32/Makefile.vc b/win32/Makefile.vc
new file mode 100644
index 00000000..0dc13e79
--- /dev/null
+++ b/win32/Makefile.vc
@@ -0,0 +1,70 @@
+# NMake Makefile for building librsvg on Windows
+
+# The items below this line should not be changed, unless one is maintaining
+# the NMake Makefiles.  Customizations can be done in the following NMake Makefile
+# portions (please see comments in the these files to see what can be customized):
+#
+# detectenv-msvc.mak
+# config-msvc.mak
+!include detectenv-msvc.mak
+
+# Include the Makefile portions with the source listings
+!include ..\rsvg-c-srcs.mk
+
+# Include the Makefile portion that enables features based on user input
+!include config-msvc.mak
+
+!ifdef INTROSPECTION
+!include introspection-msvc.mak
+!endif
+
+!if "$(VALID_CFGSET)" == "TRUE"
+
+# We need Visual Studio 2013 or later
+!if $(VCVERSION) < 1800
+VALID_MSC = FALSE
+!else
+VALID_MSC = TRUE
+!endif
+
+!if "$(VALID_MSC)" == "TRUE"
+
+# Include the Makefile portion to convert the source and header lists
+# into the lists we need for compilation and introspection
+
+all: $(RSVG_TOOLS) $(RSVG_EXTRA_TOOLS) $(EXTRA_TARGETS) build-info-librsvg
+
+# Include the build rules for Rust builds, sources, DLLs and executables
+!include rsvg-rust.mak
+!include create-lists-msvc.mak
+!include build-rules-msvc.mak
+
+tests: all $(rsvg_tests)
+       @set PATH=$(BINDIR);$(PATH)
+       set G_TEST_SRCDIR=$(MAKEDIR)\..\tests
+       @for %%x in ($(rsvg_tests)) do %%x
+
+# Include the rules for build directory creation and code generation
+!include generate-msvc.mak
+
+# Generate the introspection files
+
+!if "$(INTROSPECTION)" == "1"
+# Include the rules for building the introspection files
+!include introspection-msvc.mak
+!endif
+
+!include install.mak
+
+!else # "$(VALID_MSC)" == "TRUE"
+all:
+       @echo You need Visual Studio 2013 or later.
+
+!endif # "$(VALID_MSC)" == "TRUE"
+
+!else # "$(VALID_CFGSET)" == "TRUE"
+all: help
+       @echo You need to specify a valid configuration, via CFG=release or CFG=debug
+!endif # "$(VALID_CFGSET)" == "TRUE"
+
+!include info-msvc.mak
diff --git a/win32/build-rules-msvc.mak b/win32/build-rules-msvc.mak
new file mode 100644
index 00000000..8c110fe3
--- /dev/null
+++ b/win32/build-rules-msvc.mak
@@ -0,0 +1,169 @@
+# NMake Makefile portion for compilation rules
+# Items in here should not need to be edited unless
+# one is maintaining the NMake build files.  The format
+# of NMake Makefiles here are different from the GNU
+# Makefiles.  Please see the comments about these formats.
+
+# Inference rules for compiling the .obj files.
+# Used for libs and programs with more than a single source file.
+# Format is as follows
+# (all dirs must have a trailing '\'):
+#
+# {$(srcdir)}.$(srcext){$(destdir)}.obj::
+#      $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<<
+# $<
+# <<
+{..\librsvg\}.c{$(OUTDIR)\librsvg\}.obj:
+       @if not exist $(@D) $(MAKE) /f Makefile.vc CFG=$(CFG) $(@D)
+       $(CC) $(LIBRSVG_CFLAGS) $(LIBRSVG_INCLUDES) /Fo$(@D)\ /Fd$(@D)\ /c @<<
+$<
+<<
+
+{..\gdk-pixbuf-loader\}.c{$(OUTDIR)\rsvg-gdk-pixbuf-loader\}.obj:
+       @if not exist $(@D) $(MAKE) /f Makefile.vc CFG=$(CFG) $(@D)
+       $(CC) $(RSVG_PIXBUF_LOADER_CFLAGS) $(TOOLS_DEP_INCLUDES) /Fo$(@D)\ /Fd$(@D)\ /c @<<
+$<
+<<
+
+{..\}.c{$(OUTDIR)\rsvg-tools\}.obj:
+       @if not exist $(@D) $(MAKE) /f Makefile.vc CFG=$(CFG) $(@D)
+       $(CC) $(BASE_CFLAGS) $(TOOLS_DEP_INCLUDES) /Fo$(@D)\ /Fd$(@D)\ /c @<<
+$<
+<<
+
+{..\tools\}.c{$(OUTDIR)\rsvg-tools\}.obj:
+       @if not exist $(@D) $(MAKE) /f Makefile.vc CFG=$(CFG) $(@D)
+       $(CC) $(BASE_CFLAGS) $(LIBRSVG_LOG_DOMAIN) $(TOOLS_DEP_INCLUDES) /Fo$(@D)\ /Fd$(@D)\ /c @<<
+$<
+<<
+
+{..\tests\}.c{$(OUTDIR)\rsvg-tests\}.obj:
+       @if not exist $(@D) $(MAKE) /f Makefile.vc CFG=$(CFG) $(@D)
+       $(CC) $(TEST_CFLAGS) $(LIBRSVG_LOG_DOMAIN) $(TOOLS_DEP_INCLUDES) /Fo$(@D)\ /Fd$(@D)\ /c @<<
+$<
+<<
+
+# Rules for building .lib files
+$(LIBRSVG_LIB): $(LIBRSVG_DLL)
+
+# Rules for linking DLLs
+# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
+# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
+#      link /DLL [$(linker_flags)] [$(dependent_libs)] [/def:$(def_file_if_used)] 
[/implib:$(lib_name_if_needed)] -out:$@ @<<
+# $(dependent_objects)
+# <<
+#      @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
+$(LIBRSVG_DLL):        \
+$(RSVG_INTERNAL_LIB)           \
+$(OUTDIR)\librsvg\rsvg.def     \
+$(OUTDIR)\librsvg\config.h     \
+$(librsvg_OBJS)
+       link /DLL $(LDFLAGS)    \
+       $(LIBRSVG_DEP_LIBS)     \
+       /def:$(OUTDIR)\librsvg\rsvg.def \
+       /implib:$(LIBRSVG_LIB)  \
+       -out:$@ @<<
+$(librsvg_OBJS)
+<<
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
+
+$(GDK_PIXBUF_SVG_LOADER): $(LIBRSVG_LIB) $(OUTDIR)\rsvg-gdk-pixbuf-loader\io-svg.obj
+       link /DLL $(LDFLAGS) $** $(BASE_DEP_LIBS) /out:$@
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
+
+# Rules for linking Executables
+# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
+# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
+#      link [$(linker_flags)] [$(dependent_libs)] -out:$@ @<<
+# $(dependent_objects)
+# <<
+#      @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
+$(OUTDIR)\rsvg-convert.exe: $(LIBRSVG_LIB) $(OUTDIR)\rsvg-tools\rsvg-convert.obj
+$(OUTDIR)\rsvg-view-3.exe: $(LIBRSVG_LIB) $(OUTDIR)\rsvg-tools\rsvg-view.obj
+
+$(OUTDIR)\rsvg-dimensions.exe: \
+       $(LIBRSVG_LIB)  \
+       $(OUTDIR)\rsvg-tools\rsvg-dimensions.obj        \
+       $(OUTDIR)\rsvg-tools\rsvg-tools-main.obj
+
+$(OUTDIR)\test-performance.exe:        \
+       $(LIBRSVG_LIB)  \
+       $(OUTDIR)\rsvg-tools\test-performance.obj       \
+       $(OUTDIR)\rsvg-tools\rsvg-tools-main.obj
+
+$(OUTDIR)\rsvg-convert.exe     \
+$(OUTDIR)\rsvg-view-3.exe      \
+$(OUTDIR)\rsvg-dimensions.exe  \
+$(OUTDIR)\test-performance.exe:
+       link $(LDFLAGS) $** $(TOOLS_DEP_LIBS) /out:$@
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
+
+# Include the rules for the test programs
+!include rsvg_tests_rules.mak
+
+!if [del /f /q rsvg_tests_rules.mak]
+!endif
+
+$(rsvg_tests):
+       link $(LDFLAGS) $** $(TEST_DEP_LIBS) /out:$@
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
+
+!ifdef INTROSPECTION
+$(OUTDIR)\Rsvg-$(RSVG_API_VER).gir: $(LIBRSVG_LIB) $(OUTDIR)\librsvg\Rsvg_2_0_gir_list
+       @-echo Generating $@...
+       @set PATH=$(BINDIR);$(PATH)
+       $(PYTHON) $(G_IR_SCANNER)       \
+       --verbose -no-libtool   \
+       --namespace=Rsvg        \
+       --nsversion=2.0 \
+       --pkg=pango --extra-library=libxml2     \
+       --library=rsvg-2.0      \
+       --add-include-path=$(G_IR_INCLUDEDIR)   \
+       --include=GLib-2.0 --include=GObject-2.0        \
+       --include=Gio-2.0 --include=cairo-1.0   \
+       --include=GdkPixbuf-2.0 \
+       --pkg-export=librsvg-2.0        \
+       --cflags-begin  \
+       $(LIBRSVG_INCLUDES:/I=-I) -DRSVG_COMPILATION    \
+       $(EXTRA_BASE_CFLAGS:/=-)        \
+       --cflags-end    \
+       --c-include=librsvg/rsvg.h      \
+       --filelist=$(OUTDIR)\librsvg\Rsvg_2_0_gir_list  \
+       -L.\$(OUTDIR) -L$(LIBDIR) -L$(BINDIR)   \
+       -o $@
+
+$(OUTDIR)\Rsvg-2.0.typelib: $(OUTDIR)\Rsvg-2.0.gir
+       @-echo Compiling $@...
+       $(G_IR_COMPILER)        \
+       --includedir=. --includedir=$(G_IR_TYPELIBDIR) --debug --verbose        \
+       $(@D:\=/)/$(@B).gir     \
+       -o $@
+!endif
+
+clean:
+       @if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).typelib del /f /q $(OUTDIR)\Rsvg-$(RSVG_API_VER).typelib
+       @if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).gir del /f /q $(OUTDIR)\Rsvg-$(RSVG_API_VER).gir
+       @-del /f /q $(OUTDIR)\*.dll
+       @-del /f /q $(OUTDIR)\*.exe
+       @-del /f /q $(OUTDIR)\*.dll
+       @-del /f /q $(OUTDIR)\*.pdb
+       @-del /f /q $(OUTDIR)\*.ilk
+       @-del /f /q $(OUTDIR)\*.exp
+       @-del /f /q $(OUTDIR)\*.lib
+       @-del /s /q $(OUTDIR)\rsvg-tests\*.obj
+       @-del /s /q $(OUTDIR)\rsvg-tests\*.pdb
+       @-del /s /q $(OUTDIR)\rsvg-tools\*.obj
+       @-del /s /q $(OUTDIR)\rsvg-tools\*.pdb
+       @-del /s /q $(OUTDIR)\rsvg-gdk-pixbuf-loader\*.obj
+       @-del /s /q $(OUTDIR)\rsvg-gdk-pixbuf-loader\*.pdb
+       @-del /s /q $(OUTDIR)\rsvg-tools\*.pdb
+       @-del /s /q $(OUTDIR)\librsvg\Rsvg_2_0_gir_list
+       @-del /s /q $(OUTDIR)\librsvg\*.obj
+       @-del /s /q $(OUTDIR)\librsvg\*.pdb
+       @-rmdir /s /q $(OUTDIR)\output
+       @-rmdir /s /q $(OUTDIR)\rsvg-tests
+       @-rmdir /s /q $(OUTDIR)\rsvg-tools
+       @-rmdir /s /q $(OUTDIR)\rsvg-gdk-pixbuf-loader
+       @-rmdir /s /q $(OUTDIR)\librsvg
+       $(MAKE) /f rsvg-rust.mak CFG=$(CFG) cargo-clean
+       @-rmdir /s /q $(OUTDIR)\obj
diff --git a/win32/config-msvc.mak b/win32/config-msvc.mak
new file mode 100644
index 00000000..1968cbef
--- /dev/null
+++ b/win32/config-msvc.mak
@@ -0,0 +1,154 @@
+# NMake Makefile portion for enabling features for Windows builds
+
+# Please do not change anything beneath this line unless maintaining the NMake Makefiles
+OUTDIR = vs$(VSVER)\$(CFG)\$(PLAT)
+RSVG_VER = 2
+RSVG_API_VER = $(RSVG_VER).0
+CHECK_GIR_PACKAGE = gdk-pixbuf-2.0
+
+# Make bin, include and library directories of configurable
+!ifndef BINDIR
+BINDIR=$(PREFIX)\bin
+!endif
+
+!ifndef LIBDIR
+LIBDIR=$(PREFIX)\lib
+!endif
+
+!ifndef INCLUDEDIR
+INCLUDEDIR=$(PREFIX)\include
+!endif
+
+LDFLAGS = $(LDFLAGS) /libpath:$(LIBDIR)
+
+# These are the base minimum libraries required for building librsvg.
+
+# Visual Studio 2015 and later supports the /utf-8 compiler flag
+# that prevents C4819 warnings/errors on non-Western locales
+!if $(VSVER) > 12
+EXTRA_BASE_CFLAGS = /utf-8
+!else
+EXTRA_BASE_CFLAGS =
+!endif
+
+BASE_CFLAGS =  \
+       $(CFLAGS_ADD)           \
+       /DHAVE_CONFIG_H         \
+       /FImsvc_recommended_pragmas.h   \
+       $(EXTRA_BASE_CFLAGS)
+
+BASE_DEP_INCLUDES =                            \
+       /I$(INCLUDEDIR)\gdk-pixbuf-2.0  \
+       /I$(INCLUDEDIR)\gio-win32-2.0   \
+       /I$(INCLUDEDIR)\glib-2.0                \
+       /I$(LIBDIR)\glib-2.0\include    \
+       /I$(INCLUDEDIR)
+
+BASE_DEP_LIBS =                \
+       gdk_pixbuf-2.0.lib      \
+       gio-2.0.lib     \
+       gobject-2.0.lib \
+       glib-2.0.lib    \
+       cairo.lib       \
+       intl.lib
+
+LIBRSVG_LOG_DOMAIN = /DG_LOG_DOMAIN=\"librsvg\"
+
+LIBRSVG_CFLAGS =                       \
+       $(BASE_CFLAGS)          \
+       $(LIBRSVG_LOG_DOMAIN)           \
+       /DRSVG_DISABLE_DEPRECATION_WARNINGS     \
+       /DRSVG_COMPILATION
+
+LIBRSVG_INCLUDES =                     \
+       /I..                            \
+       /I.\$(OUTDIR)\librsvg   \
+       /I$(INCLUDEDIR)\pango-1.0       \
+       /I$(INCLUDEDIR)\libcroco-0.6    \
+       $(BASE_DEP_INCLUDES)    \
+       /I$(INCLUDEDIR)\libxml2
+
+TEST_CFLAGS = $(BASE_CFLAGS)
+TEST_DEP_LIBS = $(TOOLS_DEP_LIBS)
+
+# Use PangoFT2 (for tests only)
+!ifdef USE_PANGOFT2
+TEST_CFLAGS =  \
+       $(TEST_CFLAGS)  \
+       /DHAVE_PANGOFT2
+
+TEST_DEP_LIBS =        \
+       $(TEST_DEP_LIBS)        \
+       pangoft2-1.0.lib        \
+       fontconfig.lib
+!endif
+
+RSVG_INTERNAL_LIB = $(OUTDIR)\obj\rsvg_internals\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg_internals.lib
+
+LIBRSVG_DEP_LIBS =     \
+       $(RSVG_INTERNAL_LIB)    \
+       pangocairo-1.0.lib      \
+       $(LIBRSVG_EXTRA_DEP_LIBS)       \
+       pango-1.0.lib   \
+       cairo-gobject.lib       \
+       croco-0.6.lib   \
+       $(BASE_DEP_LIBS)        \
+       libxml2.lib     \
+       advapi32.lib    \
+       userenv.lib             \
+       ws2_32.lib
+
+RSVG_PIXBUF_LOADER_CFLAGS =    \
+       $(BASE_CFLAGS)          \
+       /DGDK_PIXBUF_ENABLE_BACKEND     \
+       /DG_LOG_DOMAIN=\"libpixbufloader-svg\"
+
+!if "$(LIBTOOL_DLL_NAME)" == "1"
+LIBRSVG_DLL_FILENAME = $(OUTDIR)\librsvg-$(RSVG_API_VER)-0
+!else
+LIBRSVG_DLL_FILENAME = $(OUTDIR)\rsvg-$(RSVG_API_VER)-vs$(VSVER)
+!endif
+
+LIBRSVG_DLL = $(LIBRSVG_DLL_FILENAME).dll
+LIBRSVG_LIB = $(OUTDIR)\rsvg-$(RSVG_API_VER).lib
+
+GDK_PIXBUF_SVG_LOADER = $(OUTDIR)\libpixbufloader-svg.dll
+
+TOOLS_DEP_INCLUDES =   \
+       /I..    \
+       /I.\$(OUTDIR)\librsvg   \
+       $(BASE_DEP_INCLUDES)
+
+TOOLS_DEP_LIBS = $(BASE_DEP_LIBS)
+
+RSVG_TOOLS = $(OUTDIR)\rsvg-convert.exe
+
+RSVG_EXTRA_TOOLS =     \
+       $(OUTDIR)\rsvg-dimensions.exe   \
+       $(OUTDIR)\test-performance.exe
+
+# Build rsvg-view-3, which requires GTK
+!ifndef NO_GTK
+RSVG_TOOLS =   \
+       $(RSVG_TOOLS)   \
+       $(OUTDIR)\rsvg-view-3.exe
+
+TOOLS_DEP_INCLUDES =   \
+       /I$(INCLUDEDIR)\gtk-3.0 \
+       /I$(INCLUDEDIR)\pango-1.0       \
+       /I$(INCLUDEDIR)\atk-1.0 \
+       $(TOOLS_DEP_INCLUDES)
+
+TOOLS_DEP_LIBS =       \
+       gtk-3.0.lib     \
+       gdk-3.0.lib     \
+       $(TOOLS_DEP_LIBS)
+!endif
+
+# Build Introspection if requested
+EXTRA_TARGETS = $(GDK_PIXBUF_SVG_LOADER)
+!ifdef INTROSPECTION
+EXTRA_TARGETS =        \
+       $(EXTRA_TARGETS)        \
+       $(OUTDIR)\Rsvg-2.0.typelib
+!endif
diff --git a/win32/create-lists-msvc.mak b/win32/create-lists-msvc.mak
new file mode 100644
index 00000000..06541a84
--- /dev/null
+++ b/win32/create-lists-msvc.mak
@@ -0,0 +1,89 @@
+# Convert the source listing to object (.obj) listing in
+# another NMake Makefile module, include it, and clean it up.
+# This is a "fact-of-life" regarding NMake Makefiles...
+# This file does not need to be changed unless one is maintaining the NMake Makefiles
+
+# For those wanting to add things here:
+# To add a list, do the following:
+# # $(description_of_list)
+# if [call create-lists.bat header $(makefile_snippet_file) $(variable_name)]
+# endif
+#
+# if [call create-lists.bat file $(makefile_snippet_file) $(file_name)]
+# endif
+#
+# if [call create-lists.bat footer $(makefile_snippet_file)]
+# endif
+# ... (repeat the if [call ...] lines in the above order if needed)
+# !include $(makefile_snippet_file)
+#
+# (add the following after checking the entries in $(makefile_snippet_file) is correct)
+# (the batch script appends to $(makefile_snippet_file), you will need to clear the file unless the 
following line is added)
+#!if [del /f /q $(makefile_snippet_file)]
+#!endif
+
+# In order to obtain the .obj filename that is needed for NMake Makefiles to build DLLs/static LIBs or EXEs, 
do the following
+# instead when doing 'if [call create-lists.bat file $(makefile_snippet_file) $(file_name)]'
+# (repeat if there are multiple $(srcext)'s in $(source_list), ignore any headers):
+# !if [for %c in ($(source_list)) do @if "%~xc" == ".$(srcext)" @call create-lists.bat file 
$(makefile_snippet_file) $(intdir)\%~nc.obj]
+#
+# $(intdir)\%~nc.obj needs to correspond to the rules added in build-rules-msvc.mak
+# %~xc gives the file extension of a given file, %c in this case, so if %c is a.cc, %~xc means .cc
+# %~nc gives the file name of a given file without extension, %c in this case, so if %c is a.cc, %~nc means a
+
+NULL=
+
+# For librsvg
+
+!if [call create-lists.bat header rsvg_objs.mak librsvg_real_SRCS]
+!endif
+
+!if [for %s in ($(librsvg_c_srcs:/=\)) do @call create-lists.bat file rsvg_objs.mak ..\%s]
+!endif
+
+!if [call create-lists.bat footer rsvg_objs.mak]
+!endif
+
+!if [call create-lists.bat header rsvg_objs.mak librsvg_real_pub_HDRS]
+!endif
+
+!if [for %s in ($(headers:/=\)) do @call create-lists.bat file rsvg_objs.mak ..\%s]
+!endif
+
+!if [call create-lists.bat footer rsvg_objs.mak]
+!endif
+
+!if [call create-lists.bat header rsvg_objs.mak librsvg_real_extra_pub_HDRS]
+!endif
+
+!if [for %s in ($(extra_inc_headers:/=\)) do @call create-lists.bat file rsvg_objs.mak ..\%s]
+!endif
+
+!if [call create-lists.bat footer rsvg_objs.mak]
+!endif
+
+!if [call create-lists.bat header rsvg_objs.mak librsvg_OBJS]
+!endif
+
+!if [for %c in ($(librsvg_c_srcs:/=\)) do @if "%~xc" == ".c" @call create-lists.bat file rsvg_objs.mak 
^$(OUTDIR)\librsvg\%~nc.obj]
+!endif
+
+!if [call create-lists.bat footer rsvg_objs.mak]
+!endif
+
+!if [call create-lists.bat header rsvg_objs.mak rsvg_tests]
+!endif
+
+!if [for %c in (..\tests\*.c) do @if not "%~nxc" == "test-utils.c" call create-lists.bat file rsvg_objs.mak 
^$(OUTDIR)\%~nc.exe]
+!endif
+
+!if [call create-lists.bat footer rsvg_objs.mak]
+!endif
+
+!if [for %c in (..\tests\*.c) do @if not "%~nxc" == "test-utils.c" @echo ^$(OUTDIR)\%~nc.exe: 
^$(LIBRSVG_LIB) ^$(OUTDIR)\rsvg-tests\%~nc.obj ^$(OUTDIR)\rsvg-tests\test-utils.obj >>rsvg_tests_rules.mak]
+!endif
+
+!include rsvg_objs.mak
+
+!if [del /f /q rsvg_objs.mak]
+!endif
\ No newline at end of file
diff --git a/win32/create-lists.bat b/win32/create-lists.bat
new file mode 100644
index 00000000..ef60d5ce
--- /dev/null
+++ b/win32/create-lists.bat
@@ -0,0 +1,42 @@
+@echo off
+rem Simple .bat script for creating the NMake Makefile snippets.
+
+if not "%1" == "header" if not "%1" == "file" if not "%1" == "footer" goto :error_cmd
+if "%2" == "" goto error_no_destfile
+
+if "%1" == "header" goto :header
+if "%1" == "file" goto :addfile
+if "%1" == "footer" goto :footer
+
+:header
+if "%3" == "" goto error_var
+echo %3 =      \>>%2
+goto done
+
+:addfile
+if "%3" == "" goto error_file
+echo.  %3      \>>%2
+goto done
+
+:footer
+echo.  $(NULL)>>%2
+echo.>>%2
+goto done
+
+:error_cmd
+echo Specified command '%1' was invalid.  Valid commands are: header file footer.
+goto done
+
+:error_no_destfile
+echo Destination NMake snippet file must be specified
+goto done
+
+:error_var
+echo A name must be specified for using '%1'.
+goto done
+
+:error_file
+echo A file must be specified for using '%1'.
+goto done
+
+:done
\ No newline at end of file
diff --git a/win32/detectenv-msvc.mak b/win32/detectenv-msvc.mak
index 787a8974..75462e2e 100644
--- a/win32/detectenv-msvc.mak
+++ b/win32/detectenv-msvc.mak
@@ -58,6 +58,10 @@ version is not supported.
 !error $(MSG)
 !endif
 
+!ifndef PREFIX
+PREFIX=..\..\vs$(VSVER)\$(PLAT)
+!endif
+
 VALID_CFGSET = FALSE
 !if "$(CFG)" == "release" || "$(CFG)" == "debug" || "$(CFG)" == "Release" || "$(CFG)" == "Debug"
 VALID_CFGSET = TRUE
@@ -65,16 +69,20 @@ VALID_CFGSET = TRUE
 
 # We want debugging symbols logged for all builds,
 # using .pdb files for release builds
-CFLAGS_BASE = /Zi
-
-!if "$(CFG)" == "release" || "$(CFG)" == "Release"
-CFLAGS_ADD = /MD /O2 $(CFLAGS_BASE)
-!else
-CFLAGS_ADD = /MDd /Od $(CFLAGS_BASE)
-!endif
+CFLAGS_BASE = /W3 /Zi
 
 !if "$(PLAT)" == "x64"
 LDFLAGS_ARCH = /machine:x64
 !else
 LDFLAGS_ARCH = /machine:x86
 !endif
+
+LDFLAGS_BASE = $(LDFLAGS_ARCH) /DEBUG
+
+!if "$(CFG)" == "release" || "$(CFG)" == "Release"
+CFLAGS_ADD = /MD /O2 /GL /MP /d2Zi+ $(CFLAGS_BASE)
+LDFLAGS = $(LDFLAGS_BASE) /LTCG /opt:ref
+!else
+CFLAGS_ADD = /MDd /Od $(CFLAGS_BASE)
+LDFLAGS = $(LDFLAGS_BASE)
+!endif
diff --git a/win32/generate-msvc.mak b/win32/generate-msvc.mak
new file mode 100644
index 00000000..d9652703
--- /dev/null
+++ b/win32/generate-msvc.mak
@@ -0,0 +1,31 @@
+# NMake Makefile portion for code generation and
+# intermediate build directory creation
+# Items in here should not need to be edited unless
+# one is maintaining the NMake build files.
+
+# Copy the pre-defined config.h.win32
+$(OUTDIR)\librsvg\config.h: ..\config.h.win32
+       @if not exist $(@D) $(MAKE) /f Makefile.vc CFG=$(CFG) $(@D)
+       @-copy $** $@
+
+# Create the build directories
+$(OUTDIR)\librsvg      \
+$(OUTDIR)\rsvg-gdk-pixbuf-loader       \
+$(OUTDIR)\rsvg-tools   \
+$(OUTDIR)\rsvg-tests:
+       @-mkdir $@
+
+# Generate the .def file
+$(OUTDIR)\librsvg\rsvg.def: ..\rsvg.symbols
+       @if not exist $(@D) $(MAKE) /f Makefile.vc CFG=$(CFG) $(@D)
+       @echo EXPORTS > $@
+       $(CPP) /EP $** >> $@
+
+# Generate listing file for introspection
+$(OUTDIR)\librsvg\Rsvg_2_0_gir_list:   \
+$(librsvg_real_pub_HDRS)       \
+$(librsvg_real_extra_pub_HDRS) \
+$(librsvg_real_SRCS)
+       @if exist $@ del $@
+       @for %%s in ($(librsvg_real_pub_HDRS) $(librsvg_real_extra_pub_HDRS)) do echo %%s >> $@
+       @for %%s in ($(librsvg_real_SRCS)) do @if "%%~xs" == ".c" echo %%s >> $@
\ No newline at end of file
diff --git a/win32/info-msvc.mak b/win32/info-msvc.mak
new file mode 100644
index 00000000..59df98ad
--- /dev/null
+++ b/win32/info-msvc.mak
@@ -0,0 +1,104 @@
+# NMake Makefile portion for displaying config info
+
+!ifdef INTROSPECTION
+BUILD_INTROSPECTION = yes
+!else
+BUILD_INTROSPECTION = no
+!endif
+
+!if "$(CFG)" == "release" || "$(CFG)" == "Release"
+BUILD_TYPE = release
+!else
+BUILD_TYPE = debug
+!endif
+
+build-info-librsvg:
+       @echo.
+       @echo =========================
+       @echo Configuration for librsvg
+       @echo =========================
+       @echo Build Type: $(BUILD_TYPE)
+       @echo.
+       @echo Built Tools:
+       @for %%t in ($(RSVG_TOOLS:.exe=) $(RSVG_EXTRA_TOOLS:.exe=)) do @echo %%~nt
+       @echo.
+       @echo Introspection: $(BUILD_INTROSPECTION)
+
+help:
+       @echo.
+       @echo ============================
+       @echo Building librsvg Using NMake
+       @echo ============================
+       @echo nmake /f Makefile.vc CFG=[release^|debug] ^<PREFIX=PATH^> ... OPTION=1 ...
+       @echo.
+       @echo Where:
+       @echo ------
+       @echo CFG: Required, use CFG=release for an optimized build and CFG=debug
+       @echo for a debug build.  PDB files are generated for all builds.
+       @echo.
+       @echo PREFIX: Optional, the path where dependent libraries and tools may be
+       @echo found, default is ^$(srcrootdir)\..\vs^$(short_vs_ver)\^$(platform),
+       @echo where ^$(short_vs_ver) is 12 for VS 2013, 14 for VS 2015 and so on; and
+       @echo ^$(platform) is Win32 for 32-bit builds and x64 for x64 builds.
+       @echo.
+       @echo BINDIR: Optional, the path where dependent external DLL and executables
+       @echo may be found, default is ^$(PREFIX)\bin.  Note that for introspection
+       @echo builds, dependent .gir and .typelib files are searched first in
+       @echo $(BINDIR)\..\share\gir-1.0 and $(BINDIR)\..\lib\girepository-1.0.
+       @echo.
+       @echo LIBDIR: Optional, the path where dependent external .lib's may be found,
+       @echo default is ^$(PREFIX)\lib.  Note that for introspection builds, this
+       @echo influences that $(LIBDIR)\pkgconfig will be searched first for pkg-config
+       @echo files.
+       @echo.
+       @echo INCLUDEDIR: Optional, the base path where dependent external headers may
+       @echo be found, default is ^$(PREFIX)\include.  Note that headers for GLib, etc,
+       @echo will be searched for in ^$(INCLUDEDIR)\glib-2.0 and
+       @echo ^$(LIBDIR)\glib-2.0\include.
+       @echo.
+       @echo PKG_CONFIG_PATH: Full path to pkg-config.exe.  Required if building
+       @echo introspection files and if pkg-config.exe is not in your PATH or it
+       @echo is called something other than pkg-config.
+       @echo.
+       @echo PYTHON: Full path to your Python interpreter executable.  Required
+       @echo if building introspection files and if python.exe is not in your PATH.
+       @echo Note that it must be of the same configuration (x86/x64 and Debug/Release)
+       @echo and Python release series that was used to build GObject-Introspection
+       @echo if building introspection files is desired.  If using
+       @echo GObject-Introspection built with Meson, consult the shebang line in
+       @echo ^$(BINDIR)\g-ir-scanner for determining the correct Python interpreter.
+       @echo.
+       @echo OPTION: Optional, may be any of the following, use OPTION=1 to enable;
+       @echo multiple OPTION's may be used.  If no OPTION is specified, a default
+       @echo librsvg with the rsvg-view-3 utility program is built, without the
+       @echo introspection files.
+       @echo ======
+       @echo.
+       @echo NO_GTK:
+       @echo Disable GTK support, which will prevent rsvg-view-3.exe from being built.
+       @echo.
+       @echo INTROSPECTION:
+       @echo Enable the build of introspection files requires the GNOME
+       @echo gobject-introspection libraries and tools.  Please see the PYTHON section
+       @echo above for more details.
+       @echo.
+       @echo USE_PANGOFT2:
+       @echo Build the test programs with PangoFT2 support, requires Pango built with
+       @echo FreeType support, which also requires the FontConfig, HarfBuzz and
+       @echo FreeType DLLs and .lib's.
+       @echo.
+       @echo LIBTOOL_DLL_NAME:
+       @echo Use a libtool-style DLL name to mimic the DLL file naming generated by
+       @echo MinGW/autotools builds.  Please note that this does not enable one to use
+       @echo this build with MinGW builds.
+       @echo ======
+       @echo A 'clean' target is supported to remove all generated files, intermediate
+       @echo object files and binaries for the specified configuration.
+       @echo.
+       @echo A 'tests' target is supported to build and runthe test programs.
+       @echo.
+       @echo An 'install' target is supported to copy the build (DLLs, utility programs,
+       @echo LIBs, along with the introspection files if applicable) to appropriate
+       @echo locations under ^$(PREFIX).
+       @echo ======
+       @echo.
diff --git a/win32/install.mak b/win32/install.mak
new file mode 100644
index 00000000..1950a528
--- /dev/null
+++ b/win32/install.mak
@@ -0,0 +1,21 @@
+# NMake Makefile snippet for copying the built libraries, utilities and headers to
+# a path under $(PREFIX).
+
+install: all
+       @if not exist $(PREFIX)\bin\ mkdir $(PREFIX)\bin
+       @if not exist $(PREFIX)\lib\gdk-pixbuf-2.0\2.10.0\loaders\ mkdir 
$(PREFIX)\lib\gdk-pixbuf-2.0\2.10.0\loaders
+       @if not exist $(PREFIX)\include\librsvg-$(RSVG_API_VER)\librsvg @mkdir 
$(PREFIX)\include\librsvg-$(RSVG_API_VER)\librsvg
+       @for %%x in (dll pdb) do @copy /b $(LIBRSVG_DLL_FILENAME).%%x $(PREFIX)\bin
+       @copy /b $(LIBRSVG_LIB) $(PREFIX)\lib
+       @for %%x in (dll pdb) do @copy /b $(OUTDIR)\libpixbufloader-svg.%%x 
$(PREFIX)\lib\gdk-pixbuf-2.0\2.10.0\loaders
+       @for %%f in ($(RSVG_TOOLS)) do @(for %%x in (exe pdb) do @copy %%~dpnf.%%x $(PREFIX)\bin)
+       @for %%h in ($(librsvg_real_pub_HDRS) $(librsvg_real_extra_pub_HDRS)) do @copy %%h 
$(PREFIX)\include\librsvg-$(RSVG_API_VER)\librsvg\%%h
+       @set PATH=$(PREFIX)\bin;$(BINDIR);$(PATH)
+       @-gdk-pixbuf-query-loaders > loaders.cache
+       @for %%f in (loaders.cache) do @if %%~zf equ 0 del %%f
+       @if exist loaders.cache move loaders.cache $(PREFIX)\lib\gdk-pixbuf-2.0\2.10.0
+       @rem Copy the generated introspection files, if built
+       @if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).gir if not exist $(PREFIX)\share\gir-1.0\ mkdir 
$(PREFIX)\share\gir-1.0
+       @if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).gir copy $(OUTDIR)\Rsvg-$(RSVG_API_VER).gir 
$(PREFIX)\share\gir-1.0
+       @if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).typelib if not exist $(PREFIX)\lib\girepository-1.0\ mkdir 
$(PREFIX)\lib\girepository-1.0
+       @if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).typelib copy /b $(OUTDIR)\Rsvg-$(RSVG_API_VER).typelib 
$(PREFIX)\lib\girepository-1.0
diff --git a/win32/introspection-msvc.mak b/win32/introspection-msvc.mak
index e7cb10c5..e395a2de 100644
--- a/win32/introspection-msvc.mak
+++ b/win32/introspection-msvc.mak
@@ -7,20 +7,16 @@
 # You will need to have built gobject-introspection for this to work.
 # Change or pass in or set the following to suit your environment
 
-!if "$(PREFIX)" == ""
-PREFIX = ..\..\vs$(VSVER)\$(PLAT)
-!endif
-
 !if ![setlocal]                && \
-    ![set PFX=$(PREFIX)]       && \
-    ![for %P in (%PFX%) do @echo PREFIX_FULL=%~dpnfP > pfx.x]
+    ![set PFX_LIB=$(LIBDIR)\lib]       && \
+    ![for %P in (%PFX_LIB%) do @echo PREFIX_LIB_FULL=%~dpnfP > pfx.x]
 !endif
 !include pfx.x
 
 !if "$(PKG_CONFIG_PATH)" == ""
-PKG_CONFIG_PATH=$(PREFIX_FULL)\lib\pkgconfig
+PKG_CONFIG_PATH=$(PREFIX_LIB_FULL)\pkgconfig
 !else
-PKG_CONFIG_PATH=$(PREFIX_FULL)\lib\pkgconfig;$(PKG_CONFIG_PATH)
+PKG_CONFIG_PATH=$(PREFIX_LIB_FULL)\pkgconfig;$(PKG_CONFIG_PATH)
 !endif
 
 !if ![del $(ERRNUL) /q/f pfx.x]
@@ -46,10 +42,10 @@ PKG_CONFIG=pkg-config
 
 GIR_SUBDIR = share\gir-1.0
 GIR_TYPELIBDIR = lib\girepository-1.0
-G_IR_SCANNER = $(PREFIX)\bin\g-ir-scanner
-G_IR_COMPILER = $(PREFIX)\bin\g-ir-compiler.exe
-G_IR_INCLUDEDIR = $(PREFIX)\$(GIR_SUBDIR)
-G_IR_TYPELIBDIR = $(PREFIX)\$(GIR_TYPELIBDIR)
+G_IR_SCANNER = $(BINDIR)\g-ir-scanner
+G_IR_COMPILER = $(BINDIR)\g-ir-compiler.exe
+G_IR_INCLUDEDIR = $(BINDIR)\..\$(GIR_SUBDIR)
+G_IR_TYPELIBDIR = $(BINDIR)\..\$(GIR_TYPELIBDIR)
 
 VALID_PKG_CONFIG_PATH = FALSE
 
@@ -61,7 +57,7 @@ ERROR_MSG =
 BUILD_INTROSPECTION = TRUE
 
 !if ![set PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)]  \
-       && ![$(PKG_CONFIG) --print-errors --errors-to-stdout $(CHECK_PACKAGE) > pkgconfig.x]    \
+       && ![$(PKG_CONFIG) --print-errors --errors-to-stdout $(CHECK_GIR_PACKAGE) > pkgconfig.x]        \
        && ![setlocal]  \
        && ![set file="pkgconfig.x"]    \
        && ![FOR %A IN (%file%) DO @echo PKG_CHECK_SIZE=%~zA > pkgconfig.chksize]       \
diff --git a/win32/rsvg-rust.mak b/win32/rsvg-rust.mak
index bfd065c4..22ff8c74 100644
--- a/win32/rsvg-rust.mak
+++ b/win32/rsvg-rust.mak
@@ -1,4 +1,9 @@
+!ifndef VCVER
 !include detectenv-msvc.mak
+!ifndef LIBDIR
+LIBDIR=$(PREFIX)\lib
+!endif
+!endif
 
 !if "$(CARGO)" == ""
 CARGO = cargo
@@ -33,20 +38,22 @@ CARGO_CMD = $(CARGO) build $(CARGO_TARGET)
 !endif
 
 vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_internals\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg_internals.lib:
+       @set PATH=%PATH%;%HOMEPATH%\.cargo\bin
        @set CARGO_TARGET_DIR=..\win32\vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_internals
-       @set GTK_LIB_DIR=..\..\vs$(VSVER)\$(PLAT)\lib;$(LIB)
+       @set GTK_LIB_DIR=$(LIBDIR);$(LIB)
        $(RUSTUP_CMD)
        @cd ..\rsvg_internals
        $(CARGO_CMD) --verbose
-       @cd ..\win32\vs$(VSVER)
+       @cd ..\win32
        @set GTK_LIB_DIR=
        @set CARGO_TARGET_DIR=
 
 cargo-clean:
+       @set PATH=%PATH%;%HOMEPATH%\.cargo\bin
        @set CARGO_TARGET_DIR=..\win32\vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_internals
        @cd ..\rsvg_internals
        @$(CARGO) clean
-       @cd ..\win32\vs$(VSVER)
+       @cd ..\win32
        @set CARGO_TARGET_DIR=
        
 !else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]