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

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since cc232d3 was cc232d3, checked in by Pierre Labastie <pieere@…>, 6 years ago

Fix a possible error in "remove-la-files.sh":
If /opt is empty, the instruction "find /opt/* ..." exits with non zero
status. The new instruction should be equivalent, but without this issue.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@19619 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • 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 <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 &gt; /usr/sbin/remove-la-files.sh &lt;&lt; "EOF"
83<literal>#!/bin/bash
84
85# /usr/sbin/remove-la-files.sh
86# Written for Beyond Linux From Scratch
87# by Bruce Dubbs &lt;bdubbs@&lfs-domainname;&gt;
88
89# Make sure we are running with root privs
90if test "${EUID}" -ne 0; then
91 echo "Error: $(basename ${0}) must be run as the root user! Exiting..."
92 exit 1
93fi
94
95# Make sure PKG_CONFIG_PATH is set if discarded by sudo
96source /etc/profile
97
98OLD_LA_DIR=/var/local/la-files
99
100mkdir -p $OLD_LA_DIR
101
102# Only search directories in /opt, but not symlinks to directories
103OPTDIRS=$(find /opt -mindepth 1 -maxdepth 1 -type d)
104
105# Move any found .la files to a directory out of the way
106find /usr/lib $OPTDIRS -name "*.la" ! -path "/usr/lib/ImageMagick*" \
107 -exec mv -fv {} $OLD_LA_DIR \;
108###############
109
110# Fix any .pc files that may have .la references
111
112STD_PC_PATH='/usr/lib/pkgconfig
113 /usr/share/pkgconfig
114 /usr/local/lib/pkgconfig
115 /usr/local/share/pkgconfig'
116
117# For each directory that can have .pc files
118for d in $(echo $PKG_CONFIG_PATH | tr : ' ') $STD_PC_PATH; do
119
120 # For each pc file
121 for pc in $d/*.pc ; do
122 if [ $pc == "$d/*.pc" ]; then continue; fi
123
124 # Check each word in a line with a .la reference
125 for word in $(grep '\.la' $pc); do
126 if $(echo $word | grep -q '.la$' ); then
127 mkdir -p $d/la-backup
128 cp -fv $pc $d/la-backup
129
130 basename=$(basename $word )
131 libref=$(echo $basename|sed -e 's/^lib/-l/' -e 's/\.la$//')
132
133 # Fix the .pc file
134 sed -i "s:$word:$libref:" $pc
135 fi
136 done
137 done
138done
139
140EOF
141
142chmod +x /usr/sbin/remove-la-files.sh</literal></userinput></screen>
143
144 <para condition="html" role="usernotes">
145 User Notes: <ulink url="&blfs-wiki;/la-files"/>
146 </para>
147
148 </sect2>
149
150</sect1>
Note: See TracBrowser for help on using the repository browser.