www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/23/15:56:15

Newsgroups: comp.os.msdos.djgpp
From: gerlach AT netcom DOT com (Matthew H. Gerlach)
Subject: Re: dos/unix defines
Message-ID: <gerlachE93Jr6.DGp@netcom.com>
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
References: <Pine DOT SGI DOT 3 DOT 93 DOT 970422112220 DOT 7282C-100000 AT gibson DOT eee DOT upd DOT edu DOT ph>
Date: Wed, 23 Apr 1997 15:16:18 GMT
Lines: 83
Sender: gerlach AT netcom23 DOT netcom DOT com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

This discussion is primarliy dealing with condition compilation of 
code based on OS.

I would like to similar stuff using GNU make, because I have makefiles used
on both UNIX and DJCPP make.  In other words, I would like to something like 
the following:

ifeq (OS, UNIX)
RM=rm -f
else
rm=del
endif


Can someone please point me in the right direction to do this?  The
GNU make manual discusses contitional code, but it did not suggest a 
a variable to test of OS type.  A search through dejanews did not
enlighten me either.

Thanks,

Matthew

In article <Pine DOT SGI DOT 3 DOT 93 DOT 970422112220 DOT 7282C-100000 AT gibson DOT eee DOT upd DOT edu DOT ph> Orlando Andico <orly AT gibson DOT eee DOT upd DOT edu DOT ph> writes:
>On Mon, 21 Apr 1997, Andrew Deren wrote:
>
>> Does anyone know what #define I have to use to detect whether a program is
>> compiled on DOS or UNIX. I use Borland C++ and DJGPP for DOS and gcc and
>> CC for unix if that matters.
>> THanks.
>> 
>
>Depends on your UNIX version and C compiler. __unix__ is defined by all
>the GCC's I've seen, even DJGPP, so that's not a smart one. I personally
>use the following (n.b. _all_ the #defines I use are made by GCC, so this 
>code will only be reliable on GCC machines; besides, I've only tested
>this code on DJGPP under DOS, DJGPP under Linux, Linux-ELF 1.x and 2.x,
>Solaris 2.x, SunOS 4.x (both SPARC), and IRIX 5.3):
>
>#ifdef __sgi
>#ifdef __SVR4_SOURCE
> printf ("running on SGI IRIX 5.x/6.x\n");
>#else
> printf ("running on SGI IRIX 4.x\n");
>#endif
>#endif
>
>#ifdef __linux__
> printf ("running on Linux\n");
>#endif
>
>#ifdef __sun__
>#ifdef __sparc__
> printf ("running on Sun SPARC.. ");
>#else
> printf ("running on Sun non-SPARC.. ");
>#endif
>
>#ifdef __svr4__
> printf ("under Solaris 2.x\n");
>#else
> printf ("under SunOS 4.x or lower\n");
>#endif
>
>#ifdef __MSDOS__
> printf ("running under MSDOS.. ");
>#ifdef __DJGPP__
> printf ("under DJGPP\n");
>#else
> printf ("under non-GNU compiler\n");
>#endif
>#endif
>
>
>
>-----------------------------------------------------------------------
>Orlando Andico                               IRC Lab/EE Dept/UP Diliman
>email: orly AT gibson DOT eee DOT upd DOT edu DOT ph          http://gibson.eee.upd.edu.ph
>   "There's an obvious attraction to the path of least resistance.."
>


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019