xref: /illumos-gate/usr/src/cmd/ipf/tools/Makefile (revision c43efa7f6b109f90d7f4962df8c0e1a94008d2d1)
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
89CLEANFILES	+= $(IPF_OBJS) $(IPFS_OBJS) $(IPFTEST_OBJS) $(IPFSTAT_OBJS)
90CLEANFILES	+= $(IPMON_OBJS) $(IPNAT_OBJS) $(IPPOOL_OBJS)
91CLOBBERFILES	+= $(IPFPROG)
92
93ROOTIPF=	$(ROOTLIB)/ipf
94
95ROOTIPFPROG=	$(IPFPROG:%=$(ROOTIPF)/%)
96
97.KEEP_STATE:
98
99all: $(PROG) $(IPFPROG)
100
101install: all install_local $(ROOTIPF) $(ROOTUSRSBINPROG) $(ROOTIPFPROG)
102
103$(USRLIBIPF):
104	$(INS.dir)
105
106$(USRLIBIPF)/% : %
107	$(INS.file)
108
109$(ROOTIPF)/%: %
110	$(INS.file)
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
119ipf_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
132ipf_l.c: lexer.c $(COMMONIPF)/ipf.h $(COMMONIPF)/netinet/ip_fil.h
133	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
134	       -e 's/lexer.h/ipf_l.h/' lexer.c > $@
135
136ipf_l.h: lexer.h
137	sed -e 's/yy/ipf_yy/g' lexer.h > $@
138
139CLEANFILES += ipf_l.c ipf_l.h
140
141ipfs:	$(IPFS_OBJS)
142	$(LINK.c) -o ipfs $(IPFS_OBJS) $(LDLIBS)
143	$(POST_PROCESS)
144
145ipfstat:	$(IPFSTAT_OBJS) $(MAPFILE.NGB)
146	$(LINK.c) -o ipfstat $(IPFSTAT_OBJS) $(LDLIBS)
147	$(POST_PROCESS)
148
149ipmon:	$(IPMON_OBJS) $(LIBIPF) $(MAPFILE.NGB)
150	$(LINK.c) -o ipmon $(IPMON_OBJS) $(LDLIBS)
151	$(POST_PROCESS)
152
153ipmon_y.o: ipmon_y.c $(COMMONIPF)/ipmon.h ipmon_y.h ipmon_l.h
154
155ipmon_y.c ipmon_y.h: ipmon_y.y
156	$(YACC) -d -b ipmon ipmon_y.y
157	sed -e 's/yy/ipmon_yy/g' \
158	    -e 's/extern [a-z]* .*();//' \
159	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
160	   ipmon.tab.c > ipmon_y.c
161	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
162	   ipmon.tab.h > ipmon_y.h
163
164CLEANFILES += ipmon.tab.c ipmon.tab.h
165CLEANFILES += ipmon_y.c ipmon_y.h
166
167ipmon_l.o: ipmon_l.c $(COMMONIPF)/ipmon.h ipmon_y.h ipmon_l.h
168
169ipmon_l.c: lexer.c $(COMMONIPF)/ipmon.h
170	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
171            -e 's/lexer.h/ipmon_l.h/' lexer.c > $@
172
173ipmon_l.h: lexer.h
174	sed -e 's/yy/ipmon_yy/g' lexer.h > $@
175
176CLEANFILES += ipmon_l.c ipmon_l.h
177
178ipnat:	$(IPNAT_OBJS) $(LIBIPF) $(MAPFILE.NGB)
179	$(LINK.c) -o ipnat $(IPNAT_OBJS) $(LDLIBS)
180	$(POST_PROCESS)
181
182ipnat_y.o: ipnat_y.c $(COMMONIPF)/netinet/ip_nat.h ipnat_y.h ipnat_l.h
183
184ipnat_y.c ipnat_y.h: ipnat_y.y
185	$(YACC) -d -b ipnat ipnat_y.y
186	sed -e 's/yy/ipnat_yy/g' \
187	    -e 's/extern [a-z]* .*();//' \
188	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
189	   ipnat.tab.c > ipnat_y.c
190	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
191	   ipnat.tab.h > ipnat_y.h
192
193CLEANFILES += ipnat.tab.c ipnat.tab.h
194CLEANFILES += ipnat_y.c ipnat_y.h
195
196ipnat_l.o: ipnat_l.c $(COMMONIPF)/netinet/ip_nat.h ipnat_l.h
197
198ipnat_l.c: lexer.c $(COMMONIPF)/netinet/ip_nat.h
199	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
200	       -e 's/lexer.h/ipnat_l.h/' lexer.c > $@
201
202ipnat_l.h: lexer.h
203	sed -e 's/yy/ipnat_yy/g' lexer.h > $@
204
205CLEANFILES += ipnat_l.c ipnat_l.h
206
207ippool:	$(IPPOOL_OBJS) $(LIBIPF) $(MAPFILE.NGB)
208	$(LINK.c) -o ippool $(IPPOOL_OBJS) $(LDLIBS)
209	$(POST_PROCESS)
210
211ippool_y.o: ippool_y.c $(COMMONIPF)/netinet/ip_pool.h ippool_y.h ippool_l.h
212
213ippool_y.c ippool_y.h: ippool_y.y
214	$(YACC) -d -b ippool ippool_y.y
215	sed -e 's/yy/ippool_yy/g' \
216	    -e 's/extern [a-z]* .*();//' \
217	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
218	   ippool.tab.c > ippool_y.c
219	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
220	   ippool.tab.h > ippool_y.h
221
222CLEANFILES += ippool.tab.c ippool.tab.h
223CLEANFILES += ippool_y.c ippool_y.h
224
225ippool_l.o: ippool_l.c $(COMMONIPF)/netinet/ip_pool.h ippool_l.h
226
227ippool_l.c: lexer.c $(COMMONIPF)/netinet/ip_pool.h
228	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
229	       -e 's/lexer.h/ippool_l.h/' lexer.c > $@
230
231ippool_l.h: lexer.h
232	sed -e 's/yy/ippool_yy/g' lexer.h > $@
233
234CLEANFILES += ippool_l.c ippool_l.h
235
236ipftest:	$(IPFTEST_OBJS) $(LIBIPF) $(MAPFILE.NGB)
237	$(LINK.c) $(ZIGNORE) -o ipftest $(IPFTEST_OBJS) $(LDLIBS)
238	$(POST_PROCESS)
239
240clean:
241	-$(RM) $(CLEANFILES)
242
243#
244# NOTE: all rules must use relative paths otherwise absolute paths will be
245#       embedded into the binaries making them false positives and
246#       reported by wsdiff
247#
248
249%.o:	../../../uts/common/inet/ipf/%.c
250	$(COMPILE.c) $<
251	$(POST_PROCESS_O)
252
253%.o:	../../../common/net/patricia/%.c
254	$(COMPILE.c) $<
255	$(POST_PROCESS_O)
256
257install_local: $(USRLIBIPF) $(USRLIBIPFLICENCE)
258
259include ../../Makefile.targ
260