2 # Copyright (C) 1993-2001 by Darren Reed.
4 # See the IPFILTER.LICENCE file for details on licencing.
6 # $Id: Makefile,v 2.11.2.15 2002/12/02 04:22:56 darrenr Exp $
12 CC=gcc -Wstrict-prototypes -Wmissing-prototypes
19 CPUDIR=`uname -s|sed -e 's@/@@g'`-`uname -r`-`uname -m`
20 IPFILKERN=`/bin/ls -1tr /usr/src/sys/compile | grep -v .bak | tail -1`
22 # To enable this to work as a Loadable Kernel Module...
26 # To enable logging of blocked/passed packets...
30 # The facility you wish to log messages from ipmon to syslogd with.
32 LOGFAC=-DLOGFAC=LOG_LOCAL0
35 # Uncomment the next 3 lines if you want to view the state table a la top(1)
36 # (requires that you have installed ncurses).
37 STATETOP_CFLAGS=-DSTATETOP
39 # Where to find the ncurses include files (if not in default path),
42 #STATETOP_INC=-I/usr/local/include
44 # How to link the ncurses library
47 #STATETOP_LIB=-L/usr/local/lib -lncurses
50 # Uncomment this when building IPv6 capability.
54 # For packets which don't match any pass rules or any block rules, set either
55 # FR_PASS or FR_BLOCK (respectively). It defaults to FR_PASS if left
56 # undefined. This is ignored for ipftest, which can thus return three
57 # results: pass, block and nomatch. This is the sort of "block unless
58 # explicitly allowed" type #define switch.
60 POLICY=-DIPF_DEFAULT_PASS=FR_PASS
62 MFLAGS1='CFLAGS=$(CFLAGS) $(ARCHINC) $(SOLARIS2) $(INET6) $(IPFLOG)' \
63 "IPFLOG=$(IPFLOG)" "LOGFAC=$(LOGFAC)" "POLICY=$(POLICY)" \
64 "SOLARIS2=$(SOLARIS2)" "DEBUG=$(DEBUG)" "DCPU=$(CPU)" \
65 "CPUDIR=$(CPUDIR)" 'STATETOP_CFLAGS=$(STATETOP_CFLAGS)' \
66 'STATETOP_INC=$(STATETOP_INC)' 'STATETOP_LIB=$(STATETOP_LIB)' \
67 "BITS=$(BITS)" "OBJ=$(OBJ)"
68 DEST="BINDEST=$(BINDEST)" "SBINDEST=$(SBINDEST)" "MANDIR=$(MANDIR)"
69 MFLAGS=$(MFLAGS1) "IPFLKM=$(IPFLKM)"
73 ########## ########## ########## ########## ########## ########## ##########
82 @echo "Chose one of the following targets for making IP filter:"
84 @echo "solaris - auto-selects SunOS4.1.x/Solaris 2.3-6/Solaris2.4-6x86"
85 @echo "netbsd - compile for NetBSD"
86 @echo "openbsd - compile for OpenBSD"
87 @echo "freebsd - compile for FreeBSD 2.0, 2.1 or earlier"
88 @echo "freebsd22 - compile for FreeBSD-2.2 or greater"
89 @echo "freebsd3 - compile for FreeBSD-3.x"
90 @echo "freebsd4 - compile for FreeBSD-4.x"
91 @echo "bsd - compile for generic 4.4BSD systems"
92 @echo "bsdi - compile for BSD/OS"
93 @echo "irix - compile for SGI IRIX"
97 @if [ -d test ]; then (cd test; make) \
98 else echo test directory not present, sorry; fi
101 if [ ! -f netinet/done ] ; then \
102 (cd netinet; ln -s ../*.h .; ln -s ../ip_*_pxy.c .; ); \
103 (cd netinet; ln -s ../ipsend/tcpip.h tcpip.h); \
104 touch netinet/done; \
107 sunos solaris: include
108 CC="$(CC)" ./buildsunos
111 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
112 -rm -f BSD/$(CPUDIR)/ioconf.h
113 @if [ -n $(IPFILKERN) ] ; then \
114 if [ -f /sys/compile/$(IPFILKERN)/ioconf.h ] ; then \
115 ln -s /sys/compile/$(IPFILKERN)/ioconf.h BSD/$(CPUDIR); \
117 ln -s /sys/$(IPFILKERN)/ioconf.h BSD/$(CPUDIR); \
119 elif [ ! -f `uname -v|sed -e 's@^.*:\(/[^: ]*\).*@\1@'`/ioconf.h ] ; then \
120 echo -n "Can't find ioconf.h in "; \
121 echo `uname -v|sed -e 's@^.*:\(/[^: ]*\).*@\1@'`; \
124 ln -s `uname -v|sed -e 's@^.*:\(/[^: ]*\).*@\1@'`/ioconf.h BSD/$(CPU) ; \
129 if [ x$INET6 = x ] ; then \
130 echo "#undef INET6" > opt_inet6.h; \
132 echo "#define INET6" > opt_inet6.h; \
134 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
135 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) "ML=mlfk_ipl.c" "MLD=mlfk_ipl.c" "LKM=ipf.ko" "DLKM=-DKLD_MODULE -I/sys"; cd ..)
136 (cd BSD/$(CPUDIR); make -f Makefile.ipsend TOP=../.. $(MFLAGS1); cd ..)
138 freebsd3 freebsd30: include
139 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
140 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS1) "ML=mlf_ipl.c" LKM= ; cd ..)
141 (cd BSD/$(CPUDIR); make -f Makefile.ipsend TOP=../.. $(MFLAGS1); cd ..)
144 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
145 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) 'DLKM=-D_LKM' "ML=mln_ipl.c"; cd ..)
146 (cd BSD/$(CPUDIR); make -f Makefile.ipsend TOP=../.. $(MFLAGS); cd ..)
148 openbsd openbsd21: include
149 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
150 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) 'DLKM=-D_LKM' "ML=mln_ipl.c"; cd ..)
151 (cd BSD/$(CPUDIR); make -f Makefile.ipsend TOP=../.. $(MFLAGS); cd ..)
153 freebsd freebsd20 freebsd21: include
154 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
155 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) "ML=mlf_ipl.c"; cd ..)
156 (cd BSD/$(CPUDIR); make -f Makefile.ipsend TOP=../.. $(MFLAGS); cd ..)
159 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
160 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS); cd ..)
161 (cd BSD/$(CPUDIR); make -f Makefile.ipsend TOP=../.. $(MFLAGS); cd ..)
164 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
165 (cd BSD/$(CPUDIR); make build "CC=$(CC)" TOP=../.. $(MFLAGS) LKM= ; cd ..)
166 (cd BSD/$(CPUDIR); make -f Makefile.ipsend "CC=$(CC)" TOP=../.. $(MFLAGS); cd ..)
169 make setup "TARGOS=IRIX" "CPUDIR=$(CPUDIR)"
170 -(cd IRIX/$(CPUDIR); if [ $(MAKE) = make ] ; then make -f Makefile.std build TOP=../.. $(DEST) SGI=`../getrev` $(MFLAGS); else smake build SGI=`../getrev` TOP=../.. $(DEST) $(MFLAGS); fi;)
171 -(cd IRIX/$(CPUDIR); if [ $(MAKE) = make ] ; then make -f Makefile.ipsend.std SGI=`../getrev` TOP=../.. $(DEST) $(MFLAGS); else smake -f Makefile.ipsend SGI=`../getrev` TOP=../.. $(DEST) $(MFLAGS); fi)
174 make setup "TARGOS=Linux" "CPUDIR=$(CPUDIR)"
178 (cd Linux/$(CPUDIR); make build TOP=../.. $(DEST) $(MFLAGS) LKM= ; cd ..)
179 (cd Linux/$(CPUDIR); make -f Makefile.ipsend TOP=../.. $(DEST) $(MFLAGS); cd ..)
182 -if [ ! -d $(TARGOS)/$(CPUDIR) ] ; then mkdir $(TARGOS)/$(CPUDIR); fi
183 -rm -f $(TARGOS)/$(CPUDIR)/Makefile $(TARGOS)/$(CPUDIR)/Makefile.ipsend
184 -ln -s ../Makefile $(TARGOS)/$(CPUDIR)/Makefile
185 -if [ ! -f $(TARGOS)/$(CPUDIR)/Makefile.std -a \
186 -f $(TARGOS)/Makefile.std ] ; then \
187 ln -s ../Makefile.std $(TARGOS)/$(CPUDIR)/Makefile.std; \
189 -if [ ! -f $(TARGOS)/$(CPUDIR)/Makefile.ipsend.std -a \
190 -f $(TARGOS)/Makefile.ipsend.std ] ; then \
191 ln -s ../Makefile.ipsend.std $(TARGOS)/$(CPUDIR)/Makefile.ipsend.std; \
193 -ln -s ../Makefile.ipsend $(TARGOS)/$(CPUDIR)/Makefile.ipsend
196 ${RM} -f core *.o ipt fils ipf ipfstat ipftest ipmon if_ipl \
198 ${RM} -rf sparcv7 sparcv9
199 (cd SunOS4; make clean)
200 (cd SunOS5; make clean)
202 (cd Linux; make clean)
203 if [ "`uname -s`" = "IRIX" ]; then (cd IRIX; make clean); fi
204 [ -d test ] && (cd test; make clean)
205 (cd ipsend; make clean)
208 sh -c 'cd netinet; for i in *; do if [ -h $$i ] ; then /bin/rm -f $$i; fi; done'
209 ${RM} -f netinet/done
211 clean-bsd: clean-include
214 clean-sunos4: clean-include
215 (cd SunOS4; make clean)
217 clean-sunos5: clean-include
218 (cd SunOS5; make clean)
220 clean-irix: clean-include
221 (cd IRIX; make clean)
223 clean-linux: clean-include
224 (cd Linux; make clean)
227 -@for i in ipf.c ipt.h solaris.c ipf.h kmem.c ipft_ef.c linux.h \
228 ipft_pc.c fil.c ipft_sn.c mln_ipl.c fils.c ipft_td.c \
229 mls_ipl.c ip_compat.h ipl.h opt.c ip_fil.c ipl_ldev.c \
230 parse.c ip_fil.h ipmon.c pcap.h ip_sfil.c ipt.c snoop.h \
231 ip_state.c ip_state.h ip_nat.c ip_nat.h ip_frag.c \
232 ip_frag.h ip_sfil.c misc.c; do \
233 if [ ! -f $$i ] ; then \
234 echo "getting $$i"; \
239 sunos4 solaris1: null
240 (cd SunOS4; make build TOP=.. "CC=$(CC)" $(DEST) $(MFLAGS); cd ..)
241 (cd SunOS4; make -f Makefile.ipsend "CC=$(CC)" TOP=.. $(DEST) $(MFLAGS); cd ..)
243 sunos5 solaris2: null
244 (cd SunOS5/$(CPUDIR); make build TOP=../.. "CC=$(CC)" $(DEST) $(MFLAGS) "SOLARIS2=$(SOLARIS2)" "CPU=-Dsparc -D__sparc__"; cd ..)
245 (cd SunOS5/$(CPUDIR); make -f Makefile.ipsend TOP=../.. "CC=$(CC)" $(DEST) $(MFLAGS); cd ..)
247 sunos5x86 solaris2x86: null
248 (cd SunOS5/$(CPUDIR); make build TOP=../.. "CC=$(CC)" $(DEST) $(MFLAGS) "SOLARIS2=$(SOLARIS2)" "CPU=-Di86pc -Di386 -D__i386__"; cd ..)
249 (cd SunOS5/$(CPUDIR); make -f Makefile.ipsend TOP=../.. "CC=$(CC)" $(DEST) $(MFLAGS); cd ..)
252 (cd Linux/$(CPUDIR); make install "TOP=../.." $(DEST) $(MFLAGS); cd ..)
253 (cd Linux/$(CPUDIR); make -f Makefile.ipsend INSTALL=$(INSTALL) install "TOP=../.." $(DEST) $(MFLAGS); cd ..)
256 (cd BSD/$(CPUDIR); make install "TOP=../.." $(MFLAGS); cd ..)
257 (cd BSD/$(CPUDIR); make -f Makefile.ipsend INSTALL=$(INSTALL) install "TOP=../.." $(MFLAGS); cd ..)
259 install-sunos4: solaris
260 (cd SunOS4; $(MAKE) "CPU=$(CPU)" "TOP=.." install)
262 install-sunos5: solaris
263 (cd SunOS5; $(MAKE) "CPUDIR=`uname -p`-`uname -r`" "CPU=$(CPU) TOP=.." install)
266 (cd IRIX; smake install "CPU=$(CPU) TOP=.." $(DEST) $(MFLAGS))
269 -@for i in ipf.c ipt.h solaris.c ipf.h kmem.c ipft_ef.c linux.h \
270 ipft_pc.c fil.c ipft_sn.c mln_ipl.c fils.c ipft_td.c \
271 mls_ipl.c ip_compat.h ipl.h opt.c ip_fil.c ipl_ldev.c \
272 parse.c ip_fil.h ipmon.c pcap.h ip_sfil.c ipt.c snoop.h \
273 ip_state.c ip_state.h ip_nat.c ip_nat.h ip_frag.c \
274 ip_frag.h ip_sfil.c misc.c; do \
275 if [ ! -f $$i ] ; then \
276 echo "getting $$i"; \
282 find . -type d -name CVS -print | xargs /bin/rm -rf
283 find . -type f -name .cvsignore -print | xargs /bin/rm -f
286 -@if [ "`$(MAKE) -v 2>&1 | sed -ne 's/GNU.*/GNU/p'`" = "GNU" ] ; then \
287 echo 'Do not use GNU make (gmake) to compile IPFilter'; \