[amtk/meson-msvc: 10/22] build: Support Visual Studio builds with NMake



commit f5f5d911308b39296124f2694725b1f6e3019dab
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Apr 28 13:32:38 2020 +0800

    build: Support Visual Studio builds with NMake
    
    This adds a set of NMake Makefiles that can be used to build amtk with its
    tests and sample programs, and optionally with the introspection files.
    
    A README.txt file, along with an information page that is displayed when
    running 'nmake /f Makefile.vc' is invoked without the CFG parameter, which
    reveals the options that must be passed to 'nmake /f Makefile.vc' to carry
    out the build, as well as optional options that can be used as well.
    
    This will also produce a working pkg-config file if Python was used during
    the build/install process, and a 'test' target is also supported to run the
    test programs in testsuite/.

 Makefile.am                  |   2 +-
 configure.ac                 |   3 ++
 win32/Makefile.am            |  18 +++++++
 win32/Makefile.vc            |  52 ++++++++++++++++++
 win32/README.txt             | 104 ++++++++++++++++++++++++++++++++++++
 win32/amtkpc.py              |  34 ++++++++++++
 win32/build-rules-msvc.mak   | 117 ++++++++++++++++++++++++++++++++++++++++
 win32/config-msvc.mak.in     |  97 +++++++++++++++++++++++++++++++++
 win32/config.h.win32.in      |  98 ++++++++++++++++++++++++++++++++++
 win32/create-lists-msvc.mak  |  92 ++++++++++++++++++++++++++++++++
 win32/create-lists.bat       |  42 +++++++++++++++
 win32/detectenv-msvc.mak     |  99 ++++++++++++++++++++++++++++++++++
 win32/generate-msvc.mak      |  28 ++++++++++
 win32/info-msvc.mak          | 114 +++++++++++++++++++++++++++++++++++++++
 win32/install-msvc.mak       |  20 +++++++
 win32/introspection-msvc.mak |  90 +++++++++++++++++++++++++++++++
 win32/pc_base.py             | 124 +++++++++++++++++++++++++++++++++++++++++++
 win32/replace.py             | 115 +++++++++++++++++++++++++++++++++++++++
 18 files changed, 1248 insertions(+), 1 deletion(-)
---
diff --git a/Makefile.am b/Makefile.am
index cee9f6a..ffa3407 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = po amtk tests testsuite docs
+SUBDIRS = po amtk tests testsuite docs win32
 
 include $(top_srcdir)/aminclude_static.am
 clean-local: code-coverage-clean
diff --git a/configure.ac b/configure.ac
index fe69734..bd83347 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,6 +134,9 @@ AC_CONFIG_FILES([
        po/Makefile.in
        tests/Makefile
        testsuite/Makefile
+       win32/config.h.win32
+       win32/config-msvc.mak
+       win32/Makefile
 ])
 
 AC_OUTPUT
