help-make
[Top][All Lists]
Advanced

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

Re: Internal make command Macro to identify linux/os distribution.


From: Gautam Shejwalkar
Subject: Re: Internal make command Macro to identify linux/os distribution.
Date: Tue, 9 Sep 2008 16:18:00 +0530

Hi Dave,

Thank you for your quick reply.

Yes, I was referring to the distro. Actually based on the distro I want to decide which rpm package needs to be installed. B'coz only in uname -r we get the information on the distro. I am not sure if there are any other commands available for checking the distro type.
Any way the solution which you have mentioned is a good one.

Regards,
-SG

On Tue, Sep 9, 2008 at 3:59 PM, Dave Korn <address@hidden> wrote:
Gautam Shejwalkar wrote on 09 September 2008 08:52:

> Hi,
>
> Is there any internal command or macro available to identify on which
> Linux distribution the make is running. I know one way of finding is to
> run 'unake -r' and then compare it with the know string. But if there is
> any better way or solution which make provides it will great.

 Nah, there's nothing built in.  A lot of makefiles don't even care what
system they're running on; in the GNU world, configure scripts (specifically
config.guess) work it out and define variables on the make command-line
appropriately; and make is cross-system, so can't assume it's even running on
Linux at all.

 (BTW, you said 'distribution', which means Red hat or Ubuntu or Debian or
whatever, but "uname -r" tells you which kernel version you're running.  I
assume you really mean kernel version rather than distro, so you can take care
of kernel build system and internal ABI differences.)

 So just go ahead and take the simple solution: at the start of your makefile

KERNELVERSION:=$(shell uname -r)

and then use make's string match functions to check what you need to know.
Note that it's important to use ':=' instead of just plain '=' otherwise make
launches a fresh shell and re-runs the uname command every time you refer to
$(KERNELVERSION)!



   cheers,
     DaveK
--
Can't think of a witty .sigline today....



reply via email to

[Prev in Thread] Current Thread [Next in Thread]