All of lore.kernel.org
 help / color / mirror / Atom feed
* KBuild puts client progam output in upper level directory
@ 2014-02-17 20:45 Eric Fowler
  0 siblings, 0 replies; only message in thread
From: Eric Fowler @ 2014-02-17 20:45 UTC (permalink / raw)
  To: kernelnewbies

I have a simple project that includes one driver and one client
program to test the driver.

I have two directories under linux/drivers/myproject, mydriver/, and
myclient/, respectively. Each has a Makefile. The Makefile for the
driver functions just fine, and produces the driver in the same
directory as the makefile. The syntax here is as follows:

#DRIVER MAKEFILE
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := mydriver.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif


When this is invoked with:
make  -C ~/linux-cortexm-1.12.0/linux/ M=`pwd`

It produces what I want, a mydriver.ko file in the same directory.

But when I try to build the client in it's own directory (from
myclient.c alone), I get a client executable two directories up, in
./linux .

Here is that Makefile:
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
host-progs := myclient
build-targets := $(host-prog)

# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) myclient
endif


I am puzzled about what KBuild is doing, and why it is doing it.

Eric


-- 
cc:NSA

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-17 20:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-17 20:45 KBuild puts client progam output in upper level directory Eric Fowler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.