mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: Get major number in Makefile
@ 2002-04-02 18:30 Jesse Pollard
  0 siblings, 0 replies; 3+ messages in thread
From: Jesse Pollard @ 2002-04-02 18:30 UTC (permalink / raw)
  To: mylinuxk, linux-kernel

Michael Zhu <mylinuxk@yahoo.ca>:
> 
> Hi, smart gurus, I have a question while writing a
> Makefile file to install my device driver. In my
> device driver I dynamically allocate the major number
> of my device. In my Makefile I want to build a device
> node for my device under the /dev directory.
> 
>    mknod /dev/mydevice c $major 0;
> 
> So I need to know the major number of my deivce in the
> Makefile. I've read the Linux 'Device Driver'. There
> is some information about this. I use the following
> command to get the major number in my Makefile.
> 
> major=`awk "\\$2==\"$mymodule\" {printf \\$1}"
> /proc/devices`
> 
> But when I use the 'make install' command to install
> my driver, the following error returned.
> 
> major=`awk "\\==\"$ymodule\" {printf \\}"
> /proc/devices`
> awk: 0: unexpected character '\'
> awk: line 1: syntax error at or near ==
> make: *** [install] Error 2
> 
> What is wrong with my command? Can anyone tell me how
> to get the major number in Makefile.

1. you want $(mymodule) instead of $mymodule
2. instead of \\$ you want $$
3. you need to use the @ construct.

vcs was the module I looked for.

Don't put quotes around it... that has make passing the quotes too.

End result is something like the following:

mymodule=vcs

target:
        @major=`awk '$$2 == "$(mymodule)" {print $$1}' /proc/devices`
        @echo $$major

Whether or not you really want to do this is something else. 

-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil

Any opinions expressed are solely my own.

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

* Re: Get major number in Makefile
  2002-04-02 15:42 Michael Zhu
@ 2002-04-02 15:54 ` Richard B. Johnson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard B. Johnson @ 2002-04-02 15:54 UTC (permalink / raw)
  To: Michael Zhu; +Cc: linux-kernel

On Tue, 2 Apr 2002, Michael Zhu wrote:

> Hi, smart gurus, I have a question while writing a
> Makefile file to install my device driver. In my
> device driver I dynamically allocate the major number
> of my device. In my Makefile I want to build a device
> node for my device under the /dev directory.
> 
>    mknod /dev/mydevice c $major 0;
> 
> So I need to know the major number of my deivce in the
> Makefile. I've read the Linux 'Device Driver'. There
> is some information about this. I use the following
> command to get the major number in my Makefile.
> 
> major=`awk "\\$2==\"$mymodule\" {printf \\$1}"
> /proc/devices`
> 
> But when I use the 'make install' command to install
> my driver, the following error returned.
> 
> major=`awk "\\==\"$ymodule\" {printf \\}"
> /proc/devices`
> awk: 0: unexpected character '\'
> awk: line 1: syntax error at or near ==
> make: *** [install] Error 2
> 
> What is wrong with my command? Can anyone tell me how
> to get the major number in Makefile.
> 
> Thank you very much.

`make` will interpret '$', you need $$ in the Makefile.
Also, you may not want to 'acquire' major numbers this way. Your
module may work only on the machine that built it.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).

                 Windows-2000/Professional isn't.


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

* Get major number in Makefile
@ 2002-04-02 15:42 Michael Zhu
  2002-04-02 15:54 ` Richard B. Johnson
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Zhu @ 2002-04-02 15:42 UTC (permalink / raw)
  To: linux-kernel

Hi, smart gurus, I have a question while writing a
Makefile file to install my device driver. In my
device driver I dynamically allocate the major number
of my device. In my Makefile I want to build a device
node for my device under the /dev directory.

   mknod /dev/mydevice c $major 0;

So I need to know the major number of my deivce in the
Makefile. I've read the Linux 'Device Driver'. There
is some information about this. I use the following
command to get the major number in my Makefile.

major=`awk "\\$2==\"$mymodule\" {printf \\$1}"
/proc/devices`

But when I use the 'make install' command to install
my driver, the following error returned.

major=`awk "\\==\"$ymodule\" {printf \\}"
/proc/devices`
awk: 0: unexpected character '\'
awk: line 1: syntax error at or near ==
make: *** [install] Error 2

What is wrong with my command? Can anyone tell me how
to get the major number in Makefile.

Thank you very much.


______________________________________________________________________ 
Find, Connect, Date! http://personals.yahoo.ca

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

end of thread, other threads:[~2002-04-02 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-02 18:30 Get major number in Makefile Jesse Pollard
  -- strict thread matches above, loose matches on Subject: below --
2002-04-02 15:42 Michael Zhu
2002-04-02 15:54 ` Richard B. Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®