xref: /titanic_44/usr/src/cmd/ipf/tools/Makefile.tools (revision 94bdecd9e84ae1042607002db3e64a6849da5874)
1#
2# CDDL HEADER START
3#
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.
7#
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.
12#
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]
18#
19# CDDL HEADER END
20#
21#
22# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
26#
27# Copyright (c) 2012, Joyent Inc. All rights reserved.
28#
29
30PROG=		ipf ipfs ipmon ipnat ippool ipfstat
31IPFPROG=	ipftest
32
33IPF_OBJS=	ipf.o ipfcomp.o ipfzone.o ipf_y.o ipf_l.o
34IPFS_OBJS=	ipfs.o ipfzone.o
35IPFSTAT_OBJS=	ipfstat.o ipfzone.o
36IPMON_OBJS=	ipmon.o ipfzone.o ipmon_y.o ipmon_l.o
37IPNAT_OBJS=	ipnat.o ipfzone.o ipnat_y.o ipnat_l.o
38IPPOOL_OBJS=	ippool.o ipfzone.o ippool_y.o ippool_l.o
39IPFTEST_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 \
44		ipf_y.o ipf_l.o \
45		ipnat_y.o ipnat_l.o \
46		ippool_y.o ippool_l.o \
47		ip_pool.o radix.o
48
49OBJS=		$(IPF_OBJS) $(IPFS_OBJS) $(IPFSTAT_OBJS) \
50		$(IPMON_OBJS) $(IPNAT_OBJS) $(IPPOOL_OBJS) $(IPFTEST_OBJS)
51
52OBJSL=		$(IPF_OBJS) $(IPFS_OBJS) $(IPFSTAT_OBJS) \
53		$(IPMON_OBJS) $(IPNAT_OBJS)
54
55SRCS=		$(OBJSL:%.o=../%.c)
56
57include ../../../Makefile.cmd
58include ../../Makefile.ipf
59
60LDLIBS		+= $(LIBBPF)
61LDFLAGS		+= $(MAPFILE.NGB:%=-M%)
62
63CPPFLAGS	+= -I. -DIPFILTER_LOOKUP -DIPFILTER_LOG
64
65ipfstat.o	:=	CPPFLAGS += -DSTATETOP
66ipfstat		:=	LDLIBS += -lcurses
67
68ipf		:=	LDLIBS += -lsocket -lnsl
69ipftest		:=	LDLIBS += -lsocket -lnsl -lmd
70ipfstat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
71ipmon		:=	LDLIBS += -lsocket -lnsl
72ipnat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
73ippool		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
74
75CLEANFILES	+= $(OBJS)
76CLOBBERFILES	+= $(IPFPROG)
77
78ROOTIPF=	$(ROOTLIB)/ipf
79ROOTIPF32=	$(ROOTIPF)/$(MACH32)
80ROOTIPF64=	$(ROOTIPF)/$(MACH64)
81
82ROOTIPFPROG32=	$(IPFPROG:%=$(ROOTIPF32)/%)
83ROOTIPFPROG64=	$(IPFPROG:%=$(ROOTIPF64)/%)
84
85ROOTIPFLINKS=		$(IPFPROG:%=$(ROOTIPF)/%)
86ROOTUSRSBINLINKS=	$(PROG:%=$(ROOTUSRSBIN)/%)
87
88all:
89
90$(ROOTIPF32):
91	$(INS.dir)
92
93$(ROOTIPF64):
94	$(INS.dir)
95
96$(ROOTIPF)/%: %
97	$(INS.file)
98
99$(ROOTIPF32)/%: %
100	$(INS.file)
101
102$(ROOTIPF64)/%: %
103	$(INS.file)
104
105$(ROOTUSRSBINLINKS): FRC
106	-$(RM) $@; $(LN) $(ISAEXEC) $@
107
108$(ROOTIPFLINKS): FRC
109	-$(RM) $@; $(LN) $(ISAEXEC) $@
110
111
112.KEEP_STATE:
113
114ipf:	$(IPF_OBJS) $(LIBIPF) $(MAPFILE.NGB)
115	$(LINK.c) -o ipf $(IPF_OBJS) $(LDLIBS)
116	$(POST_PROCESS)
117
118ipf_y.o: ../ipf_y.c $(COMMONIPF)/netinet/ip_fil.h $(COMMONIPF)/ipf.h \
119	../ipf_y.c ../ipf_l.h
120
121../ipf_y.c ../ipf_y.h: ../ipf_y.y
122	$(YACC) -d -b ipf ../ipf_y.y
123	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.c/' \
124	   ipf.tab.c > ../ipf_y.c
125	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
126	   ipf.tab.h > ../ipf_y.h
127
128CLEANFILES += ipf.tab.c ipf.tab.h
129CLEANFILES += ../ipf_y.c ../ipf_y.h
130
131ipf_l.o: ../ipf_l.c $(COMMONIPF)/netinet/ip_fil.h $(COMMONIPF)/ipf.h  \
132	 ../ipf_y.h ../ipf_l.h
133	$(COMPILE.c) ../ipf_l.c -o $@
134
135../ipf_l.c: ../lexer.c $(COMMONIPF)/ipf.h $(COMMONIPF)/netinet/ip_fil.h
136	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
137	       -e 's/lexer.h/ipf_l.h/' ../lexer.c > $@
138
139../ipf_l.h: ../lexer.h
140	sed -e 's/yy/ipf_yy/g' ../lexer.h > $@
141
142CLEANFILES += ../ipf_l.c ../ipf_l.h
143
144
145ipfs:	$(IPFS_OBJS)
146	$(LINK.c) -o ipfs $(IPFS_OBJS) $(LDLIBS)
147	$(POST_PROCESS)
148
149ipfstat:	$(IPFSTAT_OBJS) $(MAPFILE.NGB)
150	$(LINK.c) -o ipfstat $(IPFSTAT_OBJS) $(LDLIBS)
151	$(POST_PROCESS)
152
153ipmon:	$(IPMON_OBJS) $(LIBIPF) $(MAPFILE.NGB)
154	$(LINK.c) -o ipmon $(IPMON_OBJS) $(LDLIBS)
155	$(POST_PROCESS)
156
157ipmon_y.o: ../ipmon_y.c $(COMMONIPF)/ipmon.h \
158	../ipmon_y.h ../ipmon_l.h
159
160../ipmon_y.c ../ipmon_y.h: ../ipmon_y.y
161	$(YACC) -d -b ipmon ../ipmon_y.y
162	sed -e 's/yy/ipmon_yy/g' \
163	    -e 's/extern [a-z]* .*();//' \
164	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
165	   ipmon.tab.c > ../ipmon_y.c
166	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
167	   ipmon.tab.h > ../ipmon_y.h
168
169CLEANFILES += ipmon.tab.c ipmon.tab.h
170CLEANFILES += ../ipmon_y.c ../ipmon_y.h
171
172ipmon_l.o: ../ipmon_l.c $(COMMONIPF)/ipmon.h ../ipmon_y.h ../ipmon_l.h
173	$(COMPILE.c) ../ipmon_l.c -o $@
174
175../ipmon_l.c: ../lexer.c $(COMMONIPF)/ipmon.h
176	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
177            -e 's/lexer.h/ipmon_l.h/' ../lexer.c > $@
178
179../ipmon_l.h: ../lexer.h
180	sed -e 's/yy/ipmon_yy/g' ../lexer.h > $@
181
182CLEANFILES += ../ipmon_l.c ../ipmon_l.h
183
184ipnat:	$(IPNAT_OBJS) $(LIBIPF) $(MAPFILE.NGB)
185	$(LINK.c) -o ipnat $(IPNAT_OBJS) $(LDLIBS)
186	$(POST_PROCESS)
187
188ipnat_y.o: ../ipnat_y.c $(COMMONIPF)/netinet/ip_nat.h \
189	../ipnat_y.h ../ipnat_l.h
190
191../ipnat_y.c ../ipnat_y.h: ../ipnat_y.y
192	$(YACC) -d -b ipnat ../ipnat_y.y
193	sed -e 's/yy/ipnat_yy/g' \
194	    -e 's/extern [a-z]* .*();//' \
195	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
196	   ipnat.tab.c > ../ipnat_y.c
197	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
198	   ipnat.tab.h > ../ipnat_y.h
199
200CLEANFILES += ipnat.tab.c ipnat.tab.h
201CLEANFILES += ../ipnat_y.c ../ipnat_y.h
202
203ipnat_l.o: ../ipnat_l.c $(COMMONIPF)/netinet/ip_nat.h ../ipnat_l.h
204	$(COMPILE.c) ../ipnat_l.c -o $@
205
206../ipnat_l.c: ../lexer.c $(COMMONIPF)/netinet/ip_nat.h
207	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
208	       -e 's/lexer.h/ipnat_l.h/' ../lexer.c > $@
209
210../ipnat_l.h: ../lexer.h
211	sed -e 's/yy/ipnat_yy/g' ../lexer.h > $@
212
213CLEANFILES += ../ipnat_l.c ../ipnat_l.h
214
215ippool:	$(IPPOOL_OBJS) $(LIBIPF) $(MAPFILE.NGB)
216	$(LINK.c) -o ippool $(IPPOOL_OBJS) $(LDLIBS)
217	$(POST_PROCESS)
218
219ippool_y.o: ../ippool_y.c $(COMMONIPF)/netinet/ip_pool.h \
220	../ippool_y.h ../ippool_l.h
221
222../ippool_y.c ../ippool_y.h: ../ippool_y.y
223	$(YACC) -d -b ippool ../ippool_y.y
224	sed -e 's/yy/ippool_yy/g' \
225	    -e 's/extern [a-z]* .*();//' \
226	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
227	   ippool.tab.c > ../ippool_y.c
228	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
229	   ippool.tab.h > ../ippool_y.h
230
231CLEANFILES += ippool.tab.c ippool.tab.h
232CLEANFILES += ../ippool_y.c ../ippool_y.h
233
234ippool_l.o: ../ippool_l.c $(COMMONIPF)/netinet/ip_pool.h ../ippool_l.h
235	$(COMPILE.c) ../ippool_l.c -o $@
236
237../ippool_l.c: ../lexer.c $(COMMONIPF)/netinet/ip_pool.h
238	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
239	       -e 's/lexer.h/ippool_l.h/' ../lexer.c > $@
240
241../ippool_l.h: ../lexer.h
242	sed -e 's/yy/ippool_yy/g' ../lexer.h > $@
243
244CLEANFILES += ../ippool_l.c ../ippool_l.h
245
246ipftest:	$(IPFTEST_OBJS) $(LIBIPF) $(MAPFILE.NGB)
247	$(LINK.c) $(ZIGNORE) -o ipftest $(IPFTEST_OBJS) $(LDLIBS)
248	$(POST_PROCESS)
249
250clean:
251	-$(RM) $(CLEANFILES)
252
253lint: 	lint_SRCS
254
255#
256# NOTE: all rules must use relative paths otherwise absolute paths will be
257#       embedded into the binaries making them false positives and
258#       reported by wsdiff
259#
260
261%.o:	../../../../uts/common/inet/ipf/%.c
262	$(COMPILE.c) $<
263
264%.o:	../%.c
265	$(COMPILE.c) $<
266
267%.o:	../../../../common/net/patricia/%.c
268	$(COMPILE.c) $<
269
270include ../../../Makefile.targ
271
272FRC:
273