# NMake Makefile portion for enabling features for Windows builds

!ifndef VULKAN_SDK_DIR
!message If you see compilation errors due to a missing vulkan/vulkan.h,
!message consider passing VULKAN_SDK_DIR=$$(root_directory_of_your_LunarG_Vulkan_SDK),
!message which is normally c:\VulkanSDK\$$(YOUR_LUNARG_VULKAN_SDK_VER) to the
!message NMake command line, and retry the build.
# Fallback for compatibility for older Vulkan SDKs
VULKAN_SDK_DIR=$(VULKAN_SDK)
!endif

# These are the base minimum libraries required for building gtkmm.
!ifndef BASE_INCLUDEDIR
BASE_INCLUDEDIR = $(PREFIX)\include
!endif
!ifndef BASE_LIBDIR
BASE_LIBDIR = $(PREFIX)\lib
!endif
!ifndef BASE_TOOLS_DIR
BASE_TOOLS_DIR = $(PREFIX)\bin
!endif

# Please do not change anything beneath this line unless maintaining the NMake Makefiles
# Debug/Release builds
!if "$(CFG)" == "debug" || "$(CFG)" == "Debug"
DEBUG_SUFFIX = -d
!else
DEBUG_SUFFIX =
!endif

# Dependencies

GTK_API_VERSION = 4
GTKMM_MAJOR_VERSION = 4
GTKMM_MINOR_VERSION = 0
GTKMM_API_VERSION = $(GTKMM_MAJOR_VERSION).$(GTKMM_MINOR_VERSION)

PANGO_API_VERSION = 1.0
PANGOMM_MAJOR_VERSION = 2
PANGOMM_MINOR_VERSION = 48
PANGOMM_API_VERSION = $(PANGOMM_MAJOR_VERSION).$(PANGOMM_MINOR_VERSION)

GLIB_API_VERSION = 2.0
GLIBMM_MAJOR_VERSION = 2
GLIBMM_MINOR_VERSION = 68
GLIBMM_API_VERSION = $(GLIBMM_MAJOR_VERSION).$(GLIBMM_MINOR_VERSION)

CAIROMM_MAJOR_VERSION = 1
CAIROMM_MINOR_VERSION = 16
CAIROMM_API_VERSION = $(CAIROMM_MAJOR_VERSION).$(CAIROMM_MINOR_VERSION)

SIGC_MAJOR_VERSION = 3
SIGC_MINOR_VERSION = 0
SIGC_SERIES = $(SIGC_MAJOR_VERSION).$(SIGC_MINOR_VERSION)

GDK_PIXBUF_API_VERSION = 2.0
GRAPHENE_API_VERSION = 1.0

OUTDIR = vs$(VSVER)\$(CFG)\$(PLAT)
DEPS_MKFILE = deps-vs$(VSVER)-$(PLAT)-$(CFG).mak
M4_PATH_MKFILE = find-m4-bindir-vs$(VSVER)-$(PLAT)-$(CFG).mak
UNIX_TOOLS_PATH_MKFILE = check-unix-tools-bindir-vs$(VSVER)-$(PLAT)-$(CFG).mak
BUILD_MKFILE_SNIPPET = gtkmm-vs$(VSVER)-$(PLAT)-$(CFG).mak

!if [for %t in (GTK PANGOMM GDK_PIXBUF PANGO GLIBMM CAIROMM SIGC CAIRO GRAPHENE HARFBUZZ FONTCONFIG FREETYPE GLIB EPOXY) do @(echo !ifndef %t_INCLUDEDIR>>$(DEPS_MKFILE) & echo %t_INCLUDEDIR=^$^(BASE_INCLUDEDIR^)>>$(DEPS_MKFILE) & echo !endif>>$(DEPS_MKFILE))]
!endif
!if [for %t in (GTK PANGOMM GDK_PIXBUF PANGO GLIBMM CAIROMM SIGC CAIRO GRAPHENE GLIB EPOXY) do @(echo !ifndef %t_LIBDIR>>$(DEPS_MKFILE) & echo %t_LIBDIR=^$^(BASE_LIBDIR^)>>$(DEPS_MKFILE) & echo !endif>>$(DEPS_MKFILE))]
!endif
!if [for %t in (GLIB) do @(echo !ifndef %t_BINDIR>>$(DEPS_MKFILE) & echo %t_BINDIR=^$^(BASE_TOOLS_DIR^)>>$(DEPS_MKFILE) & echo !endif>>$(DEPS_MKFILE))]
!endif

