🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Bob_Sidebotham Tue, 01 Sep 1992 09:25
dependency chaining bug
#710
Author: Bob_Sidebotham
Date: Tue, 01 Sep 1992 09:25
76 lines
2436 bytes
There's a bug in the way that dependencies of the form -l<lib> work. In
the following makefile, "baz" and "bar" are made in a similar manner,
except that baz is made implicitly with a dependency list of "baz.o
-lfoo", while bar is made with a dependency list of "bar.o libfoo.a". If
the file "foo.h" is touched, the object file and library will not be
remade if you type "make baz", but will be remade if you type "make bar".

To try this out, put this makefile in a clean directory, and type
"make". It will create all the necessary files. Then type "make baz" and
"make bar". You should see the following results:

[make-bug] make -v
GNU Make version 3.62, by Richard Stallman and Roland McGrath.
Copyright (C) 1988-1991 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

echo "main() {}" > bar.c
cc    -c bar.c -o bar.o
echo "/* a library component */" > foo.c
echo "/* a header file */" > foo.h
cc    -c foo.c -o foo.o
ar rv libfoo.a foo.o
ar: creating an archive file libfoo.a
a - foo.o
cc -L.  bar.o libfoo.a   -o bar
echo "main() {}" > baz.c
cc    -c baz.c -o baz.o
cc -L.  baz.o -lfoo   -o baz
[make-bug] touch foo.h
[make-bug] make baz
make: `baz' is up to date.
[make-bug] make bar
cc    -c foo.c -o foo.o
ar rv libfoo.a foo.o
r - foo.o
cc -L.  bar.o libfoo.a   -o bar

Here's the makefile:

------------------CUT HERE-----------------
vpath		.
LDFLAGS=	-L.

all:		bar baz

foo.c:
		echo "/* a library component */" > foo.c

foo.h:
		echo "/* a header file */" > foo.h

bar.c:
		echo "main() {}" > bar.c

baz.c:
		echo "main() {}" > baz.c

foo.o:		foo.c foo.h

libfoo.a:	foo.o
		ar rv libfoo.a foo.o

bar:		bar.o libfoo.a

baz:		baz.o -lfoo

clean:
		$(RM) foo.c foo.h bar.c bar.o baz.c baz.o foo.o libfoo.a bar baz
--------------------END Makefile---------------

Thanks,

Bob Sidebotham bob@transarc.com
Transarc Corporation 412-338-4367
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads