gmake/make dependency problem

Harti Brandt hartmut.brandt at dlr.de
Tue Sep 20 01:45:56 PDT 2005


[I answer to this mail; because I did not see the original one]

On Tue, 20 Sep 2005, Giorgos Keramidas wrote:

GK>On 2005-09-19 19:00, Harlan Stenn <stenn at ntp.isc.org> wrote:
GK>> I'm confused.
GK>>
GK>> I believe that:
GK>>
GK>>  a: b
GK>>
GK>> means that 'a' depends on 'b', and if 'b' has a later timestamp than 'a'
GK>> then the rule will be invoked to produce a new 'a' from  whatever is
GK>> done with 'b'.
GK>>
GK>> In this case, 'a' is ntpd-opts.c, and 'b' is ntpd-opts.def.
GK>>
GK>> As can be seen on your system and mine:
GK>>
GK>> > It seems that ntpd-opts.c has a timestamp 1 minute after ntpd-opts.def,
GK>>
GK>> which means it is up-to-date with respect to its dependencies.
GK>
GK>True.  I was confused when I posted my previous reply.  With the tarball
GK>you posted, I can run make(1) with -ddm and see what you mean:
GK>
GK>  1 % flame:/home/keramida/ws/ntp/obj/ntpq$ make -ddm
GK>  2 % Caching ....done
GK>  3 % Caching /usr/share/mk...done
GK>  4 % expanding "sys.mk".../usr/share/mk/sys.mk
GK>  5 % Searching for /etc/make.conf...Looking for "/etc/make.conf"...Caching 18:38:48 Sep 12, 2005 for /etc/make.conf
GK>  6 % Searching for /etc/make.conf...Looking for "/etc/make.conf"...got it (in mtime cache)
GK>  7 % Searching for bsd.compat.mk...failed.
GK>  8 % Searching for bsd.compat.mk...failed.
GK>  9 % Searching for bsd.compat.mk.../usr/share/mk...here...returning /usr/share/mk/bsd.compat.mk
GK> 10 % Searching for bsd.cpu.mk...failed.
GK> 11 % Searching for bsd.cpu.mk...failed.
GK> 12 % Searching for bsd.cpu.mk.../usr/share/mk...here...returning /usr/share/mk/bsd.cpu.mk
GK> 13 % Searching for BSDmakefile...failed.
GK> 14 % Searching for BSDmakefile.../usr/share/mk...failed.
GK> 15 % Searching for makefile...failed.
GK> 16 % Searching for makefile.../usr/share/mk...failed.
GK> 17 % Searching for ./.deps/ntpq.Po...failed. Trying subdirectories...failed. Looking for "./.deps/ntpq.Po"...Caching 01:09:41 Sep 20, 2005 for ./.deps/ntpq.Po
GK> 18 % Searching for ./.deps/ntpq-opts.Po...failed. Trying subdirectories...failed. Looking for "./.deps/ntpq-opts.Po"...Caching 01:09:42 Sep 20, 2005 for ./.deps/ntpq-opts.Po
GK> 19 % Searching for ./.deps/ntpq-subs.Po...failed. Trying subdirectories...failed. Looking for "./.deps/ntpq-subs.Po"...Caching 01:09:41 Sep 20, 2005 for ./.deps/ntpq-subs.Po
GK> 20 % Searching for .depend...failed.
GK> 21 % Searching for .depend.../usr/share/mk...failed.
GK> 22 % Caching ../../ntp-4.2.0b/ntpq...done
GK> 23 % Searching for ntpq-opts.def.c...../../ntp-4.2.0b/ntpq...failed.
GK> 24 % Searching for ntpq-opts.def...failed.
GK> 25 % Examining ntpq-opts.def...Searching for ntpq-opts.def...../../ntp-4.2.0b/ntpq...here...returning ../../ntp-4.2.0b/ntpq/ntpq-opts.def
GK> 26 % modified 11:02:16 Aug 30, 2005...up-to-date.
GK> 27 % Examining ntpq-opts.c...non-existent...modified before source...out-of-date.
GK> 28 % cd ../../ntp-4.2.0b/ntpq && autogen ntpq-opts.def
GK> 29 % autogen: not found
GK> 30 % *** Error code 127
GK> 31 %
GK> 32 % Stop in /home/keramida/ws/ntp/obj/ntpq.
GK> 33 % flame:/home/keramida/ws/ntp/obj/ntpq$
GK>
GK>At line 27 I see that ntpq-opts.c isn't looked up in VPATH.  This may be
GK>a make(1) bug, sorry for the initial confusion.
GK>
GK>I've Cc'ed Harti who's been working on make(1) lately.

Ok. The following Makefile reproduces this problem:

################
VPATH = foo
.SUFFIXES:
.SUFFIXES: .c .o

x: b.c
	echo x-b >x

b.c : a.def
	cd foo; echo b-a >b.c

.c.o:
	cc -c $<
#########

Then do:
mkdir foo
touch foo/a.def
(wait a little bit)
touch foo/b.c

make

#########

I'm not sure that this is really a bug. The man page for make(1) says:

     VPATH	     Makefiles may assign a colon-delimited list of directo-
		     ries to VPATH.  These directories will be searched for
		     source files by make after it has finished parsing all
		     input makefiles.

Note, that it says 'sources'. That is, make(1) will not find foo/b.c
when processing the dependency b.c : a.def. gmake on the other hand
applies VPATH also to targets.

If you change the Makefile like:

VPATH= foo
.SUFFIXES:
.SUFFIXES: .c .o

x: b.c
	echo x-b

foo/b.c : a.def
	echo b-a >foo/b.c

.c.o:
	cc -c $<

It seems to work.

harti


More information about the freebsd-questions mailing list