linux: Accept user-provided pkg-config command

When cross-building, it's necessary to use versions of the various
toolchain commands that have been built specifically to target the
desired architecture, and that are named accordingly.

In practice, the make invocation will look something like

  $ make CC=aarch64-linux-gnu-gcc \
         PKG_CONFIG=aarch64-linux-gnu-pkg-config

However, whereas $(CC) is a built-in make variable and so it
behaves correctly out of the box, for $(PKG_CONFIG) we have to do
some work ourselves.
This commit is contained in:
Helmut Grohne 2019-05-12 19:59:22 +02:00 committed by LordReg
parent f0584c7fdd
commit ceaf8699f8

View file

@ -6,6 +6,7 @@ DATAROOTDIR ?= $(PREFIX)/share
MANDIR ?= $(DATAROOTDIR)/man
DOCDIR ?= $(DATAROOTDIR)/doc/spectrwm
XSESSIONSDIR ?= $(DATAROOTDIR)/xsessions
PKG_CONFIG ?= pkg-config
BUILDVERSION = $(shell sh $(CURDIR)/../buildver.sh)
LIBVERSION = $(shell . $(CURDIR)/../lib/shlib_version; echo $$major.$$minor)
@ -21,12 +22,12 @@ endif
BIN_CFLAGS = -fPIE
BIN_LDFLAGS = -fPIE -pie
BIN_CPPFLAGS = $(shell pkg-config --cflags x11 x11-xcb xcb-icccm xcb-keysyms xcb-randr xcb-util xcb-xinput xcb-xtest xcursor xft)
BIN_LDLIBS = $(shell pkg-config --libs x11 x11-xcb xcb-icccm xcb-keysyms xcb-randr xcb-util xcb-xinput xcb-xtest xcursor xft)
BIN_CPPFLAGS = $(shell $(PKG_CONFIG) --cflags x11 x11-xcb xcb-icccm xcb-keysyms xcb-randr xcb-util xcb-xinput xcb-xtest xcursor xft)
BIN_LDLIBS = $(shell $(PKG_CONFIG) --libs x11 x11-xcb xcb-icccm xcb-keysyms xcb-randr xcb-util xcb-xinput xcb-xtest xcursor xft)
LIB_CFLAGS = -fPIC
LIB_LDFLAGS = -fPIC -shared
LIB_CPPFLAGS = $(shell pkg-config --cflags x11)
LIB_LDLIBS = $(shell pkg-config --libs x11) -ldl
LIB_CPPFLAGS = $(shell $(PKG_CONFIG) --cflags x11)
LIB_LDLIBS = $(shell $(PKG_CONFIG) --libs x11) -ldl
all: spectrwm libswmhack.so.$(LIBVERSION)