Date: Mon, 22 Feb 1999 13:55:00 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Richard Legner cc: djgpp AT delorie DOT com Subject: Re: MAKEing trouble In-Reply-To: <36D112BB.6C7678AA@whitehorse.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com 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: > 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? ;-)