Correct math and limerick.
[dragonfly.git] / contrib / bmake / mk / yacc.mk
blob910b004431df774b687dac788c556165be809fa2
1 # $Id: yacc.mk,v 1.6 2011/06/10 22:45:46 sjg Exp $
4 # @(#) Copyright (c) 1999-2011, Simon J. Gerraty
6 # This file is provided in the hope that it will
7 # be of use. There is absolutely NO WARRANTY.
8 # Permission to copy, redistribute or otherwise
9 # use this file is hereby granted provided that
10 # the above copyright notice and this notice are
11 # left intact.
13 # Please send copies of changes and bug-fixes to:
14 # sjg@crufty.net
17 # this file contains rules to DTRT when SRCS contains foo.y or foo.c
18 # when only a foo.y exists.
20 YACC?= yacc
21 YFLAGS?= -v -t
22 RM?= rm
24 YACC.y?= ${YACC} ${YFLAGS}
26 .if ${YACC.y:M-d} == "" || defined(NO_RENAME_Y_TAB_H)
28 .y.c:
29 ${YACC.y} ${.IMPSRC}
30 [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET}
31 ${RM} -f y.tab.[!h]
33 .else
35 # the touch of the .c is to ensure it is newer than .h (paranoia)
36 .y.h:
37 ${YACC.y} ${.IMPSRC}
38 [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET:T:R}.c
39 [ ! -s y.tab.h ] || cmp -s y.tab.h ${.TARGET:T:R}.h \
40 || mv y.tab.h ${.TARGET:T:R}.h
41 touch ${.TARGET:T:R}.c
42 ${RM} -f y.tab.*
44 # Normally the .y.h rule does the work - to avoid races.
45 # If for any reason the .c is lost but the .h remains,
46 # regenerate the .c
47 .y.c: ${.TARGET:T:R}.h
48 [ -s ${.TARGET} ] || { \
49 ${YACC.y} ${.IMPSRC} && \
50 { [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET}; \
51 ${RM} y.tab.*; }; }
52 .endif
54 beforedepend: ${SRCS:T:M*.y:S/.y/.c/g}
56 CLEANFILES+= ${SRCS:T:M*.y:S/.y/.[ch]/g}
57 CLEANFILES+= y.tab.[ch]