packages/pmacct: use new service functions
[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:=3
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 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
21
22 PKG_CONFIG_DEPENDS:= \
23         CONFIG_IPV6 \
24
25 include $(INCLUDE_DIR)/package.mk
26
27 define Package/pmacct/Default
28   SECTION:=admin
29   CATEGORY:=Administration
30   SUBMENU:=Pmacct suite
31   URL:=http://www.pmacct.net/
32 endef
33
34 define Package/pmacct-client
35   $(call Package/pmacct/Default)
36   TITLE:=Command-line client to gather data from the IMT plugin
37   VARIANT:=basic
38 endef
39
40 define Package/nfacctd/Default
41   $(call Package/pmacct/Default)
42   TITLE:=NetFlow accounting daemon
43 endef
44
45 define Package/pmacctd/Default
46   $(call Package/pmacct/Default)
47   DEPENDS+= +libpcap
48   TITLE:=IP pcap-based accounting daemon
49 endef
50
51 define Package/sfacctd/Default
52   $(call Package/pmacct/Default)
53   DEPENDS+= +libpcap
54   TITLE:=sFlow accounting daemon
55 endef
56
57 define Package/uacctd/Default
58   $(call Package/pmacct/Default)
59   DEPENDS+= +iptables-mod-ulog
60   TITLE:=ulog accounting daemon
61 endef
62
63
64 CONFIGURE_ARGS+= \
65         $(call autoconf_bool,CONFIG_IPV6,ipv6) \
66         --with-pcap-includes="$(STAGING_DIR)/usr/include" \
67         --with-pcap-libs="$(STAGING_DIR)/usr/lib" \
68         --enable-ulog \
69
70 ifeq ($(BUILD_VARIANT),basic)
71
72   CONFIGURE_ARGS += \
73         --disable-mysql \
74         --disable-pgsql \
75         --disable-sqlite3 \
76
77 endif
78
79 ifeq ($(BUILD_VARIANT),mysql)
80
81   CONFIGURE_ARGS += \
82         --enable-mysql \
83         --with-mysql-includes="$(STAGING_DIR)/usr/include" \
84         --with-mysql-libs="$(STAGING_DIR)/usr/lib/mysql" \
85         --disable-pgsql \
86         --disable-sqlite3 \
87
88   CONFIGURE_VARS+= \
89         LIBS="-lz" \
90
91 endif
92
93 ifeq ($(BUILD_VARIANT),pgsql)
94
95   CONFIGURE_ARGS += \
96         --disable-mysql \
97         --enable-pgsql \
98         --with-pgsql-includes="$(STAGING_DIR)/usr/include" \
99         --with-pgsql-libs="$(STAGING_DIR)/usr/lib" \
100         --disable-sqlite3 \
101
102 endif
103
104 ifeq ($(BUILD_VARIANT),sqlite)
105
106   CONFIGURE_ARGS += \
107         --disable-mysql \
108         --disable-pgsql \
109         --enable-sqlite3 \
110         --with-sqlite3-includes="$(STAGING_DIR)/usr/include" \
111         --with-sqlite3-libs="$(STAGING_DIR)/usr/lib" \
112
113 endif
114
115
116 define Build/Compile
117         $(MAKE) -C $(PKG_BUILD_DIR) \
118                 DESTDIR="$(PKG_INSTALL_DIR)" \
119                 all install
120 endef
121
122
123 define Package/pmacct-client/install
124         $(INSTALL_DIR) $(1)/usr/sbin
125         $(CP) $(PKG_BUILD_DIR)/src/pmacct $(1)/usr/sbin/
126 endef
127
128
129 # $(1): build variant {basic,mysql,pgsql,sqlite}
130 # $(2): package name prefix {nfacctd,pmacctd,sfacctd,uacctd}
131 # $(3): package name suffix {,-mysql,-pgsql,-sqlite}
132 # $(4): additional title (with MySQL support, ...)
133 # $(5): additional dependencies (+libmysqlclient, ...)
134
135 define BuildPackage/Template
136
137   define Package/$(2)$(3)
138     $(call Package/$(2)/Default)
139     DEPENDS+= $(5)
140     TITLE+= $(4)
141     VARIANT:=$(1)
142   endef
143
144   define Package/$(2)$(3)/conffiles
145     /etc/default/$(2)
146     /etc/$(2).conf
147   endef
148
149   define Package/$(2)$(3)/install
150         $(INSTALL_DIR) $$(1)/usr/sbin
151         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/$(2) $$(1)/usr/sbin/
152         $(INSTALL_DIR) $$(1)/etc
153         $(INSTALL_DATA) ./files/$(2).conf $$(1)/etc/
154         $(INSTALL_DIR) $$(1)/etc/default
155         $(INSTALL_DATA) ./files/$(2).default $$(1)/etc/default/$(2)
156         $(INSTALL_DIR) $$(1)/etc/init.d
157         $(INSTALL_BIN) ./files/$(2).init $$(1)/etc/init.d/$(2)
158   endef
159
160   $$(eval $$(call BuildPackage,$(2)$(3)))
161
162 endef
163
164 $(eval $(call BuildPackage,pmacct-client))
165
166 $(eval $(call BuildPackage/Template,basic,nfacctd,,,))
167 $(eval $(call BuildPackage/Template,basic,pmacctd,,,))
168 $(eval $(call BuildPackage/Template,basic,sfacctd,,,))
169 $(eval $(call BuildPackage/Template,basic,uacctd,,,))
170
171 $(eval $(call BuildPackage/Template,mysql,nfacctd,-mysql,with MySQL support,+libmysqlclient))
172 $(eval $(call BuildPackage/Template,mysql,pmacctd,-mysql,with MySQL support,+libmysqlclient))
173 $(eval $(call BuildPackage/Template,mysql,sfacctd,-mysql,with MySQL support,+libmysqlclient))
174 $(eval $(call BuildPackage/Template,mysql,uacctd,-mysql,with MySQL support,+libmysqlclient))
175
176 $(eval $(call BuildPackage/Template,pgsql,nfacctd,-pgsql,with PostgreSQL support,+libpq))
177 $(eval $(call BuildPackage/Template,pgsql,pmacctd,-pgsql,with PostgreSQL support,+libpq))
178 $(eval $(call BuildPackage/Template,pgsql,sfacctd,-pgsql,with PostgreSQL support,+libpq))
179 $(eval $(call BuildPackage/Template,pgsql,uacctd,-pgsql,with PostgreSQL support,+libpq))
180
181 $(eval $(call BuildPackage/Template,sqlite,nfacctd,-sqlite,with SQLite support,+libsqlite3))
182 $(eval $(call BuildPackage/Template,sqlite,pmacctd,-sqlite,with SQLite support,+libsqlite3))
183 $(eval $(call BuildPackage/Template,sqlite,sfacctd,-sqlite,with SQLite support,+libsqlite3))
184 $(eval $(call BuildPackage/Template,sqlite,uacctd,-sqlite,with SQLite support,+libsqlite3))