dcc64ee0ca6f58d9ea6fc2a3ca65fe9ec7a105e2
[packages.git] / admin / pmacct / Makefile
1 #
2 # Copyright (C) 2006-2011 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=pmacct
11 PKG_VERSION:=0.12.5
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=http://www.pmacct.net/
16 PKG_MD5SUM:=3d10f9301a17f034a0f221490a99a5d0
17
18 PKG_BUILD_DEPENDS:=libpcap
19
20 include $(INCLUDE_DIR)/package.mk
21
22 define Package/pmacct/Default
23   SECTION:=admin
24   CATEGORY:=Administration
25   SUBMENU:=Pmacct suite
26   URL:=http://www.pmacct.net/
27 endef
28
29 define Package/nfacctd/Default
30   $(call Package/pmacct/Default)
31   TITLE:=NetFlow accounting daemon
32 endef
33
34 define Package/nfacctd
35   $(call Package/nfacctd/Default)
36 endef
37
38 define Package/nfacctd-mysql
39   $(call Package/nfacctd/Default)
40   TITLE+= with MySQL support
41   DEPENDS+= +libmysqlclient
42 endef
43
44 define Package/nfacctd-pgsql
45   $(call Package/nfacctd/Default)
46   TITLE+= with PostreSQL support
47   DEPENDS+= +libpq
48 endef
49
50 define Package/nfacctd-sqlite
51   $(call Package/nfacctd/Default)
52   TITLE+= with SQLite support
53   DEPENDS+= +libsqlite3
54 endef
55
56 define Package/pmacctd/Default
57   $(call Package/pmacct/Default)
58   DEPENDS+= +libpcap
59   TITLE:=IP pcap-based accounting daemon
60 endef
61
62 define Package/pmacctd
63   $(call Package/pmacctd/Default)
64 endef
65
66 define Package/pmacctd-mysql
67   $(call Package/pmacctd/Default)
68   TITLE+= with MySQL support
69   DEPENDS+= +libmysqlclient
70 endef
71
72 define Package/pmacctd-pgsql
73   $(call Package/pmacctd/Default)
74   TITLE+= with PostreSQL support
75   DEPENDS+= +libpq
76 endef
77
78 define Package/pmacctd-sqlite
79   $(call Package/pmacctd/Default)
80   TITLE+= with SQLite support
81   DEPENDS+= +libsqlite3
82 endef
83
84 define Package/uacctd/Default
85   $(call Package/pmacct/Default)
86   DEPENDS+= +iptables-mod-ulog
87   TITLE:=ulog accounting daemon
88 endef
89
90 define Package/uacctd
91   $(call Package/pmacctd/Default)
92 endef
93
94 define Package/uacctd-mysql
95   $(call Package/pmacctd/Default)
96   TITLE+= with MySQL support
97   DEPENDS+= +libmysqlclient
98 endef
99
100 define Package/uacctd-pgsql
101   $(call Package/pmacctd/Default)
102   TITLE+= with PostreSQL support
103   DEPENDS+= +libpq
104 endef
105
106 define Package/uacctd-sqlite
107   $(call Package/pmacctd/Default)
108   TITLE+= with SQLite support
109   DEPENDS+= +libsqlite3
110 endef
111
112 define Package/pmacct-client
113   $(call Package/pmacct/Default)
114   TITLE:=Command-line client to gather data from the IMT plugin
115 endef
116
117 define Compile/Template
118
119 $(PKG_BUILD_DIR)/nfacctd$(1) $(PKG_BUILD_DIR)/pmacctd$(1) $(PKG_BUILD_DIR)/uacctd$(1): $(STAMP_CONFIGURED)
120         -$(MAKE) -C $(PKG_BUILD_DIR) distclean
121         $(call Build/Configure/Default, \
122                 --with-pcap-includes="$(STAGING_DIR)/usr/include" \
123                 --with-pcap-libs="$(STAGING_DIR)/usr/lib" \
124                 --enable-ulog \
125                 $(2) \
126                 ,\
127                 LIBS="-lz" \
128                 ,,\
129         );
130         $(MAKE) -C $(PKG_BUILD_DIR) \
131                 all
132         mv -f $(PKG_BUILD_DIR)/src/nfacctd $(PKG_BUILD_DIR)/nfacctd$(1)
133         mv -f $(PKG_BUILD_DIR)/src/pmacctd $(PKG_BUILD_DIR)/pmacctd$(1)
134         mv -f $(PKG_BUILD_DIR)/src/uacctd $(PKG_BUILD_DIR)/uacctd$(1)
135
136 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/nfacctd$(1) $(PKG_BUILD_DIR)/pmacctd$(1) $(PKG_BUILD_DIR)/uacctd$(1)
137
138 endef
139
140
141 define Install/Template
142
143 define Package/$(1)$(2)/conffiles
144 /etc/default/$(1)
145 /etc/$(1).conf
146 endef
147
148 define Package/$(1)$(2)/install
149         $(INSTALL_DIR) $$(1)/usr/sbin
150         $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(1)$(2) $$(1)/usr/sbin/$(1)
151         $(INSTALL_DIR) $$(1)/etc
152         $(INSTALL_DATA) ./files/$(1).conf $$(1)/etc/
153         $(INSTALL_DIR) $$(1)/etc/default
154         $(INSTALL_DATA) ./files/$(1).default $$(1)/etc/default/$(1)
155         $(INSTALL_DIR) $$(1)/etc/init.d
156         $(INSTALL_BIN) ./files/$(1).init $$(1)/etc/init.d/$(1)
157 endef
158
159 endef
160
161 ifneq ($(SDK)$(CONFIG_PACKAGE_nfacctd)$(CONFIG_PACKAGE_pmacctd)$(CONFIG_PACKAGE_uacctd),)
162   define Compile/pmacct/basic
163     $(call Compile/Template,, \
164         --disable-mysql \
165         --disable-pgsql \
166         --disable-sqlite3 \
167     )
168     $(call Install/Template,nfacctd,)
169     $(call Install/Template,pmacctd,)
170         $(call Install/Template,uacctd,)
171   endef
172 endif
173 $(eval $(Compile/pmacct/basic))
174
175 ifneq ($(SDK)$(CONFIG_PACKAGE_nfacctd-mysql)$(CONFIG_PACKAGE_pmacctd-mysql)$(CONFIG_PACKAGE_uacctd-mysql),)
176   define Compile/pmacct/mysql
177     $(call Compile/Template,-mysql, \
178         --enable-mysql \
179         --with-mysql-includes="$(STAGING_DIR)/usr/include" \
180         --with-mysql-libs="$(STAGING_DIR)/usr/lib/mysql" \
181     )
182     $(call Install/Template,nfacctd,-mysql)
183     $(call Install/Template,pmacctd,-mysql)
184         $(call Install/Template,uacctd,-mysql)
185   endef
186 endif
187 $(eval $(Compile/pmacct/mysql))
188
189 ifneq ($(SDK)$(CONFIG_PACKAGE_nfacctd-pgsql)$(CONFIG_PACKAGE_pmacctd-pgsql)$(CONFIG_PACKAGE_uacctd-pgsql),)
190   define Compile/pmacct/pgsql
191     $(call Compile/Template,-pgsql, \
192         --enable-pgsql \
193         --with-pgsql-includes="$(STAGING_DIR)/usr/include" \
194         --with-pgsql-libs="$(STAGING_DIR)/usr/lib" \
195     )
196     $(call Install/Template,nfacctd,-pgsql)
197     $(call Install/Template,pmacctd,-pgsql)
198         $(call Install/Template,uacctd,-pgsql)
199   endef
200 endif
201 $(eval $(Compile/pmacct/pgsql))
202
203 ifneq ($(SDK)$(CONFIG_PACKAGE_nfacctd-sqlite)$(CONFIG_PACKAGE_pmacctd-sqlite)$(CONFIG_PACKAGE_uacctd-sqlite),)
204   define Compile/pmacct/sqlite
205     $(call Compile/Template,-sqlite, \
206         --enable-sqlite3 \
207         --with-sqlite3-includes="$(STAGING_DIR)/usr/include" \
208         --with-sqlite3-libs="$(STAGING_DIR)/usr/lib" \
209     )
210     $(call Install/Template,nfacctd,-sqlite)
211     $(call Install/Template,pmacctd,-sqlite)
212         $(call Install/Template,uacctd,-sqlite)
213   endef
214 endif
215 $(eval $(Compile/pmacct/sqlite))
216
217 define Build/Configure
218 endef
219
220 define Build/Compile
221 endef
222
223 define Package/pmacct-client/install
224         $(INSTALL_DIR) $(1)/usr/sbin
225         $(CP) $(PKG_BUILD_DIR)/src/pmacct $(1)/usr/sbin/
226 endef
227
228 $(eval $(call BuildPackage,nfacctd))
229 $(eval $(call BuildPackage,nfacctd-mysql))
230 $(eval $(call BuildPackage,nfacctd-pgsql))
231 $(eval $(call BuildPackage,nfacctd-sqlite))
232 $(eval $(call BuildPackage,pmacctd))
233 $(eval $(call BuildPackage,pmacctd-mysql))
234 $(eval $(call BuildPackage,pmacctd-pgsql))
235 $(eval $(call BuildPackage,pmacctd-sqlite))
236 $(eval $(call BuildPackage,pmacct-client))
237 $(eval $(call BuildPackage,uacctd))
238 $(eval $(call BuildPackage,uacctd-mysql))
239 $(eval $(call BuildPackage,uacctd-pgsql))
240 $(eval $(call BuildPackage,uacctd-sqlite))
241