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