setting-environment.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <sect1 id="ch05-settingenviron">
  2. <title>Setting up the environment</title>
  3. <?dbhtml filename="settingenvironment.html" dir="chapter05"?>
  4. <para>While logged in as user <emphasis>lfs</emphasis>, issue the
  5. following commands to set up a good work environment:</para>
  6. <screen><userinput>cat &gt; ~/.bash_profile &lt;&lt; "EOF"</userinput>
  7. set +h
  8. umask 022
  9. LFS=/mnt/lfs
  10. LC_ALL=POSIX
  11. PATH=/tools/bin:$PATH
  12. export LFS LC_ALL PATH
  13. unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
  14. <userinput>EOF
  15. source ~/.bash_profile</userinput></screen>
  16. <para>The <userinput>set +h</userinput> command turns off
  17. <userinput>bash</userinput>'s hash function. Normally hashing is a useful
  18. feature: <userinput>bash</userinput> uses a hash table to remember the
  19. full pathnames of executable files to avoid searching the PATH time and time
  20. again to find the same executable. However, we'd like the new tools to be
  21. used as soon as they are installed. By switching off the hash function, our
  22. "interactive" commands (<userinput>make</userinput>,
  23. <userinput>patch</userinput>, <userinput>sed</userinput>,
  24. <userinput>cp</userinput> and so forth) will always use
  25. the newest available version during the build process.</para>
  26. <para>Setting the user file-creation mask to 022 ensures that newly created
  27. files and directories are only writable for their owner, but readable and
  28. executable for anyone.</para>
  29. <para>The LFS variable should of course be set to the mount point you
  30. chose.</para>
  31. <para>The LC_ALL variable controls the localization of certain programs,
  32. making their messages follow the conventions of a specified country. If your
  33. host system uses a version of Glibc older than 2.2.4,
  34. having LC_ALL set to something other than "POSIX" or "C" during this chapter
  35. may cause trouble if you exit the chroot environment and wish to return later.
  36. By setting LC_ALL to "POSIX" (or "C", the two are equivalent) we ensure that
  37. everything will work as expected in the chroot environment.</para>
  38. <para>We prepend <filename>/tools/bin</filename> to the standard PATH so
  39. that, as we move along through this chapter, the tools we build will get used
  40. during the rest of the building process.</para>
  41. <para>The CC, CXX, CPP, LD_LIBRARY_PATH and LD_PRELOAD environment variables all
  42. have the potential to cause havoc with our Chapter 5 toolchain. We therefore
  43. unset them to prevent any chance of this happening.</para>
  44. <para>Now, after sourcing the just-created profile, we're all set to begin
  45. building the temporary tools that will support us in later chapters.</para>
  46. </sect1>