[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: "shell" in Makefile



On Sun, Jun 24, 2007 at 09:40:40AM -0700, Easthope wrote:
> Debian users,
> 
> In 
> 
> http://git.kernel.org/?p=linux/kernel/git/linville/wireless-dev.git;a=
> summary
> 
> Vivek described a makefile containing this text.
> 
> obj-m := hello.o
> KDIR := /lib/modules/$(shell uname -r)/build
> PWD := $(shell pwd)
> default:
>     $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
> 
> shell is not a command in the Etch here.

It is not a command in etch. But it is in GNU Make:
    http://www.gnu.org/software/make/manual/html_node/Shell-Function.html#Shell-Function

> So what is "shell uname -r" and "shell pwd"?

That's the way to get the output a command into a Make variable.

> Why not just $(uname -r) and $(pwd)?

It would be in bash - where $( somecommand ) is replaced by the output 
of somecommand.

Make uses the syntax of $(variablename) to reference the value of a 
variable - and $(functionname params) to call functions - one of which 
is 'shell', which calls an external (to make) command.

Hope this helps

-- 
Karl E. Jorgensen
karl@jorgensen.org.uk  http://www.jorgensen.org.uk/
karl@jorgensen.com     http://karl.jorgensen.com
==== Today's fortune:
Lady Nancy Astor:
	"Winston, if you were my husband, I'd put poison in your coffee."
Winston Churchill:
	"Nancy, if you were my wife, I'd drink it."

Attachment: signature.asc
Description: Digital signature


Reply to: