This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc produces foo.exe, not foo


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@deneb.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@cygnus.com" with one line of text: "help".
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]