X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=dummynet%2FMakefile;h=6c6d9f6c15d3aec0b98128dae0c4be0bc475fc9d;hb=4e189c94aef3d3e9a4e8edfd2bb989feeb5d5e26;hp=eab794af096c8979c4dfea7fc6e2e4d479c97e84;hpb=5ad9fec40da13c449d50def12f9cea6e24b6a708;p=ipfw.git diff --git a/dummynet/Makefile b/dummynet/Makefile index eab794a..6c6d9f6 100644 --- a/dummynet/Makefile +++ b/dummynet/Makefile @@ -5,7 +5,6 @@ # # The defaults are set to build without modifications on PlanetLab # and possibly 2.6 versions. -# # Some variables need to have specific names, because they are used # by the build infrastructure on Linux and OpenWrt. They are: @@ -33,27 +32,40 @@ $(warning including dummynet/Makefile) # lets default for 2.6 for planetlab builds VER ?= 2.6 -# General values +#--- General values for all types of build --- +# obj-m is the target module obj-m := ipfw_mod.o +#-- the list of source files. IPFW_SRCS is our own name. +# Original ipfw and dummynet sources + FreeBSD stuff, +IPFW_SRCS = ip_fw2.c ip_dummynet.c ip_fw_pfil.c in_cksum.c +IPFW_SRCS += radix.c +# Module glue and functions missing in linux +IPFW_SRCS += ipfw2_mod.c bsd_compat.c + # generic cflags used on all systems -ipfw-cflags += -Dradix -ipfw-cflags += -DIPFIREWALL_DEFAULT_TO_ACCEPT -DTRACE +#ipfw-cflags += -DIPFW_HASHTABLES +ipfw-cflags += -DIPFIREWALL_DEFAULT_TO_ACCEPT # _BSD_SOURCE enables __FAVOR_BSD (udp/tcp bsd structs instead of posix) ipfw-cflags += -D_BSD_SOURCE ipfw-cflags += -DKERNEL_MODULE # build linux kernel module # the two header trees for empty and override files -ipfw-cflags += -I $(M)/include_e -I $(M)/include +ipfw-cflags += -I $(M)/include_e +ipfw-cflags += -I $(M)/include ipfw-cflags += -include $(M)/../glue.h # headers +ipfw-cflags += -include $(M)/missing.h # headers $(warning "---- Building dummynet kernel module for Version $(VER)") + # We have three sections for OpenWrt, Linux 2.4 and Linux 2.6 -# + ifeq ($(VER),openwrt) + #--- The Makefile section for openwrt --- + # We do not include a dependency on include_e as it is called + # by Makefile.openwrt in Build/Prepare M=. - obj-y := ipfw2_mod.o bsd_compat.o \ - in_cksum.o ip_dummynet.o ip_fw2.o ip_fw_pfil.o - O_TARGET := ipfw_mod.o + obj-y := $(IPFW_SRCS:%.c=%.o) + O_TARGET := $(obj-m) # xcflags-y is a temporary variable where we store build options xcflags-y += -O1 -DLINUX_24 @@ -72,22 +84,22 @@ else # !openwrt, below we do linux builds for 2.4 and 2.6 # We can override it from the command line, or let the system guess. ifneq ($(shell echo $(VER)|grep '2.4'),) - # The linux 2.4 version + # Makefile section for the linux 2.4 version + # tested on linux-2.4.35.4, does not work with 2.4.37 + # # guess the kernel path -- or is it under /lib/modules ? - KERNELPATH ?= /usr/src/`uname -r`/build - - # Guess the gcc include directory - # The gcc version is in the last line returned by gcc -v - # gcc version 4.3.2 (Debian 4.3.2-1.1) - MYGCC_VER ?= $(shell gcc -v 2>&1 |tail -n 1 | cut -d " " -f 3) - # We don't know the exact directory unde /usr/lib/gcc so we guess + KERNELPATH ?= /usr/src/`uname -r` + + # We need to figure out the gcc include directory, if not + # set by the user through MYGCC_INCLUDE + # Find compiler version (3rd field in last line returned by gcc -v) + # e.g. gcc version 4.3.2 (Debian 4.3.2-1.1) + MYGCC_VER ?= $(shell $(CC) -v 2>&1 |tail -n 1 | cut -d " " -f 3) + # We don't know the exact directory under /usr/lib/gcc so we guess MYGCC_INCLUDE ?= $(shell echo /usr/lib/gcc/*/$(MYGCC_VER) | cut -d " " -f 1)/include $(warning "---- gcc includes guessed to $(MYGCC_INCLUDE)") # additional warning - #WARN = -Wp,-MD,/home/luigi/ports-luigi/dummynet-branches/ipfw_mod/dummynet/.ipfw2_mod.o.d - #WARN += -Iinclude -include include/linux/autoconf.h - WARN += -Wall -Wundef WARN += -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing WARN += -fno-common -Werror-implicit-function-declaration @@ -96,22 +108,29 @@ ifneq ($(shell echo $(VER)|grep '2.4'),) WARN += -m32 -msoft-float # -mregparm=3 #WARN += -freg-struct-return -mpreferred-stack-boundary=2 WARN += -Wno-sign-compare - WARN += -Wdeclaration-after-statement -Wno-pointer-sign + WARN += -Wdeclaration-after-statement + ifneq ($(MYGCC_VER),3.4.6) + WARN += -Wno-pointer-sign + endif ccflags-y += -O1 -DLINUX_24 CFLAGS = -DMODULE -D__KERNEL__ -nostdinc \ - -isystem ${KERNELPATH}/include -isystem $(MYGCC_INCLUDE) ${ccflags-y} + -isystem ${KERNELPATH}/include -isystem $(MYGCC_INCLUDE) \ + ${ccflags-y} # The Main target all: mod24 -else +else # !2.4 -- + + # This is the Makefile section for Linux 2.6.x including planetlab + ifeq ($(IPFW_PLANETLAB),1) $(warning "---- Building for PlanetLab") ipfw-cflags += -DIPFW_PLANETLAB # PlanetLab compilation endif # if not set, use the version from the installed system KERNELPATH ?= /lib/modules/`uname -r`/build - # the latest kernel + # Otherwise, if you have kernel sources, try something like this: #KERNELPATH = /usr/src/linux-2.6.22 $(warning "---- Building Version 2.6 $(VER) in $(KERNELPATH)") WARN := -O1 -Wall -Werror -DDEBUG_SPINLOCK -DDEBUG_MUTEXES @@ -119,34 +138,39 @@ endif # Required by kernel <= 2.6.22, ccflags-y is used on newer version LINUX_VERSION_CODE := $(shell grep LINUX_VERSION_CODE $(KERNELPATH)/include/linux/version.h|cut -d " " -f3) - ifeq ($(LINUX_VERSION_CODE),132630) + ifeq ($(shell if [ -z $(LINUX_VERSION_CODE) ] ; then echo "true"; fi),true) + $(warning "---- Perhaps you miss a (cd $(KERNELPATH); make oldconfig; make prepare; make scripts)"); + endif + ifeq ($(shell if [ $(LINUX_VERSION_CODE) -le 132630 ] ; then echo "true"; fi),true) EXTRA_CFLAGS += $(ccflags-y) endif all: include_e $(MAKE) -C $(KERNELPATH) V=1 M=`pwd` modules -endif +endif # !2.4 -#-- back to the common section of code +#-- back to the common section of code for Linux 2.4 and 2.6 # the list of objects used to build the module ipfw_mod-y = $(IPFW_SRCS:%.c=%.o) -# Original ipfw and dummynet sources + FreeBSD stuff, -IPFW_SRCS = ip_fw2.c ip_dummynet.c ip_fw_pfil.c in_cksum.c -IPFW_SRCS += radix.c -# Module glue and functions missing in linux -IPFW_SRCS += ipfw2_mod.c bsd_compat.c hashtable.c new_glue.c - # additional $(CC) flags ccflags-y += $(WARN) ccflags-y += $(ipfw-cflags) +# if we really want debug symbols... ccflags-y += -g mod24: include_e $(obj-m) $(obj-m): $(ipfw_mod-y) $(LD) $(LDFLAGS) -m elf_i386 -r -o $@ $^ + +# M is the current directory, used in recursive builds +# so we allow it to be overridden +M ?= $(shell pwd) +endif # !openwrt + +#--- various common targets clean: -rm -f *.o *.ko Module.symvers *.mod.c -rm -rf include_e @@ -161,7 +185,7 @@ distclean: clean EDIRS= altq arpa machine net netinet netinet6 sys -EFILES += opt_inet6.h opt_ipfw.h opt_ipsec.h +EFILES += opt_inet6.h opt_ipfw.h opt_ipsec.h opt_mpath.h EFILES += opt_mbuf_stress_test.h opt_param.h EFILES += altq/if_altq.h @@ -172,23 +196,26 @@ EFILES += net/vnet.h EFILES += netinet/ether.h netinet/icmp6.h netinet/if_ether.h EFILES += netinet/in.h netinet/in_pcb.h netinet/in_var.h -EFILES += netinet/ip_carp.h netinet/ip_var.h netinet/pim.h +EFILES += netinet/in_systm.h +EFILES += netinet/ip_carp.h netinet/ip_var.h netinet/pim.h EFILES += netinet/sctp.h netinet/tcp_timer.h netinet/tcpip.h EFILES += netinet/udp_var.h EFILES += netinet6/ip6_var.h EFILES += sys/_lock.h sys/_rwlock.h sys/_mutex.h sys/jail.h -EFILES += sys/condvar.h sys/eventhandler.h +EFILES += sys/condvar.h sys/eventhandler.h sys/domain.h EFILES += sys/limits.h sys/lock.h sys/mutex.h sys/priv.h EFILES += sys/proc.h sys/rwlock.h sys/socket.h sys/socketvar.h EFILES += sys/sysctl.h sys/time.h sys/ucred.h -M ?= $(shell pwd) include_e: echo "running in $M" -@rm -rf $(M)/include_e opt_* -@mkdir -p $(M)/include_e -@(cd $(M)/include_e; mkdir -p $(EDIRS); touch $(EFILES) ) -endif # !openwrt + +#--- some other targets for testing purposes +test_radix: test_radix.o radix.o +test_radix: CFLAGS=-Wall -Werror -O2