[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available
- From: William Ahern <william@...>
- Date: Tue, 1 Apr 2014 12:02:05 -0700
On Tue, Apr 01, 2014 at 09:25:28AM -0300, Roberto Ierusalimschy wrote:
> > On Solaris flockfile and friends aren't visible by default. [...]
>
> Do you know a reliable environment variable that can be used to detect
> Solaris and friends?
>
I've found this documentation project immensely useful for platform
detection using the CPP environment
http://sourceforge.net/p/predef/wiki/Home/
Scroll down to the middle of the following page for information on
Solaris OS detection
http://sourceforge.net/p/predef/wiki/OperatingSystems/
(tl;dr check for sun or __sun)
and here for detection of Solaris Studio
http://sourceforge.net/p/predef/wiki/Compilers/
(tl;dr check for __SUNPRO_C)
I use this shell script from my GNU Makefile to detect the compiler
#!/bin/sh
set -e
: ${CC:=cc}
${CC} -E - <<-EOF | awk '/sunpro/||/clang/||/gcc/||/other/{ print $1; exit; }'
#if defined __SUNPRO_C
sunpro
#elif defined __clang__
clang
#elif defined __GNUC__
gcc
#else
other
#endif
EOF
And of course `uname -s` will give the operating system.