diff mbox

tools: gpio: add kernel headers in CFLAGS

Message ID 1456495590-7610-1-git-send-email-bamv2005@gmail.com
State New
Headers show

Commit Message

Bamvor Zhang Feb. 26, 2016, 2:06 p.m. UTC
From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>


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.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

---
 tools/gpio/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Linus Walleij March 7, 2016, 5:01 a.m. UTC | #1
On Fri, Feb 26, 2016 at 9:06 PM, Bamvor Jian Zhang <bamv2005@gmail.com> wrote:

> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

>

> 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.

>

> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>


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
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tools/gpio/Makefile b/tools/gpio/Makefile
index 4d198d5..6b8804f 100644
--- a/tools/gpio/Makefile
+++ b/tools/gpio/Makefile
@@ -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