bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ought to exist: by which rules?


From: Ilya N. Golubev
Subject: ought to exist: by which rules?
Date: Sat, 10 Mar 2007 01:44:55 +0300

Versions: 3.79.1, 3.81.

The definition of (file that is) <ought to exist> <(make) Implicit
Rule Search> is ambiguous.  <file name is mentioned in the makefile as
an explicit prerequisite> does not state, whether this means the
prerequisite in rule in question or in any other rule in makefiles.

This manifests with makefile like this.  (I know, libtool does things
like these much cleaner.  Call it pre- libtool legacy code if you
like.)

AR = ar
RANLIB = ranlib
SUFFIXES = .am.a
external_libdir = external
external_libadd = $(external_libdir)/libexternal.a
.SUFFIXES:
.SUFFIXES: .am.a
%.a:%.am.a \
${external_libadd}
        if [ -d o ];then rm -rf o;else :;fi
        mkdir o&&{ cd o&&{ for i in $?; \
        do\
          case "$$i" in /*);; *)i="../$$i";;esac;\
          objects=`$(AR) t "$$i"`;\
          $(AR) x "$$i";\
          $(AR) cru ../$@ $$objects;\
          rm -f $$objects;\
        done;cd ..;};rmdir o;};
        $(RANLIB) $@
libk.a:libk.am.a \
${external_libadd}
# end of makefile

if the case when the target is `.a' file, and both `%.a' target
`%.am.a' prerequisite files exist, but
`$(external_libdir)/libexternal.a' prerequite file does not.  `%.am.a'
is newer then `%.a'.  Tried that for `%' being `k', `b'.  Note
explicit `libk.a' rule in makefile above.

The reasonable expectation is that `make' will try to rebuild the
target, and issue clear error message that the prerequisite does not
exist.  Some versions do, some do not.  Actually, they output the
following.

3.79.1

make: *** No rule to make target `no_such_dir/libexternal.a', needed by 
`libb.a'.  Stop.

make: *** No rule to make target `no_such_dir/libexternal.a', needed by 
`libk.a'.  Stop.

3.81

make: Nothing to be done for `libb.a'.

make: *** No rule to make target `no_such_dir/libexternal.a', needed by 
`libk.a'.  Stop.

What 3.81 does for `libb.a' is most dangerous.  The target may
actually need update, but `make' will not tell that.

If `libb.a' does not exist, its error message is also hardly adequate
for diagnostics.

make: *** No rule to make target `libb.a'.  Stop.

Thus, of alternate interpretations allowed for by documentation, looks
like at least 2 different ones are implemented.  Please clarify,
should users rely on any of them, and if yes, on which.  (That is, if
the behavior in some of the cases described above should be left
explicitly undefined, please document so.)  If some standards, formal
or factual (in form of widespread makes behaving some way and
applications depending on that) are relevant, explicit references to
them are welcome.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]