diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index 095047e7e7b0..6aa97abc0c53 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -121,17 +121,27 @@ CLEANFILES+= ${_LC} SRCS:= ${SRCS:S/${_YSRC}/${_YC}/} CLEANFILES+= ${_YC} .if !empty(YFLAGS:M-d) && !empty(SRCS:My.tab.h) -.ORDER: ${_YC} y.tab.h -y.tab.h: .NOMETA -${_YC} y.tab.h: ${_YSRC} +# Multi-output targets both expect a .meta file and will fight over it. Only +# allow it on the .c file instead. +y.tab.h: ${_YC} .NOMETA +# Force rebuild the .c file if any of its other outputs are missing. +.if !exists(y.tab.h) +${_YC}: .PHONY .META +.endif +${_YC}: ${_YSRC} ${YACC} ${YFLAGS} ${.ALLSRC} cp y.tab.c ${_YC} CLEANFILES+= y.tab.c y.tab.h .elif !empty(YFLAGS:M-d) .for _YH in ${_YC:R}.h -.ORDER: ${_YC} ${_YH} -${_YH}: .NOMETA -${_YC} ${_YH}: ${_YSRC} +# Multi-output targets both expect a .meta file and will fight over it. Only +# allow it on the .c file instead. +${_YH}: ${_YC} .NOMETA +# Force rebuild the .c file if any of its other outputs are missing. +.if !exists(${_YH}) +${_YC}: .PHONY .META +.endif +${_YC}: ${_YSRC} ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC} SRCS+= ${_YH} CLEANFILES+= ${_YH} diff --git a/share/mk/bsd.snmpmod.mk b/share/mk/bsd.snmpmod.mk index c45937cc82a7..6ecbbcf09bf7 100644 --- a/share/mk/bsd.snmpmod.mk +++ b/share/mk/bsd.snmpmod.mk @@ -12,9 +12,14 @@ GENSNMPTREEFLAGS+= -I${SHAREDIR}/snmpdefs ${MOD}_oid.h: ${MOD}_tree.def ${EXTRAMIBDEFS} ${EXTRAMIBSYMS} cat ${.ALLSRC} | gensnmptree ${GENSNMPTREEFLAGS} -e ${XSYM} > ${.TARGET} -.ORDER: ${MOD}_tree.c ${MOD}_tree.h -${MOD}_tree.h: .NOMETA -${MOD}_tree.c ${MOD}_tree.h: ${MOD}_tree.def ${EXTRAMIBDEFS} +# Multi-output targets both expect a .meta file and will fight over it. Only +# allow it on the .c file instead. +${MOD}_tree.h: ${MOD}_tree.c .NOMETA +# Force rebuild the .c file if any of its other outputs are missing. +.if !exists(${MOD}_tree.h) +${MOD}_tree.c: .PHONY .META +.endif +${MOD}_tree.c: ${MOD}_tree.def ${EXTRAMIBDEFS} cat ${.ALLSRC} | gensnmptree -f ${GENSNMPTREEFLAGS} -p ${MOD}_ .if defined(DEFS)