[comp.bugs.4bsd] make: multiple dependency lines and ..

hans@duttnph.tudelft.nl (Hans Buurman) (07/06/89)

I am sure somebody will point out if I am mistaken, but...

There seems to something strange with the way make deals with multiple
dependency lines. They will not work properly when the directory .. is
at the head of the target's path.

Repeat by:

make the following file tree:

	.
        |
   -----------------
   |        |      |
Makefile   dir    dir2
	    |      |
	    |      ----------
	    |       |       |
	   foo    file1  Makefile

The Makefiles are listed below:

::::::::::::::
Makefile
::::::::::::::
dir/foo:
	touch dir2/file1 dir/foo

dir/foo: dir2/file1

::::::::::::::
dir2/Makefile
::::::::::::::
../dir/foo:
	touch file1 ../dir/foo

../dir/foo: file1


The following is output from a Sun 4/280 running SunOs 4.0.1. The bug
reproduces on a Sun3/60 running 4.0.1, a Sun 3/60 running 3.5, and a
Vax running Ultrix V2.2. Note that at 68, the touch command is not
executed, while at 73 it is.

hans64> ls
Makefile  dir       dir2
hans65> cd dir2
/home/duttnph/ph/hans/tmp/dir2
hans66> ls
Makefile  file1
hans67> ls ../dir 
hans68> make -d
MAKEFLAGS value: 
  Building ../dir/foo because it is out of date relative to file1
hans69> cat Makefile
../dir/foo:
        touch file1 ../dir/foo

../dir/foo: file1
hans70> !ls
ls ../dir
hans71> cd ..
/home/duttnph/ph/hans/tmp
hans72> cat Makefile
dir/foo:
        touch dir2/file1 dir/foo

dir/foo: dir2/file1
hans73> make -d
MAKEFLAGS value: 
  Building dir/foo because it is out of date relative to dir2/file1
touch dir2/file1 dir/foo
hans74> ls dir
foo
hans75> 


I don't have any sources at my disposal so I cannot say anything about
a fix. A workaround is to use a symbolic link to the directory where
you want the target to go.

-----------------------------------------------------------------------------
Hans Buurman                   | hans@duttnph.tudelft.nl
Pattern Recognition Group      | hans@duttnph.UUCP
Faculty of Applied Physics     | mcvax!hp4nl!dutrun!duttnph!hans
Delft University of Technology | tel. 31 - (0) 15 - 78 46 94

hans@duttnph.tudelft.nl (Hans Buurman) (07/18/89)

I complained the other day about make, multiple dependency lines
and .. . I got one reply from Bradley White (bww@mtxinu.com),
which seems only appropriate to share with the net:

} The problem in your case though is with code to handle double suffix
} rules like:
} 
} 	.c.o:
} 		cc -c $*.c
} 
} In order to make it possible to redefine these rules, make throws
} away all but the last command set for any target that begins with '.'.
} 
} So in your case
} 
} 	../dir/foo:
} 		touch file1 ../dir/foo
} 
} 	../dir/foo: file1
} 
} turned into
} 
} 	../dir/foo:
} 
} 	../dir/foo: file1
} 
} and so nothing was ever executed.
} 
} The fix?  Well, seeing as you can only ever have one rule set on
} a ':' target anyway, just make sure it is the last one.  That is,
} 
} 	../dir/foo: file1
} 
} 	../dir/foo:
} 		touch file1 ../dir/foo
} 
} will work just fine.
} 
(...)
} 
} I too consider the behaviour an aberration, and have proposed changing
} the rule for discarding previous command sets to "begins with a '.'
} AND doesn't contain a '/'" --- a suffix rule should never have a '/'.

Thanks to Bradley White for pointing this out. We agreed that it was
a bug indeed.

-----------------------------------------------------------------------------
Hans Buurman                   | hans@duttnph.tudelft.nl
Pattern Recognition Group      | hans@duttnph.UUCP
Faculty of Applied Physics     | mcvax!hp4nl!dutrun!duttnph!hans
Delft University of Technology | tel. 31 - (0) 15 - 78 46 94