[lfs-dev] static libs

Bruce Dubbs bruce.dubbs at gmail.com
Sun Mar 8 19:26:28 PDT 2015


Ken Moffat wrote:
> On Sat, Mar 07, 2015 at 11:21:03PM +0000, Ken Moffat wrote:
>> I've just started a 32-bit qemu build.  For most of the packages
>> where I noticed static libs, I'm adding --disable-static.  Not for
>> flex or zlib.  For ncurses I'm adding --disable-normal : I suspect
>> it one or two static ncurses libs might still remain).  And I will
>> be installing all locales and running the tests, then looking at the
>> logs and throwing it away ready for the second attempt.
>
> Here are my preliminary findings (32-bit, in qemu):
>
> 1. acl continues to give me /usr/lib/libacl.a, even with
> --disable-static.
>
> 2. I have been manually removing (not just renaming)
> /usr/lib/libbz2.a in my script in normal builds for some time (I
> have a vague memory that I once botched the move of the .so to
> .usr/lib (version upgrade, still had old lib version hardcoded) and
> something tried to link to the static lib (but failed - something on
> x86_64 trying to link a shared library).
>
> 3. I have been manually removing 4 static libs from e2fsprogs:
> libcom_err.a, libe2p.a, libext2fs.a, libss.a in my normal builds.
>
> 4. libtool with --disable-static still installs /usr/lib/libltdl.a.
>
> 5. ncurses with --disable-normal still installs
> /usr/lib/libncurses++w.a
>
> 6. libfl.a from flex is used by automake's tests, libfl_pic.a is
> also installed.
>
> 7. libz.a from zlib is used by binutils tests.
>
> I have not bothered to mention static libs from binutils, gcc, glibc.
>
> The test results apart from eudev look unchanged, except that my
> failures in acl and inetutils on real hardware must indeed be due to
> something omitted from my kernel config.
>
> This is with --disable-static in: acl, eudev, expat, gdbm, gettext,
> gmp, intltool, mpc, mpfr, procps-ng and --enable-shared
> --disable-static in util-linux.
>
> I suppose that my next step will be to look (again) at acl, and to
> look at bzip2, e2fsprogs, libtool, ncurses and perhaps flex.  Might
> be some days before I am willing to stare at the acl files.

Attached is what I've come up with so far.  I didn't try to run tests, but it 
does remove everything except binutils (2), e2fsprogs(4), gcc(17) and glibc(17).

In some cases, it might just be easier and more direct to just remove the files 
after install.  I was able to remove libncurses++w.a and libbz2.a bit I think 
acl and libtool worked OK, but I'll need to double check.

For libltdl.a and libz.a we might want to remove those in 6.73. Cleaning Up.

   -- Bruce


-------------- next part --------------
Index: chapter06/attr.xml
===================================================================
--- chapter06/attr.xml	(revision 10874)
+++ chapter06/attr.xml	(working copy)
@@ -53,7 +53,9 @@
 -->
     <para>Prepare Attr for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr --bindir=/bin</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr \
+            --bindir=/bin \
+            --disable-static</userinput></screen>
 
     <para>Compile the package:</para>
 
Index: chapter06/bison.xml
===================================================================
--- chapter06/bison.xml	(revision 10874)
+++ chapter06/bison.xml	(working copy)
@@ -40,6 +40,10 @@
   <sect2 role="installation">
     <title>Installation of Bison</title>
 
+    <para>Inhibit static library installation:</para>
+
+<screen><userinput remap="pre">sed -i '/lib_LIBRARIES =/d' Makefile.in</userinput></screen>    
+
     <para>Prepare Bison for compilation:</para>
 
 <screen><userinput remap="configure">./configure --prefix=/usr --docdir=/usr/share/doc/bison-&bison-version;</userinput></screen>
Index: chapter06/eudev.xml
===================================================================
--- chapter06/eudev.xml	(revision 10874)
+++ chapter06/eudev.xml	(working copy)
@@ -62,6 +62,7 @@
             --enable-keymap         \
             --disable-introspection \
             --disable-gudev         \
+            --disable-static        \
             --disable-gtk-doc-html</userinput></screen>
 
 <para>Compile the package:</para>
Index: chapter06/expat.xml
===================================================================
--- chapter06/expat.xml	(revision 10874)
+++ chapter06/expat.xml	(working copy)
@@ -43,7 +43,7 @@
 
     <para>Prepare Expat for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr --disable-static</userinput></screen>
 
     <para>Compile the package:</para>
 
Index: chapter06/flex.xml
===================================================================
--- chapter06/flex.xml	(revision 10874)
+++ chapter06/flex.xml	(working copy)
@@ -47,7 +47,9 @@
 
     <para>Prepare Flex for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr --docdir=/usr/share/doc/flex-&flex-version;</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --disable-static \
+            --docdir=/usr/share/doc/flex-&flex-version;</userinput></screen>
 
     <para>Compile the package:</para>
 
Index: chapter06/gdbm.xml
===================================================================
--- chapter06/gdbm.xml	(revision 10874)
+++ chapter06/gdbm.xml	(working copy)
@@ -46,7 +46,9 @@
 
     <para>Prepare GDBM for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr --enable-libgdbm-compat</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --disable-static \
+            --enable-libgdbm-compat</userinput></screen>
 
     <variablelist>
       <title>The meaning of the configure option:</title>
Index: chapter06/gettext.xml
===================================================================
--- chapter06/gettext.xml	(revision 10874)
+++ chapter06/gettext.xml	(working copy)
@@ -45,7 +45,9 @@
 
     <para>Prepare Gettext for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr --docdir=/usr/share/doc/gettext-&gettext-version;</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --disable-static \
+            --docdir=/usr/share/doc/gettext-&gettext-version;</userinput></screen>
 
     <para>Compile the package:</para>
 
Index: chapter06/gmp.xml
===================================================================
--- chapter06/gmp.xml	(revision 10874)
+++ chapter06/gmp.xml	(working copy)
@@ -52,8 +52,9 @@
 
     <para>Prepare GMP for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr \
-            --enable-cxx  \
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --enable-cxx     \
+            --disable-static \
             --docdir=/usr/share/doc/gmp-&gmp-version;</userinput></screen>
 
     <variablelist>
Index: chapter06/libcap.xml
===================================================================
--- chapter06/libcap.xml	(revision 10874)
+++ chapter06/libcap.xml	(working copy)
@@ -43,6 +43,10 @@
   <sect2 role="installation">
     <title>Installation of Libcap</title>
 
+    <para>Prevent a static library from being installed:</para>
+
+<screen><userinput remap="pre">sed -i '/install.*STALIBNAME/d' libcap/Makefile</userinput></screen>
+
     <para>Compile the package:</para>
 
 <screen><userinput remap="make">make</userinput></screen>
Index: chapter06/libtool.xml
===================================================================
--- chapter06/libtool.xml	(revision 10874)
+++ chapter06/libtool.xml	(working copy)
@@ -44,7 +44,7 @@
 
     <para>Prepare Libtool for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr --disable-static</userinput></screen>
 
     <para>Compile the package:</para>
 
Index: chapter06/mpc.xml
===================================================================
--- chapter06/mpc.xml	(revision 10874)
+++ chapter06/mpc.xml	(working copy)
@@ -44,7 +44,9 @@
 
     <para>Prepare MPC for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr --docdir=/usr/share/doc/mpc-&mpc-version;</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --disable-static \
+            --docdir=/usr/share/doc/mpc-&mpc-version;</userinput></screen>
 
     <para>Compile the package and generate the HTML documentation:</para>
 
Index: chapter06/mpfr.xml
===================================================================
--- chapter06/mpfr.xml	(revision 10874)
+++ chapter06/mpfr.xml	(working copy)
@@ -49,6 +49,7 @@
     <para>Prepare MPFR for compilation:</para>
 
 <screen><userinput remap="configure">./configure --prefix=/usr        \
+            --disable-static     \
             --enable-thread-safe \
             --docdir=/usr/share/doc/mpfr-&mpfr-version;</userinput></screen>
 
Index: chapter06/ncurses.xml
===================================================================
--- chapter06/ncurses.xml	(revision 10874)
+++ chapter06/ncurses.xml	(working copy)
@@ -51,6 +51,10 @@
 <screen><userinput>bzcat ../&ncurses-rollup-patch; | patch -Np1</userinput></screen>
     -->
 
+    <para>Don't install static library:</para>
+
+<screen><userinput remap="pre">sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in</userinput></screen>
+
     <para>Prepare Ncurses for compilation:</para>
 
 <screen><userinput remap="configure">./configure --prefix=/usr           \
@@ -57,6 +61,7 @@
             --mandir=/usr/share/man \
             --with-shared           \
             --without-debug         \
+            --without-normal        \
             --enable-pc-files       \
             --enable-widec</userinput></screen>
 
@@ -78,6 +83,14 @@
       </varlistentry>
 
       <varlistentry>
+        <term><parameter>--without-normal</parameter></term>
+        <listitem>
+          <para>This switch disables building and installing most static libraries.
+          </para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
         <term><parameter>--enable-pc-files</parameter></term>
         <listitem>
           <para>This switch generates and installs .pc files for pkg-config.
@@ -119,12 +132,13 @@
 <screen><userinput remap="install">for lib in ncurses form panel menu ; do
     rm -vf                    /usr/lib/lib${lib}.so
     echo "INPUT(-l${lib}w)" > /usr/lib/lib${lib}.so
-    ln -sfv lib${lib}w.a      /usr/lib/lib${lib}.a
     ln -sfv ${lib}w.pc        /usr/lib/pkgconfig/${lib}.pc
-done
+done</userinput></screen>
 
-ln -sfv libncurses++w.a /usr/lib/libncurses++.a</userinput></screen>
 
+<!--    ln -sfv lib${lib}w.a      /usr/lib/lib${lib}.a -->
+<!--ln -sfv libncurses++w.a /usr/lib/libncurses++.a</userinput></screen>-->
+
     <para>Finally, make sure that old applications that look for
     <filename class="libraryfile">-lcurses</filename> at build time are still
     buildable:</para>
@@ -131,9 +145,9 @@
 
 <screen><userinput remap="install">rm -vf                     /usr/lib/libcursesw.so
 echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so
-ln -sfv libncurses.so      /usr/lib/libcurses.so
-ln -sfv libncursesw.a      /usr/lib/libcursesw.a
-ln -sfv libncurses.a       /usr/lib/libcurses.a</userinput></screen>
+ln -sfv libncurses.so      /usr/lib/libcurses.so</userinput></screen>
+<!--ln -sfv libncursesw.a      /usr/lib/libcursesw.a
+ln -sfv libncurses.a       /usr/lib/libcurses.a</userinput></screen>-->
 
     <para>If desired, install the Ncurses documentation:</para>
 
Index: chapter06/readline.xml
===================================================================
--- chapter06/readline.xml	(revision 10874)
+++ chapter06/readline.xml	(working copy)
@@ -56,7 +56,9 @@
 
     <para>Prepare Readline for compilation:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr --docdir=/usr/share/doc/readline-&readline-version;</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --disable-static \
+            --docdir=/usr/share/doc/readline-&readline-version;</userinput></screen>
 
     <para>Compile the package:</para>
 
Index: chapter06/util-linux.xml
===================================================================
--- chapter06/util-linux.xml	(revision 10874)
+++ chapter06/util-linux.xml	(working copy)
@@ -72,6 +72,7 @@
             --disable-runuser    \
             --disable-pylibmount \
             --without-python     \
+            --disable-static     \
             --without-systemd    \
             --without-systemdsystemunitdir</userinput></screen>
 
Index: chapter06/xz.xml
===================================================================
--- chapter06/xz.xml	(revision 10874)
+++ chapter06/xz.xml	(working copy)
@@ -46,7 +46,9 @@
 
     <para>Prepare Xz for compilation with:</para>
 
-<screen><userinput remap="configure">./configure --prefix=/usr --docdir=/usr/share/doc/xz-&xz-version;</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --disable-static \
+            --docdir=/usr/share/doc/xz-&xz-version;</userinput></screen>
 
     <para>Compile the package:</para>
 
Index: chapter06/zlib.xml
===================================================================
--- chapter06/zlib.xml	(revision 10874)
+++ chapter06/zlib.xml	(working copy)
@@ -41,6 +41,10 @@
   <sect2 role="installation">
     <title>Installation of Zlib</title>
 
+    <para>Prevent the static library from being installed:</para>
+
+<screen><userinput remap="pre">sed -i '/cp.*STATICLIB/,+1d' Makefile.in</userinput></screen>
+
     <para>Prepare Zlib for compilation:</para>
 
 <screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>


More information about the lfs-dev mailing list