integrated
[ipfw.git] / Makefile
1 # $Id: Makefile 8654 2011-05-23 08:39:50Z marta $
2 #
3 # Top level makefile for building ipfw 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 DATE ?= $(shell date +%Y%m%d)
15 SNAPSHOT_NAME=$(DATE)-ipfw3.tgz
16 BINDIST=$(DATE)-dummynet-linux.tgz
17 WINDIST=$(DATE)-dummynet-windows.zip
18
19 ###########################################
20 #  windows x86 and x64 specific variables #
21 ###########################################
22 #  DRIVE must be the hard drive letter where DDK is installed
23 #  DDKDIR must be the path to the DDK root directory, without drive letter
24 #  TARGETOS (x64 only) must be one of the following:
25 #  wnet   -> windows server 2003
26 #  wlh    -> windows vista and windows server 2008
27 #  win7   -> windows 7
28 #  future version must be added here
29 export DDK
30 export DRIVE
31 export DDKDIR
32 DRIVE = C:
33 DDKDIR = /WinDDK/7600.16385.1
34 DDK = $(DRIVE)$(DDKDIR)
35
36 TARGETOS=win7
37
38 _all: all
39
40 clean distclean:
41         echo target is $(@)
42         (cd ipfw && $(MAKE) $(@) )
43         (cd dummynet2 && $(MAKE) $(@) )
44         # -- windows x64 only
45         - rm -rf dummynet2-64
46         - rm -rf ipfw-64
47         - rm -rf binary64
48
49 all:
50         echo target is $(@)
51         (cd ipfw && $(MAKE) $(@) )
52         (cd dummynet2 && $(MAKE) $(@) )
53         # -- windows only
54         - [ -f ipfw/ipfw.exe ] && cp ipfw/ipfw.exe binary/ipfw.exe
55         - [ -f dummynet2/objchk_wxp_x86/i386/ipfw.sys ] && \
56                 cp dummynet2/objchk_wxp_x86/i386/ipfw.sys binary/ipfw.sys
57
58 snapshot:
59         $(MAKE) distclean
60         (cd ..; tar cvzhf /tmp/$(SNAPSHOT_NAME) --exclude .svn \
61                 --exclude README.openwrt --exclude tags --exclude NOTES \
62                 --exclude tcc-0.9.25-bsd \
63                 --exclude original_passthru \
64                 --exclude ipfw3.diff --exclude add_rules \
65                 --exclude test --exclude test_ \
66                 ipfw3 )
67
68 bindist:
69         $(MAKE) clean
70         $(MAKE) all
71         tar cvzf /tmp/$(BINDIST) ipfw/ipfw ipfw/ipfw.8 dummynet2/ipfw_mod.ko
72
73 windist:
74         $(MAKE) clean
75         -$(MAKE) all
76         -rm /tmp/$(WINDIST)
77         zip -r /tmp/$(WINDIST) binary -x \*.svn\*
78
79 win64:  clean
80         (cd dummynet2 && $(MAKE) include_e)
81         cp -r ipfw ipfw-64
82         echo "EXTRA_CFLAGS += -D_X64EMU" >> ipfw-64/Makefile
83         (cd ipfw-64 && $(MAKE) all)
84         cp -r dummynet2 dummynet2-64
85         rm -f dummynet2-64/Makefile
86         cp win64/sources dummynet2-64/sources
87         mkdir dummynet2-64/tmpbuild
88         mkdir binary64
89         win64/mysetenv.sh $(DRIVE) $(DDKDIR) $(TARGETOS)
90         cp binary/cygwin1.dll binary64/cygwin1.dll
91         cp ipfw-64/ipfw.exe binary64/ipfw.exe
92         cp win64/*.inf binary64
93         cp binary/testme.bat binary64/testme.bat
94         cp binary/wget.exe binary64/wget.exe
95         
96 planetlab_update:
97         # clean and create a local working directory
98         rm -rf /tmp/pl-tmp
99         mkdir -p /tmp/pl-tmp/pl
100         mkdir -p /tmp/pl-tmp/ol2
101         # get the trunk version of the PlanetLab repository
102         # to specify the sshkey use the .ssh/config file
103         (cd /tmp/pl-tmp/pl; \
104                 svn co svn+ssh://svn.planet-lab.org/svn/ipfw/trunk)
105         # get an updated copy of the main ipfw repository
106         (cd /tmp/pl-tmp/ol2; \
107                 svn export svn+ssh://onelab2.iet.unipi.it/home/svn/ports-luigi/dummynet-branches/ipfw3)
108         # copy the new version over the old one
109         (cd /tmp/pl-tmp; cp -rP ol2/ipfw3/* pl/trunk)
110         # files cleanup in the old version
111         (cd /tmp/pl-tmp; diff -r ol2/ipfw3 pl/trunk | \
112                 grep -v "svn" | awk '{print $$3 $$4}' | \
113                 sed 's/:/\//' | xargs rm -rf)
114         # local adjustmens here
115         rm -rf /tmp/pl-tmp/pl/trunk/planetlab/check_planetlab_sync
116         # commit to the remote repo
117         @echo "Please, revise the update with the commands:"
118         @echo "(cd /tmp/pl-tmp/pl/trunk; svn diff)"
119         @echo "(cd /tmp/pl-tmp/pl/trunk; svn status)"
120         @echo "and commit with:"
121         @echo "(cd /tmp/pl-tmp/pl/trunk; svn ci -m 'Update from the mail ipfw repo.')"
122
123 openwrt_release:
124         # create a temporary directory
125         $(eval TMPDIR := $(shell mktemp -d -p /tmp/ ipfw3_openwrt_XXXXX))
126         # create the source destination directory
127         $(eval IPFWDIR := ipfw3-$(DATE))
128         $(eval DSTDIR := $(TMPDIR)/$(IPFWDIR))
129         mkdir $(DSTDIR)
130         # copy the package, clean objects and svn info
131         cp -r ./ipfw ./dummynet2 glue.h Makefile ./configuration README $(DSTDIR)
132         (cd $(DSTDIR); make -s distclean; find . -name .svn | xargs rm -rf)
133         (cd $(TMPDIR); tar czf $(IPFWDIR).tar.gz $(IPFWDIR))
134
135         # create the port files in /tmp/ipfw3-port
136         $(eval PORTDIR := $(TMPDIR)/ipfw3)
137         mkdir -p $(PORTDIR)/patches
138         # generate the Makefile, PKG_VERSION and PKG_MD5SUM
139         md5sum $(DSTDIR).tar.gz | cut -d ' ' -f 1 > $(TMPDIR)/md5sum
140         cat ./OPENWRT/Makefile | \
141                 sed s/PKG_VERSION:=/PKG_VERSION:=$(DATE)/ | \
142                 sed s/PKG_MD5SUM:=/PKG_MD5SUM:=`cat $(TMPDIR)/md5sum`/ \
143                 > $(PORTDIR)/Makefile
144
145         @echo ""
146         @echo "The openwrt port is in $(TMPDIR)/ipfw3-port"
147         @echo "The source file should be copied to the public server:"
148         @echo "scp $(DSTDIR).tar.gz marta@info.iet.unipi.it:~marta/public_html/dummynet"
149         @echo "after this the temporary directory $(TMPDIR) can be removed."
150
151 install: