Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ipf / Makefile
blobaca4676b0bb294cda01f3e9a0bfd251d127169cd
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 # Id: Makefile,v 2.76.2.29 2009/07/18 19:05:35 darrenr Exp
10 SHELL=/bin/sh
11 BINDEST=/usr/local/bin
12 SBINDEST=/sbin
13 MANDIR=/usr/local/man
14 #To test prototyping
15 #CC=gcc -Wstrict-prototypes -Wmissing-prototypes
16 # -Wunused -Wuninitialized
17 #CC=gcc
18 #CC=cc -Dconst=
19 DEBUG=-g
20 # -O
21 CFLAGS=-I$$(TOP) -D_BSD_SOURCE
22 CPU=`uname -m`
23 CPUDIR=`uname -s|sed -e 's@/@@g'`-`uname -r`-`uname -m`
24 OBJ=.
26 # To enable this to work as a Loadable Kernel Module...
28 IPFLKM=-DIPFILTER_LKM
30 # To enable logging of blocked/passed packets...
32 IPFLOG=-DIPFILTER_LOG
34 # To enable loading filter rules compiled to C code...
36 #COMPIPF=-DIPFILTER_COMPILED
38 # To enable synchronisation between IPFilter hosts
40 #SYNC=-DIPFILTER_SYNC
42 # To enable extended IPFilter functionality
44 LOOKUP=-DIPFILTER_LOOKUP -DIPFILTER_SCAN
46 # The facility you wish to log messages from ipmon to syslogd with.
48 LOGFAC=-DLOGFAC=LOG_LOCAL0
50 # To enable rules to be written with BPF syntax, uncomment these two lines.
52 # WARNING: If you're building a commercial product based on IPFilter, using
53 # this options *may* infringe at least one patent held by CheckPoint
54 # (5,606,668.)
56 #IPFBPF=-DIPFILTER_BPF -I/usr/local/include
57 #LIBBPF=-L/usr/local/lib -lpcap
59 # HP-UX and Solaris require this uncommented for BPF.
61 #BPFILTER=bpf_filter.o
63 # LINUXKERNEL is the path to the top of your Linux kernel source tree.
64 # By default IPFilter looks for /usr/src/linux, but you may have to change
65 # it to /usr/src/linux-2.4 or similar.
67 LINUXKERNEL=/usr/src/kernels/2.6.29.5-191.fc11.i586
68 LINUX=`uname -r | awk -F. ' { printf"%d",$$1;for(i=1;i<NF&&i<3;i++){printf("%02d",$$(i+1));}}'`
72 #BUILDROOT=/usr/src/redhat/BUILD/ipfilter
73 BUILDROOT=${HOME}/rpmbuild/BUILDROOT/ipfilter-4.1.32-1.i386
76 # All of the compile-time options are here, used for compiling the userland
77 # tools for regression testing. Well, all except for IPFILTER_LKM, of course.
79 ALLOPTS=-DIPFILTER_LOG -DIPFILTER_LOOKUP \
80 -DIPFILTER_SCAN -DIPFILTER_SYNC -DIPFILTER_CKSUM
83 # Uncomment the next 3 lines if you want to view the state table a la top(1)
84 # (requires that you have installed ncurses).
85 #STATETOP_CFLAGS=-DSTATETOP
87 # Where to find the ncurses include files (if not in default path),
89 #STATETOP_INC=
90 #STATETOP_INC=-I/usr/local/include
92 # How to link the ncurses library
94 #STATETOP_LIB=-lncurses
95 #STATETOP_LIB=-L/usr/local/lib -lncurses
98 # Uncomment this when building IPv6 capability.
100 #INET6=-DUSE_INET6
102 # For packets which don't match any pass rules or any block rules, set either
103 # FR_PASS or FR_BLOCK (respectively). It defaults to FR_PASS if left
104 # undefined. This is ignored for ipftest, which can thus return three
105 # results: pass, block and nomatch. This is the sort of "block unless
106 # explicitly allowed" type #define switch.
108 POLICY=-DIPF_DEFAULT_PASS=FR_PASS
110 MFLAGS1='CFLAGS=$(CFLAGS) $(ARCHINC) $(SOLARIS2) $(SGIREV) $(INET6)' \
111 "IPFLOG=$(IPFLOG)" "LOGFAC=$(LOGFAC)" "POLICY=$(POLICY)" \
112 "SOLARIS2=$(SOLARIS2)" "DEBUG=$(DEBUG)" "DCPU=$(CPU)" \
113 "LIBBPF=$(LIBBPF)" "CPUDIR=$(CPUDIR)" "IPFBPF=$(IPFBPF)" \
114 'STATETOP_CFLAGS=$(STATETOP_CFLAGS)' "BPFILTER=$(BPFILTER)" \
115 'STATETOP_INC=$(STATETOP_INC)' 'STATETOP_LIB=$(STATETOP_LIB)' \
116 "BITS=$(BITS)" "OBJ=$(OBJ)" "LOOKUP=$(LOOKUP)" "COMPIPF=$(COMPIPF)" \
117 'SYNC=$(SYNC)' 'ALLOPTS=$(ALLOPTS)' 'LIBBPF=$(LIBBPF)'
118 MFLAGS=$(MFLAGS1) "IPFLKM=$(IPFLKM)"
119 MACHASSERT=`/bin/ls -1 /usr/sys/*/mach_assert.h | head -1`
121 SHELL=/bin/sh
123 ########## ########## ########## ########## ########## ########## ##########
125 CP=/bin/cp
126 RM=/bin/rm
127 CHMOD=/bin/chmod
128 INSTALL=install
131 all:
132 @echo "Chose one of the following targets for making IP filter:"
133 @echo ""
134 @echo "solaris - auto-selects SunOS4.1.x/Solaris 2.3-6/Solaris2.4-6x86"
135 @echo "netbsd - compile for NetBSD"
136 @echo "openbsd - compile for OpenBSD"
137 @echo "freebsd20 - compile for FreeBSD 2.0, 2.1 or earlier"
138 @echo "freebsd22 - compile for FreeBSD-2.2 or greater"
139 @echo "freebsd - compile for all other versions of FreeBSD"
140 @echo "bsd - compile for generic 4.4BSD systems"
141 @echo "bsdi - compile for BSD/OS"
142 @echo "irix - compile for SGI IRIX"
143 @echo "hpux - compile for HP-UX 11.00"
144 @echo "osf - compile for OSF/Tru64 5.1"
145 @echo ""
147 tests:
148 @if [ -d test ]; then (cd test; make) \
149 else echo test directory not present, sorry; fi
151 retest:
152 @if [ -d test ]; then (cd test; make clean && make) \
153 else echo test directory not present, sorry; fi
155 include:
156 -mkdir -p net netinet
157 if [ ! -f netinet/done ] ; then \
158 (cd netinet; ln -s ../*.h .; ln -s ../ip_*_pxy.c .;); \
159 (cd netinet; ln -s ../ipsend/tcpip.h tcpip.h); \
160 touch netinet/done; \
162 -(cd netinet; ln -s ../ip_rules.h ip_rules.h)
163 if [ ! -f net/done ] ; then \
164 (cd net; ln -s ../radix_ipf.h .; ); \
165 touch net/done; \
168 sunos solaris: include
169 MAKE="$(MAKE)" MAKEFLAGS="$(MAKEFLAGS)" BPFILTER=$(BPFILTER) \
170 CC="$(CC)" DEBUG="$(DEBUG)" ./buildsunos
172 freebsd:
173 make freebsd`uname -r|cut -c1`
175 freebsd22: include
176 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
177 -rm -f BSD/$(CPUDIR)/ioconf.h
178 -if [ x$(IPFILKERN) != x ] ; then \
179 if [ -f /sys/compile/$(IPFILKERN)/ioconf.h ] ; then \
180 ln -s /sys/compile/$(IPFILKERN)/ioconf.h BSD/$$y; \
181 else \
182 ln -s /sys/$(IPFILKERN)/ioconf.h BSD/$$y; \
183 fi \
184 else \
185 x=`uname -v|sed -e 's@^.*:\(/[^: ]*\).*$$@\1/ioconf.h@'`; \
186 y=`uname -s|sed -e 's@/@@g'`-`uname -r`-`uname -m`; \
187 if [ ! -f $$x ] ; then \
188 echo -n "Can't find ioconf.h at $$x "; \
189 exit 1;\
190 else \
191 ln -s $$x BSD/$$y ; \
192 fi \
194 make freebsd20
196 freebsd5 freebsd6 freebsd7 freebsd8: include
197 if [ x$(INET6) = x ] ; then \
198 echo "#undef INET6" > opt_inet6.h; \
199 else \
200 echo "#define INET6" > opt_inet6.h; \
202 if [ "x$(IPFBPF)" = "x" ] ; then \
203 echo "#undef NBPF" > opt_bpf.h; \
204 echo "#undef NBPFILTER" > opt_bpf.h; \
205 echo "#undef DEV_BPF" > opt_bpf.h; \
206 else \
207 echo "#define NBPF" > opt_bpf.h; \
208 echo "#define NBPFILTER" > opt_bpf.h; \
209 echo "#define DEV_BPF" > opt_bpf.h; \
211 if [ x$(ENABLE_PFIL) = x ] ; then \
212 echo "#undef PFIL_HOOKS" > opt_pfil.h; \
213 else \
214 echo "#define PFIL_HOOKS" > opt_pfil.h; \
217 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
218 (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 ..)
219 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS1); cd ..)
221 freebsd4 : include
222 if [ x$(INET6) = x ] ; then \
223 echo "#undef INET6" > opt_inet6.h; \
224 else \
225 echo "#define INET6" > opt_inet6.h; \
227 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
228 (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 ..)
229 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS1); cd ..)
231 freebsd3 freebsd30: include
232 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
233 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS1) "ML=mlf_ipl.c" "MLR=mlf_rule.o" LKM= LKMR=; cd ..)
234 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS1); cd ..)
236 netbsd: include
237 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
238 @if [ ! -d /sys -o ! -d /sys/arch ] ; then \
239 echo "*****************************************************"; \
240 echo "* *"; \
241 echo "* Please extract source code to create /sys and *";\
242 echo "* /sys/arch and run 'config GENERIC' *"; \
243 echo "* *"; \
244 echo "*****************************************************"; \
245 exit 1; \
247 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) 'DLKM=-D_LKM' "ML=mln_ipl.c" LKMR= "MLR=mln_rule.o"; cd ..)
248 # (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS); cd ..)
250 openbsd: include
251 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
252 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) 'DLKM=-D_LKM' "ML=mlo_ipl.c" LKMR= "MLR=mlo_rule.o"; cd ..)
253 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS); cd ..)
255 freebsd20 freebsd21: include
256 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
257 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) "ML=mlf_ipl.c" "MLR=mlf_rule.o"; cd ..)
258 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS); cd ..)
260 osf tru64: null include
261 make setup "TARGOS=OSF" "CPUDIR=`OSF/cpurev`"
262 (cd OSF/`OSF/cpurev`; make build TRU64=`uname -v` TOP=../.. "DEBUG=-g" $(MFLAGS) "MACHASSERT=$(MACHASSERT)" "OSREV=`../cpurev`"; cd ..)
263 (cd OSF/`OSF/cpurev`; make -f Makefile.ipsend build TRU64=`uname -v` TOP=../.. $(MFLAGS) "OSREV=`../cpurev`"; cd ..)
265 aix: null include
266 make setup "TARGOS=AIX" "CPUDIR=`AIX/cpurev`"
267 (cd AIX/`AIX/cpurev`; make build AIX=`uname -v` TOP=../.. "DEBUG=-g" $(MFLAGS) "OSREV=`../cpurev`" BITS=`../bootbits.sh`; cd ..)
268 # (cd AIX/`AIX/cpurev`; make -f Makefile.ipsend build AIX=`uname -v` TOP=../.. $(MFLAGS) "OSREV=`../cpurev`"; cd ..)
270 bsd: include
271 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
272 (cd BSD/$(CPUDIR); make build TOP=../.. $(MFLAGS) 'DLKM=-D_LKM' "ML=mln_ipl.c" "MLR=mln_rule.o"; cd ..)
273 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build TOP=../.. $(MFLAGS); cd ..)
275 bsdi bsdos: include
276 make setup "TARGOS=BSD" "CPUDIR=$(CPUDIR)"
277 (cd BSD/$(CPUDIR); make build "CC=$(CC)" TOP=../.. $(MFLAGS) LKM= LKMR= ; cd ..)
278 (cd BSD/$(CPUDIR); make -f Makefile.ipsend build "CC=$(CC)" TOP=../.. $(MFLAGS); cd ..)
280 irix IRIX: include
281 make setup TARGOS=IRIX CPUDIR=`IRIX/cpurev`
282 if [ "x${SGIREV}" = "x" ] ; then \
283 make irix "SGIREV=-D_KMEMUSER -DIRIX=`IRIX/getrev`"; \
284 else \
285 (cd IRIX/`IRIX/cpurev`; smake -l -J 1 build TOP=../.. $(DEST) $(MFLAGS) IRIX=`../getrev` SGI=$$(IRIX) CPUDIR=`../cpurev`; cd ..); \
286 (cd IRIX/`IRIX/cpurev`; make -f Makefile.ipsend build TOP=../.. $(DEST) $(MFLAGS) IRIX=`../getrev` SGI=$$(IRIX) CPUDIR=`../cpurev`; cd ..); \
289 setup:
290 -if [ ! -d $(TARGOS)/$(CPUDIR) ] ; then mkdir $(TARGOS)/$(CPUDIR); fi
291 -rm -f $(TARGOS)/$(CPUDIR)/Makefile $(TARGOS)/$(CPUDIR)/Makefile.ipsend
292 -ln -s ../Makefile $(TARGOS)/$(CPUDIR)/Makefile
293 -ln -s ../Makefile.ipsend $(TARGOS)/$(CPUDIR)/Makefile.ipsend
294 -if [ -f $(TARGOS)/Makefile.common ] ; then \
295 rm -f $(TARGOS)/$(CPUDIR)/Makefile.common; \
296 ln -s ../Makefile.common $(TARGOS)/$(CPUDIR)/Makefile.common;\
299 clean: clean-include
300 /bin/rm -rf h y.output
301 ${RM} -f core *.o ipt fils ipf ipfstat ipftest ipmon if_ipl \
302 vnode_if.h $(LKM) *~
303 /bin/rm -rf sparcv7 sparcv9 mdbgen_build
304 (cd SunOS4; $(MAKE) TOP=.. clean)
305 -(cd SunOS5; $(MAKE) TOP=.. clean)
306 (cd BSD; $(MAKE) TOP=.. clean)
307 (cd HPUX; $(MAKE) BITS=32 TOP=.. clean)
308 (cd Linux; $(MAKE) TOP=.. clean)
309 (cd OSF; $(MAKE) TOP=.. clean)
310 (cd AIX; $(MAKE) TOP=.. clean)
311 if [ "`uname -s`" = "IRIX" ]; then (cd IRIX; $(MAKE) clean); fi
312 [ -d test ] && (cd test; $(MAKE) clean)
313 (cd ipsend; $(MAKE) clean)
315 clean-include:
316 sh -c 'if [ -d netinet ] ; then cd netinet; for i in *; do if [ -h $$i ] ; then /bin/rm -f $$i; fi; done fi'
317 sh -c 'if [ -d net ] ; then cd net; for i in *; do if [ -h $$i ] ; then /bin/rm -f $$i; fi; done fi'
318 ${RM} -f netinet/done net/done
320 clean-bsd: clean-include
321 (cd BSD; make TOP=.. clean)
323 clean-hpux: clean-include
324 (cd HPUX; $(MAKE) BITS=32 clean)
326 clean-osf: clean-include
327 (cd OSF; make clean)
329 clean-aix: clean-include
330 (cd AIX; make clean)
332 clean-linux: clean-include
333 (cd Linux; make clean)
335 clean-sunos4: clean-include
336 (cd SunOS4; make clean)
338 clean-sunos5: clean-include
339 (cd SunOS5; $(MAKE) clean)
340 /bin/rm -rf sparcv?
342 clean-irix: clean-include
343 (cd IRIX; $(MAKE) clean)
345 h/xti.h:
346 mkdir -p h
347 ln -s /usr/include/sys/xti.h h
349 hpux: include h/xti.h
350 make setup CPUDIR=`HPUX/cpurev` TARGOS=HPUX
351 (cd HPUX/`HPUX/cpurev`; $(MAKE) build TOP=../.. $(DEST) $(MFLAGS) "BITS=`getconf KERNEL_BITS`" `../makeargs`; cd ..)
352 (cd HPUX/`HPUX/cpurev`; $(MAKE) -f Makefile.ipsend build TOP=../.. $(DEST) $(MFLAGS) "BITS=`getconf KERNEL_BITS`" `../makeargs`; cd ..)
354 sunos4 solaris1:
355 (cd SunOS4; make build TOP=.. "CC=$(CC)" $(DEST) $(MFLAGS); cd ..)
356 (cd SunOS4; make -f Makefile.ipsend build "CC=$(CC)" TOP=.. $(DEST) $(MFLAGS); cd ..)
358 sunos5 solaris2: null
359 (cd SunOS5/$(CPUDIR); $(MAKE) build TOP=../.. "CC=$(CC)" $(DEST) $(MFLAGS) "SOLARIS2=$(SOLARIS2)"; cd ..)
360 (cd SunOS5/$(CPUDIR); $(MAKE) -f Makefile.ipsend build TOP=../.. "CC=$(CC)" $(DEST) $(MFLAGS); cd ..)
362 linux: include
363 (cd Linux; make build LINUX=$(LINUX) TOP=.. "DEBUG=-g" "CC=$(CC)" $(MFLAGS) OBJ=$(CPUDIR) LINUXKERNEL=$(LINUXKERNEL); cd ..)
364 (cd Linux; make ipflkm LINUX=$(LINUX) TOP=.. "DEBUG=-g" "CC=$(CC)" $(MFLAGS) OBJ=$(CPUDIR) LINUXKERNEL=$(LINUXKERNEL) WORKDIR=`pwd`; cd ..)
365 # (cd Linux; make -f Makefile.ipsend build LINUX=$(LINUX) TOP=.. "CC=$(CC)" $(MFLAGS); cd ..)
367 install-linux: linux
368 (cd Linux/; make LINUX=$(LINUX) TOP=.. "DEBUG=-g" "CC=$(CC)" $(MFLAGS) OBJ=$(CPUDIR) ROOTDIR=$(BUILDROOT) install ; cd ..)
370 install-bsd:
371 (cd BSD/$(CPUDIR); make install "TOP=../.." $(MFLAGS); cd ..)
372 (cd BSD/$(CPUDIR); make -f Makefile.ipsend INSTALL=$(INSTALL) install "TOP=../.." $(MFLAGS); cd ..)
374 install-sunos4: solaris
375 (cd SunOS4; $(MAKE) CPU=$(CPU) TOP=.. install)
377 install-sunos5: solaris null
378 (cd SunOS5; $(MAKE) TOP=.. install)
380 install-aix:
381 (cd AIX/`AIX/cpurev`; make install "TOP=../.." $(MFLAGS); cd ..)
382 # (cd AIX/`AIX/cpurev`; make -f Makefile.ipsend INSTALL=$(INSTALL) install "TOP=../.." $(MFLAGS); cd ..)
384 install-hpux: hpux
385 (cd HPUX/`HPUX/cpurev`; $(MAKE) CPU=$(CPU) TOP=../.. "BITS=`getconf KERNEL_BITS`" install)
387 install-irix: irix
388 (cd IRIX; smake install CPU=$(CPU) TOP=.. $(DEST) $(MFLAGS) CPUDIR=`./cpurev`)
390 install-osf install-tru64:
391 (cd OSF/`OSF/cpurev`; make install "TOP=../.." $(MFLAGS); cd ..)
393 do-cvs:
394 find . -type d -name CVS -print | xargs /bin/rm -rf
395 find . -type f -name .cvsignore -print | xargs /bin/rm -f
396 /bin/rm -f ip_msnrpc_pxy.c ip_sunrpc_pxy.c
398 ip_rules.c ip_rules.h: rules/ip_rules tools/ipfcomp.c
399 -./ipf -n -cc -f rules/ip_rules 2>/dev/null 1>&2
401 null:
402 @if [ "`$(MAKE) -v 2>&1 | sed -ne 's/GNU.*/GNU/p'`" = "GNU" ] ; then \
403 echo 'Do not use GNU make (gmake) to compile IPFilter'; \
404 exit 1; \
406 -@echo make ok
408 mdb:
409 /bin/rm -rf mdbgen_build
410 mdbgen -D_KERNEL -DIPFILTER_LOG -DIPFILTER_LOOKUP -DSUNDDI \
411 -DIPFILTER_SCAN -DIPFILTER_LKM -DSOLARIS2=10 -n ipf_mdb -k \
412 -I/home/dr146992/pfil -I/home/dr146992/ipf -f \
413 /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