Skip to content

Commit 4a7eca8

Browse files
committed
build: don't hard-code pkg-config
1 parent 8611241 commit 4a7eca8

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

projects/unix/Makefile

+13-10
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ ifeq ($(OS), OSX)
137137
endif
138138
endif
139139

140+
# test for essential build dependencies
141+
ifeq ($(origin PKG_CONFIG), undefined)
142+
PKG_CONFIG = $(CROSS_COMPILE)pkg-config
143+
ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),)
144+
$(error $(PKG_CONFIG) not found)
145+
endif
146+
endif
147+
140148
ifeq ($(OS), LINUX)
141149
HIDAPI_NAME=hidapi-hidraw
142150
else
@@ -145,18 +153,13 @@ endif
145153

146154
# test for presence of HIDLIB
147155
ifeq ($(origin HID_CFLAGS) $(origin HID_LDLIBS), undefined undefined)
148-
HIDAPI_CONFIG = $(CROSS_COMPILE)pkg-config $(HIDAPI_NAME)
149-
ifeq ($(shell which $(HIDAPI_CONFIG) 2>/dev/null),)
150-
HIDAPI_CONFIG = $(CROSS_COMPILE)pkg-config $(HIDAPI_NAME)
151-
ifeq ($(shell which $(HIDAPI_CONFIG) 2>/dev/null),)
152-
$(error No HIDAPI development libraries found!)
153-
else
154-
$(warning Using HIDAPI libraries)
155-
endif
156+
ifeq ($(shell $(PKG_CONFIG) --modversion $(HIDAPI_NAME) 2>/dev/null),)
157+
$(error No hidapi development libraries found!)
156158
endif
157-
HID_CFLAGS += $(shell $(HIDAPI_CONFIG) --cflags)
158-
HID_LDLIBS += $(shell $(HIDAPI_CONFIG) --libs)
159+
HID_CFLAGS = $(shell $(PKG_CONFIG) --cflags $(HIDAPI_NAME))
160+
HID_LDLIBS = $(shell $(PKG_CONFIG) --libs $(HIDAPI_NAME))
159161
endif
162+
160163
CFLAGS += $(HID_CFLAGS)
161164
LDLIBS += $(HID_LDLIBS)
162165

0 commit comments

Comments
 (0)