pkg-config/nmake/Makefile.vc
Chun-wei Fan df33829d62 NMake: Add support to build pkg-config without existing GLib
This adds support to the NMake Makefiles to build the bundled GLib 2.38.2
sources for use with building pkg-config with Visual Studio, which is now
the default build variant.  Building against a pre-installed GLib installation
is now supported via passing in HAVE_GLIB=1 in the NMake command line.

Notice that gettext-runtime (intl.lib, the one provided by proxy-libintl also
works) is required for the build with the bundled GLib to work, and as in a
previous commit, this will build the bundled GLib as a DLL, which must also
be distributed with pkg-config.exe for things to run, with the gettext-runtime
or proxy-libintl DLL as well.
2023-09-19 16:16:21 +08:00

99 lines
2.5 KiB
Text

# Note: This does assume an existing GLib installation!
# Visual Studio builds of GLib does not need an existing pkg-config
# installation, so build GLib first before using this.
# Set these if necessary. 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 $(INCLUDEDIR)\glib-2.0 and $(LIBDIR)\glib-2.0\include
# and its import library will be found in $(LIBDIR).
!ifndef GLIB_PREFIX
GLIB_PREFIX = ..\vs$(VSVER)\$(PLAT)
!endif
!ifndef INCLUDEDIR
INCLUDEDIR = $(GLIB_PREFIX)\include
!endif
!ifndef LIBDIR
LIBDIR = $(GLIB_PREFIX)\lib
!endif
# The items below this line should not be changed, unless one is maintaining
# the NMake Makefiles.
!include detectenv-msvc.mak
!if "$(VALID_CFGSET)" == "TRUE"
INCLUDES_GLIB = \
/I..\glib\glib /I..\glib \
/I.\vs$(VSVER)\$(CFG)\$(PLAT)\glib\glib /I.\vs$(VSVER)\$(CFG)\$(PLAT)\glib \
/I.\dirent
INCLUDES_PKGCONFIG = /I. /I.\vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config
CFLAGS = $(CFLAGS_ADD) /W3 /Zi
!ifdef HAVE_GLIB
CFLAGS = $(CFLAGS) /FImsvc_recommended_pragmas.h
INCLUDES_PKGCONFIG = \
$(INCLUDES_PKGCONFIG) \
/I$(INCLUDEDIR)\glib-2.0 \
/I$(LIBDIR)\glib-2.0\include
!else
CFLAGS = $(CFLAGS) /D_CRT_SECURE_NO_WARNIGS /D_CRT_NONSTDC_NO_WARNINGS /wd4244
INCLUDES_PKGCONFIG = $(INCLUDES_PKGCONFIG) $(INCLUDES_GLIB)
!endif
# PKG_CONFIG_SYSTEM_INCLUDE_PATH and PKG_CONFIG_SYSTEM_LIBRARY_PATH only
# work for GCC builds for now, so just set this to nothing for now
pkg_config_CFLAGS = \
$(CFLAGS) \
/DHAVE_CONFIG_H \
/DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"\"" \
/DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"\""
glib_CFLAGS = \
$(CFLAGS) \
/DHAVE_CONFIG_H \
/DG_LOG_DOMAIN=\"GLib\" \
/DGLIB_COMPILATION \
/DGLIB_DISABLE_DEPRECATIONS \
/DDLL_EXPORT \
/DPCRE_STATIC
LDFLAGS_BASE = $(LDFLAGS_ARCH) /libpath:$(LIBDIR) /DEBUG
NULL=
!if "$(CFG)" == "debug"
LDFLAGS = $(LDFLAGS_BASE)
ARFLAGS = $(LDFLAGS)
!else
LDFLAGS = $(LDFLAGS_BASE) /opt:ref /LTCG
ARFLAGS = $(LDFLAGS_BASE) /LTCG
!endif
!include ..\Makefile.sources
!include create-lists-msvc.mak
pkg_config_build_deps =
!ifdef HAVE_GLIB
pkg_config_LIBS = glib-2.0.lib
!else
pkg_config_build_deps = vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config-glib.lib
pkg_config_LIBS = $(pkg_config_build_deps)
glib_dep_libs = intl.lib winmm.lib ws2_32.lib ole32.lib advapi32.lib shell32.lib user32.lib
!endif
all: vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config.exe
!include build-rules-msvc.mak
!else
all:
@echo You need to specify a valid configuration, via
@echo CFG=release or CFG=debug
!endif