Subject: Re: sys.mk .y lossage [2]
To: None <tech-toolchain@NetBSD.ORG>
From: Todd Vierling <tv@NetBSD.ORG>
List: tech-toolchain
Date: 04/01/1998 13:20:55
On Wed, 1 Apr 1998, Todd Vierling wrote:

: - Set a NetBSD-specific flag, YHEADER, which when set to -d enables
:   cleaning of .y counterpart .h files and adds the .y.h rule, which
:   (as well as in .y.c) produces a .h file _with_the_same_basename_ as
:   the .c file.  If something _really_ wants it named "y.tab.h", it
:   should set CLEANFILES+=y.tab.h and YFLAGS=-d (and it won't clobber
:   filebasename.h).

Yes, I meant to say that this should go into <bsd.sys.mk>.  Here's the diffs
for the .mk files to implement all of this.  The changes to Makefiles around
the tree to ensure that these work are rather trivial, just mundane.

I propose this for inclusion into the tree barring objections before Friday
afternoon.  Otherwise, I'll shove them in (and all the related Makefile
changes to use these). 

Index: bsd.kmod.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.kmod.mk,v
retrieving revision 1.25
diff -u -r1.25 bsd.kmod.mk
--- bsd.kmod.mk	1998/04/01 16:58:33	1.25
+++ bsd.kmod.mk	1998/04/01 18:20:08
@@ -21,6 +21,9 @@
 
 DPSRCS+=	${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
 CLEANFILES+=	${DPSRCS}
+.if defined(YHEADER)
+CLEANFILES+=	${SRCS:M*.y:.y=.h}
+.endif
 
 OBJS+=		${SRCS:N*.h:N*.sh:R:S/$/.o/g}
 
Index: bsd.lib.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
retrieving revision 1.128
diff -u -r1.128 bsd.lib.mk
--- bsd.lib.mk	1998/04/01 16:58:33	1.128
+++ bsd.lib.mk	1998/04/01 18:20:08
@@ -209,6 +209,9 @@
 
 DPSRCS+=	${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
 CLEANFILES+=	${DPSRCS}
+.if defined(YHEADER)
+CLEANFILES+=	${SRCS:M*.y:.y=.h}
+.endif
 
 OBJS+=		${SRCS:N*.h:N*.sh:R:S/$/.o/g}
 lib${LIB}.a:: ${OBJS} __archivebuild
Index: bsd.prog.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.prog.mk,v
retrieving revision 1.92
diff -u -r1.92 bsd.prog.mk
--- bsd.prog.mk	1998/04/01 16:58:33	1.92
+++ bsd.prog.mk	1998/04/01 18:20:09
@@ -87,6 +87,9 @@
 
 DPSRCS+=	${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
 CLEANFILES+=	${DPSRCS}
+.if defined(YHEADER)
+CLEANFILES+=	${SRCS:M*.y:.y=.h}
+.endif
 
 .if !empty(SRCS:N*.h:N*.sh)
 OBJS+=		${SRCS:N*.h:N*.sh:R:S/$/.o/g}
Index: bsd.sys.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.sys.mk,v
retrieving revision 1.18
diff -u -r1.18 bsd.sys.mk
--- bsd.sys.mk	1998/04/01 16:58:33	1.18
+++ bsd.sys.mk	1998/04/01 18:20:09
@@ -11,6 +11,10 @@
 CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include
 .endif
 
+.if defined(YHEADER)
+YFLAGS+= -d
+.endif
+
 # Helpers for cross-compiling
 HOST_CC?=	cc
 HOST_CFLAGS?=	-O
@@ -36,8 +40,8 @@
 	${COMPILE.m} ${.IMPSRC}
 
 
-.if defined(PARALLEL)
 # Lex
+.if defined(PARALLEL)
 .l:
 	${LEX.l} -o${.TARGET:R}.yy.c ${.IMPSRC}
 	${LINK.c} -o ${.TARGET} ${.TARGET:R}.yy.c ${LDLIBS} -ll
@@ -48,8 +52,23 @@
 	${LEX.l} -o${.TARGET:R}.yy.c ${.IMPSRC}
 	${COMPILE.c} -o ${.TARGET} ${.TARGET:R}.yy.c 
 	rm -f ${.TARGET:R}.yy.c
+.endif
 
 # Yacc
+.if defined(YHEADER)
+.y:
+	${YACC.y} -b ${.TARGET:R} ${.IMPSRC}
+	${LINK.c} -o ${.TARGET} ${.TARGET:R}.tab.c ${LDLIBS}
+	rm -f ${.TARGET:R}.tab.c ${.TARGET:R}.tab.h
+.y.c .y.h:
+	${YACC.y} -b ${.TARGET:R} ${.IMPSRC}
+	mv ${.TARGET:R}.tab.c ${.TARGET:R}.c
+	mv ${.TARGET:R}.tab.h ${.TARGET:R}.h
+.y.o:
+	${YACC.y} -b ${.TARGET:R} ${.IMPSRC}
+	${COMPILE.c} -o ${.TARGET} ${.TARGET:R}.tab.c
+	rm -f ${.TARGET:R}.tab.c ${.TARGET:R}.tab.h
+.elif defined(PARALLEL)
 .y:
 	${YACC.y} -b ${.TARGET:R} ${.IMPSRC}
 	${LINK.c} -o ${.TARGET} ${.TARGET:R}.tab.c ${LDLIBS}
Index: sys.mk
===================================================================
RCS file: /cvsroot/src/share/mk/sys.mk,v
retrieving revision 1.39
diff -u -r1.39 sys.mk
--- sys.mk	1998/04/01 16:58:33	1.39
+++ sys.mk	1998/04/01 18:20:09
@@ -76,7 +76,6 @@
 TSORT?= 	tsort -q
 
 YACC?=		yacc
-YFLAGS?=	-d
 YACC.y?=	${YACC} ${YFLAGS}
 
 # C


-- 
-- Todd Vierling (Personal tv@pobox.com; Bus. todd_vierling@xn.xerox.com)