-#
-# $Id: Makefile 4657 2010-01-04 11:20:53Z marta $
-#
-# gnu Makefile to build linux module for ipfw+dummynet.
+# $Id: Makefile 5858 2010-03-24 16:16:19Z svn_magno $
+# gnu Makefile to build linux/Windows module for ipfw+dummynet.
#
# The defaults are set to build without modifications on PlanetLab
# and possibly 2.6 versions.
+# On Windows, we use gnu-make and MSC
# Some variables need to have specific names, because they are used
# by the build infrastructure on Linux and OpenWrt. They are:
# VER linux version we are building for (2.4 2.6 or openwrt)
#---
+UNAME:=$(shell uname)
$(warning including dummynet/Makefile)
# lets default for 2.6 for planetlab builds
#-- 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 ip_fw_sockopt.c
+IPFW_SRCS := ip_fw2.c ip_fw_pfil.c ip_fw_sockopt.c
IPFW_SRCS += ip_fw_dynamic.c ip_fw_table.c ip_fw_log.c
IPFW_SRCS += radix.c in_cksum.c
+IPFW_SRCS += ip_dummynet.c ip_dn_io.c ip_dn_glue.c
+IPFW_SRCS += dn_heap.c
+IPFW_SRCS += dn_sched_fifo.c dn_sched_wf2q.c
+IPFW_SRCS += dn_sched_rr.c dn_sched_qfq.c
+IPFW_SRCS += dn_sched_prio.c
# Module glue and functions missing in linux
IPFW_SRCS += ipfw2_mod.c bsd_compat.c
$(warning "---- Building dummynet kernel module for Version $(VER)")
+ifneq (,$(findstring CYGWIN,$(shell uname)))
+ ISWIN=1
+endif
+ifneq ($(TCC),)
+ ISWIN=1
+endif
+ifeq ($(ISWIN),1)
+ M ?= $(shell pwd)
+ WIN_SRCS += md_win.c
+ WIN_SRCS += miniport.c protocol.c passthru.c debug.c
+ #compiler, linker, target, sources and objects
+ #DDK is exported from the root makefile
+ #DDK = C:/WinDDK/7600.16385.1
+ OBJDIR=objchk_wxp_x86/i386/
+
+ TARGET = ipfw
+
+ CSOURCES = $(IPFW_SRCS) $(WIN_SRCS)
+
+ COBJS := $(CSOURCES:.c=.obj)
+ COBJS := $(addprefix $(OBJDIR),$(COBJS))
+
+ #include paths
+ INCLUDE_PATHS = -Ii386 -Iinclude -Iinclude_e -I.
+ # INCLUDE_PATHS += -I$(OBJDIR)
+ INCLUDE_PATHS += -I$(DDK)/inc/api
+ INCLUDE_PATHS += -I$(DDK)/inc/ddk
+ INCLUDE_PATHS += -I$(DDK)/inc/crt
+
+ # #preprocessor MS defines
+ PREPROC = -D_X86_=1 -Di386=1 -DSTD_CALL -DCONDITION_HANDLING=1
+ PREPROC += -DNT_UP=0 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 -DWINNT=1
+ PREPROC += -D_WIN32_WINNT=0x0501 -DWINVER=0x0501 -D_WIN32_IE=0x0603
+ PREPROC += -DWIN32_LEAN_AND_MEAN=1
+ PREPROC += -D__BUILDMACHINE__=WinDDK -DFPO=0 -D_DLL=1
+ PREPROC += -DNDIS_MINIPORT_DRIVER -DNDIS_WDM=1
+ PREPROC += -DNDIS51_MINIPORT=1 -DNDIS51=1
+ PREPROC += -DMSC_NOOPT -DNTDDI_VERSION=0x05010200
+ PREPROC += -DKMDF_MAJOR_VERSION_STRING=01 -DKMDF_MINOR_VERSION_STRING=009
+ #PREPROC += -DDBG=1 #debug
+ PREPROC += -DNDEBUG #always up, seems no effect, possibly no debug?
+ PREPROC += -DDEVL=1 #always up, seems no effect
+ #macroing module name, WARNING: must match the one in .inf files
+ PREPROC += -DMODULENAME=Ipfw
+
+ #our defines
+ OUR_PREPROC = -D_KERNEL -DKERNEL_MODULE -DKLD_MODULE
+ OUR_PREPROC += -D__BSD_VISIBLE -DIPFIREWALL_DEFAULT_TO_ACCEPT
+ OUR_PREPROC += -D__LITTLE_ENDIAN -DSYSCTL_NODE -DEMULATE_SYSCTL
+
+ifeq ($(TCC),)
+ CC = $(DDK)/bin/x86/x86/cl.exe
+ LD = $(DDK)/bin/x86/x86/link.exe
+ # #complier options
+ CFLAGS = -Fo$(OBJDIR) -c -FC -Zc:wchar_t-
+ CFLAGS += -Zl -Zp8 -Gy -Gm- -GF -cbstring -Gz -hotpatch -EHs-c-
+ CFLAGS += -W2 # -W3 gives too many conversion errors
+ CFLAGS += -GR- -GF -GS -Zi # XXX do we need this ?
+ CFLAGS += -Fd$(OBJDIR)
+ CFLAGS += -wd4603 -wd4627 -typedil-
+ CFLAGS += -FI $(DDK)/inc/api/warning.h
+ CFLAGS += -FI winmissing.h
+ CFLAGS += -FI missing.h # headers
+ CFLAGS += -FI ../glue.h # headers
+
+ #optimization options
+ OPTIMIZE = -Od -Oi -Oy-
+
+ #linker options
+ LDFLAGS = /MERGE:_PAGE=PAGE /MERGE:_TEXT=.text
+ LDFLAGS += /SECTION:INIT,d /OPT:REF /OPT:ICF
+ LDFLAGS += /IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221
+ LDFLAGS += /INCREMENTAL:NO /release /NODEFAULTLIB /WX
+ LDFLAGS += /debug /debugtype:cv,fixup,pdata
+ LDFLAGS += /version:6.1 /osversion:6.1 /functionpadmin:5
+ LDFLAGS += /safeseh /pdbcompress
+ LDFLAGS += /STACK:0x40000,0x1000 /driver /base:0x10000 /align:0x80
+ LDFLAGS += /stub:$(DDK)\\lib\\wxp\\stub512.com
+ LDFLAGS += /subsystem:native,5.01 /entry:GsDriverEntry@8
+ LDFLAGS += /out:$(OBJDIR)/ipfw.sys
+
+ #libraries to build against
+ LIBS = $(DDK)/lib/wxp/i386/BufferOverflowK.lib
+ LIBS += $(DDK)/lib/wxp/i386/ntoskrnl.lib
+ LIBS += $(DDK)/lib/wxp/i386/hal.lib
+ LIBS += $(DDK)/lib/wxp/i386/wmilib.lib
+ LIBS += $(DDK)/lib/wxp/i386/ndis.lib
+ LIBS += $(DDK)/lib/wxp/i386/sehupd.lib
+else
+ # TCC points to the root of tcc tree
+ CC=$(TCC)/bin/wintcc
+ EXTRA_CFLAGS += -DTCC -I..
+ EXTRA_CFLAGS += -I$(TCC)/include/winapi -I$(TCC)/include
+ EXTRA_CFLAGS += -nostdinc
+
+ CFLAGS += -include winmissing.h -include missing.h -include ../glue.h
+ CFLAGS += -I../../inc/api -I../../inc/ddk -I../../inc/crt
+ CFLAGS += -DRC_INVOKED
+endif
+
+ #empty include directory to be built
+ M ?= $(shell pwd)
+ EDIRS += asm linux
+ EFILES += asm/div64.h
+ EFILES += linux/if.h linux/random.h linux/errno.h
+ EFILES += net/if_types.h net/inet_hashtables.h net/route.h
+
+ #targets
+all: $(TARGET)
+
+$(TARGET): include_e
+ rm -rf objchk_wxp_x86
+ mkdir -p objchk_wxp_x86/i386
+ $(CC) $(INCLUDE_PATHS) $(PREPROC) $(OUR_PREPROC) $(CFLAGS) $(OPTIMIZE) $(CSOURCES)
+ $(LD) $(LDFLAGS) $(COBJS) $(LIBS)
+
+else # !windows
+
# We have three sections for OpenWrt, Linux 2.4 and Linux 2.6
ifeq ($(VER),openwrt)
xcflags-y += -O1 -DLINUX_24
xcflags-y += -g
- EXTRA_CFLAGS := $(xcflags-y) $(ipfw-cflags)
+ EXTRA_CFLAGS := $(xcflags-y) $(ipfw-cflags) -DSYSCTL_NODE -DEMULATE_SYSCTL
# we should not export anything
#export-objs := ipfw2_mod.o
# so we allow it to be overridden
M ?= $(shell pwd)
endif # !openwrt
+endif # !windows
#--- various common targets
clean:
-rm -f *.o *.ko Module.symvers *.mod.c
+ -rm -rf objchk_wxp_x86
-rm -rf include_e
distclean: clean
-rm -f .*cmd modules.order opt_*
-rm -rf .tmp_versions include_e
- -rm -rf .*.o.d
+ -rm -rf .*.o.d _CL_*
# support to create empty dirs and files in include_e/
# EDIRS is the list of directories, EFILES is the list of files.
-EDIRS= altq arpa machine net netinet netinet6 sys
+EDIRS += altq arpa machine net netinet netinet6 sys
EFILES += opt_inet6.h opt_ipfw.h opt_ipsec.h opt_mpath.h
EFILES += opt_mbuf_stress_test.h opt_param.h