xref: /titanic_50/usr/src/cmd/ipf/tools/Makefile.tools (revision 94bdecd9e84ae1042607002db3e64a6849da5874)
17c478bd9Sstevel@tonic-gate#
2f4b3ec61Sdh155122# CDDL HEADER START
3f4b3ec61Sdh155122#
4f4b3ec61Sdh155122# The contents of this file are subject to the terms of the
5f4b3ec61Sdh155122# Common Development and Distribution License (the "License").
6f4b3ec61Sdh155122# You may not use this file except in compliance with the License.
7f4b3ec61Sdh155122#
8f4b3ec61Sdh155122# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9f4b3ec61Sdh155122# or http://www.opensolaris.org/os/licensing.
10f4b3ec61Sdh155122# See the License for the specific language governing permissions
11f4b3ec61Sdh155122# and limitations under the License.
12f4b3ec61Sdh155122#
13f4b3ec61Sdh155122# When distributing Covered Code, include this CDDL HEADER in each
14f4b3ec61Sdh155122# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15f4b3ec61Sdh155122# If applicable, add the following below this CDDL HEADER, with the
16f4b3ec61Sdh155122# fields enclosed by brackets "[]" replaced with your own identifying
17f4b3ec61Sdh155122# information: Portions Copyright [yyyy] [name of copyright owner]
18f4b3ec61Sdh155122#
19f4b3ec61Sdh155122# CDDL HEADER END
20f4b3ec61Sdh155122#
21f4b3ec61Sdh155122#
2216070783SVladimir Kotal# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate# Use is subject to license terms.
247c478bd9Sstevel@tonic-gate#
25b6805bf7SGordon Ross# Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
26b6805bf7SGordon Ross#
27*94bdecd9SRob Gulewich# Copyright (c) 2012, Joyent Inc. All rights reserved.
28*94bdecd9SRob Gulewich#
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gatePROG=		ipf ipfs ipmon ipnat ippool ipfstat
317c478bd9Sstevel@tonic-gateIPFPROG=	ipftest
327c478bd9Sstevel@tonic-gate
33*94bdecd9SRob GulewichIPF_OBJS=	ipf.o ipfcomp.o ipfzone.o ipf_y.o ipf_l.o
34*94bdecd9SRob GulewichIPFS_OBJS=	ipfs.o ipfzone.o
35*94bdecd9SRob GulewichIPFSTAT_OBJS=	ipfstat.o ipfzone.o
36*94bdecd9SRob GulewichIPMON_OBJS=	ipmon.o ipfzone.o ipmon_y.o ipmon_l.o
37*94bdecd9SRob GulewichIPNAT_OBJS=	ipnat.o ipfzone.o ipnat_y.o ipnat_l.o
38*94bdecd9SRob GulewichIPPOOL_OBJS=	ippool.o ipfzone.o ippool_y.o ippool_l.o
39*94bdecd9SRob GulewichIPFTEST_OBJS=	ipftest.o ipfzone.o \
40d6c23f6fSyx160601		ip_fil.o ip_state.o ip_compat.o \
41d6c23f6fSyx160601		ip_frag.o ip_nat.o ip_nat6.o fil.o \
427c478bd9Sstevel@tonic-gate		ip_htable.o ip_lookup.o \
437c478bd9Sstevel@tonic-gate		ip_proxy.o ip_auth.o ip_log.o \
447c478bd9Sstevel@tonic-gate		ipf_y.o ipf_l.o \
457c478bd9Sstevel@tonic-gate		ipnat_y.o ipnat_l.o \
467c478bd9Sstevel@tonic-gate		ippool_y.o ippool_l.o \
477c478bd9Sstevel@tonic-gate		ip_pool.o radix.o
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gateOBJS=		$(IPF_OBJS) $(IPFS_OBJS) $(IPFSTAT_OBJS) \
50b6805bf7SGordon Ross		$(IPMON_OBJS) $(IPNAT_OBJS) $(IPPOOL_OBJS) $(IPFTEST_OBJS)
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gateOBJSL=		$(IPF_OBJS) $(IPFS_OBJS) $(IPFSTAT_OBJS) \
537c478bd9Sstevel@tonic-gate		$(IPMON_OBJS) $(IPNAT_OBJS)
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gateSRCS=		$(OBJSL:%.o=../%.c)
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gateinclude ../../../Makefile.cmd
587c478bd9Sstevel@tonic-gateinclude ../../Makefile.ipf
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gateLDLIBS		+= $(LIBBPF)
6124da5b34SrieLDFLAGS		+= $(MAPFILE.NGB:%=-M%)
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gateCPPFLAGS	+= -I. -DIPFILTER_LOOKUP -DIPFILTER_LOG
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gateipfstat.o	:=	CPPFLAGS += -DSTATETOP
667c478bd9Sstevel@tonic-gateipfstat		:=	LDLIBS += -lcurses
677c478bd9Sstevel@tonic-gate
687c478bd9Sstevel@tonic-gateipf		:=	LDLIBS += -lsocket -lnsl
69734b6a94Sdarrenmipftest		:=	LDLIBS += -lsocket -lnsl -lmd
707c478bd9Sstevel@tonic-gateipfstat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
717c478bd9Sstevel@tonic-gateipmon		:=	LDLIBS += -lsocket -lnsl
727c478bd9Sstevel@tonic-gateipnat		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
73f4b3ec61Sdh155122ippool		:=	LDLIBS += -lsocket -lnsl -lkvm -lelf
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gateCLEANFILES	+= $(OBJS)
76b6805bf7SGordon RossCLOBBERFILES	+= $(IPFPROG)
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gateROOTIPF=	$(ROOTLIB)/ipf
797c478bd9Sstevel@tonic-gateROOTIPF32=	$(ROOTIPF)/$(MACH32)
807c478bd9Sstevel@tonic-gateROOTIPF64=	$(ROOTIPF)/$(MACH64)
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gateROOTIPFPROG32=	$(IPFPROG:%=$(ROOTIPF32)/%)
837c478bd9Sstevel@tonic-gateROOTIPFPROG64=	$(IPFPROG:%=$(ROOTIPF64)/%)
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gateROOTIPFLINKS=		$(IPFPROG:%=$(ROOTIPF)/%)
867c478bd9Sstevel@tonic-gateROOTUSRSBINLINKS=	$(PROG:%=$(ROOTUSRSBIN)/%)
877c478bd9Sstevel@tonic-gate
88b6805bf7SGordon Rossall:
89b6805bf7SGordon Ross
907c478bd9Sstevel@tonic-gate$(ROOTIPF32):
917c478bd9Sstevel@tonic-gate	$(INS.dir)
927c478bd9Sstevel@tonic-gate
937c478bd9Sstevel@tonic-gate$(ROOTIPF64):
947c478bd9Sstevel@tonic-gate	$(INS.dir)
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate$(ROOTIPF)/%: %
977c478bd9Sstevel@tonic-gate	$(INS.file)
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate$(ROOTIPF32)/%: %
1007c478bd9Sstevel@tonic-gate	$(INS.file)
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate$(ROOTIPF64)/%: %
1037c478bd9Sstevel@tonic-gate	$(INS.file)
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate$(ROOTUSRSBINLINKS): FRC
1067c478bd9Sstevel@tonic-gate	-$(RM) $@; $(LN) $(ISAEXEC) $@
1077c478bd9Sstevel@tonic-gate
1087c478bd9Sstevel@tonic-gate$(ROOTIPFLINKS): FRC
1097c478bd9Sstevel@tonic-gate	-$(RM) $@; $(LN) $(ISAEXEC) $@
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate
1127c478bd9Sstevel@tonic-gate.KEEP_STATE:
1137c478bd9Sstevel@tonic-gate
11424da5b34Srieipf:	$(IPF_OBJS) $(LIBIPF) $(MAPFILE.NGB)
1157c478bd9Sstevel@tonic-gate	$(LINK.c) -o ipf $(IPF_OBJS) $(LDLIBS)
1167c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
1177c478bd9Sstevel@tonic-gate
118ab25eeb5Syz155240ipf_y.o: ../ipf_y.c $(COMMONIPF)/netinet/ip_fil.h $(COMMONIPF)/ipf.h \
1197c478bd9Sstevel@tonic-gate	../ipf_y.c ../ipf_l.h
1207c478bd9Sstevel@tonic-gate
1217c478bd9Sstevel@tonic-gate../ipf_y.c ../ipf_y.h: ../ipf_y.y
1227c478bd9Sstevel@tonic-gate	$(YACC) -d -b ipf ../ipf_y.y
1237c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.c/' \
1247c478bd9Sstevel@tonic-gate	   ipf.tab.c > ../ipf_y.c
1257c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
1267c478bd9Sstevel@tonic-gate	   ipf.tab.h > ../ipf_y.h
1277c478bd9Sstevel@tonic-gate
128b6805bf7SGordon RossCLEANFILES += ipf.tab.c ipf.tab.h
129b6805bf7SGordon RossCLEANFILES += ../ipf_y.c ../ipf_y.h
130b6805bf7SGordon Ross
131ab25eeb5Syz155240ipf_l.o: ../ipf_l.c $(COMMONIPF)/netinet/ip_fil.h $(COMMONIPF)/ipf.h  \
1327c478bd9Sstevel@tonic-gate	 ../ipf_y.h ../ipf_l.h
1337c478bd9Sstevel@tonic-gate	$(COMPILE.c) ../ipf_l.c -o $@
1347c478bd9Sstevel@tonic-gate
135ab25eeb5Syz155240../ipf_l.c: ../lexer.c $(COMMONIPF)/ipf.h $(COMMONIPF)/netinet/ip_fil.h
1367c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipf_yy/g' -e 's/y.tab.h/ipf_y.h/' \
1377c478bd9Sstevel@tonic-gate	       -e 's/lexer.h/ipf_l.h/' ../lexer.c > $@
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate../ipf_l.h: ../lexer.h
1407c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipf_yy/g' ../lexer.h > $@
1417c478bd9Sstevel@tonic-gate
142b6805bf7SGordon RossCLEANFILES += ../ipf_l.c ../ipf_l.h
143b6805bf7SGordon Ross
144b6805bf7SGordon Ross
1457c478bd9Sstevel@tonic-gateipfs:	$(IPFS_OBJS)
1467c478bd9Sstevel@tonic-gate	$(LINK.c) -o ipfs $(IPFS_OBJS) $(LDLIBS)
1477c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
1487c478bd9Sstevel@tonic-gate
14924da5b34Srieipfstat:	$(IPFSTAT_OBJS) $(MAPFILE.NGB)
1507c478bd9Sstevel@tonic-gate	$(LINK.c) -o ipfstat $(IPFSTAT_OBJS) $(LDLIBS)
1517c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
1527c478bd9Sstevel@tonic-gate
15324da5b34Srieipmon:	$(IPMON_OBJS) $(LIBIPF) $(MAPFILE.NGB)
1547c478bd9Sstevel@tonic-gate	$(LINK.c) -o ipmon $(IPMON_OBJS) $(LDLIBS)
1557c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
1567c478bd9Sstevel@tonic-gate
1577c478bd9Sstevel@tonic-gateipmon_y.o: ../ipmon_y.c $(COMMONIPF)/ipmon.h \
1587c478bd9Sstevel@tonic-gate	../ipmon_y.h ../ipmon_l.h
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gate../ipmon_y.c ../ipmon_y.h: ../ipmon_y.y
1617c478bd9Sstevel@tonic-gate	$(YACC) -d -b ipmon ../ipmon_y.y
1627c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipmon_yy/g' \
1637c478bd9Sstevel@tonic-gate	    -e 's/extern [a-z]* .*();//' \
1647c478bd9Sstevel@tonic-gate	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
1657c478bd9Sstevel@tonic-gate	   ipmon.tab.c > ../ipmon_y.c
1667c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
1677c478bd9Sstevel@tonic-gate	   ipmon.tab.h > ../ipmon_y.h
1687c478bd9Sstevel@tonic-gate
169b6805bf7SGordon RossCLEANFILES += ipmon.tab.c ipmon.tab.h
170b6805bf7SGordon RossCLEANFILES += ../ipmon_y.c ../ipmon_y.h
171b6805bf7SGordon Ross
1727c478bd9Sstevel@tonic-gateipmon_l.o: ../ipmon_l.c $(COMMONIPF)/ipmon.h ../ipmon_y.h ../ipmon_l.h
1737c478bd9Sstevel@tonic-gate	$(COMPILE.c) ../ipmon_l.c -o $@
1747c478bd9Sstevel@tonic-gate
1757c478bd9Sstevel@tonic-gate../ipmon_l.c: ../lexer.c $(COMMONIPF)/ipmon.h
1767c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipmon_yy/g' -e 's/y.tab.h/ipmon_y.h/' \
1777c478bd9Sstevel@tonic-gate            -e 's/lexer.h/ipmon_l.h/' ../lexer.c > $@
1787c478bd9Sstevel@tonic-gate
1797c478bd9Sstevel@tonic-gate../ipmon_l.h: ../lexer.h
1807c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipmon_yy/g' ../lexer.h > $@
1817c478bd9Sstevel@tonic-gate
182b6805bf7SGordon RossCLEANFILES += ../ipmon_l.c ../ipmon_l.h
183b6805bf7SGordon Ross
18424da5b34Srieipnat:	$(IPNAT_OBJS) $(LIBIPF) $(MAPFILE.NGB)
1857c478bd9Sstevel@tonic-gate	$(LINK.c) -o ipnat $(IPNAT_OBJS) $(LDLIBS)
1867c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
1877c478bd9Sstevel@tonic-gate
188ab25eeb5Syz155240ipnat_y.o: ../ipnat_y.c $(COMMONIPF)/netinet/ip_nat.h \
1897c478bd9Sstevel@tonic-gate	../ipnat_y.h ../ipnat_l.h
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate../ipnat_y.c ../ipnat_y.h: ../ipnat_y.y
1927c478bd9Sstevel@tonic-gate	$(YACC) -d -b ipnat ../ipnat_y.y
1937c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipnat_yy/g' \
1947c478bd9Sstevel@tonic-gate	    -e 's/extern [a-z]* .*();//' \
1957c478bd9Sstevel@tonic-gate	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
1967c478bd9Sstevel@tonic-gate	   ipnat.tab.c > ../ipnat_y.c
1977c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
1987c478bd9Sstevel@tonic-gate	   ipnat.tab.h > ../ipnat_y.h
1997c478bd9Sstevel@tonic-gate
200b6805bf7SGordon RossCLEANFILES += ipnat.tab.c ipnat.tab.h
201b6805bf7SGordon RossCLEANFILES += ../ipnat_y.c ../ipnat_y.h
202b6805bf7SGordon Ross
203ab25eeb5Syz155240ipnat_l.o: ../ipnat_l.c $(COMMONIPF)/netinet/ip_nat.h ../ipnat_l.h
2047c478bd9Sstevel@tonic-gate	$(COMPILE.c) ../ipnat_l.c -o $@
2057c478bd9Sstevel@tonic-gate
206ab25eeb5Syz155240../ipnat_l.c: ../lexer.c $(COMMONIPF)/netinet/ip_nat.h
2077c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipnat_yy/g' -e 's/y.tab.h/ipnat_y.h/' \
2087c478bd9Sstevel@tonic-gate	       -e 's/lexer.h/ipnat_l.h/' ../lexer.c > $@
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate../ipnat_l.h: ../lexer.h
2117c478bd9Sstevel@tonic-gate	sed -e 's/yy/ipnat_yy/g' ../lexer.h > $@
2127c478bd9Sstevel@tonic-gate
213b6805bf7SGordon RossCLEANFILES += ../ipnat_l.c ../ipnat_l.h
214b6805bf7SGordon Ross
21524da5b34Srieippool:	$(IPPOOL_OBJS) $(LIBIPF) $(MAPFILE.NGB)
2167c478bd9Sstevel@tonic-gate	$(LINK.c) -o ippool $(IPPOOL_OBJS) $(LDLIBS)
2177c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
2187c478bd9Sstevel@tonic-gate
219ab25eeb5Syz155240ippool_y.o: ../ippool_y.c $(COMMONIPF)/netinet/ip_pool.h \
2207c478bd9Sstevel@tonic-gate	../ippool_y.h ../ippool_l.h
2217c478bd9Sstevel@tonic-gate
2227c478bd9Sstevel@tonic-gate../ippool_y.c ../ippool_y.h: ../ippool_y.y
2237c478bd9Sstevel@tonic-gate	$(YACC) -d -b ippool ../ippool_y.y
2247c478bd9Sstevel@tonic-gate	sed -e 's/yy/ippool_yy/g' \
2257c478bd9Sstevel@tonic-gate	    -e 's/extern [a-z]* .*();//' \
2267c478bd9Sstevel@tonic-gate	    -e 's/^\(static [a-z]* .*\)();/\1(void);/' \
2277c478bd9Sstevel@tonic-gate	   ippool.tab.c > ../ippool_y.c
2287c478bd9Sstevel@tonic-gate	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
2297c478bd9Sstevel@tonic-gate	   ippool.tab.h > ../ippool_y.h
2307c478bd9Sstevel@tonic-gate
231b6805bf7SGordon RossCLEANFILES += ippool.tab.c ippool.tab.h
232b6805bf7SGordon RossCLEANFILES += ../ippool_y.c ../ippool_y.h
233b6805bf7SGordon Ross
234ab25eeb5Syz155240ippool_l.o: ../ippool_l.c $(COMMONIPF)/netinet/ip_pool.h ../ippool_l.h
2357c478bd9Sstevel@tonic-gate	$(COMPILE.c) ../ippool_l.c -o $@
2367c478bd9Sstevel@tonic-gate
237ab25eeb5Syz155240../ippool_l.c: ../lexer.c $(COMMONIPF)/netinet/ip_pool.h
2387c478bd9Sstevel@tonic-gate	sed -e 's/yy/ippool_yy/g' -e 's/y.tab.h/ippool_y.h/' \
2397c478bd9Sstevel@tonic-gate	       -e 's/lexer.h/ippool_l.h/' ../lexer.c > $@
2407c478bd9Sstevel@tonic-gate
2417c478bd9Sstevel@tonic-gate../ippool_l.h: ../lexer.h
2427c478bd9Sstevel@tonic-gate	sed -e 's/yy/ippool_yy/g' ../lexer.h > $@
2437c478bd9Sstevel@tonic-gate
244b6805bf7SGordon RossCLEANFILES += ../ippool_l.c ../ippool_l.h
245b6805bf7SGordon Ross
24624da5b34Srieipftest:	$(IPFTEST_OBJS) $(LIBIPF) $(MAPFILE.NGB)
24724da5b34Srie	$(LINK.c) $(ZIGNORE) -o ipftest $(IPFTEST_OBJS) $(LDLIBS)
2487c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
2497c478bd9Sstevel@tonic-gate
2507c478bd9Sstevel@tonic-gateclean:
2517c478bd9Sstevel@tonic-gate	-$(RM) $(CLEANFILES)
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gatelint: 	lint_SRCS
2547c478bd9Sstevel@tonic-gate
25516070783SVladimir Kotal#
25616070783SVladimir Kotal# NOTE: all rules must use relative paths otherwise absolute paths will be
25716070783SVladimir Kotal#       embedded into the binaries making them false positives and
25816070783SVladimir Kotal#       reported by wsdiff
25916070783SVladimir Kotal#
26016070783SVladimir Kotal
26116070783SVladimir Kotal%.o:	../../../../uts/common/inet/ipf/%.c
2627c478bd9Sstevel@tonic-gate	$(COMPILE.c) $<
2637c478bd9Sstevel@tonic-gate
2647c478bd9Sstevel@tonic-gate%.o:	../%.c
2657c478bd9Sstevel@tonic-gate	$(COMPILE.c) $<
2667c478bd9Sstevel@tonic-gate
26716070783SVladimir Kotal%.o:	../../../../common/net/patricia/%.c
268c793af95Ssangeeta	$(COMPILE.c) $<
269c793af95Ssangeeta
2707c478bd9Sstevel@tonic-gateinclude ../../../Makefile.targ
2717c478bd9Sstevel@tonic-gate
2727c478bd9Sstevel@tonic-gateFRC:
273