From: hacklu on

I don't understand the macro KBUILD_MODNAME .
when I compile a driver program. It returns me "linux/pci.h:655: error: 'KBUILD_MODNAME' undeclared (first use in this function) "

In the makefile I had used the "-D" options




thanks a lot

2010-08-03



hacklu

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Boaz Harrosh on
On 08/03/2010 10:11 AM, hacklu wrote:
>
> I don't understand the macro KBUILD_MODNAME .
> when I compile a driver program. It returns me "linux/pci.h:655: error: 'KBUILD_MODNAME' undeclared (first use in this function) "
>
> In the makefile I had used the "-D" options
>
> thanks a lot
>
> 2010-08-03
>
> hacklu
>

The KBUILD_MODNAME fails to be set when there are two drivers built from the same
directory. There are many directories in the source tree with more then one driver
but they don't use the pr_debug macro.

Cheers
Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Boaz Harrosh on
On 08/03/2010 12:52 PM, Boaz Harrosh wrote:
> On 08/03/2010 10:11 AM, hacklu wrote:
>>
>> I don't understand the macro KBUILD_MODNAME .
>> when I compile a driver program. It returns me "linux/pci.h:655: error: 'KBUILD_MODNAME' undeclared (first use in this function) "
>>
>> In the makefile I had used the "-D" options
>>
>> thanks a lot
>>
>> 2010-08-03
>>
>> hacklu
>>
>
> The KBUILD_MODNAME fails to be set when there are two drivers built from the same
> directory. There are many directories in the source tree with more then one driver
> but they don't use the pr_debug macro.
>
> Cheers
> Boaz

Rrr it was a long time since I fought this. Maybe it's not the problem with two
drivers in same dir, maybe it's when two drivers share the same foo.c file.

Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Sam Ravnborg on
On Tue, Aug 03, 2010 at 05:35:40PM +0800, hacklu wrote:
>
> I am compiling the boardcom's driver now.
> the driver had defined EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
> in the a.makefile.
> and the a.makefile was included by b.makefile.
> when in the b.makefile,
> there is this command.
> $(CC) $(DEPS_OPT) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $< ;)
>
> I had add "echo $(EXTRA_CFLAGS)" before this line;but returns NULL;
>
> so I suspicion the $(EXTRA_CFLAGS) hasn't been work.
>
> I aslo try to add "export EXTRA_CFLAGS" in a.makefile,but it doesn't work either.
>
> the problem has puzzled me for some days.
>
> help me please~~


It looks like the driver uses the old 2.4 way to define a Makefile.
This will not work with 2.6.

What you need to do is to define a Makefile (*) like you would
if the driver was included in the kernel and then build
it using the following command:

make -C path/to/kernel/ M=`pwd`

The kernel shall be built before you do this as the method uses
information from the buitl kernel.

(*) The Makefile may not refer to new CONFIG_ symbols.
So it likely looks like this:

obj-m := foo.o bar.o

Do not be suprised that the Makefile becomes much much simpler - this is expected.

Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Américo Wang on
On Tue, Aug 03, 2010 at 05:35:40PM +0800, hacklu wrote:
>
>I am compiling the boardcom's driver now.
>the driver had defined EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
>in the a.makefile.
>and the a.makefile was included by b.makefile.
>when in the b.makefile,
>there is this command.
> $(CC) $(DEPS_OPT) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $< ;)
>
>I had add "echo $(EXTRA_CFLAGS)" before this line;but returns NULL;
>
>so I suspicion the $(EXTRA_CFLAGS) hasn't been work.
>


You don't need to write this line by yourself, you just
need to provide a correct: obj-$(XXXXX) += your_module.o,
kbuild will automatically compile it with proper flags.
(If not, try CFLAGS_MODULE.)

If you insist to do this, I think you can just append
-D"KBUILD_MODNAME=your_module" to that line by hand.

Hope this helps.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
 |  Next  |  Last
Pages: 1 2
Prev: [git pull] spi tree
Next: New EPOLL flag: EPOLLHEAD