Merge pull request #2126 from lynxis/libmicrohttpd
[feed/packages.git] / net / nut / Makefile
1 #
2 # Copyright (C) 2006-2015 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:=nut
11 PKG_VERSION:=2.7.4
12 PKG_RELEASE:=2
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/
16 PKG_MD5SUM:=3ba53656933d7471f95140b32a5b8d5c
17 PKG_MAINTAINER:=Martin Rowe <martin.p.rowe@gmail.com>
18 PKG_LICENSE:=GPL-2.0
19 PKG_LICENSE_FILES:=LICENSE-GPL2
20
21 PKG_BUILD_DIR:=$(BUILD_DIR)/nut-$(PKG_VERSION)
22 PKG_INSTALL:=1
23
24 PKG_CONFIG_DEPENDS:= \
25 CONFIG_NUT_CLIENTS_UPSC \
26 CONFIG_NUT_CLIENTS_UPSCMD \
27 CONFIG_NUT_CLIENTS_UPSLOG \
28 CONFIG_NUT_CLIENTS_UPSMON \
29 CONFIG_NUT_CLIENTS_UPSRW \
30 CONFIG_NUT_CLIENTS_UPSSCHED \
31 CONFIG_NUT_DRIVER_SNMP \
32 CONFIG_NUT_DRIVER_USB \
33 CONFIG_NUT_SERVER \
34 CONFIG_NUT_SSL
35
36 include $(INCLUDE_DIR)/package.mk
37
38 define Package/nut/Default
39 SECTION:=net
40 CATEGORY:=Network
41 URL:=http://www.networkupstools.org/
42 DEPENDS:=nut
43 endef
44
45 define Package/nut/description
46 Network UPS Tools (NUT) is a client/server monitoring system that
47 allows computers to share uninterruptible power supply (UPS) and
48 power distribution unit (PDU) hardware. Clients access the hardware
49 through the server, and are notified whenever the power status
50 changes.
51 endef
52
53 define Package/nut
54 $(call Package/nut/Default)
55 TITLE:=Network UPS Tools
56 DEPENDS:= \
57 +libpthread \
58 +NUT_DRIVER_SNMP:libnetsnmp \
59 +NUT_DRIVER_USB:libusb-compat \
60 +NUT_SSL:libopenssl
61 MENU:=1
62 endef
63
64 define Package/nut/config
65 source "$(SOURCE)/Config.in"
66 endef
67
68 define Package/nut/conffiles
69 /etc/nut/nut.conf
70 $(if $(CONFIG_NUT_CLIENTS_UPSMON),/etc/nut/upsmon.conf)
71 $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),/etc/nut/upssched.conf)
72 $(if $(CONFIG_NUT_SERVER),/etc/nut/ups.conf)
73 $(if $(CONFIG_NUT_SERVER),/etc/nut/upsd.conf)
74 $(if $(CONFIG_NUT_SERVER),/etc/nut/upsd.users)
75 endef
76
77 define Package/nut/install
78 $(INSTALL_DIR) $(1)/etc/nut
79 $(INSTALL_DIR) $(1)/usr/bin
80 $(INSTALL_DIR) $(1)/usr/lib
81 $(INSTALL_DIR) $(1)/usr/sbin
82 $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/nut.conf.sample $(1)/etc/nut/nut.conf
83 $(if $(or $(CONFIG_NUT_CLIENTS_UPSC),\
84 $(CONFIG_NUT_CLIENTS_UPSCMD),\
85 $(CONFIG_NUT_CLIENTS_LOG),\
86 $(CONFIG_NUT_CLIENTS_UPSRW),\
87 $(CONFIG_NUT_CLIENTS_UPSMON),\
88 $(CONFIG_NUT_CLIENTS_UPSSCHED)),$(CP) $(PKG_INSTALL_DIR)/usr/lib/libupsclient.so* $(1)/usr/lib/)
89 $(if $(or $(CONFIG_NUT_SERVER),\
90 $(CONFIG_NUT_CLIENTS_UPSMON)),$(INSTALL_DIR) $(1)/etc/init.d)
91 $(if $(CONFIG_NUT_SERVER),$(INSTALL_DIR) $(1)/lib/nut)
92 $(if $(CONFIG_NUT_SERVER),$(INSTALL_DIR) $(1)/usr/share/nut)
93 $(if $(CONFIG_NUT_SERVER),$(CP) ./files/nut-server.init $(1)/etc/init.d/)
94 $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin)
95 $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsdrvctl $(1)/usr/sbin)
96 $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/share/nut/cmdvartab $(1)/usr/share/nut/)
97 $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/share/nut/driver.list $(1)/usr/share/nut/)
98 $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/ups.conf.sample $(1)/etc/nut/ups.conf)
99 $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.conf.sample $(1)/etc/nut/upsd.conf)
100 $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.users.sample $(1)/etc/nut/upsd.users)
101 $(if $(CONFIG_NUT_CLIENTS_UPSC),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upsc $(1)/usr/bin/)
102 $(if $(CONFIG_NUT_CLIENTS_UPSCMD),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upscmd $(1)/usr/bin/)
103 $(if $(CONFIG_NUT_CLIENTS_UPSLOG),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upslog $(1)/usr/bin/)
104 $(if $(CONFIG_NUT_CLIENTS_UPSRW),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upsrw $(1)/usr/bin/)
105 $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(CP) ./files/nut-monitor.init $(1)/etc/init.d/)
106 $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin/)
107 $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsmon.conf.sample $(1)/etc/nut/upsmon.conf)
108 $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upssched-cmd $(1)/usr/bin/)
109 $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upssched $(1)/usr/sbin/)
110 $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upssched.conf.sample $(1)/etc/nut/upssched.conf)
111 endef
112
113 define Package/nut-web-cgi
114 $(call Package/nut/Default)
115 TITLE+= Web CGI interface
116 DEPENDS+=+libgd
117 endef
118
119 define Package/nut-web-cgi/description
120 The CGI programs are clients that run through your web server.
121 They allow you to see UPS status and perform certain administrative
122 commands from any web browser. Javascript and cookies are not required.
123 endef
124
125 define Package/nut-web-cgi/conffiles
126 /etc/nut/hosts.conf
127 /etc/nut/upsset.conf
128 /etc/nut/upsstats.html
129 /etc/nut/upsstats-single.html
130 endef
131
132 define Package/nut-web-cgi/install
133 $(INSTALL_DIR) $(1)/etc/nut
134 $(INSTALL_DIR) $(1)/usr/share/www/cgi-bin
135 $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/hosts.conf.sample $(1)/etc/nut/hosts.conf
136 $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsset.conf.sample $(1)/etc/nut/upsset.conf
137 $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats.html.sample $(1)/etc/nut/upsstats.html
138 $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats-single.html.sample $(1)/etc/nut/upsstats-single.html
139 $(CP) $(PKG_INSTALL_DIR)/usr/share/www/nut $(1)/usr/share/www/
140 $(CP) $(PKG_INSTALL_DIR)/usr/share/www/cgi-bin/nut $(1)/usr/share/www/cgi-bin/
141 endef
142
143 define Package/nut-avahi-service
144 $(call Package/nut/Default)
145 TITLE+= (Avahi service)
146 DEPENDS+=+avahi-daemon
147 endef
148
149 define Package/nut-avahi-service/description
150 This package contains the service definition for announcing the
151 attached UPS via mDNS/DNS-SD.
152 endef
153
154 define Package/nut-avahi-service/conffiles
155 /etc/avahi/services/nut.service
156 endef
157
158 define Package/nut-avahi-service/install
159 $(INSTALL_DIR) $(1)/etc/avahi/services
160 $(INSTALL_CONF) ./files/nut.service $(1)/etc/avahi/services/
161 endef
162
163 # Dealing with all of the drivers is very repetitive, but the previous
164 # maintainer had a neat solution which just needed some tweaking.
165 define DriverPackage
166 define Package/nut-driver-$(2)
167 $(call Package/nut/Default)
168 TITLE:=$(2) (NUT $(1) driver)
169 $(if $(filter $(1),snmp),DEPENDS+= @NUT_DRIVER_SNMP)
170 $(if $(filter $(1),usb),DEPENDS+= @NUT_DRIVER_USB)
171 endef
172 # Deliberately empty description in order to trigger a build failure.
173 # It should be overridden by the list below, and when updating to a
174 # new version of nut we will need to provide descriptions for any new
175 # drivers.
176 define Package/nut-driver-$(2)/description
177
178 endef
179 define Package/nut-driver-$(2)/install
180 $(INSTALL_DIR) $$(1)/lib/nut
181 $(CP) $$(PKG_INSTALL_DIR)/lib/nut/$(2) $$(1)/lib/nut/
182 $(if $(filter $(2),clone),$(CP) $$(PKG_INSTALL_DIR)/lib/nut/$(2)-outlet $$(1)/lib/nut/)
183 endef
184 endef
185 define DriverDescription
186 define Package/nut-driver-$(2)/description
187 $(3)
188 endef
189 endef
190 # These lists are lifted *directly* from drivers/Makefile.am in the nut
191 # source tree. This it to make it simpler to keep in sync when updating
192 # to a newer version of nut. Do not edit this manually.
193 #
194 # DO NOT EDIT (except to update with a fresh cut/paste)!
195 SERIAL_DRIVERLIST = al175 bcmxcp belkin belkinunv bestfcom \
196 bestfortress bestuferrups bestups dummy-ups etapro everups \
197 gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \
198 oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino \
199 safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \
200 blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser \
201 nutdrv_qx
202 SNMP_DRIVERLIST = snmp-ups
203 USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \
204 blazer_usb richcomm_usb riello_usb \
205 nutdrv_atcl_usb \
206 nutdrv_qx
207 # END: DO NOT EDIT!
208 SERIAL_DRIVERLIST_IGNORE:=skel clone-outlet nutdrv_qx
209 # nutdrv_qx can be either USB or serial. Given most routers have USB
210 # instead of serial ports, and not wanting two identical packages with
211 # different names that conflict with each other, only the option for the
212 # driver with USB bindings is provided. If you really want to save that
213 # tiny bit of space and build it without USB support, remove nutdrv_qx
214 # from the previous line.
215
216 $(foreach d,$(filter-out $(SERIAL_DRIVERLIST_IGNORE),$(SERIAL_DRIVERLIST)),$(eval $(call DriverPackage,serial,$(d))))
217 $(foreach d,$(SNMP_DRIVERLIST),$(eval $(call DriverPackage,snmp,$(d))))
218 $(foreach d,$(USB_LIBUSB_DRIVERLIST),$(eval $(call DriverPackage,usb,$(d))))
219
220 $(eval $(call DriverDescription,serial,al175,\
221 Driver for Eltek UPS models with AL175 alarm module))
222 $(eval $(call DriverDescription,serial,bcmxcp,\
223 Driver for UPSes supporting the serial BCM/XCP protocol))
224 $(eval $(call DriverDescription,serial,belkin,\
225 Driver for Belkin serial UPS equipment))
226 $(eval $(call DriverDescription,serial,belkinunv,\
227 Driver for Belkin "Universal UPS" and compatible))
228 $(eval $(call DriverDescription,serial,bestfcom,\
229 Driver for Best Power Fortress/Ferrups))
230 $(eval $(call DriverDescription,serial,bestfortress,\
231 Driver for old Best Fortress UPS equipment))
232 $(eval $(call DriverDescription,serial,bestuferrups,\
233 Driver for Best Power Micro-Ferrups))
234 $(eval $(call DriverDescription,serial,bestups,\
235 Driver for Best Power / SOLA (Phoenixtec protocol) UPS equipment))
236 $(eval $(call DriverDescription,serial,dummy-ups,\
237 Driver for multi-purpose UPS emulation))
238 $(eval $(call DriverDescription,serial,etapro,\
239 Driver for ETA UPS equipment))
240 $(eval $(call DriverDescription,serial,everups,\
241 Driver for Ever UPS models))
242 $(eval $(call DriverDescription,serial,gamatronic,\
243 Driver for Gamatronic UPS equipment))
244 $(eval $(call DriverDescription,serial,genericups,\
245 Driver for contact-closure UPS equipment))
246 $(eval $(call DriverDescription,serial,isbmex,\
247 Driver for ISBMEX UPS equipment))
248 $(eval $(call DriverDescription,serial,liebert,\
249 Driver for Liebert contact-closure UPS equipment))
250 $(eval $(call DriverDescription,serial,liebert-esp2,\
251 Driver for Liebert UPS, using the ESP-II serial protocol))
252 $(eval $(call DriverDescription,serial,masterguard,\
253 Driver for Masterguard UPS equipment))
254 $(eval $(call DriverDescription,serial,metasys,\
255 Driver for Meta System UPS equipment))
256 $(eval $(call DriverDescription,serial,oldmge-shut,\
257 Driver for SHUT Protocol UPS equipment, deprecated, use mge-shut))
258 $(eval $(call DriverDescription,serial,mge-utalk,\
259 Driver for MGE UPS SYSTEMS UTalk protocol equipment))
260 $(eval $(call DriverDescription,serial,microdowell,\
261 Driver for Microdowell Enterprise UPS series))
262 $(eval $(call DriverDescription,serial,mge-shut,\
263 Driver for SHUT Protocol UPS equipment))
264 $(eval $(call DriverDescription,serial,oneac,\
265 Driver for Oneac UPS equipment))
266 $(eval $(call DriverDescription,serial,optiups,\
267 Driver for Opti-UPS (Viewsonic) UPS and Zinto D (ONLINE-USV) equipment))
268 $(eval $(call DriverDescription,serial,powercom,\
269 Driver for serial Powercom/Trust/Advice UPS equipment))
270 $(eval $(call DriverDescription,serial,rhino,\
271 Driver for Brazilian Microsol RHINO UPS equipment))
272 $(eval $(call DriverDescription,serial,safenet,\
273 Driver for SafeNet compatible UPS equipment))
274 $(eval $(call DriverDescription,serial,solis,\
275 Driver for Brazilian Microsol SOLIS UPS equipment))
276 $(eval $(call DriverDescription,serial,tripplite,\
277 Driver for Tripp-Lite SmartPro UPS equipment))
278 $(eval $(call DriverDescription,serial,tripplitesu,\
279 Driver for Tripp-Lite SmartOnline (SU) UPS equipment))
280 $(eval $(call DriverDescription,serial,upscode2,\
281 Driver for UPScode II compatible UPS equipment))
282 $(eval $(call DriverDescription,serial,victronups,\
283 Driver for IMV/Victron UPS unit Match, Match Lite, NetUps))
284 $(eval $(call DriverDescription,serial,powerpanel,\
285 Driver for PowerPanel Plus compatible UPS equipment))
286 $(eval $(call DriverDescription,serial,blazer_ser,\
287 Driver for Megatec/Q1 protocol serial based UPS equipment))
288 $(eval $(call DriverDescription,serial,clone,\
289 UPS driver clone))
290 $(eval $(call DriverDescription,serial,ivtscd,\
291 Driver for the IVT Solar Controller Device))
292 $(eval $(call DriverDescription,serial,apcsmart,\
293 Driver for American Power Conversion Smart Protocol UPS equipment))
294 $(eval $(call DriverDescription,serial,apcsmart-old,\
295 Driver for American Power Conversion Smart Protocol UPS equipment))
296 $(eval $(call DriverDescription,serial,apcupsd-ups,\
297 Driver for apcupsd client access))
298 $(eval $(call DriverDescription,serial,riello_ser,\
299 Driver for Riello UPS Protocol UPS equipment))
300 $(eval $(call DriverDescription,snmp,snmp-ups,\
301 Multi-MIB Driver for SNMP UPS equipment))
302 $(eval $(call DriverDescription,usb,usbhid-ups,\
303 Driver for USB/HID UPS equipment))
304 $(eval $(call DriverDescription,usb,bcmxcp_usb,\
305 Experimental driver for UPSes supporting the BCM/XCP protocol over USB))
306 $(eval $(call DriverDescription,usb,tripplite_usb,\
307 Driver for older Tripp Lite USB UPSes (not PDC HID)))
308 $(eval $(call DriverDescription,usb,blazer_usb,\
309 Driver for Megatec/Q1 protocol USB based UPS equipment))
310 $(eval $(call DriverDescription,usb,richcomm_usb,\
311 Driver for UPS equipment using Richcomm dry-contact to USB solution))
312 $(eval $(call DriverDescription,usb,riello_usb,\
313 Driver for Riello UPS Protocol UPS equipment via USB))
314 $(eval $(call DriverDescription,usb,nutdrv_atcl_usb,\
315 Driver for ATCL FOR UPS equipment))
316 $(eval $(call DriverDescription,usb,nutdrv_qx,\
317 Driver for Q* protocol serial and USB based UPS equipment))
318
319 CONFIGURE_ARGS += \
320 --sysconfdir=/etc/nut \
321 --datadir=/usr/share/nut \
322 --with-dev \
323 --$(if $(CONFIG_NUT_DRIVER_USB),with,without)-usb \
324 --without-avahi \
325 --$(if $(CONFIG_NUT_DRIVER_SNMP),with,without)-snmp \
326 --without-neon \
327 --without-powerman \
328 --without-ipmi \
329 --without-freeipmi \
330 --$(if $(CONFIG_NUT_SSL),with,without)-ssl $(if $(CONFIG_NUT_SSL),--with-openssl) \
331 --without-libltdl \
332 --$(if $(CONFIG_PACKAGE_nut-web-cgi),with,without)-cgi \
333 --with-statepath=/var/run \
334 --with-drvpath=/lib/nut \
335 --with-cgipath=/usr/share/www/cgi-bin/nut \
336 --with-htmlpath=/usr/share/www/nut \
337 --with-user=root \
338 --with-group=root
339
340 define Build/InstallDev
341 $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib/pkgconfig
342 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/
343 $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
344 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig/
345 endef
346
347 $(eval $(call BuildPackage,nut))
348 $(eval $(call BuildPackage,nut-web-cgi))
349 $(eval $(call BuildPackage,nut-avahi-service))
350 $(foreach d,$(filter-out $(SERIAL_DRIVERLIST_IGNORE),$(SERIAL_DRIVERLIST)),$(eval $(call BuildPackage,nut-driver-$(d))))
351 $(foreach d,$(SNMP_DRIVERLIST),$(eval $(call BuildPackage,nut-driver-$(d))))
352 $(foreach d,$(USB_LIBUSB_DRIVERLIST),$(eval $(call BuildPackage,nut-driver-$(d))))