X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kipfw%2FMakefile;h=9942499d5310ffeb9d5a1c9727f2b8087843d87c;hb=4123da8a54c132ad87656bbb989919f965dfbfca;hp=6ca0562876ab9e315a6c27d8d100cee56783e165;hpb=8e87ee720bdedbc75ae87923fa1032af0d62d5fe;p=ipfw-google.git diff --git a/kipfw/Makefile b/kipfw/Makefile index 6ca0562..9942499 100644 --- a/kipfw/Makefile +++ b/kipfw/Makefile @@ -34,13 +34,16 @@ # examples found in the $(DDK)/src/network/ndis/passthru/driver/ # They can be re-created using the 'ndis-glue' target in the -include $(PWD)/../Makefile.inc +IPFW3_ROOT ?= $(PWD)/.. +include $(IPFW3_ROOT)/Makefile.inc TARGET = kipfw # lets default for 2.6 for planetlab builds VER ?= 2.6 +# $(warning ########## linux dir is $(LINUX_DIR) ###########) +# $(warning ########## KERNELPATH is $(KERNELPATH) ###########) #--- General values for all types of build --- # obj-m is the target module obj-m := ipfw_mod.o @@ -70,13 +73,15 @@ ipfw-cflags += -I $(M)/../sys ipfw-cflags += -include $(M)/../glue.h # headers ipfw-cflags += -include $(M)/missing.h # headers +$(warning ------ arch $(OSARCH) goals $(MAKECMDGOALS) -----------) + ifeq ($(OSARCH),Windows) #--- { Windows block -ifeq ($(VER),win64) + ifeq ($(VER),win64) $(warning ---- building for 64-bit windows ---) win_arch= -DAMD64=1 -else + else win_arch= -Di386=1 -endif + endif M ?= $(shell pwd) WIN_SRCS += md_win.c WIN_SRCS += miniport.c protocol.c passthru.c debug.c @@ -117,7 +122,7 @@ endif OUR_PREPROC += -D__BSD_VISIBLE -DIPFIREWALL_DEFAULT_TO_ACCEPT OUR_PREPROC += -D__LITTLE_ENDIAN -DSYSCTL_NODE -DEMULATE_SYSCTL -ifeq ($(TCC),) # Microsoft C compiler + ifeq ($(TCC),) # Microsoft C compiler CC = $(DDK)/bin/x86/x86/cl.exe LD = $(DDK)/bin/x86/x86/link.exe # #complier options @@ -155,7 +160,7 @@ ifeq ($(TCC),) # Microsoft C compiler LIBS += $(DDK)/lib/wxp/i386/wmilib.lib LIBS += $(DDK)/lib/wxp/i386/ndis.lib LIBS += $(DDK)/lib/wxp/i386/sehupd.lib -else # use tcc. not working yet for the kernel module. + else # use tcc. not working yet for the kernel module. # TCC points to the root of tcc tree CC=$(TCC)/bin/wintcc EXTRA_CFLAGS += -DTCC -I.. @@ -165,7 +170,7 @@ else # use tcc. not working yet for the kernel module. CFLAGS += -include winmissing.h -include missing.h -include ../glue.h CFLAGS += -I../../inc/api -I../../inc/ddk -I../../inc/crt CFLAGS += -DRC_INVOKED -endif # use tcc + endif # use tcc #empty include directory to be built M ?= $(shell pwd) @@ -186,9 +191,20 @@ $(TARGET): include_e else # } { linux variables and targets + # extract version number (hex, aXXYY). Newer linuxes have a different dir + # if not set, use the version from the installed system + KERNELPATH ?= $(KSRC) + LIN_VER := $(shell V=linux/version.h; G=. ; \ + [ -f $(KERNELPATH)/include/$${V} ] || G=generated/uapi ;\ + grep LINUX_VERSION_CODE $(KERNELPATH)/include/$${G}/linux/version.h | \ + awk '{printf "%03x%02x", $$3/256, $$3%256} ') + + $(warning ------------- linux version $(LIN_VER) (hex) ------------) # We have three sections: OpenWrt, Linux 2.4 and Linux 2.6 -ifeq ($(VER),openwrt) #--- { The Makefile section for openwrt --- +ifeq ($(LIN_VER),openwrt) #--- { The Makefile section for openwrt --- + # this was used on openwrt, but not anymore + $(error ------ build on openwrt ---------- ) # We do not include a dependency on include_e as it is called # by Makefile.openwrt in Build/Prepare M=. @@ -207,7 +223,7 @@ ifeq ($(VER),openwrt) #--- { The Makefile section for openwrt --- endif # ---- } end openwrt version -ifneq ($(shell echo $(VER)|grep '2.4'),) #--- { +ifneq ($(shell echo $(LIN_VER)|grep '2.4'),) #--- { # Makefile section for the linux 2.4 version # tested on linux-2.4.35.4, does not work with 2.4.37 # @@ -245,49 +261,56 @@ ifneq ($(shell echo $(VER)|grep '2.4'),) #--- { all: mod24 else # --- } { linux 2.6 and newer + $(warning --- build 2.6 and newer target $(TARGET) ----) # 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 ?= $(KSRC) -# $(warning "---- Building Version 2.6 $(VER) in $(KERNELPATH)") + ifeq ($(IPFW_PLANETLAB),1) + $(warning "---- Building for PlanetLab") + ipfw-cflags += -DIPFW_PLANETLAB # PlanetLab compilation + endif + WARN := -O1 -Wall -Werror -DDEBUG_SPINLOCK -DDEBUG_MUTEXES # The main target # Required by GCC 4.6 ccflags-y += -Wno-unused-but-set-variable - # extract version number (decimal). Newer linuxes have a different dir - LINUX_VERSION_CODE := $(shell V=linux/version.h; G=. ; \ - [ -f $(KERNELPATH)/include/$${V} ] || G=generated/uapi ;\ - grep LINUX_VERSION_CODE $(KERNELPATH)/include/$${G}/linux/version.h | \ - awk '{printf "%d", $$3} ') - - # awk '{printf "%d %03x%02d", $$3, $$3/256, $$3%256} ') - # $(warning version $(LINUX_VERSION_CODE)) - ifeq ($(shell if [ -z $(LINUX_VERSION_CODE) ] ; then echo "true"; fi),true) + ifeq ($(shell if [ -z $(LIN_VER) ] ; then echo "true"; fi),true) $(warning "---- Perhaps you miss a (cd $(KERNELPATH); make oldconfig; make prepare; make scripts)"); endif - # Required by kernel <= 2.6.22, ccflags-y is used on newer version - ifeq ($(shell if [ "$(LINUX_VERSION_CODE)" -le 132630 ] ; then echo "true"; fi),true) + # Required by kernel < 2.6.23, ccflags-y is used on newer version + ifeq ($(shell [ "$(LIN_VER)" \< "20617" ] && echo "true"),true) EXTRA_CFLAGS += $(ccflags-y) endif - $(warning $(shell [ "$(LINUX_VERSION_CODE)" -le 132635 ] && \ + $(warning $(shell [ "$(LIN_VER)" \< "2061c" ] && \ [ `$(MAKE) -version | head -1 | cut -d " " -f 3` != '3.81' ] && \ echo "**** need make 3.81 *****") ) # $(warning make is $(MAKE) version is $(shell $(MAKE) -version | head -1) ) + #--- openwrt ? + ifeq ($(_VER),xx-openwrt) + $(warning ----------------------- compiling for openwrt -----) + M=. + obj-y := $(IPFW_SRCS:%.c=%.o) + O_TARGET := $(obj-m) + + # xcflags-y is a temporary variable where we store build options + xcflags-y += -O1 + xcflags-y += -g + + EXTRA_CFLAGS := $(xcflags-y) $(ipfw-cflags) -DSYSCTL_NODE -DEMULATE_SYSCTL + endif #---- end openwrt + all: $(TARGET) $(TARGET): include_e + echo "xxxxxxxxxxxxx $(MAKE) -C $(KERNELPATH) V=$(V) M=`pwd` modules" $(MAKE) -C $(KERNELPATH) V=$(V) M=`pwd` modules + endif # } --- linux 2.6 and newer #-- back to the common section for linux