xref: /titanic_41/usr/src/cmd/ipf/tools/Makefile.tools (revision e8fb11a1575b42dcd5c49341c588d9f6cd636135)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27#
28
29PROG=		ipf ipfs ipmon ipnat ippool ipfstat
30IPFPROG=	ipftest
31
32IPF_OBJS=	ipf.o ipfcomp.o ipf_y.o ipf_l.o
33IPFS_OBJS=	ipfs.o
34IPFSTAT_OBJS=	ipfstat.o
35IPMON_OBJS=	ipmon.o ipmon_y.o ipmon_l.o
36IPNAT_OBJS=	ipnat.o ipnat_y.o ipnat_l.o
37IPPOOL_OBJS=	ippool.o ippool_y.o ippool_l.o
38IPFTEST_OBJS=	ipftest.o  \
39		ip_fil.o ip_state.o \
40		ip_frag.o ip_nat.o fil.o \
41		ip_htable.o ip_lookup.o \
42		ip_proxy.o ip_auth.o ip_log.o \
43		ipf_y.o ipf_l.o \
44		ipnat_y.o ipnat_l.o \
45		ippool_y.o ippool_l.o \
46		ip_pool.o radix.o
47
48OBJS=		$(IPF_OBJS) $(IPFS_OBJS) $(IPFSTAT_OBJS) \
49		$(IPMON_OBJS) $(IPNAT_OBJS) $(IPFTEST_OBJS)
50
51OBJSL=		$(IPF_OBJS) $(IPFS_OBJS) $(IPFSTAT_OBJS) \
52		$(IPMON_OBJS) $(IPNAT_OBJS)
53
54SRCS=		$(OBJSL:%.o=../%.c)
55
56include ../../../Makefile.cmd
57include ../../Makefile.ipf
58
59LDLIBS		+= $(LIBBPF)
60
61CPPFLAGS	+= -I. -DIPFILTER_LOOKUP -DIPFILTER_LOG
62
63ipfstat.o	:=	CPPFLAGS += -DSTATETOP
64ipfstat		:=	LDLIBS += -lcurses
65
66ipf		:=	LDLIBS += -lsocket -lnsl
67ipftest		:=	LDLIBS += -lsocket -lnsl -lmd
68ipfstat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
69ipmon		:=	LDLIBS += -lsocket -lnsl
70ipnat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
71ippool		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
72
73CLEANFILES	+= $(OBJS)
74
75ROOTIPF=	$(ROOTLIB)/ipf
76ROOTIPF32=	$(ROOTIPF)/$(MACH32)
77ROOTIPF64=	$(ROOTIPF)/$(MACH64)
78
79ROOTIPFPROG32=	$(IPFPROG:%=$(ROOTIPF32)/%)
80ROOTIPFPROG64=	$(IPFPROG:%=$(ROOTIPF64)/%)
81
82ROOTIPFLINKS=		$(IPFPROG:%=$(ROOTIPF)/%)
83ROOTUSRSBINLINKS=	$(PROG:%=$(ROOTUSRSBIN)/%)
84
85$(ROOTIPF32):
86	$(INS.dir)
87
88$(ROOTIPF64):
89	$(INS.dir)
90
91$(ROOTIPF)/%: %
92	$(INS.file)
93
94$(ROOTIPF32)/%: %
95	$(INS.file)
96
97$(ROOTIPF64)/%: %
98	$(INS.file)
99
100$(ROOTUSRSBINLINKS): FRC
101	-$(RM) $@; $(LN) $(ISAEXEC) $@
102
103$(ROOTIPFLINKS): FRC
104	-$(RM) $@; $(LN) $(ISAEXEC) $@
105
106
107.KEEP_STATE:
108
109ipf:	$(IPF_OBJS) $(LIBIPF)
110	$(LINK.c) -o ipf $(IPF_OBJS) $(LDLIBS)
111	$(POST_PROCESS)
112
113ipf_y.o: ../ipf_y.c $(COMMONIPF)/netinet/ip_fil.h $(COMMONIPF)/ipf.h \
114	../ipf_y.c ../ipf_l.h
115
116../ipf_y.c ../ipf_y.h: ../ipf_y.y
117	$(YACC) -d -b ipf ../ipf_y.y
118	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.c/' \
119	   ipf.tab.c > ../ipf_y.c
120	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
121	   ipf.tab.h > ../ipf_y.h
122
123ipf_l.o: ../ipf_l.c $(COMMONIPF)/netinet/ip_fil.h $(COMMONIPF)/ipf.h  \
124	 ../ipf_y.h ../ipf_l.h
125	$(COMPILE.c) ../ipf_l.c -o $@
126
127../ipf_l.c: ../lexer.c $(COMMONIPF)/ipf.h $(COMMONIPF)/netinet/ip_fil.h
128	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
129	       -e 's/lexer.h/ipf_l.h/' ../lexer.c > $@
130
131../ipf_l.h: ../lexer.h
132	sed -e 's/yy/ipf_yy/g' ../lexer.h > $@
133
134ipfs:	$(IPFS_OBJS)
135	$(LINK.c) -o ipfs $(IPFS_OBJS) $(LDLIBS)
136	$(POST_PROCESS)
137
138ipfstat:	$(IPFSTAT_OBJS)
139	$(LINK.c) -o ipfstat $(IPFSTAT_OBJS) $(LDLIBS)
140	$(POST_PROCESS)
141
142ipmon:	$(IPMON_OBJS) $(LIBIPF)
143	$(LINK.c) -o ipmon $(IPMON_OBJS) $(LDLIBS)
144	$(POST_PROCESS)
145
146ipmon_y.o: ../ipmon_y.c $(COMMONIPF)/ipmon.h \
147	../ipmon_y.h ../ipmon_l.h
148
149../ipmon_y.c ../ipmon_y.h: ../ipmon_y.y
150	$(YACC) -d -b ipmon ../ipmon_y.y
151	sed -e 's/yy/ipmon_yy/g' \
152	    -e 's/extern [a-z]* .*();//' \
153	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
154	   ipmon.tab.c > ../ipmon_y.c
155	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
156	   ipmon.tab.h > ../ipmon_y.h
157
158ipmon_l.o: ../ipmon_l.c $(COMMONIPF)/ipmon.h ../ipmon_y.h ../ipmon_l.h
159	$(COMPILE.c) ../ipmon_l.c -o $@
160
161../ipmon_l.c: ../lexer.c $(COMMONIPF)/ipmon.h
162	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
163            -e 's/lexer.h/ipmon_l.h/' ../lexer.c > $@
164
165../ipmon_l.h: ../lexer.h
166	sed -e 's/yy/ipmon_yy/g' ../lexer.h > $@
167
168ipnat:	$(IPNAT_OBJS) $(LIBIPF)
169	$(LINK.c) -o ipnat $(IPNAT_OBJS) $(LDLIBS)
170	$(POST_PROCESS)
171
172ipnat_y.o: ../ipnat_y.c $(COMMONIPF)/netinet/ip_nat.h \
173	../ipnat_y.h ../ipnat_l.h
174
175../ipnat_y.c ../ipnat_y.h: ../ipnat_y.y
176	$(YACC) -d -b ipnat ../ipnat_y.y
177	sed -e 's/yy/ipnat_yy/g' \
178	    -e 's/extern [a-z]* .*();//' \
179	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
180	   ipnat.tab.c > ../ipnat_y.c
181	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
182	   ipnat.tab.h > ../ipnat_y.h
183
184ipnat_l.o: ../ipnat_l.c $(COMMONIPF)/netinet/ip_nat.h ../ipnat_l.h
185	$(COMPILE.c) ../ipnat_l.c -o $@
186
187../ipnat_l.c: ../lexer.c $(COMMONIPF)/netinet/ip_nat.h
188	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
189	       -e 's/lexer.h/ipnat_l.h/' ../lexer.c > $@
190
191../ipnat_l.h: ../lexer.h
192	sed -e 's/yy/ipnat_yy/g' ../lexer.h > $@
193
194ippool:	$(IPPOOL_OBJS) $(LIBIPF)
195	$(LINK.c) -o ippool $(IPPOOL_OBJS) $(LDLIBS)
196	$(POST_PROCESS)
197
198ippool_y.o: ../ippool_y.c $(COMMONIPF)/netinet/ip_pool.h \
199	../ippool_y.h ../ippool_l.h
200
201../ippool_y.c ../ippool_y.h: ../ippool_y.y
202	$(YACC) -d -b ippool ../ippool_y.y
203	sed -e 's/yy/ippool_yy/g' \
204	    -e 's/extern [a-z]* .*();//' \
205	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
206	   ippool.tab.c > ../ippool_y.c
207	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
208	   ippool.tab.h > ../ippool_y.h
209
210ippool_l.o: ../ippool_l.c $(COMMONIPF)/netinet/ip_pool.h ../ippool_l.h
211	$(COMPILE.c) ../ippool_l.c -o $@
212
213../ippool_l.c: ../lexer.c $(COMMONIPF)/netinet/ip_pool.h
214	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
215	       -e 's/lexer.h/ippool_l.h/' ../lexer.c > $@
216
217../ippool_l.h: ../lexer.h
218	sed -e 's/yy/ippool_yy/g' ../lexer.h > $@
219
220ipftest:	$(IPFTEST_OBJS) $(LIBIPF)
221	$(LINK.c) -zignore -o ipftest $(IPFTEST_OBJS) $(LDLIBS)
222	$(POST_PROCESS)
223
224clean:
225	-$(RM) $(CLEANFILES)
226
227lint: 	lint_SRCS
228
229%.o:	$(SRC)/uts/common/inet/ipf/%.c
230	$(COMPILE.c) $<
231
232%.o:	../%.c
233	$(COMPILE.c) $<
234
235%.o:	$(SRC)/common/net/patricia/%.c
236	$(COMPILE.c) $<
237
238include ../../../Makefile.targ
239
240FRC:
241