# NMake Makefile portion for enabling features for Windows builds

# Please do not change anything beneath this line unless maintaining the NMake Makefiles

CAIROMM_MAJOR_VERSION = 1
CAIROMM_MINOR_VERSION = 16

LIBSIGC_MAJOR_VERSION = 3
LIBSIGC_MINOR_VERSION = 0

# These are the base minimum libraries required for building cairomm.

DEPS_MKFILE = deps-vs$(VSVER)-$(PLAT)-$(CFG).mak
BUILD_MKFILE = cairomm-vs$(VSVER)-$(PLAT)-$(CFG).mak
!ifndef BASE_INCLUDEDIR
BASE_INCLUDEDIR = $(PREFIX)\include
!endif
!ifndef BASE_LIBDIR
BASE_LIBDIR = $(PREFIX)\lib
!endif
SIGC_SERIES = $(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)
GLIB_SERIES = 2.0

# Gather up dependencies for their include directories and lib/bin dirs.
!if [for %t in (SIGC CAIRO FREETYPE FC GLIB BOOST) do @(echo !ifndef %t_INCLUDEDIR>>$(DEPS_MKFILE) & echo %t_INCLUDEDIR=^$^(BASE_INCLUDEDIR^)>>$(DEPS_MKFILE) & echo !endif>>$(DEPS_MKFILE))]
!endif
!if [for %t in (SIGC CAIRO FREETYPE FC GLIB BOOST) do @(echo !ifndef %t_LIBDIR>>$(DEPS_MKFILE) & echo %t_LIBDIR=^$^(BASE_LIBDIR^)>>$(DEPS_MKFILE) & echo !endif>>$(DEPS_MKFILE))]
!endif

!include $(DEPS_MKFILE)

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

# Set up include paths
# libsigc++
BASE_INCLUDES =	/I.. /I.\cairomm
DEPS_INCLUDES = /I$(BASE_INCLUDEDIR) /I$(PREFIX)\include

DEPS_INCLUDES = /I$(SIGC_INCLUDEDIR)\sigc++-$(SIGC_SERIES) /I$(SIGC_LIBDIR)\sigc++-$(SIGC_SERIES)\include $(DEPS_INCLUDES)

# FontConfig/FreeType
!if "$(FC_INCLUDEDIR)" != "$(BASE_INCLUDEDIR)"
DEPS_INCLUDES = /I$(FC_INCLUDEDIR) $(DEPS_INCLUDES)
!endif
DEPS_INCLUDES = /I$(FREETYPE_INCLUDEDIR)\freetype2 $(DEPS_INCLUDES)
!if "$(FREETYPE_INCLUDEDIR)" != "$(BASE_INCLUDEDIR)"
DEPS_INCLUDES = /I$(FREETYPE_INCLUDEDIR) $(DEPS_INCLUDES)
!endif

# GLib/GObject
DEPS_INCLUDES = /I$(GLIB_INCLUDEDIR)\glib-$(GLIB_SERIES) /I$(GLIB_LIBDIR)\glib-$(GLIB_SERIES)\include $(DEPS_INCLUDES)

# Cairo
DEPS_INCLUDES = /I$(CAIRO_INCLUDEDIR)\cairo $(DEPS_INCLUDES)
!if "$(CAIRO_INCLUDEDIR)" != "$(BASE_INCLUDEDIR)"
DEPS_INCLUDES = /I$(CAIRO_INCLUDEDIR) $(DEPS_INCLUDES)
!endif

!if "$(CFG)" == "debug" || "$(CFG)" == "Debug"
DEBUG_SUFFIX = -d
!else
DEBUG_SUFFIX =
!endif

# 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

CAIROMM_BASE_CFLAGS =			\
	/D_CRT_SECURE_NO_WARNINGS	\
	/D_CRT_NONSTDC_NO_WARNINGS	\
	/D_USE_MATH_DEFINES		\
	/EHsc /utf-8	\
	/std:c++17

