initial version, corresponding to ipfw3-2012
[ipfw-google.git] / planetlab / Makefile.planetlab
1 # $Id: Makefile 11687 2012-08-12 20:51:25Z luigi $
2 #
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.
6 #
7 # To build on system with non standard Kernel sources or userland files,
8 # you should run this with
9 #
10 #       make KERNELPATH=/path/to/linux-2.x.y.z USRDIR=/path/to/usr
11 #
12 # We assume that $(USRDIR) contains include/ and lib/ used to build userland.
13 #
14
15 include Makefile.inc
16
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
21
22 .PHONY: ipfw kipfw
23
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
32 #  win7   -> windows 7
33 #  future version must be added here
34 export WIN64
35 export DDK
36 export DRIVE
37 export DDKDIR
38 DRIVE ?= C:
39 DDKDIR ?= /WinDDK/7600.16385.1
40 DDK = $(DRIVE)$(DDKDIR)
41
42 TARGETOS=win7
43
44 _all: all
45
46 clean distclean:
47         -@(cd ipfw && $(MAKE) $(@) )
48         -@rm -rf kipfw-mod binary64/[A-hj-z]*
49
50 all: kipfw ipfw
51         @# -- windows only
52 ifeq ($(OSARCH),Windows)        # copy files
53 ifeq ($(WIN64),)
54         -@ cp ipfw/ipfw.exe kipfw-mod/$(OBJDIR)/ipfw.sys binary/
55         -@ cp kipfw/*.inf binary/
56 else
57         -@ cp binary/* binary64/
58         -@ cp ipfw/ipfw.exe kipfw-mod/objchk_win7_amd64/amd64/ipfw.sys binary64/
59 endif   # WIN64
60 endif   # Windows
61
62 win64:
63         $(MAKE) WIN64=1
64
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.
70
71 ndis-glue:
72         -@mkdir -p kipfw-mod
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 )
75
76 kipfw-src:
77         -@rm -rf kipfw-mod
78         -@mkdir -p kipfw-mod
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)
83         make ndis-glue
84 endif
85
86 snapshot:
87         $(MAKE) distclean
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_ \
94                 ipfw3-2012 )
95
96 bindist:
97         $(MAKE) clean
98         $(MAKE) all
99         tar cvzf /tmp/$(BINDIST) ipfw/ipfw ipfw/ipfw.8 kipfw-mod/ipfw_mod.ko
100
101 windist:
102         $(MAKE) clean
103         -$(MAKE) all
104         -rm /tmp/$(WINDIST)
105         zip -r /tmp/$(WINDIST) binary -x \*.svn\*
106
107
108 ipfw:
109         @(cd ipfw && $(MAKE) $(@) )
110
111 kipfw: kipfw-src
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)
118 endif
119
120 IPF3_REPO ?= svn+ssh://some.host/some/path/ipfw3-2012
121
122 planetlab_update:
123         # clean and create a local working directory
124         rm -rf /tmp/pl-tmp
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.')"
147
148 openwrt_release:
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))
154         mkdir $(DSTDIR)
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))
159
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
169
170         @echo ""
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."
175
176 install:
177
178 diff:
179         -@(diff -upr $(BSD_HEAD)/sbin/ipfw ipfw)
180         -@(diff -upr $(BSD_HEAD)/sys sys)
181