1 # $Id: Makefile 11687 2012-08-12 20:51:25Z 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
24 ###########################################
25 # windows x86 and x64 specific variables #
26 ###########################################
27 # DRIVE must be the hard drive letter where DDK is installed
28 # DDKDIR must be the path to the DDK root directory, without drive letter
29 # TARGETOS (x64 only) must be one of the following:
30 # wnet -> windows server 2003
31 # wlh -> windows vista and windows server 2008
33 # future version must be added here
39 DDKDIR ?= /WinDDK/7600.16385.1
40 DDK = $(DRIVE)$(DDKDIR)
47 -@(cd ipfw && $(MAKE) $(@) )
48 -@rm -rf kipfw-mod binary64/[A-hj-z]*
52 ifeq ($(OSARCH),Windows) # copy files
54 -@ cp ipfw/ipfw.exe kipfw-mod/$(OBJDIR)/ipfw.sys binary/
55 -@ cp kipfw/*.inf binary/
57 -@ cp binary/* binary64/
58 -@ cp ipfw/ipfw.exe kipfw-mod/objchk_win7_amd64/amd64/ipfw.sys binary64/
65 # kipfw-src prepares the sources for the kernel part.
66 # The windows files (passthru etc.) are modified version of the
67 # examples found in the $(DDK)/src/network/ndis/passthru/driver/
68 # They can be re-created using the 'ndis-glue' target
69 # # We need a sed trick to remove newlines from the patchfile.
73 cp $(DDK)/src/network/ndis/passthru/driver/*.[ch] kipfw-mod
74 cat kipfw/win-passthru.diff | sed "s/$$(printf '\r')//g" | (cd kipfw-mod; patch )
79 -@cp -Rp kipfw/* kipfw-mod
80 -@cp `find sys -name \*.c` kipfw-mod
81 -@(cd kipfw-mod && $(MAKE) include_e)
82 ifeq ($(OSARCH),Windows)
88 (cd ..; tar cvzhf /tmp/$(SNAPSHOT_NAME) --exclude .svn \
89 --exclude README.openwrt --exclude tags --exclude NOTES \
90 --exclude tcc-0.9.25-bsd \
91 --exclude original_passthru \
92 --exclude ipfw3.diff --exclude add_rules \
93 --exclude test --exclude test_ \
99 tar cvzf /tmp/$(BINDIST) ipfw/ipfw ipfw/ipfw.8 kipfw-mod/ipfw_mod.ko
105 zip -r /tmp/$(WINDIST) binary -x \*.svn\*
109 @(cd ipfw && $(MAKE) $(@) )
112 ifeq ($(WIN64),) # linux or windows 32 bit
113 @(cd kipfw-mod && $(MAKE) $(@) )
114 else #--- windows 64 bit, we use build.exe and nmake
115 rm -f kipfw-mod/Makefile
116 mkdir kipfw-mod/tmpbuild # check mysetenv.sh
117 bash kipfw/mysetenv.sh $(DRIVE) $(DDKDIR) $(TARGETOS)
120 IPF3_REPO ?= svn+ssh://some.host/some/path/ipfw3-2012
123 # clean and create a local working directory
125 mkdir -p /tmp/pl-tmp/pl
126 mkdir -p /tmp/pl-tmp/ol2
127 # get the trunk version of the PlanetLab repository
128 # to specify the sshkey use the .ssh/config file
129 (cd /tmp/pl-tmp/pl; \
130 svn co svn+ssh://svn.planet-lab.org/svn/ipfw/trunk)
131 # get an updated copy of the main ipfw repository
132 (cd /tmp/pl-tmp/ol2; svn export $(IPFW3_REPO) )
133 # copy the new version over the old one
134 (cd /tmp/pl-tmp; cp -rP ol2/ipfw3/* pl/trunk)
135 # files cleanup in the old version
136 (cd /tmp/pl-tmp; diff -r ol2/ipfw3 pl/trunk | \
137 grep -v "svn" | awk '{print $$3 $$4}' | \
138 sed 's/:/\//' | xargs rm -rf)
139 # local adjustments here
140 rm -rf /tmp/pl-tmp/pl/trunk/planetlab/check_planetlab_sync
141 # commit to the remote repo
142 @echo "Please, revise the update with the commands:"
143 @echo "(cd /tmp/pl-tmp/pl/trunk; svn diff)"
144 @echo "(cd /tmp/pl-tmp/pl/trunk; svn status)"
145 @echo "and commit with:"
146 @echo "(cd /tmp/pl-tmp/pl/trunk; svn ci -m 'Update from the mail ipfw repo.')"
149 # create a temporary directory
150 $(eval TMPDIR := $(shell mktemp -d -p /tmp/ ipfw3_openwrt_XXXXX))
151 # create the source destination directory
152 $(eval IPFWDIR := ipfw3-$(DATE))
153 $(eval DSTDIR := $(TMPDIR)/$(IPFWDIR))
155 # copy the package, clean objects and svn info
156 cp -r ./ipfw ./kipfw-mod glue.h Makefile ./configuration README $(DSTDIR)
157 (cd $(DSTDIR); make -s distclean; find . -name .svn | xargs rm -rf)
158 (cd $(TMPDIR); tar czf $(IPFWDIR).tar.gz $(IPFWDIR))
160 # create the port files in /tmp/ipfw3-port
161 $(eval PORTDIR := $(TMPDIR)/ipfw3)
162 mkdir -p $(PORTDIR)/patches
163 # generate the Makefile, PKG_VERSION and PKG_MD5SUM
164 md5sum $(DSTDIR).tar.gz | cut -d ' ' -f 1 > $(TMPDIR)/md5sum
165 cat ./OPENWRT/Makefile | \
166 sed s/PKG_VERSION:=/PKG_VERSION:=$(DATE)/ | \
167 sed s/PKG_MD5SUM:=/PKG_MD5SUM:=`cat $(TMPDIR)/md5sum`/ \
168 > $(PORTDIR)/Makefile
171 @echo "The openwrt port is in $(TMPDIR)/ipfw3-port"
172 @echo "The source file should be copied to the public server:"
173 @echo "scp $(DSTDIR).tar.gz marta@info.iet.unipi.it:~marta/public_html/dummynet"
174 @echo "after this the temporary directory $(TMPDIR) can be removed."
179 -@(diff -upr $(BSD_HEAD)/sbin/ipfw ipfw)
180 -@(diff -upr $(BSD_HEAD)/sys sys)