source: introduction/important/la-files.xml@ eede1a3

11.0 ken/refactor-virt lazarus qt5new trunk upgradedb
Last change on this file since eede1a3 was 45ab6c7, checked in by Xi Ruoyao <xry111@…>, 9 months ago

more SVN prop clean up

Remove "$LastChanged$" everywhere, and also some unused $Date$

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