Mail Archives: djgpp/1999/02/22/15:40:37
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
- Raw text -