From: vance AT deneb DOT com (Stephen Vance) Subject: Re: gcc produces foo.exe, not foo 26 Sep 1998 05:15:57 -0700 Message-ID: <360BA99B.6DBB00B6.cygnus.gnu-win32@deneb.com> References: Mime-Version: 1.0 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit To: Arne Glenstrup Cc: gnu-win32 AT cygnus DOT com Arne Glenstrup wrote:
Now that we have established that we need some (in my opinion) dirty
$(EXEEXT)-stuff, what is the consensus on how to use it with regards to
makefile targets and -o switches to compilers? Should a makefile look
like this:

  EXEEXT = @EXEEXT@

  goal$(EXEEXT): goal.c
                 $(CC) -o goal$(EXEEXT) goal.c
                 cp goal$(EXEEXT) anothergoal$(EXEEXT)
                 mv goal$(EXEEXT) yet.another.goal

or should it look like this:

  EXEEXT = @EXEEXT@

  goal:          goal.c
                 $(CC) -o goal goal.c
                 cp goal$(EXEEXT) anothergoal$(EXEEXT)
                 mv goal$(EXEEXT) yet.another.goal

Actually, for really portable makefiles, you need to consider that not all compilers and linkers use -o.  Specifically, MSVC uses /OUT: with not trailing space.  Here's a remedy in pseudo-GNUmake syntax.
 
NULLSTRING =
SPACE = $(NULLSTRING) # DO NOT REMOVE.  End of line.


if $(MSVC)
LDOUT = /OUT:
else
LDOUT = -o$(SPACE)
endif
foo$(EXEEXT): foo$(OBJEXT)
    $(CC) $(LDOUT)$@ $(LDFLAGS) $?
-- 
Stephen Vance                           |  http://www.deneb.com
Deneb Robotics, Inc.                    |  mailto:vance AT deneb DOT com
5500 New King Street                    |  Phone: (248) 267-9696
Troy, MI 48098-2615                     |  Fax:   (248) 267-8585

What is done well is done quickly enough. -Augustus Caesar
  - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".