Subject: Re: gcc produces foo.exe, not foo
From: [email-masked] (Stephen Vance)

26 Sep 1998 05:15:57 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: Arne Glenstrup <[email-masked]>
Cc: [email-masked]

<HTML>
Arne Glenstrup wrote:
<BLOCKQUOTE TYPE=CITE>Now that we have established that we need some (in
my opinion) dirty
<BR>$(EXEEXT)-stuff, what is the consensus on how to use it with regards
to
<BR>makefile targets and -o switches to compilers? Should a makefile look
<BR>like this:

<P>&nbsp; EXEEXT = @EXEEXT@

<P>&nbsp; goal$(EXEEXT): goal.c
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$(CC) -o goal$(EXEEXT) goal.c
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cp goal$(EXEEXT) anothergoal$(EXEEXT)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mv goal$(EXEEXT) yet.another.goal

<P>or should it look like this:

<P>&nbsp; EXEEXT = @EXEEXT@

<P>&nbsp; goal:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goal.c
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$(CC) -o goal goal.c
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cp goal$(EXEEXT) anothergoal$(EXEEXT)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mv goal$(EXEEXT) yet.another.goal</BLOCKQUOTE>
Actually, for really portable makefiles, you need to consider that not
all compilers and linkers use -o.&nbsp; Specifically, MSVC uses /OUT: with
not trailing space.&nbsp; Here's a remedy in pseudo-GNUmake syntax.
<BR>&nbsp;
<PRE>NULLSTRING =</PRE>

<PRE>SPACE = $(NULLSTRING) # DO NOT REMOVE.&nbsp; End of line.</PRE>

<PRE></PRE>

<PRE>if $(MSVC)</PRE>

<PRE>LDOUT = /OUT:</PRE>

<PRE>else</PRE>

<PRE>LDOUT = -o$(SPACE)</PRE>

<PRE>endif</PRE>

<PRE>foo$(EXEEXT): foo$(OBJEXT)</PRE>

<PRE>&nbsp;&nbsp;&nbsp; $(CC) $(LDOUT)$@ $(LDFLAGS) $?</PRE>

<PRE>--&nbsp;
Stephen Vance&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; <A HREF="http://www.deneb.com">http://www.deneb.com</A>
Deneb Robotics, Inc.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; <A HREF="mailto:[email-masked]">mailto:[email-masked]</A>
5500 New King Street&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; Phone: (248) 267-9696
Troy, MI 48098-2615&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; Fax:&nbsp;&nbsp; (248) 267-8585

What is done well is done quickly enough. -Augustus Caesar</PRE>
&nbsp;</HTML>

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".