Remove radix from compilation.
[ipfw.git] / dummynet / Makefile
1 #
2 # $Id$
3 #
4 # gnu Makefile to build linux module for ipfw+dummynet.
5 #
6 # The defaults are set to build without modifications on PlanetLab
7 # and possibly 2.6 versions.
8 #
9
10 # Some variables need to have specific names, because they are used
11 # by the build infrastructure on Linux and OpenWrt. They are:
12
13 #   ccflags-y   additional $(CC) flags
14 #   M           used by Kbuild, we must set it to `pwd`
15 #   obj-m       list of .o modules to build
16 #   $(MOD)-y    for each $MOD in obj-m, the list of objects
17 #   obj-y       same as above, for openwrt
18 #   O_TARGET    the link target, for openwrt
19 #   EXTRA_CFLAGS as the name says... in openwrt
20 #   EXTRA_CFLAGS is used in 2.6.22 module kernel compilation too
21 #   KERNELPATH  the path to the kernel sources or headers
22 #
23 # Not sure about this (the name might be reserved)
24 #   ipfw-cflags         our flags for building the module
25 #
26 # Other variables are only private and can be renamed. They include:
27 #
28 #   VER         linux version we are building for (2.4 2.6 or openwrt)
29 #---
30
31 $(warning including dummynet/Makefile)
32
33 # lets default for 2.6 for planetlab builds
34 VER ?= 2.6
35
36 # General values
37 obj-m := ipfw_mod.o
38
39 # generic cflags used on all systems
40 #ipfw-cflags += -Dradix
41 ipfw-cflags += -DIPFIREWALL_DEFAULT_TO_ACCEPT -DTRACE
42 # _BSD_SOURCE enables __FAVOR_BSD (udp/tcp bsd structs instead of posix)
43 ipfw-cflags += -D_BSD_SOURCE
44 ipfw-cflags += -DKERNEL_MODULE  # build linux kernel module
45 # the two header trees for empty and override files
46 ipfw-cflags += -I $(M)/include_e -I $(M)/include
47 ipfw-cflags += -include $(M)/../glue.h  # headers
48
49 $(warning "---- Building dummynet kernel module for Version $(VER)")
50 # We have three sections for OpenWrt, Linux 2.4 and Linux 2.6
51 #
52 ifeq ($(VER),openwrt)
53   M=.
54   obj-y := ipfw2_mod.o bsd_compat.o \
55         in_cksum.o ip_dummynet.o ip_fw2.o ip_fw_pfil.o
56   O_TARGET := ipfw_mod.o
57
58   # xcflags-y is a temporary variable where we store build options
59   xcflags-y += -O1 -DLINUX_24
60   xcflags-y += -g
61
62   EXTRA_CFLAGS := $(xcflags-y) $(ipfw-cflags)
63
64   # we should not export anything
65   #export-objs := ipfw2_mod.o
66 -include $(TOPDIR)/Rules.make
67
68 else    # !openwrt, below we do linux builds for 2.4 and 2.6
69
70   # KERNELPATH is where the kernel headers reside. On PlanetLab
71   # it is set already by the build system.
72   # We can override it from the command line, or let the system guess.
73
74 ifneq ($(shell echo $(VER)|grep '2.4'),)
75   # The linux 2.4 version
76   # guess the kernel path -- or is it under /lib/modules ?
77   KERNELPATH ?= /usr/src/`uname -r`/build
78
79   # Guess the gcc include directory
80   # The gcc version is in the last line returned by gcc -v
81   # gcc version 4.3.2 (Debian 4.3.2-1.1)
82   MYGCC_VER ?= $(shell gcc -v 2>&1 |tail -n 1 | cut -d " " -f 3)
83   # We don't know the exact directory unde /usr/lib/gcc so we guess
84   MYGCC_INCLUDE ?= $(shell echo /usr/lib/gcc/*/$(MYGCC_VER) | cut -d " " -f 1)/include
85   $(warning "---- gcc includes guessed to $(MYGCC_INCLUDE)")
86
87   # additional warning
88   #WARN = -Wp,-MD,/home/luigi/ports-luigi/dummynet-branches/ipfw_mod/dummynet/.ipfw2_mod.o.d
89   #WARN += -Iinclude  -include include/linux/autoconf.h
90
91   WARN += -Wall -Wundef
92   WARN += -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
93   WARN += -fno-common -Werror-implicit-function-declaration
94   # WARN += -O2  -fno-stack-protector -m32 -msoft-float -mregparm=3
95   # -mregparm=3 gives a printk error
96   WARN += -m32 -msoft-float # -mregparm=3
97   #WARN += -freg-struct-return -mpreferred-stack-boundary=2
98   WARN += -Wno-sign-compare
99   WARN += -Wdeclaration-after-statement -Wno-pointer-sign
100
101   ccflags-y += -O1 -DLINUX_24
102   CFLAGS = -DMODULE -D__KERNEL__ -nostdinc \
103         -isystem ${KERNELPATH}/include -isystem $(MYGCC_INCLUDE) ${ccflags-y}
104   # The Main target
105 all: mod24
106
107 else
108 ifeq ($(IPFW_PLANETLAB),1)
109   $(warning "---- Building for PlanetLab")
110   ipfw-cflags += -DIPFW_PLANETLAB        # PlanetLab compilation
111 endif
112   # if not set, use the version from the installed system
113   KERNELPATH ?= /lib/modules/`uname -r`/build
114   # the latest kernel
115   #KERNELPATH = /usr/src/linux-2.6.22
116   $(warning "---- Building Version 2.6 $(VER) in $(KERNELPATH)")
117   WARN := -O1 -Wall -Werror -DDEBUG_SPINLOCK -DDEBUG_MUTEXES
118   # The main target
119
120   # Required by kernel <= 2.6.22, ccflags-y is used on newer version
121   LINUX_VERSION_CODE := $(shell grep LINUX_VERSION_CODE $(KERNELPATH)/include/linux/version.h|cut -d " " -f3)
122   ifeq ($(LINUX_VERSION_CODE),132630)
123     EXTRA_CFLAGS += $(ccflags-y)
124   endif
125
126 all: include_e
127         $(MAKE) -C $(KERNELPATH) V=1 M=`pwd` modules
128 endif
129
130 #-- back to the common section of code
131
132 # the list of objects used to build the module
133 ipfw_mod-y = $(IPFW_SRCS:%.c=%.o)
134
135 # Original ipfw and dummynet sources + FreeBSD stuff,
136 IPFW_SRCS = ip_fw2.c ip_dummynet.c ip_fw_pfil.c in_cksum.c
137 #IPFW_SRCS += radix.c
138 # Module glue and functions missing in linux
139 IPFW_SRCS += ipfw2_mod.c bsd_compat.c hashtable.c new_glue.c
140
141 # additional $(CC) flags
142 ccflags-y += $(WARN)
143 ccflags-y += $(ipfw-cflags)
144 ccflags-y += -g
145
146 mod24: include_e $(obj-m)
147
148 $(obj-m): $(ipfw_mod-y)
149         $(LD) $(LDFLAGS) -m elf_i386 -r -o $@ $^
150 clean:
151         -rm -f *.o *.ko Module.symvers *.mod.c
152         -rm -rf include_e
153
154 distclean: clean
155         -rm -f .*cmd modules.order opt_*
156         -rm -rf .tmp_versions include_e
157         -rm -rf .*.o.d
158
159 # support to create empty dirs and files in include_e/
160 # EDIRS is the list of directories, EFILES is the list of files.
161
162 EDIRS= altq arpa machine net netinet netinet6 sys
163
164 EFILES += opt_inet6.h opt_ipfw.h opt_ipsec.h
165 EFILES += opt_mbuf_stress_test.h opt_param.h
166
167 EFILES += altq/if_altq.h
168 EFILES += arpa/inet.h
169 EFILES += machine/in_cksum.h
170 EFILES += net/ethernet.h net/netisr.h net/pf_mtag.h
171 EFILES += net/vnet.h
172
173 EFILES += netinet/ether.h netinet/icmp6.h netinet/if_ether.h
174 EFILES += netinet/in.h netinet/in_pcb.h netinet/in_var.h
175 EFILES +=  netinet/ip_carp.h netinet/ip_var.h netinet/pim.h
176 EFILES += netinet/sctp.h netinet/tcp_timer.h netinet/tcpip.h
177 EFILES += netinet/udp_var.h
178
179 EFILES += netinet6/ip6_var.h
180
181 EFILES += sys/_lock.h sys/_rwlock.h sys/_mutex.h sys/jail.h
182 EFILES += sys/condvar.h sys/eventhandler.h
183 EFILES += sys/limits.h sys/lock.h sys/mutex.h sys/priv.h
184 EFILES += sys/proc.h sys/rwlock.h sys/socket.h sys/socketvar.h
185 EFILES += sys/sysctl.h sys/time.h sys/ucred.h
186
187 M ?= $(shell pwd)
188 include_e:
189         echo "running in $M"
190         -@rm -rf $(M)/include_e opt_*
191         -@mkdir -p $(M)/include_e
192         -@(cd $(M)/include_e; mkdir -p $(EDIRS); touch $(EFILES) )
193
194 endif # !openwrt