remove kvm's R macro
[freebsd-src/fkvm-freebsd.git] / contrib / ipfilter / Makefile
blob334cd451218871493d169b27e31fcd819e363de9
2 # Copyright (C) 1993-2001 by Darren Reed.
4 # Redistribution and use in source and binary forms are permitted
5 # provided that this notice is preserved and due credit is given
6 # to the original author and the contributors.
8 # $FreeBSD$
9 # Id: Makefile,v 2.76.2.24 2007/09/26 10:04:03 darrenr Exp $
11 SHELL=/bin/sh
12 BINDEST=/usr/local/bin
13 SBINDEST=/sbin
14 MANDIR=/usr/local/man
15 #To test prototyping
16 #CC=gcc -Wstrict-prototypes -Wmissing-prototypes
17 # -Wunused -Wuninitialized
18 #CC=gcc
19 #CC=cc -Dconst=
20 DEBUG=-g
21 # -O
22 CFLAGS=-I$$(TOP) -D_BSD_SOURCE
23 CPU=`uname -m`
24 CPUDIR=`uname -s|sed -e 's@/@@g'`-`uname -r`-`uname -m`
25 OBJ=.
27 # To enable this to work as a Loadable Kernel Module...
29 IPFLKM=-DIPFILTER_LKM
31 # To enable logging of blocked/passed packets...
33 IPFLOG=-DIPFILTER_LOG
35 # To enable loading filter rules compiled to C code...
37 #COMPIPF=-DIPFILTER_COMPILED
39 # To enable synchronisation between IPFilter hosts
41 #SYNC=-DIPFILTER_SYNC
43 # To enable extended IPFilter functionality
45 LOOKUP=-DIPFILTER_LOOKUP -DIPFILTER_SCAN
47 # The facility you wish to log messages from ipmon to syslogd with.
49 LOGFAC=-DLOGFAC=LOG_SECURITY
51 # To enable rules to be written with BPF syntax, uncomment these two lines.
53 # WARNING: If you're building a commercial product based on IPFilter, using
54 # this options *may* infringe at least one patent held by CheckPoint
55 # (5,606,668.)
57 #IPFBPF=-DIPFILTER_BPF -I/usr/local/include
58 #LIBBPF=-L/usr/local/lib -lpcap
60 # HP-UX and Solaris require this uncommented for BPF.
62 #BPFILTER=bpf_filter.o
64 # LINUXKERNEL is the path to the top of your Linux kernel source tree.
65 # By default IPFilter looks for /usr/src/linux, but you may have to change
66 # it to /usr/src/linux-2.4 or similar.
68 LINUXKERNEL=/usr/src/linux
69 LINUX=`uname -r | awk -F. ' { printf"%d",$$1;for(i=1;i<NF&&i<3;i++){printf("%02d",$$(i+1));}}'`
72 # All of the compile-time options are here, used for compiling the userland
73 # tools for regression testing. Well, all except for IPFILTER_LKM, of course.
75 ALLOPTS=-DIPFILTER_LOG -DIPFILTER_LOOKUP \
76 -DIPFILTER_SCAN -DIPFILTER_SYNC -DIPFILTER_CKSUM
79 # Uncomment the next 3 lines if you want to view the state table a la top(1)
80 # (requires that you have installed ncurses).
81 #STATETOP_CFLAGS=-DSTATETOP
83 # Where to find the ncurses include files (if not in default path),
85 #STATETOP_INC=
86 #STATETOP_INC=-I/usr/local/include
88 # How to link the ncurses library
90 #STATETOP_LIB=-lncurses
91 #STATETOP_LIB=-L/usr/local/lib -lncurses
94 # Uncomment this when building IPv6 capability.
96 #INET6=-DUSE_INET6
98 # For packets which don't match any pass rules or any block rules, set either
99 # FR_PASS or FR_BLOCK (respectively). It defaults to FR_PASS if left
100 # undefined. This is ignored for ipftest, which can thus return three
101 # results: pass, block and nomatch. This is the sort of "block unless
102 # explicitly allowed" type #define switch.
104 POLICY=-DIPF_DEFAULT_PASS=FR_PASS
106 MFLAGS1='CFLAGS=$(CFLAGS) $(ARCHINC) $(SOLARIS2) $(SGIREV) $(INET6)' \
107 "IPFLOG=$(IPFLOG)" "LOGFAC=$(LOGFAC)" "POLICY=$(POLICY)" \
108 "SOLARIS2=$(SOLARIS2)" "DEBUG=$(DEBUG)" "DCPU=$(CPU)" \
109 "LIBBPF=$(LIBBPF)" "CPUDIR=$(CPUDIR)" "IPFBPF=$(IPFBPF)" \
110 'STATETOP_CFLAGS=$(STATETOP_CFLAGS)' "BPFILTER=$(BPFILTER)" \
111 'STATETOP_INC=$(STATETOP_INC)' 'STATETOP_LIB=$(STATETOP_LIB)' \
112 "BITS=$(BITS)" "OBJ=$(OBJ)" "LOOKUP=$(LOOKUP)" "COMPIPF=$(COMPIPF)" \
113 'SYNC=$(SYNC)' 'ALLOPTS=$(ALLOPTS)' 'LIBBPF=$(LIBBPF)'
114 MFLAGS=$(MFLAGS1) "IPFLKM=$(IPFLKM)"
115 MACHASSERT=`/bin/ls -1 /usr/sys/*/mach_assert.h | head -1`
117 SHELL=/bin/sh
119 ########## ########## ########## ########## ########## ########## ##########
121 CP=/bin/cp
122 RM=/bin/rm
123 CHMOD=/bin/chmod
124 INSTALL=install
127 all:
128 @echo "Chose one of the following targets for making IP filter:"
129 @echo ""
130 @echo "solaris - auto-selects SunOS4.1.x/Solaris 2.3-6/Solaris2.4-6x86"
131 @echo "netbsd - compile for NetBSD"
132 @echo "openbsd - compile for OpenBSD"
133 @echo "freebsd20 - compile for FreeBSD 2.0, 2.1 or earlier"
134 @echo "freebsd22 - compile for FreeBSD-2.2 or greater"
135 @echo "freebsd - compile for all other versions of FreeBSD"
136 @echo "bsd - compile for generic 4.4BSD systems"
137 @echo "bsdi - compile for BSD/OS"
138 @echo "irix - compile for SGI IRIX"
139 @echo "hpux - compile for HP-UX 11.00"
140 @echo "osf - compile for OSF/Tru64 5.1"
141 @echo ""
143 tests:
144 @if [ -d test ]; then (cd test; make) \
145 else echo test directory not present, sorry; fi
147 retest:
148 @if [ -d test ]; then (cd test; make clean && make) \
149 else echo test directory not present, sorry; fi
151 include:
152 -mkdir -p net netinet
153 if [ ! -f netinet/done ] ; then \
154 (cd netinet; ln -s ../*.h .; ln -s ../ip_*_pxy.c .;); \
155 (cd netinet; ln -s ../ipsend/tcpip.h tcpip.h); \
156 touch netinet/done; \
158 -(cd netinet; ln -s ../ip_rules.h ip_rules.h)
159 if [ ! -f net/done ] ; then \
160 (cd net; ln -s ../radix_ipf.h .; ); \
161 touch net/done; \
164 sunos solaris: include
165 MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" BPFILTER=$(BPFILTER) \
166 CC="$(CC)" DEBUG="$(DEBUG)" ./buildsunos
168 freebsd:
169 make freebsd`uname -r|cut -c1`
171 freebsd22: include
172 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
173 -rm -f BSD/$(CPUDIR)/ioconf.h
174 -if [ x$(IPFILKERN) != x ] ; then \
175 if [ -f /sys/compile/$(IPFILKERN)/ioconf.h ] ; then \
176 ln -s /sys/compile/$(IPFILKERN)/ioconf.h BSD/$$y; \
177 else \
178 ln -s /sys/$(IPFILKERN)/ioconf.h BSD/$$y; \
179 fi \
180 else \
181 x=`uname -v|sed -e 's@^.*:\(/[^: ]*\).*$$@\1/ioconf.h@'`; \
182 y=`uname -s|sed -e 's@/@@g'`-`uname -r`-`uname -m`; \
183 if [ ! -f $$x ] ; then \
184 echo -n "Can't find ioconf.h at $$x "; \
185 exit 1;\
186 else \
187 ln -s $$x BSD/$$y ; \
188 fi \
190 make freebsd20
192 freebsd5 freebsd6 freebsd7: include
193 if [ x$(INET6) = x ] ; then \
194 echo "#undef INET6" > opt_inet6.h; \
195 else \
196 echo "#define INET6" > opt_inet6.h; \
198 if [ "x$(IPFBPF)" = "x" ] ; then \
199 echo "#undef NBPF" > opt_bpf.h; \
200 echo "#undef NBPFILTER" > opt_bpf.h; \
201 echo "#undef DEV_BPF" > opt_bpf.h; \
202 else \
203 echo "#define NBPF" > opt_bpf.h; \
204 echo "#define NBPFILTER" > opt_bpf.h; \
205 echo "#define DEV_BPF" > opt_bpf.h; \
207 if [ x$(ENABLE_PFIL) = x ] ; then \
208 echo "#undef PFIL_HOOKS" > opt_pfil.h; \
209 else \
210 echo "#define PFIL_HOOKS" > opt_pfil.h; \
213 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
214 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) "ML=mlfk_ipl.c" "MLD=mlfk_ipl.c" "LKM=ipf.ko.5" "LKMR=ipfrule.ko.5" "DLKM=-DKLD_MODULE" "MLR=mlfk_rule.o"; cd ..)
215 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS1); cd ..)
217 freebsd4 : include
218 if [ x$(INET6) = x ] ; then \
219 echo "#undef INET6" > opt_inet6.h; \
220 else \
221 echo "#define INET6" > opt_inet6.h; \
223 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
224 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) "ML=mlfk_ipl.c" "MLD=mlfk_ipl.c" "LKM=ipf.ko" "LKMR=ipfrule.ko" "DLKM=-DKLD_MODULE" "MLR=mlfk_rule.o"; cd ..)
225 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS1); cd ..)
227 freebsd3 freebsd30: include
228 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
229 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS1) "ML=mlf_ipl.c" "MLR=mlf_rule.o" LKM= LKMR=; cd ..)
230 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS1); cd ..)
232 netbsd: include
233 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
234 @if [ ! -d /sys -o ! -d /sys/arch ] ; then \
235 echo "*****************************************************"; \
236 echo "* *"; \
237 echo "* Please extract source code to create /sys and *";\
238 echo "* /sys/arch and run 'config GENERIC' *"; \
239 echo "* *"; \
240 echo "*****************************************************"; \
241 exit 1; \
243 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) 'DLKM=-D_LKM' "ML=mln_ipl.c" LKMR= "MLR=mln_rule.o"; cd ..)
244 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS); cd ..)
246 openbsd: include
247 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
248 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) 'DLKM=-D_LKM' "ML=mlo_ipl.c" LKMR= "MLR=mlo_rule.o"; cd ..)
249 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS); cd ..)
251 freebsd20 freebsd21: include
252 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
253 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) "ML=mlf_ipl.c" "MLR=mlf_rule.o"; cd ..)
254 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS); cd ..)
256 osf tru64: null include
257 make setup "TARGOS=OSF" "CPUDIR=`OSF/cpurev`"
258 (cd OSF/`OSF/cpurev`; make build TRU64=`uname -v` TOP=../.. "DEBUG=-g" $(MFLAGS) "MACHASSERT=$(MACHASSERT)" "OSREV=`../cpurev`"; cd ..)
259 (cd OSF/`OSF/cpurev`; make -f Makefile.ipsend build TRU64=`uname -v` TOP=../.. $(MFLAGS) "OSREV=`../cpurev`"; cd ..)
261 aix: null include
262 make setup "TARGOS=AIX" "CPUDIR=`AIX/cpurev`"
263 (cd AIX/`AIX/cpurev`; make build AIX=`uname -v` TOP=../.. "DEBUG=-g" $(MFLAGS) "OSREV=`../cpurev`" BITS=`../bootbits.sh`; cd ..)
264 # (cd AIX/`AIX/cpurev`; make -f Makefile.ipsend build AIX=`uname -v` TOP=../.. $(MFLAGS) "OSREV=`../cpurev`"; cd ..)
266 bsd: include
267 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
268 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) 'DLKM=-D_LKM' "ML=mln_ipl.c" "MLR=mln_rule.o"; cd ..)
269 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS); cd ..)
271 bsdi bsdos: include
272 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
273 (cd BSD/$(CPUDIR); make build "CC=$(CC)" TOP=../.. $(MFLAGS) LKM= LKMR= ; cd ..)
274 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build "CC=$(CC)" TOP=../.. $(MFLAGS); cd ..)
276 irix IRIX: include
277 make setup TARGOS=IRIX CPUDIR=`IRIX/cpurev`
278 if [ "x${SGIREV}" = "x" ] ; then \
279 make irix "SGIREV=-D_KMEMUSER -DIRIX=`IRIX/getrev`"; \
280 else \
281 (cd IRIX/`IRIX/cpurev`; smake -l -J 1 build TOP=../.. $(DEST) $(MFLAGS) IRIX=`../getrev` SGI=$$(IRIX) CPUDIR=`../cpurev`; cd ..); \
282 (cd IRIX/`IRIX/cpurev`; make -f Makefile.ipsend build TOP=../.. $(DEST) $(MFLAGS) IRIX=`../getrev` SGI=$$(IRIX) CPUDIR=`../cpurev`; cd ..); \
285 setup:
286 -if [ ! -d $(TARGOS)/$(CPUDIR) ] ; then mkdir $(TARGOS)/$(CPUDIR); fi
287 -rm -f $(TARGOS)/$(CPUDIR)/Makefile $(TARGOS)/$(CPUDIR)/Makefile.ipsend
288 -ln -s ../Makefile $(TARGOS)/$(CPUDIR)/Makefile
289 -ln -s ../Makefile.ipsend $(TARGOS)/$(CPUDIR)/Makefile.ipsend
290 -if [ -f $(TARGOS)/Makefile.common ] ; then \
291 rm -f $(TARGOS)/$(CPUDIR)/Makefile.common; \
292 ln -s ../Makefile.common $(TARGOS)/$(CPUDIR)/Makefile.common;\
295 clean: clean-include
296 /bin/rm -rf h y.output
297 ${RM} -f core *.o ipt fils ipf ipfstat ipftest ipmon if_ipl \
298 vnode_if.h $(LKM) *~
299 /bin/rm -rf sparcv7 sparcv9 mdbgen_build
300 (cd SunOS4; $(MAKE) TOP=.. clean)
301 -(cd SunOS5; $(MAKE) TOP=.. clean)
302 (cd BSD; $(MAKE) TOP=.. clean)
303 (cd HPUX; $(MAKE) BITS=32 TOP=.. clean)
304 (cd Linux; $(MAKE) TOP=.. clean)
305 (cd OSF; $(MAKE) TOP=.. clean)
306 (cd AIX; $(MAKE) TOP=.. clean)
307 if [ "`uname -s`" = "IRIX" ]; then (cd IRIX; $(MAKE) clean); fi
308 [ -d test ] && (cd test; $(MAKE) clean)
309 (cd ipsend; $(MAKE) clean)
311 clean-include:
312 sh -c 'if [ -d netinet ] ; then cd netinet; for i in *; do if [ -h $$i ] ; then /bin/rm -f $$i; fi; done fi'
313 sh -c 'if [ -d net ] ; then cd net; for i in *; do if [ -h $$i ] ; then /bin/rm -f $$i; fi; done fi'
314 ${RM} -f netinet/done net/done
316 clean-bsd: clean-include
317 (cd BSD; make TOP=.. clean)
319 clean-hpux: clean-include
320 (cd HPUX; $(MAKE) BITS=32 clean)
322 clean-osf: clean-include
323 (cd OSF; make clean)
325 clean-aix: clean-include
326 (cd AIX; make clean)
328 clean-linux: clean-include
329 (cd Linux; make clean)
331 clean-sunos4: clean-include
332 (cd SunOS4; make clean)
334 clean-sunos5: clean-include
335 (cd SunOS5; $(MAKE) clean)
336 /bin/rm -rf sparcv?
338 clean-irix: clean-include
339 (cd IRIX; $(MAKE) clean)
341 h/xti.h:
342 mkdir -p h
343 ln -s /usr/include/sys/xti.h h
345 hpux: include h/xti.h
346 make setup CPUDIR=`HPUX/cpurev` TARGOS=HPUX
347 (cd HPUX/`HPUX/cpurev`; $(MAKE) build TOP=../.. $(DEST) $(MFLAGS) "BITS=`getconf KERNEL_BITS`" `../makeargs`; cd ..)
348 (cd HPUX/`HPUX/cpurev`; $(MAKE) -f Makefile.ipsend build TOP=../.. $(DEST) $(MFLAGS) "BITS=`getconf KERNEL_BITS`" `../makeargs`; cd ..)
350 sunos4 solaris1:
351 (cd SunOS4; make build TOP=.. "CC=$(CC)" $(DEST) $(MFLAGS); cd ..)
352 (cd SunOS4; make -f Makefile.ipsend build "CC=$(CC)" TOP=.. $(DEST) $(MFLAGS); cd ..)
354 sunos5 solaris2: null
355 (cd SunOS5/$(CPUDIR); $(MAKE) build TOP=../.. "CC=$(CC)" $(DEST) $(MFLAGS) "SOLARIS2=$(SOLARIS2)"; cd ..)
356 (cd SunOS5/$(CPUDIR); $(MAKE) -f Makefile.ipsend build TOP=../.. "CC=$(CC)" $(DEST) $(MFLAGS); cd ..)
358 linux: include
359 (cd Linux; make build LINUX=$(LINUX) TOP=.. "DEBUG=-g" "CC=$(CC)" $(MFLAGS) OBJ=$(CPUDIR) LINUXKERNEL=$(LINUXKERNEL); cd ..)
360 (cd Linux; make ipflkm LINUX=$(LINUX) TOP=.. "DEBUG=-g" "CC=$(CC)" $(MFLAGS) OBJ=$(CPUDIR) LINUXKERNEL=$(LINUXKERNEL) WORKDIR=`pwd`; cd ..)
361 # (cd Linux; make -f Makefile.ipsend build LINUX=$(LINUX) TOP=.. "CC=$(CC)" $(MFLAGS); cd ..)
363 install-linux: linux
364 (cd Linux/; make LINUX=$(LINUX) TOP=.. "DEBUG=-g" "CC=$(CC)" $(MFLAGS) OBJ=$(CPUDIR) install ; cd ..)
366 install-bsd:
367 (cd BSD/$(CPUDIR); make install "TOP=../.." $(MFLAGS); cd ..)
368 (cd BSD/$(CPUDIR); make -f Makefile.ipsend INSTALL=$(INSTALL) install "TOP=../.." $(MFLAGS); cd ..)
370 install-sunos4: solaris
371 (cd SunOS4; $(MAKE) CPU=$(CPU) TOP=.. install)
373 install-sunos5: solaris null
374 (cd SunOS5; $(MAKE) TOP=.. install)
376 install-aix:
377 (cd AIX/`AIX/cpurev`; make install "TOP=../.." $(MFLAGS); cd ..)
378 # (cd AIX/`AIX/cpurev`; make -f Makefile.ipsend INSTALL=$(INSTALL) install "TOP=../.." $(MFLAGS); cd ..)
380 install-hpux: hpux
381 (cd HPUX/`HPUX/cpurev`; $(MAKE) CPU=$(CPU) TOP=../.. "BITS=`getconf KERNEL_BITS`" install)
383 install-irix: irix
384 (cd IRIX; smake install CPU=$(CPU) TOP=.. $(DEST) $(MFLAGS) CPUDIR=`./cpurev`)
386 install-osf install-tru64:
387 (cd OSF/`OSF/cpurev`; make install "TOP=../.." $(MFLAGS); cd ..)
389 do-cvs:
390 find . -type d -name CVS -print | xargs /bin/rm -rf
391 find . -type f -name .cvsignore -print | xargs /bin/rm -f
392 /bin/rm -f ip_msnrpc_pxy.c ip_sunrpc_pxy.c
394 ip_rules.c ip_rules.h: rules/ip_rules tools/ipfcomp.c
395 -./ipf -n -cc -f rules/ip_rules 2>/dev/null 1>&2
397 null:
398 @if [ "`$(MAKE) -v 2>&1 | sed -ne 's/GNU.*/GNU/p'`" = "GNU" ] ; then \
399 echo 'Do not use GNU make (gmake) to compile IPFilter'; \
400 exit 1; \
402 -@echo make ok
404 mdb:
405 /bin/rm -rf mdbgen_build
406 mdbgen -D_KERNEL -DIPFILTER_LOG -DIPFILTER_LOOKUP -DSUNDDI \
407 -DIPFILTER_SCAN -DIPFILTER_LKM -DSOLARIS2=10 -n ipf_mdb -k \
408 -I/home/dr146992/pfil -I/home/dr146992/ipf -f \
409 /usr/include/netinet/in_systm.h,/usr/include/sys/ethernet.h,/usr/include/netinet/in.h,/usr/include/netinet/ip.h,/usr/include/netinet/ip_var.h,/usr/include/netinet/tcp.h,/usr/include/netinet/tcpip.h,/usr/include/netinet/ip_icmp.h,/usr/include/netinet/udp.h,ip_compat.h,ip_fil.h,ip_nat.h,ip_state.h,ip_proxy.h,ip_scan.h