From d7eedd0c01efbb24b315cf99b19cc248c57a0671 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sat, 7 Sep 2019 17:30:21 +0000 Subject: [PATCH] Use target specific pkg-config wrapper if available --- Makefile | 4 ++-- common.mk | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b8628f6..5910dca 100644 --- a/Makefile +++ b/Makefile @@ -38,13 +38,13 @@ $(BUILD_DIR)/neatvnc.pc: BENCH_DIR = $(BUILD_DIR)/bench $(BENCH_DIR)/%.o: bench/%.c | $(BENCH_DIR) - $(CC_OBJ) $(shell pkg-config --cflags libpng) + $(CC_OBJ) $(shell $(PKGCONFIG) --cflags libpng) $(BENCH_DIR): ; mkdir -p $@ $(BENCH_DIR)/zrle-bench: $(BENCH_DIR)/zrle-bench: $(OBJECTS) $(BUILD_DIR)/pngfb.o \ $(BENCH_DIR)/zrle-bench.o - $(LINK_EXE) $(shell pkg-config --libs libpng) + $(LINK_EXE) $(shell $(PKGCONFIG) --libs libpng) .PHONY: install install: $(DSO) $(BUILD_DIR)/neatvnc.pc diff --git a/common.mk b/common.mk index e611cb7..73d965f 100644 --- a/common.mk +++ b/common.mk @@ -18,6 +18,12 @@ else STRIP := $(MACHINE)-strip endif +ifeq (, $(shell which $(MACHINE)-pkg-config 2>/dev/null)) + PKGCONFIG ?= pkg-config +else + PKGCONFIG ?= $(MACHINE)-pkg-config +endif + CFLAGS ?= -g -O3 $(ARCH_CFLAGS) -flto -DNDEBUG LDFLAGS ?= -flto @@ -27,8 +33,8 @@ CC_OBJ = $(CC) -c $(CFLAGS) $< -o $@ -MMD -MP -MF $(@:.o=.deps) LINK_EXE = $(CC) $^ $(LDFLAGS) -o $@ LINK_DSO = $(CC) -fPIC -shared $^ $(LDFLAGS) -o $@ -CFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell pkg-config --cflags $(dep))) -LDFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell pkg-config --libs $(dep))) +CFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell $(PKGCONFIG) --cflags $(dep))) +LDFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell $(PKGCONFIG) --libs $(dep))) OBJECTS := $(SOURCES:src/%.c=$(BUILD_DIR)/%.o) $(BUILD_DIR): ; mkdir -p $(BUILD_DIR)