UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / src / win32 / README.mingw32
blob5818a09ec2bbae321140e7cc7266583b5d352c4a
2 This file documents building the native Win32 apcupsd using the
3 MinGW cross compiler tools on a Linux (possibly other Unix)
4 system.  The Win32 build can co-exist in in the same directory at
5 the same time as a normal Linux build since all the binaries for
6 Win32 are kept in src/win32.
7    
9 The basic directory structure you need to have is:
10   apcupsd                    top level directory -- any name 
11     apcupsd-source           top level apcupsd source directory -- any name
12       src
13         win32                main directory where the Win32 FD is built.
14           compat             win32 emulation lib for Unix calls
16     dekpgs-win32             
17        pthreads              The POSIX pthreads library (third party)
18        libusb                The multi-platform USB library (third party)
20     cross-tools              Cross compliation tools (gcc, g++, mingw, ...)
22 depkgs-win32 is released in a separate .tar.gz file that contains the
23 source for the above mentioned libraries needed to build the
24 Win32 apcupsd.  It can be found in the Source Forge apcupsd project
25 release section (not yet).  Temporarily, you can find a copy of
26 this on:
28    www.sibbald.com/download/depkgs-win32-apcupsd.tar.gz
29    www.kroptech.com/~adk0212/apcupsd/depkgs-win32-apcupsd.tar.gz
31 It will detar into depkgs-win32.  Note, this version is pre-buit, so
32 you can skip the ./build-mingw32 described several steps below, unless
33 you want to be sure it works on your system.
35 cross-tools is a directory that you create. There is a script, described
36 below, that will download all the necessary files and build them. You need
37 only run that script once, unless we move to a new version of the tools.
39 Now, once you have the directory structure as defined above, you do
40 the following once:
42   cd apcupsd/apcupsd-source
43   ./configure (any standard set of config options the exact ones   
44                are not important).
45   cd src/win32
46   ./build-win32-cross-tools
48 The above only needs to be done once unless we change the cross-tools 
49 version.  In general, you can run the script multiple times with no
50 problem. For it to work, you must have a valid gcc compiler installed on
51 your system as well as wget and texinfo.  There may be other dependencies.
53 After building the cross-tools, you can proceed to build the depkgs-win32 
54 packages, which must use the cross-tools compiler.
56    cd
57    cd apcupsd/depkgs-win32
58    ./build-mingw32
60 The above only needs to be done once as well as long as the cross-tools or
61 depkgs-win32 versions do not change. As noted above, the above step
62 can be skipped if you dowload the package from www.sibbald.com...
64 Finally, to build the Win32 apcupsd, do the following:
66    cd apcupsd-source/src/win32
67    make -f Makefile.mingw32
69 This should compile a lot of files, and finally create apcupsd.exe,
70 apcaccess.exe, and pthreadGCE.dll.  You need the dll to run either 
71 apcupsd.exe or apcaccess.exe.
73 If you want to change the Makefile, simply edit Makefile.mingw32.in,
74 then in the top level directory, do:
76    make Makefiles
78 or do any ./configure command.
81 Items to be done:
82 - Use syslog from apcupsd lib/wincompat.c so that a dialog
83   box is used in place of syslog().
84 - Implement additional drivers (snmp)
85 - Ensure that calling scripts works -- definitely broken
86 - General testing
88 ============== Adam's tips ==============
89 Here is the configure I'm using for the 3.12.x releases:
91 ./configure \
92        --prefix=/apcupsd \
93        --sbindir=/apcupsd/bin \
94        --sysconfdir=/apcupsd/etc/apcupsd \
95        --with-pid-dir=/apcupsd/etc/apcupsd \
96        --mandir=/apcupsd \
97        --with-cgi-bin=/apcupsd/etc/apcupsd/cgi \
98        --enable-pthreads \
99        --enable-net \
100        --enable-snmp \
101        --enable-master-slave
103 For 3.13.x you'll want to remove the master-slave enable. Also, if you
104 want to build the SNMP driver as I do, you'll nee to build NET-SNMP
105 under cygwin as well. The configure line I use for that is:
107 ./configure \
108          --with-mib-modules="host agentx disman/event-mib examples/example" \
109          --with-out-mib-modules=host/hr_network \
110          --disable-agent --disable-applications
111 ====
113 Date: Mon, 13 Mar 2006 19:08:45 -0500
115 Adam Kropelin wrote:
116 > I just committed changes to configure that will build the generic usb
117 > driver on win32 under cygwin. There is no real magic to it; include
118 > "--enable-usb" in your configure options and everything should Just
119 > Work. The include and library paths to libusb are hard-coded to
120 > "C:\Program Files\LibUSB-Win32" currently, so be sure to install
121 > libusb-win32 in that directory (which I believe is the default).
123 I just got it working using the libusb-win32 "device driver" instead of 
124 the "filter driver". This allows us to provide our own *.inf file, 
125 preempting the Windows built-in UPS driver. The missing event problem I 
126 mentioned in an earlier mail is now solved and Win32 USB is working very 
127 well. (Limited testing...I've only tested WinXP so far.)
129 The only difference to use the "device driver" method is in how you 
130 install libusb-win32. Eventually I believe the installer will be able to 
131 install the driver automatically, but at the moment it's a manual 
132 process. I've made a zip file containing the required pieces:
133 <http://www.kroptech.com/~adk0212/apcupsd/apcupsd-libusb-win32.zip>
135 The basic procedure is:
136     1. Extract zip file to <C:\Program Files\LibUSB-Win32>
137     2. ./configure apcupsd source with your favorite options 
138 plus --enable-usb
139     3. Build & install apcupsd
140     4. Plug in your USB UPS and wait for Windows to recognize it
141     5. Open the Windows Device Manager and locate the "Human Interface 
142 Devices" section
143     6. Locate "American Power Conversion USB UPS" under the HID section
144     7. Right-click "American Power Conversion USB UPS" and select 
145 "Update driver..."
146     8. (Abbreviated) Do not allow Windows to search for a driver, 
147 specify one yourself. Depending on your version of Windows, the exact 
148 sequence of dialogs and options is different, but essentially you need 
149 to get to the list of devices with the "Have Disk..." button. When you 
150 get there, choose "Have Disk..."
151     9. Browse to <C:\Program Files\LibUSB-Win32\driver> and hit Open
152     10. Select "American Power Conversion USB UPS (Apcupsd)" and hit 
153 Next
154     11. The driver should be installed.
155     12. If you examine the Device Manager tree again, you should see a 
156 "LibUSB-Win32 Devices" section, under which is listed "American Power 
157 Conversion USB UPS (Apcupsd)". You should NOT see "HID UPS Battery" 
158 under the "Batteries" section.
159     13. Future plugging/unplugging of the UPS will be handled 
160 automatically. The driver only needs to be installed once.
161     14. Edit apcupsd.conf to set...
162         UPSCABLE usb
163         UPSTYPE usb
164         DEVICE
165     15. Start apcupsd and watch the magic (or the smoke...)
167 --Adam
169 P.S. To get back to the Windows standard driver, go into Device Manager 
170 and do an "Update Driver..." on "American Power Conversion USB UPS 
171 (Apcupsd)". Select the "American Power Conversion USB UPS (Microsoft)" 
172 driver from the list. After that you should be back where you started 
173 and the "Batteries -> HID UPS Battery" entry should be back and the
175 ====  to add USB
176 You should need to compile...
178     src/libusbhid/*.c
179     src/drivers/usb/*.c
180     src/drivers/usb/generic/*.c