Skip to contentSkip to conversation

tools: gpio: add kernel headers in CFLAGS

PATCH In review Bamvor Jian Zhang 2 participants 2 messages Feb 26, 2016 – Mar 7, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: gpio: add kernel headers in CFLAGS

From: Bamvor Jian Zhang <[email protected]>

Gpio tools require linux/gpio.h which may be only exist in kernel source code in a cross compile environment.

Add such header to CFLAGS to avoid compiling failure.

---
 tools/gpio/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/gpio/Makefile +7 -1
index 4d198d5..6b8804f 100644
@@ -1,5 +1,11 @@
+ifneq ($(INSTALL_HDR_PATH),)
+KERNEL_HEADERS := $(INSTALL_HDR_PATH)/include
+else
+KERNEL_HEADERS ?= $(abspath ../../usr/include)
+endif
+
 CC = $(CROSS_COMPILE)gcc
-CFLAGS += -Wall -g -D_GNU_SOURCE
+CFLAGS += -Wall -g -D_GNU_SOURCE -I $(KERNEL_HEADERS)
 
 all: lsgpio
 
Signature · 1 line
2.6.2
#1 lore raw
Quoted 8 lines · Bamvor Jian Zhang

From: Bamvor Jian Zhang <[email protected]>

Gpio tools require linux/gpio.h which may be only exist in kernel source code in a cross compile environment.

Add such header to CFLAGS to avoid compiling failure.

I already got a patch like this and NACKed it: the procedure to compile userspace tools is:

make -C ${LINUX_TREE} headers_install ARCH=<arch> INSTALL_HDR_PATH=<bar> cd tools/gpio
make CFLAGS="${CFLAGS} -I<bar>"

So you push the new locations of your fresh kernel headers to the front of the include path. But make headers_install is mandatory before trying to compile userspace, as uapi may differ between architectures.

Yours,
Linus Walleij