!include $(DEPS_MKFILE)

!if [del /f/q $(DEPS_MKFILE)]
!endif

!ifndef M4
!ifdef UNIX_TOOLS_BINDIR
M4 = $(UNIX_TOOLS_BINDIR)\m4.exe
!else
M4 = m4
!endif
!endif

# Try to deduce full path to m4.exe, as needed
!if [if not exist $(M4)\ if exist $(M4) echo M4_FULL_PATH = $(M4)>$(M4_PATH_MKFILE)]
!endif
!if [if exist $(M4).exe echo M4_FULL_PATH = $(M4).exe>$(M4_PATH_MKFILE)]
!endif
!if [if not exist $(M4_PATH_MKFILE) ((echo M4_FULL_PATH = \>$(M4_PATH_MKFILE)) & where $(M4)>>$(M4_PATH_MKFILE) 2>NUL)]
!endif

!include $(M4_PATH_MKFILE)

!if [del /f/q $(M4_PATH_MKFILE)]
!endif

!if [if not "$(UNIX_TOOLS_BINDIR)" == "" if not "$(M4_FULL_PATH)" == "" echo UNIX_TOOLS_BINDIR_CHECKED = $(UNIX_TOOLS_BINDIR)>$(UNIX_TOOLS_PATH_MKFILE)]
!endif

!if [if "$(UNIX_TOOLS_BINDIR)" == "" if not "$(M4_FULL_PATH)" == "" (for %f in ($(M4_FULL_PATH)) do @echo UNIX_TOOLS_BINDIR_CHECKED = %~dpf>$(UNIX_TOOLS_PATH_MKFILE))]
!endif

!if [if not exist $(UNIX_TOOLS_PATH_MKFILE) (echo UNIX_TOOLS_BINDIR_CHECKED = >$(UNIX_TOOLS_PATH_MKFILE))]
!endif

!include $(UNIX_TOOLS_PATH_MKFILE)

!if [del /f/q $(UNIX_TOOLS_PATH_MKFILE)]
!endif

!ifndef GMMPROC_DIR
GMMPROC_DIR=$(GLIBMM_LIBDIR)\glibmm-$(GLIBMM_API_VERSION)\proc
!endif

!ifndef GMMPROC_PANGO_DIR
GMMPROC_PANGO_DIR=$(PANGOMM_LIBDIR)\pangomm-$(PANGOMM_API_VERSION)\proc\m4
!endif

