tweak for building in fedora20
[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         (cd kipfw-mod; for i in  `find . -type f`; do sed -i.tmp "s/$$(printf '\r')//g" $$i; done )
77         cat kipfw/win-passthru.diff | sed "s/$$(printf '\r')//g" | (cd kipfw-mod; patch )
78
79 kipfw-src:
80         -@rm -rf kipfw-mod
81         -@mkdir -p kipfw-mod
82         -@cp -Rp kipfw/* kipfw-mod
83         -@cp `find sys -name \*.c` kipfw-mod
84         -@(cd kipfw-mod && $(MAKE) include_e)
85 ifeq ($(OSARCH),Windows)
86         make ndis-glue
87 endif
88
89 snapshot:
90         $(MAKE) distclean
91         (tar cvzhf /tmp/$(SNAPSHOT_NAME) -s':^:ipfw3-2012/:' $(DISTFILES) )
92
93 bindist:
94         $(MAKE) clean
95         $(MAKE) all
96         tar cvzf /tmp/$(BINDIST) ipfw/ipfw ipfw/ipfw.8 kipfw-mod/ipfw_mod.ko
97
98 windist:
99         $(MAKE) clean
100         -$(MAKE) all
101         -rm /tmp/$(WINDIST)
102         zip -r /tmp/$(WINDIST) binary -x \*.svn\*
103
104
105 ipfw:
106         @(cd ipfw && $(MAKE) $(@) )
107
108 kipfw: kipfw-src
109 ifeq ($(WIN64),)        # linux or windows 32 bit
110         @(cd kipfw-mod && $(MAKE) $(@) )
111 else    #--- windows 64 bit, we use build.exe and nmake
112         rm -f kipfw-mod/Makefile
113         mkdir kipfw-mod/tmpbuild                # check mysetenv.sh
114         bash kipfw/mysetenv.sh $(DRIVE) $(DDKDIR) $(TARGETOS)
115 endif
116
117 openwrt_release:
118         # create a temporary directory
119         $(eval TMPDIR := $(shell mktemp -d -p /tmp/ ipfw3_openwrt_XXXXX))
120         # create the source destination directory
121         $(eval IPFWDIR := ipfw3-$(DATE))
122         $(eval DSTDIR := $(TMPDIR)/$(IPFWDIR))
123         mkdir $(DSTDIR)
124         # copy the package, clean objects and svn info
125         cp -r ./ipfw ./kipfw-mod glue.h Makefile ./configuration README $(DSTDIR)
126         (cd $(DSTDIR); make -s distclean; find . -name .svn | xargs rm -rf)
127         (cd $(TMPDIR); tar czf $(IPFWDIR).tar.gz $(IPFWDIR))
128
129         # create the port files in /tmp/ipfw3-port
130         $(eval PORTDIR := $(TMPDIR)/ipfw3)
131         mkdir -p $(PORTDIR)/patches
132         # generate the Makefile, PKG_VERSION and PKG_MD5SUM
133         md5sum $(DSTDIR).tar.gz | cut -d ' ' -f 1 > $(TMPDIR)/md5sum
134         cat ./OPENWRT/Makefile | \
135                 sed s/PKG_VERSION:=/PKG_VERSION:=$(DATE)/ | \
136                 sed s/PKG_MD5SUM:=/PKG_MD5SUM:=`cat $(TMPDIR)/md5sum`/ \
137                 > $(PORTDIR)/Makefile
138
139         @echo ""
140         @echo "The openwrt port is in $(TMPDIR)/ipfw3-port"
141         @echo "The source file should be copied to the public server:"
142         @echo "scp $(DSTDIR).tar.gz marta@info.iet.unipi.it:~marta/public_html/dummynet"
143         @echo "after this the temporary directory $(TMPDIR) can be removed."
144
145 install:
146
147 diff:
148         -@(diff -upr $(BSD_HEAD)/sbin/ipfw ipfw)
149         -@(diff -upr $(BSD_HEAD)/sys sys)
150