play with the makefile to try and support openwrt
[ipfw-google.git] / Makefile.openwrt
1 # Makefile to build the package in openwrt.
2 # goes into package/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 ifeq ($(KERNEL),2.6)
21
22 VERS:=2.6
23 IPFW_MOD:=ipfw_mod.ko
24 IPFW_SRC_DIR:=M
25
26 else
27
28 VERS:=openwrt
29 CFLAGS_WRT:=-DSYSCTL_NODE -DEMULATE_SYSCTL
30 IPFW_MOD:=ipfw_mod.o
31 IPFW_SRC_DIR:=SUBDIRS
32
33 endif
34
35 # Description for the package.
36 # The names KernelPackage/ipfw3 must match the arguments to the
37 # call $(eval $(call KernelPackage,ipfw3)) used to build it
38
39 define KernelPackage/ipfw3
40  SUBMENU:=Other modules
41  TITLE:= IPFW and dummynet
42  # FILES is what makes up the module, both kernel and userland
43  # It must be in the KernelPackage section
44  FILES := $(PKG_BUILD_DIR)/kipfw/$(IPFW_MOD) $(PKG_BUILD_DIR)/ipfw/ipfw
45  # AUTOLOAD:=$(call AutoLoad,80,ipfw_mod)
46 endef
47
48 define KernelPackage/ipfw3/description
49  This package contains the ipfw and dummynet module
50 endef
51
52 # Standard entries for the openwrt builds: Build/Prepare and Build/Compile
53 # Remember that commands must start with a tab
54
55 # 'prepare' instructions for both kernel and userland
56 # We copy the entire subtree, then build include_e/ which
57 # contains empty headers used by the kernel sources.
58 define Build/Prepare
59   # $(warning Preparing ipfw sources)
60         mkdir -p $(PKG_BUILD_DIR)
61         $(CP) -Rp $(IPFW_DIR)/* $(PKG_BUILD_DIR)/
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         # compile the kernel part for openwrt
68         $(MAKE) -C "$(LINUX_DIR)" \
69                 CROSS_COMPILE="$(TARGET_CROSS)" \
70                 ARCH="$(LINUX_KARCH)" \
71                 $(IPFW_SRC_DIR)="$(PKG_BUILD_DIR)/kipfw" \
72                 IPFW3_ROOT="$(PKG_BUILD_DIR)" \
73                 _VER=$(VERS) modules
74         # compile the userland part for openwrt
75         $(MAKE) -C $(PKG_BUILD_DIR)/ipfw \
76                 $(TARGET_CONFIGURE_OPTS) \
77                 CFLAGS="$(TARGET_CFLAGS) $(CFLAGS_WRT) -I./include_e -I./include -include ../glue.h -DNO_ALTQ -D__BSD_VISIBLE" \
78                 _VER=$(VERS) all
79 endef
80
81 define Package/ipfw3-userland
82   SECTION:=utils
83   CATEGORY:=Utilities
84   TITLE := /sbin/ipfw
85   DESCRIPTION := This is the control program for ipfw and dummynet
86 endef
87
88 define Package/ipfw3-userland/install
89         $(INSTALL_DIR) $(1) /sbin
90 endef
91
92 # XXX not entirely clear why the install entry for userland works,
93 # given that /sbin/ipfw is in KernelPackage/ipfw3
94
95 $(eval $(call Package,ipfw3-userland))
96 $(eval $(call KernelPackage,ipfw3))