pkg-config/nmake/Makefile.vc
Chun-wei Fan 5eb56ec08a NMake: Move NMake Makefiles into its own subdir
Makes the $(srcroot) a bit cleaner.  Also don't track the build artfacts
as well as config.h.win32, since it is generated when building a release
tarball.
2023-09-18 11:59:41 +08:00

106 lines
3.2 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"
CFLAGS = $(CFLAGS_ADD) /W3 /Zi /FImsvc_recommended_pragmas.h /I. \
/I.\vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config \
/I$(INCLUDEDIR)\glib-2.0 \
/I$(LIBDIR)\glib-2.0\include
# 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="\"\""
LDFLAGS_BASE = $(LDFLAGS_ARCH) /libpath:$(LIBDIR) /DEBUG
NULL=
!if "$(CFG)" == "debug"
LDFLAGS = $(LDFLAGS_BASE)
!else
LDFLAGS = $(LDFLAGS_BASE) /opt:ref /LTCG
!endif
!include ..\Makefile.sources
# Convert the source (*.c) listing to object (.obj) listing in
# another NMake Makefile module, include it, and clean it up.
!if [echo pkg_config_OBJS = \> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [for %c in ($(pkg_config_SOURCES)) do @if "%~xc" == ".c" echo. vs^$(VSVER)\^$(CFG)\^$(PLAT)\pkg-config\%~nc.obj \>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [echo. ^$(NULL)>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!include objs_vs$(VSVER)_$(PLAT)_$(CFG).mak
!if [del /f /q objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
pkg_config_LIBS = glib-2.0.lib
{..\}.c{vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\}.obj::
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\ md vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\config.h copy config.h.win32 vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\config.h
$(CC) $(pkg_config_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\ /c @<<
$<
<<
all: vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config.exe
vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config.exe: $(pkg_config_OBJS)
link $(LDFLAGS) $(pkg_config_LIBS) -out:$@ @<<
$(pkg_config_OBJS)
<<
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
clean:
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.pdb
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exe.manifest
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exe
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.ilk
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\*.obj
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\vc$(PDBVER).pdb
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\config.h
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config
@-rd vs$(VSVER)\$(CFG)\$(PLAT)
@-rd vs$(VSVER)\$(CFG)
@-rd vs$(VSVER)
!else
all:
@echo You need to specify a valid configuration, via
@echo CFG=release or CFG=debug
!endif