linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Makefile for kernel modules
@ 2010-10-02 17:20 Dragoslav Zaric
  2010-10-02 17:53 ` Davidlohr Bueso
  2010-10-04  2:32 ` Américo Wang
  0 siblings, 2 replies; 3+ messages in thread
From: Dragoslav Zaric @ 2010-10-02 17:20 UTC (permalink / raw)
  To: linux-kernel

Dear all,

I have a question about kernel modules compilation. I understand the
way how make/Makefile works,
for example if I have two source files, hexdump3.asm and textlib.asm,
my Makefile will look like this:
---------------------------------------------------------------------------
hexdump3: hexdump3.o
	ld -o hexdump3 hexdump3.o textlib.o
hexdump3.o: hexdump3.asm
	nasm -f elf -g -F stabs hexdump3.asm
textlib.o: textlib.asm
	nasm -f elf -g -F stabs textlib.asm
---------------------------------------------------------------------------
and I understand how this works, it goes bottom up, building dependencies first.

But if I have two kernel modules source files, for example, start.c
and stop.c, my Makefile will look like this:
---------------------------------------------------------------------------
obj-m += startstop.o
startstop-objs := start.o stop.o

all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
---------------------------------------------------------------------------
But this does not work on my machine, it runs without errors but does
not produce startstop.ko file.
Also, when I run make on my machine, first line that appears is:
---------------------------------------------------------------------------
make -C /lib/modules/2.6.33.7-rt29/build
M=/home/maiev/work/modules/parts modules
---------------------------------------------------------------------------

So, does anybody know what are lines for manual kernel module
compilation using probably gcc,
without 'obj-m +=' or at least how Makefile should look for multiple
kernel module source files ???

Kind regards

--
Dragoslav Zaric

Professional Programmer
MSc Astrophysics

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Makefile for kernel modules
  2010-10-02 17:20 Makefile for kernel modules Dragoslav Zaric
@ 2010-10-02 17:53 ` Davidlohr Bueso
  2010-10-04  2:32 ` Américo Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Davidlohr Bueso @ 2010-10-02 17:53 UTC (permalink / raw)
  To: Dragoslav Zaric; +Cc: linux-kernel

On Sat, 2010-10-02 at 21:20 +0400, Dragoslav Zaric wrote:
> Dear all,
> 
> I have a question about kernel modules compilation. I understand the
> way how make/Makefile works,
> for example if I have two source files, hexdump3.asm and textlib.asm,
> my Makefile will look like this:
> ---------------------------------------------------------------------------
> hexdump3: hexdump3.o
> 	ld -o hexdump3 hexdump3.o textlib.o
> hexdump3.o: hexdump3.asm
> 	nasm -f elf -g -F stabs hexdump3.asm
> textlib.o: textlib.asm
> 	nasm -f elf -g -F stabs textlib.asm
> ---------------------------------------------------------------------------
> and I understand how this works, it goes bottom up, building dependencies first.
> 
> But if I have two kernel modules source files, for example, start.c
> and stop.c, my Makefile will look like this:
> ---------------------------------------------------------------------------
> obj-m += startstop.o
> startstop-objs := start.o stop.o
> 
> all:
> 	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
> clean:
> 	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
> ---------------------------------------------------------------------------
> But this does not work on my machine, it runs without errors but does
> not produce startstop.ko file.
> Also, when I run make on my machine, first line that appears is:
> ---------------------------------------------------------------------------
> make -C /lib/modules/2.6.33.7-rt29/build
> M=/home/maiev/work/modules/parts modules
> ---------------------------------------------------------------------------
> 
> So, does anybody know what are lines for manual kernel module
> compilation using probably gcc,
> without 'obj-m +=' or at least how Makefile should look for multiple
> kernel module source files ???

This is covered, among many other resources, in LDD3, chapter 2:
http://lwn.net/images/pdf/LDD3/ch02.pdf

For these kind of questions you might want to email the kernelnewbies
ML, instead of LKML, which is basically for the development of the
kernel.

- Davidlohr



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Makefile for kernel modules
  2010-10-02 17:20 Makefile for kernel modules Dragoslav Zaric
  2010-10-02 17:53 ` Davidlohr Bueso
@ 2010-10-04  2:32 ` Américo Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Américo Wang @ 2010-10-04  2:32 UTC (permalink / raw)
  To: Dragoslav Zaric; +Cc: linux-kernel

On Sat, Oct 02, 2010 at 09:20:16PM +0400, Dragoslav Zaric wrote:
...
>
>But if I have two kernel modules source files, for example, start.c
>and stop.c, my Makefile will look like this:
>---------------------------------------------------------------------------
>obj-m += startstop.o
>startstop-objs := start.o stop.o

startstop-objs should be startstop-y

>
>all:
>	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
>clean:
>	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
>---------------------------------------------------------------------------
>But this does not work on my machine, it runs without errors but does
>not produce startstop.ko file.
>Also, when I run make on my machine, first line that appears is:
>---------------------------------------------------------------------------
>make -C /lib/modules/2.6.33.7-rt29/build
>M=/home/maiev/work/modules/parts modules
>---------------------------------------------------------------------------
>
>So, does anybody know what are lines for manual kernel module
>compilation using probably gcc,
>without 'obj-m +=' or at least how Makefile should look for multiple
>kernel module source files ???
>

Please read Documentation/kbuild/modules.txt.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-04  2:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-02 17:20 Makefile for kernel modules Dragoslav Zaric
2010-10-02 17:53 ` Davidlohr Bueso
2010-10-04  2:32 ` Américo Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).