glibc-inst.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <sect2>
  2. <title>Installation of Glibc</title>
  3. <para>Before starting to install glibc, you must cd into the
  4. glibc-&glibc-version; directory and unpack glibc-linuxthreads inside
  5. the glibc-&glibc-version; directory, not in /usr/src as you normally
  6. would do.</para>
  7. <para>This package is known to behave badly when you have changed its
  8. default optimization flags (including the -march and -mcpu options). Glibc
  9. is best left alone. Therefore, if you have defined any environment variables
  10. that override default optimizations, such as CFLAGS and CXXFLAGS, we
  11. recommend unsetting or modifying them when building Glibc. You have
  12. been warned.</para>
  13. <para>Basically, compiling Glibc in any other way than the book suggests
  14. is putting your system at very high risk.</para>
  15. <para>We'll start by applying a patch to Glibc that fixes a few
  16. things:</para>
  17. <itemizedlist>
  18. <listitem><para>It converts all occurrences of <emphasis>$(PERL)</emphasis>
  19. to <emphasis>/usr/bin/perl</emphasis> in the
  20. <filename>malloc/Makefile</filename> file. This is done because Glibc
  21. can't autodetect the location of perl because the Perl package hasn't been
  22. installed yet.</para></listitem>
  23. <listitem><para>It replaces all occurrences of <emphasis>root</emphasis>
  24. with <emphasis>0</emphasis> in the <filename>login/Makefile</filename>
  25. file. This is done because Glibc itself isn't installed yet and therefore
  26. username to userid resolving isn't working yet, so a
  27. <userinput>chown root file</userinput> will fail, however it'll work fine
  28. if you use the numeric IDs (such as <userinput>chown 0
  29. file</userinput>).</para></listitem>
  30. <listitem><para>Lastly, the patch also fixes a problem that causes
  31. statically linked binaries to crash that were linked against Glibc-2.2
  32. libraries. This patch is only needed temporarily because we have static
  33. programs in <filename class="directory">/static/bin</filename> that might
  34. be linked against an older Glibc version (the one from the host
  35. distribution). We will install Glibc again at the end of this chapter to
  36. remove this patch so you'll have a pristine Glibc as the developers
  37. intended it.</para></listitem>
  38. </itemizedlist>
  39. <para><screen><userinput>patch -Np1 -i ../glibc-&glibc-patch-version;.patch</userinput></screen></para>
  40. <para>Glibc will check for the <filename>/etc/ld.so.conf</filename> file
  41. and abort with an error if the file is missing, so we create it.</para>
  42. <para><screen><userinput>touch /etc/ld.so.conf</userinput></screen></para>
  43. <para>It is recommended by the Glibc installation documentation to build
  44. Glibc outside of the source directory in a dedicated directory. Let's
  45. create such a directory and make it our CWD (Current Working
  46. Directory).</para>
  47. <para><screen><userinput>mkdir ../glibc-build &amp;&amp;
  48. cd ../glibc-build &amp;&amp;</userinput></screen></para>
  49. <para>Next, configure Glibc.</para>
  50. <para><screen><userinput>../glibc-&glibc-version;/configure --prefix=/usr \
  51. &nbsp;&nbsp;&nbsp;&nbsp;--disable-profile --enable-add-ons \
  52. &nbsp;&nbsp;&nbsp;&nbsp;--libexecdir=/usr/bin</userinput></screen></para>
  53. <para>During the configure stage you will see the following warning:</para>
  54. <blockquote><screen>configure: warning:
  55. *** These auxiliary programs are missing or too old: msgfmt
  56. *** some features will be disabled.
  57. *** Check the INSTALL file for required versions.</screen></blockquote>
  58. <para>The missing msgfmt (from the gettext package which we will install
  59. later in this chapter) won't cause any problems. msgfmt is used to generate
  60. the binary translation files that are used to make your system talk in a
  61. different language. Because these translation files have already been
  62. generated for you, there is no need for msgfmt. You'd only need msgfmt if
  63. you change the translation source files (the <filename>*.po</filename>
  64. files in the <filename class="directory">po</filename> subdirectory) which
  65. would require you to re-generate the binary files.</para>
  66. <para>The meaning of the configure switches are:</para>
  67. <itemizedlist>
  68. <listitem><para><userinput>--disable-profile:</userinput> This disables the
  69. building of libraries with profiling information. This command may be
  70. omitted if you plan to do profiling.</para></listitem>
  71. <listitem><para><userinput>--enable-add-ons:</userinput> This enables the
  72. add-on that we install with Glibc, linuxthreads</para></listitem>
  73. <listitem><para><userinput>--libexecdir=/usr/bin:</userinput> This will
  74. cause the pt_chown program to be installed in the /usr/bin
  75. directory.</para></listitem>
  76. </itemizedlist>
  77. <para>Because Glibc hasn't been installed yet, one of the tests that was
  78. run by the configure script failed. This test is supposed to test gcc to
  79. determine whether or not a cross-compiler is installed. However, Glibc
  80. needs to be installed already to run this test. Since the test failed, the
  81. configure script automatically assumed we do have a cross-compiler. So,
  82. we have to override that assumption by explicitly telling Glibc we're not
  83. cross-compiling.</para>
  84. <para><screen><userinput>echo "cross-compiling = no" &gt; configparms</userinput></screen></para>
  85. <para>We'll continue with compiling and installing Glibc. The Linuxthreads man
  86. pages are not going to be installed at this point because it requires a
  87. working Perl installation. We'll install Perl later on in this chapter,
  88. and the man pages will be installed when Glibc is installed for the second
  89. time at the end of this chapter.</para>
  90. <para><screen><userinput>make &amp;&amp;
  91. make install</userinput></screen></para>
  92. <para>Locales aren't installed by default so we install them now. Locales
  93. are used by Glibc to make your Linux system talk in a different language
  94. such as your native tongue.</para>
  95. <para><screen><userinput>make localedata/install-locales</userinput></screen></para>
  96. <para>An alternative to running <userinput>make
  97. localedata/install-locales</userinput> is to only install those locales
  98. which you need or want. This can be achieved using the localedef
  99. command. Information on this can be found in the INSTALL
  100. file in the glibc-&glibc-version; tree.</para>
  101. <para>To finish off the installation we'll reload Bash so it uses the new
  102. libnss files. This will get rid of the <emphasis>I have no name!</emphasis>
  103. message in the command prompt.</para>
  104. <para><screen><userinput>exec /static/bin/bash --login</userinput></screen></para>
  105. </sect2>