From: Richard Legner Newsgroups: comp.os.msdos.djgpp Subject: Re: MAKEing trouble Date: Mon, 22 Feb 1999 12:31:14 -0600 Organization: Posted via RemarQ Communities, Inc. Lines: 71 Message-ID: <36D1A272.D8BC555F@whitehorse.net> References: NNTP-Posting-Host: 199.247.227.204 NNTP-Posting-Date: Mon, 22 Feb 1999 20:32:02 GMT X-Trace: 919715522.116.35 KA6SYTPPCE3CCC7F7 X-Complaints-To: newsabuse AT remarQ DOT com X-Mailer: Mozilla 4.07 [en] (Win95; U) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii wrote: > > On Mon, 22 Feb 1999, Richard Legner wrote: > > > When I run Make, it only looks at the first dependency and executes the > > first command (gxx -o list.exe list.o swap.o) > > That's because you lied to Make about the files upon which list.exe is > dependent: Don't I feel stupid! > > > list.exe: list.cpp swap.cpp > > gxx -o list.exe list.o swap.o > > This is wrong: list.cpp and swap.cpp are NOT the dependencies of > list.exe, otherwise they would have appeared on the gxx command line. > What you need to say is this: > > list.exe: list.o swap.o > gxx -o list.exe list.o swap.o > > Now everything should work. > > > 1) when I first ran it, it reported 'no such file or directory' error > > with respect to list.o and swap.o > > That's because when you say "make", it by default only creates the first > target of the Makefile, in this case list.exe. Since swap.o and list.o > didn't exist, gxx complained about their absence. Changing the list.exe > dependency like I showed above would have fixed this problem as well, > since Make would then understand it had to rebuild swap.o and list.o, > even if you didn't tell it explicitly. > > > 3) when I run Make twice in a row (without modifying the two object > > files in between , it still rebuilds the executable. > > This shouldn't happen (unless list.cpp and swap.cpp have some weird time > stamp). If after changing your Makefile it still behaves that way, run > "make -d", redirect Make's stdout and stderr to a file, and post that > file. > > > 4) when I make changes to list.cpp and swap.cpp and then run Make, the > > executable gets rebuilt with the old abject files (Make does not update > > the object files with the most recent changes to cpp files) > > Because you didn't tell Make that list.exe depends on the object files, > so Make doesn't bother to rebuild the object files when the source files > change. Again a consequence of that single erroneous dependency. > > Maybe it's time to read the Make manual? ;-) I would not attempt to use a command based program without learning something about it first. I have read enough of the manual to start creating simple makefiles like this and to make (pun intended) silly errors like I did. I meant to have list.exe depend on the object files, not the cpp's. This error (cause by lack of attention on my part) set me back three hours and caused me some embarrassment on the newsgroup (hey, it could be worse). Oh well, how else will I learn? *grin* thanks for pointing out my mistake cheers Richard