4cff1c44684f9cf204a9e9d281bc9f75ded96962
[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:=1578
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=7e44e9275aafce871a91b9ab5f710ed953dda74c
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=9234caa91ce04d0bba893738da960b88154e5474
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 # have to set this variable after including the Makefiles
40 ifneq ($(CONFIG_BATMAN_ADV_DEV),)
41 STAMP_PREPARED:=$(STAMP_PREPARED)_dev
42 else
43 STAMP_PREPARED:=$(STAMP_PREPARED)_maint
44 endif
45 STAMP_PREPARED:=$(STAMP_PREPARED)$(if $(CONFIG_KMOD_BATMAN_ADV_BATCTL),_batctl)
46 STAMP_BUILT:=$(STAMP_BUILT)$(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),_debug)
47
48 define Package/batman-adv/Default
49 URL:=http://www.open-mesh.org/
50 MAINTAINER:=Marek Lindner <lindner_marek@yahoo.de>
51 endef
52
53 define KernelPackage/batman-adv-kernelland
54 $(call Package/batman-adv/Default)
55 SUBMENU:=Network Support
56 DEPENDS:=@LINUX_2_6
57 TITLE:=B.A.T.M.A.N. layer 2
58 FILES:=$(PKG_KMOD_BUILD_DIR)/batman-adv.$(LINUX_KMOD_SUFFIX)
59 AUTOLOAD:=$(call AutoLoad,50,batman-adv)
60 endef
61
62 define KernelPackage/batman-adv-kernelland/config
63 source "$(SOURCE)/Config.in"
64 endef
65
66 define KernelPackage/batman-adv-kernelland/description
67 B.A.T.M.A.N. layer 2
68 endef
69
70 define Download/batman-adv-kernelland
71 FILE:=$(PKG_KMOD_FNAME)
72 URL:=http://git.open-mesh.org/snapshot/$(PKG_KMOD_VERSION)/
73 endef
74 $(eval $(call Download,batman-adv-kernelland))
75
76 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
77 define Download/batctl
78 FILE:=$(PKG_TOOL_FNAME)
79 URL:=$(PKG_TOOL_URL)
80 PROTO:=svn
81 VERSION:=$(PKG_TOOL_VERSION)
82 SUBDIR:=$(PKG_SOURCE_SUBDIR)/batctl
83 endef
84 $(eval $(call Download,batctl))
85 endif
86
87 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
88 ifneq ($(DEVELOPER)$(CONFIG_BATMAN_ADV_DEV),)
89 define Download/batman
90 FILE:=batman-$(PKG_REV).tar.gz
91 URL:=http://downloads.open-mesh.org/svn/batman/trunk/batman
92 PROTO:=svn
93 VERSION:=$(PKG_REV)
94 SUBDIR:=$(PKG_SOURCE_SUBDIR)/batman
95 endef
96 $(eval $(call Download,batman))
97 endif
98 endif
99
100 define Build/Prepare
101 tar xzf "$(DL_DIR)/$(PKG_KMOD_FNAME)" -C "$(PKG_BUILD_DIR)"
102 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
103 tar xzf "$(DL_DIR)/$(PKG_TOOL_FNAME)" -C "$(BUILD_DIR)"
104 ifneq ($(DEVELOPER)$(CONFIG_BATMAN_ADV_DEV),)
105 tar xzf "$(DL_DIR)/batman-$(PKG_REV).tar.gz" -C "$(BUILD_DIR)"
106 endif
107 endif
108 mv "$(PKG_BUILD_DIR)/batman-adv" "$(PKG_KMOD_BUILD_DIR)"
109 $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),)
110 ifneq ($(CONFIG_BATMAN_ADV_DEV),)
111 $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/dev,)
112 else
113 $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/maint,)
114 endif
115 cp $(PKG_KMOD_BUILD_DIR)/Makefile.kbuild $(PKG_KMOD_BUILD_DIR)/Makefile
116 endef
117
118 MAKE_BATADV_KERNELLAND_ARGS += \
119 CROSS_COMPILE="$(TARGET_CROSS)" \
120 ARCH="$(LINUX_KARCH)" \
121 PATH="$(TARGET_PATH)" \
122 $(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),EXTRA_CFLAGS="-DCONFIG_BATMAN_ADV_DEBUG") \
123 SUBDIRS="$(PKG_KMOD_BUILD_DIR)" \
124 LINUX_VERSION="$(LINUX_VERSION)" \
125 REVISION="$(PKG_REV)" modules
126
127 MAKE_BATCTL_ARGS += \
128 CFLAGS="$(TARGET_CFLAGS)" \
129 CCFLAGS="$(TARGET_CFLAGS)" \
130 OFLAGS="$(TARGET_CFLAGS)" \
131 REVISION="$(PKG_REV)" \
132 CC="$(TARGET_CC)" \
133 NODEBUG=1 \
134 UNAME="Linux" \
135 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
136 STRIP="/bin/true" \
137 batctl install
138
139 define Build/Configure
140 endef
141
142 ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_kmod-batman-adv-kernelland),)
143 BUILD_KMOD_ADV = $(MAKE) -C "$(LINUX_DIR)" $(MAKE_BATADV_KERNELLAND_ARGS)
144 BUILD_BATCTL = $(MAKE) -C $(PKG_TOOL_BUILD_DIR) $(MAKE_BATCTL_ARGS)
145 endif
146
147 define Build/Compile
148 $(BUILD_KMOD_ADV)
149 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
150 $(BUILD_BATCTL)
151 endif
152 endef
153
154 define Build/Clean
155 rm -rf $(PKG_KMOD_BUILD_DIR)
156 endef
157
158 define KernelPackage/batman-adv-kernelland/install
159 $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d
160 $(INSTALL_BIN) ./files/etc/init.d/batman-adv-kernelland $(1)/etc/init.d
161 $(INSTALL_DATA) ./files/etc/config/batman-adv-kernelland $(1)/etc/config
162 ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
163 $(INSTALL_DIR) $(1)/usr/sbin
164 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/batctl $(1)/usr/sbin/
165 endif
166 endef
167
168 $(eval $(call KernelPackage,batman-adv-kernelland))