DEP_INCLUDES =	\
	/I$(GTK_INCLUDEDIR)\gtk-$(GTK_API_VERSION).0	\
	/I$(GDK_PIXBUF_INCLUDEDIR)\gdk-pixbuf-$(GDK_PIXBUF_API_VERSION)	\
	/I$(PANGOMM_INCLUDEDIR)\pangomm-$(PANGOMM_API_VERSION)	\
	/I$(PANGOMM_LIBDIR)\pangomm-$(PANGOMM_API_VERSION)\include	\
	/I$(PANGO_INCLUDEDIR)\pango-$(PANGO_API_VERSION)	\
	/I$(CAIROMM_INCLUDEDIR)\cairomm-$(CAIROMM_API_VERSION)	\
	/I$(CAIROMM_LIBDIR)\cairomm-$(CAIROMM_API_VERSION)\include	\
	/I$(CAIRO_INCLUDEDIR)\cairo	\
	/I$(GLIBMM_INCLUDEDIR)\giomm-$(GLIBMM_API_VERSION)	\
	/I$(GLIBMM_LIBDIR)\giomm-$(GLIBMM_API_VERSION)\include	\
	/I$(GLIBMM_INCLUDEDIR)\glibmm-$(GLIBMM_API_VERSION)	\
	/I$(GLIBMM_LIBDIR)\glibmm-$(GLIBMM_API_VERSION)\include	\
	/I$(GLIB_INCLUDEDIR)\glib-$(GLIB_API_VERSION)	\
	/I$(GLIB_LIBDIR)\glib-$(GLIB_API_VERSION)\include	\
	/I$(SIGC_INCLUDEDIR)\sigc++-$(SIGC_SERIES)	\
	/I$(SIGC_LIBDIR)\sigc++-$(SIGC_SERIES)\include	\
	/I$(GRAPHENE_INCLUDEDIR)\graphene-$(GRAPHENE_API_VERSION)	\
	/I$(GRAPHENE_LIBDIR)\graphene-$(GRAPHENE_API_VERSION)\include	\
	/I$(HARFBUZZ_INCLUDEDIR)\harfbuzz

# Just in case one built Pango with FontConfig support
!if "$(FONTCONFIG_INCLUDEDIR)" != "$(BASE_INCLUDEDIR)"
DEP_INCLUDES = $(DEP_INCLUDES) /I$(FONTCONFIG_INCLUDEDIR)
!endif
DEP_INCLUDES = $(DEP_INCLUDES) /I$(FREETYPE_INCLUDEDIR)\freetype2

# If gtk is built with Vulkan, we need to include the Vulkan headers
# (use the default %VULKAN_SDK_DIR% that the Vulkan SDK sets during installation
!ifdef VULKAN_SDK_DIR
DEP_INCLUDES = $(DEP_INCLUDES) /I$(VULKAN_SDK_DIR)\include
!endif
!if "$(EPOXY_INCLUDEDIR)" != "$(BASE_INCLUDEDIR)"
DEP_INCLUDES = $(DEP_INCLUDES) /I$(EPOXY_INCLUDEDIR)
!endif
DEP_INCLUDES = $(DEP_INCLUDES) /I$(BASE_INCLUDEDIR)

# Compiler CXXFLAGS and In-source include directories
GTKMM_BASE_CFLAGS = /FImsvc_recommended_pragmas.h
GTKMM_BUILD_INCLUDES = /I$(OUTDIR)
GTKMM_INCLUDES = /I..\untracked\gtk /I..\untracked\gtk\gtkmm /I..\gtk /I.\gtkmm
GSKMM_INCLUDES = $(GTKMM_INCLUDES:gtk=gsk)
GDKMM_INCLUDES = $(GTKMM_INCLUDES:gtk=gdk)

# Now gather up the CXXFLAGS and include flags

LIBGDKMM_CXXFLAGS = /DGDKMM_BUILD $(GTKMM_BASE_CFLAGS)
LIBGSKMM_CXXFLAGS = $(LIBGDKMM_CXXFLAGS:/DGDKMM_=/DGSKMM_)
LIBGTKMM_CXXFLAGS = $(LIBGDKMM_CXXFLAGS:/DGDKMM_=/DGTKMM_) /wd4250
GTKMM_DEMO_CFLAGS = $(CFLAGS) $(GTKMM_BASE_CFLAGS) /wd4250
LIBGDKMM_INCLUDES = $(GTKMM_BUILD_INCLUDES) $(GDKMM_INCLUDES) $(DEP_INCLUDES)
LIBGSKMM_INCLUDES = $(GTKMM_BUILD_INCLUDES) $(GSKMM_INCLUDES) $(GDKMM_INCLUDES) $(DEP_INCLUDES)
LIBGTKMM_INCLUDES = $(GTKMM_BUILD_INCLUDES) $(GTKMM_INCLUDES) $(GSKMM_INCLUDES) $(GDKMM_INCLUDES) $(DEP_INCLUDES)

