Commit 23b72e98 authored by Chun-wei Fan's avatar Chun-wei Fan

Build: Add NMake Makefiles

This adds NMake Makefiles that are consumed by Visual Studio 2013 or later
so that we can build gjs using Visual Studio with NMake.  Note that since
NMake can be clunky at some points, so we use some tricks to convert the
source listings into .obj listings that it expects, as well as to create a
file list for files that it needs to feed to the introspection scanner, as
well as batch rules (similar to the pattern rules) to compile the sources
that are spread out in different directories, and to reduce repetition as
much as possible.

Note that this is modularized, so there are items that are shared with
other projects like HarfBuzz, including:
detectenv-msvc.mak
introspection-msvc.mak
create-lists.bat

https://bugzilla.gnome.org/show_bug.cgi?id=775868
parent a94c06c7
......@@ -150,15 +150,27 @@ install-exec-hook:
include Makefile-test.am
include Makefile-insttest.am
EXTRA_DIST += \
autogen.sh \
COPYING.LGPL \
doc/ByteArray.md \
doc/cairo.md \
doc/Class_Framework.md \
doc/SpiderMonkey_Memory.md \
doc/Style_Guide.md \
win32/config.h.win32 \
EXTRA_DIST += \
autogen.sh \
COPYING.LGPL \
doc/ByteArray.md \
doc/cairo.md \
doc/Class_Framework.md \
doc/SpiderMonkey_Memory.md \
doc/Style_Guide.md \
win32/build-rules-msvc.mak \
win32/config-msvc.mak \
win32/config.h.win32 \
win32/create-lists-msvc.mak \
win32/create-lists.bat \
win32/detectenv-msvc.mak \
win32/generate-msvc.mak \
win32/gjs-introspection-msvc.mak \
win32/info-msvc.mak \
win32/install.mak \
win32/introspection-msvc.mak \
win32/Makefile.vc \
win32/README.txt \
$(NULL)
# Colin's handy Makefile bits for:
......
# NMake Makefile for building GJS 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 ..\gjs-srcs.mk
!include ..\gjs-modules-srcs.mk
# Include the Makefile portion that enables features based on user input
!include config-msvc.mak
!if "$(VALID_CFGSET)" == "TRUE"
# We need Visual Studio 2013 or later
!if $(VSVER) < 12
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
!include create-lists-msvc.mak
all: $(GJS_LIBS) $(EXTRA_TARGETS) $(GJS_UTILS) all-build-info
tests: all
# 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
!include gjs-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
@echo CFG=release or CFG=debug
!endif # "$(VALID_CFGSET)" == "TRUE"
!include info-msvc.mak
Instructions for building GJS on Visual Studio
==============================================
Building the GJS on Windows is now supported using Visual Studio
versions 2013 or later in both 32-bit and 64-bit (x64) flavors,
via NMake Makefiles. Due to C++-11 usage, Visual Studio 2012 or
earlier is not supported.
You will need the following items to build GJS using Visual Studio:
-SpiderMonkey 31 (mozjs-31)
-GObject-Introspection (G-I) 1.41.4 or later
-GLib 2.50.x or later, (which includes GIO, GObject, and the associated tools)
-Cairo including Cairo-GObject support, unless NO_CAIRO=1 is specified.
-GTK+-3.20.x or later, unless NO_GTK=1 is specified.
-and anything that the above items depends on.
Note that SpiderMonkey must be built with Visual Studio, and the rest
should preferably be built with Visual Studio as well. The Visual Studio
version used should preferably be the one that is used here to build GJS.
The following are instructions for performing such a build, as there is a
number of build configurations supported for the build. Note that the default
build (where no options (see below) are specified, the GJS library is built with
Cairo and GTK+ support. A 'clean' target is provided-it is recommended that
one cleans the build and redo the build if any configuration option changed. An
'install' target is also provided to copy the built items in their appropriate
locations under $(PREFIX), which is described below.
Invoke the build by issuing the command:
nmake /f Makefile.vc CFG=[release|debug] [PREFIX=...] <option1=1 option2=1 ...>
where:
CFG: Required. Choose from a release or debug build. Note that
all builds generate a .pdb file for each .dll and .exe built--this refers
to the C/C++ runtime that the build uses.
PREFIX: Optional. Base directory of where the third-party headers, libraries
and needed tools can be found, i.e. headers in $(PREFIX)\include,
libraries in $(PREFIX)\lib and tools in $(PREFIX)\bin. If not
specified, $(PREFIX) is set as $(srcroot)\..\vs$(X)\$(platform), where
$(platform) is win32 for 32-bit builds or x64 for 64-bit builds, and
$(X) is the short version of the Visual Studio used, as follows:
2013: 12
2015: 14
Explanation of options, set by <option>=1:
------------------------------------------
NO_CAIRO: Disables Cairo support in the GJS DLL.
NO_GTK: Disables GTK+ support in the GJS DLL
INTROSPECTION: Enable build of introspection files, for making
bindings for other programming languages available, such as
Python. This requires the GObject-Introspection
libraries and tools, along with the Python interpreter that was
used during the build of GObject-Introspection. This will
require the introspection files for GTK+, unless NO_GTK=1 is
specified, where the introspection files for GIO will be
required.
PYTHON: Full path to the Python interpreter to be used, if it is not in %PATH%.
LIBTOOL_DLL_NAME: Enable libtool-style DLL names. Note this does not make this
GJS build usable by other compilers, due to C++ usage.
# 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 @<<
# $<
# <<
{..\modules\}.cpp{$(CFG)\$(PLAT)\module-console\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\module-console\ /c @<<
$<
<<
{..\modules\}.cpp{$(CFG)\$(PLAT)\module-system\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\module-system\ /c @<<
$<
<<
{..\modules\}.cpp{$(CFG)\$(PLAT)\module-cairo\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\module-cairo\ /c @<<
$<
<<
{..\gi\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\gjs\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\libgjs-private\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\libgjs-private\}.c{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CC) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\modules\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\util\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{$(CFG)\$(PLAT)\module-resources\}.c{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CC) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\gjs\}.cpp{$(CFG)\$(PLAT)\gjs-console\}.obj::
$(CXX) $(CFLAGS) $(GJS_CFLAGS) /Fo$(CFG)\$(PLAT)\gjs-console\ /c @<<
$<
<<
# Rules for building .lib files
$(CFG)\$(PLAT)\gjs.lib: $(LIBGJS_DLL_FILENAME).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
$(LIBGJS_DLL_FILENAME).dll: \
$(GJS_INCLUDED_MODULES) \
$(CFG)\$(PLAT)\module-resources \
$(CFG)\$(PLAT)\libgjs \
$(module_resources_generated_srcs) \
$(libgjs_dll_OBJS)
link /DLL $(LDFLAGS) $(GJS_INCLUDED_MODULES) \
$(LIBGJS_DEP_LIBS) /implib:$(CFG)\$(PLAT)\gjs.lib \
-out:$@ @<<
$(libgjs_dll_OBJS)
<<
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
$(CFG)\$(PLAT)\module-console.lib: ..\config.h $(CFG)\$(PLAT)\module-console $(module_console_OBJS)
lib $(ARFLAGS) -out:$@ @<<
$(module_console_OBJS)
<<
$(CFG)\$(PLAT)\module-system.lib: ..\config.h $(CFG)\$(PLAT)\module-system $(module_system_OBJS)
lib $(ARFLAGS) -out:$@ @<<
$(module_system_OBJS)
<<
$(CFG)\$(PLAT)\module-cairo.lib: ..\config.h $(CFG)\$(PLAT)\module-cairo $(module_cairo_OBJS)
lib $(ARFLAGS) -out:$@ @<<
$(module_cairo_OBJS)
<<
# 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
$(CFG)\$(PLAT)\gjs-console.exe: $(CFG)\$(PLAT)\gjs.lib $(CFG)\$(PLAT)\gjs-console $(gjs_OBJS)
link $(LDFLAGS) $(CFG)\$(PLAT)\gjs.lib $(GJS_BASE_LIBS) -out:$@ $(gjs_OBJS)
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
clean:
@-if exist $(CFG)\$(PLAT)\GjsPrivate-1.0.typelib del /f /q $(CFG)\$(PLAT)\GjsPrivate-1.0.typelib
@-if exist $(CFG)\$(PLAT)\GjsPrivate-1.0.gir del /f /q $(CFG)\$(PLAT)\GjsPrivate-1.0.gir
@-if exist $(CFG)\$(PLAT)\gjs_private_list del /f /q $(CFG)\$(PLAT)\gjs_private_list
@-del /f /q $(CFG)\$(PLAT)\*.pdb
@-if exist $(CFG)\$(PLAT)\gjs-console.exe.manifest del /f /q $(CFG)\$(PLAT)\gjs-console.exe.manifest
@-if exist $(CFG)\$(PLAT)\gjs-console.exe del /f /q $(CFG)\$(PLAT)\gjs-console.exe
@-del /f /q $(CFG)\$(PLAT)\*.dll.manifest
@-del /f /q $(CFG)\$(PLAT)\*.dll
@-del /f /q $(CFG)\$(PLAT)\*.ilk
@-del /f /q $(CFG)\$(PLAT)\*.exp
@-del /f /q $(CFG)\$(PLAT)\*.lib
@-if exist $(CFG)\$(PLAT)\module-cairo.lib del /f /q $(CFG)\$(PLAT)\module-cairo\*.obj
@-del /f /q $(CFG)\$(PLAT)\module-system\*.obj
@-del /f /q $(CFG)\$(PLAT)\module-console\*.obj
@-del /f /q $(CFG)\$(PLAT)\libgjs\*.obj
@-del /f /q $(CFG)\$(PLAT)\gjs-console\*.obj
@-del /f /q $(module_resources_generated_srcs)
@-del vc$(VSVER)0.pdb
@-del ..\config.h
# NMake Makefile portion for enabling features for Windows builds
# Spidermonkey release series (17, 24, 31, 38, 45 etc.)
MOZJS_VERSION = 31
# Please see https://bugzilla.gnome.org/show_bug.cgi?id=775868,
# comments 26, 27 and 28
!if "$(MOZJS_VERSION)" == "31"
MOZ_BUG_WORKAROUND_CFLAG = /DJSGC_USE_EXACT_ROOTING=1
!else
MOZ_BUG_WORKAROUND_CFLAG =
!endif
# These are the base minimum libraries required for building gjs.
BASE_INCLUDES = \
/I$(PREFIX)\include\gobject-introspection-1.0\girepository \
/I$(PREFIX)\include\glib-2.0 \
/I$(PREFIX)\lib\glib-2.0\include \
/I$(PREFIX)\include\mozjs-$(MOZJS_VERSION) \
/I$(PREFIX)\include
GJS_BASE_LIBS = gio-2.0.lib gobject-2.0.lib glib-2.0.lib
LIBGJS_BASE_DEP_LIBS = \
girepository-1.0.lib \
$(GJS_BASE_LIBS) \
libffi.lib \
intl.lib \
mozjs-$(MOZJS_VERSION).lib
# For Cairo support
CAIRO_LIBS = cairo-gobject.lib cairo.lib
# For GTK+ support
GTK_INCLUDES = \
/I$(PREFIX)\include\gtk-3.0 \
/I$(PREFIX)\include\gdk-pixbuf-2.0 \
/I$(PREFIX)\include\pango-1.0 \
/I$(PREFIX)\include\atk-1.0
GTK_LIBS = gtk-3.0.lib gdk-3.0.lib
# Please do not change anything beneath this line unless maintaining the NMake Makefiles
# Bare minimum features and sources built into GJS on Windows
# We build the resource module sources directly into the gjs DLL, not as a separate .lib,
# so that we don't have to worry about the Visual Studio linker dropping items during
# optimization
GJS_DEFINES =
GJS_INCLUDED_MODULES = \
$(CFG)\$(PLAT)\module-console.lib \
$(CFG)\$(PLAT)\module-system.lib
GJS_BASE_CFLAGS = \
/I.. \
/FImsvc_recommended_pragmas.h \
/FIjs\RequiredDefines.h \
/Dssize_t=gssize \
/DG_LOG_DOMAIN=\"Gjs\" \
/wd4530 \
/wd4099 \
/wd4251 \
/wd4800
LIBGJS_DEP_INCLUDES = $(BASE_INCLUDES)
LIBGJS_DEP_LIBS = $(LIBGJS_BASE_DEP_LIBS)
LIBGJS_PRIVATE_SOURCES = $(gjs_private_srcs)
LIBGJS_HEADERS = $(gjs_public_headers:/=\)
# We build libgjs and gjs-console at least
GJS_LIBS = $(CFG)\$(PLAT)\gjs.lib
GJS_UTILS = $(CFG)\$(PLAT)\gjs-console.exe
GJS_TESTS =
# Enable Cairo
!if "$(NO_CAIRO)" != "1"
GJS_DEFINES = $(GJS_DEFINES) /DENABLE_CAIRO
GJS_INCLUDED_MODULES = \
$(GJS_INCLUDED_MODULES) \
$(CFG)\$(PLAT)\module-cairo.lib
LIBGJS_DEP_LIBS = $(CAIRO_LIBS) $(LIBGJS_DEP_LIBS)
!endif
INTROSPECTION_INCLUDE_PACKAGES = --include=Gio-2.0 --include=GObject-2.0
# Enable GTK+
!if "$(NO_GTK)" != "1"
GJS_DEFINES = $(GJS_DEFINES) /DENABLE_GTK
LIBGJS_PRIVATE_SOURCES = $(LIBGJS_PRIVATE_SOURCES) $(gjs_gtk_private_srcs)
GJS_INTROSPECTION_CHECK_PACKAGE = gtk+-3.0
INTROSPECTION_INCLUDE_PACKAGES = $(INTROSPECTION_INCLUDE_PACKAGES) --include=Gtk-3.0
LIBGJS_DEP_INCLUDES = $(GTK_INCLUDES) $(LIBGJS_DEP_INCLUDES)
LIBGJS_DEP_LIBS = $(GTK_LIBS) $(LIBGJS_DEP_LIBS)
!else
GJS_INTROSPECTION_CHECK_PACKAGE = gio-2.0
!endif
LIBGJS_SOURCES = $(gjs_srcs) $(LIBGJS_PRIVATE_SOURCES)
# Use libtool-style DLL names, if desired
!if "$(LIBTOOL_DLL_NAME)" == "1"
LIBGJS_DLL_FILENAME = $(CFG)\$(PLAT)\libgjs-0
!else
LIBGJS_DLL_FILENAME = $(CFG)\$(PLAT)\gjs-vs$(VSVER)
!endif
TEST_PROGRAMS =
# Enable Introspection
!if "$(INTROSPECTION)" == "1"
CHECK_PACKAGE = $(GJS_INTROSPECTION_CHECK_PACKAGE)
EXTRA_TARGETS = $(CFG)\$(PLAT)\GjsPrivate-1.0.gir $(CFG)\$(PLAT)\GjsPrivate-1.0.typelib
!else
EXTRA_TARGETS =
!endif
# Put together the CFLAGS
LIBGJS_CFLAGS = \
$(GJS_DEFINES) \
$(MOZ_BUG_WORKAROUND_CFLAG) \
/DGJS_COMPILATION \
/DXP_WIN \
/DWIN32 \
/DFFI_BUILDING \
$(GJS_BASE_CFLAGS) \
$(LIBGJS_DEP_INCLUDES)
GJS_CFLAGS = \
$(GJS_DEFINES) \
$(MOZ_BUG_WORKAROUND_CFLAG) \
$(GJS_BASE_CFLAGS) \
$(BASE_INCLUDES)
# 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 libgjs
!if [call create-lists.bat header gjs_objs.mak libgjs_dll_OBJS]
!endif
!if [for %c in ($(LIBGJS_SOURCES)) do @if "%~xc" == ".cpp" @call create-lists.bat file gjs_objs.mak ^$(CFG)\^$(PLAT)\libgjs\%~nc.obj]
!endif
!if [for %c in ($(LIBGJS_SOURCES)) do @if "%~xc" == ".c" @call create-lists.bat file gjs_objs.mak ^$(CFG)\^$(PLAT)\libgjs\%~nc.obj]
!endif
!if [for %c in ($(module_resource_srcs)) do @if "%~xc" == ".c" @call create-lists.bat file gjs_objs.mak ^$(CFG)\^$(PLAT)\libgjs\%~nc.obj]
!endif
!if [call create-lists.bat footer gjs_objs.mak]
!endif
!if [call create-lists.bat header gjs_objs.mak gjs_OBJS]
!endif
!if [for %c in ($(gjs_console_srcs)) do @if "%~xc" == ".cpp" @call create-lists.bat file gjs_objs.mak ^$(CFG)\^$(PLAT)\gjs-console\%~nc.obj]
!endif
!if [call create-lists.bat footer gjs_objs.mak]
!endif
!include gjs_objs.mak
!if [del /f /q gjs_objs.mak]
!endif
# For module-resources
!if [call create-lists.bat header gjs_modules_objs.mak module_resources_generated_srcs]
!endif
!if [for %c in ($(module_resource_srcs)) do @call create-lists.bat file gjs_modules_objs.mak ^$(CFG)\^$(PLAT)\module-resources\%c]
!endif
!if [call create-lists.bat footer gjs_modules_objs.mak]
!endif
!if [call create-lists.bat header gjs_modules_objs.mak module_system_OBJS]
!endif
!if [for %c in ($(module_system_srcs)) do @if "%~xc" == ".cpp" @call create-lists.bat file gjs_modules_objs.mak ^$(CFG)\^$(PLAT)\module-system\%~nc.obj]
!endif
!if [call create-lists.bat footer gjs_modules_objs.mak]
!endif
!if [call create-lists.bat header gjs_modules_objs.mak module_console_OBJS]
!endif
!if [for %c in ($(module_console_srcs)) do @if "%~xc" == ".cpp" @call create-lists.bat file gjs_modules_objs.mak ^$(CFG)\^$(PLAT)\module-console\%~nc.obj]
!endif
!if [call create-lists.bat footer gjs_modules_objs.mak]
!endif
!if [call create-lists.bat header gjs_modules_objs.mak module_cairo_OBJS]
!endif
!if [for %c in ($(module_cairo_srcs)) do @if "%~xc" == ".cpp" @call create-lists.bat file gjs_modules_objs.mak ^$(CFG)\^$(PLAT)\module-cairo\%~nc.obj]
!endif
!if [call create-lists.bat footer gjs_modules_objs.mak]
!endif
!include gjs_modules_objs.mak
!if [del /f /q gjs_modules_objs.mak]
!endif
@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
# Change this (or specify PREFIX= when invoking this NMake Makefile) if
# necessary, so that the libs and headers of the dependent third-party
# libraries can be located. For instance, if building from GLib's
# included Visual Studio projects, this should be able to locate the GLib
# build out-of-the-box if they were not moved. GLib's headers will be
# found in $(GLIB_PREFIX)\include\glib-2.0 and
# $(GLIB_PREFIX)\lib\glib-2.0\include and its import library will be found
# in $(GLIB_PREFIX)\lib.
!if "$(PREFIX)" == ""
PREFIX = ..\..\vs$(VSVER)\$(PLAT)
!endif
# Location of the PERL interpreter, for running glib-mkenums. glib-mkenums
# needs to be found in $(PREFIX)\bin. Using either a 32-bit or x64 PERL
# interpreter are supported for either a 32-bit or x64 build.
!if "$(PERL)" == ""
PERL = perl
!endif
# Location of the Python interpreter, for building introspection. The complete set
# of Python Modules for introspection (the giscanner Python scripts and the _giscanner.pyd
# compiled module) needs to be found in $(PREFIX)\lib\gobject-introspection\giscanner, and
# the g-ir-scanner Python script and g-ir-compiler utility program needs to be found
# in $(PREFIX)\bin, together with any DLLs they will depend on, if those DLLs are not already
# in your PATH.
# Note that the Python interpreter and the introspection modules and utility progam must
# correspond to the build type (i.e. 32-bit Release for 32-bit Release builds, and so on).
#
# For introspection, currently only Python 2.7.x is supported. This may change when Python 3.x
# support is added upstream in gobject-introspection--when this happens, the _giscanner.pyd must
# be the one that is built against the release series of Python that is used here.
!if "$(PYTHON)" == ""
PYTHON = python
!endif
# Location of the pkg-config utility program, for building introspection. It needs to be able
# to find the pkg-config (.pc) files so that the correct libraries and headers for the needed libraries
# can be located, using PKG_CONFIG_PATH. Using either a 32-bit or x64 pkg-config are supported for
# either a 32-bit or x64 build.
!if "$(PKG_CONFIG)" == ""
PKG_CONFIG = pkg-config
!endif
# The items below this line should not be changed, unless one is maintaining
# the NMake Makefiles. The exception is for the CFLAGS_ADD line(s) where one
# could use his/her desired compiler optimization flags, if he/she knows what is
# being done.
# 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) < 2000
VSVER = 14
!else
VSVER = 0
!endif
!if "$(VSVER)" == "0"
MSG = ^
This NMake Makefile set supports Visual Studio^
9 (2008) through 14 (2015). Your Visual Studio^
version is not supported.
!error $(MSG)
!endif
VALID_CFGSET = FALSE
!if "$(CFG)" == "release" || "$(CFG)" == "Release" || "$(CFG)" == "debug" || "$(CFG)" == "Debug"
VALID_CFGSET = TRUE
!endif
# One may change these items, but be sure to test
# the resulting binaries
!if "$(CFG)" == "release" || "$(CFG)" == "Release"
CFLAGS_ADD = /MD /O2 /GL /MP
!if "$(VSVER)" != "9"
CFLAGS_ADD = $(CFLAGS_ADD) /d2Zi+
!endif
!else
CFLAGS_ADD = /MDd /Od
!endif
!if "$(PLAT)" == "x64"
LDFLAGS_ARCH = /machine:x64
!else
LDFLAGS_ARCH = /machine:x86
!endif
!if "$(VALID_CFGSET)" == "TRUE"
CFLAGS = $(CFLAGS_ADD) /W3 /Zi
LDFLAGS_BASE = $(LDFLAGS_ARCH) /libpath:$(PREFIX)\lib /DEBUG
!if "$(CFG)" == "debug" || "$(CFG)" == "Debug"
ARFLAGS = $(LDFLAGS_ARCH)
LDFLAGS = $(LDFLAGS_BASE)
!else
ARFLAGS = $(LDFLAGS_ARCH) /LTCG
LDFLAGS = $(LDFLAGS_BASE) /LTCG /opt:ref
!endif
!endif
# 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
..\config.h: config.h.win32
@-copy $(@B).h.win32 $@
# Create the build directories
$(CFG)\$(PLAT)\module-console \
$(CFG)\$(PLAT)\module-system \
$(CFG)\$(PLAT)\module-resources \
$(CFG)\$(PLAT)\module-cairo \
$(CFG)\$(PLAT)\libgjs \
$(CFG)\$(PLAT)\gjs-console:
@-mkdir $@
# Generate the GResource sources
$(CFG)\$(PLAT)\module-resources\modules-resources.h \
$(CFG)\$(PLAT)\module-resources\modules-resources.c: ..\modules\modules.gresource.xml
$(PREFIX)\bin\glib-compile-resources.exe --target=$@ \
--sourcedir=.. --generate --c-name modules_resources \
$**
!if "$(BUILD_INTROSPECTION)" == "TRUE"
# Create the file list for introspection (to avoid the dreaded command-line-too-long problem on Windows)
$(CFG)\$(PLAT)\gjs_private_list:
@for %f in ($(LIBGJS_PRIVATE_SOURCES)) do @echo ../%f >> $@
$(CFG)\$(PLAT)\GjsPrivate-1.0.gir: $(CFG)\$(PLAT)\gjs.lib $(CFG)\$(PLAT)\gjs_private_list
@set LIB=.\$(CFG)\$(PLAT);$(PREFIX)\lib;$(LIB)
@set PATH=.\$(CFG)\$(PLAT);$(PREFIX)\bin;$(PATH)
@-echo Generating $@...
$(PYTHON) $(G_IR_SCANNER) \
--verbose -no-libtool \
--identifier-prefix=Gjs \
--symbol-prefix=gjs_ \
--warn-all \
--namespace=GjsPrivate \
--nsversion=1.0 \
$(INTROSPECTION_INCLUDE_PACKAGES) \
--library=gjs \
--library-path=$(CFG)\$(PLAT) \
--add-include-path=$(G_IR_INCLUDEDIR) \