786a39d124aa31c1f29b99eab4240ed7a961a705
[openwrt-10.03/.git] / package / wprobe / 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 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/kernel.mk
9
10 PKG_NAME:=wprobe
11 PKG_VERSION:=1
12
13 PKG_BUILD_DEPENDS:=PACKAGE_wprobe-export:libipfix
14
15 PKG_CONFIG_DEPENDS = \
16         CONFIG_PACKAGE_kmod-wprobe \
17         CONFIG_PACKAGE_wprobe-export \
18
19 include $(INCLUDE_DIR)/package.mk
20
21 define Package/wprobe/Default
22   DEPENDS:=@LINUX_2_6 @(!(TARGET_ps3||TARGET_pxcab)||BROKEN)
23 endef
24
25 define KernelPackage/wprobe
26 $(call Package/wprobe/Default)
27   SUBMENU:=Network Support
28   TITLE:=Wireless driver probe infrastructure
29   FILES:= \
30         $(PKG_BUILD_DIR)/kernel/wprobe.$(LINUX_KMOD_SUFFIX)
31   AUTOLOAD:=$(call AutoLoad,01,wprobe)
32 endef
33
34 define KernelPackage/wprobe/description
35   A module that exports measurement data from wireless driver to user space
36 endef
37
38 define Package/wprobe-util
39 $(call Package/wprobe/Default)
40   SECTION:=net
41   CATEGORY:=Network
42   DEPENDS+=+kmod-wprobe +libnl-tiny
43   TITLE:=Wireless measurement utility
44 endef
45
46 define Package/wprobe-util/description
47   wprobe-util uses the wprobe kernel module to query
48   wireless driver measurement data from an interface
49 endef
50
51 define Package/wprobe-export
52 $(call Package/wprobe/Default)
53   SECTION:=net
54   CATEGORY:=Network
55   DEPENDS+=+wprobe-util
56   TITLE:=Wireless measurement data exporter
57 endef
58
59 define Package/wprobe-export/description
60   wprobe-export uses the wprobe kernel module to export
61   wireless driver measurement data via the IPFIX protocol
62 endef
63
64 define Build/Prepare
65         mkdir -p $(PKG_BUILD_DIR)
66         $(CP) src/* $(PKG_BUILD_DIR)/
67 endef
68
69 TARGET_CPPFLAGS := \
70         -D_GNU_SOURCE \
71         -I$(STAGING_DIR)/usr/include/libnl-tiny \
72         $(TARGET_CPPFLAGS)
73
74 ifdef CONFIG_PACKAGE_kmod-wprobe
75   define Build/Compile/kmod
76         $(MAKE) -C $(LINUX_DIR) \
77                 CROSS_COMPILE="$(KERNEL_CROSS)" \
78                 ARCH="$(LINUX_KARCH)" \
79                 SUBDIRS="$(PKG_BUILD_DIR)/kernel" \
80                 KERNELDIR=$(LINUX_DIR) \
81                 CC="$(TARGET_CC)" \
82                 EXTRA_CFLAGS="-I$(PKG_BUILD_DIR)/kernel" \
83                 modules
84   endef
85 endif
86
87 define Build/Compile/lib
88         $(MAKE) -C $(PKG_BUILD_DIR)/user \
89                 $(TARGET_CONFIGURE_OPTS) \
90                 CFLAGS="$(TARGET_CFLAGS)" \
91                 CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PKG_BUILD_DIR)/kernel" \
92                 LDFLAGS="$(TARGET_LDFLAGS)" \
93                 HOST_OS=Linux \
94                 LIBNL="-lnl-tiny"
95 endef
96
97 ifdef CONFIG_PACKAGE_wprobe-export
98   define Build/Compile/exporter
99         $(MAKE) -C $(PKG_BUILD_DIR)/exporter \
100                 $(TARGET_CONFIGURE_OPTS) \
101                 CFLAGS="$(TARGET_CFLAGS)" \
102                 CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PKG_BUILD_DIR)/kernel -I$(PKG_BUILD_DIR)/user" \
103                 LDFLAGS="$(TARGET_LDFLAGS)" \
104                 LIBS="$(PKG_BUILD_DIR)/user/libwprobe.a $(STAGING_DIR)/usr/lib/libipfix.a $(STAGING_DIR)/usr/lib/libmisc.a -lnl-tiny -lm"
105   endef
106 endif
107
108 define Build/Compile
109         $(Build/Compile/kmod)
110         $(Build/Compile/lib)
111         $(Build/Compile/exporter)
112 endef
113
114 define Build/InstallDev
115         $(INSTALL_DIR) $(1)/usr/include/wprobe
116         $(CP) $(PKG_BUILD_DIR)/kernel/linux $(1)/usr/include/wprobe
117 endef
118
119 define Package/wprobe-util/install
120         $(INSTALL_DIR) $(1)/sbin
121         $(INSTALL_BIN) $(PKG_BUILD_DIR)/user/wprobe-util $(1)/sbin/
122 endef
123
124 define Package/wprobe-export/install
125         $(INSTALL_DIR) $(1)/sbin $(1)/etc/init.d $(1)/etc/config
126         $(INSTALL_BIN) ./files/wprobe.init $(1)/etc/init.d/wprobe
127         $(INSTALL_BIN) ./files/wprobe.config $(1)/etc/config/wprobe
128         $(INSTALL_BIN) $(PKG_BUILD_DIR)/exporter/wprobe-export $(1)/sbin/
129 endef
130
131 $(eval $(call KernelPackage,wprobe))
132 $(eval $(call BuildPackage,wprobe-util))
133 $(eval $(call BuildPackage,wprobe-export))