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