batman-adv: adding support for the development branch
[openwrt/svn-archive/archive.git] / net / batman-advanced / Makefile
1 #
2 # Copyright (C) 2008 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id: Makefile 5624 2006-11-23 00:29:07Z nbd $
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=batman-adv
12 PKG_REV:=1568
13 PKG_VERSION:=r$(PKG_REV)
14 PKG_RELEASE:=1
15
16 PKG_SOURCE_SUBDIR:=$(PKG_NAME)
17
18 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
19 PKG_TOOL_VERSION=$(PKG_REV)
20
21 ifneq ($(CONFIG_BATMAN_ADV_DEV),)
22 PKG_KMOD_VERSION=060c4d34077550d57cd57c5375dd5f8758391eb5
23 PKG_KMOD_FNAME=batman-adv-dev-$(PKG_REV).tar.gz
24 PKG_TOOL_URL=http://downloads.open-mesh.org/svn/batman/trunk/batctl
25 PKG_TOOL_FNAME:=batctl-dev-$(PKG_TOOL_VERSION).tar.gz
26 else
27 PKG_KMOD_VERSION=1b58d49b4342caabb9624243bc76e037eaac2673
28 PKG_KMOD_FNAME=batman-adv-maint-$(PKG_REV).tar.gz
29 PKG_TOOL_URL=http://downloads.open-mesh.org/svn/batman/branches/batctl-0.2.x/
30 PKG_TOOL_FNAME:=batctl-maint-$(PKG_TOOL_VERSION).tar.gz
31 endif
32
33 PKG_KMOD_BUILD_DIR:=$(PKG_BUILD_DIR)/batman-adv-kernelland
34 PKG_TOOL_BUILD_DIR:=$(PKG_BUILD_DIR)/batctl
35
36 include $(INCLUDE_DIR)/package.mk
37 include $(INCLUDE_DIR)/kernel.mk
38
39 define Package/batman-adv/Default
40 URL:=http://www.open-mesh.org/
41 MAINTAINER:=Marek Lindner <lindner_marek@yahoo.de>
42 endef
43
44 define KernelPackage/batman-adv-kernelland
45 $(call Package/batman-adv/Default)
46 SUBMENU:=Network Support
47 DEPENDS:=@LINUX_2_6
48 TITLE:=B.A.T.M.A.N. layer 2
49 FILES:=$(PKG_KMOD_BUILD_DIR)/batman-adv.$(LINUX_KMOD_SUFFIX)
50 AUTOLOAD:=$(call AutoLoad,50,batman-adv)
51 endef
52
53 define KernelPackage/batman-adv-kernelland/config
54 source "$(SOURCE)/Config.in"
55 endef
56
57 define KernelPackage/batman-adv-kernelland/description
58 B.A.T.M.A.N. layer 2
59 endef
60
61 define Download/batman-adv-kernelland
62 FILE:=$(PKG_KMOD_FNAME)
63 URL:=http://git.open-mesh.org/snapshot/$(PKG_KMOD_VERSION)/
64 endef
65 $(eval $(call Download,batman-adv-kernelland))
66
67 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
68 define Download/batctl
69 FILE:=$(PKG_TOOL_FNAME)
70 URL:=$(PKG_TOOL_URL)
71 PROTO:=svn
72 VERSION:=$(PKG_TOOL_VERSION)
73 SUBDIR:=$(PKG_SOURCE_SUBDIR)/batctl
74 endef
75 $(eval $(call Download,batctl))
76 endif
77
78 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
79 ifneq ($(DEVELOPER)$(CONFIG_BATMAN_ADV_DEV),)
80 define Download/batman
81 FILE:=batman-$(PKG_REV).tar.gz
82 URL:=http://downloads.open-mesh.org/svn/batman/trunk/batman
83 PROTO:=svn
84 VERSION:=$(PKG_REV)
85 SUBDIR:=$(PKG_SOURCE_SUBDIR)/batman
86 endef
87 $(eval $(call Download,batman))
88 endif
89 endif
90
91 define Build/Prepare
92 tar xzf "$(DL_DIR)/$(PKG_KMOD_FNAME)" -C "$(PKG_BUILD_DIR)"
93 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
94 tar xzf "$(DL_DIR)/$(PKG_TOOL_FNAME)" -C "$(BUILD_DIR)"
95 ifneq ($(DEVELOPER)$(CONFIG_BATMAN_ADV_DEV),)
96 tar xzf "$(DL_DIR)/batman-$(PKG_REV).tar.gz" -C "$(BUILD_DIR)"
97 endif
98 endif
99 mv "$(PKG_BUILD_DIR)/batman-adv" "$(PKG_KMOD_BUILD_DIR)"
100 cp $(PKG_KMOD_BUILD_DIR)/Makefile.kbuild $(PKG_KMOD_BUILD_DIR)/Makefile
101 $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),)
102 ifneq ($(CONFIG_BATMAN_ADV_DEV),)
103 $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/dev,)
104 else
105 $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/maint,)
106 endif
107 endef
108
109 MAKE_BATADV_KERNELLAND_ARGS += \
110 CROSS_COMPILE="$(TARGET_CROSS)" \
111 ARCH="$(LINUX_KARCH)" \
112 PATH="$(TARGET_PATH)" \
113 $(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),EXTRA_CFLAGS="-DCONFIG_BATMAN_ADV_DEBUG") \
114 SUBDIRS="$(PKG_KMOD_BUILD_DIR)" \
115 LINUX_VERSION="$(LINUX_VERSION)" \
116 REVISION="$(PKG_REV)" modules
117
118 MAKE_BATCTL_ARGS += \
119 CFLAGS="$(TARGET_CFLAGS)" \
120 CCFLAGS="$(TARGET_CFLAGS)" \
121 OFLAGS="$(TARGET_CFLAGS)" \
122 REVISION="$(PKG_REV)" \
123 CC="$(TARGET_CC)" \
124 NODEBUG=1 \
125 UNAME="Linux" \
126 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
127 STRIP="/bin/true" \
128 batctl install
129
130 define Build/Configure
131 endef
132
133 ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_kmod-batman-adv-kernelland),)
134 BUILD_KMOD_ADV = $(MAKE) -C "$(LINUX_DIR)" $(MAKE_BATADV_KERNELLAND_ARGS)
135 BUILD_BATCTL = $(MAKE) -C $(PKG_TOOL_BUILD_DIR) $(MAKE_BATCTL_ARGS)
136 endif
137
138 define Build/Compile
139 $(BUILD_KMOD_ADV)
140 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
141 $(BUILD_BATCTL)
142 endif
143 endef
144
145 define Build/Clean
146 rm -rf $(PKG_KMOD_BUILD_DIR)
147 endef
148
149 define KernelPackage/batman-adv-kernelland/install
150 $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d
151 $(INSTALL_BIN) ./files/etc/init.d/batman-adv-kernelland $(1)/etc/init.d
152 $(INSTALL_DATA) ./files/etc/config/batman-adv-kernelland $(1)/etc/config
153 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
154 $(INSTALL_DIR) $(1)/usr/sbin
155 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/batctl $(1)/usr/sbin/
156 endif
157 endef
158
159 $(eval $(call KernelPackage,batman-adv-kernelland))