[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Assign a variable based on OS, how to do?
From: |
Henrik Carlqvist |
Subject: |
Re: Assign a variable based on OS, how to do? |
Date: |
Fri, 31 Oct 2008 19:56:44 +0100 |
User-agent: |
Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
"Maximus" <maximus@microsoft.com> wrote:
> I need to assign a variable which value is based on the operating system. It
> looks like this (pseduo code):
>
> CMD_NAME = OS == WIN ? cmd.bat : cmd.sh
>
> How to write it in GNU make? I am a newbie here. Thanks!
I have the solution to your problem, but I don't have the file here at
home, it is at work. If I remember right the Makefile looks something like
this:
OS = $(shell uname)
ifeq ($OS,Linux)
CMD_NAME = cmd.sh
endif
ifeq ($OS,MINGW)
CMD_NAME = cmd.bat
endif
In mingw (msys) as well as cygwin you have access to the uname command. As
you are using gnu make I guess that you are in one of those environments
on Windows? If you don't have access to the uname command on Windows,
maybe it would be possible to call ver instead.
If I remember right I had to strip of some text from the $OS-variable in
Windows, I think that both Cygwin and MINGW adds a lot of version
information in the output from uname.
regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc3(at)poolhem.se Examples of addresses which go to spammers:
root@localhost postmaster@localhost