delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/28/05:24:50

Date: Thu, 28 Aug 1997 12:23:16 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Michael Mauch <mauch AT uni-duisburg DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: Simple Makefile: how to generate .exe file
In-Reply-To: <5u1cie$61v$3@news-hrz.uni-duisburg.de>
Message-ID: <Pine.SUN.3.91.970828122243.10704C-100000@is>
MIME-Version: 1.0

On Wed, 27 Aug 1997, Michael Mauch wrote:

> x.exe:	x.o
> 
> This makes the x.o from x.c, because of the implicit rule for compiling
> .o from .c. But x.exe is not created.

Make doesn't know how to make .exe from .o, it's not in its built-in
rule data-base.  So you must tell it how to do that.  For example:

x.exe: x.o
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@

(All of the $(whatever) variables used in the above are stored in
Make's built-in rule data-base; see the manual for more details.)

You could also make this rule more general by using pattern rules:

%.exe: %.o
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@

This will make the rule work for any .o file, not just for x.o.
Again, see the Make manual for details.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019