Allow pkg-config binary to be overridden with PKG_CONFIG

This is one of the de facto standard interfaces used in Linux
distributions for cross-compilation (alongside overriding CC and
similar variables), and in particular is used in Debian and its
derivatives.

Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2018-06-12 10:53:27 +01:00 committed by Tim Angus
parent 38a2f4d938
commit fb4b206709

View file

@ -282,15 +282,18 @@ bin_path=$(shell which $(1) 2> /dev/null)
# The autoupdater uses curl, so figure out its flags no matter what. # The autoupdater uses curl, so figure out its flags no matter what.
# We won't need this if we only build the server # We won't need this if we only build the server
# set PKG_CONFIG_PATH to influence this, e.g. # set PKG_CONFIG_PATH or PKG_CONFIG to influence this, e.g.
# PKG_CONFIG_PATH=/opt/cross/i386-mingw32msvc/lib/pkgconfig # PKG_CONFIG_PATH=/opt/cross/i386-mingw32msvc/lib/pkgconfig or
ifneq ($(call bin_path, pkg-config),) # PKG_CONFIG=arm-linux-gnueabihf-pkg-config
CURL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libcurl) PKG_CONFIG ?= pkg-config
CURL_LIBS ?= $(shell pkg-config --silence-errors --libs libcurl)
OPENAL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags openal) ifneq ($(call bin_path, $(PKG_CONFIG)),)
OPENAL_LIBS ?= $(shell pkg-config --silence-errors --libs openal) CURL_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags libcurl)
SDL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//') CURL_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs libcurl)
SDL_LIBS ?= $(shell pkg-config --silence-errors --libs sdl2) OPENAL_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags openal)
OPENAL_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs openal)
SDL_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//')
SDL_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs sdl2)
else else
# assume they're in the system default paths (no -I or -L needed) # assume they're in the system default paths (no -I or -L needed)
CURL_LIBS ?= -lcurl CURL_LIBS ?= -lcurl
@ -1061,8 +1064,8 @@ ifeq ($(NEED_OPUS),1)
-I$(OPUSDIR)/include -I$(OPUSDIR)/celt -I$(OPUSDIR)/silk \ -I$(OPUSDIR)/include -I$(OPUSDIR)/celt -I$(OPUSDIR)/silk \
-I$(OPUSDIR)/silk/float -I$(OPUSFILEDIR)/include -I$(OPUSDIR)/silk/float -I$(OPUSFILEDIR)/include
else else
OPUS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags opusfile opus || true) OPUS_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags opusfile opus || true)
OPUS_LIBS ?= $(shell pkg-config --silence-errors --libs opusfile opus || echo -lopusfile -lopus) OPUS_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs opusfile opus || echo -lopusfile -lopus)
endif endif
CLIENT_CFLAGS += $(OPUS_CFLAGS) CLIENT_CFLAGS += $(OPUS_CFLAGS)
CLIENT_LIBS += $(OPUS_LIBS) CLIENT_LIBS += $(OPUS_LIBS)
@ -1074,8 +1077,8 @@ ifeq ($(USE_CODEC_VORBIS),1)
ifeq ($(USE_INTERNAL_VORBIS),1) ifeq ($(USE_INTERNAL_VORBIS),1)
CLIENT_CFLAGS += -I$(VORBISDIR)/include -I$(VORBISDIR)/lib CLIENT_CFLAGS += -I$(VORBISDIR)/include -I$(VORBISDIR)/lib
else else
VORBIS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags vorbisfile vorbis || true) VORBIS_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags vorbisfile vorbis || true)
VORBIS_LIBS ?= $(shell pkg-config --silence-errors --libs vorbisfile vorbis || echo -lvorbisfile -lvorbis) VORBIS_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs vorbisfile vorbis || echo -lvorbisfile -lvorbis)
endif endif
CLIENT_CFLAGS += $(VORBIS_CFLAGS) CLIENT_CFLAGS += $(VORBIS_CFLAGS)
CLIENT_LIBS += $(VORBIS_LIBS) CLIENT_LIBS += $(VORBIS_LIBS)
@ -1086,8 +1089,8 @@ ifeq ($(NEED_OGG),1)
ifeq ($(USE_INTERNAL_OGG),1) ifeq ($(USE_INTERNAL_OGG),1)
OGG_CFLAGS = -I$(OGGDIR)/include OGG_CFLAGS = -I$(OGGDIR)/include
else else
OGG_CFLAGS ?= $(shell pkg-config --silence-errors --cflags ogg || true) OGG_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags ogg || true)
OGG_LIBS ?= $(shell pkg-config --silence-errors --libs ogg || echo -logg) OGG_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs ogg || echo -logg)
endif endif
CLIENT_CFLAGS += $(OGG_CFLAGS) CLIENT_CFLAGS += $(OGG_CFLAGS)
CLIENT_LIBS += $(OGG_LIBS) CLIENT_LIBS += $(OGG_LIBS)
@ -1104,8 +1107,8 @@ endif
ifeq ($(USE_INTERNAL_ZLIB),1) ifeq ($(USE_INTERNAL_ZLIB),1)
ZLIB_CFLAGS = -DNO_GZIP -I$(ZDIR) ZLIB_CFLAGS = -DNO_GZIP -I$(ZDIR)
else else
ZLIB_CFLAGS ?= $(shell pkg-config --silence-errors --cflags zlib || true) ZLIB_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags zlib || true)
ZLIB_LIBS ?= $(shell pkg-config --silence-errors --libs zlib || echo -lz) ZLIB_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs zlib || echo -lz)
endif endif
BASE_CFLAGS += $(ZLIB_CFLAGS) BASE_CFLAGS += $(ZLIB_CFLAGS)
LIBS += $(ZLIB_LIBS) LIBS += $(ZLIB_LIBS)
@ -1116,15 +1119,15 @@ ifeq ($(USE_INTERNAL_JPEG),1)
else else
# IJG libjpeg doesn't have pkg-config, but libjpeg-turbo uses libjpeg.pc; # IJG libjpeg doesn't have pkg-config, but libjpeg-turbo uses libjpeg.pc;
# we fall back to hard-coded answers if libjpeg.pc is unavailable # we fall back to hard-coded answers if libjpeg.pc is unavailable
JPEG_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libjpeg || true) JPEG_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags libjpeg || true)
JPEG_LIBS ?= $(shell pkg-config --silence-errors --libs libjpeg || echo -ljpeg) JPEG_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs libjpeg || echo -ljpeg)
BASE_CFLAGS += $(JPEG_CFLAGS) BASE_CFLAGS += $(JPEG_CFLAGS)
RENDERER_LIBS += $(JPEG_LIBS) RENDERER_LIBS += $(JPEG_LIBS)
endif endif
ifeq ($(USE_FREETYPE),1) ifeq ($(USE_FREETYPE),1)
FREETYPE_CFLAGS ?= $(shell pkg-config --silence-errors --cflags freetype2 || true) FREETYPE_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags freetype2 || true)
FREETYPE_LIBS ?= $(shell pkg-config --silence-errors --libs freetype2 || echo -lfreetype) FREETYPE_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs freetype2 || echo -lfreetype)
BASE_CFLAGS += -DBUILD_FREETYPE $(FREETYPE_CFLAGS) BASE_CFLAGS += -DBUILD_FREETYPE $(FREETYPE_CFLAGS)
RENDERER_LIBS += $(FREETYPE_LIBS) RENDERER_LIBS += $(FREETYPE_LIBS)