[net.bugs.4bsd] glitch in 4.2 BSD make

jiml@uwslh.UUCP (Jim Leinweber) (09/11/86)

In some circumstances, make gets the file names on the generated
commands wrong.  I don't know a fix.

Example: in the following sample makefile, "make lint" works, "make all"
works, "make all lint" works, but "make lint all" produces garbled commands.

The problem seems to be an interaction between the default rules for
lex.l -> lex.c -> lex.o and the overdone dependency "lint :  ... lex.l lex.c".

% cat bug.mak

CC1NULL = $(CC) $(CFLAGS) -o $* $*.c
SRC = alarmd.c bd_main.c lex.l batchq.c
H = batchq.h batchd.h include.h lex.h
BDO = bd_main.o lex.o

all : alarmd batchd batchq

alarmd : alarmd.c batchq.h ; $(CC1NULL)
batchd : $(BDO) ; $(CC) $(CFLAGS) -o batchd $(BDO) -ll
batchq : batchq.c batchq.h ; $(CC1NULL)

lex.c : lex.l lex.h
$(BDO): batchd.h batchq.h

lint : $(SRC) $H lex.c
	lint -achpx bd_*.c lex.c > lint
	lint -achpx batch.c >> lint
	lint -achpx batchq.c >> lint

% make -n -f bug.mak all lint            # this one is correct
cc  -o alarmd alarmd.c
cc  -c bd_main.c
lex  lex.l
mv lex.yy.c lex.c
cc  -c lex.c
cc  -o batchd bd_main.o lex.o -ll
cc  -o batchq batchq.c
lint -achpx bd_*.c lex.c > lint
lint -achpx batch.c >> lint
lint -achpx batchq.c >> lint

% make -n -f bug.mak lint all           # this one is wrong
lex  lex.l
mv lex.yy.c lex.c
lint -achpx bd_*.c lex.c > lint
lint -achpx batch.c >> lint
lint -achpx batchq.c >> lint
cc  -o lex lex.c                           # should be alarmd
cc  -c bd_main.c
cc  -c lex.c
cc  -o batchd bd_main.o lex.o -ll
cc  -o lex lex.c                           # should be batchq


Jim Leinweber   			usenet:  jiml@uwslh.uucp
State Hygiene Laboratory        	  {seismo, harvard, topaz, ihnp4,...}!
University of Wisconsin			  uwvax!uwslh!jiml
465 Henry Mall				internet:    uwslh!jiml@wisc.edu
Madison, Wisconsin, USA  53706		phone:   (608) 262-8092
-- 
James E. Leinweber   ...!{seismo,harvard,topaz,ihnp4}!uwvax!uwslh!jiml
Wisconsin State Hygiene Lab          (608) 262-8092
University of Wisconsin; 465 Henry Mall; Madison, WI  53706