4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
25 # Copyright 2013 Nexenta Systems, Inc. All rights reserved.
27 # Copyright (c) 2012, Joyent Inc. All rights reserved.
30 PROG= ipf ipfs ipmon ipnat ippool ipfstat
33 IPF_OBJS= ipf.o ipfcomp.o ipfzone.o ipf_y.o ipf_l.o
34 IPFS_OBJS= ipfs.o ipfzone.o
35 IPFSTAT_OBJS= ipfstat.o ipfzone.o
36 IPMON_OBJS= ipmon.o ipfzone.o ipmon_y.o ipmon_l.o
37 IPNAT_OBJS= ipnat.o ipfzone.o ipnat_y.o ipnat_l.o
38 IPPOOL_OBJS= ippool.o ipfzone.o ippool_y.o ippool_l.o
39 IPFTEST_OBJS= ipftest.o ipfzone.o \
40 ip_fil.o ip_state.o ip_compat.o \
41 ip_frag.o ip_nat.o ip_nat6.o fil.o \
42 ip_htable.o ip_lookup.o \
43 ip_proxy.o ip_auth.o ip_log.o \
46 ippool_y.o ippool_l.o \
49 OBJS= $(IPF_OBJS) $(IPFS_OBJS) $(IPFSTAT_OBJS) \
50 $(IPMON_OBJS) $(IPNAT_OBJS) $(IPPOOL_OBJS) $(IPFTEST_OBJS)
52 OBJSL= $(IPF_OBJS) $(IPFS_OBJS) $(IPFSTAT_OBJS) \
53 $(IPMON_OBJS) $(IPNAT_OBJS)
55 SRCS= $(OBJSL:%.o=../%.c)
57 include ../../../Makefile.cmd
58 include ../../Makefile.ipf
62 CPPFLAGS += -I. -DIPFILTER_LOOKUP -DIPFILTER_LOG
64 ipfstat.o := CPPFLAGS += -DSTATETOP
65 ipfstat := LDLIBS += -lncurses
67 ipftest := LDLIBS += -lmd
68 ipfstat := LDLIBS += -lkvm -lelf
69 ipnat := LDLIBS += -lkvm -lelf
70 ippool := LDLIBS += -lkvm -lelf
73 CLOBBERFILES += $(IPFPROG)
75 ROOTIPF= $(ROOTLIB64)/ipf
76 ROOTIPF32= $(ROOTIPF)/$(MACH32)
77 ROOTIPF64= $(ROOTIPF)/$(MACH64)
79 ROOTIPFPROG32= $(IPFPROG:%=$(ROOTIPF32)/%)
80 ROOTIPFPROG64= $(IPFPROG:%=$(ROOTIPF64)/%)
82 ROOTIPFLINKS= $(IPFPROG:%=$(ROOTIPF)/%)
83 ROOTUSRSBINLINKS= $(PROG:%=$(ROOTUSRSBIN)/%)
102 $(ROOTUSRSBINLINKS): FRC
103 -$(RM) $@; $(LN) $(ISAEXEC) $@
106 -$(RM) $@; $(LN) $(ISAEXEC) $@
111 ipf: $(IPF_OBJS) $(LIBIPF)
112 $(LINK.c) -o ipf $(IPF_OBJS) $(LDLIBS)
115 ipf_y.o: ../ipf_y.c $(SRCTOP)/include/netinet/ip_fil.h $(COMMONIPF)/ipf.h \
116 ../ipf_y.c ../ipf_l.h
118 ../ipf_y.c ../ipf_y.h: ../ipf_y.y
119 $(YACC) -d -b ipf ../ipf_y.y
120 sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.c/' \
121 ipf.tab.c > ../ipf_y.c
122 sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
123 ipf.tab.h > ../ipf_y.h
125 CLEANFILES += ipf.tab.c ipf.tab.h
126 CLEANFILES += ../ipf_y.c ../ipf_y.h
128 ipf_l.o: ../ipf_l.c $(SRCTOP)/include/netinet/ip_fil.h $(COMMONIPF)/ipf.h \
129 ../ipf_y.h ../ipf_l.h
130 $(COMPILE.c) ../ipf_l.c -o $@
132 ../ipf_l.c: ../lexer.c $(COMMONIPF)/ipf.h $(SRCTOP)/include/netinet/ip_fil.h
133 sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
134 -e 's/lexer.h/ipf_l.h/' ../lexer.c > $@
136 ../ipf_l.h: ../lexer.h
137 sed -e 's/yy/ipf_yy/g' ../lexer.h > $@
139 CLEANFILES += ../ipf_l.c ../ipf_l.h
143 $(LINK.c) -o ipfs $(IPFS_OBJS) $(LDLIBS)
146 ipfstat: $(IPFSTAT_OBJS)
147 $(LINK.c) -o ipfstat $(IPFSTAT_OBJS) $(LDLIBS)
150 ipmon: $(IPMON_OBJS) $(LIBIPF)
151 $(LINK.c) -o ipmon $(IPMON_OBJS) $(LDLIBS)
154 ipmon_y.o: ../ipmon_y.c $(COMMONIPF)/ipmon.h \
155 ../ipmon_y.h ../ipmon_l.h
157 ../ipmon_y.c ../ipmon_y.h: ../ipmon_y.y
158 $(YACC) -d -b ipmon ../ipmon_y.y
159 sed -e 's/yy/ipmon_yy/g' \
160 -e 's/extern [a-z]* .*();//' \
161 -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
162 ipmon.tab.c > ../ipmon_y.c
163 sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
164 ipmon.tab.h > ../ipmon_y.h
166 CLEANFILES += ipmon.tab.c ipmon.tab.h
167 CLEANFILES += ../ipmon_y.c ../ipmon_y.h
169 ipmon_l.o: ../ipmon_l.c $(COMMONIPF)/ipmon.h ../ipmon_y.h ../ipmon_l.h
170 $(COMPILE.c) ../ipmon_l.c -o $@
172 ../ipmon_l.c: ../lexer.c $(COMMONIPF)/ipmon.h
173 sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
174 -e 's/lexer.h/ipmon_l.h/' ../lexer.c > $@
176 ../ipmon_l.h: ../lexer.h
177 sed -e 's/yy/ipmon_yy/g' ../lexer.h > $@
179 CLEANFILES += ../ipmon_l.c ../ipmon_l.h
181 ipnat: $(IPNAT_OBJS) $(LIBIPF)
182 $(LINK.c) -o ipnat $(IPNAT_OBJS) $(LDLIBS)
185 ipnat_y.o: ../ipnat_y.c $(SRCTOP)/include/netinet/ip_nat.h \
186 ../ipnat_y.h ../ipnat_l.h
188 ../ipnat_y.c ../ipnat_y.h: ../ipnat_y.y
189 $(YACC) -d -b ipnat ../ipnat_y.y
190 sed -e 's/yy/ipnat_yy/g' \
191 -e 's/extern [a-z]* .*();//' \
192 -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
193 ipnat.tab.c > ../ipnat_y.c
194 sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
195 ipnat.tab.h > ../ipnat_y.h
197 CLEANFILES += ipnat.tab.c ipnat.tab.h
198 CLEANFILES += ../ipnat_y.c ../ipnat_y.h
200 ipnat_l.o: ../ipnat_l.c $(SRCTOP)/include/netinet/ip_nat.h ../ipnat_l.h
201 $(COMPILE.c) ../ipnat_l.c -o $@
203 ../ipnat_l.c: ../lexer.c $(SRCTOP)/include/netinet/ip_nat.h
204 sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
205 -e 's/lexer.h/ipnat_l.h/' ../lexer.c > $@
207 ../ipnat_l.h: ../lexer.h
208 sed -e 's/yy/ipnat_yy/g' ../lexer.h > $@
210 CLEANFILES += ../ipnat_l.c ../ipnat_l.h
212 ippool: $(IPPOOL_OBJS) $(LIBIPF)
213 $(LINK.c) -o ippool $(IPPOOL_OBJS) $(LDLIBS)
216 ippool_y.o: ../ippool_y.c $(SRCTOP)/include/netinet/ip_pool.h \
217 ../ippool_y.h ../ippool_l.h
219 ../ippool_y.c ../ippool_y.h: ../ippool_y.y
220 $(YACC) -d -b ippool ../ippool_y.y
221 sed -e 's/yy/ippool_yy/g' \
222 -e 's/extern [a-z]* .*();//' \
223 -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
224 ippool.tab.c > ../ippool_y.c
225 sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
226 ippool.tab.h > ../ippool_y.h
228 CLEANFILES += ippool.tab.c ippool.tab.h
229 CLEANFILES += ../ippool_y.c ../ippool_y.h
231 ippool_l.o: ../ippool_l.c $(SRCTOP)/include/netinet/ip_pool.h ../ippool_l.h
232 $(COMPILE.c) ../ippool_l.c -o $@
234 ../ippool_l.c: ../lexer.c $(SRCTOP)/include/netinet/ip_pool.h
235 sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
236 -e 's/lexer.h/ippool_l.h/' ../lexer.c > $@
238 ../ippool_l.h: ../lexer.h
239 sed -e 's/yy/ippool_yy/g' ../lexer.h > $@
241 CLEANFILES += ../ippool_l.c ../ippool_l.h
243 ipftest: $(IPFTEST_OBJS) $(LIBIPF)
244 $(LINK.c) $(ZIGNORE) -o ipftest $(IPFTEST_OBJS) $(LDLIBS)
252 # NOTE: all rules must use relative paths otherwise absolute paths will be
253 # embedded into the binaries making them false positives and
257 %.o: $(SRCTOP)/kernel/net/ipf/%.c
263 %.o: ../../../../common/net/patricia/%.c
266 include ../../../Makefile.targ