diff --git a/win32/Makefile.am b/win32/Makefile.am
new file mode 100644
index 0000000..ec6f371
--- /dev/null
+++ b/win32/Makefile.am
@@ -0,0 +1,18 @@
+EXTRA_DIST = \
+       amtkpc.py               \
+       build-rules-msvc.mak    \
+       config.h.win32.in       \
+       config.h.win32          \
+       config-msvc.mak         \
+       config-msvc.mak.in      \
+       create-lists.bat        \
+       create-lists-msvc.mak   \
+       detectenv-msvc.mak      \
+       generate-msvc.mak       \
+       info-msvc.mak           \
+       install-msvc.mak        \
+       introspection-msvc.mak  \
+       Makefile.vc             \
+       pc_base.py              \
+       README.txt              \
+       replace.py
diff --git a/win32/Makefile.vc b/win32/Makefile.vc
new file mode 100644
index 0000000..dc29bdf
--- /dev/null
+++ b/win32/Makefile.vc
@@ -0,0 +1,52 @@
+# NMake Makefile for building amtk 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 ..\amtk\amtk-sources.mak
+
+# 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"
+
+# Include the Makefile portion to convert the source and header lists
+# into the lists we need for compilation and introspection
+
+all: $(AMTK_DLL) $(EXTRA_TARGETS) build-info-amtk
+
+tests: all
+       @echo Running test programs...
+       @for %%t in (..\testsuite\*.c) do vs$(PDBVER)\$(CFG)\$(PLAT)\%%~nt.exe
+
+# Include the build rules for sources, DLLs and executables
+!include build-rules-msvc.mak
+
+# 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-msvc.mak
+
+!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/README.txt b/win32/README.txt
new file mode 100644
index 0000000..32345f1
--- /dev/null
+++ b/win32/README.txt
@@ -0,0 +1,104 @@
+Please do not compile amtk in a path with spaces to avoid potential
+problems during the build and/or during the usage of the amtk
+library.
+
+Please refer to the following GNOME Live! page for more detailed
+instructions on building amtk and its dependencies with Visual C++:
+
+https://live.gnome.org/GTK%2B/Win32/MSVCCompilationOfGTKStack
+
+This set of NMake Makefiles is intended to be used in a amtk source tree
+unpacked from a tarball.  For building, you will need the following libraries
+(headers, .lib's, DLLs, EXEs and scripts), with all of their dependencies:
+
+-GLib 2.52.0 or later
+-Gtk+-3.22.0 or later
+-GObject-Introspection (optional, for building/using introspection files)
+
+
+You will also need the following tools:
+-Visual Studio 2008 or later, with C/C++ compilation support (MSVC).
+-Python (optional, recommended, to generate the pkg-config files and
+ build the introspection files; if building the introspection files, the
+ Python installation must match the version, architecture and configuration
+ of the Python installation that was used to build your copy of
+ GObject-Introspection).
+-For introspection builds, the pkg-config (or compatible) tool is also needed
+ and the introspection files and pkg-config files for the dependent libraries
+ (if applicable) are also needed.  You will need to set PKG_CONFIG_PATH
+ if the pkg-config files cannot be found from the default locations that
+ pkg-config will look for.
+
+It is recommended that the dependent libraries are built with the same version
+of Visual Studio that is being used to build amtk, as far as possible.
+
+If building from a git checkout is desired, you will need to open the following
+*.in files, and replace any items that are surrounded by the '@' characters,
+and save those files without the .in file extension:
+
+(open file)                           -> (save as file)
+===========                              ==============
+config-msvc.mak.in                    -> config-msvc.mak
+config.h.win32.in                     -> config.h.win32
+
+From this directory in a Visual Studio command prompt, run the following:
+
+ nmake /f Makefile.vc CFG=<CFG> <target> <path_options> <other_options>
+
+Where:
+<CFG> is the build configuration, i.e. release or debug.  This is mandatory
+for all targets.
+
+<target> is as follows:
+-(not specified): builds the amtk DLL and tests and sample programs.
+                  If `INTROSPECTION=1` is specified, this will also build
+                  the introspection files (.gir/.typelib) for amtk.
+-all: see (not specified).
+-clean: Removes all build files
+-install: Same as (not specified) and also copies the built DLLs, .lib's, headers,
+          tools and possibly introspection files to appropriate locations under
+          $(PREFIX).  This will also create and copy the amtk-5.pc pkg-config
+          file if Python can be found.
+
+<path_options> is as follows:
+-PREFIX: Root directory where built files will be copied to with the 'install' target.
+         This also determines the root directory from which the dependent headers,
+         .lib's and DLLs/.typelib's/.gir's are looked for, if INCLUDEDIR, LIBDIR and/or
+         BINDIR are not respectively specified.  Default is
+         $(srcroot)\..\vs<vs_short_ver>\<arch>, where vs_short_ver is 9 for Visual
+         Studio 2008, 10 for VS2010, 11 for VS2012, 12 for VS2013 and 14 for VS 2015~2019.
+-INCLUDEDIR: Base directory where headers are looked for, which is PREFIX\include by
+             default.  Note that GLib headers are looked for in INCLUDEDIR\glib-2.0
+             and LIBDIR\glib-2.0\include.
+-LIBDIR: Base directory where .lib's and arch-dependent headers are looked for, which
+         is PREFIX\lib by default.
+-BINDIR: Base directory where dependent DLLs and tools (.exe's and scripts) are looked
+         for, which is PREFIX\bin by default.  Note that for introspection builds,
+         this means the introspection Python scripts and modules are in
+         BINDIR\..\lib\gobject-introspection and the dependent introspection files are
+         looked for in BINDIR\..\share\gir-1.0 and BINDIR\..\lib\girepository-1.0
+         respectively for .gir files and .typelib files.
+-PYTHON: Path to your Python interpreter executable, if not already in your %PATH% or
+         using a different installation of Python is desired.  Please see note above
+         on Python usage.  If Python cannot be found, you will not be able to build
+         introspection files and the amtk-5.pc pkg-config file will not be
+         generated using the 'install' build target.  It is also required for running
+         recent versions of glib-mkenums, which is used during the build.
+-PERL: Path to your PERL interpreter executable, if not already in your %PATH%
+       It is also required for running older versions of glib-mkenums (when
+       LEGACY_GLIB_MKENUMS is used), which is used during the build.
+-PKG_CONFIG: Path to your pkg-config (or compatible) tool, if not already in your
+             %PATH%.  This is required for introspection builds.
+-LIBINTL_LIB: Full file name of your gettext-runtime library .lib file, if it is not
+              intl.lib.  This should be in the directories indicated by %LIB% or in
+              $(LIBDIR), or should be passed in with the full path.  Note that its
+              DLL, if applicable, should be found in %PATH% or in $(BINDIR) as well,
+              for building the introspection files or for creating the GDK-Pixbuf
+              loaders cache file.
+
+<other_options> is as follows, activate the options using <option>=1:
+-INTROSPECTION: Build the introspection files.  Please see notes above.
+-LEGACY_GLIB_MKENUMS: Use this option if using an older version of GLib which ships
+                      with glib-mkenums that is written in PERL.  Please also see notes
+                      on the PERL path option above
+-LIBTOOL_DLL_NAME: Build the amtk DLL with libtool-style naming
diff --git a/win32/amtkpc.py b/win32/amtkpc.py
new file mode 100644
index 0000000..40394b0
--- /dev/null
+++ b/win32/amtkpc.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+#
+# Utility script to generate .pc files for GLib
+# for Visual Studio builds, to be used for
+# building introspection files
+
+# Author: Fan, Chun-wei
+# Date: March 10, 2016
+
+import os
+import sys
+
+from replace import replace_multi
+from pc_base import BasePCItems
+
+def main(argv):
+    amtk_api_ver = '5'
+    base_pc = BasePCItems()
+
+    base_pc.setup(argv)
+    pkg_replace_items = {'@AMTK_API_VERSION@': amtk_api_ver,
+                         '@PACKAGE_VERSION@': base_pc.version,
+                         '@AX_PACKAGE_REQUIRES@': 'glib-2.0 >= 2.52, gtk+-3.0 >= 3.22',
+                         '@AX_PACKAGE_REQUIRES_PRIVATE@': ''}
+
+    pkg_replace_items.update(base_pc.base_replace_items)
+
+    # Generate amtk-$(amtk_api_ver).pc
+    replace_multi(base_pc.top_srcdir + '/amtk.pc.in',
+                  base_pc.srcdir + '/amtk-' + amtk_api_ver + '.pc',
+                  pkg_replace_items)
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))
diff --git a/win32/build-rules-msvc.mak b/win32/build-rules-msvc.mak
new file mode 100644
index 0000000..3ac4f37
--- /dev/null
+++ b/win32/build-rules-msvc.mak
@@ -0,0 +1,117 @@
+# 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 @<<
+# $<
+# <<
+{..\amtk\}.c{$(OUTDIR)\amtk\}.obj::
+       @if not exist $(OUTDIR)\amtk\ md $(OUTDIR)\amtk
+       @if not exist $(OUTDIR)\amtk\config.h copy config.h.win32 $(OUTDIR)\amtk\config.h
+       $(CC) $(AMTK_CFLAGS) $(AMTK_INCLUDES) $(AMTK_LOG_DOMAIN) /Fo$(OUTDIR)\amtk\ /Fd$(OUTDIR)\amtk\ /c @<<
+$<
+<<
+
+{$(OUTDIR)\amtk\}.c{$(OUTDIR)\amtk\}.obj::
+       $(CC) $(AMTK_CFLAGS) $(AMTK_INCLUDES) $(AMTK_LOG_DOMAIN) /Fo$(OUTDIR)\amtk\ /Fd$(OUTDIR)\amtk\ /c @<<
+$<
+<<
+
+$(OUTDIR)\amtk\amtk-enum-types.obj: $(OUTDIR)\amtk\amtk-enum-types.h $(OUTDIR)\amtk\amtk-enum-types.c
+
+# Rules for building .lib files
+vs$(PDBVER)\$(CFG)\$(PLAT)\amtk-$(AMTK_VER).lib: $(AMTK_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
+$(AMTK_DLL):   \
+$(amtk_OBJS)
+       link /DLL $(LDFLAGS)    \
+       $(BASE_DEP_LIBS)        \
+       /implib:vs$(PDBVER)\$(CFG)\$(PLAT)\amtk-$(AMTK_VER).lib \
+       -out:$@ @<<
+$(amtk_OBJS)
+<<
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
+
+!include amtk_progs.mak
+
+!if [del /f /q amtk_progs.mak]
+!endif
+
+$(amtk_testsuite_progs):
+       @if not exist $(@D)\amtk-testsuite\ md $(@D)\amtk-testsuite
+       $(CC) $(BASE_CFLAGS) $(AMTK_INCLUDES) /Fo$(@D)\amtk-testsuite\ /Fd$(@D)\amtk-testsuite\ $** /Fe$@ 
/link $(LDFLAGS) $(BASE_DEP_LIBS)
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
+
+$(amtk_test_progs):
+       @if not exist $(@D)\amtk-tests\ md $(@D)\amtk-tests
+       $(CC) $(BASE_CFLAGS) $(AMTK_INCLUDES) /Fo$(@D)\amtk-tests\ /Fd$(@D)\amtk-tests\ $** /Fe$@ /link 
$(LDFLAGS) $(BASE_DEP_LIBS)
+       @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
+
+!ifdef INTROSPECTION
+$(OUTDIR)\Amtk-$(AMTK_API_VER).gir: vs$(PDBVER)\$(CFG)\$(PLAT)\amtk-$(AMTK_VER).lib 
$(OUTDIR)\amtk\Amtk_$(AMTK_VER)_gir_list
+       @-echo Generating $@...
+       @set PATH=$(BINDIR);$(PATH)
+       $(PYTHON) $(G_IR_SCANNER)       \
+       --verbose -no-libtool   \
+       --namespace=Amtk        \
+       --nsversion=$(AMTK_VER) \
+       --pkg=gtk+-3.0  \
+       --library=amtk-$(AMTK_VER)      \
+       --add-include-path=$(G_IR_INCLUDEDIR)   \
+       --include=Gtk-3.0       \
+       --pkg-export=amtk-$(AMTK_VER)   \
+       --cflags-begin  \
+       $(EXTRA_BASE_CFLAGS:/=-)                \
+       -DAMTK_COMPILATION                      \
+       $(AMTK_INCLUDES:/I=-I)          \
+       --cflags-end    \
+       --c-include=amtk/amtk.h \
+       --warn-all      \
+       --filelist=$(OUTDIR)\amtk\Amtk_$(AMTK_VER)_gir_list     \
+       -L.\$(OUTDIR) -L$(LIBDIR) -L$(BINDIR)   \
+       -o $@
+
+$(OUTDIR)\Amtk-$(AMTK_VER).typelib: $(OUTDIR)\Amtk-$(AMTK_VER).gir
+       @-echo Compiling $@...
+       $(G_IR_COMPILER)        \
+       --includedir=. --includedir=$(G_IR_TYPELIBDIR) --debug --verbose        \
+       $(@D:\=/)/$(@B).gir     \
+       -o $@
+!endif
+
+clean:
+       @if exist $(OUTDIR)\Amtk-$(AMTK_API_VER).typelib del /f /q $(OUTDIR)\Amtk-$(AMTK_API_VER).typelib
+       @if exist $(OUTDIR)\Amtk-$(AMTK_API_VER).gir del /f /q $(OUTDIR)\Amtk-$(AMTK_API_VER).gir
+       @-del /f /q $(OUTDIR)\*.exe
+       @-del /f /q $(OUTDIR)\*.exe.manifest
+       @-del /f /q $(OUTDIR)\*.dll
+       @-del /f /q $(OUTDIR)\*.dll.manifest
+       @-del /f /q $(OUTDIR)\*.pdb
+       @-del /f /q $(OUTDIR)\*.ilk
+       @-del /f /q $(OUTDIR)\*.exp
+       @-del /f /q $(OUTDIR)\*.lib
+       @-del /s /q $(OUTDIR)\amtk-testsuite\*.pdb
+       @-del /s /q $(OUTDIR)\amtk-testsuite\*.obj
+       @-del /s /q $(OUTDIR)\amtk-tests\*.pdb
+       @-del /s /q $(OUTDIR)\amtk-tests\*.obj
+       @-del /s /q $(OUTDIR)\amtk\Amtk_$(AMTK_API_VER)_gir_list
+       @-del /s /q $(OUTDIR)\amtk\*.obj
+       @-del /s /q $(OUTDIR)\amtk\*.pdb
+       @-del /s /q $(OUTDIR)\amtk\amtk-enum-types.*
+       @-del /s /q $(OUTDIR)\amtk\config.h
+       @-rd $(OUTDIR)\amtk-testsuite $(OUTDIR)\amtk-tests $(OUTDIR)\amtk
diff --git a/win32/config-msvc.mak.in b/win32/config-msvc.mak.in
new file mode 100644
index 0000000..bc1d5a7
--- /dev/null
+++ b/win32/config-msvc.mak.in
@@ -0,0 +1,97 @@
+# NMake Makefile portion for enabling features for Windows builds
+
+# Please do not change anything beneath this line unless maintaining the NMake Makefiles
+OUTDIR = vs$(PDBVER)\$(CFG)\$(PLAT)
+AMTK_VER = @AMTK_API_VERSION@
+AMTK_API_VER = $(AMTK_VER)
+CHECK_GIR_PACKAGE = Gtk-3.0
+AMTK_PKG_VERSION = @PACKAGE_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
+
+# Make import lib of gettext-runtime configurable
+!ifndef LIBINTL_LIB
+LIBINTL_LIB = intl.lib
+!endif
+
+# Make glib-mkenums script configurable
+!ifndef GLIB_MKENUMS
+GLIB_MKENUMS=$(PREFIX)\bin\glib-mkenums
+!endif
+
+LDFLAGS = $(LDFLAGS) /libpath:$(LIBDIR)
+
+# These are the base minimum libraries required for building amtk.
+
+# Visual Studio 2015 and later supports the /utf-8 compiler flag
+# that prevents C4819 warnings/errors on non-Western locales
+!if $(PDBVER) > 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)\gtk-3.0 \
+       /I$(INCLUDEDIR)\gdk-pixbuf-2.0  \
+       /I$(INCLUDEDIR)\pango-1.0       \
+       /I$(INCLUDEDIR)\atk-1.0 \
+       /I$(INCLUDEDIR)\glib-2.0        \
+       /I$(LIBDIR)\glib-2.0\include    \
+       /I$(INCLUDEDIR)
+
+BASE_DEP_LIBS =                        \
+       gtk-3.0.lib     \
+       gio-2.0.lib             \
+       gobject-2.0.lib         \
+       glib-2.0.lib            \
+       cairo.lib               \
+       $(LIBINTL_LIB)
+
+AMTK_LOG_DOMAIN = /DG_LOG_DOMAIN=\"Amtk\"
+
+AMTK_CFLAGS =                          \
+       $(BASE_CFLAGS)                          \
+       /DAMTK_COMPILATION                      \
+       /D_AMTK_EXTERN=__declspec(dllexport)
+
+AMTK_INCLUDES =                        \
+       /Ivs$(PDBVER)\$(CFG)\$(PLAT)\amtk       \
+       /Ivs$(PDBVER)\$(CFG)\$(PLAT)            \
+       /I..\amtk       \
+       /I..    \
+       $(BASE_DEP_INCLUDES)
+
+!ifdef LIBTOOL_DLL_NAME
+AMTK_DLL = vs$(PDBVER)\$(CFG)\$(PLAT)\libamtk-$(AMTK_VER)-0.dll
+!else
+AMTK_DLL = vs$(PDBVER)\$(CFG)\$(PLAT)\amtk-$(AMTK_VER)-vs$(PDBVER).dll
+!endif
+
+!include create-lists-msvc.mak
+
+# Build Introspection if requested
+EXTRA_TARGETS = $(amtk_testsuite_progs) $(amtk_test_progs)
+
+!ifdef INTROSPECTION
+EXTRA_TARGETS =                                \
+       $(OUTDIR)\Amtk-$(AMTK_VER).typelib      \
+       $(EXTRA_TARGETS)
+!endif
diff --git a/win32/config.h.win32.in b/win32/config.h.win32.in
new file mode 100644
index 0000000..0baa8e1
--- /dev/null
+++ b/win32/config.h.win32.in
@@ -0,0 +1,98 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if translation of program messages to the user's native
+   language is requested. */
+#define ENABLE_NLS 1
+
+/* Define to the gettext package name. */
+#define GETTEXT_PACKAGE "amtk-5"
+
+/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the
+   CoreFoundation framework. */
+/* #undef HAVE_CFLOCALECOPYCURRENT */
+
+/* Define to 1 if you have the Mac OS X function
+   CFLocaleCopyPreferredLanguages in the CoreFoundation framework. */
+/* #undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES */
+
+/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
+   the CoreFoundation framework. */
+/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
+
+/* Define if the GNU dcgettext() function is already present or preinstalled.
+   */
+#define HAVE_DCGETTEXT 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+/* #undef HAVE_DLFCN_H */
+
+/* Define if the GNU gettext() function is already present or preinstalled. */
+#define HAVE_GETTEXT 1
+
+/* Define if you have the iconv() function and it works. */
+#define HAVE_ICONV 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#if !defined (_MSC_VER) || (_MSC_VER >= 1800)
+# define HAVE_INTTYPES_H 1
+#endif
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#if !defined (_MSC_VER) || (_MSC_VER >= 1600)
+# define HAVE_STDINT_H 1
+#endif
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#ifndef _MSC_VER
+# define HAVE_STRINGS_H 1
+#endif
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#ifndef _MSC_VER
+# define HAVE_UNISTD_H 1
+#endif
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE "Amtk"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "https://gitlab.gnome.org/GNOME/amtk/issues";
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "Amtk"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "Amtk @PACKAGE_VERSION@"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "amtk"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "https://wiki.gnome.org/Projects/Amtk";
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "@PACKAGE_VERSION@"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "@PACKAGE_VERSION@"
diff --git a/win32/create-lists-msvc.mak b/win32/create-lists-msvc.mak
new file mode 100644
index 0000000..7878efc
--- /dev/null
+++ b/win32/create-lists-msvc.mak
@@ -0,0 +1,92 @@
+# 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 libamtk
+
+!if [call create-lists.bat header amtk_objs.mak amtk_headers_real]
+!endif
+
+!if [for %s in ($(amtk_public_headers)) do @call create-lists.bat file amtk_objs.mak ..\amtk\%s]
+!endif
+
+!if [call create-lists.bat footer amtk_objs.mak]
+!endif
+
+!if [call create-lists.bat header amtk_objs.mak amtk_srcs_real]
+!endif
+
+!if [for %s in ($(amtk_public_c_files)) do @call create-lists.bat file amtk_objs.mak ..\amtk\%s]
+!endif
+
+!if [call create-lists.bat footer amtk_objs.mak]
+!endif
+
+!if [call create-lists.bat header amtk_objs.mak amtk_OBJS]
+!endif
+
+!if [for %s in ($(amtk_public_c_files) $(amtk_built_public_c_files)) do @call create-lists.bat file 
amtk_objs.mak vs^$(PDBVER)\^$(CFG)\^$(PLAT)\amtk\%~ns.obj]
+!endif
+
+!if [call create-lists.bat footer amtk_objs.mak]
+!endif
+
+!if [call create-lists.bat header amtk_objs.mak amtk_testsuite_progs]
+!endif
+
+!if [for %s in (..\testsuite\*.c) do @call create-lists.bat file amtk_objs.mak 
vs^$(PDBVER)\^$(CFG)\^$(PLAT)\%~ns.exe]
+!endif
+
+!if [call create-lists.bat footer amtk_objs.mak]
+!endif
+
+!if [call create-lists.bat header amtk_objs.mak amtk_test_progs]
+!endif
+
+!if [for %s in (..\tests\*.c) do @call create-lists.bat file amtk_objs.mak 
vs^$(PDBVER)\^$(CFG)\^$(PLAT)\%~ns.exe]
+!endif
+
+!if [call create-lists.bat footer amtk_objs.mak]
+!endif
+
+!if [for %s in (..\testsuite\*.c) do @echo vs^$(PDBVER)\^$(CFG)\^$(PLAT)\%~ns.exe: 
vs^$(PDBVER)\^$(CFG)\^$(PLAT)\amtk-^$(AMTK_VER).lib %s>>amtk_progs.mak]
+!endif
+
+!if [for %s in (..\tests\*.c) do @echo vs^$(PDBVER)\^$(CFG)\^$(PLAT)\%~ns.exe: 
vs^$(PDBVER)\^$(CFG)\^$(PLAT)\amtk-^$(AMTK_VER).lib %s>>amtk_progs.mak]
+!endif
+
+!include amtk_objs.mak
+
+!if [del /f /q amtk_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 0000000..ef60d5c
--- /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 0000000..8201699
--- /dev/null
+++ b/win32/detectenv-msvc.mak
@@ -0,0 +1,99 @@
+# 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)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) < 14
+PDBVER = $(VSVER)
+!else
+PDBVER = 14
+!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$(PDBVER)\$(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 $(VSVER) > 9
+!if "$(CFG)" == "release" || "$(CFG)" == "Release"
+CFLAGS_BASE = $(CFLAGS_BASE) /d2Zi+
+!endif
+!endif
+
+!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 $(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 0000000..6992e74
--- /dev/null
+++ b/win32/generate-msvc.mak
@@ -0,0 +1,28 @@
+# 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)\amtk\config.h: config.h.win32
+       @if not exist $(@D)\ md $(@D)
+       @-copy $** $@
+
+$(OUTDIR)\amtk\amtk-enum-types.h: ..\amtk\amtk-enum-types.h.template $(amtk_headers_real)
+$(OUTDIR)\amtk\amtk-enum-types.c: ..\amtk\amtk-enum-types.c.template $(amtk_headers_real)
+
+$(OUTDIR)\amtk\amtk-enum-types.h $(OUTDIR)\amtk\amtk-enum-types.c:
+       @if not exist $(@D)\ md $(@D)
+       @cd ..\amtk
+       @if "$(LEGACY_GLIB_MKENUMS)" == "" ($(PYTHON) $(GLIB_MKENUMS) --template $(@F).template 
$(amtk_public_headers)>..\win32\$@)
+       @if not "$(LEGACY_GLIB_MKENUMS)" == "" ($(PERL) $(GLIB_MKENUMS) --template $(@F).template 
$(amtk_public_headers)>..\win32\$@)
+       @cd ..\win32
+
+# Generate listing file for introspection
+$(OUTDIR)\amtk\Amtk_$(AMTK_VER)_gir_list:      \
+$(amtk_headers_real)           \
+$(amtk_srcs_real)                      \
+$(OUTDIR)\amtk\amtk-enum-types.h       \
+$(OUTDIR)\amtk\amtk-enum-types.c
+       @if exist $@ del $@
+       @for %%s in ($**) do @echo %%s >> $@
diff --git a/win32/info-msvc.mak b/win32/info-msvc.mak
new file mode 100644
index 0000000..5d686ad
--- /dev/null
+++ b/win32/info-msvc.mak
@@ -0,0 +1,114 @@
+# 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-amtk:
+       @echo.
+       @echo =========================
+       @echo Configuration for amtk
+       @echo =========================
+       @echo Build Type: $(BUILD_TYPE)
+       @echo.
+       @echo.
+       @echo Introspection: $(BUILD_INTROSPECTION)
+
+help:
+       @echo.
+       @echo ============================
+       @echo Building amtk 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 9 for VS 2008, 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 GLIB_MKENUMS, G_IR_SCANNER, G_IR_COMPILER: Full path to glib-mkenums,
+       @echo g-ir-scanner and g-ir-compiler.exe if any of them are not in ^$(PREFIX)\bin.
+       @echo Note that G_IR_SCANNER and G_IR_COMPILER are only used if building
+       @echo introspection.
+       @echo.
+       @echo PYTHON: Full path to your Python interpreter executable.  Required
+       @echo if building introspection files or if using the Python version of glib-mkenums
+       @echo that is found in newer GLib instead of the former PERL versions,
+       @echo 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 ^$(G_IR_SCANNER) for determining the correct Python interpreter.
+       @echo.
+       @echo PERL: Full path to your PERL interpreter executable if it is not in your PATH
+       @echo This is required if LEGACY_GLIB_MKENUMS is specified, meaning that an older version
+       @echo of glib-mkenums (written in PERL) is used.
+       @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 amtk, without the introspection files.
+       @echo ======
+       @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 LEGACY_GLIB_MKENUMS:
+       @echo Enable this option if using glib-mkenums that is written using PERL, provided
+       @echo by older GLib versions.
+       @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.
+       @echo Other options:
+       @echo --------------
+       @echo LIBINTL_LIB: This defaults to intl.lib, which is the gettext-runtime library
+       @echo that we need to link to.  Define this if your gettext-runtime library .lib is
+       @echo named differently, such as libintl.lib.
+       @echo ======
+       @echo.
+       @echo A 'clean' target is supported to remove all generated files, intermediate
+       @echo object files and binaries for the specified configuration.
+       @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-msvc.mak b/win32/install-msvc.mak
new file mode 100644
index 0000000..0722b8a
--- /dev/null
+++ b/win32/install-msvc.mak
@@ -0,0 +1,20 @@
+# 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\ mkdir $(PREFIX)\lib
+       @if not exist $(PREFIX)\include\amtk-$(AMTK_VER)\amtk\ @mkdir $(PREFIX)\include\amtk-$(AMTK_VER)\amtk
+       @for %%x in (dll pdb) do copy /b $(AMTK_DLL:.dll=).%%x $(PREFIX)\bin
+       @copy /b vs$(PDBVER)\$(CFG)\$(PLAT)\amtk-$(AMTK_VER).lib $(PREFIX)\lib
+       @for %%h in ($(amtk_public_headers)) do @copy ..\amtk\%%h $(PREFIX)\include\amtk-$(AMTK_VER)\amtk
+       @copy vs$(PDBVER)\$(CFG)\$(PLAT)\amtk\amtk-enum-types.h $(PREFIX)\include\amtk-$(AMTK_VER)\amtk
+       @rem Copy the generated introspection files, if built
+       @if exist $(OUTDIR)\Amtk-$(AMTK_VER).gir if not exist $(PREFIX)\share\gir-1.0\ mkdir 
$(PREFIX)\share\gir-1.0
+       @if exist $(OUTDIR)\Amtk-$(AMTK_VER).gir copy $(OUTDIR)\Amtk-$(AMTK_VER).gir $(PREFIX)\share\gir-1.0
+       @if exist $(OUTDIR)\Amtk-$(AMTK_VER).typelib if not exist $(PREFIX)\lib\girepository-1.0\ mkdir 
$(PREFIX)\lib\girepository-1.0
+       @if exist $(OUTDIR)\Amtk-$(AMTK_VER).typelib copy /b $(OUTDIR)\Amtk-$(AMTK_VER).typelib 
$(PREFIX)\lib\girepository-1.0
+       @-$(PYTHON) amtkpc.py --version=$(AMTK_PKG_VERSION) --prefix=$(PREFIX)
+       @if not exist amtk-$(AMTK_VER).pc echo *** amtk-$(AMTK_VER) is not generated!  Generate it later 
using ^$(PYTHON) --version=$(AMTK_PKG_VERSION) --prefix=^$(PREFIX)
+       @if exist amtk-$(AMTK_VER).pc if not exist $(PREFIX)\lib\pkgconfig mkdir $(PREFIX)\lib\pkgconfig
+       @if exist amtk-$(AMTK_VER).pc move amtk-$(AMTK_VER).pc $(PREFIX)\lib\pkgconfig
diff --git a/win32/introspection-msvc.mak b/win32/introspection-msvc.mak
new file mode 100644
index 0000000..e395a2d
--- /dev/null
+++ b/win32/introspection-msvc.mak
@@ -0,0 +1,90 @@
+# Common NMake Makefile module for checking the build environment is sane
+# for building introspection files under MSVC/NMake.
+# This can be copied from $(gi_srcroot)\win32 for GNOME items
+# that support MSVC builds and introspection under MSVC.
+
+# Can override with env vars as needed
+# 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 ![setlocal]                && \
+    ![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_LIB_FULL)\pkgconfig
+!else
+PKG_CONFIG_PATH=$(PREFIX_LIB_FULL)\pkgconfig;$(PKG_CONFIG_PATH)
+!endif
+
+!if ![del $(ERRNUL) /q/f pfx.x]
+!endif
+
+# Note: The PYTHON must be the Python release series that was used to build
+# the GObject-introspection scanner Python module!
+# Either having python.exe your PATH will work or passing in
+# PYTHON=<full path to your Python interpretor> will do
+
+# This is required, and gobject-introspection needs to be built
+# before this can be successfully run.
+!if "$(PYTHON)" == ""
+PYTHON=python
+!endif
+
+# Path to the pkg-config tool, if not already in the PATH
+!if "$(PKG_CONFIG)" == ""
+PKG_CONFIG=pkg-config
+!endif
+
+# Don't change anything following this line!
+
+GIR_SUBDIR = share\gir-1.0
+GIR_TYPELIBDIR = lib\girepository-1.0
+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
+
+MSG_INVALID_PKGCONFIG = You must set or specifiy a valid PKG_CONFIG_PATH
+MSG_INVALID_CFG = You need to specify or set CFG to be release or debug to use this Makefile to build the 
Introspection Files
+
+ERROR_MSG =
+
+BUILD_INTROSPECTION = TRUE
+
+!if ![set PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)]  \
+       && ![$(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]       \
+       && ![del $(ERRNUL) /q/f pkgconfig.x]
+!endif
+
+!include pkgconfig.chksize
+!if "$(PKG_CHECK_SIZE)" == "0"
+VALID_PKG_CONFIG_PATH = TRUE
+!else
+VALID_PKG_CONFIG_PATH = FALSE
+!endif
+
+!if ![del $(ERRNUL) /q/f pkgconfig.chksize]
+!endif
+
+VALID_CFGSET = FALSE
+!if "$(CFG)" == "release" || "$(CFG)" == "debug" || "$(CFG)" == "Release" || "$(CFG)" == "Debug"
+VALID_CFGSET = TRUE
+!endif
+
+!if "$(VALID_PKG_CONFIG_PATH)" != "TRUE"
+BUILD_INTROSPECTION = FALSE
+ERROR_MSG = $(MSG_INVALID_PKGCONFIG)
+!endif
+
+!if "$(VALID_CFGSET)" != "TRUE"
+BUILD_INTROSPECTION = FALSE
+ERROR_MSG = $(MSG_INVALID_CFG)
+!endif
diff --git a/win32/pc_base.py b/win32/pc_base.py
new file mode 100644
index 0000000..a65955d
--- /dev/null
+++ b/win32/pc_base.py
@@ -0,0 +1,124 @@
+#!/usr/bin/python
+#
+# Simple utility script to generate the basic info
+# needed in a .pc (pkg-config) file, used especially
+# for introspection purposes
+
+# This can be used in various projects where
+# there is the need to generate .pc files,
+# and is copied from GLib's $(srcroot)/win32
+
+# Author: Fan, Chun-wei
+# Date: March 10, 2016
+
+import os
+import sys
+import argparse
+
+class BasePCItems:
+    def __init__(self):
+        self.base_replace_items = {}
+        self.exec_prefix = ''
+        self.includedir = ''
+        self.libdir = ''
+        self.prefix = ''
+        self.srcdir = os.path.dirname(__file__)
+        self.top_srcdir = self.srcdir + os.sep + '..'
+        self.version = ''
+
+    def setup(self, argv, parser=None):
+        if parser is None:
+            parser = argparse.ArgumentParser(description='Setup basic .pc file info')
+        parser.add_argument('--prefix', help='prefix of the installed library',
+                            required=True)
+        parser.add_argument('--exec-prefix',
+                            help='prefix of the installed programs, \
+                                  if different from the prefix')
+        parser.add_argument('--includedir',
+                            help='includedir of the installed library, \
+                                  if different from ${prefix}/include')
+        parser.add_argument('--libdir',
+                            help='libdir of the installed library, \
+                                  if different from ${prefix}/lib')
+        parser.add_argument('--version', help='Version of the package',
+                            required=True)
+        args = parser.parse_args()
+
+        self.version = args.version
+
+        # check whether the prefix and exec_prefix are valid
+        if not os.path.exists(args.prefix):
+            raise SystemExit('Specified prefix \'%s\' is invalid' % args.prefix)
+
+        # use absolute paths for prefix
+        self.prefix = os.path.abspath(args.prefix).replace('\\','/')
+
+        # check and setup the exec_prefix
+        if getattr(args, 'exec_prefix', None) is None:
+            exec_prefix_use_shorthand = True
+            self.exec_prefix = '${prefix}'
+        else:
+            if args.exec_prefix.startswith('${prefix}'):
+                exec_prefix_use_shorthand = True
+                input_exec_prefix = args.prefix + args.exec_prefix[len('${prefix}'):]
+            else:
+                exec_prefix_use_shorthand = False
+                input_exec_prefix = args.exec_prefix
+            if not os.path.exists(input_exec_prefix):
+                raise SystemExit('Specified exec_prefix \'%s\' is invalid' %
+                                  args.exec_prefix)
+            if exec_prefix_use_shorthand is True:
+                self.exec_prefix = args.exec_prefix.replace('\\','/')
+            else:
+                self.exec_prefix = os.path.abspath(input_exec_prefix).replace('\\','/')
+
+        # check and setup the includedir
+        if getattr(args, 'includedir', None) is None:
+            self.includedir = '${prefix}/include'
+        else:
+            if args.includedir.startswith('${prefix}'):
+                includedir_use_shorthand = True
+                input_includedir = args.prefix + args.includedir[len('${prefix}'):]
+            else:
+                if args.includedir.startswith('${exec_prefix}'):
+                    includedir_use_shorthand = True
+                    input_includedir = input_exec_prefix + args.includedir[len('${exec_prefix}'):]
+                else:
+                    includedir_use_shorthand = False
+                    input_includedir = args.includedir
+            if not os.path.exists(input_includedir):
+                raise SystemExit('Specified includedir \'%s\' is invalid' %
+                                  args.includedir)
+            if includedir_use_shorthand is True:
+                self.includedir = args.includedir.replace('\\','/')
+            else:
+                self.includedir = os.path.abspath(input_includedir).replace('\\','/')
+
+        # check and setup the libdir
+        if getattr(args, 'libdir', None) is None:
+            self.libdir = '${prefix}/lib'
+        else:
+            if args.libdir.startswith('${prefix}'):
+                libdir_use_shorthand = True
+                input_libdir = args.prefix + args.libdir[len('${prefix}'):]
+            else:
+                if args.libdir.startswith('${exec_prefix}'):
+                    libdir_use_shorthand = True
+                    input_libdir = input_exec_prefix + args.libdir[len('${exec_prefix}'):]
+                else:
+                    libdir_use_shorthand = False
+                    input_libdir = args.libdir
+            if not os.path.exists(input_libdir):
+                raise SystemExit('Specified libdir \'%s\' is invalid' %
+                                             args.libdir)
+            if libdir_use_shorthand is True:
+                self.libdir = args.libdir.replace('\\','/')
+            else:
+                self.libdir = os.path.abspath(input_libdir).replace('\\','/')
+
+        # setup dictionary for replacing items in *.pc.in
+        self.base_replace_items.update({'@VERSION@': self.version})
+        self.base_replace_items.update({'@prefix@': self.prefix})
+        self.base_replace_items.update({'@exec_prefix@': self.exec_prefix})
+        self.base_replace_items.update({'@libdir@': self.libdir})
+        self.base_replace_items.update({'@includedir@': self.includedir})
diff --git a/win32/replace.py b/win32/replace.py
new file mode 100644
index 0000000..3aeceb1
--- /dev/null
+++ b/win32/replace.py
@@ -0,0 +1,115 @@
+#!/usr/bin/python
+#
+# Simple utility script to manipulate
+# certain types of strings in a file
+
+# This can be used in various projects where
+# there is the need to replace strings in files,
+# and is copied from GLib's $(srcroot)/win32
+
+# Author: Fan, Chun-wei
+# Date: September 03, 2014
+
+import os
+import sys
+import re
+import string
+import argparse
+
+valid_actions = ['remove-prefix',
+                 'replace-var',
+                 'replace-str',
+                 'remove-str']
+
+def open_file(filename, mode):
+    if sys.version_info[0] < 3:
+        return open(filename, mode=mode)
+    else:
+        return open(filename, mode=mode, encoding='utf-8')
+
+def replace_multi(src, dest, replace_items):
+    with open_file(src, 'r') as s:
+        with open_file(dest, 'w') as d:
+            for line in s:
+                replace_dict = dict((re.escape(key), value) \
+                               for key, value in replace_items.items())
+                replace_pattern = re.compile("|".join(replace_dict.keys()))
+                d.write(replace_pattern.sub(lambda m: \
+                        replace_dict[re.escape(m.group(0))], line))
+
+def replace(src, dest, instring, outstring):
+    replace_item = {instring: outstring}
+    replace_multi(src, dest, replace_item)
+
+def check_required_args(args, params):
+    for param in params:
+        if getattr(args, param, None) is None:
+            raise SystemExit('%s: error: --%s argument is required' % (__file__, param))
+
+def warn_ignored_args(args, params):
+    for param in params:
+        if getattr(args, param, None) is not None:
+            print('%s: warning: --%s argument is ignored' % (__file__, param))
+
+def main(argv):
+
+    parser = argparse.ArgumentParser(description='Process strings in a file.')
+    parser.add_argument('-a',
+                        '--action',
+                        help='Action to carry out.  Can be one of:\n'
+                             'remove-prefix\n'
+                             'replace-var\n'
+                             'replace-str\n'
+                             'remove-str',
+                        choices=valid_actions)
+    parser.add_argument('-i', '--input', help='Input file')
+    parser.add_argument('-o', '--output', help='Output file')
+    parser.add_argument('--instring', help='String to replace or remove')
+    parser.add_argument('--var', help='Autotools variable name to replace')
+    parser.add_argument('--outstring',
+                        help='New String to replace specified string or variable')
+    parser.add_argument('--removeprefix', help='Prefix of string to remove')
+
+    args = parser.parse_args()
+
+    input_string = ''
+    output_string = ''
+
+    # We must have action, input, output for all operations
+    check_required_args(args, ['action','input','output'])
+
+    # Build the arguments by the operation that is to be done,
+    # to be fed into replace()
+
+    # Get rid of prefixes from a string
+    if args.action == 'remove-prefix':
+        check_required_args(args, ['instring','removeprefix'])
+        warn_ignored_args(args, ['outstring','var'])
+        input_string = args.removeprefix + args.instring
+        output_string = args.instring
+
+    # Replace an m4-style variable (those surrounded by @...@)
+    if args.action == 'replace-var':
+        check_required_args(args, ['var','outstring'])
+        warn_ignored_args(args, ['instring','removeprefix'])
+        input_string = '@' + args.var + '@'
+        output_string = args.outstring
+
+    # Replace a string
+    if args.action == 'replace-str':
+        check_required_args(args, ['instring','outstring'])
+        warn_ignored_args(args, ['var','removeprefix'])
+        input_string = args.instring
+        output_string = args.outstring
+
+    # Remove a string
+    if args.action == 'remove-str':
+        check_required_args(args, ['instring'])
+        warn_ignored_args(args, ['var','outstring','removeprefix'])
+        input_string = args.instring
+        output_string = ''
+
+    replace(args.input, args.output, input_string, output_string)
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))


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