4 @setfilename gllfsc-loongson3a-1.0.info
5 @settitle GNU/Linux-libre from source code for Loongson 3A
6 @c Comment the following if you want Letter format instead of A4 for
10 @c Book headers for PDF version
11 @setchapternewpage odd
12 @documentencoding UTF-8
15 This is edition 1.0 (last updated 31 July 2013) of
16 @cite{GNU/Linux-libre from source code for Loongson 3A}.
18 Copyright @copyright{} 2013 Christophe Jarry.
20 This document is based on the Chinese page
21 @url{http://zdbr.net.cn/download/Loongson64-@/2.0.htm}, which is
22 copyright @copyright{} 2009
23 @c Because TeX does not handle Chinese fonts automatically, we need to
31 His blog is on @url{http://youbest.cublog.cn}.
33 Various formats of this manual as well as its texinfo source are
35 @uref{http://cjarry.org/gnu-linux/gllfsc/}.
38 Permission is granted to copy, distribute and/or modify this document
39 under the terms of the GNU Free Documentation License, Version 1.3
40 or any later version published by the Free Software Foundation;
41 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
42 Texts. A copy of the license is included in the section entitled ``GNU
43 Free Documentation License''.
47 Computer instructions in this manual are free software: you can
48 redistribute them and/or modify them under the terms of the GNU
49 General Public License as published by the Free Software Foundation,
50 either version 3 of the License, or (at your option) any later
53 Those instructions are distributed in the hope that they will be
54 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
55 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56 GNU General Public License for more details.
58 You should have received a copy of the GNU General Public License
59 along with this manual. If not, see <http://www.gnu.org/licenses/>.
64 @c @setchapternewpage odd
67 @title GNU/Linux-libre from source code
68 @subtitle for Loongson 3A
69 @c @subtitle SUBTITLE-IF-ANY
70 @c @subtitle SECOND-SUBTITLE
71 @author Christophe Jarry
73 @c The following two commands
74 @c start the copyright page.
76 @vskip 0pt plus 1filll
82 @c Short table of contents
85 @c So the toc is printed at the start.
90 @top GNU/Linux-libre from source code for Loongson 3A
92 This manual describes how to build a GNU/Linux-libre system from
93 source for Loongson 3A processor.
99 * Introduction:: What this document is all about.
100 * Prerequisites:: Useful knowledge before proceeding.
101 * Preliminary Work:: Preparing the build.
102 * Building the Cross-Compilation Toolchain:: Building the cross-
103 compilation Toolchain.
104 * Building Cross-Compilation Tools:: Building the cross-compilation
106 * Building the Target System:: How to build the target system.
107 * Configuration Files:: Creating configuration files
108 needed by the new system.
109 * End:: Final things to do.
110 * Further Readings:: Websites useful to know more.
112 * GNU Free Documentation License:: Your rights and freedoms with the
114 * GNU General Public License:: Your rights and freedoms with the
120 @chapter Introduction
123 * GNU/Linux History:: A brief history of GNU/Linux.
124 * Purpose of this Document:: What this document is all about.
128 @node GNU/Linux History
129 @section GNU/Linux History
132 * GNU:: Presentation of the GNU project
133 * HURD:: Presentation of the HURD
134 * Linux:: Presentation of the kernel Linux
135 * Linux-libre:: Presentation of the kernel Linux-libre
136 * References:: Where to get more information
142 @acronym{GNU} (GNU's Not Unix) is a project launched by Richard
143 Stallman in 1984 with the goal of building an entirely free operating
144 system compatible with Unix@footnote{See
145 @uref{http://en.wikipedia.org/wiki/Unix}}. ``Free'' here means ``free
146 as in freedom''. In this context, a free operating system is an
147 operating system you can use and share in freedom. A core part of his
148 motivation is given in the GNU
149 Manifesto@footnote{@uref{http://www.gnu.org/gnu/manifesto.html}}:
152 I consider that the Golden Rule requires that if I like a program I
153 must share it with other people who like it. Software sellers want to
154 divide the users and conquer them, making each user agree not to share
155 with others. I refuse to break solidarity with other users in this
156 way. I cannot in good conscience sign a nondisclosure agreement or a
157 software license agreement. For years I worked within the Artificial
158 Intelligence Lab to resist such tendencies and other inhospitalities,
159 but eventually they had gone too far: I could not remain in an
160 institution where such things are done for me against my will.
162 So that I can continue to use computers without dishonor, I have
163 decided to put together a sufficient body of free software so that I
164 will be able to get along without any software that is not free. I
165 have resigned from the AI Lab to deny MIT any legal excuse to prevent
166 me from giving GNU away.
169 A program is free software if the program's user has the four
174 The freedom to run the program, for any purpose (freedom 0).
177 The freedom to study how the program works, and change it so it does
178 her computing as she wishes (freedom 1). Access to the source code is
179 a precondition for this.
182 The freedom to redistribute copies so she can help her neighbor
186 The freedom to distribute copies of her modified versions to others
187 (freedom 3). By doing this she can give the whole community a chance
188 to benefit from her changes. Access to the source code is a
189 precondition for this.
192 One of the most popular free software license is the GNU General
194 GPL@footnote{@uref{http://www.gnu.org/licenses/gpl.html}}).
196 The free software movement is supported by the Free Software
197 Foundation (FSF@footnote{@uref{http://www.fsf.org}}).
203 The @acronym{HURD} is an acronym for @acronym{HIRD} (HURD of
204 interfaces representing depth) of Unix-replacing daemons. It is the
205 GNU project's replacement for the Unix kernel. It is a collection of
206 servers that run on the Mach microkernel to implement file systems,
207 network protocols, file access control, and other features that are
208 implemented by the Unix kernel or similar kernels (such as Linux).
210 The purpose of the GNU HURD is to improve the user's freedom on her
211 operating system by allowing her to either add or remove a feature of
212 the kernel on the fly.
214 From early on, the HURD was developed to use GNU Mach as the
215 microkernel. This was a technical decision made by Richard Stallman,
216 who thought it would speed up the work by saving a large part of
217 it. He has admitted that he was wrong about that.
219 Nevertheless, development of the HURD is increasingly attracting
220 developers and GNU/HURD systems exist and are usable.
226 Linux is a monolithic kernel created by Linus Torvalds in 1991. Linus
227 Torvalds initially wrote a terminal emulator, which he used to access
228 the large UNIX servers of his university. He wrote the program
229 specifically for the hardware he was using and independent of an
230 operating system because he wanted to use the functions of his new PC
231 with an 80386 processor. This later became the kernel Linux.
233 Initially, Torvalds first published the kernel Linux under its own
234 licence, which had a restriction on commercial activity.
236 In the notes for the first release of the kernel Linux, Torvalds lists
237 the GNU software that is required to run Linux:
240 Sadly, a kernel by itself gets you nowhere. To get a working system
241 you need a shell, compilers, a library etc. [...] Most of the tools
242 used with linux are GNU software and are under the GNU copyleft.
245 In 1992, he suggested releasing the kernel under the GNU General
246 Public License. He first announced this decision in the release notes
247 of version 0.12. In the middle of December 1992 he published version
248 0.99 using the GNU GPL.
250 The kernel Linux is now a contribution of many professionals and
251 volonteers around the world.
255 @subsection Linux-libre
257 Linux, the kernel developed and distributed by Linus Torvalds et al,
258 contains non-Free Software@footnote{For more information about the
259 presence of proprietary firmware in the kernel Linux, read
260 @uref{http://www.fsfla.org/svnwiki/anuncio/2010-03-Linux-2.6.33-libre.en}
262 @uref{http://www.gnu.org/@/distros/free-system-distribution-guidelines.html#nonfree-firmware}.},
263 i.e., software that does not respect your essential freedoms, and it
264 induces you to install additional non-Free Software that it doesn't
268 Linux-libre@footnote{@uref{http://www.fsfla.org/svnwiki/selibre/linux-libre/index.en.html}}
269 is a project to maintain and publish 100% Free distributions of Linux,
270 suitable for use in Free System Distributions@footnote{For a full list
271 of free as in freedom GNU/Linux distributions, see
272 @uref{http://www.gnu.org/distros}.}, removing software that is
273 included without source code, with obfuscated or obscured source code,
274 under non-Free Software licenses, that do not permit you to change the
275 software so that it does what you wish, and that induces or requires
276 you to install additional pieces of non-Free Software.
280 @subsection References
282 For more information on the GNU project and its relation with the
283 kernel Linux, you can read @uref{http://www.gnu.org/gnu/thegnuproject.html}
284 and @uref{http://www.gnu.org/gnu/gnu-linux-faq.html}.
286 For more information on the history of the HURD, I recommend you to
287 read @uref{http://www.h-online.com/open/features/GNU-HURD-Altered-visions-and-lost-promise@/-1030942.html}.
289 For more information on the HURD, read @uref{http://www.gnu.org/software/hurd}.
292 @node Purpose of this Document
293 @section Purpose of this Document
295 Lemote offered me a Yeeloong 8133 in late 2012. I wanted to adapt some
296 parts of gNewSense@footnote{@uref{http://www.gnewsense.org}} for MIPS
297 to this particular laptop. I also wanted to port the document I wrote
298 for Loongson 2F to Loongson 3A: GNU/Linux@footnote{Note: in this
299 document, we use the term ``GNU/Linux'' to name the entire system and
300 ``Linux'' to name the kernel. For more information, read
301 @uref{http://www.gnu.org/gnu/why-gnu-linux.html}.} Libre from Source
302 Code for Loongson 3A was born.
306 @chapter Prerequisites
309 * Definitions:: Definitions of important notions used to build the
311 * Commands:: Help on commands
319 * sysroot:: @option{sysroot}
320 * Toolchain:: What a Toolchain is.
321 * build host target:: Understanding the meaning of the
322 @option{build}-@option{host}-@option{target}
324 * FHS:: The Filesystem Hierarchy Standard.
329 @subsection @option{sysroot}
331 The traditional way of building a GNU/Linux operating system consists
332 on building a (cross-) compilation toolchain to build a temporary
333 operating system which in turn will be used to build the target
334 system@footnote{@pxref{Further Readings} section for more
335 details}. This requires almost as much time to complete the temporary
336 system as to build the target one. Using sysroot resolves this
339 From GCC installation manual, under Cross-Compiler-Specific Options:
343 @itemx --with-sysroot=@var{dir}
344 Tells GCC to consider @var{dir} as the root of a tree that contains (a
345 subset of) the root filesystem of the target operating system. Target
346 system headers, libraries and run-time object files will be searched
347 in there. More specifically, this acts as if
348 @option{--sysroot=@var{dir}} was added to the default options of the
349 built compiler. The specified directory is not copied into the
350 install tree, unlike the options @option{--with-headers} and
351 @option{--with-libs} that this option obsoletes. The default value,
352 in case @option{--with-sysroot} is not given an argument, is
353 @option{$@{gcc_tooldir@}/sys-root}. If the specified directory is a
354 subdirectory of @option{$@{exec_prefix@}}, then it will be found
355 relative to the GCC binaries if the installation tree is moved.
357 This option affects the system root for the compiler used to build
358 target libraries (which runs on the build system) and the compiler
359 newly installed with @code{make install}; it does not affect the
360 compiler which is used to build GCC itself.
365 @subsection Toolchain
368 Wikipedia@footnote{@uref{http://www.wikipedia.org/wiki/Toolchain}}:
371 In software, a toolchain is the set of programming tools that are used
372 to create a product (typically another computer program or system of
373 programs). The tools may be used in a chain, so that the output of
374 each tool becomes the input for the next, but the term is used widely
375 to refer to any set of linked development tools.
377 A simple software development toolchain consists of a text editor for
378 editing source code, a compiler and linker to transform the source
379 code into an executable program, libraries to provide interfaces to
380 the operating system, and a debugger.
384 @node build host target
385 @subsection @option{build}, @option{host} and @option{target}
387 During a cross-compilation, @option{build} @option{host} and
388 @option{target} are among the most used options: understanding the
389 precise meaning of those parameters is very important. We could define
393 @item @option{--build=@var{platform on which the program is
395 @item @option{--host=@var{platform on which the program will run}},
396 @item @option{--target=@var{platform for which the program will create
400 Let's use GCC as an example to explain the role of those three
403 During GCC compilation, we use:
405 @samp{./configure --build=@var{build-platform}
406 --host=@var{host-platform} --target=@var{target-platform} [various
407 compilation parameters]}
409 So in those configuration parameters:
413 @option{--build} provides the name of the platform currently running.
414 If we were using an Intel Pentium processor to compile the system, our
415 @var{build-platform} would be something like @samp{i686-pc-linux-gnu}.
417 If this parameter is not specified, it will be guessed automatically.
420 @option{--host} represents the type of machine we are going to run GCC
421 on after the compilation succeeds. During a cross-compilation this has
422 to be specified, because the current machine can not know which
423 architecture we wish to target. We want to produce executables to run
424 on @emph{Loongson}, but there is currently no way we can specify
425 @samp{Loongson} directly; because of this we specify
426 @samp{mips64el-unknown-linux-gnu}.
428 @option{--host} can also be left unspecified, in that case,
429 @var{host-platform} would automatically define itself as
430 @var{build-platform}, but this is not cross-compilation anymore.
433 when @option{--build} and @option{--host} are different, configuration
434 files will maintain the cross-compilation mode.
438 @option{--target} defines the system for which compiler tools will
441 @var{target-platform} parameter is useful only for a limited number of
442 programs. Although this parameter is often present when issuing
443 @samp{./configure --help}, hardly any packages will need it.
445 This parameter is only useful for performing tasks with different
446 platforms; for instance, executable files compiled for different
447 platforms can have a totally different code.
450 If we summarize, we have:
453 @item @var{build-platform}: automatically guessed from platform in
454 use; has to be specified if not guessed.
456 @item @var{host-platform}: if unspecified, automatically equals
457 @var{build-platform}. When @var{build-platform} and
458 @var{host-platform} values are identical, it is a local compilation;
459 otherwise it is a cross-compilation.
461 @item @var{target-platform}: defines the system for which compiler
462 tools will create output; it equals @var{host-platform} if
463 unspecified. GCC, binutils, and programs related to the platform's
464 instructions have this parameter; most programs do not use this
472 The Filesystem Hierarchy Standard (FHS) has been created to specify
473 the location and use of main directories on a GNU/Linux operating
474 system. Common commands, user data, libraries have to be put inside a
475 specific directory given in the standard. During the build process,
476 some commands are used to comply with FHS.
482 Because most commands are common for a regular Unix user, only
483 uncommon commands are explained in this document. If you do not
484 understand a command that is not explained, you can use the
485 documentation available on your computer; in a terminal, typing
486 @samp{man @var{command}} should give you enough information. For GNU
487 software, @samp{info @var{package}} can also give additional
490 To know more about command line, I suggest you read "Introduction to
491 the Command Line" which is available on
492 @uref{http://flossmanuals.net/command-line/}.
495 @node Preliminary Work
496 @chapter Preliminary Work
499 In order to complete the first steps of this chapter, you will need to
500 have root permissions.
504 * Build Partition Creation:: Creating a partition for the build.
505 * Build User Creation:: Creating a user account dedicated to
507 * Work Directory Creation:: Creating the parent directory for the
509 * Partition Mount:: Mounting the partition dedicated to the
511 * Useful Directories Creation:: Creating the directories for downloads
513 * User Switch:: Switching to the user dedicated to the
515 * Environment Variables Setup:: Setting up the environment variables
516 of the target system.
517 * Downloads:: Downloading needed packages and
519 * Final Preparations:: Preparing the system for the build.
523 @node Build Partition Creation
524 @section Build Partition Creation
526 To dedicate the partition @file{/dev/sda8} to the system build, and to
527 define the filesystem to be used for it as @samp{ext3}:
530 mke2fs -t ext3 /dev/sda8
533 Option @option{-t} is followed by the type of filesystem to be
534 used. The filesystem @samp{ext3} is used as it is one of the most
535 common filesystem used with the kernel Linux.
538 @node Build User Creation
539 @section Build User Creation
541 To create the builder group, user and password:
545 useradd -s /bin/bash -g gllfsc -m -k /dev/null gllfsc
551 Option @option{-s} (or @option{--shell}) is used to define the created
552 user's default shell, here @file{/bin/bash}.
555 Option @option{-g} (or @option{--gid}) is used to define the group
556 name or number of the created user's initial login group, here
560 Option @option{-m} (or @option{--create-home}) does create the user's
561 home directory if it does not exist (@file{/home/@var{username}}).
564 Option @option{-k} (or @option{--skel}) is used to define the skeleton
565 directory to be copied in the user's home directory, here
566 @file{/dev/null}. @file{/dev/null} is a special file which, in this
567 case, will give no skeleton at all to @command{useradd}.
571 @node Work Directory Creation
572 @section Work Directory Creation
574 To create the directory @file{/gllfsc} in which the system will be
578 export TARGET_DIR="/gllfsc"
579 mkdir -pv ${TARGET_DIR}
582 @samp{export TARGET_DIR="/gllfsc"} sets the value of the variable
583 @env{TARGET_DIR} to @file{/gllfsc}, the directory in which the system
587 @node Partition Mount
588 @section Mounting Partition
590 To mount the hard drive partition, for instance @file{/dev/sda8}, used
594 mount /dev/sda8 ${TARGET_DIR}
598 @node Useful Directories Creation
599 @section Creating Compilation and Download Directories
602 mkdir -pv ${TARGET_DIR}/{build,download}
603 chown -Rv gllfsc ${TARGET_DIR}
608 @section Switching to the Build User
610 To login as the user that will build the system:
616 With the command @command{su}, it is possible to change the user
617 ID. The option @option{-} provides an environment similar to what the
618 user would expect had the user logged in directly.
621 @node Environment Variables Setup
622 @section Setting up Required Environment Variables
624 @file{~/.bash_profile} is a personal initialization file that is read
625 when Bash is invoked as an interactive login shell (@file{~} is the
626 location of the user's home directory). To write the content of the
627 file @file{~/.bash_profile}:
630 cat > ~/.bash_profile << "EOF"
631 exec env -i HOME=${HOME} TERM=${TERM} PS1=${PS1} /bin/bash
635 The first line creates the file @file{~/.bash_profile} and opens it
636 for writing until @samp{@acronym{EOF}} (End Of File) is written in it.
638 The second line tells Bash to execute @file{/bin/bash} with the option
639 @option{-i} (or @option{--ignore-environment}) which will make Bash
640 start with an empty environment. Variables @env{HOME}, @env{TERM} and
641 @env{PS1} define respectively the home directory of the current user,
642 the terminal used and the primary prompt string displayed.
644 @file{~/.bashrc} is a personal initialization file that is read when
645 Bash is invoked as an interactive shell but not a login one. To write
646 the content of the file @file{~/.bashrc}:
649 cat > ~/.bashrc << "EOF"
652 alias make='make -j4'
653 export PS1='\[\e[35m\]\A-\W\[\e[00m\]\$ '
654 export TARGET_DIR=/gllfsc
656 export BUILD_DIR="${TARGET_DIR}/build"
657 export DOWNLOAD_DIR="${TARGET_DIR}/download"
658 export CROSS_HOST="$(echo $MACHTYPE |\
659 sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
660 export CROSS_TARGET="mips64el-unknown-linux-gnu"
663 export MARCH="loongson3a"
664 export PATH=${TARGET_DIR}/cross-tools/bin:/bin:/usr/bin
668 source ~/.bash_profile
671 @samp{set +h} tells Bash to not locate nor remember commands (hash) as
672 they are looked up for execution.
674 @samp{umask 022} sets Bash process' file creation mask to
675 @samp{022}. This results in permissions of `755' for those files.
677 @samp{alias make='make -j4'} tells Bash to replace every call of
678 @samp{make} by @samp{make -j4}. This makes full use of the four cores
679 available in the Loongson 3A to build packages by parallelizing tasks.
681 @samp{export PS1='\[\e[35m\]\A-\W\[\e[00m\]\$ '} sets the primary
682 prompt strings. The primary prompt strings are the strings you see
683 before the commands you type in the terminal. The part @samp{\A-\W}
684 means that the time, in 24-hour HH:MM format and the basename of
685 @env{$PWD} will be displayed separated by a `-', as in
686 @samp{19:33-bin}. The part @samp{\$} adds a dollar sign at the end,
687 @samp{\[\e[35m\]} colors the strings in purple and @samp{\[\e[00m\]}
688 gets the original color back. For other colors, you can browse
689 @uref{http://en.wikipedia.org/wiki/ANSI_escape_code}.
691 @env{LC_ALL} is a macro used to define a single locale to overwrite
692 other @env{LC_*} and @env{LANG} environment variables so that
693 language, numeric values, time and other locale-dependant values have
694 all the same value. It is set to the standard POSIX locale.
696 @samp{export BUILD_DIR="$@{TARGET_DIR@}/build"} sets the environment
697 variable @env{BUILD_DIR} to the value of @samp{$@{TARGET_DIR@}/build}
698 which is @samp{/gllfsc/build} in this document.
700 The value of variable @env{CROSS_HOST} equals the value of variable
701 @env{MACHTYPE} of the current machine (for instance
702 @samp{i686-pc-linux-gnu}) modulo the second word, which is replaced by
703 @samp{cross} (i.e. @samp{i686-cross-linux-gnu}).
705 The value of variable @env{CROSS_TARGET} equals the value of variable
706 @env{MACHTYPE} of the machine for which the system is built (i.e.
707 @samp{mips64el-unknown-linux-gnu}).
709 The variable @env{MABI} defines the @acronym{ABI} (Application Binary
710 Interface) for which the system will be built. @option{-mabi} is an
711 option of GCC. n32/64 are for 64-bit CPUs only. 64 has 64-bit pointers
712 and long integers, whereas n32 has 32-bit pointers and long integers.
714 The variable @env{MARCH} defines the architecture for which the system
715 will be built. @option{-march} is an option of @acronym{GCC} (GNU
716 Compiler Collection).
718 The variable @env{PATH} contains a colon-separated list of directories
719 in which the shell looks for commands. The shell will first look for
720 commands in @file{$@{TARGET_DIR@}/cross-tools/bin}, then, if the
721 command was not found, in @file{/bin} and finally in @file{/usr/bin}.
723 @command{unset} command removes the variable associated, here
724 @env{CFLAGS} and @env{CXXFLAGS}. Those variables are used by GCC as
725 extra flags given to the C compiler and the C++ compiler
728 Finally @samp{source ~/.bash_profile} reads and executes the content
729 of the file @file{~/.bash_profile}.
736 * Packages Download:: List of packages to be downloaded.
737 * Patches Download:: List of patches to be downloaded.
741 @node Packages Download
742 @subsection Downloading Packages
744 The packages listed below are those used in this document. You can try
745 other versions but you will need a recent version of Binutils, GCC and
746 the kernel Linux in order to build GLLFSC for Loongson 3A.
748 Download those files under @env{$@{DOWNLOAD_DIR@}} (which is
749 @file{/gllfsc/download} in this document).
754 Autoconf: @uref{http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz}.
757 Automake: @uref{http://ftpmirror.gnu.org/automake/automake-1.14.tar.gz}.
758 @c @uref{http://ftpmirror.gnu.org/automake/automake-1.13.1.tar.gz}.
761 Bash: @uref{http://ftpmirror.gnu.org/bash/bash-4.2.tar.gz}.
764 Binutils: @uref{http://ftpmirror.gnu.org/binutils/binutils-2.23.2.tar.bz2}.
765 @c @uref{http://ftpmirror.gnu.org/binutils/binutils-2.23.1.tar.bz2}.
768 Bison: @uref{http://ftpmirror.gnu.org/bison/bison-2.7.tar.gz}.
769 @c @uref{http://ftpmirror.gnu.org/bison/bison-2.5.tar.bz2}.
772 Bootscripts: @uref{http://ftp.cross-lfs.org/pub/clfs/conglomeration/bootscripts@/-cross-lfs/bootscripts-cross-lfs-2.0.0.tar.xz}.
773 @c @uref{http://ftp.cross-lfs.org/pub/clfs/conglomeration/bootscripts-@/cross-lfs/bootscripts-cross-lfs-1.2-pre11.tar.bz2}.
776 Bzip2: @uref{http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz}.
779 Coreutils: @uref{http://ftpmirror.gnu.org/coreutils/coreutils-8.19.tar.xz}.
780 @c @uref{http://ftpmirror.gnu.org/coreutils/coreutils-8.21.tar.xz} fails.
783 DHCPCD: @uref{http://roy.marples.name/downloads/dhcpcd/dhcpcd-6.0.2.tar@/.bz2}.
784 @c @uref{http://roy.marples.name/downloads/dhcpcd/dhcpcd-5.99.3.tar@/.bz2}.
787 Diffutils: @uref{http://ftpmirror.gnu.org/diffutils/diffutils-3.2.tar.gz}.
790 E2fsprogs: @uref{http://downloads.sourceforge.net/e2fsprogs/e2fsprogs-1.42.8.tar@/.gz}.
791 @c @uref{http://downloads.sourceforge.net/e2fsprogs/e2fsprogs-1.42.7.tar@/.gz}.
794 File: @uref{ftp://ftp.astron.com/pub/file/file-5.14.tar.gz}.
795 @c @uref{ftp://ftp.astron.com/pub/file/file-5.12.tar.gz}.
798 Findutils: @uref{http://ftpmirror.gnu.org/findutils/findutils-4.4.2.tar.gz}.
801 Flex: @uref{http://downloads.sourceforge.net/flex/flex-2.5.37.tar.bz2}.
804 Gawk: @uref{http://ftpmirror.gnu.org/gawk/gawk-4.1.0.tar.gz}.
805 @c @uref{http://ftpmirror.gnu.org/gawk/gawk-4.0.2.tar.gz}.
808 GCC: @uref{http://ftpmirror.gnu.org/gcc/gcc-4.7.3/gcc-4.7.3.tar.bz2}.
809 @c 4.8.1 gives the following error message at `make`:
810 @c /usr/include/bits/resource.h:137: error: declaration does not declare anything
811 @c ../../gcc-4.8.1/gcc/system.h:448: error: new declaration 'char* strstr(const char*, const char*)'
812 @c @uref{http://ftpmirror.gnu.org/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2}.
815 Gettext: @uref{http://ftpmirror.gnu.org/gettext/gettext-0.18.3.tar.gz}.
816 @c @uref{http://ftpmirror.gnu.org/gettext/gettext-0.18.2.tar.gz}.
819 Glibc: @uref{http://ftpmirror.gnu.org/glibc/glibc-2.16.0.tar.bz2}.
820 @c fails to generate localedef, see
821 @c http://sourceware.org/bugzilla/show_bug.cgi?id=14624
822 @c @uref{http://ftpmirror.gnu.org/glibc/glibc-2.13.tar.bz2}.
825 Glibc-Ports: @uref{http://ftpmirror.gnu.org/glibc/glibc-ports-2.16.0.tar.bz2}.
826 @c @uref{http://ftpmirror.gnu.org/glibc/glibc-ports-2.13.tar.bz2}.
829 Gmp: @uref{http://ftpmirror.gnu.org/gmp/gmp-5.1.2.tar.bz2}.
830 @c @uref{http://ftpmirror.gnu.org/gmp/gmp-5.0.5.tar.bz2}.
833 Grep: @uref{http://ftpmirror.gnu.org/grep/grep-2.14.tar.xz}.
836 Groff: @uref{http://ftpmirror.gnu.org/groff/groff-1.22.2.tar.gz}.
837 @c @uref{http://ftpmirror.gnu.org/groff/groff-1.22.1.tar.gz}.
840 Gzip: @uref{http://ftpmirror.gnu.org/gzip/gzip-1.6.tar.gz}.
841 @c @uref{http://ftpmirror.gnu.org/gzip/gzip-1.5.tar.gz}.
844 Iana-Etc: @uref{http://sethwklein.net/iana-etc-2.30.tar.bz2}.
847 Inetutils: @uref{http://ftpmirror.gnu.org/inetutils/inetutils-1.9.1.tar.gz}
848 @c Iputils: @uref{http://www.skbuff.net/iputils/iputils-s20071127.tar.bz2}.
849 @c @uref{http://www.skbuff.net/iputils/iputils-s20121221.tar.bz2}.
850 @c @uref{http://www.skbuff.net/iputils/iputils-s20101006.tar.bz2}.
851 @c depends on sysfs headers.
854 Iproute2: @uref{http://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-3.10.0@/.tar.bz2}
855 @c @uref{http://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-3.7.0@/.tar.bz2}
858 Kbd: @uref{http://ftp.altlinux.org/pub/people/legion/kbd/kbd-1.15.5.tar.gz}.
859 @c @uref{http://ftp.altlinux.org/pub/people/legion/kbd/kbd-1.15.3.tar.gz}.
862 Kmod: @uref{http://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-14.tar.gz}.
863 @c @uref{http://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-12.tar.gz}.
866 Less: @uref{http://www.greenwoodsoftware.com/less/less-458.tar.gz}.
867 @c @uref{http://www.greenwoodsoftware.com/less/less-451.tar.gz}.
870 Libtool: @uref{http://ftpmirror.gnu.org/libtool/libtool-2.4.tar.gz}.
873 Linux-Libre @footnote{The kernel Linux is shipped with proprietary
874 firmware. The version called Linux-Libre exists without them, it is
875 available for download at
876 @uref{http://www.fsfla.org/svnwiki/selibre/linux-libre/}.}.
877 @c @uref{http://linux-libre.fsfla.org/pub/linux-libre/releases/3.5.4-gnu@//linux-libre-3.5.4-gnu.tar.bz2}.
880 M4: @uref{http://ftpmirror.gnu.org/m4/m4-1.4.16.tar.bz2}.
883 Make: @uref{http://ftpmirror.gnu.org/make/make-3.82.tar.bz2}.
886 Man-Pages: @uref{http://www.kernel.org/pub/linux/docs/man-pages/Archive/man-pages-@/3.52.tar.bz2}.
887 @c @uref{http://www.kernel.org/pub/linux/docs/man-pages/Archive/man-pages-@/3.46.tar.bz2}.
890 Man: @uref{http://primates.ximian.com/~flucifredi/man/man-1.6g.tar.gz}.
893 Mpc: @uref{http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz}.
896 Mpfr: @uref{http://www.mpfr.org/mpfr-3.1.1/mpfr-3.1.2.tar.bz2}.
897 @c @uref{http://www.mpfr.org/mpfr-3.1.1/mpfr-3.1.1.tar.bz2}.
900 Nano: @uref{http://ftpmirror.gnu.org/nano/nano-2.3.2.tar.gz}
901 @c @uref{http://ftpmirror.gnu.org/nano/nano-2.3.1.tar.gz}
904 Ncurses: @uref{ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz}.
907 Patch: @uref{http://ftpmirror.gnu.org/patch/patch-2.7.1.tar.bz2}.
910 Procps: @uref{http://procps.sourceforge.net/procps-3.2.8.tar.gz}.
913 Psmisc: @uref{http://sourceforge.net/projects/psmisc/files/psmisc/psmisc-22.20.tar@/.gz/download}.
916 Readline: @uref{http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz}.
919 Rsyslog: @uref{http://rsyslog.com/files/download/rsyslog/rsyslog-5.8.6.tar.gz}.
920 @c @uref{http://rsyslog.com/files/download/rsyslog/rsyslog-7.2.5.tar.gz}.
921 @c has too many dependencies
924 Sed: @uref{http://ftpmirror.gnu.org/sed/sed-4.2.2.tar.bz2}.
925 @c @uref{http://ftpmirror.gnu.org/sed/sed-4.2.1.tar.bz2}.
928 Shadow: @uref{http://pkg-shadow.alioth.debian.org/releases/shadow-4.1.4.3.tar.bz2}.
929 @c Requires automake 1.11.5 and autoconf 2.69:
930 @c @uref{http://pkg-shadow.alioth.debian.org/releases/shadow-4.1.5.1.tar@/.bz2}.
933 Sysvinit: @uref{http://download.savannah.gnu.org/releases/sysvinit/sysvinit-2.88dsf@/.tar.bz2}.
936 Tar: @uref{http://ftpmirror.gnu.org/tar/tar-1.26.tar.bz2}.
939 Texinfo: @uref{http://ftpmirror.gnu.org/texinfo/texinfo-5.1.tar.gz}.
940 @c @uref{http://ftpmirror.gnu.org/texinfo/texinfo-4.13a.tar.gz}.
943 Udev: @uref{ftp://ftp.kernel.org/pub/linux/utils/kernel/hotplug/udev-175.tar.gz}.
944 @c @uref{http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-182.tar.bz2}.
945 @c troubles with blkid
948 Util-Linux: @uref{http://www.kernel.org/pub/linux/utils/util-linux/v2.19/util-@/linux-2.19.1.tar.bz2}.
949 @c requires PAM headers
950 @c @uref{http://www.kernel.org/pub/linux/utils/util-linux/v2.22/util-linux-2.22.tar.bz2}.
953 XZ-Utils: @uref{http://tukaani.org/xz/xz-5.0.5.tar.bz2}.
954 @c @uref{http://tukaani.org/xz/xz-5.0.4.tar.bz2}.
957 Zlib: @uref{http://www.zlib.net/zlib-1.2.8.tar.gz}.
958 @c @uref{http://sourceforge.net/projects/libpng/files/zlib/1.2.7/zlib-1.2.7.tar@/.bz2/download}.
962 @node Patches Download
963 @subsection Downloading Patches
965 Patches and configuration files location:
969 @uref{http://cjarry.org/gnu-linux/gllfsc/gllfsc-loongson3a-1.0-@/patches.tar.gz}. After
970 having downloaded this file under @env{$@{DOWNLOAD_DIR@}}, execute
971 the following commands to extract its content:
974 pushd ${DOWNLOAD_DIR}
975 tar xvf gllfsc-loongson3a-1.0-patches.tar.gz
981 @uref{http://dev.lemote.com/cgit/linux-official.git/commit/?h=linux-3.6@/&id=94fe1f0a7d2e3042fa7fadfd15da71b9d0c11809}
982 describes the changes to be made to the kernel in order to add support
983 for Chinese fonts in console. The patch applies to Linux 3.6.
984 Be aware though that applying this patch to the kernel may make
985 characters that are both non-@acronym{CJK} (Chinese Japanese Korean)
986 and non-ASCII unreadable (accented letters, cyrillic, etc.).
990 @uref{http://microcai.gsalex.net/old/archives/2011/01/fbcon_UNICODE_font_support.html}
991 is useful for users who want support for @acronym{CJK} (Chinese
992 Japanese Korean) characters under the (non-graphical) terminal. It
993 gives access to a git@footnote{@uref{http://git-scm.com/}} repository
994 with kernel patches@footnote{The patches to use with version 3.5 of
995 the kernel are the first four on
996 @uref{http://repo.or.cz/w/linux-2.6/cjktty.git/shortlog/refs/heads/3.5-utf8}.}
997 that permit direct rendering of UTF-8 characters under the framebuffer
998 environment. Be aware though that applying those CJK patches to the
999 kernel may make characters that are both non-CJK and non-ASCII
1000 unreadable (accented letters, cyrillic, etc.).
1003 @uref{http://www.fsfla.org/svn/fsfla/software/linux-libre/lemote/gnewsense/tags/@/3.9.0-gnu_0loongsonlibre/100gnu+freedo.patch}
1004 @footnote{@uref{http://www.fsfla.org/svn/fsfla/software/linux-libre/lemote/gnewsense/tags/@/2.6.36-libre-lemote_0lxo/100gnu+freedo.patch}
1005 if you choose version 2.6.36 of the kernel.}
1006 this patch adds a picture of a GNU beside Freedo, Freedo being the
1007 mascot of Linux-Libre. The image can be seen on
1008 @uref{http://www.fsfla.org/svnwiki/selibre/linux-libre/100gnu+freedo}.
1012 @node Final Preparations
1013 @section Final Preparations
1016 * Target Filesystem Hierarchy Creation:: Creating the directories of
1018 * Needed Files Creation:: Creating files for needed
1019 user, groups and log.
1023 @node Target Filesystem Hierarchy Creation
1024 @subsection Target Filesystem Hierarchy Creation
1028 mkdir -pv bin boot dev {etc/,}opt home lib mnt
1029 mkdir -pv proc media/{floppy,cdrom} sbin srv sys
1030 mkdir -pv var/{lock,log,mail,run,spool}
1031 mkdir -pv var/{opt,cache,lib/{misc,locate},local}
1032 install -dv -m 0750 root
1033 install -dv -m 1777 {var/,}tmp
1034 mkdir -pv usr/{,local/}{bin,include,lib,sbin,src}
1035 mkdir -pv usr/{,local/}share/{doc,info,locale,man}
1036 mkdir -pv usr/{,local/}share/{misc,terminfo,zoneinfo}
1037 mkdir -pv usr/{,local/}share/man/man{1..8}
1038 for dir in usr{,/local}; do
1039 ln -sv share/{man,doc,info} $dir
1043 ln -svf lib usr/lib64
1044 ln -svf lib usr/lib32
1050 The command @samp{install -dv -m 1777 @{var/,@}tmp} creates the
1051 directories @file{var/tmp} and @file{tmp} with the permissions to
1052 read, write and execute for everyone. The '1' in @samp{1777} is the
1053 sticky bit which allows deletion of the file or directory having this
1054 attribute only for the owner of the file or directory.
1056 The command @samp{ln -svf lib lib64} creates a symbolic link (option
1057 @option{-s}) with the name @file{lib64} which will point to
1061 @node Needed Files Creation
1062 @subsection Creating needed user, groups and log files
1065 cat > ${TARGET_DIR}/etc/passwd << "EOF"
1066 root::0:0:root:/root:/bin/bash
1070 The file @file{/etc/passwd} contains one line for each user account,
1071 with seven fields delimited by colons. These fields are:
1078 optional encrypted password;
1087 user name or comment field;
1090 user home directory;
1093 optional user command interpreter.
1098 cat > ${TARGET_DIR}/etc/group << "EOF"
1118 The file @file{/etc/group} is a text file which defines the groups on
1119 the system. There is one entry per line, with the following format:
1120 @samp{group_name:password:GID:user_list}.
1124 touch ${TARGET_DIR}/var/run/utmp \
1125 ${TARGET_DIR}/var/log/{btmp,lastlog,wtmp}
1126 chmod -v 664 ${TARGET_DIR}/var/run/utmp \
1127 ${TARGET_DIR}/var/log/lastlog
1131 @node Building the Cross-Compilation Toolchain
1132 @chapter Building the Cross-Compilation Toolchain
1134 In this chapter, the cross-compilation toolchain is built as well as
1135 core components of the target system. Those will then be used to build
1139 * Target Linux-Header:: Linux-Header for target system.
1140 * Cross Binutils:: Binutils for cross-compilation.
1141 * Cross GCC:: GCC for cross-compilation (C support only).
1142 * Target glibc:: glibc for target system.
1143 * Cross GCC CXX:: GCC for cross-compilation (C and C++ support).
1147 @node Target Linux-Header
1148 @section Target Linux-Header
1150 In this document, the kernel used is the one modified by Lemote to
1151 support Loongson 3A. It is planned to merge the changes made by Lemote
1152 into the official kernel maintained by Linus Torvalds. At the time of
1153 writing, this merge has not been made.
1156 # 5 hours mostly to get the kernel from git
1158 # The following command takes about 5 hours to complete
1159 # with a high band width internet connection
1161 git clone git://dev.lemote.com/linux-official.git
1162 # The following command takes about 30 minutes to complete
1163 # with a high band width internet connection
1165 #git clone git://dev.lemote.com/linux-3A.git
1166 wget http://linux-libre.fsfla.org/pub/linux-libre/releases/3.9-gnu/deblob-{3.9,check}
1167 #wget http://linux-libre.fsfla.org/pub/linux-libre/releases/2.6.36-gnu/deblob-{2.6.36,check}
1171 # About 60 minutes for the following command
1172 ../deblob-3.9 --force
1173 # About 45 minutes for the following command
1174 #../deblob-2.6.36 --force
1176 # About 2 minutes for the following one (1.1G)
1177 tar -cf linux-3.9-loongson3a-deblobbed.tar linux-official
1178 #tar -cf linux-2.6.36-21-loongson3a-deblobbed.tar linux-3A
1182 make ARCH=mips headers_check
1183 make ARCH=mips INSTALL_HDR_PATH=dest headers_install
1184 cp -rv dest/include/* ${TARGET_DIR}/usr/include
1186 rm -rf linux-official deblob*
1187 #rm -rf linux-3A deblob*
1191 @samp{5 hours} is the time it takes to build the package on Lemote
1192 Yeeloong with a Loongson 3A processor. For this particular package, it
1193 incudes the time required to pull the source from git.
1195 The command @samp{make mrproper} cleans the sources.
1197 We need to specify @samp{ARCH=mips} as we are cross-compiling.
1200 @node Cross Binutils
1201 @section Cross Binutils
1203 GNU Binutils (GNU binary utilities) is a collection of programs for
1204 manipulating binaries.
1209 tar xf ${DOWNLOAD_DIR}/binutils-2.23.2.tar.bz2 -C ${BUILD_DIR}
1210 pushd $BUILD_DIR/binutils-2.23.2
1211 mkdir -pv ../binutils-build
1212 cd ../binutils-build
1214 ../binutils-2.23.2/configure \
1215 --prefix=${TARGET_DIR}/cross-tools \
1216 --build=${CROSS_HOST} \
1217 --host=${CROSS_HOST} \
1218 --target=${CROSS_TARGET} \
1219 --enable-64-bit-bfd \
1220 --with-sysroot=${TARGET_DIR} \
1226 cp -v ../binutils-2.23.2/include/libiberty.h \
1227 ${TARGET_DIR}/usr/include
1229 rm -rf binutils-build
1230 rm -rf binutils-2.23.2
1234 @samp{CC="gcc"} and @samp{AR="ar"} are flags that tell the
1235 @file{configure} script to use the local commands @command{gcc} as the
1236 C compiler and @command{ar} as the program that handles archives.
1238 @option{--prefix=$@{TARGET_DIR@}/cross-tools} tells the configure
1239 script to install architecture-independant files in
1240 @file{$@{TARGET_DIR@}/cross-tools}.
1242 The option @option{--enable-64-bit-bfd} enables 64 bit for
1243 @acronym{BFD} (the Binary File Descriptor).
1245 @option{--with-sysroot=@env{$@{TARGET_DIR@}}} tells Binutils to
1246 consider @env{$@{TARGET_DIR@}} as the root of a tree that contains (a
1247 subset of) the root filesystem of the target operating system. Target
1248 system headers, libraries and run-time object files will be searched
1251 The @option{--enable-nls} option enables Native Language Support
1252 (NLS), which lets Binutils output diagnostics in languages other than
1253 American English. Native Language Support is enabled by default if not
1254 doing a canadian cross build. The @option{--disable-nls} option
1257 The option @option{--enable-shared} is used to build shared versions
1258 of libraries, if shared libraries are supported on the target
1259 platform. Use @option{--disable-shared} to build only static
1262 @c cp -v ../binutils-2.22/include/libiberty.h \
1263 @c ${TARGET_DIR}/usr/include
1267 @section Cross GCC (C support only)
1269 GCC is the GNU compiler collection. It can compile many languages, of
1270 which only C and C++ will be enabled in this document.
1272 In this section, we build a minimal GCC in order to build glibc.
1275 to build GMP (a GCC dependency), you need a version of GCC different
1276 from 4.3.2 on you system@footnote{@uref{http://gmplib.org/#STATUS}}:
1280 GCC 4.3.2 miscompiles GMP on 64-bit machines; please use a different
1281 gcc version (e.g., gcc 4.3.1 and gcc 4.3.3 both work properly). We
1282 have not been able to find any workaround for this gcc bug.
1283 Unfortunately, Debian 5.0 has decided to stay with this trouble gcc
1284 version, resulting in that many users strike this bug.
1287 I recommend installing @samp{gcc-4.4} on gNewSense Parkes to avoid
1292 tar xf ${DOWNLOAD_DIR}/gcc-4.7.3.tar.bz2 -C ${BUILD_DIR}
1293 pushd ${BUILD_DIR}/gcc-4.7.3
1294 tar xf ${DOWNLOAD_DIR}/gmp-5.1.2.tar.bz2
1296 tar xf ${DOWNLOAD_DIR}/mpc-1.0.1.tar.gz
1298 tar xf ${DOWNLOAD_DIR}/mpfr-3.1.2.tar.bz2
1300 mkdir -pv ../gcc-build
1302 ../gcc-4.7.3/configure \
1303 --prefix=${TARGET_DIR}/cross-tools \
1304 --build=${CROSS_HOST} \
1305 --host=${CROSS_HOST} \
1306 --target=${CROSS_TARGET} \
1307 --with-sysroot=${TARGET_DIR} \
1308 --disable-multilib \
1313 --enable-languages=c \
1314 --with-abi=${MABI} \
1315 --with-mpfr-include="${BUILD_DIR}/gcc-4.7.3/mpfr/src" \
1316 --with-mpfr-lib="${BUILD_DIR}/gcc-build/mpfr/src/.libs"
1318 make all-target-libgcc
1320 make install-target-libgcc
1327 @option{--disable-multilib} specifies that multiple target libraries
1328 to support different target variants@footnote{Such as different ABI,
1329 for instance n32 and 64.}, calling conventions, etc@:. should not be
1330 built. The default is to build a predefined set of them.
1332 @option{--with-newlib} specifies that @samp{newlib} is being used as
1333 the target C library.
1335 @option{--disable-threads} specifies that threading support should be
1338 @option{--enable-languages=c} specifies that only the C compiler and
1339 its runtime libraries should be built.
1341 @c --with-abi=${MABI}
1343 @c --with-mpfr-include="${BUILD_DIR}/gcc-4.7.3/mpfr/src" \
1344 @c --with-mpfr-lib="${BUILD_DIR}/gcc-build/mpfr/src/.libs"
1345 @c to avoid error: libmpfr not found or uses a different ABI (including static vs shared).
1347 GCC provides a low-level runtime library, @file{libgcc.a} or
1348 @file{libgcc_s.so.1} on some platforms. GCC generates calls to
1349 routines in this library automatically, whenever it needs to perform
1350 some operation that is too complicated to emit inline code for. This
1351 is built with @samp{make all-target-libgcc} and installed with
1352 @samp{make install-target-libgcc}
1356 @section Target glibc
1358 Glibc is the GNU C library. It provides macros, type definitions, and
1359 functions for tasks like string handling, mathematical computations,
1360 input/output processing, memory allocation and several other operating
1365 tar xf ${DOWNLOAD_DIR}/glibc-2.16.0.tar.bz2 -C ${BUILD_DIR}
1366 pushd ${BUILD_DIR}/glibc-2.16.0
1367 tar xf ${DOWNLOAD_DIR}/glibc-ports-2.16.0.tar.bz2
1368 mv -v glibc-ports-2.16.0 ports
1369 sed -i.orig "s/\ -lgcc_eh\|\ -lgcc_s//g" Makeconfig
1370 patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.16.0-cross_hacks-2.patch
1371 echo "" > ports/sysdeps/mips/mips64/n64/Makefile
1372 echo "" > ports/sysdeps/mips/mips64/n32/Makefile
1373 echo "" > ports/sysdeps/mips/mips32/Makefile
1374 sed -i "/default) machine=/s/n32/${MABI}/g" \
1375 ports/sysdeps/mips/preconfigure
1376 mkdir -pv ../glibc-build
1379 cat > config.cache << EOF
1380 libc_cv_c_cleanup=yes
1381 libc_cv_slibdir=/lib
1384 cat > configparms << EOF
1385 install_root=${TARGET_DIR}
1390 CC="${CROSS_TARGET}-gcc -march=${MARCH} -mabi=${MABI}" \
1391 AR="${CROSS_TARGET}-ar" \
1392 RANLIB="${CROSS_TARGET}-ranlib" \
1393 ../glibc-2.16.0/configure \
1395 --libexecdir=/usr/lib/glibc \
1396 --build=${CROSS_HOST} \
1397 --host=${CROSS_TARGET} \
1401 --enable-kernel=2.6.36 \
1403 --with-binutils=${TARGET_DIR}/cross-tools/bin \
1404 --with-headers=${TARGET_DIR}/usr/include \
1405 --cache-file=config.cache
1407 make # to be run twice?
1411 #make localedata/install-locales
1412 # fails with (localedef patch does not fix the following):
1413 #....../bin/sh: /gllfsc/build/glibc-build/locale/localedef-native: not found
1414 #Giving up installing locales for now
1421 cat > ${TARGET_DIR}/etc/nsswitch.conf << "EOF"
1422 # Begin /etc/nsswitch.conf
1436 # End /etc/nsswitch.conf
1439 cat > ${TARGET_DIR}/etc/ld.so.conf << "EOF"
1440 # Begin /etc/ld.so.conf
1445 # End /etc/ld.so.conf
1449 @c @samp{sed -i.orig "s/\ -lgcc_eh\|\ -lgcc_s//g" Makeconfig}
1451 @file{glibc-2.16.0-cross_hacks-2.patch} is used to avoid the error
1452 @samp{/usr/bin/install: cannot remove `/usr/lib/libc.a': Permission
1455 Glibc uses @samp{n32} ABI by default with MIPS. To use @env{MABI}
1456 instead, we do the following:
1459 echo "" > ports/sysdeps/mips/mips64/n64/Makefile
1460 echo "" > ports/sysdeps/mips/mips64/n32/Makefile
1461 echo "" > ports/sysdeps/mips/mips32/Makefile
1462 sed -i "/default) machine=/s/n32/${MABI}/g" \
1463 ports/sysdeps/mips/preconfigure
1467 Contents of the files above.
1469 cat mips64/n64/Makefile
1470 # `long double' is a distinct type we support.
1471 long-double-fcts = yes
1473 ifeq ($(filter -mabi=64,$(CC)),)
1477 cat mips64/n32/Makefile
1478 # `long double' is a distinct type we support.
1479 long-double-fcts = yes
1481 ifeq ($(filter -mabi=n32,$(CC)),)
1486 ifeq ($(filter -mabi=32,$(CC)),)
1490 grep 'default)' preconfigure
1492 default) machine=mips/mips64/n32 mips_config_abi=n32 ;;
1496 The file @file{config.cache} is used to attribute values to variables
1497 of the configure script.
1499 @samp{libc_cv_forced_unwind=yes} is used to avoid the error message
1500 @samp{error: forced unwind support is required}.
1502 @samp{libc_cv_c_cleanup=yes} is used to avoid the error message
1503 @samp{error: the compiler must support C cleanup handling}.
1505 @samp{libc_cv_slibdir=/lib} defines @file{/lib} as the directory in
1506 which the C library of the target system will be installed, instead of
1507 @file{/lib64} or @file{/lib32}.
1509 You can install glibc somewhere other than where you configured it to
1510 go by setting the @code{install_root} variable on the command line for
1511 @samp{make install}. The value of this variable is prepended to all
1512 the paths for installation. This is useful when setting up a chroot
1513 environment or preparing a binary distribution. The directory should
1514 be specified with an absolute file name.
1516 Files listed in @samp{install-lib} are installed in the directory
1517 specified by @samp{libdir} in @file{configparms} or @file{Makeconfig}.
1521 CC="${CROSS_TARGET}-gcc -march=${MARCH} -mabi=${MABI}" \
1522 AR="${CROSS_TARGET}-ar" \
1523 RANLIB="${CROSS_TARGET}-ranlib"
1526 @samp{CC="$@{CROSS_TARGET@}-gcc -march=$@{MARCH@} -mabi=$@{MABI@}"}
1527 sets @code{CC} to the cross-compiler for the target's architecture,
1528 processor and ABI we configured the library for. @code{AR} and
1529 @code{RANLIB} are set to cross-compiling versions of @code{ar} and
1530 @code{ranlib} as the native tools are not configured to work with
1531 object files for the target we configured for.
1533 @option{--prefix=/usr} tells the @file{configure} script to install
1534 glibc in the @file{/usr} directory of the target system.
1536 @c @option{--libexecdir=/usr/lib/glibc} tells the configure script to
1537 @c install glibc executables inside @file{/usr/lib/glibc}.
1539 Unlike previous builds, @option{--host} now equals
1540 @env{$@{CROSS_TARGET@}} instead of @env{$@{CROSS_HOST@}}. This is
1541 because we are building the glibc version that the target system will
1542 use. We won't have to build it later.
1544 Profiling can be of help to optimize a program by analysing memory
1545 use, the usage of particular instructions, etc. Option
1546 @option{--disable-profile} is used to disable this.
1548 Option @option{--enable-add-ons} is used to enable all the add-on
1549 packages in the main source directory, which includes the glibc-ports
1550 used to support the MIPS architecture.
1552 The option @option{--with-tls} tells the configure script to use
1553 @acronym{TLS} (thread-local storage). Thread-local storage is a
1554 computer programming method that uses memory local to a thread.
1556 The @samp{2.6.36} parameter given to option @option{--enable-kernel}
1557 describes the smallest version of the Linux kernel the generated
1558 library is expected to support. The higher the version number is, the
1559 less compatibility code is added, and the faster the code gets.
1561 Option @option{--with-__thread} enables threads in glibc.
1563 The option @option{--with-binutils=$@{TARGET_DIR@}/cross-tools/bin}
1564 tells the @file{configure} script to use the binutils (assembler and
1565 linker) built in the cross-compilation toolchain process.
1567 @option{--with-headers=$@{TARGET_DIR@}/usr/include} indicates the
1568 location of the kernel Linux' headers.
1570 @option{--cache-file=config.cache} specifies the file in which cache
1571 variables are listed for @file{configure}.
1573 @c @samp{make localedata/install-locales} configures all locales that are
1574 @c supported by glibc.
1576 The file @file{$@{TARGET_DIR@}/etc/nsswitch.conf} contains the
1577 configuration of @acronym{NSS} (Name Service Switch). NSS is a facility
1578 in Unix-like operating systems that provides a variety of sources for
1579 common configuration databases and name resolution mechanisms. These
1580 sources include local operating system files (such as
1581 @file{/etc/passwd}, @file{/etc/group}, and @file{/etc/hosts}), the
1582 Domain Name System (DNS), the Network Information Service (NIS), and
1585 @c The timezone is defined for `Paris'.
1587 @c Purpose of the file @file{$@{TARGET_DIR@}/etc/ld.so.conf}
1591 @section Cross GCC (C and C++ support)
1593 In this section, we build a complete cross-compiler with support for C
1597 # 3 hours and 30 minutes
1598 tar xf ${DOWNLOAD_DIR}/gcc-4.7.3.tar.bz2 -C ${BUILD_DIR}
1599 pushd ${BUILD_DIR}/gcc-4.7.3
1600 tar xf ${DOWNLOAD_DIR}/gmp-5.1.2.tar.bz2
1602 tar xf ${DOWNLOAD_DIR}/mpc-1.0.1.tar.gz
1604 tar xf ${DOWNLOAD_DIR}/mpfr-3.1.2.tar.bz2
1606 mkdir -v ../gcc-build
1608 ../gcc-4.7.3/configure \
1609 --prefix=${TARGET_DIR}/cross-tools \
1610 --build=${CROSS_HOST} \
1611 --host=${CROSS_HOST} \
1612 --target=${CROSS_TARGET} \
1613 --with-sysroot=${TARGET_DIR} \
1616 --enable-__cxa_atexit \
1617 --disable-multilib \
1618 --with-abi=${MABI} \
1620 --enable-long-long \
1621 --enable-threads=posix \
1622 --enable-languages=c,c++ \
1623 --with-mpfr-include="${BUILD_DIR}/gcc-4.7.3/mpfr/src" \
1624 --with-mpfr-lib="${BUILD_DIR}/gcc-build/mpfr/src/.libs"
1625 make # to be run twice
1633 @option{--enable-__cxa_atexit} enables @code{__cxa_atexit}, rather
1634 than @code{atexit}, to register C++ destructors for local statics and
1635 global objects. This is essential for fully standards-compliant
1636 handling of destructors, but requires @code{__cxa_atexit} in libc.
1638 @option{--enable-c99} enables support for the C99 standard.
1640 @option{--enable-long-long} enables support for @code{long long int}
1643 @c @option{--enable-threads=posix}
1646 @node Building Cross-Compilation Tools
1647 @chapter Building the Cross-Compilation Tools
1650 * Cross File:: File for cross-compilation.
1651 * Cross Groff:: Groff for cross-compilation.
1652 * Cross Shadow:: Shadow for cross-compilation.
1653 * Cross M4:: M4 for cross-compilation.
1654 * Cross Ncurses:: Ncurses for cross-compilation.
1655 * Cross Cleaning:: Cleaning up the cross-compilation toolchain.
1662 The command @command{file} is used to determine the type of a file:
1663 text, executable or data.
1667 tar xf ${DOWNLOAD_DIR}/file-5.14.tar.gz -C ${BUILD_DIR}
1668 pushd ${BUILD_DIR}/file-5.14
1670 --prefix=${TARGET_DIR}/cross-tools
1682 Groff is the GNU version of the roff document formatting system which
1683 is used to produce man pages.
1685 You need G++ on your system to compile this program from source. Under
1686 gNewSense Parkes, try @samp{sudo apt-get install g++-4.4}.
1690 psselect (part of psutils) is needed for documentation in HTML (see
1691 @uref{http://cblfs.cross-lfs.org/index.php/PSUtils}).
1698 tar xf ${DOWNLOAD_DIR}/groff-1.22.2.tar.gz -C ${BUILD_DIR}
1699 pushd ${BUILD_DIR}/groff-1.22.2
1702 --prefix=${TARGET_DIR}/cross-tools \
1711 @samp{PAGE=A4} defines the default format of pages for printed output.
1713 @option{--without-x} disables the dependancy on the X window system.
1719 The package contains programs to handle users, groups and passwords in
1720 a secure way: passwords are encrypted.
1724 tar xf ${DOWNLOAD_DIR}/shadow-4.1.4.3.tar.bz2 -C ${BUILD_DIR}
1725 pushd ${BUILD_DIR}/shadow-4.1.4.3
1726 patch -Np1 -i ${DOWNLOAD_DIR}/shadow-4.1.4.3-sysroot_hacks-1.patch
1728 's/bindir)\/\$\$i/bindir)\/mips64el-unknown-linux-gnu-\$\$i/' \
1731 echo "shadow_cv_passwd_dir=${TARGET_DIR}/bin" > config.cache
1732 echo "ac_cv_func_lckpwdf=no" >> config.cache
1734 --prefix=${TARGET_DIR}/cross-tools \
1735 --sbindir=${TARGET_DIR}/cross-tools/bin \
1736 --sysconfdir=${TARGET_DIR}/etc \
1741 --program-prefix=${CROSS_TARGET}- \
1742 --cache-file=config.cache
1743 sed -i.orig "/PASSWD_PROGRAM/s/passwd/${CROSS_TARGET}-&/" config.h
1747 rm -rf shadow-4.1.4.3
1751 @c @samp{shadow_cv_passwd_dir=$@{TARGET_DIR@}/bin}
1752 @c @samp{ac_cv_func_lckpwdf=no}
1754 The patch @file{shadow-4.1.4.3-sysroot_hacks-1.patch} is used so that
1755 shadow can be built with the sysroot method. Because we use this
1756 patch, @samp{shadow_cv_passwd_dir=$@{TARGET_DIR@}/bin} and
1757 @samp{ac_cv_func_lckpwdf=no} have to be added in @file{config.cache}
1758 in order for the @file{configure} script not to test the
1759 functionalities associated.
1761 @c @option{--sbindir=$@{TARGET_DIR@}/cross-tools/bin}
1763 @c @option{--sysconfdir=$@{TARGET_DIR@}/etc}
1765 @option{--without-audit}, @option{--without-libpam} and
1766 @option{--without-selinux} disable support for auditing, @acronym{PAM}
1767 (Pluggable authentication modules) and @acronym{SELinux}
1768 (Security-Enhanced Linux). We do not need those extra features.
1770 @option{--program-prefix=$@{CROSS_TARGET@}-} prepends the value of
1771 @env{CROSS_TARGET} (that is @samp{mips64el-unknown-linux-gnu} in this
1772 document) to installed program names for cross-compilation.
1774 @c @samp{sed -i.orig "/PASSWD_PROGRAM/s/passwd/$@{CROSS_TARGET@}-&/"
1775 @c config.h} is used to avoid the error message
1781 Bison 2.5 requires M4 to be built.
1783 GNU M4 is a package containing an implementation of the m4 macro
1784 language. GNU M4 is used in GNU Autoconf' @file{configure} files.
1788 tar xf ${DOWNLOAD_DIR}/m4-1.4.16.tar.bz2 -C ${BUILD_DIR}
1789 pushd ${BUILD_DIR}/m4-1.4.16
1791 --prefix=${TARGET_DIR}/cross-tools
1803 GNU ncurses contains a library used to write text-based user
1804 interfaces in a terminal-independent manner.
1808 tar xf ${DOWNLOAD_DIR}/ncurses-5.9.tar.gz -C ${BUILD_DIR}
1809 pushd ${BUILD_DIR}/ncurses-5.9
1811 --prefix=${TARGET_DIR}/cross-tools \
1815 install -m755 progs/tic ${TARGET_DIR}/cross-tools/bin
1821 @option{--without-shared} is used to avoid building the whole library
1822 as only @command{tic} is installed.
1825 @node Cross Cleaning
1826 @section Cleaning up Cross-Compilation Toolchain
1828 In order to save some space, binaries and libraries of
1829 cross-compilation tools can be stripped out.
1832 incorrect cleaning arguments used against library files can lead to
1833 library files breaking. For this reason, be careful of the command
1834 arguments. If you are not comfortable with this, you can skip this
1835 section as it will have no effect on the process of building the
1841 pushd ${TARGET_DIR}/cross-tools
1842 strip --strip-all bin/*
1843 strip --strip-debug lib/*
1847 @option{--strip-all} removes all symbols. This command reduces the
1848 size of the @file{bin} directory's content from 29 MB to 12 MB.
1850 @option{--strip-debug} removes debugging symbols only. This command
1851 reduces the size of the @file{lib} directory's content from 21 MB to
1855 @node Building the Target System
1856 @chapter Building the Target System
1858 After having set up the cross-compilation toolchain and tools, the
1859 operating system for the target machine is built in this chapter.
1862 * Environment Setup:: Setting up the environment.
1863 * Man Pages:: Building Man Pages.
1864 * Zlib:: Building Zlib.
1865 * Binutils:: Building Binutils.
1866 * GMP:: Building GMP.
1867 * MPFR:: Building MPFR.
1868 * MPC:: Building MPC.
1869 * GCC:: Building GCC.
1870 * Sed:: Building Sed.
1871 * E2fsprogs:: Building E2fsprogs.
1872 * Coreutils:: Building Coreutils.
1873 * iana-etc:: Building iana-etc.
1875 * Bison:: Building Bison.
1876 * Ncurses:: Building Ncurses.
1877 * Procps:: Building Procps.
1878 * Libtool:: Building Libtool.
1879 * Readline:: Building Readline.
1880 * Autoconf:: Building Autoconf.
1881 * Automake:: Building Automake.
1882 * Bash:: Building Bash.
1883 * Bzip2:: Building Bzip2.
1884 * DHCPCD:: Building DHCPCD.
1885 * Diffutils:: Building Diffutils.
1886 * File:: Building File.
1887 * Findutils:: Building Findutils.
1888 * Flex:: Building Flex.
1889 * Gawk:: Building Gawk.
1890 * Gettext:: Building Gettext.
1891 * Grep:: Building Grep.
1892 * Groff:: Building Groff.
1893 * Gzip:: Building Gzip.
1894 * Inetutils:: Building Inetutils.
1895 * Iproute2:: Building Iproute2.
1896 * Kbd:: Building Kbd.
1897 * Kmod:: Building Kmod.
1898 * Less:: Building Less.
1899 * Make:: Building Make.
1900 * Man:: Building Man.
1901 * Nano:: Building Nano.
1902 * Patch:: Building Patch.
1903 * Psmisc:: Building Psmisc.
1904 * Rsyslog:: Building Rsyslog.
1905 * Shadow:: Building Shadow.
1906 * Sysvinit:: Building Sysvinit.
1907 * Tar:: Building Tar.
1908 * Texinfo:: Building Texinfo.
1909 * Udev:: Building Udev.
1910 * Util-Linux:: Building Util-Linux.
1911 * XZ-Utils:: Building XZ-Utils.
1912 * Bootscripts:: Building Bootscripts.
1913 * Kernel:: Building the Kernel.
1917 @node Environment Setup
1918 @section Setting up the Environment
1920 Because this chapter is about the build of the target system and not
1921 the build of the cross-compilation toolchain and tools anymore, we
1922 need to update some environment variables.
1924 For more convenience, we can set environment variables up in the
1925 @file{~/.bashrc} file, so that this setup is preserved when logging
1930 cat >> ~/.bashrc << EOF
1931 export CC="${CROSS_TARGET}-gcc -march=${MARCH} -mabi=${MABI}"
1932 export CXX="${CROSS_TARGET}-g++ -march=${MARCH} -mabi=${MABI}"
1933 export AR="${CROSS_TARGET}-ar"
1934 export AS="${CROSS_TARGET}-as"
1935 export RANLIB="${CROSS_TARGET}-ranlib"
1936 export LD="${CROSS_TARGET}-ld"
1937 export STRIP="${CROSS_TARGET}-strip"
1939 source ~/.bash_profile
1942 @env{CC} is the flag that indicates the C compiler to be used,
1943 @env{CXX} the C++ compiler, @env{AR} the archiver, @env{AS} the
1944 assembler, @env{RANLIB} the archives' index generator, @env{LD} the
1945 linker and @env{STRIP} the program for stripping.
1947 All the programs to be used are prefixed with
1948 @samp{$@{CROSS_TARGET@}-} in order to use the cross-compilation
1949 toolchain instead of the toolchain of the host.
1955 The man-pages package documents the kernel Linux and C library's
1956 interfaces that are used by user-space programs.
1960 tar xf ${DOWNLOAD_DIR}/man-pages-3.52.tar.bz2 -C ${BUILD_DIR}
1961 pushd ${BUILD_DIR}/man-pages-3.52
1962 #tar xf ${DOWNLOAD_DIR}/man-pages-3.46.tar.bz2 -C ${BUILD_DIR}
1963 #pushd ${BUILD_DIR}/man-pages-3.46
1964 make prefix=${TARGET_DIR}/usr install
1966 rm -rf man-pages-3.52
1967 #rm -rf man-pages-3.46
1971 The option @option{prefix=$@{TARGET_DIR@}/usr} is used to install the
1972 man pages on the target partition's @env{TARGET_DIR} instead of the
1973 @file{/usr} directory of the host.
1979 Zlib is a compression/decompression library.
1983 tar xf ${DOWNLOAD_DIR}/zlib-1.2.8.tar.gz -C ${BUILD_DIR}
1984 pushd ${BUILD_DIR}/zlib-1.2.8
1988 make prefix=${TARGET_DIR}/usr install
1989 # For FHS compatibility:
1990 #mv -v ${TARGET_DIR}/usr/lib/libz.so.* ${TARGET_DIR}/lib
1991 #ln -svf ../../lib/libz.so.1 ${TARGET_DIR}/usr/lib/libz.so
1997 In order to build zlib by cross-compilation, the flag @env{AR} has to
1998 be equal to @samp{$@{AR@}}.
2006 tar xf ${DOWNLOAD_DIR}/binutils-2.23.2.tar.bz2 -C ${BUILD_DIR}
2007 pushd ${BUILD_DIR}/binutils-2.23.2
2008 mkdir -pv ../binutils-build
2009 cd ../binutils-build
2010 ../binutils-2.23.2/configure \
2012 --build=${CROSS_HOST} \
2013 --host=${CROSS_TARGET} \
2014 --target=${CROSS_TARGET} \
2015 --enable-64-bit-bfd \
2019 make DESTDIR=${TARGET_DIR} tooldir=/usr install
2020 cp -v ../binutils-2.23.2/include/libiberty.h ${TARGET_DIR}/usr/include
2022 rm -rf binutils-build
2023 rm -rf binutils-2.23.2
2027 The option @option{--host} is now set to @env{CROSS_TARGET} because
2028 the host that will run this build will be the target system.
2030 @c @samp{make tooldir=/usr}
2031 @c @samp{make DESTDIR=$@{TARGET_DIR@} tooldir=/usr install}
2037 @acronym{GMP} (GNU multiple precision arithmetic library) is required
2042 tar xf ${DOWNLOAD_DIR}/gmp-5.1.2.tar.bz2 -C ${BUILD_DIR}
2043 pushd ${BUILD_DIR}/gmp-5.1.2
2045 --host=${CROSS_TARGET} \
2049 make DESTDIR=${TARGET_DIR} install
2050 rm -v ${TARGET_DIR}/usr/lib/lib{gmp,gmpxx,mp}.la
2056 The option @option{--enable-cxx} enables support for the C++ language.
2058 The files @file{$@{TARGET_DIR@}/usr/lib/lib@{gmp,gmpxx,mp@}.la} are
2059 removed to avoid the following error when building MPFR:
2060 @samp{/usr/lib/libgmp.so: could not read symbols: File in wrong
2067 GNU @acronym{MPFR} (Multiple Precision Floating-Point Reliably) is a
2068 portable C library for arbitrary-precision binary floating-point
2069 computation with correct rounding.
2073 tar xf ${DOWNLOAD_DIR}/mpfr-3.1.2.tar.bz2 -C ${BUILD_DIR}
2074 pushd ${BUILD_DIR}/mpfr-3.1.2
2076 --host=${CROSS_TARGET} \
2079 make DESTDIR=${TARGET_DIR} install
2080 rm -v ${TARGET_DIR}/usr/lib/libmpfr.la
2086 The file @file{$@{TARGET_DIR@}/usr/lib/libmpfr.la} is removed to
2087 avoid the following error when building MPC:
2088 @samp{/usr/lib/libmpfr.so: could not read symbols: File in wrong
2095 GNU @acronym{MPC} (Multiple Precision Complex Library) is a C library
2096 for the arithmetic of complex numbers with arbitrarily high precision
2097 and correct rounding of the result.
2101 tar xf ${DOWNLOAD_DIR}/mpc-1.0.1.tar.gz -C ${BUILD_DIR}
2102 pushd ${BUILD_DIR}/mpc-1.0.1
2104 --host=${CROSS_TARGET} \
2107 make DESTDIR=${TARGET_DIR} install
2118 # 3 hours and 30 minutes
2119 tar xf ${DOWNLOAD_DIR}/gcc-4.7.3.tar.bz2 -C ${BUILD_DIR}
2120 pushd ${BUILD_DIR}/gcc-4.7.3
2121 sed -i.orig 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
2122 sed -i.orig 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
2123 mkdir -v ../gcc-build
2125 ../gcc-4.7.3/configure \
2127 --libexecdir=/usr/lib \
2128 --build=${CROSS_HOST} \
2129 --host=${CROSS_TARGET} \
2130 --target=${CROSS_TARGET} \
2132 --enable-threads=posix \
2133 --enable-__cxa_atexit \
2135 --enable-long-long \
2136 --disable-multilib \
2137 --with-abi=${MABI} \
2138 --enable-clocale=gnu \
2139 --enable-languages=c,c++ \
2140 --disable-libstdcxx-pch
2142 make DESTDIR=${TARGET_DIR} install
2143 # For FHS compatibility:
2144 #ln -sv ../usr/bin/cpp ${TARGET_DIR}/lib
2145 ln -sv gcc ${TARGET_DIR}/usr/bin/cc
2153 # The following patch seems needless to me as it only replaces
2154 # {usr,}/lib32 with {usr,}/lib64 and we already have:
2155 # {usr,}/lib32 -> {usr,}/lib
2156 # {usr,}/lib64 -> {usr,}/lib
2157 #patch -Np1 -i ${DOWNLOAD_DIR}/gcc-4.6.0-pure64-1.patch
2160 @samp{sed -i.orig 's/install_to_$(INSTALL_DEST) //'
2161 libiberty/Makefile.in} is used as we already installed the library
2162 @file{libiberty.a} with Binutils.
2164 @c We use @samp{sed -i.orig 's@@\./fixinc\.sh@@-c true@@'
2165 @c gcc/Makefile.in} to avoid using fixincludes that may output errors if
2166 @c headers have been modified.
2168 Using @option{--enable-clocale=gnu} option ensures that the correct
2169 locale will automatically be chosen.
2171 Option @option{--disable-libstdcxx-pch} disables support for
2172 precompiled headers (PCH).
2174 The line @samp{ln -sv gcc $@{TARGET_DIR@}/usr/bin/cc} creates a
2175 symbolic link @file{cc} that points on @file{gcc}.
2181 GNU sed is a stream editor: it is used to perform basic text
2182 transformations on an input stream (a file or input from a pipeline).
2186 tar xf ${DOWNLOAD_DIR}/sed-4.2.2.tar.bz2 -C ${BUILD_DIR}
2187 pushd ${BUILD_DIR}/sed-4.2.2
2189 --build=${CROSS_HOST} \
2190 --host=${CROSS_TARGET} \
2194 make DESTDIR=${TARGET_DIR} install
2200 @c @option{--bindir=/bin} FHS?
2206 E2fsprogs is a package that contains tools to handle the ext2, ext3
2207 and ext4 filesystems.
2211 tar xf ${DOWNLOAD_DIR}/e2fsprogs-1.42.8.tar.gz -C ${BUILD_DIR}
2212 pushd ${BUILD_DIR}/e2fsprogs-1.42.8
2216 --build=${CROSS_HOST} \
2217 --host=${CROSS_TARGET} \
2219 --with-root-prefix="" \
2222 make DESTDIR=${TARGET_DIR} install
2223 make DESTDIR=${TARGET_DIR} install-libs
2224 rm -v ${TARGET_DIR}/usr/lib/lib{blkid,com_err,e2p,ext2fs,ss,uuid}.so
2225 ln -sv ../../lib/libblkid.so.1 ${TARGET_DIR}/usr/lib/libblkid.so
2226 ln -sv ../../lib/libcom_err.so.2 ${TARGET_DIR}/usr/lib/libcom_err.so
2227 ln -sv ../../lib/libe2p.so.2 ${TARGET_DIR}/usr/lib/libe2p.so
2228 ln -sv ../../lib/libext2fs.so.2 ${TARGET_DIR}/usr/lib/libext2fs.so
2229 ln -sv ../../lib/libss.so.2 ${TARGET_DIR}/usr/lib/libss.so
2230 ln -sv ../../lib/libuuid.so.1 ${TARGET_DIR}/usr/lib/libuuid.so
2232 rm -rf e2fsprogs-1.42.8
2236 @option{--with-root-prefix=""} is used to put e2fsprogs binaries
2237 inside @file{/sbin} instead of @file{@var{PREFIX}/sbin} which would be
2240 Option @option{--enable-elf-shlibs} enables e2fsprogs shared
2243 @samp{make DESTDIR=$@{TARGET_DIR@} install-libs} is used to install
2244 libraries, those are not installed with @samp{make
2245 DESTDIR=$@{TARGET_DIR@} install}.
2247 The sequence of commands that follows first removes symbolic links
2248 @file{$@{TARGET_DIR@}/usr/lib/lib@{@/blkid,com_err,e2p,ext2fs,ss,uuid@}.so}
2249 which point on abolute paths
2250 @file{/lib/lib@{blkid,com_err,e2p,ext2fs,ss,uuid@}.so}. In order to
2251 use the libraries of the target operating system, we need to symlink
2252 @file{$@{TARGET_DIR@}/usr/lib/lib@{blkid,com_err,e2p,ext2fs,ss,uuid@}.so}
2253 to their relative paths files.
2259 GNU coreutils (core utilities) includes the standard programs for text
2260 and file manipulation.
2262 On gNewSense Parkes, you need to install @file{xz-utils} to extract
2267 tar xf ${DOWNLOAD_DIR}/coreutils-8.19.tar.xz -C ${BUILD_DIR}
2268 pushd ${BUILD_DIR}/coreutils-8.19
2269 cat > config.cache << EOF
2270 fu_cv_sys_stat_statfs2_bsize=yes
2271 gl_cv_func_mbrtowc_incomplete_state=yes
2272 gl_cv_func_mbrtowc_nul_retval=yes
2273 gl_cv_func_mbrtowc_null_arg=yes
2274 gl_cv_func_mbrtowc_retval=yes
2275 gl_cv_func_btowc_eof=yes
2276 gl_cv_func_wcrtomb_retval=yes
2277 gl_cv_func_wctob_works=yes
2278 gl_cv_func_fstatat_zero_flag=yes
2281 --build=${CROSS_HOST} \
2282 --host=${CROSS_TARGET} \
2284 --enable-install-program=hostname \
2285 --enable-no-install-program=kill,uptime \
2286 --cache-file=config.cache
2288 make DESTDIR=${TARGET_DIR} install
2289 # For FHS compatibility:
2290 #mv -v ${TARGET_DIR}/usr/bin/{cat,chgrp,chmod,chown,cp,date} \
2292 #mv -v ${TARGET_DIR}/usr/bin/{dd,df,echo,false,hostname,ls,mkdir} \
2294 #mv -v ${TARGET_DIR}/usr/bin/{mv,pwd,rm,rmdir,stty,true,ln,uname} \
2296 #mv -v ${TARGET_DIR}/usr/bin/chroot ${TARGET_DIR}/usr/sbin
2297 #mv -v ${TARGET_DIR}/usr/bin/{[,basename,head,install,nice} \
2299 #mv -v ${TARGET_DIR}/usr/bin/{readlink,sleep,sync,test,touch} \
2301 #ln -svf ../../bin/install ${TARGET_DIR}/usr/bin
2303 rm -rf coreutils-8.19
2307 @c @samp{sed -i.orig '/strftime/s/\ LC_ALL//' man/help2man}
2309 The variables listed in the file @file{config.cache} are used in order
2310 to avoid that the @file{configure} script evaluate their values:
2311 otherwise the build may fail when cross-compiling.
2313 We use @option{--enable-install-program=hostname} to install the
2314 command @command{hostname} which is not built by default.
2316 We use @option{--enable-no-install-program=kill,uptime} in order not
2317 to install commands @command{kill} and @command{uptime}. Those
2318 commands will be installed by the package procps.
2324 The iana-etc package installs services and protocols using data from
2325 the Internet Assigned Numbers Authority (IANA).
2329 tar xf ${DOWNLOAD_DIR}/iana-etc-2.30.tar.bz2 -C ${BUILD_DIR}
2330 pushd ${BUILD_DIR}/iana-etc-2.30
2332 make DESTDIR=${TARGET_DIR} install
2334 rm -rf iana-etc-2.30
2344 tar xf ${DOWNLOAD_DIR}/m4-1.4.16.tar.bz2 -C ${BUILD_DIR}
2345 pushd ${BUILD_DIR}/m4-1.4.16
2346 sed -i.orig '/gets is a security hole/d' lib/stdio.in.h
2348 --build=${CROSS_HOST} \
2349 --host=${CROSS_TARGET} \
2352 make DESTDIR=${TARGET_DIR} install
2358 @samp{sed -i.orig '/gets is a security hole/d' lib/stdio.in.h} is used
2359 to fix the following error when issuing @samp{make}:
2360 @samp{./stdio.h:477:1: error: 'gets' undeclared here (not in a
2363 @c It deletes the following line in lib/stdio.in.h:
2364 @c _GL_WARN_ON_USE (gets, ``gets is a security hole - use fgets instead'');
2370 GNU bison parser generator.
2374 tar xf ${DOWNLOAD_DIR}/bison-2.7.tar.gz -C ${BUILD_DIR}
2375 pushd ${BUILD_DIR}/bison-2.7
2377 --build=${CROSS_HOST} \
2378 --host=${CROSS_TARGET} \
2380 echo '#define YYENABLE_NLS 1' >> config.h
2382 make DESTDIR=${TARGET_DIR} install
2388 @samp{echo '#define YYENABLE_NLS 1' >> config.h} is used to build
2389 @acronym{NLS} (native language support) inside bison.
2397 tar xf ${DOWNLOAD_DIR}/ncurses-5.9.tar.gz -C ${BUILD_DIR}
2398 pushd ${BUILD_DIR}/ncurses-5.9
2400 --build=${CROSS_HOST} \
2401 --host=${CROSS_TARGET} \
2407 --with-build-cc="gcc -D_GNU_SOURCE" \
2410 make DESTDIR=${TARGET_DIR} install
2411 # For FHS compatibility:
2412 #mv -v ${TARGET_DIR}/lib/lib{panel,menu,form,ncurses,ncurses++}w.a \
2413 # ${TARGET_DIR}/usr/lib
2414 #rm -v ${TARGET_DIR}/lib/lib{ncurses,menu,panel,form}w.so
2415 #ln -svf ../../lib/libncursesw.so.5 \
2416 # ${TARGET_DIR}/usr/lib/libncursesw.so
2417 #ln -svf ../../lib/libmenuw.so.5 ${TARGET_DIR}/usr/lib/libmenuw.so
2418 #ln -svf ../../lib/libpanelw.so.5 ${TARGET_DIR}/usr/lib/libpanelw.so
2419 #ln -svf ../../lib/libformw.so.5 ${TARGET_DIR}/usr/lib/libformw.so
2420 #for lib in curses ncurses form panel menu ; do
2421 # echo "INPUT(-l${lib}w)" > ${TARGET_DIR}/usr/lib/lib${lib}.so
2422 # ln -sfv lib${lib}w.a ${TARGET_DIR}/usr/lib/lib${lib}.a
2424 ln -sfv libncursesw.so ${TARGET_DIR}/lib/libncurses.so
2425 #ln -sfv libncursesw.so ${TARGET_DIR}/usr/lib/libcursesw.so
2426 #ln -sfv libncursesw.a ${TARGET_DIR}/usr/lib/libcursesw.a
2427 #ln -sfv libncurses++w.a ${TARGET_DIR}/usr/lib/libncurses++.a
2428 #ln -sfv ncursesw5-config ${TARGET_DIR}/usr/bin/ncurses5-config
2429 #ln -sfv ../../usr/share/terminfo ${TARGET_DIR}/usr/lib/terminfo
2435 Option @option{--enable-widec} enables wide characters support in
2438 @c Option @option{--without-debug}
2440 Option @option{--without-ada} disables support for the Ada programming
2441 language inside ncurses.
2443 @c Option @option{--with-build-cc="gcc -D_GNU_SOURCE"}
2445 @c Option @option{--libdir=/lib}
2449 for lib in curses ncurses form panel menu ; do
2450 echo "INPUT(-l${lib}w)" > ${TARGET_DIR}/usr/lib/lib${lib}.so
2451 ln -sfv lib${lib}w.a ${TARGET_DIR}/usr/lib/lib${lib}.a
2453 ln -sfv libncursesw.so ${TARGET_DIR}/usr/lib/libcursesw.so
2454 ln -sfv libncursesw.a ${TARGET_DIR}/usr/lib/libcursesw.a
2455 ln -sfv libncurses++w.a ${TARGET_DIR}/usr/lib/libncurses++.a
2456 ln -sfv ncursesw5-config ${TARGET_DIR}/usr/bin/ncurses5-config
2459 The commands above create symlinks from libraries without support for
2460 wide characters to libraries with support for them.
2464 The command @samp{ln -sfv libncursesw.so $@{TARGET_DIR@}/lib/libncurses.so}
2465 creates the symlink @file{libcurses.so} so that programs that do not
2466 know @file{libncursesw.so} can be linked against it.
2468 @c ln -sfv ../../usr/share/terminfo ${TARGET_DIR}/usr/lib/terminfo
2474 The procps package contains utilities that give information about
2475 processes using the @file{/proc} filesystem. The package includes the
2476 commands @command{ps}, @command{top}, @command{vmstat}, @command{w},
2477 @command{kill}, @command{free}, @command{slabtop}, and
2482 tar xf ${DOWNLOAD_DIR}/procps-3.2.8.tar.gz -C ${BUILD_DIR}
2483 pushd ${BUILD_DIR}/procps-3.2.8
2488 DESTDIR=${TARGET_DIR} \
2491 install="install -D" \
2498 Option @option{CPPFLAGS= } is used so that the target system's ncurses
2499 library will be used, default value would have been
2500 @option{-I/usr/include/ncurses}.
2502 Option @option{lib64=lib} makes the directory @file{/lib} the one
2503 where to put 64 bit libraries, default would be @file{/lib64}.
2505 Option @option{ldconfig= } is used in order not to use current host's
2508 Option @option{install="install -D"} is used so that all the files
2509 installed are owned by the current user. By default, all installed
2510 files are owned by root.
2516 GNU libtool is a generic library support script. It hides the
2517 complexity of using shared libraries behind a consistent, portable
2522 tar xf ${DOWNLOAD_DIR}/libtool-2.4.tar.gz -C ${BUILD_DIR}
2523 pushd ${BUILD_DIR}/libtool-2.4
2525 --build=${CROSS_HOST} \
2526 --host=${CROSS_TARGET} \
2529 make DESTDIR=${TARGET_DIR} install
2539 The GNU Readline library provides a set of functions for use by
2540 applications that allow users to edit command lines as they are typed
2545 tar xf ${DOWNLOAD_DIR}/readline-6.2.tar.gz -C ${BUILD_DIR}
2546 pushd ${BUILD_DIR}/readline-6.2
2548 --build=${CROSS_HOST} \
2549 --host=${CROSS_TARGET} \
2553 make DESTDIR=${TARGET_DIR} install
2554 make DESTDIR=${TARGET_DIR} install-doc
2555 # For FHS compatibility:
2556 #mv -v ${TARGET_DIR}/lib/lib{readline,history}.a ${TARGET_DIR}/usr/lib
2557 #rm -v ${TARGET_DIR}/lib/lib{readline,history}.so
2558 #ln -svf ../../lib/libreadline.so.6 \
2559 # ${TARGET_DIR}/usr/lib/libreadline.so
2560 #ln -svf ../../lib/libhistory.so.6 ${TARGET_DIR}/usr/lib/libhistory.so
2566 @c sed -i 's:^SHLIB_LIBS=:SHLIB_LIBS=-lncursesw:' support/shobj-conf
2572 GNU autoconf is an extensible package of M4 macros that produce shell
2573 scripts to automatically configure software source code
2574 packages. These scripts can adapt the packages to many kinds of
2575 UNIX-like systems without manual user intervention.
2579 tar xf ${DOWNLOAD_DIR}/autoconf-2.69.tar.gz -C ${BUILD_DIR}
2580 pushd ${BUILD_DIR}/autoconf-2.69
2582 --build=${CROSS_HOST} \
2583 --host=${CROSS_TARGET} \
2586 make DESTDIR=${TARGET_DIR} install
2588 rm -rf autoconf-2.69
2596 GNU automake is a tool for automatically generating @file{Makefile.in}
2597 files compliant with the GNU Coding
2598 Standards@footnote{@uref{http://www.gnu.org/prep/standards/}}.
2602 tar xf ${DOWNLOAD_DIR}/automake-1.14.tar.gz -C ${BUILD_DIR}
2603 pushd ${BUILD_DIR}/automake-1.14
2605 --build=${CROSS_HOST} \
2606 --host=${CROSS_TARGET} \
2609 make DESTDIR=${TARGET_DIR} install
2611 rm -rf automake-1.14
2619 GNU @acronym{Bash} (Bourne again shell) is an sh-compatible shell that
2620 incorporates useful features from the Korn shell (ksh) and C shell
2625 tar xf ${DOWNLOAD_DIR}/bash-4.2.tar.gz -C ${BUILD_DIR}
2626 pushd ${BUILD_DIR}/bash-4.2
2627 cat > config.cache << "EOF"
2628 ac_cv_func_mmap_fixed_mapped=yes
2629 ac_cv_func_strcoll_works=yes
2630 ac_cv_func_working_mktime=yes
2631 bash_cv_func_sigsetjmp=present
2632 bash_cv_getcwd_malloc=yes
2633 bash_cv_job_control_missing=present
2634 bash_cv_printf_a_format=yes
2635 bash_cv_sys_named_pipes=present
2636 bash_cv_ulimit_maxfds=yes
2637 bash_cv_under_sys_siglist=yes
2638 bash_cv_unusable_rtsigs=no
2639 gt_cv_int_divbyzero_sigfpe=yes
2642 --build=${CROSS_HOST} \
2643 --host=${CROSS_TARGET} \
2646 --cache-file=config.cache \
2647 --without-bash-malloc \
2648 --with-installed-readline
2651 DESTDIR=${TARGET_DIR} \
2652 htmldir=/usr/share/doc/bash-4.2 \
2654 ln -sv bash ${TARGET_DIR}/bin/sh
2660 The variables listed in the file @file{config.cache} are used in order
2661 to avoid that the @file{configure} script evaluate their values:
2662 otherwise the build may fail when cross-compiling.
2664 @c --bindir=/bin instead of /usr/bin, FHS?
2666 Option @option{--without-bash-malloc} tells the @file{configure}
2667 script not to use the @code{malloc} function shipped with
2668 Bash. Glibc's version will be used instead.
2670 Option @option{--with-installed-readline} tells the configure script
2671 to use the installed readline library instead of the one shipped with
2674 @c htmldir=/usr/share/doc/bash-4.2
2676 @samp{ln -sv bash $@{TARGET_DIR@}/bin/sh} creates a symlink @file{sh}
2683 Bzip2 is a package that contains utilities to compress and decompress
2684 files with a better original size/compressed size ratio than gzip.
2688 tar xf ${DOWNLOAD_DIR}/bzip2-1.0.6.tar.gz -C ${BUILD_DIR}
2689 pushd ${BUILD_DIR}/bzip2-1.0.6
2690 sed -i.orig -e "/^all:/s/ test//" Makefile
2691 sed -i -e 's:ln -s -f $(PREFIX)/bin/:ln -s :' Makefile
2693 -f Makefile-libbz2_so \
2703 PREFIX=${TARGET_DIR}/usr \
2705 cp -v bzip2-shared ${TARGET_DIR}/bin/bzip2
2706 cp -av libbz2.so* ${TARGET_DIR}/lib
2707 ln -sv ../../lib/libbz2.so.1.0 ${TARGET_DIR}/usr/lib/libbz2.so
2708 rm -v ${TARGET_DIR}/usr/bin/{bunzip2,bzcat,bzip2}
2709 ln -sv bzip2 ${TARGET_DIR}/bin/bunzip2
2710 ln -sv bzip2 ${TARGET_DIR}/bin/bzcat
2716 @samp{sed -i.orig -e "/^all:/s/ test//" Makefile} is used to skip
2717 tests when building.
2719 @samp{sed -i -e 's:ln -s -f $(PREFIX)/bin/:ln -s :' Makefile} is used
2720 in order to have relative path symlinks instead of absolute ones.
2722 Option @option{-f Makefile-libbz2_so} is used to build shared
2725 Flags @env{CC}, @env{AR} and @env{RANLIB} are used so that bzip2 is
2726 built using cross-compilation tools instead of the host's ones.
2728 @samp{make clean} is used to clean up temporary files.
2730 The second build commands are used to build static libraries.
2733 cp -v bzip2-shared ${TARGET_DIR}/bin/bzip2
2734 cp -av libbz2.so* ${TARGET_DIR}/lib
2735 ln -sv ../../lib/libbz2.so.1.0 ${TARGET_DIR}/usr/lib/libbz2.so
2736 rm -v ${TARGET_DIR}/usr/bin/{bunzip2,bzcat,bzip2}
2737 ln -sv bzip2 ${TARGET_DIR}/bin/bunzip2
2738 ln -sv bzip2 ${TARGET_DIR}/bin/bzcat
2745 DHCPCD is a wrapper for the @acronym{DHCP} (Dynamic Host Configuration
2746 Protocol) client daemon.
2750 tar xf ${DOWNLOAD_DIR}/dhcpcd-6.0.2.tar.bz2 -C ${BUILD_DIR}
2751 pushd ${BUILD_DIR}/dhcpcd-6.0.2
2753 --build=${CROSS_HOST} \
2754 --host=${CROSS_TARGET} \
2758 --dbdir=/var/lib/dhcpcd \
2759 --libexecdir=/usr/lib/dhcpcd
2761 make DESTDIR=${TARGET_DIR} install
2767 @c Option @option{--bindir=/sbin} is used to comply with FHS?
2768 @c @option{--sysconfdir=/etc} @file{/etc} instead of ?
2769 @c @option{--dbdir=/var/lib/dhcpcd} @file{/var/lib/dhcpcd} instead of?
2770 @c @option{--libexecdir=/usr/lib/dhcpcd} @file{/usr/lib/dhcpcd} instead of ?
2776 GNU Diffutils is a package of several programs related to finding
2777 differences between files.
2781 tar xf ${DOWNLOAD_DIR}/diffutils-3.2.tar.gz -C ${BUILD_DIR}
2782 pushd ${BUILD_DIR}/diffutils-3.2
2783 sed -i.orig '/gets is a security hole/d' lib/stdio.in.h
2785 --build=${CROSS_HOST} \
2786 --host=${CROSS_TARGET} \
2789 make DESTDIR=${TARGET_DIR} install
2791 rm -rf diffutils-3.2
2795 @samp{sed -i.orig '/gets is a security hole/d' lib/stdio.in.h} is used
2796 to fix the following error when issuing @samp{make}:
2797 @samp{./stdio.h:1012:1: error: 'gets' undeclared here (not in a
2800 @c It deletes the following line in lib/stdio.in.h:
2801 @c _GL_WARN_ON_USE (gets, ``gets is a security hole - use fgets instead'');
2809 tar xf ${DOWNLOAD_DIR}/file-5.14.tar.gz -C ${BUILD_DIR}
2810 pushd ${BUILD_DIR}/file-5.14
2812 --build=${CROSS_HOST} \
2813 --host=${CROSS_TARGET} \
2816 make DESTDIR=${TARGET_DIR} install
2826 The GNU Find Utilities are typically used to provide directory search
2827 and file locating capabilities.
2831 tar xf ${DOWNLOAD_DIR}/findutils-4.4.2.tar.gz -C ${BUILD_DIR}
2832 pushd ${BUILD_DIR}/findutils-4.4.2
2833 cat > config.cache << EOF
2834 gl_cv_func_wcwidth_works=yes
2835 gl_cv_header_working_fcntl_h=yes
2836 ac_cv_func_fnmatch_gnu=yes
2839 --build=${CROSS_HOST} \
2840 --host=${CROSS_TARGET} \
2842 --libexecdir=/usr/lib/locate \
2843 --localstatedir=/var/lib/locate \
2844 --cache-file=config.cache
2846 make DESTDIR=${TARGET_DIR} install
2847 # For FHS compatibility:
2848 #mv -v ${TARGET_DIR}/usr/bin/find ${TARGET_DIR}/bin
2849 #sed -i.orig 's@find:=${BINDIR}@find:=/bin@' \
2850 # ${TARGET_DIR}/usr/bin/updatedb
2852 rm -rf findutils-4.4.2
2856 @c --libexecdir=/usr/lib/locate
2857 @c --localstatedir=/var/lib/locate
2863 Flex is a tool for generating scanners. A scanner, sometimes called a
2864 tokenizer, is a program which recognizes lexical patterns in text.
2868 tar xf ${DOWNLOAD_DIR}/flex-2.5.37.tar.bz2 -C ${BUILD_DIR}
2869 pushd ${BUILD_DIR}/flex-2.5.37
2870 cat > config.cache << EOF
2871 ac_cv_path_M4="/usr/bin/m4"
2874 --build=${CROSS_HOST} \
2875 --host=${CROSS_TARGET} \
2877 --cache-file=config.cache
2879 make DESTDIR=${TARGET_DIR} install
2880 ln -sv libfl.a ${TARGET_DIR}/usr/lib/libl.a
2885 cat > ${TARGET_DIR}/usr/bin/lex << "EOF"
2887 exec /usr/bin/flex -l "$@"
2889 chmod -v 755 ${TARGET_DIR}/usr/bin/lex
2892 @file{config.cache} forces flex to use @file{/usr/bin/m4} instead of
2893 @file{/gllfsc/cross-tools/bin/m4} on the target machine.
2895 For compatibility issues, we create the symlink @file{libl.a}.
2897 We then create target system's @file{/usr/bin/lex} that will execute
2898 @command{flex} with option @option{-l} in order to behave with maximal
2899 compatibility like @command{lex}.
2902 @samp{sed -i.orig "s/-I@@includedir@@//g" Makefile.in} is used in
2903 order not to use host's headers in @file{/usr/include} during
2907 @c Variables @samp{ac_cv_func_malloc_0_nonnull=yes} and
2908 @c @samp{ac_cv_func_realloc_0_nonnull=yes} are used to get rid of
2909 @c error message: @samp{}.
2911 @c We use option @option{-fPIC} passed to the cross-compiler in order to
2912 @c generate position-independent code (PIC).
2918 GNU awk (Gawk) is a program used to select particular records in a
2919 file and perform operations upon them.
2923 tar xf ${DOWNLOAD_DIR}/gawk-4.1.0.tar.gz -C ${BUILD_DIR}
2924 pushd ${BUILD_DIR}/gawk-4.1.0
2926 '/check-recursive all-recursive/s/ check-for-shared-lib-support//' \
2927 extension/Makefile.in
2929 --build=${CROSS_HOST} \
2930 --host=${CROSS_TARGET} \
2932 --libexecdir=/usr/lib
2934 make DESTDIR=${TARGET_DIR} install
2940 The sed expression is used to avoid the error @samp{Building the
2941 extensions is not supported on this platform}.
2947 GNU gettext utilities are a set of tools that provides a framework to
2948 help packages produce multi-lingual messages.
2952 tar xf ${DOWNLOAD_DIR}/gettext-0.18.3.tar.gz -C ${BUILD_DIR}
2953 pushd ${BUILD_DIR}/gettext-0.18.3
2954 cat > config.cache << EOF
2955 am_cv_func_iconv_works=yes
2956 gl_cv_func_wcwidth_works=yes
2957 gt_cv_func_printf_posix=yes
2958 gt_cv_int_divbyzero_sigfpe=yes
2961 --build=${CROSS_HOST} \
2962 --host=${CROSS_TARGET} \
2964 --cache-file=config.cache
2966 #cp gettext-tools/gnulib-lib/.libs/libgettextlib.la{,i}
2967 #cp gettext-tools/src/.libs/libgettextsrc.la{,i}
2968 make DESTDIR=${TARGET_DIR} install
2970 rm -rf gettext-0.18.3
2974 @c cp gettext-tools/gnulib-lib/.libs/libgettextlib.la{,i} ?
2975 @c cp gettext-tools/src/.libs/libgettextsrc.la{,i} ?
2981 GNU @command{grep} command searches one or more input files for lines
2982 containing a match to a specified pattern.
2986 tar xf ${DOWNLOAD_DIR}/grep-2.14.tar.xz -C ${BUILD_DIR}
2987 pushd ${BUILD_DIR}/grep-2.14
2989 --build=${CROSS_HOST} \
2990 --host=${CROSS_TARGET} \
2993 --disable-perl-regexp
2995 make DESTDIR=${TARGET_DIR} install
3001 Option @option{--disable-perl-regexp} disables support of Perl-style
3002 regular expressions (regexp).
3010 tar xf ${DOWNLOAD_DIR}/groff-1.22.2.tar.gz -C ${BUILD_DIR}
3011 pushd ${BUILD_DIR}/groff-1.22.2
3014 --build=${CROSS_HOST} \
3015 --host=${CROSS_TARGET} \
3021 make prefix=${TARGET_DIR}/usr install
3022 ln -sv soelim ${TARGET_DIR}/usr/bin/zsoelim
3023 ln -sv eqn ${TARGET_DIR}/usr/bin/geqn
3024 ln -sv tbl ${TARGET_DIR}/usr/bin/gtbl
3030 The variables @env{TROFFBIN=troff} and @env{GROFFBIN=groff} tell
3031 @command{make} to use @command{troff} and @command{groff} commands
3032 installed in the @ref{Building Cross-Compilation Tools} to build
3035 The variable @env{GROFF_BIN_PATH} before @env{PATH} is checked for
3036 programs @command{groff} is calling (preprocessors, troff, and output
3037 devices). If not set, it defaults to the directory where the
3038 @file{groff} binary is located.
3040 The symlinks are used for compatibility.
3046 GNU Gzip is a data compression program.
3050 tar xf ${DOWNLOAD_DIR}/gzip-1.6.tar.gz -C ${BUILD_DIR}
3051 pushd ${BUILD_DIR}/gzip-1.6
3053 --build=${CROSS_HOST} \
3054 --host=${CROSS_TARGET} \
3058 make DESTDIR=${TARGET_DIR} install
3059 # For FHS compatibility:
3060 #mv -v ${TARGET_DIR}/bin/z{egrep,cmp,diff,fgrep,force,grep,less,more} \
3061 # ${TARGET_DIR}/usr/bin
3062 #mv -v ${TARGET_DIR}/bin/znew \
3063 # ${TARGET_DIR}/usr/bin
3073 Inetutils is a collection of common network programs.
3077 tar xf ${DOWNLOAD_DIR}/inetutils-1.9.1.tar.gz -C ${BUILD_DIR}
3078 pushd ${BUILD_DIR}/inetutils-1.9.1
3079 sed -i.orig '/gets is a security hole/d' lib/stdio.in.h
3080 sed -i.orig -e '/PATH_PROCNET_DEV/s/\ no//' paths
3082 --build=${CROSS_HOST} \
3083 --host=${CROSS_TARGET} \
3086 make DESTDIR=${TARGET_DIR} install
3088 rm -rf inetutils-1.9.1
3092 @samp{sed -i.orig '/gets is a security hole/d' lib/stdio.in.h} is used
3093 to fix the following error when issuing @samp{make}:
3094 @samp{./stdio.h:1030:1: error: 'gets' undeclared here (not in a
3097 @c It deletes the following line in lib/stdio.in.h:
3098 @c _GL_WARN_ON_USE (gets, ``gets is a security hole - use fgets instead'');
3100 @samp{sed -i.orig -e '/PATH_PROCNET_DEV/s/\ no//' paths} is used to
3101 fix the following error when issuing @samp{make}:
3102 @samp{'PATH_PROCNET_DEV' undeclared (first use in this function)}.
3108 Iproute2 is a collection of utilities for controlling TCP and UDP IP
3109 networking and traffic.
3113 tar xf ${DOWNLOAD_DIR}/iproute2-3.10.0.tar.bz2 -C ${BUILD_DIR}
3114 pushd ${BUILD_DIR}/iproute2-3.10.0
3115 sed -i.orig '/^TARGETS/s@arpd@@g' misc/Makefile
3117 DESTDIR=${TARGET_DIR} \
3119 DOCDIR=/usr/share/doc/iproute2 \
3120 MANDIR=/usr/share/man
3122 DESTDIR=${TARGET_DIR} \
3123 DOCDIR=/usr/share/doc/iproute2 \
3124 MANDIR=/usr/share/man \
3127 rm -rf iproute2-3.10.0
3131 @samp{sed -i.orig '/^TARGETS/s@@arpd@@@@g' misc/Makefile} is used to
3132 disable the build of @command{arpd} as it requires Berkeley DB to be
3135 @env{DOCDIR} and @env{MANDIR} indicate the location in which the
3136 documentation and the manual pages will be installed,
3137 respectively. Those are no absolute paths but use the value of
3138 @env{DESTDIR} as a prefix.
3144 Kbd contains keytable files and keyboard utilities.
3148 tar xf ${DOWNLOAD_DIR}/kbd-1.15.5.tar.gz -C ${BUILD_DIR}
3149 pushd ${BUILD_DIR}/kbd-1.15.5
3150 cat > config.cache << EOF
3151 ac_cv_func_setpgrp_void=yes
3152 ac_cv_func_malloc_0_nonnull=yes
3153 ac_cv_func_realloc_0_nonnull=yes
3156 --build=${CROSS_HOST} \
3157 --host=${CROSS_TARGET} \
3159 --cache-file=config.cache \
3162 make DESTDIR=${TARGET_DIR} install
3163 # For FHS compatibility
3164 #mv -v ${TARGET_DIR}/usr/bin/{kbd_mode,dumpkeys,loadkeys,openvt} \
3166 #mv -v ${TARGET_DIR}/usr/bin/setfont \
3173 Option @option{--disable-vlock} disables the build of vlock. vlock
3174 needs PAM library headers to be present on the build system and is not
3175 necessary for us, so we do not build it.
3181 Kmod (previously known as module-init-tools) provide userspace-side
3182 assistance in loading kernel modules and their dependencies.
3186 tar xf ${DOWNLOAD_DIR}/kmod-14.tar.gz -C ${BUILD_DIR}
3187 pushd ${BUILD_DIR}/kmod-14
3189 --build=${CROSS_HOST} \
3190 --host=${CROSS_TARGET} \
3197 DESTDIR=${TARGET_DIR} \
3205 ln -sv kmod ${TARGET_DIR}/bin/lsmod
3206 ln -sv ../bin/kmod ${TARGET_DIR}/sbin/depmod
3207 ln -sv ../bin/kmod ${TARGET_DIR}/sbin/insmod
3208 ln -sv ../bin/kmod ${TARGET_DIR}/sbin/modprobe
3209 ln -sv ../bin/kmod ${TARGET_DIR}/sbin/modinfo
3210 ln -sv ../bin/kmod ${TARGET_DIR}/sbin/rmmod
3213 @option{--with-zlib} enables support for modules compressed with
3216 By default, installation uses @env{INSTALL=install-with-care} which
3217 checks if old utilities have not been destroyed. To avoid this check,
3218 we use @env{INSTALL=install}.
3224 Less is a file pager. A file pager is used to view the content of a
3229 tar xf ${DOWNLOAD_DIR}/less-458.tar.gz -C ${BUILD_DIR}
3230 pushd ${BUILD_DIR}/less-458
3232 --build=${CROSS_HOST} \
3233 --host=${CROSS_TARGET} \
3237 make prefix=${TARGET_DIR}/usr install
3238 # For FHS compatibility:
3239 #mv -v ${TARGET_DIR}/usr/bin/less ${TARGET_DIR}/bin
3249 GNU @command{make} utility determines automatically which pieces of a
3250 large program need to be recompiled, and issues the commands to
3255 tar xf ${DOWNLOAD_DIR}/make-3.82.tar.bz2 -C ${BUILD_DIR}
3256 pushd ${BUILD_DIR}/make-3.82
3258 --build=${CROSS_HOST} \
3259 --host=${CROSS_TARGET} \
3262 make DESTDIR=${TARGET_DIR} install
3272 Man is an interface to the on-line reference manuals.
3276 tar xf ${DOWNLOAD_DIR}/man-1.6g.tar.gz -C ${BUILD_DIR}
3277 pushd ${BUILD_DIR}/man-1.6g
3278 sed -i.orig -e "/PREPATH=/s@=.*@=\"$(eval echo \
3279 ${TARGET_DIR}/{,usr/}{sbin,bin})\"@g" -e 's@-is@&Rc@g' configure
3280 sed -i.orig -e 's@MANPATH./usr/man@#&@g' \
3281 -e 's@MANPATH./usr/local/man@#&@g' src/man.conf.in
3284 sed -i.orig "s@${TARGET_DIR}@@" conf_script
3285 gcc src/makemsg.c -o src/makemsg
3287 make DESTDIR=${TARGET_DIR} install
3293 In the first use of @command{sed}, the first part replaces
3294 @env{PREPATH} default value
3295 @samp{/bin:/usr/bin:/usr/ucb:/usr/local/@/bin:$PATH} with
3296 @samp{$@{TARGET_DIR@}/@{,usr/@}@{sbin,bin@}}. The variable
3297 @env{TARGET_DIR} is used to avoid errors when running the
3298 @file{configure} script.
3300 The second part is used to replace default options of the man pager
3301 @option{-is} with @option{-isRc}. Option @option{-c} will cause
3302 @command{less} to display man pages faster as this option disables
3307 The second call of @command{sed} tells @command{man} where the cat
3308 pages corresponding to given man pages should not be stored:
3309 @file{/usr/man} and @file{/usr/local/man}.
3311 Option @option{-confdir} is used to define configuration files
3312 location to target system's @file{/etc}.
3314 The third call of @command{sed} is used in order to remove the
3315 presence of @env{TARGET_DIR} on the target system's programs.
3317 @command{makemsg} will be used during the build, but because using the
3318 cross-compiler may make its build fail, we use the host's compiler.
3324 GNU nano is a lightweight text editor.
3328 tar xf ${DOWNLOAD_DIR}/nano-2.3.2.tar.gz -C ${BUILD_DIR}
3329 pushd ${BUILD_DIR}/nano-2.3.2
3330 #tar xf ${DOWNLOAD_DIR}/nano-2.3.1.tar.gz -C ${BUILD_DIR}
3331 #pushd ${BUILD_DIR}/nano-2.3.1
3333 --build=${CROSS_HOST} \
3334 --host=${CROSS_TARGET} \
3337 '/CPPFLAGS/s/\/usr\/include\/ncursesw/${TARGET_DIR}\/usr\/include/' \
3338 `find . -iname 'Makefile'`
3340 make DESTDIR=${TARGET_DIR} install
3346 The sed expression is used to replace @file{/usr/include/ncursesw}
3347 with @file{$@{TARGET_DIR@}/usr/include} in every file named
3348 @file{Makefile} in order to overcome the error
3349 @samp{/usr/include/ncursesw/ncurses.h:60:34: fatal error:
3350 ncursesw/ncurses_dll.h: No such file or directory}.
3353 commands in nano are displayed as in `^X'. The `^' character means
3354 @key{CTRL} key, so `^X' means @kbd{CTRL-X}.
3361 GNU patch takes a patch file containing a difference listing produced
3362 by the @command{diff} program and applies those differences to one or
3363 more original files, producing patched versions.
3367 tar xf ${DOWNLOAD_DIR}/patch-2.7.1.tar.bz2 -C ${BUILD_DIR}
3368 pushd ${BUILD_DIR}/patch-2.7.1
3369 cat > config.cache << EOF
3370 ac_cv_path_ed_PROGRAM=ed
3371 ac_cv_func_strnlen_working=yes
3374 --build=${CROSS_HOST} \
3375 --host=${CROSS_TARGET} \
3377 --cache-file=config.cache
3379 make prefix=${TARGET_DIR}/usr install
3389 This package contains utilities that use the proc filesystem.
3393 tar xf ${DOWNLOAD_DIR}/psmisc-22.20.tar.gz -C ${BUILD_DIR}
3394 pushd ${BUILD_DIR}/psmisc-22.20
3395 cat > config.cache << EOF
3396 ac_cv_func_malloc_0_nonnull=yes
3397 ac_cv_func_realloc_0_nonnull=yes
3400 --build=${CROSS_HOST} \
3401 --host=${CROSS_TARGET} \
3404 --cache-file=config.cache
3406 make DESTDIR=${TARGET_DIR} install
3407 # For FHS compatibility:
3408 #mv -v ${TARGET_DIR}/bin/pstree* ${TARGET_DIR}/usr/bin
3409 #ln -sv killall ${TARGET_DIR}/bin/pidof
3419 Rsyslog is an utility creating log messages.
3423 tar xf ${DOWNLOAD_DIR}/rsyslog-5.8.6.tar.gz -C ${BUILD_DIR}
3424 pushd ${BUILD_DIR}/rsyslog-5.8.6
3425 cat > config.cache << EOF
3426 ac_cv_func_malloc_0_nonnull=yes
3427 ac_cv_func_realloc_0_nonnull=yes
3429 PKG_CONFIG_PATH="${TARGET_DIR}/usr/lib/pkgconfig" \
3431 --build=${CROSS_HOST} \
3432 --host=${CROSS_TARGET} \
3435 --cache-file=config.cache
3437 make DESTDIR=${TARGET_DIR} install
3438 install -dv ${TARGET_DIR}/etc/rsyslog.d
3440 rm -rf rsyslog-5.8.6
3443 cat > ${TARGET_DIR}/etc/rsyslog.conf << "EOF"
3444 $ModLoad imuxsock.so
3447 $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
3451 $FileCreateMode 0640
3457 $RepeatedMsgReduction on
3459 $IncludeConfig /etc/rsyslog.d/*.conf
3461 auth,authpriv.* /var/log/auth.log
3462 *.*;auth,authpriv.none -/var/log/syslog
3463 daemon.* -/var/log/daemon.log
3464 kern.* -/var/log/kern.log
3465 lpr.* -/var/log/lpr.log
3466 mail.* -/var/log/mail.log
3467 user.* -/var/log/user.log
3471 auth,authpriv.none;\
3472 news.none;mail.none -/var/log/debug
3473 *.=info;*.=notice;*.=warn;\
3474 auth,authpriv.none;\
3476 mail,news.none -/var/log/messages
3478 # Emergency are shown to everyone
3483 @samp{install -dv $@{TARGET_DIR@}/etc/rsyslog.d} is used to create
3484 target system's @file{/etc/rsyslog.d} directory. Rsyslog looks for
3485 user-defined configuration files in this directory. The line
3486 @samp{$IncludeConfig /etc/rsyslog.d/*.conf} in the target system's
3487 configuration file @file{/etc/rsyslog.conf} has this purpose.
3489 We then create the target system's configuration file
3490 @file{/etc/rsyslog.conf}.
3498 tar xf ${DOWNLOAD_DIR}/shadow-4.1.4.3.tar.bz2 -C ${BUILD_DIR}
3499 pushd ${BUILD_DIR}/shadow-4.1.4.3
3500 patch -Np1 -i ${DOWNLOAD_DIR}/shadow-4.1.4.3-man-ru.patch
3502 echo "ac_cv_func_setpgrp_void=yes" > config.cache
3504 --build=${CROSS_HOST} \
3505 --host=${CROSS_TARGET} \
3512 --cache-file=config.cache \
3514 sed -i.orig 's/groups$(EXEEXT) //' src/Makefile
3515 for mkf in $(find man -name Makefile)
3517 sed -i.orig -e '/groups.1.xml/d' -e 's/groups.1 //' ${mkf}
3520 make DESTDIR=${TARGET_DIR} install
3521 sed -i.orig -e 's@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@' \
3522 -e 's@/var/spool/mail@/var/mail@' \
3523 ${TARGET_DIR}/etc/login.defs
3524 # For FHS compatibility:
3525 #mv -v ${TARGET_DIR}/usr/bin/passwd ${TARGET_DIR}/bin
3526 ${CROSS_TARGET}-pwconv
3527 ${CROSS_TARGET}-grpconv
3528 ${CROSS_TARGET}-passwd root
3530 rm -rf shadow-4.1.4.3
3535 ${CROSS_TARGET}-passwd root
3536 gives the following message:
3537 Cannot change ID to root.
3540 The patch @file{shadow-4.1.4.3-man-ru.patch} contains a fix to
3541 @file{man/ru/Makefile.am} preventing @samp{make install} to
3542 complete. @command{automake-1.11} is then run to update the makefile
3543 prototype @file{Makefile.in}.
3545 @c echo "ac_cv_func_setpgrp_void=yes" > config.cache
3547 The option @option{--enable-man} is used to generate man pages.
3549 The first call of @command{sed} disables the build of command
3550 @command{groups}, as coreutils already installed it.
3552 The second call of @command{sed} enables support for MD5 encrypted
3553 passwords and changes the mail default directory from
3554 @file{/var/spool/mail} to @file{/var/mail}.
3556 The @command{pwconv} command creates @file{shadow} file from file
3557 @file{passwd} and an optionally existing @file{shadow} file.
3559 The @command{grpconv} command creates @file{gshadow} file from file
3560 @file{group} and an optionally existing @file{gshadow} file.
3562 The command @samp{passwd root} will create the password for the root
3563 user, you will need it when logging in as root on your new system.
3569 Sysvinit is the system-V style init process. Init is the first process
3570 started during booting. It is started by the kernel. Init continues
3571 running as a daemon until the system is shut down. It is the direct or
3572 indirect ancestor of all other processes and automatically adopts all
3578 tar xf ${DOWNLOAD_DIR}/sysvinit-2.88dsf.tar.bz2 -C ${BUILD_DIR}
3579 pushd ${BUILD_DIR}/sysvinit-2.88dsf
3580 sed -i.orig -e 's@/dev/initctl@$(ROOT)&@g' \
3581 -e 's@\(mknod \)-m \([0-9]* \)\(.* \)p@\1\3p; chmod \2\3@g' \
3582 -e '/^ifeq/s/$(ROOT)//' \
3583 -e 's@/usr/lib@$(ROOT)&@' \
3586 make -C src ROOT=${TARGET_DIR} CC="${CC}"
3587 make -C src ROOT=${TARGET_DIR} INSTALL="install" install
3589 rm -rf sysvinit-2.88dsf
3592 cat > ${TARGET_DIR}/etc/inittab << "EOF"
3593 # Begin /etc/inittab
3597 si::sysinit:/etc/rc.d/init.d/rc sysinit
3599 l0:0:wait:/etc/rc.d/init.d/rc 0
3600 l1:S1:wait:/etc/rc.d/init.d/rc 1
3601 l2:2:wait:/etc/rc.d/init.d/rc 2
3602 l3:3:wait:/etc/rc.d/init.d/rc 3
3603 l4:4:wait:/etc/rc.d/init.d/rc 4
3604 l5:5:wait:/etc/rc.d/init.d/rc 5
3605 l6:6:wait:/etc/rc.d/init.d/rc 6
3607 ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
3609 su:S016:once:/sbin/sulogin
3611 1:2345:respawn:/sbin/agetty tty1 9600
3612 2:2345:respawn:/sbin/agetty tty2 9600
3613 3:2345:respawn:/sbin/agetty tty3 9600
3614 4:2345:respawn:/sbin/agetty tty4 9600
3615 5:2345:respawn:/sbin/agetty tty5 9600
3616 6:2345:respawn:/sbin/agetty tty6 9600
3618 #c0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100
3624 The first call of @command{sed} replaces @file{/dev/initctl} with
3625 @file{$(ROOT)/dev/initctl}, and @file{/usr/lib} with
3626 @file{$(ROOT)/usr/lib} among other things in order to install sysvinit
3627 on the target system.
3629 @samp{make -C src clobber} is used to clean up the @file{src}
3632 Then, we create the @file{inittab} file that describes which processes
3633 are started at bootup and during normal operation.
3635 The line @samp{#c0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100} is
3636 commented out (with @code{#}) in order to avoid the message:
3637 @samp{INIT: Id "c0" respawning too fast: disabled for 5 minutes} on
3644 GNU tar is an archiving utility: it stores and extracts files from a
3645 tape or disk archive.
3649 tar xf ${DOWNLOAD_DIR}/tar-1.26.tar.bz2 -C ${BUILD_DIR}
3650 pushd ${BUILD_DIR}/tar-1.26
3651 cat > config.cache << EOF
3652 gl_cv_func_btowc_eof=yes
3653 ac_cv_func_malloc_0_nonnull=yes
3654 ac_cv_func_realloc_0_nonnull=yes
3655 gl_cv_func_mbrtowc_incomplete_state=yes
3656 gl_cv_func_mbrtowc_nul_retval=yes
3657 gl_cv_func_mbrtowc_null_arg=yes
3658 gl_cv_func_mbrtowc_retval=yes
3659 gl_cv_func_wcrtomb_retval=yes
3661 sed -i.orig '/gets is a security hole/d' gnu/stdio.in.h
3663 --build=${CROSS_HOST} \
3664 --host=${CROSS_TARGET} \
3667 --libexecdir=/usr/sbin \
3668 --cache-file=config.cache
3670 make DESTDIR=${TARGET_DIR} install
3676 The sed expression is use to avoid the error @samp{./stdio.h:479:1:
3677 error: 'gets' undeclared here (not in a function)}.
3683 GNU Texinfo is a documentation system that can produce both online
3684 information and a printed manual from a single source.
3688 tar xf ${DOWNLOAD_DIR}/texinfo-5.1.tar.gz -C ${BUILD_DIR}
3689 pushd ${BUILD_DIR}/texinfo-5.1
3691 --build=${CROSS_HOST} \
3692 --host=${CROSS_TARGET} \
3694 make -C tools/gnulib/lib
3697 make DESTDIR=${TARGET_DIR} install
3702 pushd ${TARGET_DIR}/usr/share/info
3705 do install-info $f dir 2>/dev/null
3710 The first three calls of @command{make} make it possible to build
3711 Texinfo by cross-compilation.
3713 For Info to work, the @file{info} directory must contain a file that
3714 serves as a top level directory for the Info system. By convention,
3715 this file is called @file{dir}. We update this file for the target
3722 Udev is the dynamic device management of the kernel Linux.
3726 tar xf ${DOWNLOAD_DIR}/udev-175.tar.gz -C ${BUILD_DIR}
3727 pushd ${BUILD_DIR}/udev-175
3729 --build=${CROSS_HOST} \
3730 --host=${CROSS_TARGET} \
3734 --with-rootlibdir=/lib \
3735 --libexecdir=/lib/udev \
3736 --docdir=/usr/share/doc/udev-175 \
3737 --disable-introspection \
3738 --with-pci-ids-path=no \
3739 --with-usb-ids-path=no \
3742 make DESTDIR=${TARGET_DIR} install
3743 install -dv ${TARGET_DIR}/lib/firmware
3744 ln -sv ../lib/udev/udevd ${TARGET_DIR}/sbin/udevd
3754 util-linux is a random collection of utilities for use with the kernel
3759 tar xf ${DOWNLOAD_DIR}/util-linux-2.23.tar.bz2 -C ${BUILD_DIR}
3760 pushd ${BUILD_DIR}/util-linux-2.23
3762 --build=${CROSS_HOST} \
3763 --host=${CROSS_TARGET} \
3767 --disable-makeinstall-chown
3769 make DESTDIR=${TARGET_DIR} install
3770 mv -v ${TARGET_DIR}/usr/bin/logger ${TARGET_DIR}/bin
3772 rm -r util-linux-2.23
3776 Option @option{--enable-partx} enables the build and installation of
3777 the @command{addpart}, @command{delpart} and @command{partx} commands.
3779 Option @option{--disable-wall} disables the build of the
3780 @command{wall} command which is already provided by sysvinit.
3782 Option @option{--enable-write} enables the build and installation of
3783 the @command{write} command.
3785 Option @option{--disable-makeinstall-chown} disables the change of
3786 owner to root for installed programs.
3792 XZ Utils is a general-purpose data compression software with high
3797 tar xf ${DOWNLOAD_DIR}/xz-5.0.5.tar.bz2 -C ${BUILD_DIR}
3798 pushd ${BUILD_DIR}/xz-5.0.5
3799 #tar xf ${DOWNLOAD_DIR}/xz-5.0.4.tar.bz2 -C ${BUILD_DIR}
3800 #pushd ${BUILD_DIR}/xz-5.0.4
3802 --build=${CROSS_HOST} \
3803 --host=${CROSS_TARGET} \
3806 make DESTDIR=${TARGET_DIR} install
3807 # For FHS compatibility:
3808 #mv -v ${TARGET_DIR}/usr/bin/{xz,lzma,lzcat,unlzma,unxz,xzcat} \
3817 @section Bootscripts
3819 The bootscript archive contains scripts that manage services during
3820 system's bootup and shutdown.
3824 tar xf ${DOWNLOAD_DIR}/bootscripts-cross-lfs-2.0.0.tar.xz \
3826 pushd ${BUILD_DIR}/bootscripts-cross-lfs-2.0-pre2
3827 make DESTDIR=${TARGET_DIR} install-bootscripts
3828 make DESTDIR=${TARGET_DIR} install-network
3830 rm -rf bootscripts-cross-lfs-2.0-pre2
3834 This installs basic bootscripts required for bootup and shutdown, and
3835 network-related bootscripts.
3843 tar xf ${DOWNLOAD_DIR}/linux-3.9-loongson3a-deblobbed.tar \
3845 pushd ${BUILD_DIR}/linux-official
3846 #tar xf ${DOWNLOAD_DIR}/linux-2.6.36-21-loongson3a-deblobbed.tar \
3848 #pushd ${BUILD_DIR}/linux-3A
3849 patch -Np1 -i $DOWNLOAD_DIR/linux-3.9-firmware-timeout.patch
3850 patch -Np1 -i $DOWNLOAD_DIR/linux-3.9-kernel-panic.patch
3851 #patch -Np1 -i $DOWNLOAD_DIR/linux-2.6.36-firmware-timeout.patch
3852 #patch -Np1 -i $DOWNLOAD_DIR/linux-2.6.36-kernel-panic.patch
3856 @file{linux-3.9-firmware-timeout.patch} is used to avoid waiting 60
3857 seconds for the binary-blob firmware to load, as those have been
3858 removed by the @file{deblob} script.
3860 @file{linux-3.9-kernel-panic.patch} is used in order to avoid a kernel
3861 panic that may occur frequently at boot with the deblobbed kernel.
3866 #cp arch/mips/configs/loongson3a_defconfig .config
3867 cp arch/mips/configs/loongson3_defconfig .config
3868 #cp arch/mips/configs/loongson3_config .config
3869 #Skip the following as, with 4 CPUs, the result is ugly:
3870 #patch -Np1 -i ${DOWNLOAD_DIR}/100gnu+freedo.patch
3873 Then, if you want to change the configuration:
3876 #make ARCH=mips CROSS_COMPILE=${CROSS_TARGET}- config
3877 make ARCH=mips CROSS_COMPILE=${CROSS_TARGET}- menuconfig
3883 CROSS_COMPILE=${CROSS_TARGET}-
3886 CROSS_COMPILE=${CROSS_TARGET}- \
3887 INSTALL_MOD_PATH=${TARGET_DIR} \
3889 cp vmlinuz ${TARGET_DIR}/boot/vmlinuz
3890 cp System.map ${TARGET_DIR}/boot/System.map
3891 cp .config ${TARGET_DIR}/boot/config
3897 because future compilation may need kernel sources, the compilation
3898 directory of the kernel should be preserved.
3902 @node Configuration Files
3903 @chapter Creating Required Configuration Files for the New System
3906 * Time Setup File:: File for time setup.
3907 * Bash Keyboard Setup:: Setting up keyboard function keys
3909 * Bash Startup Files:: Setting up Bash shell startup files.
3910 * Localhost Setup:: Setting up localhost.
3911 * hosts Setup:: Setting up @file{hosts} file.
3912 * Network Address Setup:: Setting up network address.
3913 * DNS Setup:: Setting up DNS.
3914 * fstab File Creation:: Creating @file{fstab} file.
3918 @node Time Setup File
3919 @section File for Time Setup
3922 cat > ${TARGET_DIR}/etc/sysconfig/clock << "EOF"
3923 # Begin /etc/sysconfig/clock
3927 # End /etc/sysconfig/clock
3932 @node Bash Keyboard Setup
3933 @section Setting up Keyboard Function keys for the Shell
3935 Readline default configuration file is set:
3938 cat > ${TARGET_DIR}/etc/inputrc << "EOF"
3940 set convert-meta Off
3941 set horizontal-scroll-mode Off
3944 "\eOd": backward-word
3945 "\eOc": forward-word
3946 "\e[1~": beginning-of-line
3947 "\e[4~": end-of-line
3948 "\e[5~": beginning-of-history
3949 "\e[6~": end-of-history
3950 "\e[3~": delete-char
3951 "\e[2~": quoted-insert
3952 "\eOH": beginning-of-line
3954 "\e[H": beginning-of-line
3959 If @option{convert-meta} is set to @samp{on}, Readline will convert
3960 characters with the eighth bit set to an @sc{ascii} key sequence by
3961 stripping the eighth bit and prefixing an @key{ESC} character,
3962 converting them to a meta-prefixed key sequence.
3964 @option{horizontal-scroll-mode} set to @samp{off} means that the text
3965 of the lines being edited will be wrapped onto a new screen line when
3966 they are longer than the width of the screen, instead of being
3967 scrolled horizontally on a single screen line.
3971 @option{input-meta} If set to @samp{on}, Readline will enable
3972 eight-bit input (it will not clear the eighth bit in the characters it
3973 reads), regardless of what the terminal claims it can support.
3975 If @option{output-meta} is set to @samp{on}, Readline will display
3976 characters with the eighth bit set directly rather than as a
3977 meta-prefixed escape sequence.
3980 "\eOd": backward-word
3981 "\eOc": forward-word
3982 "\e[1~": beginning-of-line
3983 "\e[4~": end-of-line
3984 "\e[5~": beginning-of-history
3985 "\e[6~": end-of-history
3986 "\e[3~": delete-char
3987 "\e[2~": quoted-insert
3988 "\eOH": beginning-of-line
3990 "\e[H": beginning-of-line
3995 @node Bash Startup Files
3996 @section Setting up Bash Shell Startup Files
3999 cat > ${TARGET_DIR}/etc/profile << "EOF"
4000 # Begin /etc/profile
4002 export LANG=en_US.UTF-8
4003 export INPUTRC=/etc/inputrc
4004 export PS1='\[\e[31m\]\A-\W\[\e[00m\]\$ '
4010 The environement variable @env{LANG} defines the default language that
4011 should be used on the system. @samp{en_US.UTF-8} means ``english''
4012 language, country ``US'' and @acronym{UTF-8} (UCS Transformation
4013 Format—8-bit) encoding (Unicode).
4015 @c For a full list, see???
4017 For explanations on @env{PS1}, @pxref{Environment Variables Setup}.
4020 @node Localhost Setup
4021 @section Localhost Setup
4024 echo "HOSTNAME=gllfsc" > ${TARGET_DIR}/etc/sysconfig/network
4029 @section Setting up @file{hosts} File
4032 cat > ${TARGET_DIR}/etc/hosts << "EOF"
4035 127.0.0.1 gllfsc localhost
4042 @node Network Address Setup
4043 @section Setting up Network Address
4045 You can choose to have a network static or dynamic address.
4048 * Network Static Address Setup:: Setting up Network Static Address.
4049 * Network Dynamic Address Setup:: Setting up Network Dynamic
4054 @node Network Static Address Setup
4055 @subsection Setting up Network Static Address
4058 pushd ${TARGET_DIR}/etc/sysconfig/network-devices
4059 mkdir -v ifconfig.eth0
4060 cat > ifconfig.eth0/ipv4 << "EOF"
4066 BROADCAST=192.168.1.255
4072 @code{IP}, @code{GATEWAY}, @code{BROADCAST} addresses are set up
4073 according to one's situation.
4077 @node Network Dynamic Address Setup
4078 @subsection Setting up Network Dynamic Address
4081 pushd ${TARGET_DIR}/etc/sysconfig/network-devices
4082 mkdir -v ifconfig.eth0
4083 cat > ifconfig.eth0/dhcpcd << "EOF"
4094 @section Setting up DNS
4097 cat > ${TARGET_DIR}/etc/resolv.conf << "EOF"
4098 # Begin /etc/resolv.conf
4100 nameserver your-main-DNS-address
4101 nameserver your-secondary-DNS-address
4103 # End /etc/resolv.conf
4108 @node fstab File Creation
4109 @section @file{fstab} File Creation
4111 The file @file{/etc/fstab} is used at boot to mount partitions under
4112 the requested directories.
4115 cat > ${TARGET_DIR}/etc/fstab << "EOF"
4118 # file system mount-point type options dump fsck order
4120 /dev/sda8 / ext3 defaults 1 1
4121 /dev/sda3 swap swap pri=1 0 0
4122 proc /proc proc defaults 0 0
4123 sysfs /sys sysfs defaults 0 0
4124 devpts /dev/pts devpts gid=4,mode=620 0 0
4125 shm /dev/shm tmpfs defaults 0 0
4132 the name of the hard drive and the name of filesystem used here have
4133 to be modified to reflect @emph{your} real situation.
4141 * Archiving:: All the system archived in one
4143 * Recommendations:: Some tips.
4148 @section Archiving the System
4150 After the system has been completed, we use the command @command{exit}
4151 to logout as the @emph{gllfsc} user.
4153 Now, login as the @emph{root} user.
4155 Then fix the permissions on the new system:
4158 export TARGET_DIR=/gllfsc
4160 mknod -m 600 dev/console c 5 1
4161 mknod -m 666 dev/null c 1 3
4162 cp -a dev/{console,null} lib/udev/devices/
4163 chown -R root:root *
4166 We archive the entire system by using the following command:
4169 # 20 minutes without kernel sources nor cross-tools
4170 #tar -cjf gllfsc-20130723.tar.bz2 bin boot dev etc home lib* media \
4171 # mnt opt proc root sbin srv sys tmp usr var
4173 # 20 minutes without kernel sources
4174 tar -cjf gllfsc-20130723.tar.bz2 bin boot cross-tools dev etc home \
4175 lib* media mnt opt proc root sbin srv sys tmp usr var
4177 # 60 minutes with kernel sources + cross-tools
4178 #tar -cjf gllfsc-20130723.tar.bz2 *
4181 It is then easy to copy the archive to the target machine and extract.
4184 @node Recommendations
4185 @section Some Recommendations
4187 We recommend extracting the system to an empty partition. Moreover,
4188 the filesystem of the chosen partition has to be a filesystem
4189 supported by the kernel you compiled. Finally, this partition has to
4190 be consistent with the system description in the file
4191 @file{/etc/fstab} you created during setup (@pxref{fstab File
4194 Then, you will have to edit the PMON BIOS configuration file of the
4195 target machine: @file{/boot.cfg}. This file has to be put on the first
4196 partition of the hard
4197 drive@footnote{@uref{http://gnewsense.org/Projects/Lemote#Updating_of_the_PMON_configuration}}. A
4198 minimal @file{/boot.cfg} could be:
4200 On the Yeeloong 8133, vmlinuz must be on the first primary partition
4209 kernel /dev/fs/ext2@wd0/vmlinuz
4210 args console=tty1 root=/dev/sda8
4214 @node Further Readings
4215 @chapter Further Readings
4217 Haiyong Sun's website (in Chinese):
4218 @uref{http://youbest.cublog.cn}. It includes documents on building a
4219 GNU/Linux system for Loongson and a GNU/Hurd system for x86.
4221 Cross [GNU/]Linux from scratch: @uref{http://www.cross-lfs.org}.
4222 Includes a lot of documentation to build a GNU/Linux system by
4223 cross-compilation on a variety of hardware, no information (yet) for
4224 cross-compiling with sysroot on MIPS though. There is also a
4225 Community-driven Beyond [GNU/]Linux From Scratch on
4226 @uref{http://cblfs.cross-lfs.org}. It documents the building of Xorg
4227 and TeXLive among other things.
4229 @c Some patches from the above project are available for download on
4230 @c @uref{http://svn.cross-lfs.org/svn/repos/patches/}.
4232 @uref{http://www.linuxfromscratch.org/hints/downloads/files/more_control_and_pkg_@/man.txt}
4233 documents an interesting way of managing packages. Quotation from the
4241 You want to know which packages your files belong to?
4244 You want to deinstall software that doesn't have make uninstall?
4247 You are bothered by programs installed setuid root behind your back?
4250 You don't like packages quietly overwriting files from other packages?
4253 You don't like package managers like RPM?
4256 YOU WANT TOTAL CONTROL USING ONLY UNIX BUILTINS?
4260 The suckless team@footnote{@uref{http://suckless.org}} is a group of
4261 programmers that share the following
4262 philosophy@footnote{@uref{http://suckless.org/philosophy}}:
4265 Focus on simplicity, clarity and frugality. Our philosophy is about
4266 keeping things simple, minimal and usable. We believe this should
4267 become the mainstream philosophy in the IT sector. Unfortunately, the
4268 tendency for complex, error-prone and slow software seems to be
4269 prevalent in the present-day software industry. We intend to prove the
4270 opposite with our software projects.
4273 The simple and lightweight programs released by this team are
4274 interesting for machines based on Loongson 3A processor as performance
4275 is limited compared to current x86 processors.
4281 I thank Lemote and particularily the CEO, Fuxin Zhang, for offering me
4282 a Yeeloong 8133, Huacai Chen and Haiyong Sun for their help in fixing
4283 the bugs I found in the deblobbed kernel.
4285 I am particularily grateful to Haiyong Sun for having shared his
4286 knowledge on building a free operating system for Loongson 2F
4287 machines, this document is heavily based on this.
4290 @node GNU Free Documentation License
4291 @appendix GNU Free Documentation License
4292 @include fdl-1.3.texi
4295 @node GNU General Public License
4296 @appendix GNU General Public License