tweak for building in fedora20
[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:=ipfw3
12 PKG_RELEASE:=1
13
14 # MV is undefined, we use it in the internal Makefiles
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 ifeq ($(KERNEL),2.4)
23     VERS:=openwrt
24     CFLAGS_WRT:=-DSYSCTL_NODE -DEMULATE_SYSCTL
25     IPFW_MOD:=ipfw_mod.o
26     IPFW_SRC_DIR:=SUBDIRS
27 else
28     #VERS:=2.6
29     IPFW_MOD:=ipfw_mod.ko
30     IPFW_SRC_DIR:=M
31 endif
32
33 define Package/ipfw3
34   SECTION:=utils
35   CATEGORY:=Utilities
36   TITLE := /sbin/ipfw
37   DEPENDS := +libc +libgcc
38   FILES := $(PKG_BUILD_DIR)/ipfw/ipfw
39   $(warning --- build dir is $(PKG_BUILD_DIR) ---)
40 endef
41
42 define Package/ipfw3/description
43   Control program for ipfw and dummynet
44 endef
45
46 # XXX not entirely clear why the install entry for userland works,
47 # given that /sbin/ipfw is in KernelPackage/ipfw3
48
49 define Package/ipfw3/install
50         $(INSTALL_DIR) $(1) /sbin
51 endef
52
53 # Description for the package.
54 # The names KernelPackage/ipfw3 must match the arguments to the
55 # call $(eval $(call KernelPackage,ipfw3)) used to build it
56
57 define KernelPackage/ipfw3
58   SUBMENU:=Other modules
59   TITLE:= IPFW and dummynet
60   # FILES is what makes up the module, both kernel and userland
61   # It must be in the KernelPackage section XXX
62   FILES := $(PKG_BUILD_DIR)/kipfw-mod/$(IPFW_MOD)
63   # AUTOLOAD:=$(call AutoLoad,80,ipfw_mod)
64 endef
65
66 define KernelPackage/kmod-ipfw3/description
67   ipfw and dummynet kernel module
68 endef
69
70 # Standard entries for the openwrt builds: Build/Prepare and Build/Compile
71 # Remember that commands must start with a tab
72
73 # 'prepare' instructions for both kernel and userland
74 # We copy the entire subtree, then build include_e/ which
75 # contains empty headers used by the kernel sources.
76 define Build/Prepare
77   # $(warning --- Preparing ipfw sources ---)
78         mkdir -p $(PKG_BUILD_DIR)
79         $(CP) -Rp $(IPFW_DIR)/* $(PKG_BUILD_DIR)/
80         # The kernel sources are spread in multiple places,
81         # so we put everything in kipfw-mod
82         mkdir -p $(PKG_BUILD_DIR)/kipfw-mod
83         cp -Rp $(IPFW_DIR)/kipfw/* $(PKG_BUILD_DIR)/kipfw-mod
84         cp `find $(IPFW_DIR)/sys -name \*.c` $(PKG_BUILD_DIR)/kipfw-mod
85         # we do not need cross parameters
86         (cd $(PKG_BUILD_DIR)/ipfw && $(MAKE) include_e )
87         (cd $(PKG_BUILD_DIR)/kipfw-mod && $(MAKE) include_e )
88 endef
89
90 define Build/Compile
91         # XXX check whether we need all linux_dir etc.
92         $(warning --- compile the user part for ipfw/openwrt ---)
93         $(MAKE) -C $(PKG_BUILD_DIR)/ipfw \
94                 LINUX_DIR=$(LINUX_DIR) \
95                 $(TARGET_CONFIGURE_OPTS) \
96                 CFLAGS="$(TARGET_CFLAGS) $(CFLAGS_WRT) -I./include_e -I./include -include ../glue.h -DNO_ALTQ -D__BSD_VISIBLE" \
97                 _VER=$(VERS) all
98         $(warning --- compile the kernel part for ipfw/openwrt ---)
99         $(MAKE) -C "$(LINUX_DIR)" \
100                 CROSS_COMPILE="$(TARGET_CROSS)" \
101                 LINUX_DIR=$(LINUX_DIR) \
102                 KERNELPATH=$(LINUX_DIR) \
103                 ARCH="$(LINUX_KARCH)" \
104                 $(IPFW_SRC_DIR)="$(PKG_BUILD_DIR)/kipfw-mod" \
105                 IPFW3_ROOT="$(PKG_BUILD_DIR)" \
106                 _VER=$(VERS) modules
107         $(warning +++ done compile the kernel part for ipfw/openwrt ---)
108 endef
109
110
111 $(eval $(call BuildPackage,ipfw3))
112 $(eval $(call KernelPackage,ipfw3))