xref: /netbsd-src/external/bsd/ipf/bin/ipftest/Makefile (revision 8e7ba7d8077e8940afcab595fafaff18f3df3317)
1#	$NetBSD: Makefile,v 1.9 2023/08/16 03:33:52 mrg Exp $
2
3.include <bsd.own.mk>
4
5PROG=		ipftest
6SRCS=		ipftest.c fil.c ip_frag.c ip_state.c ip_nat.c ip_nat6.c \
7		ip_proxy.c ip_auth.c ip_htable.c ip_lookup.c \
8		ip_dstlist.c ip_pool.c ip_sync.c \
9		ip_fil.c ip_log.c ippool_y.c ippool_l.c ipf_y.c \
10		ipf_l.c ipnat_y.c ipnat_l.c radix_ipf.c bpf_filter.c
11MAN=		ipftest.1
12
13CPPFLAGS+=	-DIPFILTER_LOG -DIPFILTER_LOOKUP \
14		-DIPFILTER_SYNC -DIPFILTER_CKSUM \
15		-I. -D_KERNTYPES
16
17COPTS.radix.c=	-Wno-error
18COPTS+=		-fno-strict-aliasing
19
20.PATH:		${NETBSDSRCDIR}/sys/external/bsd/ipf/netinet
21
22DPSRCS+=	ipnat_l.h ipnat_y.h ippool_l.h ippool_y.h ipf_l.h ipf_y.h
23
24CLEANFILES+=	ipf_y.c ipf_y.h
25CLEANFILES+=	ipf_l.c ipf_l.h
26CLEANFILES+=	ipf.tab.c ipf.tab.h
27CLEANFILES+=	ipnat_y.c ipnat_y.h
28CLEANFILES+=	ipnat_l.c ipnat_l.h
29CLEANFILES+=	ipnat.tab.c ipnat.tab.h
30CLEANFILES+=	ippool_y.c ippool_y.h
31CLEANFILES+=	ippool_l.c ippool_l.h
32CLEANFILES+=	ippool.tab.c ippool.tab.h
33
34ipnat_y.c: ipnat_y.y
35	${_MKTARGET_CREATE}
36	${YACC} -b ipnat -d ${.ALLSRC}
37	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
38	    -e 's/y.tab.c/ipnat_y.c/' \
39	    -e s/\"ipnat_y.y\"/\"..\\/tools\\/ipnat_y.y\"/ \
40	    ipnat.tab.c > ${.TARGET}
41	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
42	    -e 's/y.tab.h/ipnat_y.h/' \
43	    ipnat.tab.h > ${.TARGET:.c=.h}
44
45ipnat_y.h: ipnat_y.c
46
47ipnat_l.c: lexer.c
48	${_MKTARGET_CREATE}
49	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
50	    -e 's/y.tab.h/ipnat_y.h/' \
51	    -e 's/lexer.h/ipnat_l.h/' \
52	    ${.ALLSRC} > ${.TARGET}
53
54ipnat_l.h: lexer.h
55	${_MKTARGET_CREATE}
56	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
57	    ${.ALLSRC} > ${.TARGET}
58
59ippool_y.c: ippool_y.y
60	${_MKTARGET_CREATE}
61	${YACC} -b ippool -d ${.ALLSRC}
62	${TOOL_SED} -e 's/yy/ippool_yy/g' \
63	    -e 's/"ippool_y.y"/"..\/tools\/ippool_y.y"/' \
64	    ippool.tab.c > ${.TARGET}
65	${TOOL_SED} -e 's/yy/ippool_yy/g' \
66	    ippool.tab.h > ${.TARGET:.c=.h}
67
68ippool_y.h: ippool_y.c
69
70ippool_l.c: lexer.c
71	${_MKTARGET_CREATE}
72	${TOOL_SED} -e 's/yy/ippool_yy/g' \
73	    -e 's/y.tab.h/ippool_y.h/' \
74	    -e 's/lexer.h/ippool_l.h/' \
75	    ${.ALLSRC} > ${.TARGET}
76
77ippool_l.h: lexer.h
78	${_MKTARGET_CREATE}
79	${TOOL_SED} -e 's/yy/ippool_yy/g' \
80	    ${.ALLSRC} > ${.TARGET}
81
82ipf_y.c: ipf_y.y
83	${_MKTARGET_CREATE}
84	${YACC} -b ipf -d ${.ALLSRC}
85	${TOOL_SED} -e 's/yy/ipf_yy/g' \
86	    -e 's/"ipf_y.y"/"..\/tools\/ipf_y.y"/' \
87		ipf.tab.c > ${.TARGET}
88	${TOOL_SED} -e 's/yy/ipf_yy/g' \
89		ipf.tab.h > ${.TARGET:.c=.h}
90
91ipf_y.h: ipf_y.c
92
93ipf_l.c: lexer.c
94	${_MKTARGET_CREATE}
95	${TOOL_SED} -e 's/yy/ipf_yy/g' \
96	     -e 's/y.tab.h/ipf_y.h/' \
97	     -e 's/lexer.h/ipf_l.h/' \
98	    ${.ALLSRC} > ${.TARGET}
99
100ipf_l.h: lexer.h
101	${_MKTARGET_CREATE}
102	${TOOL_SED} -e 's/yy/ipf_yy/g' \
103	    ${.ALLSRC} > ${.TARGET}
104
105# Ugh. Generates too large offsets with -O2.
106.if defined(HAVE_GCC) && ${HAVE_GCC} >= 7 && ${ACTIVE_CC} == "gcc"
107. if ${MACHINE_CPU} == "m68k" && empty(CFLAGS:M-O0)
108COPTS.ipf_y.c+=	-O1
109. endif
110.endif
111
112COPTS.fil.c+=	${CC_WNO_STRINGOP_OVERFLOW}
113
114# XXXGCC12 this seems wrong; all paths would end up with ref > 1.
115.if defined(HAVE_GCC) && ${HAVE_GCC} >= 12 && ${ACTIVE_CC} == "gcc"
116COPTS.ip_proxy.c+=	-Wno-use-after-free
117.endif
118
119.include <bsd.prog.mk>
120