1 # $Id: Makefile 11689 2012-08-12 21:07:34Z luigi $
3 # Top level makefile for building ipfw/dummynet (kernel and userspace).
4 # You can run it manually or also under the Planetlab build.
5 # Planetlab wants also the 'install' target.
7 # To build on system with non standard Kernel sources or userland files,
8 # you should run this with
10 # make KERNELPATH=/path/to/linux-2.x.y.z USRDIR=/path/to/usr
12 # We assume that $(USRDIR) contains include/ and lib/ used to build userland.
17 DATE ?= $(shell date +%Y%m%d)
18 SNAPSHOT_NAME=$(DATE)-ipfw3.tgz
19 BINDIST=$(DATE)-dummynet-linux.tgz
20 WINDIST=$(DATE)-dummynet-windows.zip
22 DISTFILES= Makefile Makefile.inc README binary* ipfw kipfw *.h sys
26 ###########################################
27 # windows x86 and x64 specific variables #
28 ###########################################
29 # DRIVE must be the hard drive letter where DDK is installed
30 # DDKDIR must be the path to the DDK root directory, without drive letter
31 # TARGETOS (x64 only) must be one of the following:
32 # wnet -> windows server 2003
33 # wlh -> windows vista and windows server 2008
35 # future version must be added here
37 DDKDIR ?= /WinDDK/7600.16385.1
38 DDK = $(DRIVE)$(DDKDIR)
49 -@(cd ipfw && $(MAKE) $(@) )
50 -@rm -rf kipfw-mod binary64/[A-hj-z]*
54 ifeq ($(OSARCH),Windows) # copy files
56 -@ cp ipfw/ipfw.exe kipfw-mod/$(OBJDIR)/ipfw.sys binary/
57 -@ cp kipfw/*.inf binary/
59 -@ cp binary/* kipfw/*.inf binary64/
60 -@ cp ipfw/ipfw.exe kipfw-mod/objchk_win7_amd64/amd64/ipfw.sys binary64/
67 # kipfw-src prepares the sources for the kernel part.
68 # The windows files (passthru etc.) are modified version of the
69 # examples found in the $(DDK)/src/network/ndis/passthru/driver/
70 # They can be re-created using the 'ndis-glue' target
71 # # We need a sed trick to remove newlines from the patchfile.
75 cp $(DDK)/src/network/ndis/passthru/driver/*.[ch] kipfw-mod
76 cat kipfw/win-passthru.diff | sed "s/$$(printf '\r')//g" | (cd kipfw-mod; patch )
81 -@cp -Rp kipfw/* kipfw-mod
82 -@cp `find sys -name \*.c` kipfw-mod
83 -@(cd kipfw-mod && $(MAKE) include_e)
84 ifeq ($(OSARCH),Windows)
90 (tar cvzhf /tmp/$(SNAPSHOT_NAME) -s':^:ipfw3-2012/:' $(DISTFILES) )
95 tar cvzf /tmp/$(BINDIST) ipfw/ipfw ipfw/ipfw.8 kipfw-mod/ipfw_mod.ko
101 zip -r /tmp/$(WINDIST) binary -x \*.svn\*
105 @(cd ipfw && $(MAKE) $(@) )
108 ifeq ($(WIN64),) # linux or windows 32 bit
109 @(cd kipfw-mod && $(MAKE) $(@) )
110 else #--- windows 64 bit, we use build.exe and nmake
111 rm -f kipfw-mod/Makefile
112 mkdir kipfw-mod/tmpbuild # check mysetenv.sh
113 bash kipfw/mysetenv.sh $(DRIVE) $(DDKDIR) $(TARGETOS)
117 # create a temporary directory
118 $(eval TMPDIR := $(shell mktemp -d -p /tmp/ ipfw3_openwrt_XXXXX))
119 # create the source destination directory
120 $(eval IPFWDIR := ipfw3-$(DATE))
121 $(eval DSTDIR := $(TMPDIR)/$(IPFWDIR))
123 # copy the package, clean objects and svn info
124 cp -r ./ipfw ./kipfw-mod glue.h Makefile ./configuration README $(DSTDIR)
125 (cd $(DSTDIR); make -s distclean; find . -name .svn | xargs rm -rf)
126 (cd $(TMPDIR); tar czf $(IPFWDIR).tar.gz $(IPFWDIR))
128 # create the port files in /tmp/ipfw3-port
129 $(eval PORTDIR := $(TMPDIR)/ipfw3)
130 mkdir -p $(PORTDIR)/patches
131 # generate the Makefile, PKG_VERSION and PKG_MD5SUM
132 md5sum $(DSTDIR).tar.gz | cut -d ' ' -f 1 > $(TMPDIR)/md5sum
133 cat ./OPENWRT/Makefile | \
134 sed s/PKG_VERSION:=/PKG_VERSION:=$(DATE)/ | \
135 sed s/PKG_MD5SUM:=/PKG_MD5SUM:=`cat $(TMPDIR)/md5sum`/ \
136 > $(PORTDIR)/Makefile
139 @echo "The openwrt port is in $(TMPDIR)/ipfw3-port"
140 @echo "The source file should be copied to the public server:"
141 @echo "scp $(DSTDIR).tar.gz marta@info.iet.unipi.it:~marta/public_html/dummynet"
142 @echo "after this the temporary directory $(TMPDIR) can be removed."
147 -@(diff -upr $(BSD_HEAD)/sbin/ipfw ipfw)
148 -@(diff -upr $(BSD_HEAD)/sys sys)