now the kernel builds,
[ipfw-google.git] / Makefile
1 # $Id: Makefile 11689 2012-08-12 21:07:34Z 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 DISTFILES= Makefile Makefile.inc README binary* ipfw kipfw *.h sys
23
24 .PHONY: ipfw kipfw
25
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
34 #  win7   -> windows 7
35 #  future version must be added here
36 DRIVE ?= C:
37 DDKDIR ?= /WinDDK/7600.16385.1
38 DDK = $(DRIVE)$(DDKDIR)
39 TARGETOS=win7
40
41 export WIN64
42 export DDK
43 export DRIVE
44 export DDKDIR
45
46 _all: all
47
48 clean distclean:
49         -@(cd ipfw && $(MAKE) $(@) )
50         -@rm -rf kipfw-mod binary64/[A-hj-z]*
51
52 all: kipfw ipfw
53         @# -- windows only
54 ifeq ($(OSARCH),Windows)        # copy files
55 ifeq ($(WIN64),)
56         -@ cp ipfw/ipfw.exe kipfw-mod/$(OBJDIR)/ipfw.sys binary/
57         -@ cp kipfw/*.inf binary/
58 else
59         -@ cp binary/* kipfw/*.inf binary64/
60         -@ cp ipfw/ipfw.exe kipfw-mod/objchk_win7_amd64/amd64/ipfw.sys binary64/
61 endif   # WIN64
62 endif   # Windows
63
64 win64:
65         $(MAKE) WIN64=1
66
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.
72
73 ndis-glue:
74         -@mkdir -p kipfw-mod
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 )
77
78 kipfw-src:
79         -@rm -rf kipfw-mod
80         -@mkdir -p kipfw-mod
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)
85         make ndis-glue
86 endif
87
88 snapshot:
89         $(MAKE) distclean
90         (tar cvzhf /tmp/$(SNAPSHOT_NAME) -s':^:ipfw3-2012/:' $(DISTFILES) )
91
92 bindist:
93         $(MAKE) clean
94         $(MAKE) all
95         tar cvzf /tmp/$(BINDIST) ipfw/ipfw ipfw/ipfw.8 kipfw-mod/ipfw_mod.ko
96
97 windist:
98         $(MAKE) clean
99         -$(MAKE) all
100         -rm /tmp/$(WINDIST)
101         zip -r /tmp/$(WINDIST) binary -x \*.svn\*
102
103
104 ipfw:
105         @(cd ipfw && $(MAKE) $(@) )
106
107 kipfw: kipfw-src
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)
114 endif
115
116 openwrt_release:
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))
122         mkdir $(DSTDIR)
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))
127
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
137
138         @echo ""
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."
143
144 install:
145
146 diff:
147         -@(diff -upr $(BSD_HEAD)/sbin/ipfw ipfw)
148         -@(diff -upr $(BSD_HEAD)/sys sys)
149