xref: /illumos-gate/usr/src/cmd/ipf/tools/Makefile (revision 33efde4275d24731ef87927237b0ffb0630b6b2d)
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# cmd/ipf/tools/Makefile
30#
31#
32
33include ../../Makefile.cmd
34include ../../Makefile.cmd.64
35include ../Makefile.ipf
36include ../../Makefile.ctf
37
38LICENCE= IPFILTER.LICENCE
39
40PROG=		ipf ipfs ipmon ipnat ippool ipfstat
41IPFPROG=	ipftest
42
43IPF_OBJS=	ipf.o ipfcomp.o ipfzone.o ipf_y.o ipf_l.o
44IPFS_OBJS=	ipfs.o ipfzone.o
45IPFSTAT_OBJS=	ipfstat.o ipfzone.o
46IPMON_OBJS=	ipmon.o ipfzone.o ipmon_y.o ipmon_l.o
47IPNAT_OBJS=	ipnat.o ipfzone.o ipnat_y.o ipnat_l.o
48IPPOOL_OBJS=	ippool.o ipfzone.o ippool_y.o ippool_l.o
49IPFTEST_OBJS=	ipftest.o ipfzone.o \
50		ip_fil.o ip_state.o ip_compat.o \
51		ip_frag.o ip_nat.o ip_nat6.o fil.o \
52		ip_htable.o ip_lookup.o \
53		ip_proxy.o ip_auth.o ip_log.o \
54		ipf_y.o ipf_l.o \
55		ipnat_y.o ipnat_l.o \
56		ippool_y.o ippool_l.o \
57		ip_pool.o radix.o
58
59USRLIBIPF=		$(ROOTLIB)/ipf
60USRLIBIPFLICENCE=	$(LICENCE:%=$(USRLIBIPF)/%)
61
62$(USRLIBIPFLICENCE):=FILEMODE= 0644
63
64CFLAGS += -D_ELF64
65LDLIBS += -L ../lib -lipf
66
67LDLIBS		+= $(LIBBPF)
68LDFLAGS		+= $(MAPFILE.NGB:%=-Wl,-M%)
69
70CPPFLAGS	+= -I. -DIPFILTER_LOOKUP -DIPFILTER_LOG
71
72ipfstat.o	:=	CPPFLAGS += -DSTATETOP
73ipfstat		:=	LDLIBS += -lcurses
74
75ipf		:=	LDLIBS += -lsocket -lnsl
76ipf		:=	OBJS += $(IPF_OBJS)
77ipfs		:=	OBJS += $(IPFS_OBJS)
78ipftest		:=	LDLIBS += -lsocket -lnsl -lmd
79ipftest		:=	OBJS += $(IPFTEST_OBJS)
80ipfstat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
81ipfstat		:=	OBJS += $(IPFSTAT_OBJS)
82ipmon		:=	LDLIBS += -lsocket -lnsl
83ipmon		:=	OBJS += $(IPMON_OBJS)
84ipnat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
85ipnat		:=	OBJS += $(IPNAT_OBJS)
86ippool		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
87ippool		:=	OBJS += $(IPPOOL_OBJS)
88
89# because of labels from yacc
90ipf_y.o		:= CERRWARN += -_gcc=-Wno-unused-label
91ipmon_y.o	:= CERRWARN += -_gcc=-Wno-unused-label
92ipnat_y.o	:= CERRWARN += -_gcc=-Wno-unused-label
93ippool_y.o	:= CERRWARN += -_gcc=-Wno-unused-label
94
95CLEANFILES	+= $(IPF_OBJS) $(IPFS_OBJS) $(IPFTEST_OBJS) $(IPFSTAT_OBJS)
96CLEANFILES	+= $(IPMON_OBJS) $(IPNAT_OBJS) $(IPPOOL_OBJS)
97CLOBBERFILES	+= $(IPFPROG)
98
99ROOTIPF=	$(ROOTLIB)/ipf
100
101ROOTIPFPROG=	$(IPFPROG:%=$(ROOTIPF)/%)
102
103.KEEP_STATE:
104
105all: $(PROG) $(IPFPROG)
106
107install: all install_local $(ROOTIPF) $(ROOTUSRSBINPROG) $(ROOTIPFPROG)
108
109$(USRLIBIPF):
110	$(INS.dir)
111
112$(USRLIBIPF)/% : %
113	$(INS.file)
114
115$(ROOTIPF)/%: %
116	$(INS.file)
117
118ipf:	$(IPF_OBJS) $(LIBIPF) $(MAPFILE.NGB)
119	$(LINK.c) -o ipf $(IPF_OBJS) $(LDLIBS)
120	$(POST_PROCESS)
121
122ipf_y.o: ipf_y.c $(COMMONIPF)/netinet/ip_fil.h $(COMMONIPF)/ipf.h \
123	ipf_y.c ipf_l.h
124
125ipf_y.c ipf_y.h: ipf_y.y
126	$(YACC) -d -b ipf ipf_y.y
127	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.c/' \
128	   ipf.tab.c > ipf_y.c
129	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
130	   ipf.tab.h > ipf_y.h
131
132CLEANFILES += ipf.tab.c ipf.tab.h
133CLEANFILES += ipf_y.c ipf_y.h
134
135ipf_l.o: ipf_l.c $(COMMONIPF)/netinet/ip_fil.h $(COMMONIPF)/ipf.h  \
136	 ipf_y.h ipf_l.h
137
138ipf_l.c: lexer.c $(COMMONIPF)/ipf.h $(COMMONIPF)/netinet/ip_fil.h
139	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
140	       -e 's/lexer.h/ipf_l.h/' lexer.c > $@
141
142ipf_l.h: lexer.h
143	sed -e 's/yy/ipf_yy/g' lexer.h > $@
144
145CLEANFILES += ipf_l.c ipf_l.h
146
147ipfs:	$(IPFS_OBJS)
148	$(LINK.c) -o ipfs $(IPFS_OBJS) $(LDLIBS)
149	$(POST_PROCESS)
150
151ipfstat:	$(IPFSTAT_OBJS) $(MAPFILE.NGB)
152	$(LINK.c) -o ipfstat $(IPFSTAT_OBJS) $(LDLIBS)
153	$(POST_PROCESS)
154
155ipmon:	$(IPMON_OBJS) $(LIBIPF) $(MAPFILE.NGB)
156	$(LINK.c) -o ipmon $(IPMON_OBJS) $(LDLIBS)
157	$(POST_PROCESS)
158
159ipmon_y.o: ipmon_y.c $(COMMONIPF)/ipmon.h ipmon_y.h ipmon_l.h
160
161ipmon_y.c ipmon_y.h: ipmon_y.y
162	$(YACC) -d -b ipmon ipmon_y.y
163	sed -e 's/yy/ipmon_yy/g' \
164	    -e 's/extern [a-z]* .*();//' \
165	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
166	   ipmon.tab.c > ipmon_y.c
167	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
168	   ipmon.tab.h > ipmon_y.h
169
170CLEANFILES += ipmon.tab.c ipmon.tab.h
171CLEANFILES += ipmon_y.c ipmon_y.h
172
173ipmon_l.o: ipmon_l.c $(COMMONIPF)/ipmon.h ipmon_y.h ipmon_l.h
174
175ipmon_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
179ipmon_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 ipnat_y.h ipnat_l.h
189
190ipnat_y.c ipnat_y.h: ipnat_y.y
191	$(YACC) -d -b ipnat ipnat_y.y
192	sed -e 's/yy/ipnat_yy/g' \
193	    -e 's/extern [a-z]* .*();//' \
194	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
195	   ipnat.tab.c > ipnat_y.c
196	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
197	   ipnat.tab.h > ipnat_y.h
198
199CLEANFILES += ipnat.tab.c ipnat.tab.h
200CLEANFILES += ipnat_y.c ipnat_y.h
201
202ipnat_l.o: ipnat_l.c $(COMMONIPF)/netinet/ip_nat.h ipnat_l.h
203
204ipnat_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
208ipnat_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 ippool_y.h ippool_l.h
218
219ippool_y.c ippool_y.h: ippool_y.y
220	$(YACC) -d -b ippool ippool_y.y
221	sed -e 's/yy/ippool_yy/g' \
222	    -e 's/extern [a-z]* .*();//' \
223	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
224	   ippool.tab.c > ippool_y.c
225	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
226	   ippool.tab.h > ippool_y.h
227
228CLEANFILES += ippool.tab.c ippool.tab.h
229CLEANFILES += ippool_y.c ippool_y.h
230
231ippool_l.o: ippool_l.c $(COMMONIPF)/netinet/ip_pool.h ippool_l.h
232
233ippool_l.c: lexer.c $(COMMONIPF)/netinet/ip_pool.h
234	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
235	       -e 's/lexer.h/ippool_l.h/' lexer.c > $@
236
237ippool_l.h: lexer.h
238	sed -e 's/yy/ippool_yy/g' lexer.h > $@
239
240CLEANFILES += ippool_l.c ippool_l.h
241
242ipftest:	$(IPFTEST_OBJS) $(LIBIPF) $(MAPFILE.NGB)
243	$(LINK.c) $(ZIGNORE) -o ipftest $(IPFTEST_OBJS) $(LDLIBS)
244	$(POST_PROCESS)
245
246clean:
247	-$(RM) $(CLEANFILES)
248
249#
250# NOTE: all rules must use relative paths otherwise absolute paths will be
251#       embedded into the binaries making them false positives and
252#       reported by wsdiff
253#
254
255%.o:	../../../uts/common/inet/ipf/%.c
256	$(COMPILE.c) $<
257	$(POST_PROCESS_O)
258
259%.o:	../../../common/net/patricia/%.c
260	$(COMPILE.c) $<
261	$(POST_PROCESS_O)
262
263install_local: $(USRLIBIPF) $(USRLIBIPFLICENCE)
264
265include ../../Makefile.targ
266