[vala/master.msvc] build: Add a set of NMake Makefiles




commit 93558f460cb6acbeaf18fd3a41070e3e5ecf6f8c
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Aug 25 17:45:27 2021 +0800

    build: Add a set of NMake Makefiles
    
    This adds a set of NMake Makefiles that is able to:
    
    * Compile Vala from the generated C sources in a release tarball
    * Compile Vala with an existing Vala build/installation from the
      original Vala sources.
    
    What is not done currently:
    * Generating sources in gobject-introspection/ using Bison/Flex.
    * Re-generating the *.vapi files in vapi/ using existing .gir
      files.
    * Running the tests
    * Building vapidocs
    * Preparing for the build directly from a GIT checkout.
    
    This is done in a modular fashion so that one may specify the
    INCLUDEDIR and LIBDIR if the include and library paths for GLib
    are not in the compiler's default paths.
    
    This NMake Makefile set supports Visual Studio 2008 and later-
    please note that I did not (and am not intending to) update the
    .vala/*.c/*.h files to make the support work.

 Makefile.am                 |   1 +
 configure.ac                |   3 +
 win32/Makefile.am           |  12 ++++
 win32/Makefile.vc           |  62 ++++++++++++++++
 win32/build-rules-msvc.mak  | 167 ++++++++++++++++++++++++++++++++++++++++++++
 win32/config-msvc.mak.in    | 147 ++++++++++++++++++++++++++++++++++++++
 win32/create-lists-msvc.mak | 102 +++++++++++++++++++++++++++
 win32/create-lists.bat      |  42 +++++++++++
 win32/detectenv-msvc.mak    |  95 +++++++++++++++++++++++++
 win32/generate-msvc.mak     |  87 +++++++++++++++++++++++
 win32/install-msvc.mak      |  16 +++++
 11 files changed, 734 insertions(+)
---
diff --git a/Makefile.am b/Makefile.am
index 47032fdd7..3c98166ad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,6 +13,7 @@ SUBDIRS = \
        doc \
        gobject-introspection \
        vapigen \
+       win32   \
        $(NULL)
 
 if ENABLE_VALADOC
diff --git a/configure.ac b/configure.ac
index 9d09f4dd8..8b1e1fc7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,6 +274,9 @@ AC_CONFIG_FILES([Makefile
            valadoc/doclets/gtkdoc/Makefile
            valadoc/icons/Makefile
            valadoc/tests/Makefile
+           win32/Makefile
+           win32/config-msvc.mak
+           win32/config.h.win32
 ])
 
 AC_OUTPUT
diff --git a/win32/Makefile.am b/win32/Makefile.am
new file mode 100644
index 000000000..de94f7eb3
--- /dev/null
+++ b/win32/Makefile.am
@@ -0,0 +1,12 @@
+EXTRA_DIST =   \
+       compat/unistd.h \
+       compat/utime.h  \
+       build-rules-msvc.mak    \
+       config.h.win32  \
+       config-msvc.mak \
+       create-lists.bat        \
+       create-lists-msvc.mak   \
+       detectenv-msvc.mak      \
+       generate-msvc.mak       \
+       install-msvc.mak        \
+       Makefile.vc
\ No newline at end of file
diff --git a/win32/Makefile.vc b/win32/Makefile.vc
new file mode 100644
index 000000000..05d27b723
--- /dev/null
+++ b/win32/Makefile.vc
@@ -0,0 +1,62 @@
+# NMake Makefile for building Vala 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 ..\gee\Makefile.sources
+!include ..\vala\Makefile.sources
+!include ..\ccode\Makefile.sources
+!include ..\codegen\Makefile.sources
+!include ..\compiler\Makefile.sources
+!include ..\gobject-introspection\Makefile.sources
+!include ..\vapigen\Makefile.sources
+
+# Include the Makefile portion that enables features based on user input
+!include config-msvc.mak
+
+!if "$(VALID_CFGSET)" == "TRUE"
+
+# We need Visual Studio 2008 or later
+!if $(VCVERSION) < 1500
+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: $(BUILT_PROGRAMS)
+
+# Include the build rules for sources, DLLs and executables
+!include create-lists-msvc.mak
+!include build-rules-msvc.mak
+
+# Include the rules for build directory creation and code generation
+!include generate-msvc.mak
+
+
+!include install-msvc.mak
+
+!else # "$(VALID_MSC)" == "TRUE"
+all:
+       @echo You need Visual Studio 2008 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
+
+.SUFFIXES: .vala .c .obj .dll .exe
diff --git a/win32/build-rules-msvc.mak b/win32/build-rules-msvc.mak
new file mode 100644
index 000000000..179c6fdca
--- /dev/null
+++ b/win32/build-rules-msvc.mak
@@ -0,0 +1,167 @@
+# 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 @<<
+# $<
+# <<
+
+!ifndef REGEN_C_SOURCES
+{..\gee\}.c{$(OUTDIR)\gee\}.obj::
+       @if not exist $(OUTDIR)\gee\ md $(OUTDIR)\gee
+       @if not exist config.h copy config.h.win32 config.h
+       $(CC) $(LIBVALA_CFLAGS) $(LIBVALA_BUILD_INCLUDES) /Fo$(OUTDIR)\gee\ /Fd$(OUTDIR)\gee\ /c @<<
+$<
+<<
+
+{..\vala\}.c{$(OUTDIR)\vala\}.obj::
+       @if not exist $(OUTDIR)\vala\ md $(OUTDIR)\vala
+       @if not exist config.h copy config.h.win32 config.h
+       $(CC) $(LIBVALA_CFLAGS) $(LIBVALA_BUILD_INCLUDES) /Fo$(OUTDIR)\vala\ /Fd$(OUTDIR)\vala\ /c @<<
+$<
+<<
+
+{..\ccode\}.c{$(OUTDIR)\ccode\}.obj::
+       @if not exist $(OUTDIR)\ccode\ md $(OUTDIR)\ccode
+       $(CC) $(LIBVALA_CCODE_CFLAGS) $(LIBVALA_BUILD_CCODE_INCLUDES) /Fo$(OUTDIR)\ccode\ /Fd$(OUTDIR)\ccode\ 
/c @<<
+$<
+<<
+
+{..\codegen\}.c{$(OUTDIR)\codegen\}.obj::
+       @if not exist $(OUTDIR)\codegen\ md $(OUTDIR)\codegen
+       $(CC) $(LIBVALA_CODEGEN_CFLAGS) $(LIBVALA_BUILD_CODEGEN_INCLUDES) /Fo$(OUTDIR)\codegen\ 
/Fd$(OUTDIR)\codegen\ /c @<<
+$<
+<<
+
+{..\compiler\}.c{$(OUTDIR)\compiler\}.obj::
+       @if not exist $(OUTDIR)\compiler\ md $(OUTDIR)\compiler
+       $(CC) $(VALAC_CFLAGS) $(VALA_FULL_INCLUDES) /Fo$(OUTDIR)\compiler\ /Fd$(OUTDIR)\compiler\ /c @<<
+$<
+<<
+
+{..\vapigen\}.c{$(OUTDIR)\vapigen\}.obj::
+       @if not exist $(OUTDIR)\vapigen\ md $(OUTDIR)\vapigen
+       $(CC) $(VAPIGEN_CFLAGS) $(VAPIGEN_INCLUDES) /Fo$(OUTDIR)\vapigen\ /Fd$(OUTDIR)\vapigen\ /c @<<
+$<
+<<
+
+!else
+
+{$(OUTDIR)\gee\}.c{$(OUTDIR)\gee\}.obj::
+       @if not exist config.h copy config.h.win32 config.h
+       $(CC) $(LIBVALA_CFLAGS) $(LIBVALA_BUILD_INCLUDES) /Fo$(OUTDIR)\gee\ /Fd$(OUTDIR)\gee\ /c @<<
+$<
+<<
+
+{$(OUTDIR)\vala\}.c{$(OUTDIR)\vala\}.obj::
+       @if not exist config.h copy config.h.win32 config.h
+       $(CC) $(LIBVALA_CFLAGS) $(LIBVALA_BUILD_INCLUDES) /Fo$(OUTDIR)\vala\ /Fd$(OUTDIR)\vala\ /c @<<
+$<
+<<
+
+{$(OUTDIR)\ccode\}.c{$(OUTDIR)\ccode\}.obj::
+       $(CC) $(LIBVALA_CCODE_CFLAGS) $(LIBVALA_BUILD_CCODE_INCLUDES) /Fo$(OUTDIR)\ccode\ /Fd$(OUTDIR)\ccode\ 
/c @<<
+$<
+<<
+
+{$(OUTDIR)\codegen\}.c{$(OUTDIR)\codegen\}.obj::
+       $(CC) $(LIBVALA_CODEGEN_CFLAGS) $(LIBVALA_BUILD_CODEGEN_INCLUDES) /Fo$(OUTDIR)\codegen\ 
/Fd$(OUTDIR)\codegen\ /c @<<
+$<
+<<
+
+{$(OUTDIR)\compiler\}.c{$(OUTDIR)\compiler\}.obj::
+       $(CC) $(VALAC_CFLAGS) $(VALA_FULL_INCLUDES) /Fo$(OUTDIR)\compiler\ /Fd$(OUTDIR)\compiler\ /c @<<
+$<
+<<
+
+{$(OUTDIR)\gobject-introspection\}.c{$(OUTDIR)\gobject-introspection\}.obj::
+       $(CC) $(BASE_CFLAGS) $(GOBJECT_INTROSPECTION_BUILD_INCLUDES) /Fo$(OUTDIR)\gobject-introspection\ 
/Fd$(OUTDIR)\gobject-introspection\ /c @<<
+$<
+<<
+
+{$(OUTDIR)\vapigen\}.c{$(OUTDIR)\vapigen\}.obj::
+       $(CC) $(VAPIGEN_CFLAGS) $(VAPIGEN_INCLUDES) /Fo$(OUTDIR)\vapigen\ /Fd$(OUTDIR)\vapigen\ /c @<<
+$<
+<<
+!endif
+
+{..\gobject-introspection\}.c{$(OUTDIR)\gobject-introspection\}.obj::
+       @if not exist $(OUTDIR)\gobject-introspection\ md $(OUTDIR)\gobject-introspection
+       $(CC) $(BASE_CFLAGS) $(GOBJECT_INTROSPECTION_BUILD_INCLUDES) /Fo$(OUTDIR)\gobject-introspection\ 
/Fd$(OUTDIR)\gobject-introspection\ /c @<<
+$<
+<<
+
+# Rules for building .lib files
+$(VALA_LIB): $(VALA_DLL)
+$(VALA_CODEGEN_LIB): $(VALA_CODEGEN_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
+$(VALA_DLL): $(vala_libgee_objs) $(vala_libvala_objs)
+$(VALA_CODEGEN_DLL): $(VALA_LIB) $(vala_libccode_objs) $(vala_libcodegen_objs)
+
+$(VALA_CODEGEN_DLL) $(VALA_CCODE_DLL) $(VALA_DLL):
+       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
+
+$(VALAC_EXE): $(VALA_CODEGEN_LIB) $(VALA_LIB) $(vala_libccode_objs) $(compiler_objs)
+       link $(LDFLAGS)         \
+       $(BASE_DEP_LIBS)        \
+       /delayload:valaccodegen.dll delayimp.lib        \
+       /out:$@ @<<
+$**
+<<
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
+
+
+$(GEN_INTROSPECT): $(gen_introspection_objs) $(gidl_objs)
+$(VAPIGEN): $(vapigen_objs) $(gidl_objs) $(vala_libccode_objs) $(VALA_LIB)
+$(VAPICHECK): $(vapicheck_objs) $(gidl_objs) $(vala_libccode_objs) $(VALA_LIB)
+
+$(GEN_INTROSPECT) $(VAPIGEN) $(VAPICHECK):
+       link $(LDFLAGS)         \
+       $(BASE_DEP_LIBS)        \
+       /out:$@ @<<
+$**
+<<
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
+
+clean:
+       @-del /f /q $(OUTDIR)\*.dll.manifest
+       @-del /f /q $(OUTDIR)\*.dll
+       @-del /f /q $(OUTDIR)\*.exe.manifest
+       @-del /f /q $(OUTDIR)\*.exe
+       @-del /f /q $(OUTDIR)\*.pdb
+       @-del /f /q $(OUTDIR)\*.ilk
+       @-del /f /q $(OUTDIR)\*.exp
+       @-del /f /q $(OUTDIR)\*.lib
+       @-if not "$(REGEN_C_SOURCES)" == "" del /f /q $(OUTDIR)\libvala$(LIB_SUFFIX).vapi
+       @-for %d in (vapigen gobject-introspection compiler codegen ccode vala gee) do @for %x in (obj pdb) 
do @del $(OUTDIR)\%d\*.%x
+       @-if not "$(REGEN_C_SOURCES)" == "" for %d in (vapigen gobject-introspection compiler codegen ccode 
vala gee) do @for %x in (c h vapi) do @del $(OUTDIR)\%d\*.%x
+       @-for %d in (vapigen gobject-introspection compiler codegen ccode vala gee) do @rd $(OUTDIR)\%d
+       @-del /s /q config.h
diff --git a/win32/config-msvc.mak.in b/win32/config-msvc.mak.in
new file mode 100644
index 000000000..8ead51b6a
--- /dev/null
+++ b/win32/config-msvc.mak.in
@@ -0,0 +1,147 @@
+# 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)
+LIB_SUFFIX = @PACKAGE_SUFFIX@
+VALA_PKG_VERSION = @VALA_MAJOR_VERSION@.@VALA_MINOR_VERSION@.@VALA_MICRO_VERSION@
+
+# 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
+
+!ifndef VALAC
+VALAC = valac
+!endif
+
+!ifndef VAPIGEN
+VAPIGEN = vapigen
+!endif
+
+LDFLAGS = $(LDFLAGS) /libpath:$(LIBDIR)
+
+# These are the base minimum libraries required for building Vala.
+
+# 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                 \
+       /DWIN32                                 \
+       /FImsvc_recommended_pragmas.h   \
+       $(EXTRA_BASE_CFLAGS)
+
+BASE_DEP_INCLUDES =                    \
+       /I$(INCLUDEDIR)\gio-win32-2.0   \
+       /I$(INCLUDEDIR)\glib-2.0        \
+       /I$(LIBDIR)\glib-2.0\include    \
+       /I$(INCLUDEDIR)
+
+BASE_DEP_LIBS =                        \
+       gobject-2.0.lib         \
+       gmodule-2.0.lib         \
+       glib-2.0.lib
+
+LIBVALA_LOG_DOMAIN = /DG_LOG_DOMAIN=\"vala\"
+LIBVALA_CCODE_LOG_DOMAIN = /DG_LOG_DOMAIN=\"vala-ccode\"
+LIBVALA_CODEGEN_LOG_DOMAIN = /DG_LOG_DOMAIN=\"vala-ccodegen\"
+VALAC_LOG_DOMAIN = /DG_LOG_DOMAIN=\"valac\"
+VAPIGEN_LOG_DOMAIN = /DG_LOG_DOMAIN=\"vapigen\"
+
+VALA_BASE_INCLUDES =   \
+       /I.\compat                      \
+       /I.                             \
+       $(BASE_DEP_INCLUDES)
+
+LIBVALA_CFLAGS =                               \
+       $(BASE_CFLAGS)                          \
+       $(LIBVALA_LOG_DOMAIN)   \
+       /DPACKAGE_DATADIR=\"$(INSTALLPREFIX:\=/)/share/vala$(LIB_SUFFIX)\"
+
+LIBVALA_CCODE_CFLAGS = $(BASE_CFLAGS) $(LIBVALA_CCODE_LOG_DOMAIN)
+LIBVALA_CODEGEN_CFLAGS = $(BASE_CFLAGS) $(LIBVALA_CODEGEN_LOG_DOMAIN)
+VALAC_CFLAGS = $(BASE_CFLAGS) $(VALAC_LOG_DOMAIN)
+VAPIGEN_CFLAGS = $(BASE_CFLAGS) $(VAPIGEN_LOG_DOMAIN)
+
+# Set include paths according to whether we regenerate the C sources
+!ifndef REGEN_C_SOURCES
+LIBGEE_INCLUDES = /I..\gee
+LIBVALA_INCLUDES = /I..\vala
+LIBVALA_CCODE_INCLUDES = /I..\ccode
+LIBVALA_CODEGEN_INCLUDES = /I..\codegen
+GOBJECT_INTROSPECTION_INCLUDES = /I..\gobject-introspection
+
+LIBGEE_HEADER = ..\gee\valagee.h
+LIBVALA_HEADER = ..\vala\vala.h
+VALA_VAPI = ..\vala\libvala$(LIB_SUFFIX).vapi
+!else
+LIBGEE_INCLUDES = /Ivs$(VSVER)\$(CFG)\$(PLAT)\gee
+LIBVALA_INCLUDES = /Ivs$(VSVER)\$(CFG)\$(PLAT)\vala
+LIBVALA_CCODE_INCLUDES = /Ivs$(VSVER)\$(CFG)\$(PLAT)\ccode
+LIBVALA_CODEGEN_INCLUDES = /Ivs$(VSVER)\$(CFG)\$(PLAT)\codegen
+GOBJECT_INTROSPECTION_INCLUDES =       \
+       /Ivs$(VSVER)\$(CFG)\$(PLAT)\gobject-introspection       \
+       /I..\gobject-introspection
+
+LIBGEE_HEADER = vs$(VSVER)\$(CFG)\$(PLAT)\gee\valagee.h
+LIBVALA_HEADER = vs$(VSVER)\$(CFG)\$(PLAT)\vala\vala.h
+VALA_VAPI = vs$(VSVER)\$(CFG)\$(PLAT)\libvala$(LIB_SUFFIX).vapi
+!endif
+
+GOBJECT_INTROSPECTION_BUILD_INCLUDES = \
+       $(GOBJECT_INTROSPECTION_INCLUDES)       \
+       $(VALA_BASE_INCLUDES)
+
+LIBVALA_BUILD_INCLUDES =       \
+       $(LIBGEE_INCLUDES)      \
+       $(VALA_BASE_INCLUDES)
+
+LIBVALA_BUILD_CCODE_INCLUDES = \
+       $(LIBGEE_INCLUDES)      \
+       $(LIBVALA_INCLUDES)     \
+       $(VALA_BASE_INCLUDES)
+
+LIBVALA_BUILD_CODEGEN_INCLUDES =       \
+       $(LIBGEE_INCLUDES)      \
+       $(LIBVALA_CCODE_INCLUDES)       \
+       $(LIBVALA_INCLUDES)     \
+       $(VALA_BASE_INCLUDES)
+
+VALA_FULL_INCLUDES =   \
+       $(LIBGEE_INCLUDES)      \
+       $(LIBVALA_CCODE_INCLUDES)       \
+       $(LIBVALA_INCLUDES)     \
+       $(LIBVALA_CODEGEN_INCLUDES)     \
+       $(VALA_BASE_INCLUDES)
+
+VAPIGEN_INCLUDES =     \
+       $(LIBGEE_INCLUDES)      \
+       $(LIBVALA_CCODE_INCLUDES)       \
+       $(LIBVALA_INCLUDES)     \
+       $(GOBJECT_INTROSPECTION_INCLUDES)       \
+       $(VALA_BASE_INCLUDES)
+
+VALA_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\vala$(LIB_SUFFIX).lib
+VALA_CODEGEN_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\valaccodegen.lib
+VALA_DLL = $(VALA_LIB:.lib=.dll)
+VALA_CODEGEN_DLL = $(VALA_CODEGEN_LIB:.lib=.dll)
+GEN_INTROSPECT = vs$(VSVER)\$(CFG)\$(PLAT)\gen-introspect.exe
+VALAC_EXE = vs$(VSVER)\$(CFG)\$(PLAT)\valac.exe
+VAPIGEN = vs$(VSVER)\$(CFG)\$(PLAT)\vapigen.exe
+VAPICHECK = vs$(VSVER)\$(CFG)\$(PLAT)\vapicheck.exe
+
+BUILT_PROGRAMS = $(VALAC_EXE) $(VAPIGEN) $(VAPICHECK) $(GEN_INTROSPECT)
diff --git a/win32/create-lists-msvc.mak b/win32/create-lists-msvc.mak
new file mode 100644
index 000000000..9a45f1d63
--- /dev/null
+++ b/win32/create-lists-msvc.mak
@@ -0,0 +1,102 @@
+# 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 vala
+!if [for %d in ($(PREFIX)) do @echo INSTALLPREFIX=%~dpfd>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & 
echo.>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %d in (gee vala ccode codegen) do @for %s in (real_sources gen_c_sources objs) do @echo 
vala_lib%d_%s =>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %d in (compiler vapigen) do @for %s in (real_sources gen_c_sources objs) do @echo %d_%s 
=>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %s in ($(libgee_la_VALASOURCES:.vala=)) do @echo vala_libgee_real_sources = 
^$(vala_libgee_real_sources) ..\gee\%s.vala>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+     @echo vala_libgee_gen_c_sources = ^$(vala_libgee_gen_c_sources) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\gee\%s.c>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+        @echo vala_libgee_objs = ^$(vala_libgee_objs) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\gee\%s.obj>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %s in ($(libvala_la_VALASOURCES:.vala=)) do @echo vala_libvala_real_sources = 
^$(vala_libvala_real_sources) ..\vala\%s.vala>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+     @echo vala_libvala_gen_c_sources = ^$(vala_libvala_gen_c_sources) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\vala\%s.c>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+        @echo vala_libvala_objs = ^$(vala_libvala_objs) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\vala\%s.obj>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %s in ($(libvalaccode_la_VALASOURCES:.vala=)) do @echo vala_libccode_real_sources = 
^$(vala_libccode_real_sources) ..\ccode\%s.vala>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+     @echo vala_libccode_gen_c_sources = ^$(vala_libccode_gen_c_sources) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\ccode\%s.c>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+        @echo vala_libccode_objs = ^$(vala_libccode_objs) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\ccode\%s.obj>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %s in ($(libvalaccodegen_la_VALASOURCES:.vala=)) do @echo vala_libcodegen_real_sources = 
^$(vala_libcodegen_real_sources) ..\codegen\%s.vala>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+     @echo vala_libcodegen_gen_c_sources = ^$(vala_libcodegen_gen_c_sources) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\codegen\%s.c>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+        @echo vala_libcodegen_objs = ^$(vala_libcodegen_objs) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\codegen\%s.obj>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %s in ($(valac_VALASOURCES:.vala=)) do @echo compiler_real_sources = ^$(compiler_real_sources) 
..\compiler\%s.vala>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+     @echo compiler_gen_c_sources = ^$(compiler_gen_c_sources) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\compiler\%s.c>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+        @echo compiler_objs = ^$(compiler_objs) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\compiler\%s.obj>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %s in ($(vapigen_VALASOURCES:.vala=)) do @echo vapigen_real_sources = ^$(vapigen_real_sources) 
..\vapigen\%s.vala>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+     @echo vapigen_gen_c_sources = ^$(vapigen_gen_c_sources) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\vapigen\%s.c>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+        @echo vapigen_objs = ^$(vapigen_objs) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\vapigen\%s.obj>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [for %s in ($(vapicheck_VALASOURCES:.vala=)) do @echo vapicheck_real_sources = 
^$(vapicheck_real_sources) ..\vapigen\%s.vala>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+     @echo vapicheck_gen_c_sources = ^$(vapicheck_gen_c_sources) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\vapigen\%s.c>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak & \
+        @echo vapicheck_objs = ^$(vapicheck_objs) 
vs^$(VSVER)\^$(CFG)\^$(PLAT)\vapigen\%s.obj>>vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [call create-lists.bat header vala_vs$(VSVER)_$(CFG)_$(PLAT).mak gidl_objs]
+!endif
+
+!if [for %s in ($(libgidl_la_SOURCES)) do @if "%~xs" == ".c" call create-lists.bat file 
vala_vs$(VSVER)_$(CFG)_$(PLAT).mak vs$(VSVER)\$(CFG)\$(PLAT)\gobject-introspection\%~ns.obj]
+!endif
+
+!if [call create-lists.bat footer vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!if [call create-lists.bat header vala_vs$(VSVER)_$(CFG)_$(PLAT).mak gen_introspection_objs]
+!endif
+
+!if [for %s in ($(gen_introspect_SOURCES) scannerlexer.c scannerparser.c) do @if "%~xs" == ".c" call 
create-lists.bat file vala_vs$(VSVER)_$(CFG)_$(PLAT).mak 
vs$(VSVER)\$(CFG)\$(PLAT)\gobject-introspection\%~ns.obj]
+!endif
+
+!if [call create-lists.bat footer vala_vs$(VSVER)_$(CFG)_$(PLAT).mak]
+!endif
+
+!include vala_vs$(VSVER)_$(CFG)_$(PLAT).mak
+
+!if [del /f /q vala_vs$(VSVER)_$(CFG)_$(PLAT).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 000000000..ef60d5ce1
--- /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
new file mode 100644
index 000000000..321e72391
--- /dev/null
+++ b/win32/detectenv-msvc.mak
@@ -0,0 +1,95 @@
+# Common NMake Makefile module for checking the build environment
+# This can be copied from $(glib_srcroot)\build\win32 for GNOME items
+# that support MSVC builds and introspection under MSVC, and can be used
+# for building test programs as well.
+
+# Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or
+# VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir)
+!if !defined(VCINSTALLDIR) && !defined(WINDOWSSDKDIR)
+MSG = ^
+This Makefile is only for Visual Studio 2008 and later.^
+You need to ensure that the Visual Studio Environment is properly set up^
+before running this Makefile.
+!error $(MSG)
+!endif
+
+ERRNUL  = 2>NUL
+_HASH=^#
+
+!if ![echo VCVERSION=_MSC_VER > vercl.x] \
+    && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
+    && ![echo PLAT=Win32 >> vercl.x] \
+    && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
+    && ![echo PLAT=x64 >> vercl.x] \
+    && ![echo $(_HASH)elif defined(_M_ARM64) >> vercl.x] \
+    && ![echo PLAT=arm64 >> vercl.x] \
+    && ![echo $(_HASH)endif >> vercl.x] \
+    && ![cl -nologo -TC -P vercl.x $(ERRNUL)]
+!include vercl.i
+!if ![echo VCVER= ^\> vercl.vc] \
+    && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
+!include vercl.vc
+!endif
+!endif
+!if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc]
+!endif
+
+!if $(VCVERSION) > 1499 && $(VCVERSION) < 1600
+VSVER = 9
+!elseif $(VCVERSION) > 1599 && $(VCVERSION) < 1700
+VSVER = 10
+!elseif $(VCVERSION) > 1699 && $(VCVERSION) < 1800
+VSVER = 11
+!elseif $(VCVERSION) > 1799 && $(VCVERSION) < 1900
+VSVER = 12
+!elseif $(VCVERSION) > 1899 && $(VCVERSION) < 1910
+VSVER = 14
+!elseif $(VCVERSION) > 1909 && $(VCVERSION) < 1920
+VSVER = 15
+!elseif $(VCVERSION) > 1919 && $(VCVERSION) < 2000
+VSVER = 16
+!else
+VSVER = 0
+!endif
+
+!if "$(VSVER)" == "0"
+MSG = ^
+This NMake Makefile set supports Visual Studio^
+9 (2008) through 16 (2019).  Your Visual Studio^
+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
+!endif
+
+# We want debugging symbols logged for all builds,
+# using .pdb files for release builds
+CFLAGS_BASE = /W3 /Zi
+
+!if "$(PLAT)" == "x64"
+LDFLAGS_ARCH = /machine:x64
+!elseif "$(PLAT)" == "arm64"
+LDFLAGS_ARCH = /machine:arm64
+!else
+LDFLAGS_ARCH = /machine:x86
+!endif
+
+LDFLAGS_BASE = $(LDFLAGS_ARCH) /DEBUG
+
+!if "$(CFG)" == "release" || "$(CFG)" == "Release"
+CFLAGS_ADD = /MD /O2 /GL /MP $(CFLAGS_BASE)
+LDFLAGS = $(LDFLAGS_BASE) /LTCG /opt:ref
+!if $(VSVER) > 9
+CFLAGS_ADD = $(CFLAGS_ADD) /d2Zi+ 
+!endif
+!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 000000000..87bab497c
--- /dev/null
+++ b/win32/generate-msvc.mak
@@ -0,0 +1,87 @@
+# 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.
+
+# Generate valaversion.vala.in
+# ....
+
+# Generate the various .vapi files in the sources
+!ifdef REGEN_C_SOURCES
+$(vala_libgee_gen_c_sources): $(OUTDIR)\gee\gee.vapi
+
+$(OUTDIR)\gee\gee.vapi: $(vala_libgee_real_sources)
+       @echo Generating $@ and lib$(@B) C sources and headers...
+       @$(VALAC) --disable-version-header -C --vapidir ..\vapi --pkg gobject-2.0       \
+               -H $(@D)\vala$(@B).h --library $(@B) -b ..\$(@B) -d $(@D) $(vala_libgee_real_sources)
+
+$(vala_libvala_gen_c_sources): $(OUTDIR)\libvala$(LIB_SUFFIX).vapi
+
+$(OUTDIR)\libvala$(LIB_SUFFIX).vapi: $(OUTDIR)\gee\gee.vapi $(OUTDIR)\vala\vala.vapi
+       @echo Generating $@...
+       @if exist $@ del $@
+       @type $**>>$@
+
+$(OUTDIR)\vala\vala.vapi: $(vala_libvala_real_sources) $(OUTDIR)\gee\gee.vapi
+       @echo Generating $@ and lib$(@B) C sources and headers...
+       @$(VALAC) --disable-version-header -C --vapidir ..\vapi --pkg gmodule-2.0 --pkg gobject-2.0     \
+               --vapidir $(OUTDIR)\gee --pkg gee --pkg config \
+               -H $(@D)\vala.h --library $(@B) -b ..\$(@B) -d $(@D) $(vala_libvala_real_sources)
+
+$(vala_libccode_gen_c_sources): $(OUTDIR)\ccode\ccode.vapi
+$(OUTDIR)\ccode\ccode.vapi: $(vala_libccode_real_sources) $(OUTDIR)\gee\gee.vapi $(OUTDIR)\vala\vala.vapi
+       @echo Generating $@ and lib$(@B) C sources and headers...
+       @$(VALAC) --disable-version-header -C --vapidir ..\vapi --pkg gobject-2.0       \
+               --vapidir $(OUTDIR)\gee --pkg gee --vapidir $(OUTDIR)\vala --pkg vala --pkg config      \
+               -H $(@D)\vala$(@B).h --library $(@B) -b ..\$(@B) -d $(@D) $(vala_libccode_real_sources)
+
+$(vala_libcodegen_gen_c_sources): $(OUTDIR)\codegen\codegen.vapi
+$(OUTDIR)\codegen\codegen.vapi: $(vala_libcodegen_real_sources) $(OUTDIR)\ccode\ccode.vapi 
$(OUTDIR)\gee\gee.vapi $(OUTDIR)\vala\vala.vapi
+       @echo Generating $@ and lib$(@B) C sources and headers...
+       @$(VALAC) --disable-version-header -C --vapidir ..\vapi --pkg gobject-2.0       \
+               --vapidir $(OUTDIR)\gee --pkg gee --vapidir $(OUTDIR)\ccode --pkg ccode --vapidir 
$(OUTDIR)\vala --pkg vala     \
+               -H $(@D)\vala$(@B).h --library $(@B) -b ..\$(@B) -d $(@D) $(vala_libcodegen_real_sources)
+
+$(compiler_gen_c_sources): $(compiler_real_sources) $(OUTDIR)\codegen\codegen.vapi 
$(OUTDIR)\ccode\ccode.vapi $(OUTDIR)\gee\gee.vapi $(OUTDIR)\vala\vala.vapi
+       @echo Generating valac C sources...
+       @$(VALAC) --disable-version-header -C --vapidir ..\vapi --pkg gobject-2.0 \
+               --vapidir $(OUTDIR)\gee --pkg gee  --vapidir $(OUTDIR)\ccode --pkg ccode \
+               --vapidir $(OUTDIR)\vala --pkg vala --vapidir $(OUTDIR)\codegen --pkg codegen --pkg config    
  \
+               -b ..\compiler -d $(@D) $(compiler_real_sources)
+
+$(vapigen_gen_c_sources): $(vapigen_real_sources) $(OUTDIR)\gee\gee.vapi $(OUTDIR)\vala\vala.vapi
+       @echo Generating vapigen sources...
+       @$(VALAC) --disable-version-header -C --vapidir ..\vapi \
+               --vapidir $(OUTDIR)\gee --pkg gee --vapidir $(OUTDIR)\vala --pkg vala   \
+               --vapidir ..\gobject-introspection --pkg gidl   \
+               -b ..\vapigen -d $(@D) $(vapigen_real_sources)
+
+$(vapicheck_gen_c_sources): $(vapicheck_real_sources) $(OUTDIR)\gee\gee.vapi $(OUTDIR)\vala\vala.vapi
+       @echo Generating vapicheck sources...
+       @$(VALAC) --disable-version-header -C --vapidir ..\vapi \
+               --vapidir $(OUTDIR)\gee --pkg gee --vapidir $(OUTDIR)\vala --pkg vala   \
+               --vapidir ..\gobject-introspection --pkg gidl   \
+               -b ..\vapigen -d $(@D) $(vapicheck_real_sources)
+!endif
+
+# 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 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 >> $@
+
diff --git a/win32/install-msvc.mak b/win32/install-msvc.mak
new file mode 100644
index 000000000..ed2661b8a
--- /dev/null
+++ b/win32/install-msvc.mak
@@ -0,0 +1,16 @@
+# 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\vala$(LIB_SUFFIX)\ mkdir $(PREFIX)\lib\vala$(LIB_SUFFIX)
+       @if not exist $(PREFIX)\include\vala$(LIB_SUFFIX)\ mkdir $(PREFIX)\include\vala$(LIB_SUFFIX)
+       @if not exist $(PREFIX)\share\vala\vapi\ mkdir $(PREFIX)\share\vala\vapi
+       @if not exist $(PREFIX)\share\vala$(LIB_SUFFIX)\vapi\ mkdir $(PREFIX)\share\vala$(LIB_SUFFIX)\vapi
+       @for %%s in (valac vapigen) do @for %%x in (exe pdb) do @copy /b vs$(VSVER)\$(CFG)\$(PLAT)\%%s.%%x 
$(PREFIX)\bin
+       @for %%s in (vala$(LIB_SUFFIX) valaccodegen) do @for %%x in (dll pdb) do @copy /b 
vs$(VSVER)\$(CFG)\$(PLAT)\%%s.%%x $(PREFIX)\bin
+       @copy /b vs$(VSVER)\$(CFG)\$(PLAT)\vala$(LIB_SUFFIX).lib $(PREFIX)\lib
+       @for %%h in ($(LIBGEE_HEADER) $(LIBVALA_HEADER)) do @copy %%h $(PREFIX)\include\vala$(LIB_SUFFIX)
+       @for %%s in (gen-introspect) do @for %%x in (exe dll pdb) do @if exist 
vs$(VSVER)\$(CFG)\$(PLAT)\%%s.%%x copy /b vs$(VSVER)\$(CFG)\$(PLAT)\%%s.%%x $(PREFIX)\lib\vala$(LIB_SUFFIX)
+       @for %%x in (vapi deps) do @copy /b ..\vapi\*.%x $(PREFIX)\share\vala$(LIB_SUFFIX)\vapi
+       @copy /b $(VALA_VAPI) $(PREFIX)\share\vala\vapi


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