|
Home > Archive > Unix Programming > May 2004 > recognize UNIX version
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
recognize UNIX version
|
|
| Darko M. 2004-05-11, 5:40 pm |
| Is there any portable way of recognizing which version of UNIX (or
Linux, for me it's a sort of) is the software being installed on
(preprocessor way), or which version of UNIX is the software being
running on?
I'm kind of ready to suffer looking for all the non-typical system
calls and functions and porting them to various (modern) versions of
UNIX.
Something like sysconf or #ifdef UNIXBSD, blabla...
I would also like if I could find a table or something where I would
have all the different syscalls listed in various versions of UNIX (I
know I want too much 
Well?
Thanks.
| |
| Eric Enright 2004-05-11, 5:40 pm |
| On Tue, 11 May 2004 10:58:55 -0700, Darko M. wrote:
> Is there any portable way of recognizing which version of UNIX (or
> Linux, for me it's a sort of) is the software being installed on
> (preprocessor way), or which version of UNIX is the software being
> running on?
Two easy ways I can think of are to popen uname, and check the MACHTYPE
environment variable (not sure how portable that last one is, but it's
present on my Linux and Sol9).
--
Eric Enright /"\
sauronAtiptsoftDcom \ / ASCII Ribbon Campaign
X Against HTML E-Mail
Public Key: 0xBEDF636F / \
| |
| Barry Margolin 2004-05-11, 5:40 pm |
| In article <ef663480.0405110958.aa60590@posting.google.com>,
mdanko@tesla.rcub.bg.ac.yu (Darko M.) wrote:
> Is there any portable way of recognizing which version of UNIX (or
> Linux, for me it's a sort of) is the software being installed on
> (preprocessor way), or which version of UNIX is the software being
> running on?
This is usually not a useful thing to do. It's much better to
conditionalize on individual features rather than the OS version. Have
you looked at GNU autoconf?
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
| |
| Bjorn Reese 2004-05-11, 5:40 pm |
| On Tue, 11 May 2004 10:58:55 -0700, Darko M. wrote:
> Is there any portable way of recognizing which version of UNIX (or
> Linux, for me it's a sort of) is the software being installed on
> (preprocessor way), or which version of UNIX is the software being
> running on?
For the preprocessor part see
http://predef.sourceforge.net/
--
mail1dotstofanetdotdk
| |
| Levente KOVACS 2004-05-12, 4:39 am |
| On 11 May 2004 10:58:55 -0700
mdanko@tesla.rcub.bg.ac.yu (Darko M.) wrote:
> Is there any portable way of recognizing which version of UNIX (or
> Linux, for me it's a sort of) is the software being installed on
> (preprocessor way), or which version of UNIX is the software being
> running on?
You should write a ./configure shell script, which generates makefile,
and config.h. You should include config.h in your program.
There's a program called uname, which comes with every UNIX platforms.
See man uname.
The ./configure shell script shall execute such commands like
SYSTEM=`uname -s`
..
..
..
echo "#define SYSTEM $SYSTEM" >>config.h
Or something like that.
You can add flags to your cc, and/or linker like
CCFLAGS=`gtk-config --cflags`
LDFLAGS=`gtk-config --link`
..
..
..
echo CCFLAGS=$CCFLAGS >>Makefile
echo LDFLAGS=$LDFALGS >>Makefile
And, the rest of your Makefile shall use thoes variables.
I know, that autoconf does this, but for me it's too complicated, and
sometime I run into problems (e.g. with the gEDA tools).
I just made this mail, I do not run things like this...yet. But I'm
thinkink about writing some scripts.
Anyway... I hope it helped.
Levente
--
Leva
__
Email: levente.kovacs@cern.ch
Home Page: http://web.interware.hu/leva
Public key: http://web.interware.hu/leva/CERN/public_key
________________________________________
/"\
\ / ASCII Ribbon Campaign
X against HTML email & vCards
/ \ http://arc.pasp.de/
Have Fun, & Linux! 73 for all by HA5OGL.
This message was generated by Sylpheed.
|
|
|
|
|