57509cbe0a1f5fe7ddccf1148e2dba3474e2a865
[openwrt/svn-archive/archive.git] / net / pmacct / Makefile
1 #
2 # Copyright (C) 2006 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$
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=pmacct
12 PKG_VERSION:=0.10.3
13 PKG_RELEASE:=1
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
16 PKG_SOURCE_URL:=http://www.ba.cnr.it/~paolo/pmacct/
17 PKG_MD5SUM:=0be1ffd9d4bda73575caa3240abbf4cb
18 PKG_CAT:=zcat
19
20 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
21
22 PKG_BUILDDEP:=libpcap
23
24 include $(INCLUDE_DIR)/package.mk
25
26 define Package/pmacct/Default
27 SECTION:=net
28 CATEGORY:=Network
29 SUBMENU:=pmacct (accounting and aggregation tools)
30 URL:=http://www.ba.cnr.it/~paolo/pmacct/
31 endef
32
33 define Package/nfacctd/Default
34 $(call Package/pmacct/Default)
35 TITLE:=NetFlow accounting daemon
36 endef
37
38 define Package/nfacctd
39 $(call Package/nfacctd/Default)
40 endef
41
42 define Package/nfacctd-mysql
43 $(call Package/nfacctd/Default)
44 TITLE+= with MySQL support
45 DEPENDS+= +libmysqlclient
46 endef
47
48 define Package/nfacctd-pgsql
49 $(call Package/nfacctd/Default)
50 TITLE+= with PostreSQL support
51 DEPENDS+= +libpq
52 endef
53
54 define Package/nfacctd-sqlite
55 $(call Package/nfacctd/Default)
56 TITLE+= with SQLite support
57 DEPENDS+= +libsqlite3
58 endef
59
60 define Package/pmacctd/Default
61 $(call Package/pmacct/Default)
62 DEPENDS+= +libpcap
63 TITLE:=IP pcap-based accounting daemon
64 endef
65
66 define Package/pmacctd
67 $(call Package/pmacctd/Default)
68 endef
69
70 define Package/pmacctd-mysql
71 $(call Package/pmacctd/Default)
72 TITLE+= with MySQL support
73 DEPENDS+= +libmysqlclient
74 endef
75
76 define Package/pmacctd-pgsql
77 $(call Package/pmacctd/Default)
78 TITLE+= with PostreSQL support
79 DEPENDS+= +libpq
80 endef
81
82 define Package/pmacctd-sqlite
83 $(call Package/pmacctd/Default)
84 TITLE+= with SQLite support
85 DEPENDS+= +libsqlite3
86 endef
87
88 define Package/sfacctd/Default
89 $(call Package/pmacct/Default)
90 TITLE:=sFlow accounting daemon
91 endef
92
93 define Package/pmacct-client
94 $(call Package/pmacct/Default)
95 TITLE:=Command-line client to gather data from the IMT plugin
96 endef
97
98
99 ifneq ($(SDK),)
100 CONFIG_PACKAGE_nfacctd:=m
101 CONFIG_PACKAGE_nfacctd-mysql:=m
102 CONFIG_PACKAGE_nfacctd-pgsql:=m
103 CONFIG_PACKAGE_nfacctd-sqlite:=m
104 CONFIG_PACKAGE_pmacctd:=m
105 CONFIG_PACKAGE_pmacctd-mysql:=m
106 CONFIG_PACKAGE_pmacctd-pgsql:=m
107 CONFIG_PACKAGE_pmacctd-sqlite:=m
108 endif
109
110 define Compile/Template
111
112 $(PKG_BUILD_DIR)/nfacctd-$(1) $(PKG_BUILD_DIR)/pmacctd-$(1): $(PKG_BUILD_DIR)/.configured
113 -$(MAKE) -C $(PKG_BUILD_DIR) distclean
114 $(call Build/Configure/Default, \
115 --with-pcap-includes="$(STAGING_DIR)/usr/include" \
116 --with-pcap-libs="$(STAGING_DIR)/usr/lib" \
117 $(2) \
118 , \
119 LIBS="-lz" \
120 );
121 $(MAKE) -C $(PKG_BUILD_DIR) \
122 CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
123 all
124 mv -f $(PKG_BUILD_DIR)/src/nfacctd $(PKG_BUILD_DIR)/nfacctd-$(1)
125 mv -f $(PKG_BUILD_DIR)/src/pmacctd $(PKG_BUILD_DIR)/pmacctd-$(1)
126
127 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/nfacctd-$(1) $(PKG_BUILD_DIR)/pmacctd-$(1)
128
129 endef
130
131
132 define Install/Template
133
134 define Package/$(1)/conffiles
135 /etc/default/$(3)
136 /etc/$(3).conf
137 endef
138
139 define Package/$(1)/install
140 install -d -m0755 $$(1)/usr/sbin
141 install -m0755 $(PKG_BUILD_DIR)/$(2) $$(1)/usr/sbin/$(3)
142 install -d -m0755 $$(1)/etc
143 install -m0644 ./files/$(3).conf $$(1)/etc/
144 install -d -m0755 $$(1)/etc/default
145 install -m0644 ./files/$(3).default $$(1)/etc/default/$(3)
146 install -d -m0755 $$(1)/etc/init.d
147 install -m0755 ./files/$(3).init $$(1)/etc/init.d/$(3)
148 endef
149
150 endef
151
152
153 ifneq ($(CONFIG_PACKAGE_nfacctd)$(CONFIG_PACKAGE_pmacctd),)
154 $(eval $(call Compile/Template,basic))
155 $(eval $(call Install/Template,nfacctd,nfacctd-basic,nfacctd))
156 $(eval $(call Install/Template,pmacctd,pmacctd-basic,pmacctd))
157 endif
158 ifneq ($(CONFIG_PACKAGE_nfacctd-mysql)$(CONFIG_PACKAGE_pmacctd-mysql),)
159 $(eval $(call Compile/Template,mysql, \
160 --enable-mysql \
161 --with-mysql-includes="$(STAGING_DIR)/usr/include" \
162 --with-mysql-libs="$(STAGING_DIR)/usr/lib/mysql" \
163 , \
164 LIBS='-lz' \
165 ))
166 $(eval $(call Install/Template,nfacctd-mysql,nfacctd-mysql,nfacctd))
167 $(eval $(call Install/Template,pmacctd-mysql,pmacctd-mysql,pmacctd))
168 endif
169 ifneq ($(CONFIG_PACKAGE_nfacctd-pgsql)$(CONFIG_PACKAGE_pmacctd-pgsql),)
170 $(eval $(call Compile/Template,pgsql, \
171 --enable-pgsql \
172 --with-pgsql-includes="$(STAGING_DIR)/usr/include" \
173 --with-pgsql-libs="$(STAGING_DIR)/usr/lib" \
174 ))
175 $(eval $(call Install/Template,nfacctd-pgsql,nfacctd-pgsql,nfacctd))
176 $(eval $(call Install/Template,pmacctd-pgsql,pmacctd-pgsql,pmacctd))
177 endif
178 ifneq ($(CONFIG_PACKAGE_nfacctd-sqlite)$(CONFIG_PACKAGE_pmacctd-sqlite),)
179 $(eval $(call Compile/Template,sqlite, \
180 --enable-sqlite3 \
181 --with-sqlite3-includes="$(STAGING_DIR)/usr/include" \
182 --with-sqlite3-libs="$(STAGING_DIR)/usr/lib" \
183 ))
184 $(eval $(call Install/Template,nfacctd-sqlite,nfacctd-sqlite,nfacctd))
185 $(eval $(call Install/Template,pmacctd-sqlite,pmacctd-sqlite,pmacctd))
186 endif
187
188 define Build/Configure
189 endef
190
191 define Build/Compile
192 endef
193
194 define Package/pmacct-client/install
195 install -d -m0755 $(1)/usr/sbin
196 $(CP) $(PKG_BUILD_DIR)/src/pmacct $(1)/usr/sbin/
197 endef
198
199 $(eval $(call BuildPackage,nfacctd))
200 $(eval $(call BuildPackage,nfacctd-mysql))
201 $(eval $(call BuildPackage,nfacctd-pgsql))
202 $(eval $(call BuildPackage,nfacctd-sqlite))
203 $(eval $(call BuildPackage,pmacctd))
204 $(eval $(call BuildPackage,pmacctd-mysql))
205 $(eval $(call BuildPackage,pmacctd-pgsql))
206 $(eval $(call BuildPackage,pmacctd-sqlite))
207 $(eval $(call BuildPackage,pmacct-client))