Regress to generating foo.c from foo.y via y.tab.c for crufty applications

that want a y.tab.h file.  This want must be specified by putting y.tab.h
in SRCS (and defaulting to or putting -d in YFLAGS).  This only works if
there is only one yacc parser, of course.  One improvement:  copy y.tab.c
to foo.c instead of renaming it, so that `#line...y.tab.c' statements in
it refer to an existing file.

Regress to not generating explicit rules for .l and .y sources containing
slashes.  This case is unusual and hard to handle properly.

Don't generate an unused dependency when -d is not in YFLAGS.
This commit is contained in:
bde 1998-05-06 15:01:18 +00:00
parent 216aef2a42
commit e6e7e77dcf

View File

@ -1,5 +1,5 @@
# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
# $Id: bsd.prog.mk,v 1.69 1998/05/04 17:43:46 bde Exp $
# $Id: bsd.prog.mk,v 1.70 1998/05/05 03:59:27 bde Exp $
.if exists(${.CURDIR}/../Makefile.inc)
.include "${.CURDIR}/../Makefile.inc"
@ -29,7 +29,7 @@ LDFLAGS+= -static
CLEANFILES?=
.for _LSRC in ${SRCS:M*.l}
.for _LSRC in ${SRCS:M*.l:N*/*}
.for _LC in ${_LSRC:S/.l/.c/}
${_LC}: ${_LSRC}
${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET}
@ -38,21 +38,29 @@ CLEANFILES:= ${CLEANFILES} ${_LC}
.endfor
.endfor
.for _YSRC in ${SRCS:M*.y}
.for _YSRC in ${SRCS:M*.y:N*/*}
.for _YC in ${_YSRC:S/.y/.c/}
.for _YH in ${_YSRC:S/.y/.h/}
SRCS:= ${SRCS:S/${_YSRC}/${_YC}/}
CLEANFILES:= ${CLEANFILES} ${_YC}
.if ${YFLAGS:M-d} != "" && ${SRCS:My.tab.h}
.ORDER: ${_YC} y.tab.h
${_YC} y.tab.h: ${_YSRC}
${YACC} ${YFLAGS} ${.ALLSRC}
cp y.tab.c ${_YC}
SRCS:= ${SRCS} y.tab.h
CLEANFILES:= ${CLEANFILES} y.tab.c y.tab.h
.elif ${YFLAGS:M-d} != ""
.for _YH in ${_YC:S/.c/.h/}
.ORDER: ${_YC} ${_YH}
${_YC} ${_YH}: ${_YSRC}
${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
SRCS:= ${SRCS:S/${_YSRC}/${_YC}/}
CLEANFILES:= ${CLEANFILES} ${_YC}
.if ${YFLAGS:M-d} != ""
y.tab.h: ${_YH}
ln -sf ${_YH} ${.TARGET}
SRCS:= ${SRCS} y.tab.h
CLEANFILES:= ${CLEANFILES} ${_YH} y.tab.h
.endif
SRCS:= ${SRCS} ${_YH}
CLEANFILES:= ${CLEANFILES} ${_YH}
.endfor
.else
${_YC}: ${_YSRC}
${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
.endif
.endfor
.endfor