diff options
author | bde <bde@FreeBSD.org> | 1998-05-04 13:54:41 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-05-04 13:54:41 +0000 |
commit | bcde8eae1d96c67e656fc23ac17d2116fb04f345 (patch) | |
tree | 004e2726a07c8d583561b341de2af372f226852b | |
parent | 135d8c12b7bb275655c220ce88939a7697260492 (diff) | |
download | FreeBSD-src-bcde8eae1d96c67e656fc23ac17d2116fb04f345.zip FreeBSD-src-bcde8eae1d96c67e656fc23ac17d2116fb04f345.tar.gz |
Generate explicit rules and other infrastructure for lex and yacc
sources. This will be used to fix `make -jN' races in many
Makefiles in /usr/src, and to simplify these and other Makefiles.
To get the fixes and simplifications, application Makefiles should
put the raw lex and yacc source names (foo.l and bar.y) in SRCS and
not put the names of any generated files in SRCS or CLEANFILES. A
few Makefiles already do this, although it didn't actually work before
(mkdep couldn't create complete dependencies because there is no
intermediate .c file for the .y.o and .l.o implicit rules).
Complications: if bar.y is in SRCS and -d is in YFLAGS, then bar.h
will be generated whether or not it is used, even if this clobbers a
real source file. This is so that bar.c can be generated using the
-j-safe and debugger-friendly -o option to YACC. There are smaller
warts for handling y.tab.h. y.tab.c and lex.yy.c are not supported.
-rw-r--r-- | share/mk/bsd.prog.mk | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 7801f01..4db65e0 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -1,5 +1,5 @@ # from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 -# $Id: bsd.prog.mk,v 1.66 1998/03/12 20:02:15 eivind Exp $ +# $Id: bsd.prog.mk,v 1.67 1998/03/23 14:58:27 eivind Exp $ .if exists(${.CURDIR}/../Makefile.inc) .include "${.CURDIR}/../Makefile.inc" @@ -27,6 +27,32 @@ LDFLAGS+= -static .if defined(PROG) .if defined(SRCS) +CLEANFILES?= + +.for _LSRC in ${SRCS:M*.l} +_LC:= ${_LSRC:S/.l/.c/} +${_LC}: ${_LSRC} + ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET} +SRCS:= ${SRCS:S/${_LSRC}/${_LC}/} +CLEANFILES:= ${CLEANFILES} ${_LC} +.endfor + +.for _YSRC in ${SRCS:M*.y} +_YC:= ${_YSRC:S/.y/.c/} +_YH:= ${_YSRC:S/.y/.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: + ln -sf ${_YH} ${.TARGET} +SRCS:= ${SRCS} y.tab.h +CLEANFILES:= ${CLEANFILES} ${_YH} y.tab.h +.endif +.endfor + OBJS+= ${SRCS:N*.h:R:S/$/.o/g} ${PROG}: ${OBJS} |