This is a very slight deviation from posix rules, but not in spirit. My interpretation is that posix rules describe the intent of the make rules (produce a file in such a way), but don't really care about intermediate names.
FreeBSD already has something like this in tree (though they use lex >$@ instad of lex -o $@ ? ) They also have some non-working mechanism for full posix compatibility (because you deduce you run in posix mode if your first comment says .POSIX, but sys.mk is read before that, ahah. That would actually be fixable, it shouldn't be that complicated to delay reading sys.mk until you either run into a .POSIX line or something else) Something should also be done for yacc, but that's bound to be slightly different. My plans for yacc are as follows: - don't touch the sys.mk rules. They are mandated by posix and CAN'T be changed. - put up proper rules in bsd.sys.mk. So that a yacc file produces a .c and a .h by default *with the same names*. This requires adjusting a few makefiles to cope - use that on SRCS so that we can finally have "correct" file.c file.h: file.y dependency lines without needing to adjust every makefile. Reading thru freebsd, again, they did something like this (read their bsd.dep.mk). The main departure from their scheme is to put the actual rule in bsd.sys.mk, and the dependency in bsd.dep.mk like they do. So, for now, I need okays for this patch. Index: bsd.sys.mk =================================================================== RCS file: /cvs/src/share/mk/bsd.sys.mk,v retrieving revision 1.11 diff -u -p -r1.11 bsd.sys.mk --- bsd.sys.mk 1 Jul 2017 14:41:54 -0000 1.11 +++ bsd.sys.mk 5 Jul 2017 11:11:26 -0000 @@ -11,19 +11,6 @@ CXXFLAGS+= -idirafter ${DESTDIR}/usr/inc .endif .if defined(PARALLEL) -# Lex -.l: - ${LEX.l} -o${.TARGET:R}.yy.c ${.IMPSRC} - ${LINK.c} -o ${.TARGET} ${.TARGET:R}.yy.c ${LDLIBS} -ll - rm -f ${.TARGET:R}.yy.c -.l.c: - ${LEX.l} -o${.TARGET} ${.IMPSRC} -.l.o: - ${LEX.l} -o${.TARGET:R}.yy.c ${.IMPSRC} - ${COMPILE.c} -o ${.TARGET} ${.TARGET:R}.yy.c - rm -f ${.TARGET:R}.yy.c - if test -f ${.TARGET:R}.d; then sed -i -e 's,${.TARGET:R}.yy.c,${.IMPSRC},' ${.TARGET:R}.d; fi - # Yacc .y: ${YACC.y} -b ${.TARGET:R} ${.IMPSRC} Index: sys.mk =================================================================== RCS file: /cvs/src/share/mk/sys.mk,v retrieving revision 1.78 diff -u -p -r1.78 sys.mk --- sys.mk 1 Jul 2017 14:41:54 -0000 1.78 +++ sys.mk 5 Jul 2017 11:11:26 -0000 @@ -185,17 +185,16 @@ CTAGS?= /usr/bin/ctags # Lex .l: - ${LEX.l} ${.IMPSRC} - ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll - rm -f lex.yy.c + ${LEX.l} -o ${.PREFIX}.lex.c ${.IMPSRC} + ${LINK.c} -o ${.TARGET} ${.PREFIX}.lex.c ${LDLIBS} -ll + rm -f ${.PREFIX}.lex.c .l.c: - ${LEX.l} ${.IMPSRC} - mv lex.yy.c ${.TARGET} + ${LEX.l} -o ${.TARGET} ${.IMPSRC} .l.o: - ${LEX.l} ${.IMPSRC} - ${COMPILE.c} -o ${.TARGET} lex.yy.c - rm -f lex.yy.c - if test -f ${.TARGET:R}.d; then sed -i -e 's,lex.yy.c,${.IMPSRC},' ${.TARGET:R}.d; fi + ${LEX.l} -o ${.PREFIX}.lex.c ${.IMPSRC} + ${COMPILE.c} -c ${.PREFIX}.lex.c + rm -f ${.PREFIX}.lex.c + if test -f ${.TARGET:R}.d; then sed -i -e 's,${.PREFIX}.lex.c,${.IMPSRC},' ${.TARGET:R}.d; fi # Yacc .y: