1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
5 | %general-entities;
|
---|
6 | ]>
|
---|
7 |
|
---|
8 | <sect1 id="la-files" xreflabel="Libtool archive (.la) files">
|
---|
9 | <?dbhtml filename="la-files.html"?>
|
---|
10 |
|
---|
11 | <sect1info>
|
---|
12 | <othername>$LastChangedBy$</othername>
|
---|
13 | <date>$Date$</date>
|
---|
14 | </sect1info>
|
---|
15 |
|
---|
16 | <title>About Libtool Archive (.la) files</title>
|
---|
17 |
|
---|
18 | <!-- section g : 'Others' in longindex.html -->
|
---|
19 | <indexterm zone="la-files">
|
---|
20 | <primary sortas="g-la-files">Library archive (.la) files</primary>
|
---|
21 | </indexterm>
|
---|
22 |
|
---|
23 | <sect2 role="package">
|
---|
24 | <title>Files with a .la extention</title>
|
---|
25 |
|
---|
26 | <para>
|
---|
27 |
|
---|
28 | In LFS we installed a package, libtool, that is used by many packages to
|
---|
29 | build on a variety of Unix platforms. This includes platforms such as
|
---|
30 | AIX, Solaris, IRIX, HP-UX, and Cygwin as well as Linux. The origins of
|
---|
31 | this tool are quite dated. It was intended to manage libraries on
|
---|
32 | systems with less advanced capabilities than a modern Linux system.
|
---|
33 |
|
---|
34 | </para>
|
---|
35 |
|
---|
36 | <para>
|
---|
37 |
|
---|
38 | On a Linux system, libtool specific files are generally unneeded.
|
---|
39 | Normally libraries are specified in the build process during the link
|
---|
40 | phase. Since a linux system uses the <ulink
|
---|
41 | url="https://en.wikipedia.org/wiki/Executable_and_Linkable_Format">
|
---|
42 | Executable and Linkable Format (ELF)</ulink> for executables and
|
---|
43 | libraries, information needed to complete the task is embedded in the
|
---|
44 | files. At run time the program loader can query the appropriate files
|
---|
45 | and properly load and execute the program.
|
---|
46 |
|
---|
47 | </para>
|
---|
48 |
|
---|
49 | <para>
|
---|
50 |
|
---|
51 | The problem is that libtool usually creates one or more text files for
|
---|
52 | package libraries called libtool archives. These small files have a
|
---|
53 | ".la" extention and contain information that is similar to that embedded
|
---|
54 | in the libraries. When building a package that uses libtool, the
|
---|
55 | process automatically looks for these files. If a package is updated
|
---|
56 | and no longer uses the .la file, then the build process can break.
|
---|
57 |
|
---|
58 | </para>
|
---|
59 |
|
---|
60 | <para>
|
---|
61 |
|
---|
62 | The solution is to remove the .la files. However there is a catch.
|
---|
63 | Some packages, such as <xref linkend='imagemagick'/>, use a libtool
|
---|
64 | function, lt_dlopen, to load libraries as needed during execution and
|
---|
65 | resolve their dependencies at run time. In this case, the .la files
|
---|
66 | should remain.
|
---|
67 |
|
---|
68 | </para>
|
---|
69 |
|
---|
70 | <para>
|
---|
71 |
|
---|
72 | The script below, removes all unneeded .la files and saves them in a
|
---|
73 | directory, /var/local/la-files by default, not in the normal library
|
---|
74 | path. It also searches all pkg-config files (.pc) for embedded
|
---|
75 | references to .la files and fixes them to be conventional library
|
---|
76 | references needed when an application or library is built. It
|
---|
77 | can be run as needed to clean up the directories that may be causing
|
---|
78 | problems.
|
---|
79 |
|
---|
80 | </para>
|
---|
81 |
|
---|
82 | <screen role="root"><userinput>cat > /usr/sbin/remove-la-files.sh << "EOF"
|
---|
83 | <literal># Begin /etc/bashrc
|
---|
84 | # Written for Beyond Linux From Scratch
|
---|
85 | # by Bruce Dubbs <bdubbs@&lfs-domainname;>
|
---|
86 |
|
---|
87 | # Make sure we are running with root privs
|
---|
88 | if test "${EUID}" -ne 0; then
|
---|
89 | echo "Error: $(basename ${0}) must be run as the root user! Exiting..."
|
---|
90 | exit 1
|
---|
91 | fi
|
---|
92 |
|
---|
93 | # Make sure PKG_CONFIG_PATH is set if discarded by sudo
|
---|
94 | source /etc/profile
|
---|
95 |
|
---|
96 | OLD_LA_DIR=/var/local/la-files
|
---|
97 |
|
---|
98 | mkdir -p $OLD_LA_DIR
|
---|
99 |
|
---|
100 | # Only search directories in /opt, but not symlinks to directories
|
---|
101 | OPTDIRS=$(find /opt/* -maxdepth 0 -type d)
|
---|
102 |
|
---|
103 | # Move any found .la files to a directory out of the way
|
---|
104 | find /usr/lib $OPTDIRS -name "*.la" ! -path "/usr/lib/ImageMagick*" \
|
---|
105 | -exec mv -fv {} $OLD_LA_DIR \;
|
---|
106 | ###############
|
---|
107 |
|
---|
108 | # Fix any .pc files tha may have .la references
|
---|
109 |
|
---|
110 | STD_PC_PATH='/usr/lib/pkgconfig
|
---|
111 | /usr/share/pkgconfig
|
---|
112 | /usr/local/lib/pkgconfig
|
---|
113 | /usr/local/share/pkgconfig'
|
---|
114 |
|
---|
115 | # For each directory tha can have .pc files
|
---|
116 | for d in $(echo $PKG_CONFIG_PATH | tr : ' ') $STD_PC_PATH; do
|
---|
117 |
|
---|
118 | # For each pc file
|
---|
119 | for pc in $d/*.pc ; do
|
---|
120 | if [ $pc == "$d/*.pc" ]; then continue; fi
|
---|
121 |
|
---|
122 | # Check each word in a line with a .la reference
|
---|
123 | for word in $(grep '\.la' $pc); do
|
---|
124 | if $(echo $word | grep -q '.la$' ); then
|
---|
125 | mkdir -p $d/la-backup
|
---|
126 | cp -fv $pc $d/la-backup
|
---|
127 |
|
---|
128 | basename=$(basename $word )
|
---|
129 | libref=$(echo $basename|sed -e 's/^lib/-l/' -e 's/\.la$//')
|
---|
130 |
|
---|
131 | # Fix the .pc file
|
---|
132 | sed -i "s:$word:$libref:" $pc
|
---|
133 | fi
|
---|
134 | done
|
---|
135 | done
|
---|
136 | done
|
---|
137 |
|
---|
138 | EOF
|
---|
139 |
|
---|
140 | chmod +x /usr/sbin/remove-la-files.sh</literal></userinput></screen>
|
---|
141 |
|
---|
142 | <para condition="html" role="usernotes">
|
---|
143 | User Notes: <ulink url="&blfs-wiki;/la-files"/>i
|
---|
144 | </para>
|
---|
145 |
|
---|
146 | </sect2>
|
---|
147 |
|
---|
148 | </sect1>
|
---|