🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3748

Re: Generic and platform-specific Makefiles

#3748
From: Martijn
Date: Thu, 21 Aug 2003 13:18
48 lines
2247 bytes
Alex Vinokur wrote:
> Hi,
>
> I would like to create Makefile which suits different platforms and
> operating systems.
>
> #########################
> # GNU Make version 3.79.1
> #########################
>
> For instance, I have some program.
>
> If I compile the program on Cygwin (Windows 2000)
>   the Makefile must contain the following line :
> -------------------------
> LIBS          = -lwsock32
> -------------------------

What you could do is make targets for the different architectures.  You
could set variables specific to these targets.  Just remember that the first
target is the "default" one (specifying a specific first target named so
could prevent confusion):

# first target is the default
default: linux

linux:
  LIBS =

win32:
  LIBS = -lwsock32

Or you could use a define (which I believe is nicer seems nicer):

# specify -DWIN32 as a parameter to make to set this var
ifdef WIN32
    LIBS = -lwsock32
else
    LIBS =
endif

Of course if you want to have these decisions made without required actions
by the user, you will have to look at the environment some way, like Gisle
suggested.

--
Martijn
http://www.sereneconcepts.nl
Technical Details
Message-ID: <3f44c732$0$49114$e4fe514c@news.xs4all.nl>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!transit.news.xs4all.nl!not-for-mail
References: <bi2ar0$4h8si$1@ID-79865.news.uni-berlin.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109f73,1b57b03510500b7e
X-Google-Attributes: gid109f73,public
X-Google-Thread: fc89c,1b57b03510500b7e
X-Google-Attributes: gidfc89c,public
X-Google-ArrivalTime: 2003-08-21 06:20:53 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!transit.news.xs4all.nl!not-for-mail
From: "Martijn" <subscription-NOSPAM-101@hotNOFILTERmail.com>
Newsgroups: comp.unix.programmer,gnu.utils.help
References: <bi2ar0$4h8si$1@ID-79865.news.uni-berlin.de>
Subject: Re: Generic and platform-specific Makefiles
Date: Thu, 21 Aug 2003 15:18:33 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Lines: 50
Message-ID: <3f44c732$0$49114$e4fe514c@news.xs4all.nl>
NNTP-Posting-Date: 21 Aug 2003 15:20:50 CEST
NNTP-Posting-Host: 80.126.5.101
X-Trace: 1061472050 news.xs4all.nl 49114 80.126.5.101:63805
X-Complaints-To: abuse@xs4all.nl