This is a collaboration of sort with FreeBSD. To me very specific, working on fixing depends made me look at fixing yacc support, and at the same time, I looked at FreeBSD, and they did this already (with different code, our share/mk are wildly divergent), so this comforted me this was doable and probably not too painful.
So far so good. It has surprisingly little impact on base. I'm currently building xenocara as well, and intend to put this thru a ports build as well. What this does: - change the .y -> .c rule for bsd.prog.mk/bsd.lib.mk (thru bsd.sys.mk) so that it does .y -> .c/.h, thus changing the name of the generated .h file - add an explicit dependency (+ the same rule, more or less) in bsd.dep.mk so that the .c and .h are tied correctly, and so that the .h is cleaned as well. What this does not: - change the default rule in sys.mk for yacc files, because that would break posix compatibility, and impact way more software we don't have a direct interest in maintaining. Impact: surprisingly few programs. A lot of other stuff actually has ad-hoc rules that could probably be cleansed afterwards. Considering how much of a headache, having the framework do something sane by default, even if this involves changing a few files, seems like a good thing to me... After running that build, I think it's reaching the stage where I'm actually asking for review and okays. Index: games/atc/lex.l =================================================================== RCS file: /build/data/openbsd/cvs/src/games/atc/lex.l,v retrieving revision 1.4 diff -u -p -r1.4 lex.l --- games/atc/lex.l 27 Oct 2009 23:59:23 -0000 1.4 +++ games/atc/lex.l 7 Jul 2017 11:15:08 -0000 @@ -43,7 +43,7 @@ * For more info on this and all of my stuff, mail edja...@berkeley.edu. */ -#include "y.tab.h" +#include "grammar.h" extern int line; Index: sbin/wsconsctl/map_scan.l =================================================================== RCS file: /build/data/openbsd/cvs/src/sbin/wsconsctl/map_scan.l,v retrieving revision 1.6 diff -u -p -r1.6 map_scan.l --- sbin/wsconsctl/map_scan.l 19 Nov 2015 19:48:27 -0000 1.6 +++ sbin/wsconsctl/map_scan.l 7 Jul 2017 11:05:29 -0000 @@ -39,7 +39,7 @@ #include <limits.h> #include <err.h> #include "wsconsctl.h" -#include "y.tab.h" +#include "map_parse.h" void map_scan_setinput(char *str) Index: share/mk/bsd.dep.mk =================================================================== RCS file: /build/data/openbsd/cvs/src/share/mk/bsd.dep.mk,v retrieving revision 1.20 diff -u -p -r1.20 bsd.dep.mk --- share/mk/bsd.dep.mk 5 Jul 2017 13:30:01 -0000 1.20 +++ share/mk/bsd.dep.mk 7 Jul 2017 11:04:37 -0000 @@ -38,6 +38,17 @@ tags: ${i:R:S/$/.o/} ${i:R:S/$/.po/} ${i:R:S/$/.so/} ${i:R:S/$/.do/}: $i .endfor +# give us better rules for yacc + +.if ${YFLAGS:M-d} +# loop may not trigger +. for f in ${SRCS:M*.y} +${f:.y=.c} ${f:.y=.h}: $f + ${YACC.y} -o ${f:.y=.c} ${.IMPSRC} +. endfor +CLEANFILES += ${SRCS:M*.y:.y=.h} +.endif + CLEANFILES += ${DEPS} .depend BUILDFIRST ?= Index: share/mk/bsd.sys.mk =================================================================== RCS file: /build/data/openbsd/cvs/src/share/mk/bsd.sys.mk,v retrieving revision 1.12 diff -u -p -r1.12 bsd.sys.mk --- share/mk/bsd.sys.mk 5 Jul 2017 13:31:40 -0000 1.12 +++ share/mk/bsd.sys.mk 7 Jul 2017 10:32:40 -0000 @@ -10,18 +10,5 @@ CPPFLAGS+= -nostdinc -idirafter ${DESTDI CXXFLAGS+= -idirafter ${DESTDIR}/usr/include/g++ .endif -.if defined(PARALLEL) -# Yacc -.y: - ${YACC.y} -b ${.TARGET:R} ${.IMPSRC} - ${LINK.c} -o ${.TARGET} ${.TARGET:R}.tab.c ${LDLIBS} - rm -f ${.TARGET:R}.tab.c .y.c: - ${YACC.y} -b ${.TARGET:R} ${.IMPSRC} - mv ${.TARGET:R}.tab.c ${.TARGET} -.y.o: - ${YACC.y} -b ${.TARGET:R} ${.IMPSRC} - ${COMPILE.c} -o ${.TARGET} ${.TARGET:R}.tab.c - rm -f ${.TARGET:R}.tab.c - if test -f ${.TARGET:R}.d; then sed -i -e 's,${.TARGET:R}.tab.c,${.IMPSRC},' ${.TARGET:R}.d; fi -.endif + ${YACC.y} -o ${.TARGET} ${.IMPSRC} Index: usr.bin/m4/Makefile =================================================================== RCS file: /build/data/openbsd/cvs/src/usr.bin/m4/Makefile,v retrieving revision 1.15 diff -u -p -r1.15 Makefile --- usr.bin/m4/Makefile 4 Jul 2017 08:39:57 -0000 1.15 +++ usr.bin/m4/Makefile 7 Jul 2017 11:13:24 -0000 @@ -14,11 +14,4 @@ DPADD= ${LIBM} ${LIBUTIL} SRCS= eval.c expr.c look.c main.c misc.c gnum4.c trace.c tokenizer.l parser.y MAN= m4.1 -parser.c parser.h: parser.y - ${YACC} -o parser.c -d ${.ALLSRC} - -tokenizer.o: parser.h - -CLEANFILES+=parser.c parser.h tokenizer.o - .include <bsd.prog.mk> Index: usr.bin/rdist/Makefile =================================================================== RCS file: /build/data/openbsd/cvs/src/usr.bin/rdist/Makefile,v retrieving revision 1.19 diff -u -p -r1.19 Makefile --- usr.bin/rdist/Makefile 12 Jul 2014 03:32:00 -0000 1.19 +++ usr.bin/rdist/Makefile 7 Jul 2017 11:07:00 -0000 @@ -5,7 +5,6 @@ PROG= rdist CFLAGS+=-I. -I${.CURDIR} SRCS= gram.y child.c client.c common.c distopt.c docmd.c expand.c \ isexec.c lookup.c message.c rdist.c -CLEANFILES+=gram.c y.tab.h WARNINGS=yes .include <bsd.prog.mk> Index: usr.bin/rdist/client.c =================================================================== RCS file: /build/data/openbsd/cvs/src/usr.bin/rdist/client.c,v retrieving revision 1.35 diff -u -p -r1.35 client.c --- usr.bin/rdist/client.c 9 Dec 2015 19:39:10 -0000 1.35 +++ usr.bin/rdist/client.c 7 Jul 2017 11:07:43 -0000 @@ -39,7 +39,7 @@ #include <unistd.h> #include "client.h" -#include "y.tab.h" +#include "gram.h" /* * Routines used in client mode to communicate with remove server. Index: usr.bin/rdist/docmd.c =================================================================== RCS file: /build/data/openbsd/cvs/src/usr.bin/rdist/docmd.c,v retrieving revision 1.32 diff -u -p -r1.32 docmd.c --- usr.bin/rdist/docmd.c 20 Jan 2015 09:00:16 -0000 1.32 +++ usr.bin/rdist/docmd.c 7 Jul 2017 11:07:59 -0000 @@ -39,7 +39,7 @@ #include <unistd.h> #include "client.h" -#include "y.tab.h" +#include "gram.h" /* * Functions for rdist that do command (cmd) related activities. Index: usr.bin/rdist/rdist.c =================================================================== RCS file: /build/data/openbsd/cvs/src/usr.bin/rdist/rdist.c,v retrieving revision 1.30 diff -u -p -r1.30 rdist.c --- usr.bin/rdist/rdist.c 8 Feb 2015 23:40:34 -0000 1.30 +++ usr.bin/rdist/rdist.c 7 Jul 2017 11:07:15 -0000 @@ -38,7 +38,7 @@ #include <unistd.h> #include "client.h" -#include "y.tab.h" +#include "gram.h" /* Index: usr.sbin/config/scan.l =================================================================== RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/scan.l,v retrieving revision 1.23 diff -u -p -r1.23 scan.l --- usr.sbin/config/scan.l 19 Nov 2015 19:48:27 -0000 1.23 +++ usr.sbin/config/scan.l 7 Jul 2017 11:10:47 -0000 @@ -48,7 +48,7 @@ #include <string.h> #include <unistd.h> #include "config.h" -#include "y.tab.h" +#include "gram.h" int yyline; const char *yyfile;