# We build gtkmm-vc$(VSVER_LIB)-$(GTKMM_MAJOR_VERSION)_$(GTKMM_MINOR_VERSION).dll or
#          gtkmm-vc$(VSVER_LIB)-d-$(GTKMM_MAJOR_VERSION)_$(GTKMM_MINOR_VERSION).dll at least

# With /GL, gtkmm4-demo fails on VS 2017 32 bit with an internal compiler error...
!if $(VSVER) < 16 && "$(PLAT)" == "Win32"
GTKMM_DEMO_CFLAGS = $(GTKMM_DEMO_CFLAGS: /GL=)
GTKMM_DEMO_LDFLAGS = $(LDFLAGS: /LTCG=)
!else
GTKMM_DEMO_LDFLAGS = $(LDFLAGS)
!endif

!if "$(USE_COMPAT_LIBS)" != ""
MESON_VERVER_LIB =
VSVER_LIB = 150
!else
VSVER_LIB = $(PDBVER)$(VSVER_SUFFIX)
MESON_VERVER_LIB = -vc$(VSVER_LIB)
!endif

GIO_LIBS = gio-$(GLIB_API_VERSION).lib gobject-$(GLIB_API_VERSION).lib gmodule-$(GLIB_API_VERSION).lib glib-$(GLIB_API_VERSION).lib

CAIRO_LIBS = cairo-gobject.lib cairo.lib
EPOXY_LIB = epoxy.lib
GDK_PIXBUF_LIB = gdk_pixbuf-$(GDK_PIXBUF_API_VERSION).lib
GRAPHENE_LIB = graphene-$(GRAPHENE_API_VERSION).lib
GTK_LIB = gtk-$(GTK_API_VERSION).lib
PANGO_LIBS = pangocairo-$(PANGO_API_VERSION).lib pango-$(PANGO_API_VERSION).lib

!ifdef USE_MESON_LIBS
SIGC_LIBNAME = sigc-$(SIGC_SERIES)
GLIBMM_LIBNAME = glibmm$(MESON_VERVER_LIB)-$(GLIBMM_API_VERSION)
GIOMM_LIBNAME = giomm$(MESON_VERVER_LIB)-$(GLIBMM_API_VERSION)
CAIROMM_LIBNAME = cairomm$(MESON_VERVER_LIB)-$(CAIROMM_API_VERSION)
PANGOMM_LIBNAME = pangomm$(MESON_VERVER_LIB)-$(PANGOMM_API_VERSION)
GTKMM_LIBNAME = gtkmm$(MESON_VERVER_LIB)-$(GTKMM_API_VERSION)
GTKMM_DLLNAME = $(GTKMM_LIBNAME)-1
!else
SIGC_LIBNAME = sigc-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(SIGC_SERIES:.=_)
GLIBMM_LIBNAME = glibmm-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(GLIBMM_API_VERSION:.=_)
GIOMM_LIBNAME = giomm-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(GLIBMM_API_VERSION:.=_)
CAIROMM_LIBNAME = cairomm-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(CAIROMM_API_VERSION:.=_)
PANGOMM_LIBNAME = pangomm-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(PANGOMM_API_VERSION:.=_)
GTKMM_LIBNAME = gtkmm-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(GTKMM_API_VERSION:.=_)
GTKMM_DLLNAME = $(GTKMM_LIBNAME)
!endif

SIGC_LIB = $(SIGC_LIBNAME).lib
GLIBMM_LIB = $(GLIBMM_LIBNAME).lib
GIOMM_LIB = $(GIOMM_LIBNAME).lib
CAIROMM_LIB = $(CAIROMM_LIBNAME).lib
PANGOMM_LIB = $(PANGOMM_LIBNAME).lib
GTKMM_LIB = $(GTKMM_LIBNAME).lib

