help-make
[Top][All Lists]
Advanced

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

Re: Newbie question - testing for OS. . .


From: Martin Sebor
Subject: Re: Newbie question - testing for OS. . .
Date: Tue, 19 Dec 2006 20:52:19 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915

Ken Smith wrote:

On 12/19/06, Mike Shal <address@hidden> wrote:

On 12/19/06, Dave Korn <address@hidden> wrote:
> On 19 December 2006 22:08, bC wrote:
>
> > I've built a couple simplistic make files to install my program, needed > > data files and libraries.... one aimed at being used on Fedora Core 3, the > > other on Fedora Core 5. Those are currently the two favorites of my target > > audience; and I've found them to vary in what libraries are present by
> > default.
> >
> > I'd like to maintain just the one make file... so, I need a test and > > decision based upon which version of the OS the make utility finds itself > > running under. I would appreciate a kick-start in the right direction.
>
>   Perhaps something along the lines of
>
> OS_VERSION=$(shell uname)
>

Though keep in mind that everytime you use $(OS_VERSION) it will
execute another shell command. If you use $(OS_VERSION) in more than
one place, you probably want:

OS_VERSION:=$(shell uname)

(note the ":=") This will execute the shell only once, when the
variable is declared.


All good points.  I have only to add that uname without arguments will
give you useful platform information but it may lack any sort of
pertinent version information.  I find the following to be fairly
portable and a pretty good way to dial makefile settings to a
particular platform.

osname := $(shell uname -s)
osver := $(shell uname -r)
cpuarch := $(shell uname -m)

Unfortunately, the string printed out by uname -r on AIX is the minor
version of the OS. To get the major version you need to use the -v
option.

Martin


Then you can do things like this, for example.

Darwin-8.8.1-i386-CFLAGS := -DMACOSX_X86
SunOS-5.9-sun4u-CFLAGS := -DSOL9_SPARC

CFLAGS := $($(osname)-$(osver)-$(cpuarch)-CFLAGS)

 HTH,
 Ken Smith


_______________________________________________
Help-make mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-make





reply via email to

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