blob: 27a2e77b22323cba4b95e8f3f5819e99233ccc78 [file] [log] [blame]
Linus Walleij6c04caa2006-03-29 17:33:51 +00001INSTALLATION OVERVIEW
2=====================
3
Linus Walleij0dd71e92006-05-04 18:47:07 +00004Once libmtp is built and installed, you will have the following files
5($PREFIX is the --prefix option given to the "configure" script and
6defaults to /usr/local/):
Linus Walleij6c04caa2006-03-29 17:33:51 +00007
Linus Walleij0dd71e92006-05-04 18:47:07 +00008 $PREFIX/lib/libmtp.a Static C library
9 $PREFIX/lib/libmtp.so.x.y.z Dynamic C library
10 $PREFIX/lib/libmtp.so.x A link to the library
11 $PREFIX/lib/libmtp.so A link to the library
12 $PREFIX/include/libmtp.h C header file for libmtp API
13 $PREFIX/lib/pkgconfig/libmtp.pc pkg-config configuration file
Linus Walleij6c04caa2006-03-29 17:33:51 +000014
Linus Walleij0dd71e92006-05-04 18:47:07 +000015Sample programs will be built in the "example" directory, and should
16help you get used to using the libmtp API, as well as provide some
17immediate gratification. Links to other programs using the libmtp
18API may be found at the homepage: http://libmtp.sourceforge.net/
Linus Walleij6c04caa2006-03-29 17:33:51 +000019
Linus Walleijd4637502009-06-14 23:03:33 +000020
Linus Walleijb8ee9252009-01-03 00:02:58 +000021Install From Distribution
22-------------------------
23
24You should probably prefer to install libmtp from the distribution
25source you're using. Last time we checked, libmtp was part of Ubuntu,
Linus Walleijd4637502009-06-14 23:03:33 +000026Fedora, OpenSUSE, Debian testing, Gentoo, FreeBSD ports and OpenBSD
Linus Walleijb8ee9252009-01-03 00:02:58 +000027packages/ports.
28
29
Linus Walleijd4637502009-06-14 23:03:33 +000030Dependencies
31------------
32
33To build libmtp you should only need development files for libusb.
34(Often named libusb-devel or similar.) For working with CVS versions
35you may need autoconf, automake, libtool, gettext(-devel).
36
Linus Walleijff3d2792012-02-18 21:45:15 +010037To enable the optional MTPZ support using libgcrypt you need the
38libgcrypt library installed as well.
39
Linus Walleijd4637502009-06-14 23:03:33 +000040
Linus Walleij0dd71e92006-05-04 18:47:07 +000041Shared Library Support
42----------------------
43
44Shared library linking is supported. You will need to 'make install'
45the library before you can execute the sample binaries, and add the
46libmtp install directory to your shared library search path.
47
48On Linux, you would add the line "/usr/local/lib" to your
49"/etc/ld.so.conf" or as a oneliner in for example a
50"/etc/ld.so.conf.d/local.conf" file and run the
Linus Walleijd4637502009-06-14 23:03:33 +000051program "ldconfig" to scan in the shared libraries at
52the new path. This is a part of the Linux shared library
Linus Walleij0dd71e92006-05-04 18:47:07 +000053loader actually.
54
55To access the library from real odd locations you can use
56the LD_LIBRARY_PATH environment variable by setting it before
57you run your program, for example:
58
59 % export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
60 % my_program
61
62This way of enabling the library to link is a workaround hack.
63Note that the LD_LIBRARY_PATH is actually supposed to be used for
64testing, not production systems or distributions. It is commonly
65used as a workaround when a user is installing libraries in her/his
66home directory however. Read more about this environment variable
67here: http://www.visi.com/~barr/ldpath.html
68
69The shared library comes with different interface version numbers,
70for example libmtp.so.4, libmtp.so.5 and so forth. This is used so
71that both old and new libmtp libraries shall be able to coexist on
Linus Walleijd4637502009-06-14 23:03:33 +000072the same system. When you compile your programs they will typically
73bind to the latest version of the shared library. A link to the
Linus Walleij0dd71e92006-05-04 18:47:07 +000074latest version is always provided as $PREFIX/lib/libmtp.so.
75
76libusb Support
77--------------
78
79This package depends on libusb. Get libusb from sourceforge at:
80
81 http://www.sourceforge.net/projects/libusb/
82
Linus Walleij63a92582006-06-03 20:36:35 +000083On Linux, please use the very latest version you can get, between
840.1.8 and 0.1.12 a lot of things happened which pertains to
85the udev hotplugging support, see below.
86
Linus Walleij0dd71e92006-05-04 18:47:07 +000087
88BASIC BUILD PROCEDURE
89=====================
90
91To build the package:
92
Linus Walleij925cd452010-12-05 21:26:48 +000093 % ./configure
Linus Walleij0dd71e92006-05-04 18:47:07 +000094 % make
95 % make install
96
97By default, libmtp will add the program-prefix "mtp-" to all the
98example programs prior to installation. The program-prefix option
99makes libmtp sample programs avoid collision with other programs like
Linus Walleij284aacb2007-08-11 21:17:36 +0000100sox' "play" program. If the default prefix for some reason fail,
101try to tag on "--program-prefix=mtp-" to the "configure" command.
102
Linus Walleij925cd452010-12-05 21:26:48 +0000103The "libexedir" in the configure file is hardcoded to /lib/udev to
Linus Walleij1774a8e2010-12-05 20:01:53 +0000104make the mtp-probe (which is built for Linux only) install into
Linus Walleij925cd452010-12-05 21:26:48 +0000105that directory. This is the only location that makes sens for this
106executable.
Linus Walleij0dd71e92006-05-04 18:47:07 +0000107
108if you want to install the documentation type:
109
110 % make install-docs
111
112if you checked out the sources from CVS, you must first run the
113autogen.sh script that generates all the GNU autotools files.
Linus Walleij362d13e2009-08-02 19:59:21 +0000114Notice that this requires GNU autoconf, automake and libtool and
115possibly some other packages like gettext, readline, intltool and
116other M4 macro sources. This is done with:
Linus Walleij0dd71e92006-05-04 18:47:07 +0000117
118 % ./autogen.sh
119
120
121Linux hotplugging
122-----------------
123
124After compilation and installation you may (and should) add hotplugging
125support by running the hotplug script, if your distribution supports
126hotplugging (all do). This typically means you have something
127in /etc/hotplug and that hotplugging is started when you boot your
128machine in a script named /etc/init.d/hotplug or similar.
129
130Activate hotplugging by running:
131
132 %./hotplug.sh
133
134Hotplug will (typically) use the device map file installed by hotplug.sh
135at /etc/hotplug/usb/libmtp.usermap to lift the device to userspace for the
136current user by running the script /etc/hotplug/usb/libmtp.sh. If
137you have the program "resmgr" installed (currently used only by SuSE to
138our knowledge) that program will be used for enabling desktop user
139access, otherwise the current user of the desktop will be determined
140from files in /var/run. (See the script "libmtp.sh" for details.)
141
142
143Linux udev hotplugging
144----------------------
145
146Newer Linux distributions have dropped support for the old hotplug system
147and rely solely on udev, and rules stored below /etc/udev/rules.d to
148handle permissions and actions on device connections. It's quite solid
149but the whole thing is rather shaky when it comes to such things as
150custom devices handled solely by libusb, which is what libmtp and for
151example SANE backends use.
152
153The libmtp.rules file that comes with libmtp can be used as a starter.
154
Linus Walleijc4cd50b2011-01-08 22:50:07 +0000155This will set the environment variables ID_MEDIA_PLAYER and
156ID_MTP_DEVICE to "1" and the former one will be recognized by the
157scripts distributed by recent versions of udev to be a
158console-writable device that should be accessible for all
159users.
Linus Walleij0dd71e92006-05-04 18:47:07 +0000160
Linus Walleijc4cd50b2011-01-08 22:50:07 +0000161Ancient udev, HAL, libusb
162-------------------------
163
164The old script for udev used to set the device access to "666"
165which is rather nasty (not that big security issue, unless you
166think someone will break into your jukebox) some systems used
167to let PAM do this by placing a configuration file in
168/etc/security/ somewhere. Then it was replaced with simple
169udev rules.
170
171At one point HAL was used to take devices detected by udev and
172signal to userspace that they were available and provide some
173information about them. This was unnecessary middleware, it has
174been killed and most userspace applications now get their
175information directly from udev instead.
176
177In old libusb first you need a crazy rule that creates a device
178node in the /dev/bus/usb hierarchy whenever any USB device is
179connected. The script has this at the top, you can comment it
180in if your distribution does not already create these device
181nodes.
182
183Then libusb may need to be patched to recognize this hierarchy.
Linus Walleij0dd71e92006-05-04 18:47:07 +0000184The 0.1.12 version is the first which is properly fixed.
185
Linus Walleij0dd71e92006-05-04 18:47:07 +0000186
187
188If you cannot run hotplugging
189-----------------------------
190
191If you have a distro without hotplugging enabled try this as root:
192
193 % chmod -R a+w /proc/bus/usb
194
195You have to do this again every time you unplug/replug your USB cable
196or restart the jukebox, every time you quit libnjb and restart it,
197etc etc etc an alternative is to run libmtp as root which works just fine.
198The problem is to somehow assure that you (ie the current user) always
199has write access on /proc/bus/usb/*
200
201You can find the Linux hotplug project at:
202http://linux-hotplug.sourceforge.net/
Linus Walleijd3b78572007-08-24 21:28:24 +0000203
204
205Compilation for embedded devices
206--------------------------------
207
208Problems with Autoconf complaining about a missing malloc() function
209during cross-compilation can be solved with this hack if you're using
210glibc:
211
212 % export ac_cv_func_malloc_0_nonnull=yes
213 % ./configure
214
215If you're using uclibc you may have to smack in a custom rpl_malloc()
216function in your program, see the Autoconf texinfo documentation.
217
218See further:
Linus Walleijc868cbc2011-02-09 20:19:25 +0100219http://wiki.buici.com/wiki/Autoconf_and_RPL_MALLOC
220
221Compilation for Solaris/SunOS
222-----------------------------
223
Darran Kartaschew11082d32011-12-13 00:42:01 +0100224libmtp builds on Solaris/SunOS with either gcc or SunStudio 12. It does
225require GNU Make (aka gmake) to be installed. Building libmtp on Solaris
22610 and Solaris 11 differ slightly, so alternate instructions are provided
227for each Solaris version.
228
229For Solaris 10
230--------------
Linus Walleijc868cbc2011-02-09 20:19:25 +0100231
Darran90ec6e52011-02-13 17:53:20 +0100232To build using GCC:
Darran Kartaschew11082d32011-12-13 00:42:01 +0100233
Darran90ec6e52011-02-13 17:53:20 +0100234 % CFLAGS="I/usr/sfw/lib -L/usr/sfw/lib -R/usr/sfw/lib" MAKE=gmake \
235 INSTALL=/usr/ucb/install ./configure
236 % gmake
237 % gmake install
Linus Walleijc868cbc2011-02-09 20:19:25 +0100238
Darran Kartaschew11082d32011-12-13 00:42:01 +0100239Custom CLFAGS are required for libusb.so as it lives in /usr/sfw/lib,
240and this path is not in the default search path for ld. If these
241CFLAGS are not set, several components of ./configure will fail leading
Darran90ec6e52011-02-13 17:53:20 +0100242to a failed build.
Linus Walleijc868cbc2011-02-09 20:19:25 +0100243
Darran90ec6e52011-02-13 17:53:20 +0100244To build using SunStudio 12:
Linus Walleijc868cbc2011-02-09 20:19:25 +0100245
Darran90ec6e52011-02-13 17:53:20 +0100246 % CFLAGS="I/usr/sfw/lib -L/usr/sfw/lib -R/usr/sfw/lib" MAKE=gmake \
247 INSTALL=/usr/ucb/install CC=cc ./configure
248 % gmake
249 % gmake install
Linus Walleijc868cbc2011-02-09 20:19:25 +0100250
Linus Walleijc868cbc2011-02-09 20:19:25 +0100251
Darran90ec6e52011-02-13 17:53:20 +0100252General Notes:
Darran Kartaschew11082d32011-12-13 00:42:01 +0100253All MTP devices on Solaris 10u2+ are driven by the usb_mid driver, which
254will automatically export ugen device interfaces with the correct device
255permissions. No special configuration is required. See the usb_mid(7D)
256and ugen(7D) manpages and /usr/sfw/share/doc/libusb/libusb.txt for
Darran90ec6e52011-02-13 17:53:20 +0100257more information.
Darran Kartaschew11082d32011-12-13 00:42:01 +0100258
259For Solaris 11
260--------------
261
262Building libmtp on Solaris 11 is very similar to those instructions for
263Solaris 10, however libusb now lives in /usr/lib, and openusb is also
264available as an alternative USB library. Oracle does not provide a
265libusb v1.0 API compatible version of libusb, instead providing the older
266v0.1 API interface version of libusb. As mentioned, Oracle also provides
267the OpenUSB USB library as an alternate to libusb v1.0, however OpenUSB is
268not source or binary compatible with libusb.
269
270Before building/installing libmtp there are some components missing from
271the base Solaris 11 installation, and are required to be installed prior
272to building/installing libmtp. The 'libusbugen' package must be installed
273before libusb itself is usable on Solaris 11, alternatively the 'openusb'
274package may be used.
275
276To build using GCC:
277 % ./configure
278 % gmake
279 % sudo gmake install
280
281To build using SunStudio 12:
282 % CC=cc ./configure
283 % gmake
284 % sudo gmake install
285
286
287General Notes:
288All MTP devices on Solaris 11+ are driven by the usb_mid driver, which
289will automatically export ugen device interfaces with the correct device
290permissions. No special configuration is required. See the usb_mid(7D)
291and ugen(7D) manpages and /usr/share/doc/libusb/libusb.txt for more
292information.