remove libusb-legacy and point its users at libusb-compat
[packages.git] / utils / nut / Makefile
1 #
2 # Copyright © 2006-2012 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.6.5
12 PKG_RELEASE:=2
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.6/
16 PKG_MD5SUM:=e6eac4fa04baff0d0a827d64efe81a7e
17
18 PKG_BUILD_DEPENDS:=libusb-compat libnetsnmp
19 PKG_FIXUP:=autoreconf
20 PKG_INSTALL:=1
21
22 PKG_BUILD_PARALLEL:=1
23
24 define Package/nut/Default
25   URL:=http://www.networkupstools.org/
26   TITLE:= Network UPS Tools
27   DEPENDS:=@USB_SUPPORT +libnetsnmp +libpthread
28   SECTION:=utils
29   CATEGORY:=Utilities
30 endef
31
32 define Package/nut/description
33   Network UPS Tools (NUT) is a client/server monitoring system that
34   allows computers to share uninterruptible power supply (UPS) and
35   power distribution unit (PDU) hardware. Clients access the hardware
36   through the server, and are notified whenever the power status
37   changes.
38 endef
39
40 define Package/nut
41 $(call Package/nut/Default)
42   MENU:=1
43 #  TITLE+= (common)
44 endef
45
46 define Package/nut-server
47 $(call Package/nut/Default)
48   TITLE+= (server)
49   DEPENDS+= nut
50 endef
51
52 define Package/nut-client
53 $(call Package/nut/Default)
54   TITLE+= (client)
55   DEPENDS+= nut
56 endef
57
58 define Package/nut-logger
59 $(call Package/nut/Default)
60   TITLE+= (logger)
61   DEPENDS+= nut
62 endef
63
64 define Package/nut-monitor
65 $(call Package/nut/Default)
66   TITLE+= (monitor)
67   DEPENDS+= nut
68 endef
69
70 define Package/nut/install
71         $(INSTALL_DIR) $(1)/usr/lib
72         $(INSTALL_DIR) $(1)/etc/nut
73         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libupsclient.so* $(1)/usr/lib/
74         $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/nut.conf.sample $(1)/etc/nut/nut.conf
75         ln -sf /var/run/ups.conf $(1)/etc/nut/ups.conf
76 endef
77
78 define Build/InstallDev
79         $(INSTALL_DIR) $(1)/usr/include
80         $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include
81         $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
82         $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig
83         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib* $(1)/usr/lib
84 endef
85
86 define Package/nut/conffiles
87 /etc/nut/nut.conf
88 endef
89
90 define Package/nut-client/install
91         $(INSTALL_DIR) $(1)/usr/bin
92         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upsc $(1)/usr/bin
93         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upsrw $(1)/usr/bin
94         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upscmd $(1)/usr/bin
95 endef
96
97 define Package/nut-server/install
98         $(INSTALL_DIR) $(1)/etc/nut
99         $(INSTALL_DIR) $(1)/usr/sbin
100         $(INSTALL_DIR) $(1)/lib/nut
101         $(INSTALL_DIR) $(1)/usr/share/nut
102         $(INSTALL_DIR) $(1)/etc/init.d
103         $(INSTALL_BIN) ./files/ups.init $(1)/etc/init.d/ups
104         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin
105         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/nut/upsdrvctl $(1)/lib/nut
106         $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.conf.sample $(1)/etc/nut/upsd.conf
107         ln -sf /var/run/upsd.users $(1)/etc/nut/upsd.users
108         $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/nut/cmdvartab $(1)/usr/share/nut/cmdvartab
109         $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/nut/driver.list $(1)/usr/share/nut/driver.list
110 endef
111
112 define Package/nut-server/conffiles
113 /etc/nut/upsd.conf
114 endef
115
116 define Package/nut-logger/install
117         $(INSTALL_DIR) $(1)/usr/bin
118         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upslog $(1)/usr/bin
119 endef
120
121 define Package/nut-monitor/install
122         $(INSTALL_DIR) $(1)/usr/sbin
123         $(INSTALL_DIR) $(1)/etc/nut
124         $(INSTALL_DIR) $(1)/etc/init.d
125         $(INSTALL_BIN) ./files/upsmon.init $(1)/etc/init.d/upsmon
126         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin
127         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upssched $(1)/usr/sbin
128         ln -sf /var/run/upsmon.conf $(1)/etc/nut/upsmon.conf
129         $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upssched.conf.sample $(1)/etc/nut/upssched.conf
130 endef
131
132 define Package/nut-monitor/conffiles
133 /etc/nut/upssched.conf
134 endef
135
136 define DriverPackage
137   define Package/nut-driver-$(1)
138     $(call Package/nut/Default)
139     TITLE += ($(1) driver)
140     DEPENDS += nut nut-server
141     ifeq ($(1),$(filter $(1),$(USB_LIBUSB_DRIVERLIST)))
142       DEPENDS+=libusb
143     endif
144     ifeq ($(1),$(filter $(1),$(SNMP_DRIVERLIST)))
145       DEPENDS+=libnetsnmp
146     endif
147   endef
148   # Deliberately empty (well, some spaces) in order to trigger a build
149   # failure. It should be overridden by the list below, and when updating
150   # to a new version of nut we will need to provide descriptions for any
151   # new drivers.
152   define Package/nut-driver-$(1)/description
153   
154   endef
155   define Package/nut-driver-$(1)/install
156         $(INSTALL_DIR) $$(1)/lib/nut/
157         $(INSTALL_BIN) $$(PKG_INSTALL_DIR)/lib/nut/$(1) $$(1)/lib/nut/
158     ifeq ($(1),clone)
159         # Bundle clone and clone-outlet together
160         $(INSTALL_BIN) $$(PKG_INSTALL_DIR)/lib/nut/$(1)-outlet $$(1)/lib/nut/
161     endif
162   endef
163 endef
164
165 # These lists are lifted *directly* from drivers/Makefile.am in the nut
166 # source tree. This it to make it simpler to keep in sync when updating
167 # to a newer version of nut. Do not edit this manually.
168 #
169 # DO NOT EDIT (except to update with a fresh cut/paste)!
170 SERIAL_DRIVERLIST = bcmxcp belkin belkinunv bestfcom    \
171  bestfortress bestuferrups bestups dummy-ups etapro everups     \
172  gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys  \
173  oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino        \
174  safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \
175  blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old
176 SNMP_DRIVERLIST = snmp-ups
177 USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \
178  blazer_usb richcomm_usb
179 # END: DO NOT EDIT!
180
181 NUT_DRIVERS := $(filter-out skel clone-outlet,$(SERIAL_DRIVERLIST)) \
182         $(USB_LIBUSB_DRIVERLIST) $(SNMP_DRIVERLIST)
183
184 $(foreach d,$(NUT_DRIVERS),$(eval $(call DriverPackage,$(d))))
185
186 define DriverDescription
187   define Package/nut-driver-$(1)/description
188     $(2)
189   endef
190 endef
191
192 $(eval $(call DriverDescription,apcsmart,\
193         Driver for American Power Conversion Smart Protocol UPS equipment))
194 $(eval $(call DriverDescription,apcsmart-old,\
195         Driver for American Power Conversion Smart Protocol UPS equipment))
196 $(eval $(call DriverDescription,bcmxcp,\
197         Driver for UPSes supporting the serial BCM/XCP protocol))
198 $(eval $(call DriverDescription,bcmxcp_usb,\
199         Experimental driver for UPSes supporting the BCM/XCP protocol over USB))
200 $(eval $(call DriverDescription,belkin,\
201         Driver for Belkin serial UPS equipment))
202 $(eval $(call DriverDescription,belkinunv,\
203         Driver for Belkin "Universal UPS" and compatible))
204 $(eval $(call DriverDescription,bestfcom,\
205         Driver for Best Power Fortress/Ferrups))
206 $(eval $(call DriverDescription,bestfortress,\
207         Driver for old Best Fortress UPS equipment))
208 $(eval $(call DriverDescription,bestuferrups,\
209         Driver for Best Power Micro-Ferrups))
210 $(eval $(call DriverDescription,bestups,\
211         Driver for Best Power / SOLA (Phoenixtec protocol) UPS equipment))
212 $(eval $(call DriverDescription,blazer_ser,\
213         Driver for Megatec/Q1 protocol serial))
214 $(eval $(call DriverDescription,blazer_usb,\
215         Driver for Megatec/Q1 protocol USB))
216 $(eval $(call DriverDescription,clone,\
217         UPS driver clone))
218 $(eval $(call DriverDescription,dummy-ups,\
219         Driver for multi-purpose UPS emulation))
220 $(eval $(call DriverDescription,etapro,\
221         Driver for ETA UPS equipment))
222 $(eval $(call DriverDescription,everups,\
223         Driver for Ever UPS models))
224 $(eval $(call DriverDescription,gamatronic,\
225         Driver for Gamatronic UPS equipment))
226 $(eval $(call DriverDescription,genericups,\
227         Driver for contact-closure UPS equipment))
228 $(eval $(call DriverDescription,isbmex,\
229         Driver for ISBMEX UPS equipment))
230 $(eval $(call DriverDescription,ivtscd,\
231         driver for the IVT Solar Controller Device))
232 $(eval $(call DriverDescription,liebert,\
233         Driver for Liebert contact-closure UPS equipment))
234 $(eval $(call DriverDescription,liebert-esp2,\
235         Driver for Liebert UPS using the ESP-II protocol))
236 $(eval $(call DriverDescription,masterguard,\
237         Driver for Masterguard UPS equipment))
238 $(eval $(call DriverDescription,metasys,\
239         Driver for Meta System UPS equipment))
240 $(eval $(call DriverDescription,mge-shut,\
241         Driver for SHUT Protocol UPS equipment))
242 $(eval $(call DriverDescription,mge-utalk,\
243         Driver for MGE UPS SYSTEMS UTalk protocol equipment))
244 $(eval $(call DriverDescription,microdowell,\
245         Driver for Microdowell Enterprise UPS series))
246 $(eval $(call DriverDescription,oldmge-shut,\
247         Driver for SHUT Protocol UPS equipment))
248 $(eval $(call DriverDescription,oneac,\
249         Driver for Oneac UPS equipment))
250 $(eval $(call DriverDescription,optiups,\
251         Driver for Opti-UPS (Viewsonice) UPS and Zinto D (ONLINE-USV) equipment))
252 $(eval $(call DriverDescription,powercom,\
253         UPS driver for Powercom/Trust/Advice UPS equipment))
254 $(eval $(call DriverDescription,powerpanel,\
255         Driver for PowerPanel Plus compatible UPS equipment))
256 $(eval $(call DriverDescription,rhino,\
257         Driver for Brazilian Microsol RHINO UPS equipment))
258 $(eval $(call DriverDescription,richcomm_usb,\
259         Driver UPS equipment using Richcomm dry-contact to USB solution))
260 $(eval $(call DriverDescription,safenet,\
261         Driver for SafeNet compatible UPS equipment))
262 $(eval $(call DriverDescription,solis,\
263         Driver for Brazilian Microsol SOLIS UPS equipment))
264 $(eval $(call DriverDescription,tripplite,\
265         Driver for Tripp-Lite SmartPro UPS equipment))
266 $(eval $(call DriverDescription,tripplitesu,\
267         Driver for Tripp-Lite SmartOnline (SU) UPS equipment))
268 $(eval $(call DriverDescription,tripplite_usb,\
269         Driver for older Tripp Lite USB UPSes (not PDC HID)))
270 $(eval $(call DriverDescription,upscode2,\
271         Driver for UPScode II compatible UPS equipment))
272 $(eval $(call DriverDescription,usbhid-ups,\
273         Driver for USB/HID UPS equipment))
274 $(eval $(call DriverDescription,victronups,\
275         Driver for IMV/Victron UPS unit Match, Match Lite, NetUps))
276 $(eval $(call DriverDescription,snmp-ups,\
277         Multi-MIB Driver for SNMP UPS equipment))
278
279 include $(INCLUDE_DIR)/package.mk
280
281 CONFIGURE_ARGS += \
282   --without-ssl \
283   --with-pidpath=/var/run \
284   --with-statepath=/var/run \
285   --with-altpidpath=/var/run \
286   --sysconfdir=/etc/nut \
287   --with-drvpath=/lib/nut \
288   --datadir=/usr/share/nut \
289   --with-user=root \
290   --with-group=root \
291   --with-usb \
292   --with-snmp \
293   --without-libltdl \
294   --with-dev
295
296
297 $(eval $(call BuildPackage,nut))
298 $(eval $(call BuildPackage,nut-client))
299 $(eval $(call BuildPackage,nut-server))
300 $(eval $(call BuildPackage,nut-monitor))
301 $(eval $(call BuildPackage,nut-logger))
302 $(foreach d,$(NUT_DRIVERS),$(eval $(call BuildPackage,nut-driver-$(d))))