On 2006-12-12 22:20 UTC, Edward Z. Yang wrote:
> Philip Guenther wrote:
[...]
>>> Ah.  Hmm.  My *guess* is that g++ will only add the .exe suffix if
>>> there isn't already such a suffix present.  If so, then following the
>>> three points I listed should work.
> 
> This seems to be the case. I'm currently working around it by cleaning
> up *.exe files with make clean. On Unix, ${programs} does the dirty
> work. I think this is a satisfactory solution (and not a hack).

Here's how automake handles it:

  http://www.gnu.org/software/automake/manual/html_node/EXEEXT.html

You can use that technique yourself, even though you're not using
automake. Just name your programs this way:

programs := fibonacci$(EXEEXT) printNumbers$(EXEEXT)

Then a rule like

.PHONY: all
all: $(programs)

will do the right thing, portably, as long as you define $(EXEEXT)
appropriately. Changing the platform only requires changing that
one definition. And this gains the benefits of following Paul's
second rule ("Every non-.PHONY rule must update a file with the
exact name of its target"):

fibonacci$(EXEEXT): fibonacci.o

# not PHONY, so use *exact* name
%$(EXEEXT):
        $(LD) -o $@ $^ $(ALL_LDFLAGS)


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to