CAIROMM_INCLUDES =	\
	$(BASE_INCLUDES)	\
	$(DEPS_INCLUDES)

LIBCAIROMM_CFLAGS = /DCAIROMM_BUILD $(CAIROMM_BASE_CFLAGS) $(CAIROMM_INCLUDES)
CAIROMM_EX_CFLAGS = $(CAIROMM_BASE_CFLAGS) $(CAIROMM_INCLUDES)
CAIROMM_TEST_CFLAGS =	\
	$(CAIROMM_EX_CFLAGS)	\
	/DBOOST_TEST_MODULE=$(<B:test-=)	\
	/DPNG_STREAM_FILE=\"$(MAKEDIR:\=/)/../tests/png-stream-test.png\"	\
	/std:c++latest	\
	/I$(BOOST_INCLUDEDIR)

CAIROMM_INT_SOURCES = $(cairomm_cc:/=\)
CAIROMM_INT_HDRS = $(cairomm_public_h:/=\)

# We build cairomm-vc$(VSVER_LIB)-$(CAIROMM_MAJOR_VERSION)_$(CAIROMM_MINOR_VERSION).dll or
#          cairomm-vc$(VSVER_LIB)-d-$(CAIROMM_MAJOR_VERSION)_$(CAIROMM_MINOR_VERSION).dll at least

!if $(VSVER) > 14 && "$(USE_COMPAT_LIBS)" != ""
VSVER_LIB = 150
MESON_VSVER_LIB =
!else
VSVER_LIB = $(PDBVER)$(VSVER_SUFFIX)
MESON_VSVER_LIB = -vc$(VSVER_LIB)
!endif

!ifdef USE_MESON_LIBS
LIBSIGC_LIBNAME = sigc-$(SIGC_SERIES)
CAIROMM_LIBNAME = cairomm$(MESON_VSVER_LIB)-$(CAIROMM_MAJOR_VERSION).$(CAIROMM_MINOR_VERSION)

CAIROMM_DLLNAME = $(CAIROMM_LIBNAME)-1
!else
LIBSIGC_LIBNAME = sigc-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBSIGC_MAJOR_VERSION)_$(LIBSIGC_MINOR_VERSION)
CAIROMM_LIBNAME = cairomm-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(CAIROMM_MAJOR_VERSION)_$(CAIROMM_MINOR_VERSION)

CAIROMM_DLLNAME = $(CAIROMM_LIBNAME)
!endif

LIBSIGC_LIB = $(LIBSIGC_LIBNAME).lib

CAIROMM_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\$(CAIROMM_DLLNAME).dll
CAIROMM_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\$(CAIROMM_LIBNAME).lib

CAIRO_LIB = cairo.lib

!ifdef BOOST_DLL
CAIROMM_TEST_CFLAGS = $(CAIROMM_TEST_CFLAGS) /DBOOST_ALL_DYN_LINK
!endif

# Setup dependency linker flags
# libsigc++
DEPS_LDFLAGS = /libpath:$(BASE_LIBDIR)

DEPS_LDFLAGS = $(LIBSIGC_LIB) $(DEPS_LDFLAGS)
!if "$(SIGC_LIBDIR)" != "$(BASE_LIBDIR)"
DEPS_LDFLAGS = /libpath:$(SIGC_LIBDIR) $(DEPS_LDFLAGS)
!endif

# Cairo
DEPS_LDFLAGS = $(CAIRO_LIB) $(DEPS_LDFLAGS)
!if "$(CAIRO_LIBDIR)" != "$(BASE_LIBDIR)"
DEPS_LDFLAGS = /libpath:$(CAIRO_LIBDIR) $(DEPS_LDFLAGS)
!endif

# Boost (for tests)
BOOST_TESTS_LDFLAGS = $(DEPS_LDFLAGS)
!if "$(BOOST_LIBDIR)" != "$(BASE_LIBDIR)"
BOOST_TESTS_LDFLAGS = /libpath:$(BOOST_LIBDIR) $(BOOST_TESTS_LDFLAGS)
!endif

