8c54bd73bd4e69e887eecd6b218498268aee8182
[ipfw-google.git] / Makefile.openwrt
1 # Makefile to build the package in openwrt.
2 # goes into package/network/utils/ipfw3/Makefile
3 #
4 # Edit IPFW_DIR to point to the directory with the sources for ipfw
5
6 IPFW_DIR := $(TOPDIR)/../qemu-misc/ipfw3
7
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/kernel.mk
10
11 PKG_NAME:=kmod-ipfw3
12 PKG_RELEASE:=1
13
14 # MV is undefined
15 MV ?= mv
16
17 include $(INCLUDE_DIR)/package.mk
18
19 #Stuff depending on kernel version
20 $(warning --- openwrt kernel version $(KERNEL) linux dir $(LINUX_DIR) -------)
21
22
23 ifeq ($(KERNEL),2.4)
24     VERS:=openwrt
25     CFLAGS_WRT:=-DSYSCTL_NODE -DEMULATE_SYSCTL
26     IPFW_MOD:=ipfw_mod.o
27     IPFW_SRC_DIR:=SUBDIRS
28 else
29     VERS:=2.6
30     IPFW_MOD:=ipfw_mod.ko
31     IPFW_SRC_DIR:=M
32 endif
33
34 # Description for the package.
35 # The names KernelPackage/ipfw3 must match the arguments to the
36 # call $(eval $(call KernelPackage,ipfw3)) used to build it
37
38 define KernelPackage/ipfw3
39  SUBMENU:=Other modules
40  TITLE:= IPFW and dummynet
41  # FILES is what makes up the module, both kernel and userland
42  # It must be in the KernelPackage section
43  FILES := $(PKG_BUILD_DIR)/kipfw/$(IPFW_MOD) $(PKG_BUILD_DIR)/ipfw/ipfw
44  # AUTOLOAD:=$(call AutoLoad,80,ipfw_mod)
45 endef
46
47 define KernelPackage/ipfw3/description
48  This package contains the ipfw and dummynet module
49 endef
50
51 # Standard entries for the openwrt builds: Build/Prepare and Build/Compile
52 # Remember that commands must start with a tab
53
54 # 'prepare' instructions for both kernel and userland
55 # We copy the entire subtree, then build include_e/ which
56 # contains empty headers used by the kernel sources.
57 define Build/Prepare
58   # $(warning Preparing ipfw sources)
59         mkdir -p $(PKG_BUILD_DIR)
60         $(CP) -Rp $(IPFW_DIR)/* $(PKG_BUILD_DIR)/
61         # we do not need cross parameters
62         (cd $(PKG_BUILD_DIR)/ipfw && $(MAKE) include_e )
63         (cd $(PKG_BUILD_DIR)/kipfw && $(MAKE) include_e )
64 endef
65
66 define Build/Compile
67         $(warning  compile the userland part for ipfw/openwrt)
68         $(MAKE) -C $(PKG_BUILD_DIR)/ipfw \
69                 LINUX_DIR=$(LINUX_DIR) \
70                 $(TARGET_CONFIGURE_OPTS) \
71                 CFLAGS="$(TARGET_CFLAGS) $(CFLAGS_WRT) -I./include_e -I./include -include ../glue.h -DNO_ALTQ -D__BSD_VISIBLE" \
72                 _VER=$(VERS) all
73         $(warning  compile the kernel part for ipfw/openwrt)
74         # compile the kernel part for openwrt
75         $(MAKE) -C "$(LINUX_DIR)" \
76                 CROSS_COMPILE="$(TARGET_CROSS)" \
77                 LINUX_DIR=$(LINUX_DIR) \
78                 KERNELPATH=$(LINUX_DIR) \
79                 ARCH="$(LINUX_KARCH)" \
80                 $(IPFW_SRC_DIR)="$(PKG_BUILD_DIR)/kipfw" \
81                 IPFW3_ROOT="$(PKG_BUILD_DIR)" \
82                 _VER=$(VERS) modules
83 endef
84
85 define Build/Compile_new
86         $(call Build/Compile/Default)
87         $(call Build/Compile/Default,modules)
88 endef
89
90 define Package/ipfw3-userland
91   SECTION:=utils
92   CATEGORY:=Utilities
93   TITLE := /sbin/ipfw
94   DESCRIPTION := This is the control program for ipfw and dummynet
95 endef
96
97 define Package/ipfw3-userland/install
98         $(INSTALL_DIR) $(1) /sbin
99 endef
100
101 # XXX not entirely clear why the install entry for userland works,
102 # given that /sbin/ipfw is in KernelPackage/ipfw3
103
104 $(eval $(call Package,ipfw3-userland))
105 $(eval $(call KernelPackage,ipfw3))