[lkml]   [2017]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v2] selftests: gpio: fix Makefile
* Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.
Note: if pkg-config is missing (command not found), it will fail to
build because headers can't be found or libmount library can't be

* Fix the clean target to clean up also gpio-utils.

* Fix gpio-mockup-chardev installation by using TEST_PROGS_EXTENDED
instead of BINARIES which is not supported by the top-level

* Get rid of INSTALL_HDR_PATH. We don't need it since make -C is putting
us in the right location.

* Improve readibility:
- introduce GPIODIR/GPIOOBJ/GPIOINC variables
- split CFLAGS on multiple lines

Signed-off-by: Fathi Boudra <>

in v2:
* per Michael Ellerman request, revert to use exported headers instead of uapi.

tools/testing/selftests/gpio/Makefile | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 205e4d10e085..41826897af35 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -1,23 +1,28 @@
+CFLAGS += -O2 -g -std=gnu99 -Wall
+CFLAGS += -I../../../../usr/include/
+CFLAGS += $(shell pkg-config --cflags mount)
+LDLIBS += $(shell pkg-config --libs mount)

-BINARIES := gpio-mockup-chardev
+TEST_PROGS_EXTENDED := gpio-mockup-chardev
+GPIODIR := ../../../gpio
+GPIOOBJ := gpio-utils.o
+GPIOINC := gpio.h

include ../

-all: $(BINARIES)

-CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
-LDLIBS += -lmount -I/usr/include/libmount
-$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
+ $(MAKE) -C $(GPIODIR) clean

- make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio

- make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/

+ $(MAKE) -C ../../../.. headers_install
 \ /
  Last update: 2017-03-28 07:38    [W:0.038 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site