www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/24/07:26:30

Date: Tue, 24 Sep 1996 12:37:53 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "Richard L.F. van Paasen" <R DOT L DOT F DOT v DOT Paasen AT stud DOT tue DOT nl>
Cc: djgpp AT delorie DOT com
Subject: Re: Make files
In-Reply-To: <32461180.29C6@stud.tue.nl>
Message-Id: <Pine.SUN.3.91.960924122947.11589C-100000@is>
Mime-Version: 1.0

On Sun, 22 Sep 1996, Richard L.F. van Paasen wrote:

> The beauty of Borlands project files is that the only thing you have to 
> tell the compiler is the sources and external objs and libs you're using.
> It figures out all depedencies (rules etc.) by itself, even from nested 
> header files. (of course it has drawbacks too).

The beauty of GNU Make (which comes with DJGPP) is that you sometimes 
need to tell it even less, since most of the rules for the simple cases 
(such as those you list) are known to Make by default.

> I've tried to write a makefile that does the following:
> 
> - take all *.cpp and *.c and *.asm files in a given directory (yes,
> all!)
> - take some named .cpp .c and .asm files
> - compile them, when they need to be compiled (ie. when header files and
> the
>   source itself are changed)
> - compile the whole thing into an archive (or executable), add some libs
>   and objs to it (ehh, I mean .a and .o files)


I suggest the following incremental approach:

Begin with a Makefile which only describes which object files and
libraries go into the binary, like so: 

	myprog: main.o sub1.o sub2.o lib1.a lib2.a

That's all!  Now say "make -k myprog" and see what happens.  Some files
will be compiled, while for others Make will complain that it doesn't 
know what to do to generate them.  You should add a rule for every such 
case, and try again, until you get `myprog' built with no error 
messages.  For most of the cases, GNU Make only needs to know the 
dependencies (like the line above); how to produce the target given the 
dependencies it usually knows by itself.

If you don't know how to write a rule for a specific case, ask here (or,
better still, read the Make on-line docs, they are very good). 

- Raw text -


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