diff mbox

[-next] hid-example: fix some build issues

Message ID 20110418111251.8a922b6b.randy.dunlap@oracle.com
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Randy Dunlap April 18, 2011, 6:12 p.m. UTC
From: Randy Dunlap <randy.dunlap@oracle.com>

samples/hid-example.o needs some Kconfig and Makefile additions
in order to build.  It should use <linux/*.h> headers from
the build tree, so use HEADERS_CHECK to require that those
header files be present.

Change the kconfig symbol from tristate to bool since
userspace cannot be built as loadable modules.

However, I don't understand why the userspace header files are
not present as reported in Andrew's build log, since it builds
OK on x86_64 without any of these changes.

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Alan Ott <alan@signal11.us>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: linux-input@vger.kernel.org
---
 samples/Kconfig         |    4 ++--
 samples/hidraw/Makefile |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

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

Comments

Jiri Kosina April 19, 2011, 8:48 a.m. UTC | #1
[ adding Michal Marek to CC ]

On Mon, 18 Apr 2011, Randy Dunlap wrote:

> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> samples/hid-example.o needs some Kconfig and Makefile additions
> in order to build.  It should use <linux/*.h> headers from
> the build tree, so use HEADERS_CHECK to require that those
> header files be present.
> 
> Change the kconfig symbol from tristate to bool since
> userspace cannot be built as loadable modules.
> 
> However, I don't understand why the userspace header files are
> not present as reported in Andrew's build log, since it builds
> OK on x86_64 without any of these changes.

Yes, I have no idea how the build failure Andrew is reporting happens. 
Andrew -- what exact command are you using that leads to that failure?

Thanks.

> 
> Reported-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
> Cc: Alan Ott <alan@signal11.us>
> Cc: Jiri Kosina <jkosina@suse.cz>
> Cc: linux-input@vger.kernel.org
> ---
>  samples/Kconfig         |    4 ++--
>  samples/hidraw/Makefile |    2 ++
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> --- linux-next-20110418.orig/samples/hidraw/Makefile
> +++ linux-next-20110418/samples/hidraw/Makefile
> @@ -6,3 +6,5 @@ hostprogs-y := hid-example
>  
>  # Tell kbuild to always build the programs
>  always := $(hostprogs-y)
> +
> +HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include
> --- linux-next-20110418.orig/samples/Kconfig
> +++ linux-next-20110418/samples/Kconfig
> @@ -62,8 +62,8 @@ config SAMPLE_KDB
>  	  command to the kdb shell.
>  
>  config SAMPLE_HIDRAW
> -	tristate "Build simple hidraw example"
> -	depends on HIDRAW
> +	bool "Build simple hidraw example"
> +	depends on HIDRAW && HEADERS_CHECK
>  	help
>  	  Build an example of how to use hidraw from userspace.
>  
>
Michal Marek April 19, 2011, 9:13 a.m. UTC | #2
On Tue, Apr 19, 2011 at 10:48:26AM +0200, Jiri Kosina wrote:
> 
> [ adding Michal Marek to CC ]
> 
> On Mon, 18 Apr 2011, Randy Dunlap wrote:
> 
> > From: Randy Dunlap <randy.dunlap@oracle.com>
> > 
> > samples/hid-example.o needs some Kconfig and Makefile additions
> > in order to build.  It should use <linux/*.h> headers from
> > the build tree, so use HEADERS_CHECK to require that those
> > header files be present.
> > 
> > Change the kconfig symbol from tristate to bool since
> > userspace cannot be built as loadable modules.
> > 
> > However, I don't understand why the userspace header files are
> > not present as reported in Andrew's build log, since it builds
> > OK on x86_64 without any of these changes.
> 
> Yes, I have no idea how the build failure Andrew is reporting happens. 
> Andrew -- what exact command are you using that leads to that failure?

I believe Andrew was trying to build samples/hidraw/hid-example.o
directly, which unfortunatelly does not work (kbuild limitation). For
reference, this is the reply I sent privately to Andrew:

| The samples/hidraw/ directory does not appear in the output, I I guess 
| samples/hidraw/hid-example already existed? Back to the original 
| problem, I can reproduce the bug with
| 
| $ make  samples/hidraw/hid-example.o
|    CHK     include/linux/version.h
|    CHK     include/generated/utsrelease.h
|    CALL    scripts/checksyscalls.sh
|    CC      samples/hidraw/hid-example.o
| samples/hidraw/hid-example.c:29:23: fatal error: sys/ioctl.h: No such 
| file or directory
| 
| Because for %.o there is a rule in the toplevel Makefile passes control 
| to scripts/Makefile.build, while you would need scripts/Makefile.host in 
| this case. I don't know how to fix this, when Makefile.build is told to 
| build foo.o, it builds it as kernel code, it doesn't inspect the 
| hostprogs-y variable to see if perhaps foo.o is in the foodchain of some 
| host program. However, 'make  samples/hidraw/' works fine for me. So 
| what command exactly did you use?

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-input" 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

--- linux-next-20110418.orig/samples/hidraw/Makefile
+++ linux-next-20110418/samples/hidraw/Makefile
@@ -6,3 +6,5 @@  hostprogs-y := hid-example
 
 # Tell kbuild to always build the programs
 always := $(hostprogs-y)
+
+HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include
--- linux-next-20110418.orig/samples/Kconfig
+++ linux-next-20110418/samples/Kconfig
@@ -62,8 +62,8 @@  config SAMPLE_KDB
 	  command to the kdb shell.
 
 config SAMPLE_HIDRAW
-	tristate "Build simple hidraw example"
-	depends on HIDRAW
+	bool "Build simple hidraw example"
+	depends on HIDRAW && HEADERS_CHECK
 	help
 	  Build an example of how to use hidraw from userspace.