Linus Walleij | 6c04caa | 2006-03-29 17:33:51 +0000 | [diff] [blame] | 1 | INSTALLATION OVERVIEW |
| 2 | ===================== |
| 3 | |
Linus Walleij | 0dd71e9 | 2006-05-04 18:47:07 +0000 | [diff] [blame] | 4 | Once libmtp is built and installed, you will have the following files |
| 5 | ($PREFIX is the --prefix option given to the "configure" script and |
| 6 | defaults to /usr/local/): |
Linus Walleij | 6c04caa | 2006-03-29 17:33:51 +0000 | [diff] [blame] | 7 | |
Linus Walleij | 0dd71e9 | 2006-05-04 18:47:07 +0000 | [diff] [blame] | 8 | $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 Walleij | 6c04caa | 2006-03-29 17:33:51 +0000 | [diff] [blame] | 14 | |
Linus Walleij | 0dd71e9 | 2006-05-04 18:47:07 +0000 | [diff] [blame] | 15 | Sample programs will be built in the "example" directory, and should |
| 16 | help you get used to using the libmtp API, as well as provide some |
| 17 | immediate gratification. Links to other programs using the libmtp |
| 18 | API may be found at the homepage: http://libmtp.sourceforge.net/ |
Linus Walleij | 6c04caa | 2006-03-29 17:33:51 +0000 | [diff] [blame] | 19 | |
Linus Walleij | 0dd71e9 | 2006-05-04 18:47:07 +0000 | [diff] [blame] | 20 | Shared Library Support |
| 21 | ---------------------- |
| 22 | |
| 23 | Shared library linking is supported. You will need to 'make install' |
| 24 | the library before you can execute the sample binaries, and add the |
| 25 | libmtp install directory to your shared library search path. |
| 26 | |
| 27 | On Linux, you would add the line "/usr/local/lib" to your |
| 28 | "/etc/ld.so.conf" or as a oneliner in for example a |
| 29 | "/etc/ld.so.conf.d/local.conf" file and run the |
| 30 | program "ldconfig" to scan in the shared libraries at |
| 31 | the new path. This is a part of the Linux shared library |
| 32 | loader actually. |
| 33 | |
| 34 | To access the library from real odd locations you can use |
| 35 | the LD_LIBRARY_PATH environment variable by setting it before |
| 36 | you run your program, for example: |
| 37 | |
| 38 | % export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib |
| 39 | % my_program |
| 40 | |
| 41 | This way of enabling the library to link is a workaround hack. |
| 42 | Note that the LD_LIBRARY_PATH is actually supposed to be used for |
| 43 | testing, not production systems or distributions. It is commonly |
| 44 | used as a workaround when a user is installing libraries in her/his |
| 45 | home directory however. Read more about this environment variable |
| 46 | here: http://www.visi.com/~barr/ldpath.html |
| 47 | |
| 48 | The shared library comes with different interface version numbers, |
| 49 | for example libmtp.so.4, libmtp.so.5 and so forth. This is used so |
| 50 | that both old and new libmtp libraries shall be able to coexist on |
| 51 | the same system. When you compile your programs they will typically |
| 52 | bind to the latest version of the shared library. A link to the |
| 53 | latest version is always provided as $PREFIX/lib/libmtp.so. |
| 54 | |
| 55 | libusb Support |
| 56 | -------------- |
| 57 | |
| 58 | This package depends on libusb. Get libusb from sourceforge at: |
| 59 | |
| 60 | http://www.sourceforge.net/projects/libusb/ |
| 61 | |
Linus Walleij | 63a9258 | 2006-06-03 20:36:35 +0000 | [diff] [blame] | 62 | On Linux, please use the very latest version you can get, between |
| 63 | 0.1.8 and 0.1.12 a lot of things happened which pertains to |
| 64 | the udev hotplugging support, see below. |
| 65 | |
Linus Walleij | 0dd71e9 | 2006-05-04 18:47:07 +0000 | [diff] [blame] | 66 | |
| 67 | BASIC BUILD PROCEDURE |
| 68 | ===================== |
| 69 | |
| 70 | To build the package: |
| 71 | |
| 72 | % ./configure |
| 73 | % make |
| 74 | % make install |
| 75 | |
| 76 | By default, libmtp will add the program-prefix "mtp-" to all the |
| 77 | example programs prior to installation. The program-prefix option |
| 78 | makes libmtp sample programs avoid collision with other programs like |
Linus Walleij | 284aacb | 2007-08-11 21:17:36 +0000 | [diff] [blame] | 79 | sox' "play" program. If the default prefix for some reason fail, |
| 80 | try to tag on "--program-prefix=mtp-" to the "configure" command. |
| 81 | |
| 82 | On Linux you should then typically type (see below for details): |
Linus Walleij | 0dd71e9 | 2006-05-04 18:47:07 +0000 | [diff] [blame] | 83 | |
| 84 | % ./hotplug.sh |
| 85 | |
| 86 | you can achieve the same with |
| 87 | |
| 88 | % ./configure --enable-hotplugging |
| 89 | |
| 90 | you can turn off some speed enhancements (for testing) with: |
| 91 | |
| 92 | % ./configure --no-turbo |
| 93 | |
| 94 | if you want to install the documentation type: |
| 95 | |
| 96 | % make install-docs |
| 97 | |
| 98 | if you checked out the sources from CVS, you must first run the |
| 99 | autogen.sh script that generates all the GNU autotools files. |
| 100 | Notice that this requires GNU autoconf, automake and libtool. This |
| 101 | is done with: |
| 102 | |
| 103 | % ./autogen.sh |
| 104 | |
| 105 | |
| 106 | Linux hotplugging |
| 107 | ----------------- |
| 108 | |
| 109 | After compilation and installation you may (and should) add hotplugging |
| 110 | support by running the hotplug script, if your distribution supports |
| 111 | hotplugging (all do). This typically means you have something |
| 112 | in /etc/hotplug and that hotplugging is started when you boot your |
| 113 | machine in a script named /etc/init.d/hotplug or similar. |
| 114 | |
| 115 | Activate hotplugging by running: |
| 116 | |
| 117 | %./hotplug.sh |
| 118 | |
| 119 | Hotplug will (typically) use the device map file installed by hotplug.sh |
| 120 | at /etc/hotplug/usb/libmtp.usermap to lift the device to userspace for the |
| 121 | current user by running the script /etc/hotplug/usb/libmtp.sh. If |
| 122 | you have the program "resmgr" installed (currently used only by SuSE to |
| 123 | our knowledge) that program will be used for enabling desktop user |
| 124 | access, otherwise the current user of the desktop will be determined |
| 125 | from files in /var/run. (See the script "libmtp.sh" for details.) |
| 126 | |
| 127 | |
| 128 | Linux udev hotplugging |
| 129 | ---------------------- |
| 130 | |
| 131 | Newer Linux distributions have dropped support for the old hotplug system |
| 132 | and rely solely on udev, and rules stored below /etc/udev/rules.d to |
| 133 | handle permissions and actions on device connections. It's quite solid |
| 134 | but the whole thing is rather shaky when it comes to such things as |
| 135 | custom devices handled solely by libusb, which is what libmtp and for |
| 136 | example SANE backends use. |
| 137 | |
| 138 | The libmtp.rules file that comes with libmtp can be used as a starter. |
| 139 | |
| 140 | First you need a crazy rule that creates a device node in the |
| 141 | /dev/bus/usb hierarchy whenever any USB device is connected. The |
| 142 | script has this at the top, you can comment it in if your |
| 143 | distribution does not already create these device nodes. |
| 144 | |
| 145 | Then libusb may need to be patched to recognize this hierarchy. |
| 146 | The 0.1.12 version is the first which is properly fixed. |
| 147 | |
| 148 | The script sets the device access to "666" which is rather nasty |
| 149 | (not that big security issue, unless you think someone will break |
| 150 | into your jukebox) some systems prefer to let PAM do this by placing |
| 151 | a configuration file in /etc/security/ somewhere. See the Fedora Extras |
| 152 | SRPM source package in case you're interested in how it is handled |
| 153 | there. |
| 154 | |
| 155 | |
| 156 | If you cannot run hotplugging |
| 157 | ----------------------------- |
| 158 | |
| 159 | If you have a distro without hotplugging enabled try this as root: |
| 160 | |
| 161 | % chmod -R a+w /proc/bus/usb |
| 162 | |
| 163 | You have to do this again every time you unplug/replug your USB cable |
| 164 | or restart the jukebox, every time you quit libnjb and restart it, |
| 165 | etc etc etc an alternative is to run libmtp as root which works just fine. |
| 166 | The problem is to somehow assure that you (ie the current user) always |
| 167 | has write access on /proc/bus/usb/* |
| 168 | |
| 169 | You can find the Linux hotplug project at: |
| 170 | http://linux-hotplug.sourceforge.net/ |
Linus Walleij | d3b7857 | 2007-08-24 21:28:24 +0000 | [diff] [blame] | 171 | |
| 172 | |
| 173 | Compilation for embedded devices |
| 174 | -------------------------------- |
| 175 | |
| 176 | Problems with Autoconf complaining about a missing malloc() function |
| 177 | during cross-compilation can be solved with this hack if you're using |
| 178 | glibc: |
| 179 | |
| 180 | % export ac_cv_func_malloc_0_nonnull=yes |
| 181 | % ./configure |
| 182 | |
| 183 | If you're using uclibc you may have to smack in a custom rpl_malloc() |
| 184 | function in your program, see the Autoconf texinfo documentation. |
| 185 | |
| 186 | See further: |
| 187 | http://wiki.buici.com/wiki/Autoconf_and_RPL_MALLOC |