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