# Gather up the .lib's that we need to link to
DEP_LDFLAGS = $(EPOXY_LIB) /libpath:$(BASE_LIBDIR)
!if "$(EPOXY_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(EPOXY_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(GIO_LIBS) $(DEP_LDFLAGS)
!if "$(GLIB_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(GLIB_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(CAIRO_LIBS) $(DEP_LDFLAGS)
!if "$(CAIRO_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(CAIRO_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(GRAPHENE_LIB) $(DEP_LDFLAGS)
!if "$(GRAPHENE_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(GRAPHENE_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(GDK_PIXBUF_LIB) $(DEP_LDFLAGS)
!if "$(GDK_PIXBUF_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(GDK_PIXBUF_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(GTK_LIB) $(DEP_LDFLAGS)
!if "$(GTK_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(GTK_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(SIGC_LIB) $(DEP_LDFLAGS)
!if "$(SIGC_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(SIGC_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(GIOMM_LIB) $(GLIBMM_LIB) $(DEP_LDFLAGS)
!if "$(GLIBMM_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(GLIBMM_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(CAIROMM_LIB) $(DEP_LDFLAGS)
!if "$(CAIROMM_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(CAIROMM_LIBDIR) $(DEP_LDFLAGS)
!endif
DEP_LDFLAGS = $(PANGOMM_LIB) $(DEP_LDFLAGS)
!if "$(PANGOMM_LIBDIR)" != "$(BASE_LIBDIR)"
DEP_LDFLAGS = /libpath:$(PANGOMM_LIBDIR) $(DEP_LDFLAGS)
!endif


GTKMM_DLL = $(OUTDIR)\$(GTKMM_DLLNAME).dll
GTKMM_LIB = $(OUTDIR)\$(GTKMM_LIBNAME).lib

GTKMM4_DEMO = $(OUTDIR)\gtkmm4-demo$(DEBUG_SUFFIX).exe

GTKMM_INT_EXTRA_SOURCES = $(gtkmm_files_extra_any_cc)
GTKMM_INT_EXTRA_HEADERS = $(gtkmm_files_extra_any_h)
GTKMM_INT_EXTRA_HEADERS_P = $(gtkmm_files_extra_ph:/=\)

GDKMM_HG_FILES = $(gdkmm_files_any_hg)
GSKMM_HG_FILES = $(gskmm_files_any_hg)
GTKMM_HG_FILES = $(gtkmm_files_any_hg)

ENABLED_DEPRECATED = no

!ifndef DISABLE_DEPRECATED
GTKMM_INT_EXTRA_SOURCES = $(GTKMM_INT_EXTRA_SOURCES) $(gtkmm_files_extra_deprecated_cc)
GTKMM_INT_EXTRA_HEADERS = $(GTKMM_INT_EXTRA_HEADERS) $(gtkmm_files_extra_deprecated_h)

GDKMM_HG_FILES = $(GDKMM_HG_FILES) $(gdkmm_files_deprecated_hg)
GSKMM_HG_FILES = $(GSKMM_HG_FILES) $(gskmm_files_deprecated_hg)
GTKMM_HG_FILES = $(GTKMM_HG_FILES) $(gtkmm_files_deprecated_hg)
ENABLED_DEPRECATED = yes
!endif

GDKMM_INT_GENERATED_HEADERS = $(GDKMM_HG_FILES:.hg=.h)
GDKMM_INT_GENERATED_HEADERS_P = $(GDKMM_HG_FILES:.hg=_p.h)
GDKMM_INT_GENERATED_SOURCES = $(GDKMM_HG_FILES:.hg=.cc) wrap_init.cc
GSKMM_INT_GENERATED_SOURCES = $(GSKMM_HG_FILES:.hg=.cc) wrap_init.cc
GTKMM_INT_GENERATED_SOURCES = $(GTKMM_HG_FILES:.hg=.cc) wrap_init.cc

# Path to glib-compile-resources.exe
!ifndef GLIB_COMPILE_RESOURCES
GLIB_COMPILE_RESOURCES = $(GLIB_BINDIR)\glib-compile-resources.exe
!endif
