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
13 # Please send copies of changes and bug-fixes to:
17 # this file contains rules to DTRT when SRCS contains foo.y or foo.c
18 # when only a foo.y exists.
24 YACC.y?
= ${YACC} ${YFLAGS}
26 .if
${YACC.y
:M-d
} == "" || defined
(NO_RENAME_Y_TAB_H
)
30 [ ! -s y.tab.c
] || mv y.tab.c
${.TARGET
}
35 # the touch of the .c is to ensure it is newer than .h (paranoia)
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
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,
47 .y.c
: ${.TARGET
:T
:R
}.h
48 [ -s
${.TARGET
} ] ||
{ \
49 ${YACC.y
} ${.IMPSRC
} && \
50 { [ ! -s y.tab.c
] || mv y.tab.c
${.TARGET
}; \
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
]