Sync with the new ipfw3 version.
[ipfw.git] / Makefile
1 # $Id$
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                 ipfw3 )
66
67 bindist:
68         $(MAKE) clean
69         $(MAKE) all
70         tar cvzf /tmp/$(BINDIST) ipfw/ipfw ipfw/ipfw.8 dummynet2/ipfw_mod.ko
71
72 windist:
73         $(MAKE) clean
74         -$(MAKE) all
75         -rm /tmp/$(WINDIST)
76         zip -r /tmp/$(WINDIST) binary -x \*.svn\*
77
78 win64:  clean
79         (cd dummynet2 && $(MAKE) include_e)
80         cp -r ipfw ipfw-64
81         echo "EXTRA_CFLAGS += -D_X64EMU" >> ipfw-64/Makefile
82         (cd ipfw-64 && $(MAKE) all)
83         cp -r dummynet2 dummynet2-64
84         rm -f dummynet2-64/Makefile
85         cp win64/sources dummynet2-64/sources
86         mkdir dummynet2-64/tmpbuild
87         mkdir binary64
88         win64/mysetenv.sh $(DRIVE) $(DDKDIR) $(TARGETOS)
89         cp binary/cygwin1.dll binary64/cygwin1.dll
90         cp ipfw-64/ipfw.exe binary64/ipfw.exe
91         cp win64/*.inf binary64
92         cp binary/testme.bat binary64/testme.bat
93         cp binary/wget.exe binary64/wget.exe
94         
95 planetlab_update:
96         # clean and create a local working directory
97         rm -rf /tmp/pl-tmp
98         mkdir -p /tmp/pl-tmp/pl
99         mkdir -p /tmp/pl-tmp/ol2
100         # get the trunk version of the PlanetLab repository
101         # to specify the sshkey use the .ssh/config file
102         (cd /tmp/pl-tmp/pl; \
103                 svn co svn+ssh://svn.planet-lab.org/svn/ipfw/trunk)
104         # get an updated copy of the main ipfw repository
105         (cd /tmp/pl-tmp/ol2; \
106                 svn export svn+ssh://onelab2.iet.unipi.it/home/svn/ports-luigi/dummynet-branches/ipfw3)
107         # copy the new version over the old one
108         (cd /tmp/pl-tmp; cp -rP ol2/ipfw3/* pl/trunk)
109         # files cleanup in the old version
110         (cd /tmp/pl-tmp; diff -r ol2/ipfw3 pl/trunk | \
111                 grep -v "svn" | awk '{print $$3 $$4}' | \
112                 sed 's/:/\//' | xargs rm -rf)
113         # local adjustmens here
114         rm -rf /tmp/pl-tmp/pl/trunk/planetlab/check_planetlab_sync
115         # commit to the remote repo
116         @echo "Please, revise the update with the commands:"
117         @echo "(cd /tmp/pl-tmp/pl/trunk; svn diff)"
118         @echo "(cd /tmp/pl-tmp/pl/trunk; svn status)"
119         @echo "and commit with:"
120         @echo "(cd /tmp/pl-tmp/pl/trunk; svn ci -m 'Update from the mail ipfw repo.')"
121
122 install: