4 @setfilename gllfsc-loongson2f-1.0.info
5 @settitle GNU/Linux-libre from source code
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 @c To support Haiyong Sun's ideograms
13 @documentencoding UTF-8
16 This is edition 1.0 (last updated 14 October 2012) of
17 @cite{GNU/Linux-libre from source code for Loongson 2F}.
19 Copyright @copyright{} 2012 Christophe Jarry.
21 This document is based on the Chinese page
22 @url{http://zdbr.net.cn/download/Loongson64-@/2.0.htm}, which is
23 copyright @copyright{} 2009
24 @c Because TeX does not handle Chinese fonts automatically, we need to
32 His blog is on @url{http://youbest.cublog.cn}.
34 Various formats of this manual as well as its texinfo source are
36 @uref{http://cjarry.org/gnu-linux/gllfsc/}.
39 Permission is granted to copy, distribute and/or modify this document
40 under the terms of the GNU Free Documentation License, Version 1.3
41 or any later version published by the Free Software Foundation;
42 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
43 Texts. A copy of the license is included in the section entitled ``GNU
44 Free Documentation License''.
48 Computer instructions in this manual are free software: you can
49 redistribute them and/or modify them under the terms of the GNU
50 General Public License as published by the Free Software Foundation,
51 either version 3 of the License, or (at your option) any later
54 Those instructions are distributed in the hope that they will be
55 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
56 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 GNU General Public License for more details.
59 You should have received a copy of the GNU General Public License
60 along with this manual. If not, see <http://www.gnu.org/licenses/>.
65 @c @setchapternewpage odd
68 @title GNU/Linux-libre from source code
69 @subtitle for Loongson 2F
70 @c @subtitle SUBTITLE-IF-ANY
71 @c @subtitle SECOND-SUBTITLE
72 @author Christophe Jarry
73 @c @author Haiyong Sun (original author)
75 @c The following two commands
76 @c start the copyright page.
78 @vskip 0pt plus 1filll
84 @c Short table of contents
87 @c So the toc is printed at the start.
92 @top GNU/Linux-libre from source code for Loongson 2F
94 This manual describes how to build a GNU/Linux-libre system from
95 source for Loongson 2F processor.
101 * Introduction:: What this document is all about.
102 * Prerequisites:: Useful knowledge before proceeding.
103 * Preliminary Work:: Preparing the build.
104 * Building the Cross-Compilation Toolchain:: Building the cross-
105 compilation Toolchain.
106 * Building Cross-Compilation Tools:: Building the cross-compilation
108 * Building the Target System:: How to build the target system.
109 * Configuration Files:: Creating configuration files
110 needed by the new system.
111 * End:: Final things to do.
112 * Further Readings:: Websites useful to know more.
113 * GNU Free Documentation License:: Your rights and freedoms with the
115 * GNU General Public License:: Your rights and freedoms with the
121 @chapter Introduction
124 * GNU/Linux History:: A brief history of GNU/Linux.
125 * Purpose of this Document:: What this document is all about.
129 @node GNU/Linux History
130 @section GNU/Linux History
133 * GNU:: Presentation of the GNU project
134 * HURD:: Presentation of the HURD
135 * Linux:: Presentation of the kernel Linux
136 * Linux-libre:: Presentation of the kernel Linux-libre
137 * References:: Where to get more information
143 @acronym{GNU} (GNU's Not Unix) is a project launched by Richard
144 Stallman in 1984 with the goal of building an entirely free operating
145 system compatible with Unix@footnote{See
146 @uref{http://en.wikipedia.org/wiki/Unix}}. ``Free'' here means ``free
147 as in freedom''. In this context, a free operating system is an
148 operating system you can use and share in freedom. A core part of his
149 motivation is given in the GNU
150 Manifesto@footnote{@uref{http://www.gnu.org/gnu/manifesto.html}}:
153 I consider that the Golden Rule requires that if I like a program I
154 must share it with other people who like it. Software sellers want to
155 divide the users and conquer them, making each user agree not to share
156 with others. I refuse to break solidarity with other users in this
157 way. I cannot in good conscience sign a nondisclosure agreement or a
158 software license agreement. For years I worked within the Artificial
159 Intelligence Lab to resist such tendencies and other inhospitalities,
160 but eventually they had gone too far: I could not remain in an
161 institution where such things are done for me against my will.
163 So that I can continue to use computers without dishonor, I have
164 decided to put together a sufficient body of free software so that I
165 will be able to get along without any software that is not free. I
166 have resigned from the AI Lab to deny MIT any legal excuse to prevent
167 me from giving GNU away.
170 A program is free software if the program's user has the four
175 The freedom to run the program, for any purpose (freedom 0).
178 The freedom to study how the program works, and change it so it does
179 her computing as she wishes (freedom 1). Access to the source code is
180 a precondition for this.
183 The freedom to redistribute copies so she can help her neighbor
187 The freedom to distribute copies of her modified versions to others
188 (freedom 3). By doing this she can give the whole community a chance
189 to benefit from her changes. Access to the source code is a
190 precondition for this.
193 One of the most popular free software license is the GNU General
195 GPL@footnote{@uref{http://www.gnu.org/licenses/gpl.html}}).
197 The free software movement is supported by the Free Software
198 Foundation (FSF@footnote{@uref{http://www.fsf.org}}).
204 The @acronym{HURD} is an acronym for @acronym{HIRD} (HURD of
205 interfaces representing depth) of Unix-replacing daemons. It is the
206 GNU project's replacement for the Unix kernel. It is a collection of
207 servers that run on the Mach microkernel to implement file systems,
208 network protocols, file access control, and other features that are
209 implemented by the Unix kernel or similar kernels (such as Linux).
211 The purpose of the GNU HURD is to improve the user's freedom on her
212 operating system by allowing her to either add or remove a feature of
213 the kernel on the fly.
215 From early on, the HURD was developed to use GNU Mach as the
216 microkernel. This was a technical decision made by Richard Stallman,
217 who thought it would speed up the work by saving a large part of
218 it. He has admitted that he was wrong about that.
220 Nevertheless, development of the HURD is increasingly attracting
221 developers and GNU/HURD systems exist and are usable.
227 Linux is a monolithic kernel created by Linus Torvalds in 1991. Linus
228 Torvalds initially wrote a terminal emulator, which he used to access
229 the large UNIX servers of his university. He wrote the program
230 specifically for the hardware he was using and independent of an
231 operating system because he wanted to use the functions of his new PC
232 with an 80386 processor. This later became the kernel Linux.
234 Initially, Torvalds first published the kernel Linux under its own
235 licence, which had a restriction on commercial activity.
237 In the notes for the first release of the kernel Linux, Torvalds lists
238 the GNU software that is required to run Linux:
241 Sadly, a kernel by itself gets you nowhere. To get a working system
242 you need a shell, compilers, a library etc. [...] Most of the tools
243 used with linux are GNU software and are under the GNU copyleft.
246 In 1992, he suggested releasing the kernel under the GNU General
247 Public License. He first announced this decision in the release notes
248 of version 0.12. In the middle of December 1992 he published version
249 0.99 using the GNU GPL.
251 The kernel Linux is now a contribution of many professionals and
252 volonteers around the world.
256 @subsection Linux-libre
258 Linux, the kernel developed and distributed by Linus Torvalds et al,
259 contains non-Free Software@footnote{For more information about the
260 presence of proprietary firmware in the kernel Linux, read
261 @uref{http://www.fsfla.org/svnwiki/anuncio/2010-03-Linux-2.6.33-libre.en}
263 @uref{http://www.gnu.org/@/distros/free-system-distribution-guidelines.html#nonfree-firmware}.},
264 i.e., software that does not respect your essential freedoms, and it
265 induces you to install additional non-Free Software that it doesn't
269 Linux-libre@footnote{@uref{http://www.fsfla.org/svnwiki/selibre/linux-libre/index.en.html}}
270 is a project to maintain and publish 100% Free distributions of Linux,
271 suitable for use in Free System Distributions@footnote{For a full list
272 of free as in freedom GNU/Linux distributions, see
273 @uref{http://www.gnu.org/distros}.}, removing software that is
274 included without source code, with obfuscated or obscured source code,
275 under non-Free Software licenses, that do not permit you to change the
276 software so that it does what you wish, and that induces or requires
277 you to install additional pieces of non-Free Software.
281 @subsection References
283 For more information on the GNU project and its relation with the
284 kernel Linux, you can read @uref{http://www.gnu.org/gnu/thegnuproject.html}
285 and @uref{http://www.gnu.org/gnu/gnu-linux-faq.html}.
287 For more information on the history of the HURD, I recommend you to
288 read @uref{http://www.h-online.com/open/features/GNU-HURD-Altered-visions-and-lost-promise@/-1030942.html}.
290 For more information on the HURD, read @uref{http://www.gnu.org/software/hurd}.
293 @node Purpose of this Document
294 @section Purpose of this Document
296 I bought a Lemote Yeeloong 8101 in 2010 and used
297 gNewSense@footnote{@uref{http://www.gnewsense.org}} on it. After a
298 while, I wanted to use a faster and simpler operating system, but the
299 number of available GNU/Linux@footnote{Note: in this document, we use
300 the term ``GNU/Linux'' to name the entire system and ``Linux'' to name
301 the kernel. For more information, read
302 @uref{http://www.gnu.org/gnu/why-gnu-linux.html}.} distributions that
303 supported the mipsel architecture (Loongson 2F) were limited: only a
304 handful, from which only gNewSense committed to give its users full
305 freedom. Since then, another distribution called
306 Parabola@footnote{@uref{https://parabolagnulinux.org}} has been
307 developed: it is free as in freedom and supports the mips64el
310 I decided to build a GNU/Linux system from source code by
311 myself. Hopefully, I found a document in Chinese describing the
312 process of building a GNU/Linux system for Loongson processor:
313 @uref{http://zdbr.net.cn/download/Loongson64-2.0.htm}@footnote{At the
314 time of writing (september 2012), the site @uref{http://zdbr.net.cn/}
315 does not exist anymore. The author of this document was
322 and his (interesting) blog is on @uref{http://youbest.cublog.cn}.}.
323 The document was old (2009) but I updated succesfully most packages
324 from it, replaced Linux with Linux-libre and added some information I
325 felt was useful and it gave the document you are reading.
329 @chapter Prerequisites
332 * Definitions:: Definitions of important notions used to build the
334 * Commands:: Help on commands
342 * sysroot:: @option{sysroot}
343 * Toolchain:: What a Toolchain is.
344 * build host target:: Understanding the meaning of the
345 @option{build}-@option{host}-@option{target}
347 * FHS:: The Filesystem Hierarchy Standard.
352 @subsection @option{sysroot}
354 The traditional way of building a GNU/Linux operating system consists
355 on building a (cross-) compilation toolchain to build a temporary
356 operating system which in turn will be used to build the target
357 system@footnote{@xref{Further Readings} section for more
358 details}. This requires almost as much time to complete the temporary
359 system as to build the target one. Using sysroot resolves this
362 From GCC installation manual, under Cross-Compiler-Specific Options:
366 @itemx --with-sysroot=@var{dir}
367 Tells GCC to consider @var{dir} as the root of a tree that contains (a
368 subset of) the root filesystem of the target operating system. Target
369 system headers, libraries and run-time object files will be searched
370 in there. More specifically, this acts as if
371 @option{--sysroot=@var{dir}} was added to the default options of the
372 built compiler. The specified directory is not copied into the
373 install tree, unlike the options @option{--with-headers} and
374 @option{--with-libs} that this option obsoletes. The default value,
375 in case @option{--with-sysroot} is not given an argument, is
376 @option{$@{gcc_tooldir@}/sys-root}. If the specified directory is a
377 subdirectory of @option{$@{exec_prefix@}}, then it will be found
378 relative to the GCC binaries if the installation tree is moved.
380 This option affects the system root for the compiler used to build
381 target libraries (which runs on the build system) and the compiler
382 newly installed with @code{make install}; it does not affect the
383 compiler which is used to build GCC itself.
388 @subsection Toolchain
391 Wikipedia@footnote{@uref{http://www.wikipedia.org/wiki/Toolchain}}:
394 In software, a toolchain is the set of programming tools that are used
395 to create a product (typically another computer program or system of
396 programs). The tools may be used in a chain, so that the output of
397 each tool becomes the input for the next, but the term is used widely
398 to refer to any set of linked development tools.
400 A simple software development toolchain consists of a text editor for
401 editing source code, a compiler and linker to transform the source
402 code into an executable program, libraries to provide interfaces to
403 the operating system, and a debugger.
407 @node build host target
408 @subsection @option{build}, @option{host} and @option{target}
410 During a cross-compilation, @option{build} @option{host} and
411 @option{target} are among the most used options: understanding the
412 precise meaning of those parameters is very important. We could define
416 @item @option{--build=@var{platform on which the program is
418 @item @option{--host=@var{platform on which the program will run}},
419 @item @option{--target=@var{platform for which the program will create
423 Let's use GCC as an example to explain the role of those three
426 During GCC compilation, we use:
428 @samp{./configure --build=@var{build-platform}
429 --host=@var{host-platform} --target=@var{target-platform} [various
430 compilation parameters]}
432 So in those configuration parameters:
436 @option{--build} provides the name of the platform currently running.
437 If we were using an Intel Pentium processor to compile the system, our
438 @var{build-platform} would be something like @samp{i686-pc-linux-gnu}.
440 If this parameter is not specified, it will be guessed automatically.
443 @option{--host} represents the type of machine we are going to run GCC
444 on after the compilation succeeds. During a cross-compilation this has
445 to be specified, because the current machine can not know which
446 architecture we wish to target. We want to produce executables to run
447 on @emph{Loongson}, but there is currently no way we can specify
448 @samp{Loongson} directly; because of this we specify
449 @samp{mips64el-unknown-linux-gnu}.
451 @option{--host} can also be left unspecified, in that case,
452 @var{host-platform} would automatically define itself as
453 @var{build-platform}, but this is not cross-compilation anymore.
456 when @option{--build} and @option{--host} are different, configuration
457 files will maintain the cross-compilation mode.
461 @option{--target} defines the system for which compiler tools will
464 @var{target-platform} parameter is useful only for a limited number of
465 programs. Although this parameter is often present when issuing
466 @samp{./configure --help}, hardly any packages will need it.
468 This parameter is only useful for performing tasks with different
469 platforms; for instance, executable files compiled for different
470 platforms can have a totally different code.
473 If we summarize, we have:
476 @item @var{build-platform}: automatically guessed from platform in
477 use; has to be specified if not guessed.
479 @item @var{host-platform}: if unspecified, automatically equals
480 @var{build-platform}. When @var{build-platform} and
481 @var{host-platform} values are identical, it is a local compilation;
482 otherwise it is a cross-compilation.
484 @item @var{target-platform}: defines the system for which compiler
485 tools will create output; it equals @var{host-platform} if
486 unspecified. GCC, binutils, and programs related to the platform's
487 instructions have this parameter; most programs do not use this
495 The Filesystem Hierarchy Standard (FHS) has been created to specify
496 the location and use of main directories on a GNU/Linux operating
497 system. Common commands, user data, libraries have to be put inside a
498 specific directory given in the standard. During the build process,
499 some commands are used to comply with FHS.
505 In this document, because most commands are common for a regular Unix
506 user, only uncommon commands are explained in this document. If you do
507 not understand a command that is not explained, you can use the
508 documentation available on your computer; in a terminal, typing
509 @samp{man @var{command}} should give you enough information. For GNU
510 software, @samp{info @var{package}} can also give additional
514 @node Preliminary Work
515 @chapter Preliminary Work
518 In order to complete the first steps of this chapter, you will need to
519 have root permissions.
523 * Build Partition Creation:: Creating a partition for the build.
524 * Build User Creation:: Creating a user account dedicated to
526 * Work Directory Creation:: Creating the parent directory for the
528 * Partition Mount:: Mounting the partition dedicated to the
530 * Useful Directories Creation:: Creating the directories for downloads
532 * User Switch:: Switching to the user dedicated to the
534 * Environment Variables Setup:: Setting up the environment variables
535 of the target system.
536 * Downloads:: Downloading needed packages and
538 * Final Preparations:: Preparing the system for the build.
542 @node Build Partition Creation
543 @section Build Partition Creation
545 To dedicate the partition @file{/dev/sda4} to the system build, and to
546 define the filesystem to be used for it as @samp{ext3}:
549 mke2fs -t ext3 /dev/sda4
552 Option @option{-t} is followed by the type of filesystem to be
553 used. The filesystem @samp{ext3} is used as it is one of the most
554 common filesystem used with the kernel Linux.
557 @node Build User Creation
558 @section Build User Creation
560 To create the builder group, user and password:
564 useradd -s /bin/bash -g gllfsc -m -k /dev/null gllfsc
570 Option @option{-s} (or @option{--shell}) is used to define the created
571 user's default shell, here @file{/bin/bash}.
574 Option @option{-g} (or @option{--gid}) is used to define the group
575 name or number of the created user's initial login group, here
579 Option @option{-m} (or @option{--create-home}) does create the user's
580 home directory if it does not exist (@file{/home/@var{username}}).
583 Option @option{-k} (or @option{--skel}) is used to define the skeleton
584 directory to be copied in the user's home directory, here
585 @file{/dev/null}. @file{/dev/null} is a special file which, in this
586 case, will give no skeleton at all to @command{useradd}.
590 @node Work Directory Creation
591 @section Work Directory Creation
593 To create the directory @file{/gllfsc} in which the system will be
597 export TARGET_DIR="/gllfsc"
598 mkdir -pv ${TARGET_DIR}
601 @samp{export TARGET_DIR="/gllfsc"} sets the value of the variable
602 @env{TARGET_DIR} to @file{/gllfsc}, the directory in which the system
606 @node Partition Mount
607 @section Mounting Partition
609 To mount the hard drive partition, for instance @file{/dev/sda4}, used
613 mount /dev/sda4 ${TARGET_DIR}
617 @node Useful Directories Creation
618 @section Creating Compilation and Download Directories
621 mkdir -pv ${TARGET_DIR}/{build,download}
622 chown -Rv gllfsc ${TARGET_DIR}
627 @section Switching to the Build User
629 To login as the user that will build the system:
635 With the command @command{su}, it is possible to change the user
636 ID. The option @option{-} provides an environment similar to what the
637 user would expect had the user logged in directly.
640 @node Environment Variables Setup
641 @section Setting up Required Environment Variables
643 @file{~/.bash_profile} is a personal initialization file that is read
644 when Bash is invoked as an interactive login shell (@file{~} is the
645 location of the user's home directory). To write the content of the
646 file @file{~/.bash_profile}:
649 cat > ~/.bash_profile << "EOF"
650 exec env -i HOME=${HOME} TERM=${TERM} PS1=${PS1} /bin/bash
654 The first line creates the file @file{~/.bash_profile} and opens it
655 for writing until @samp{@acronym{EOF}} (End Of File) is written in it.
657 The second line tells Bash to execute @file{/bin/bash} with the option
658 @option{-i} (or @option{--ignore-environment}) which will make Bash
659 start with an empty environment. Variables @env{HOME}, @env{TERM} and
660 @env{PS1} define respectively the home directory of the current user,
661 the terminal used and the primary prompt string displayed.
663 @file{~/.bashrc} is a personal initialization file that is read when
664 Bash is invoked as an interactive shell but not a login one. To write
665 the content of the file @file{~/.bashrc}:
668 cat > ~/.bashrc << "EOF"
671 export PS1='\[\e[32m\]\A-\W\[\e[00m\]\$ '
672 export TARGET_DIR=/gllfsc
674 export BUILD_DIR="${TARGET_DIR}/build"
675 export DOWNLOAD_DIR="${TARGET_DIR}/download"
676 export CROSS_HOST="$(echo $MACHTYPE |\
677 sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
678 export CROSS_TARGET="mips64el-unknown-linux-gnu"
681 #export MARCH="loongson2e"
682 export MARCH="loongson2f"
683 export PATH=${TARGET_DIR}/cross-tools/bin:/bin:/usr/bin
687 source ~/.bash_profile
690 @samp{set +h} tells Bash to not locate nor remember commands (hash) as
691 they are looked up for execution.
693 @samp{umask 022} sets Bash process' file creation mask to
694 @samp{022}. This results in permissions of `755' for those files.
696 @samp{export PS1='\[\e[32m\]\A-\W\[\e[00m\]\$ '} sets the primary
697 prompt strings. The primary prompt strings are the strings you see
698 before the commands you type in the terminal. The part @samp{\A-\W}
699 means that the time, in 24-hour HH:MM format and the basename of
700 @env{$PWD} will be displayed separated by a `-', as in
701 @samp{19:33-bin}. The part @samp{\$} adds a dollar sign at the end,
702 @samp{\[\e[32m\]} colors the strings in green and @samp{\[\e[00m\]}
703 gets the original color back. For other colors, you can browse
704 @uref{http://en.wikipedia.org/wiki/ANSI_escape_code}.
706 @env{LC_ALL} is a macro used to define a single locale to overwrite
707 other @env{LC_*} and @env{LANG} environment variables so that
708 language, numeric values, time and other locale-dependant values have
709 all the same value. It is set to the standard POSIX locale.
711 @samp{export BUILD_DIR="$@{TARGET_DIR@}/build"} sets the environment
712 variable @env{BUILD_DIR} to the value of @samp{$@{TARGET_DIR@}/build}
713 which is @samp{/gllfsc/build} in this document.
715 The value of variable @env{CROSS_HOST} equals the value of variable
716 @env{MACHTYPE} of the current machine (for instance
717 @samp{i686-pc-linux-gnu}) modulo the second word, which is replaced by
718 @samp{cross} (i.e. @samp{i686-cross-linux-gnu}).
720 The value of variable @env{CROSS_TARGET} equals the value of variable
721 @env{MACHTYPE} of the machine for which the system is built (i.e.
722 @samp{mips64el-unknown-linux-gnu}).
724 The variable @env{MABI} defines the @acronym{ABI} (Application Binary
725 Interface) for which the system will be built. @option{-mabi} is an
726 option of GCC. n32/64 are for 64-bit CPUs only. 64 has 64-bit pointers
727 and long integers, whereas n32 has 32-bit pointers and long integers.
729 The variable @env{MARCH} defines the architecture for which the system
730 will be built. @option{-march} is an option of @acronym{GCC} (GNU
731 Compiler Collection).
733 The variable @env{PATH} contains a colon-separated list of directories
734 in which the shell looks for commands. The shell will first look for
735 commands in @file{$@{TARGET_DIR@}/cross-tools/bin}, then, if the
736 command was not found, in @file{/bin} and finally in @file{/usr/bin}.
738 @command{unset} command removes the variable associated, here
739 @env{CFLAGS} and @env{CXXFLAGS}. Those variables are used by GCC as
740 extra flags given to the C compiler and the C++ compiler
743 Finally @samp{source ~/.bash_profile} reads and executes the content
744 of the file @file{~/.bash_profile}.
751 * Packages Download:: List of packages to be downloaded.
752 * Patches Download:: List of patches to be downloaded.
756 @node Packages Download
757 @subsection Downloading Packages
759 The packages listed below are those used in this document. You can try
760 other versions but you will need a recent version of Binutils and the
761 kernel Linux in order to use the two options
762 @option{-mfix-loongson2f-nop} and
763 @option{-mfix-loongson2f-jump}. Those work around a problem related to
764 the Loongson2F architecture@footnote{For more information about the
766 @uref{http://groups.google.com/group/loongson-dev/browse_thread/thread/d9103283141c00fb/e9a8830b01cc1913?hide_quotes=no#msg_d44adf83639fb0bd}
767 and @uref{http://sourceware.org/ml/binutils/2009-11/msg00387.html}.}.
769 Download those files under @env{$@{DOWNLOAD_DIR@}} (which is
770 @file{/gllfsc/download} in this document).
775 Autoconf: @uref{http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz}.
778 Automake: @uref{http://ftpmirror.gnu.org/automake/automake-1.12.4.tar.gz}.
781 Bash: @uref{http://ftpmirror.gnu.org/bash/bash-4.2.tar.gz}.
784 Binutils: @uref{http://ftpmirror.gnu.org/binutils/binutils-2.22.tar.bz2}.
787 Bison: @uref{http://ftpmirror.gnu.org/bison/bison-2.5.tar.bz2}.
790 Bootscripts: @uref{http://ftp.cross-lfs.org/pub/clfs/conglomeration/bootscripts-@/cross-lfs/bootscripts-cross-lfs-1.2-pre11.tar.bz2}.
791 @c @uref{http://ftp.cross-lfs.org/pub/clfs/conglomeration/bootscripts@/-cross-lfs/bootscripts-cross-lfs-2.0-pre2.tar.xz}.
794 Bzip2: @uref{http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz}.
797 Coreutils: @uref{http://ftpmirror.gnu.org/coreutils/coreutils-8.19.tar.xz}.
800 DHCPCD: @uref{http://roy.marples.name/downloads/dhcpcd/dhcpcd-5.6.2.tar@/.bz2}.
803 Diffutils: @uref{http://ftpmirror.gnu.org/diffutils/diffutils-3.2.tar.gz}.
806 E2fsprogs: @uref{http://downloads.sourceforge.net/e2fsprogs/e2fsprogs-1.42.6.tar@/.gz}.
809 File: @uref{ftp://ftp.astron.com/pub/file/file-5.11.tar.gz}.
812 Findutils: @uref{http://ftpmirror.gnu.org/findutils/findutils-4.4.2.tar.gz}.
815 Flex: @uref{http://downloads.sourceforge.net/flex/flex-2.5.37.tar.bz2}.
818 Gawk: @uref{http://ftpmirror.gnu.org/gawk/gawk-4.0.1.tar.gz}.
821 GCC: @uref{http://ftpmirror.gnu.org/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2}.
824 Gettext: @uref{http://ftpmirror.gnu.org/gettext/gettext-0.18.1.1.tar.gz}.
827 Glibc: @uref{http://ftpmirror.gnu.org/glibc/glibc-2.13.tar.bz2}.
828 @c @uref{http://ftpmirror.gnu.org/glibc/glibc-2.16.0.tar.bz2}.
829 @c fails to generate localedef
832 Glibc-Ports: @uref{http://ftpmirror.gnu.org/glibc/glibc-ports-2.13.tar.bz2}.
835 Gmp: @uref{http://ftpmirror.gnu.org/gmp/gmp-5.0.5.tar.bz2}.
838 Grep: @uref{http://ftpmirror.gnu.org/grep/grep-2.14.tar.xz}.
841 Groff: @uref{http://ftpmirror.gnu.org/groff/groff-1.21.tar.gz}.
844 Gzip: @uref{http://ftpmirror.gnu.org/gzip/gzip-1.5.tar.gz}.
847 Iana-Etc: @uref{http://sethwklein.net/iana-etc-2.30.tar.bz2}.
850 Iputils: @uref{http://www.skbuff.net/iputils/iputils-s20071127.tar.bz2}.
851 @c @uref{http://www.skbuff.net/iputils/iputils-s20101006.tar.bz2}.
852 @c depends on sysfs headers.
855 Iproute2: @uref{http://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-3.5.1@/.tar.bz2}
858 Kbd: @uref{http://ftp.altlinux.org/pub/people/legion/kbd/kbd-1.15.3.tar.gz}.
861 Kmod: @uref{http://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-10.tar.gz}.
864 Less: @uref{http://www.greenwoodsoftware.com/less/less-451.tar.gz}.
867 Libtool: @uref{http://ftpmirror.gnu.org/libtool/libtool-2.4.tar.gz}.
870 Linux-Libre @footnote{The kernel Linux is shipped with proprietary
871 firmware. The version called Linux-Libre exists without them, it is
872 available for download at
873 @uref{http://www.fsfla.org/svnwiki/selibre/linux-libre/}.}:
874 @uref{http://linux-libre.fsfla.org/pub/linux-libre/releases/3.5.4-gnu@//linux-libre-3.5.4-gnu.tar.bz2}.
877 M4: @uref{http://ftpmirror.gnu.org/m4/m4-1.4.16.tar.bz2}.
880 Make: @uref{http://ftpmirror.gnu.org/make/make-3.82.tar.bz2}.
883 Man-Pages: @uref{http://www.kernel.org/pub/linux/docs/man-pages/Archive/man-pages-@/3.32.tar.bz2}.
886 Man: @uref{http://primates.ximian.com/~flucifredi/man/man-1.6g.tar.gz}.
889 Mpc: @uref{http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz}.
892 Mpfr: @uref{http://www.mpfr.org/mpfr-3.1.1/mpfr-3.1.1.tar.bz2}.
895 Nano: @uref{http://ftpmirror.gnu.org/nano/nano-2.3.1.tar.gz}
898 Ncurses: @uref{ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz}.
901 Patch: @uref{http://ftpmirror.gnu.org/patch/patch-2.7.1.tar.bz2}.
904 Procps: @uref{http://procps.sourceforge.net/procps-3.2.8.tar.gz}.
907 Psmisc: @uref{http://sourceforge.net/projects/psmisc/files/psmisc/psmisc-22.20.tar@/.gz/download}.
910 Readline: @uref{http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz}.
913 Rsyslog: @uref{http://rsyslog.com/files/download/rsyslog/rsyslog-5.8.6.tar.gz}.
916 Sed: @uref{http://ftpmirror.gnu.org/sed/sed-4.2.1.tar.bz2}.
919 Shadow: @uref{http://pkg-shadow.alioth.debian.org/releases/shadow-4.1.4.3.tar.bz2}.
920 @c @uref{http://pkg-shadow.alioth.debian.org/releases/shadow-4.1.5.1.tar@/.bz2}.
923 Sysvinit: @uref{http://download.savannah.gnu.org/releases/sysvinit/sysvinit-2.88dsf@/.tar.bz2}.
926 Tar: @uref{http://ftpmirror.gnu.org/tar/tar-1.26.tar.bz2}.
929 Texinfo: @uref{http://ftpmirror.gnu.org/texinfo/texinfo-4.13a.tar.gz}.
932 Udev: @uref{ftp://ftp.kernel.org/pub/linux/utils/kernel/hotplug/udev-175.tar.gz}.
933 @c @uref{http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-182.tar.bz2}.
934 @c troubles with blkid
937 Util-Linux: @uref{http://www.kernel.org/pub/linux/utils/util-linux/v2.19/util-@/linux-2.19.1.tar.bz2}.
938 @c @uref{http://www.kernel.org/pub/linux/utils/util-linux/v2.22/util-linux-2.22.tar.bz2}.
939 @c requires PAM headers
942 XZ-Utils: @uref{http://tukaani.org/xz/xz-5.0.4.tar.bz2}.
945 Zlib: @uref{http://sourceforge.net/projects/libpng/files/zlib/1.2.7/zlib-1.2.7.tar@/.bz2/download}.
949 @node Patches Download
950 @subsection Downloading Patches
952 Patches and configuration files location:
956 @uref{http://cjarry.org/gnu-linux/gllfsc/gllfsc-loongson2f-1.0-@/patches.tar.gz}. After
957 having downloaded this file under @env{$@{DOWNLOAD_DIR@}}, execute
958 the following commands to extract its content:
961 pushd ${DOWNLOAD_DIR}
962 tar xvf gllfsc-loongson2f-1.0-patches.tar.gz
969 @uref{http://microcai.gsalex.net/old/archives/2011/01/fbcon_UNICODE_font_support.html}
970 is useful for users who want support for @acronym{CJK} (Chinese
971 Japanese Korean) characters under the (non-graphical) terminal. It
972 gives access to a git@footnote{@uref{http://git-scm.com/}} repository
973 with kernel patches@footnote{The patches to use with version 3.5 of
974 the kernel are the first four on
975 @uref{http://repo.or.cz/w/linux-2.6/cjktty.git/shortlog/refs/heads/3.5-utf8}.}
976 that permit direct rendering of UTF-8 characters under the framebuffer
977 environment. Be aware though that applying those CJK patches to the
978 kernel may make characters that are both non-CJK and non-ASCII
979 unreadable (accented letters, cyrillic, etc.).
982 @uref{http://www.fsfla.org/svn/fsfla/software/linux-libre/lemote/gnewsense/tags/@/3.5.4-gnu_0loongsonlibre/100gnu+freedo.patch}
983 this patch adds a picture of a GNU beside Freedo, Freedo being the
984 mascot of Linux-Libre. The image can be seen on
985 @uref{http://www.fsfla.org/svnwiki/selibre/linux-libre/100gnu+freedo}.
989 @node Final Preparations
990 @section Final Preparations
993 * Target Filesystem Hierarchy Creation:: Creating the directories of
995 * Needed Files Creation:: Creating files for needed
996 user, groups and log.
1000 @node Target Filesystem Hierarchy Creation
1001 @subsection Target Filesystem Hierarchy Creation
1005 mkdir -pv bin boot dev {etc/,}opt home lib mnt
1006 mkdir -pv proc media/{floppy,cdrom} sbin srv sys
1007 mkdir -pv var/{lock,log,mail,run,spool}
1008 mkdir -pv var/{opt,cache,lib/{misc,locate},local}
1009 install -dv -m 0750 root
1010 install -dv -m 1777 {var/,}tmp
1011 mkdir -pv usr/{,local/}{bin,include,lib,sbin,src}
1012 mkdir -pv usr/{,local/}share/{doc,info,locale,man}
1013 mkdir -pv usr/{,local/}share/{misc,terminfo,zoneinfo}
1014 mkdir -pv usr/{,local/}share/man/man{1..8}
1015 for dir in usr{,/local}; do
1016 ln -sv share/{man,doc,info} $dir
1020 ln -svf lib usr/lib64
1021 ln -svf lib usr/lib32
1027 The command @samp{install -dv -m 1777 @{var/,@}tmp} creates the
1028 directories @file{var/tmp} and @file{tmp} with the permissions to
1029 read, write and execute for everyone. The '1' in @samp{1777} is the
1030 sticky bit which allows deletion of the file or directory having this
1031 attribute only for the owner of the file or directory.
1033 The command @samp{ln -svf lib lib64} creates a symbolic link (option
1034 @option{-s}) with the name @file{lib64} which will point to
1038 @node Needed Files Creation
1039 @subsection Creating needed user, groups and log files
1042 cat > ${TARGET_DIR}/etc/passwd << "EOF"
1043 root::0:0:root:/root:/bin/bash
1047 The file @file{/etc/passwd} contains one line for each user account,
1048 with seven fields delimited by colons. These fields are:
1055 optional encrypted password;
1064 user name or comment field;
1067 user home directory;
1070 optional user command interpreter.
1075 cat > ${TARGET_DIR}/etc/group << "EOF"
1095 The file @file{/etc/group} is a text file which defines the groups on
1096 the system. There is one entry per line, with the following format:
1097 @samp{group_name:password:GID:user_list}.
1101 touch ${TARGET_DIR}/var/run/utmp \
1102 ${TARGET_DIR}/var/log/{btmp,lastlog,wtmp}
1103 chmod -v 664 ${TARGET_DIR}/var/run/utmp \
1104 ${TARGET_DIR}/var/log/lastlog
1108 @node Building the Cross-Compilation Toolchain
1109 @chapter Building the Cross-Compilation Toolchain
1111 In this chapter, the cross-compilation toolchain is built as well as
1112 core components of the target system. Those will then be used to build
1116 * Target Linux-Header:: Linux-Header for target system.
1117 * Cross Binutils:: Binutils for cross-compilation.
1118 * Cross GCC:: GCC for cross-compilation (C support only).
1119 * Target glibc:: glibc for target system.
1120 * Cross GCC CXX:: GCC for cross-compilation (C and C++ support).
1124 @node Target Linux-Header
1125 @section Target Linux-Header
1127 To build a GNU/Linux distribution for Loongson 2F without patch, you
1128 need at least version 2.6.33 of the kernel Linux (-libre) as it
1129 includes: basic CS5536 VSM support, CS5536 MFGPT timer support, CPU
1130 frequency scaling support, suspend support framework, basic Loongson
1131 2F support, support for GZIP / BZIP2 / LZMA compressed kernel images
1132 @footnote{See @uref{http://kernelnewbies.org/Linux_2_6_33} for more
1133 information.}. Moreover, version 2.6.35 and above include fixes for
1134 Loongson2F processor @footnote{See
1135 @uref{http://lwn.net/Articles/386986/} for more information.}.
1137 I chose version stable 3.5.4-gnu because it is from the stable branch,
1138 it has been deblobed with the latest version of the deblob
1139 script@footnote{@uref{http://linux-libre.fsfla.org/pub/linux-libre/releases/3.5.4-gnu/deblob-main}}
1140 and because it is recent and as such it should include the most
1141 complete support for Loongson 2F.
1146 tar xf ${DOWNLOAD_DIR}/linux-libre-3.5.4-gnu.tar.bz2 -C ${BUILD_DIR}
1147 pushd ${BUILD_DIR}/linux-3.5.4
1149 make ARCH=mips headers_check
1150 make ARCH=mips INSTALL_HDR_PATH=dest headers_install
1151 cp -rv dest/include/* ${TARGET_DIR}/usr/include
1157 @samp{6 minutes} is the time it takes to build the package on Lemote
1158 Yeeloong with a Loongson 2F processor.
1160 The command @samp{make mrproper} cleans the sources.
1162 We need to specify @samp{ARCH=mips} as we are cross-compiling.
1165 @node Cross Binutils
1166 @section Cross Binutils
1168 GNU Binutils (GNU binary utilities) is a collection of programs for
1169 manipulating binaries.
1174 tar xf ${DOWNLOAD_DIR}/binutils-2.22.tar.bz2 -C ${BUILD_DIR}
1175 pushd $BUILD_DIR/binutils-2.22
1176 mkdir -pv ../binutils-build
1177 cd ../binutils-build
1179 ../binutils-2.22/configure \
1180 --prefix=${TARGET_DIR}/cross-tools \
1181 --build=${CROSS_HOST} \
1182 --host=${CROSS_HOST} \
1183 --target=${CROSS_TARGET} \
1184 --enable-64-bit-bfd \
1185 --with-sysroot=${TARGET_DIR} \
1191 cp -v ../binutils-2.22/include/libiberty.h \
1192 ${TARGET_DIR}/usr/include
1194 rm -rf binutils-build
1195 rm -rf binutils-2.22
1199 @samp{CC="gcc"} and @samp{AR="ar"} are flags that tell the
1200 @file{configure} script to use the local commands @command{gcc} as the
1201 C compiler and @command{ar} as the program that handles archives.
1203 @option{--prefix=$@{TARGET_DIR@}/cross-tools} tells the configure
1204 script to install architecture-independant files in
1205 @file{$@{TARGET_DIR@}/cross-tools}.
1207 The option @option{--enable-64-bit-bfd} enables 64 bit for
1208 @acronym{BFD} (the Binary File Descriptor).
1210 @option{--with-sysroot=@env{$@{TARGET_DIR@}}} tells Binutils to
1211 consider @env{$@{TARGET_DIR@}} as the root of a tree that contains (a
1212 subset of) the root filesystem of the target operating system. Target
1213 system headers, libraries and run-time object files will be searched
1216 The @option{--enable-nls} option enables Native Language Support
1217 (NLS), which lets Binutils output diagnostics in languages other than
1218 American English. Native Language Support is enabled by default if not
1219 doing a canadian cross build. The @option{--disable-nls} option
1222 The option @option{--enable-shared} is used to build shared versions
1223 of libraries, if shared libraries are supported on the target
1224 platform. Use @option{--disable-shared} to build only static
1227 @c cp -v ../binutils-2.22/include/libiberty.h \
1228 @c ${TARGET_DIR}/usr/include
1232 @section Cross GCC (C support only)
1234 GCC is the GNU compiler collection. It can compile many languages, of
1235 which only C and C++ will be enabled in this document.
1237 In this section, we build a minimal GCC in order to build glibc.
1240 to build GMP (a GCC dependency), you need a version of GCC different
1241 from 4.3.2 on you system@footnote{@uref{http://gmplib.org/#STATUS}}:
1245 GCC 4.3.2 miscompiles GMP on 64-bit machines; please use a different
1246 gcc version (e.g., gcc 4.3.1 and gcc 4.3.3 both work properly). We
1247 have not been able to find any workaround for this gcc bug.
1248 Unfortunately, Debian 5.0 has decided to stay with this trouble gcc
1249 version, resulting in that many users strike this bug.
1252 I recommend installing @samp{gcc-4.4} on gNewSense Parkes to avoid
1257 tar xf ${DOWNLOAD_DIR}/gcc-4.7.2.tar.bz2 -C ${BUILD_DIR}
1258 pushd ${BUILD_DIR}/gcc-4.7.2
1259 tar xf ${DOWNLOAD_DIR}/gmp-5.0.5.tar.bz2
1261 tar xf ${DOWNLOAD_DIR}/mpc-1.0.1.tar.gz
1263 tar xf ${DOWNLOAD_DIR}/mpfr-3.1.1.tar.bz2
1265 mkdir -pv ../gcc-build
1267 ../gcc-4.7.2/configure \
1268 --prefix=${TARGET_DIR}/cross-tools \
1269 --build=${CROSS_HOST} \
1270 --host=${CROSS_HOST} \
1271 --target=${CROSS_TARGET} \
1272 --with-sysroot=${TARGET_DIR} \
1273 --disable-multilib \
1278 --enable-languages=c \
1281 make all-target-libgcc
1283 make install-target-libgcc
1290 @option{--disable-multilib} specifies that multiple target libraries
1291 to support different target variants@footnote{Such as different ABI,
1292 for instance n32 and 64.}, calling conventions, etc@:. should not be
1293 built. The default is to build a predefined set of them.
1295 @option{--with-newlib} specifies that @samp{newlib} is being used as
1296 the target C library.
1298 @option{--disable-threads} specifies that threading support should be
1301 @option{--enable-languages=c} specifies that only the C compiler and
1302 its runtime libraries should be built.
1304 @c --with-abi=${MABI}
1306 GCC provides a low-level runtime library, @file{libgcc.a} or
1307 @file{libgcc_s.so.1} on some platforms. GCC generates calls to
1308 routines in this library automatically, whenever it needs to perform
1309 some operation that is too complicated to emit inline code for. This
1310 is built with @samp{make all-target-libgcc} and installed with
1311 @samp{make install-target-libgcc}
1315 @section Target glibc
1317 Glibc is the GNU C library. It provides macros, type definitions, and
1318 functions for tasks like string handling, mathematical computations,
1319 input/output processing, memory allocation and several other operating
1324 tar xf ${DOWNLOAD_DIR}/glibc-2.13.tar.bz2 -C ${BUILD_DIR}
1325 pushd ${BUILD_DIR}/glibc-2.13
1326 tar xf ${DOWNLOAD_DIR}/glibc-ports-2.13.tar.bz2
1327 mv -v glibc-ports-2.13 ports
1328 #sed -i.orig "s/\ -lgcc_eh\|\ -lgcc_s//g" Makeconfig
1329 patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.13-libgcc_eh.patch
1330 patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.13-ldd-rewrite-script.patch
1331 patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.13-localedef_segfault-1.patch
1332 patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.13-cross_hacks-2.patch
1333 echo "" > ports/sysdeps/mips/mips64/n64/Makefile
1334 echo "" > ports/sysdeps/mips/mips64/n32/Makefile
1335 echo "" > ports/sysdeps/mips/mips32/Makefile
1336 sed -i "/default) machine=/s/n32/${MABI}/g" \
1337 ports/sysdeps/mips/preconfigure
1338 mkdir -pv ../glibc-build
1341 cat > config.cache << EOF
1342 libc_cv_c_cleanup=yes
1343 libc_cv_slibdir=/lib
1346 cat > configparms << EOF
1347 install_root=${TARGET_DIR}
1352 CC="${CROSS_TARGET}-gcc -march=${MARCH} -mabi=${MABI}" \
1353 AR="${CROSS_TARGET}-ar" \
1354 RANLIB="${CROSS_TARGET}-ranlib" \
1355 ../glibc-2.13/configure \
1357 --libexecdir=/usr/lib/glibc \
1358 --build=${CROSS_HOST} \
1359 --host=${CROSS_TARGET} \
1363 --enable-kernel=3.5.4 \
1365 --with-binutils=${TARGET_DIR}/cross-tools/bin \
1366 --with-headers=${TARGET_DIR}/usr/include \
1367 --cache-file=config.cache
1370 make localedata/install-locales
1376 cat > ${TARGET_DIR}/etc/nsswitch.conf << "EOF"
1377 # Begin /etc/nsswitch.conf
1391 # End /etc/nsswitch.conf
1394 cp -v --remove-destination \
1395 ${TARGET_DIR}/usr/share/zoneinfo/Europe/Paris \
1396 ${TARGET_DIR}/etc/localtime
1398 cat > ${TARGET_DIR}/etc/ld.so.conf << "EOF"
1399 # Begin /etc/ld.so.conf
1404 # End /etc/ld.so.conf
1408 @c @samp{sed -i.orig "s/\ -lgcc_eh\|\ -lgcc_s//g" Makeconfig}
1410 The patch @file{glibc-2.13-libgcc_eh.patch} is used in order not to
1411 use library @samp{gcc_eh} to build @samp{libgcc_eh} and
1412 @samp{static-gnulib} if current compiler does not have
1415 The patch @file{glibc-2.13-ldd-rewrite-script.patch} is used to fix a
1416 bug in glibc when the configure script is called from a relative path.
1418 The patch @file{glibc-2.13-localedef_segfault-1.patch} is used to
1419 overcome a segfault you may have when generating locales if you use
1420 PaX. PaX is a patch for the kernel Linux that implements least
1421 privilege protections for memory pages.
1423 The patch @file{glibc-2.13-cross_hacks-2.patch} is used specially to
1424 build locales by cross-compilation.
1426 Glibc uses @samp{n32} ABI by default with MIPS. To use @env{MABI}
1427 instead, we do the following:
1430 echo "" > ports/sysdeps/mips/mips64/n64/Makefile
1431 echo "" > ports/sysdeps/mips/mips64/n32/Makefile
1432 echo "" > ports/sysdeps/mips/mips32/Makefile
1433 sed -i "/default) machine=/s/n32/${MABI}/g" \
1434 ports/sysdeps/mips/preconfigure
1438 Contents of the files above.
1440 cat mips64/n64/Makefile
1441 # `long double' is a distinct type we support.
1442 long-double-fcts = yes
1444 ifeq ($(filter -mabi=64,$(CC)),)
1448 cat mips64/n32/Makefile
1449 # `long double' is a distinct type we support.
1450 long-double-fcts = yes
1452 ifeq ($(filter -mabi=n32,$(CC)),)
1457 ifeq ($(filter -mabi=32,$(CC)),)
1461 grep 'default)' preconfigure
1463 default) machine=mips/mips64/n32 mips_config_abi=n32 ;;
1467 The file @file{config.cache} is used to attribute values to variables
1468 of the configure script.
1470 @samp{libc_cv_forced_unwind=yes} is used to avoid the error message
1471 @samp{error: forced unwind support is required}.
1473 @samp{libc_cv_c_cleanup=yes} is used to avoid the error message
1474 @samp{error: the compiler must support C cleanup handling}.
1476 @samp{libc_cv_slibdir=/lib} defines @file{/lib} as the directory in
1477 which the C library of the target system will be installed, instead of
1478 @file{/lib64} or @file{/lib32}.
1480 You can install glibc somewhere other than where you configured it to
1481 go by setting the @code{install_root} variable on the command line for
1482 @samp{make install}. The value of this variable is prepended to all
1483 the paths for installation. This is useful when setting up a chroot
1484 environment or preparing a binary distribution. The directory should
1485 be specified with an absolute file name.
1487 Files listed in @samp{install-lib} are installed in the directory
1488 specified by @samp{libdir} in @file{configparms} or @file{Makeconfig}.
1492 CC="${CROSS_TARGET}-gcc -march=${MARCH} -mabi=${MABI}" \
1493 AR="${CROSS_TARGET}-ar" \
1494 RANLIB="${CROSS_TARGET}-ranlib"
1497 @samp{CC="$@{CROSS_TARGET@}-gcc -march=$@{MARCH@} -mabi=$@{MABI@}"}
1498 sets @code{CC} to the cross-compiler for the target's architecture,
1499 processor and ABI we configured the library for. @code{AR} and
1500 @code{RANLIB} are set to cross-compiling versions of @code{ar} and
1501 @code{ranlib} as the native tools are not configured to work with
1502 object files for the target we configured for.
1504 @option{--prefix=/usr} tells the @file{configure} script to install
1505 glibc in the @file{/usr} directory of the target system.
1507 @c @option{--libexecdir=/usr/lib/glibc} tells the configure script to
1508 @c install glibc executables inside @file{/usr/lib/glibc}.
1510 Unlike previous builds, @option{--host} now equals
1511 @env{$@{CROSS_TARGET@}} instead of @env{$@{CROSS_HOST@}}. This is
1512 because we are building the glibc version that the target system will
1513 use. We won't have to build it later.
1515 Profiling can be of help to optimize a program by analysing memory
1516 use, the usage of particular instructions, etc. Option
1517 @option{--disable-profile} is used to disable this.
1519 Option @option{--enable-add-ons} is used to enable all the add-on
1520 packages in the main source directory, which includes the glibc-ports
1521 used to support the MIPS architecture.
1523 The option @option{--with-tls} tells the configure script to use
1524 @acronym{TLS} (thread-local storage). Thread-local storage is a
1525 computer programming method that uses memory local to a thread.
1527 The @samp{3.5.4} parameter given to option @option{--enable-kernel}
1528 describes the smallest version of the Linux kernel the generated
1529 library is expected to support. The higher the version number is, the
1530 less compatibility code is added, and the faster the code gets.
1532 Option @option{--with-__thread} enables threads in glibc.
1534 The option @option{--with-binutils=$@{TARGET_DIR@}/cross-tools/bin}
1535 tells the @file{configure} script to use the binutils (assembler and
1536 linker) built in the cross-compilation toolchain process.
1538 @option{--with-headers=$@{TARGET_DIR@}/usr/include} indicates the
1539 location of the kernel Linux' headers.
1541 @option{--cache-file=config.cache} specifies the file in which cache
1542 variables are listed for @file{configure}.
1544 @samp{make localedata/install-locales} configures all locales that are
1547 The file @file{$@{TARGET_DIR@}/etc/nsswitch.conf} contains the
1548 configuration of @acronym{NSS} (Name Service Switch). NSS is a facility
1549 in Unix-like operating systems that provides a variety of sources for
1550 common configuration databases and name resolution mechanisms. These
1551 sources include local operating system files (such as
1552 @file{/etc/passwd}, @file{/etc/group}, and @file{/etc/hosts}), the
1553 Domain Name System (DNS), the Network Information Service (NIS), and
1556 The timezone is defined for `Paris'.
1558 @c Purpose of the file @file{$@{TARGET_DIR@}/etc/ld.so.conf}
1562 @section Cross GCC (C and C++ support)
1564 In this section, we build a complete cross-compiler with support for C
1568 # 3 hours and 30 minutes
1569 tar xf ${DOWNLOAD_DIR}/gcc-4.7.2.tar.bz2 -C ${BUILD_DIR}
1570 pushd ${BUILD_DIR}/gcc-4.7.2
1571 tar xf ${DOWNLOAD_DIR}/gmp-5.0.5.tar.bz2
1573 tar xf ${DOWNLOAD_DIR}/mpc-1.0.1.tar.gz
1575 tar xf ${DOWNLOAD_DIR}/mpfr-3.1.1.tar.bz2
1577 mkdir -v ../gcc-build
1579 ../gcc-4.7.2/configure \
1580 --prefix=${TARGET_DIR}/cross-tools \
1581 --build=${CROSS_HOST} \
1582 --host=${CROSS_HOST} \
1583 --target=${CROSS_TARGET} \
1584 --with-sysroot=${TARGET_DIR} \
1587 --enable-__cxa_atexit \
1588 --disable-multilib \
1589 --with-abi=${MABI} \
1591 --enable-long-long \
1592 --enable-threads=posix \
1593 --enable-languages=c,c++
1602 @option{--enable-__cxa_atexit} enables @code{__cxa_atexit}, rather
1603 than @code{atexit}, to register C++ destructors for local statics and
1604 global objects. This is essential for fully standards-compliant
1605 handling of destructors, but requires @code{__cxa_atexit} in libc.
1607 @option{--enable-c99} enables support for the C99 standard.
1609 @option{--enable-long-long} enables support for @code{long long int}
1612 @c @option{--enable-threads=posix}
1615 @node Building Cross-Compilation Tools
1616 @chapter Building the Cross-Compilation Tools
1619 * Cross File:: File for cross-compilation.
1620 * Cross Groff:: Groff for cross-compilation.
1621 * Cross Shadow:: Shadow for cross-compilation.
1622 * Cross M4:: M4 for cross-compilation.
1623 * Cross Ncurses:: Ncurses for cross-compilation.
1624 * Cross Cleaning:: Cleaning up the cross-compilation toolchain.
1631 The command @command{file} is used to determine the type of a file:
1632 text, executable or data.
1636 tar xf ${DOWNLOAD_DIR}/file-5.11.tar.gz -C ${BUILD_DIR}
1637 pushd ${BUILD_DIR}/file-5.11
1639 --prefix=${TARGET_DIR}/cross-tools
1651 Groff is the GNU version of the roff document formatting system which
1652 is used to produce man pages.
1654 You need G++ on your system to compile this program from source. Under
1655 gNewSense Parkes, try @samp{sudo apt-get install g++-4.4}.
1659 psselect (part of psutils) is needed for documentation in HTML (see
1660 @uref{http://cblfs.cross-lfs.org/index.php/PSUtils}).
1667 tar xf ${DOWNLOAD_DIR}/groff-1.21.tar.gz -C ${BUILD_DIR}
1668 pushd ${BUILD_DIR}/groff-1.21
1671 --prefix=${TARGET_DIR}/cross-tools \
1680 @samp{PAGE=A4} defines the default format of pages for printed output.
1682 @option{--without-x} disables the dependancy on the X window system.
1688 The package contains programs to handle users, groups and passwords in
1689 a secure way: passwords are encrypted.
1693 tar xf ${DOWNLOAD_DIR}/shadow-4.1.4.3.tar.bz2 -C ${BUILD_DIR}
1694 pushd ${BUILD_DIR}/shadow-4.1.4.3
1695 patch -Np1 -i ${DOWNLOAD_DIR}/shadow-4.1.4.3-sysroot_hacks-1.patch
1697 's/bindir)\/\$\$i/bindir)\/mips64el-unknown-linux-gnu-\$\$i/' \
1700 echo "shadow_cv_passwd_dir=${TARGET_DIR}/bin" > config.cache
1701 echo "ac_cv_func_lckpwdf=no" >> config.cache
1703 --prefix=${TARGET_DIR}/cross-tools \
1704 --sbindir=${TARGET_DIR}/cross-tools/bin \
1705 --sysconfdir=${TARGET_DIR}/etc \
1710 --program-prefix=${CROSS_TARGET}- \
1711 --cache-file=config.cache
1712 sed -i.orig "/PASSWD_PROGRAM/s/passwd/${CROSS_TARGET}-&/" config.h
1716 rm -rf shadow-4.1.4.3
1720 @c @samp{shadow_cv_passwd_dir=$@{TARGET_DIR@}/bin}
1721 @c @samp{ac_cv_func_lckpwdf=no}
1723 The patch @file{shadow-4.1.4.3-sysroot_hacks-1.patch} is used so that
1724 shadow can be built with the sysroot method. Because we use this
1725 patch, @samp{shadow_cv_passwd_dir=$@{TARGET_DIR@}/bin} and
1726 @samp{ac_cv_func_lckpwdf=no} have to be added in @file{config.cache}
1727 in order for the @file{configure} script not to test the
1728 functionalities associated.
1730 @c @option{--sbindir=$@{TARGET_DIR@}/cross-tools/bin}
1732 @c @option{--sysconfdir=$@{TARGET_DIR@}/etc}
1734 @option{--without-audit}, @option{--without-libpam} and
1735 @option{--without-selinux} disable support for auditing, @acronym{PAM}
1736 (Pluggable authentication modules) and @acronym{SELinux}
1737 (Security-Enhanced Linux). We do not need those extra features.
1739 @option{--program-prefix=$@{CROSS_TARGET@}-} prepends the value of
1740 @env{CROSS_TARGET} (that is @samp{mips64el-unknown-linux-gnu} in this
1741 document) to installed program names for cross-compilation.
1743 @c @samp{sed -i.orig "/PASSWD_PROGRAM/s/passwd/$@{CROSS_TARGET@}-&/"
1744 @c config.h} is used to avoid the error message
1750 Bison 2.5 requires M4 to be built.
1752 GNU M4 is a package containing an implementation of the m4 macro
1753 language. GNU M4 is used in GNU Autoconf' @file{configure} files.
1757 tar xf ${DOWNLOAD_DIR}/m4-1.4.16.tar.bz2 -C ${BUILD_DIR}
1758 pushd ${BUILD_DIR}/m4-1.4.16
1760 --prefix=${TARGET_DIR}/cross-tools
1772 GNU ncurses contains a library used to write text-based user
1773 interfaces in a terminal-independent manner.
1777 tar xf ${DOWNLOAD_DIR}/ncurses-5.9.tar.gz -C ${BUILD_DIR}
1778 pushd ${BUILD_DIR}/ncurses-5.9
1780 --prefix=${TARGET_DIR}/cross-tools \
1784 install -m755 progs/tic ${TARGET_DIR}/cross-tools/bin
1790 @option{--without-shared} is used to avoid building the whole library
1791 as only @command{tic} is installed.
1794 @node Cross Cleaning
1795 @section Cleaning up Cross-Compilation Toolchain
1797 In order to save some space, binaries and libraries of
1798 cross-compilation tools can be stripped out.
1801 incorrect cleaning arguments used against library files can lead to
1802 library files breaking. For this reason, be careful of the command
1803 arguments. If you are not comfortable with this, you can skip this
1804 section as it will have no effect on the process of building the
1810 pushd ${TARGET_DIR}/cross-tools
1811 strip --strip-all bin/*
1812 strip --strip-debug lib/*
1816 @option{--strip-all} removes all symbols. This command reduces the
1817 size of the @file{bin} directory's content from 29 MB to 12 MB.
1819 @option{--strip-debug} removes debugging symbols only. This command
1820 reduces the size of the @file{lib} directory's content from 21 MB to
1824 @node Building the Target System
1825 @chapter Building the Target System
1827 After having set up the cross-compilation toolchain and tools, the
1828 operating system for the target machine is built in this chapter.
1831 * Environment Setup:: Setting up the environment.
1832 * Man Pages:: Building Man Pages.
1833 * Zlib:: Building Zlib.
1834 * Binutils:: Building Binutils.
1835 * GMP:: Building GMP.
1836 * MPFR:: Building MPFR.
1837 * MPC:: Building MPC.
1838 * GCC:: Building GCC.
1839 * Sed:: Building Sed.
1840 * E2fsprogs:: Building E2fsprogs.
1841 * Coreutils:: Building Coreutils.
1842 * iana-etc:: Building iana-etc.
1844 * Bison:: Building Bison.
1845 * Ncurses:: Building Ncurses.
1846 * Procps:: Building Procps.
1847 * Libtool:: Building Libtool.
1848 * Readline:: Building Readline.
1849 * Autoconf:: Building Autoconf.
1850 * Automake:: Building Automake.
1851 * Bash:: Building Bash.
1852 * Bzip2:: Building Bzip2.
1853 * DHCPCD:: Building DHCPCD.
1854 * Diffutils:: Building Diffutils.
1855 * File:: Building File.
1856 * Findutils:: Building Findutils.
1857 * Flex:: Building Flex.
1858 * Gawk:: Building Gawk.
1859 * Gettext:: Building Gettext.
1860 * Grep:: Building Grep.
1861 * Groff:: Building Groff.
1862 * Gzip:: Building Gzip.
1863 @c * Sysfsutils:: Building Sysfsutils.
1864 * IPutils:: Building IPutils.
1865 * Iproute2:: Building Iproute2.
1866 * Kbd:: Building Kbd.
1867 * Kmod:: Building Kmod.
1868 * Less:: Building Less.
1869 * Make:: Building Make.
1870 * Man:: Building Man.
1871 * Nano:: Building Nano.
1872 * Patch:: Building Patch.
1873 * Psmisc:: Building Psmisc.
1874 * Rsyslog:: Building Rsyslog.
1875 * Shadow:: Building Shadow.
1876 * Sysvinit:: Building Sysvinit.
1877 * Tar:: Building Tar.
1878 * Texinfo:: Building Texinfo.
1879 * Udev:: Building Udev.
1880 * Util-Linux:: Building Util-Linux.
1881 @c * Emacs:: Building Emacs.
1882 * XZ-Utils:: Building XZ-Utils.
1883 * Bootscripts:: Building Bootscripts.
1884 * Kernel:: Building the Kernel.
1888 @node Environment Setup
1889 @section Setting up the Environment
1891 Because this chapter is about the build of the target system and not
1892 the build of the cross-compilation toolchain and tools anymore, we
1893 need to update some environment variables.
1895 For more convenience, we can set environment variables up in the
1896 @file{~/.bashrc} file, so that this setup is preserved when logging
1901 cat >> ~/.bashrc << EOF
1902 export CFLAGS="-Wa,-mfix-loongson2f-nop"
1903 export CC="${CROSS_TARGET}-gcc -march=${MARCH} -mabi=${MABI}"
1904 export CXX="${CROSS_TARGET}-g++ -march=${MARCH} -mabi=${MABI}"
1905 export AR="${CROSS_TARGET}-ar"
1906 export AS="${CROSS_TARGET}-as"
1907 export RANLIB="${CROSS_TARGET}-ranlib"
1908 export LD="${CROSS_TARGET}-ld"
1909 export STRIP="${CROSS_TARGET}-strip"
1911 source ~/.bash_profile
1914 The variable @env{CFLAGS} is set to @option{-Wa,-mfix-loongson2f-nop}
1915 in which @option{-Wa} is a GCC option used to pass
1916 @option{-mfix-loongson2f-nop} to the assembler. This option replaces
1917 @code{NOP}@footnote{See @uref{http://en.wikipedia.org/wiki/NOP} for
1918 more information} by @code{or at,at,zero} to work around the
1919 Loongson2F @code{NOP} errata. Without it, under extreme cases, CPU
1920 might deadlock@footnote{For more information about the issue, see
1921 @uref{http://groups.google.com/group/loongson-dev/browse_thread/thread/d9103283141c00fb/e9a8830b01cc1913?hide_quotes=no#msg_d44adf83639fb0bd}
1923 @uref{http://sourceware.org/ml/binutils/2009-11/msg00387.html}.}.
1925 @env{CC} is the flag that indicates the C compiler to be used,
1926 @env{CXX} the C++ compiler, @env{AR} the archiver, @env{AS} the
1927 assembler, @env{RANLIB} the archives' index generator, @env{LD} the
1928 linker and @env{STRIP} the program for stripping.
1930 All the programs to be used are prefixed with
1931 @samp{$@{CROSS_TARGET@}-} in order to use the cross-compilation
1932 toolchain instead of the toolchain of the host.
1938 The man-pages package documents the kernel Linux and C library's
1939 interfaces that are used by user-space programs.
1943 tar xf ${DOWNLOAD_DIR}/man-pages-3.32.tar.bz2 -C ${BUILD_DIR}
1944 pushd ${BUILD_DIR}/man-pages-3.32
1945 make prefix=${TARGET_DIR}/usr install
1947 rm -rf man-pages-3.32
1951 The option @option{prefix=$@{TARGET_DIR@}/usr} is used to install the
1952 man pages on the target partition's @env{TARGET_DIR} instead of the
1953 @file{/usr} directory of the host.
1959 Zlib is a compression/decompression library.
1963 tar xf ${DOWNLOAD_DIR}/zlib-1.2.7.tar.bz2 -C ${BUILD_DIR}
1964 pushd ${BUILD_DIR}/zlib-1.2.7
1968 make prefix=${TARGET_DIR}/usr install
1969 # For FHS compatibility:
1970 #mv -v ${TARGET_DIR}/usr/lib/libz.so.* ${TARGET_DIR}/lib
1971 #ln -svf ../../lib/libz.so.1 ${TARGET_DIR}/usr/lib/libz.so
1977 In order to build zlib by cross-compilation, the flag @env{AR} has to
1978 be equal to @samp{$@{AR@}}.
1981 @samp{mv -v $@{TARGET_DIR@}/usr/lib/libz.so.* $@{TARGET_DIR@}/lib} and
1982 @samp{ln -svf ../../lib/libz.so.1 $@{TARGET_DIR@}/usr/lib/libz.so} are
1983 used to comply with the @acronym{FHS} (filesystem hierarchy standard).
1992 tar xf ${DOWNLOAD_DIR}/binutils-2.22.tar.bz2 -C ${BUILD_DIR}
1993 pushd ${BUILD_DIR}/binutils-2.22
1994 mkdir -pv ../binutils-build
1995 cd ../binutils-build
1996 ../binutils-2.22/configure \
1998 --build=${CROSS_HOST} \
1999 --host=${CROSS_TARGET} \
2000 --target=${CROSS_TARGET} \
2001 --enable-64-bit-bfd \
2005 make DESTDIR=${TARGET_DIR} tooldir=/usr install
2006 cp -v ../binutils-2.22/include/libiberty.h ${TARGET_DIR}/usr/include
2008 rm -rf binutils-build
2009 rm -rf binutils-2.22
2013 The option @option{--host} is now set to @env{CROSS_TARGET} because
2014 the host that will run this build will be the target system.
2016 @c @samp{make tooldir=/usr}
2017 @c @samp{make DESTDIR=$@{TARGET_DIR@} tooldir=/usr install}
2023 @acronym{GMP} (GNU multiple precision arithmetic library) is required
2028 tar xf ${DOWNLOAD_DIR}/gmp-5.0.5.tar.bz2 -C ${BUILD_DIR}
2029 pushd ${BUILD_DIR}/gmp-5.0.5
2031 --host=${CROSS_TARGET} \
2036 make DESTDIR=${TARGET_DIR} install
2037 rm -v ${TARGET_DIR}/usr/lib/lib{gmp,gmpxx,mp}.la
2043 The option @option{--enable-cxx} enables support for the C++ language.
2045 The Berkeley MP compatibility library (libmp) and header file
2046 (@file{mp.h}) are built and installed if the option
2047 @option{--enable-mpbsd} is used.
2049 The files @file{$@{TARGET_DIR@}/usr/lib/lib@{gmp,gmpxx,mp@}.la} are
2050 removed to avoid the following error when building MPFR:
2051 @samp{/usr/lib/libgmp.so: could not read symbols: File in wrong
2058 GNU @acronym{MPFR} (Multiple Precision Floating-Point Reliably) is a
2059 portable C library for arbitrary-precision binary floating-point
2060 computation with correct rounding.
2064 tar xf ${DOWNLOAD_DIR}/mpfr-3.1.1.tar.bz2 -C ${BUILD_DIR}
2065 pushd ${BUILD_DIR}/mpfr-3.1.1
2067 --host=${CROSS_TARGET} \
2070 make DESTDIR=${TARGET_DIR} install
2071 rm -v ${TARGET_DIR}/usr/lib/libmpfr.la
2077 The file @file{$@{TARGET_DIR@}/usr/lib/libmpfr.la} is removed to
2078 avoid the following error when building MPC:
2079 @samp{/usr/lib/libmpfr.so: could not read symbols: File in wrong
2086 GNU @acronym{MPC} (Multiple Precision Complex Library) is a C library
2087 for the arithmetic of complex numbers with arbitrarily high precision
2088 and correct rounding of the result.
2092 tar xf ${DOWNLOAD_DIR}/mpc-1.0.1.tar.gz -C ${BUILD_DIR}
2093 pushd ${BUILD_DIR}/mpc-1.0.1
2095 --host=${CROSS_TARGET} \
2098 make DESTDIR=${TARGET_DIR} install
2109 # 3 hours and 30 minutes
2110 tar xf ${DOWNLOAD_DIR}/gcc-4.7.2.tar.bz2 -C ${BUILD_DIR}
2111 pushd ${BUILD_DIR}/gcc-4.7.2
2112 sed -i.orig 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
2113 sed -i.orig 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
2114 mkdir -v ../gcc-build
2116 ../gcc-4.7.2/configure \
2118 --libexecdir=/usr/lib \
2119 --build=${CROSS_HOST} \
2120 --host=${CROSS_TARGET} \
2121 --target=${CROSS_TARGET} \
2123 --enable-threads=posix \
2124 --enable-__cxa_atexit \
2126 --enable-long-long \
2127 --disable-multilib \
2128 --with-abi=${MABI} \
2129 --enable-clocale=gnu \
2130 --enable-languages=c,c++ \
2131 --disable-libstdcxx-pch
2133 make DESTDIR=${TARGET_DIR} install
2134 # For FHS compatibility:
2135 #ln -sv ../usr/bin/cpp ${TARGET_DIR}/lib
2136 ln -sv gcc ${TARGET_DIR}/usr/bin/cc
2144 # The following patch seems needless to me as it only replaces
2145 # {usr,}/lib32 with {usr,}/lib64 and we already have:
2146 # {usr,}/lib32 -> {usr,}/lib
2147 # {usr,}/lib64 -> {usr,}/lib
2148 #patch -Np1 -i ${DOWNLOAD_DIR}/gcc-4.6.0-pure64-1.patch
2151 @samp{sed -i.orig 's/install_to_$(INSTALL_DEST) //'
2152 libiberty/Makefile.in} is used as we already installed the library
2153 @file{libiberty.a} with Binutils.
2155 @c We use @samp{sed -i.orig 's@@\./fixinc\.sh@@-c true@@'
2156 @c gcc/Makefile.in} to avoid using fixincludes that may output errors if
2157 @c headers have been modified.
2159 Using @option{--enable-clocale=gnu} option ensures that the correct
2160 locale will automatically be chosen.
2162 Option @option{--disable-libstdcxx-pch} disables support for
2163 precompiled headers (PCH).
2165 @c ln -sv ../usr/bin/cpp ${TARGET_DIR}/lib FHS?
2167 The line @samp{ln -sv gcc $@{TARGET_DIR@}/usr/bin/cc} creates a
2168 symbolic link @file{cc} that points on @file{gcc}.
2174 GNU sed is a stream editor: it is used to perform basic text
2175 transformations on an input stream (a file or input from a pipeline).
2179 tar xf ${DOWNLOAD_DIR}/sed-4.2.1.tar.bz2 -C ${BUILD_DIR}
2180 pushd ${BUILD_DIR}/sed-4.2.1
2182 --build=${CROSS_HOST} \
2183 --host=${CROSS_TARGET} \
2187 make DESTDIR=${TARGET_DIR} install
2193 @c @option{--bindir=/bin} FHS?
2199 E2fsprogs is a package that contains tools to handle the ext2, ext3
2200 and ext4 filesystems.
2204 tar xf ${DOWNLOAD_DIR}/e2fsprogs-1.42.6.tar.gz -C ${BUILD_DIR}
2205 pushd ${BUILD_DIR}/e2fsprogs-1.42.6
2209 --build=${CROSS_HOST} \
2210 --host=${CROSS_TARGET} \
2212 --with-root-prefix="" \
2215 make DESTDIR=${TARGET_DIR} install
2216 make DESTDIR=${TARGET_DIR} install-libs
2217 rm -v ${TARGET_DIR}/usr/lib/lib{blkid,com_err,e2p,ext2fs,ss,uuid}.so
2218 ln -sv ../../lib/libblkid.so.1 ${TARGET_DIR}/usr/lib/libblkid.so
2219 ln -sv ../../lib/libcom_err.so.2 ${TARGET_DIR}/usr/lib/libcom_err.so
2220 ln -sv ../../lib/libe2p.so.2 ${TARGET_DIR}/usr/lib/libe2p.so
2221 ln -sv ../../lib/libext2fs.so.2 ${TARGET_DIR}/usr/lib/libext2fs.so
2222 ln -sv ../../lib/libss.so.2 ${TARGET_DIR}/usr/lib/libss.so
2223 ln -sv ../../lib/libuuid.so.1 ${TARGET_DIR}/usr/lib/libuuid.so
2225 rm -rf e2fsprogs-1.42.6
2229 @option{--with-root-prefix=""} is used to put e2fsprogs binaries
2230 inside @file{/sbin} instead of @file{@var{PREFIX}/sbin} which would be
2233 Option @option{--enable-elf-shlibs} enables e2fsprogs shared
2236 @samp{make DESTDIR=$@{TARGET_DIR@} install-libs} is used to install
2237 libraries, those are not installed with @samp{make
2238 DESTDIR=$@{TARGET_DIR@} install}.
2240 The sequence of commands that follows first removes symbolic links
2241 @file{$@{TARGET_DIR@}/usr/lib/lib@{@/blkid,com_err,e2p,ext2fs,ss,uuid@}.so}
2242 which point on abolute paths
2243 @file{/lib/lib@{blkid,com_err,e2p,ext2fs,ss,uuid@}.so}. In order to
2244 use the libraries of the target operating system, we need to symlink
2245 @file{$@{TARGET_DIR@}/usr/lib/lib@{blkid,com_err,e2p,ext2fs,ss,uuid@}.so}
2246 to their relative paths files.
2252 GNU coreutils (core utilities) includes the standard programs for text
2253 and file manipulation.
2255 On gNewSense Parkes, you need to install @file{xz-utils} to extract
2260 tar xf ${DOWNLOAD_DIR}/coreutils-8.19.tar.xz -C ${BUILD_DIR}
2261 pushd ${BUILD_DIR}/coreutils-8.19
2262 sed -i.orig '/strftime/s/\ LC_ALL//' man/help2man
2263 cat > config.cache << EOF
2264 fu_cv_sys_stat_statfs2_bsize=yes
2265 gl_cv_func_mbrtowc_incomplete_state=yes
2266 gl_cv_func_mbrtowc_nul_retval=yes
2267 gl_cv_func_mbrtowc_null_arg=yes
2268 gl_cv_func_mbrtowc_retval=yes
2269 gl_cv_func_btowc_eof=yes
2270 gl_cv_func_wcrtomb_retval=yes
2271 gl_cv_func_wctob_works=yes
2272 gl_cv_func_fstatat_zero_flag=yes
2274 #fu_cv_sys_stat_statfs2_bsize=yes
2275 #gl_cv_func_working_mkstemp=yes
2278 --build=${CROSS_HOST} \
2279 --host=${CROSS_TARGET} \
2281 --enable-install-program=hostname \
2282 --enable-no-install-program=kill,uptime \
2283 --cache-file=config.cache
2285 make DESTDIR=${TARGET_DIR} install
2286 # For FHS compatibility:
2287 #mv -v ${TARGET_DIR}/usr/bin/{cat,chgrp,chmod,chown,cp,date} \
2289 #mv -v ${TARGET_DIR}/usr/bin/{dd,df,echo,false,hostname,ls,mkdir} \
2291 #mv -v ${TARGET_DIR}/usr/bin/{mv,pwd,rm,rmdir,stty,true,ln,uname} \
2293 #mv -v ${TARGET_DIR}/usr/bin/chroot ${TARGET_DIR}/usr/sbin
2294 #mv -v ${TARGET_DIR}/usr/bin/{[,basename,head,install,nice} \
2296 #mv -v ${TARGET_DIR}/usr/bin/{readlink,sleep,sync,test,touch} \
2298 #ln -svf ../../bin/install ${TARGET_DIR}/usr/bin
2300 rm -rf coreutils-8.19
2304 @c @samp{sed -i.orig '/strftime/s/\ LC_ALL//' man/help2man}
2306 The variables listed in the file @file{config.cache} are used in order
2307 to avoid that the @file{configure} script evaluate their values:
2308 otherwise the build may fail when cross-compiling.
2310 We use @option{--enable-install-program=hostname} to install the
2311 command @command{hostname} which is not built by default.
2313 We use @option{--enable-no-install-program=kill,uptime} in order not
2314 to install commands @command{kill} and @command{uptime}. Those
2315 commands will be installed by the package procps.
2319 mv -v ${TARGET_DIR}/usr/bin/{cat,chgrp,chmod,chown,cp,date} \
2321 mv -v ${TARGET_DIR}/usr/bin/{dd,df,echo,false,hostname,ls,mkdir} \
2323 mv -v ${TARGET_DIR}/usr/bin/{mv,pwd,rm,rmdir,stty,true,ln,uname} \
2325 mv -v ${TARGET_DIR}/usr/bin/chroot ${TARGET_DIR}/usr/sbin
2326 mv -v ${TARGET_DIR}/usr/bin/{[,basename,head,install,nice} \
2328 mv -v ${TARGET_DIR}/usr/bin/{readlink,sleep,sync,test,touch} \
2332 All programs of coreutils are moved from target system's
2333 @file{/usr/bin} to @file{/bin} for consistency.
2337 Because some programs use the target system's location @file{/usr/bin}
2338 and others the location @file{/bin} to call the command
2339 @command{install}, we symlink using @samp{ln -svf ../../bin/install
2340 $@{TARGET_DIR@}/usr/bin}.
2347 The iana-etc package installs services and protocols using data from
2348 the Internet Assigned Numbers Authority (IANA).
2352 tar xf ${DOWNLOAD_DIR}/iana-etc-2.30.tar.bz2 -C ${BUILD_DIR}
2353 pushd ${BUILD_DIR}/iana-etc-2.30
2355 make DESTDIR=${TARGET_DIR} install
2357 rm -rf iana-etc-2.30
2367 tar xf ${DOWNLOAD_DIR}/m4-1.4.16.tar.bz2 -C ${BUILD_DIR}
2368 pushd ${BUILD_DIR}/m4-1.4.16
2370 --build=${CROSS_HOST} \
2371 --host=${CROSS_TARGET} \
2374 make DESTDIR=${TARGET_DIR} install
2384 GNU bison parser generator.
2388 tar xf ${DOWNLOAD_DIR}/bison-2.5.tar.bz2 -C ${BUILD_DIR}
2389 pushd ${BUILD_DIR}/bison-2.5
2391 --build=${CROSS_HOST} \
2392 --host=${CROSS_TARGET} \
2394 echo '#define YYENABLE_NLS 1' >> config.h
2396 make DESTDIR=${TARGET_DIR} install
2402 @samp{echo '#define YYENABLE_NLS 1' >> config.h} is used to build
2403 @acronym{NLS} (native language support) inside bison.
2411 tar xf ${DOWNLOAD_DIR}/ncurses-5.9.tar.gz -C ${BUILD_DIR}
2412 pushd ${BUILD_DIR}/ncurses-5.9
2414 --build=${CROSS_HOST} \
2415 --host=${CROSS_TARGET} \
2421 --with-build-cc="gcc -D_GNU_SOURCE" \
2424 make DESTDIR=${TARGET_DIR} install
2425 # For FHS compatibility:
2426 #mv -v ${TARGET_DIR}/lib/lib{panel,menu,form,ncurses,ncurses++}w.a \
2427 # ${TARGET_DIR}/usr/lib
2428 #rm -v ${TARGET_DIR}/lib/lib{ncurses,menu,panel,form}w.so
2429 #ln -svf ../../lib/libncursesw.so.5 \
2430 # ${TARGET_DIR}/usr/lib/libncursesw.so
2431 #ln -svf ../../lib/libmenuw.so.5 ${TARGET_DIR}/usr/lib/libmenuw.so
2432 #ln -svf ../../lib/libpanelw.so.5 ${TARGET_DIR}/usr/lib/libpanelw.so
2433 #ln -svf ../../lib/libformw.so.5 ${TARGET_DIR}/usr/lib/libformw.so
2434 #for lib in curses ncurses form panel menu ; do
2435 # echo "INPUT(-l${lib}w)" > ${TARGET_DIR}/usr/lib/lib${lib}.so
2436 # ln -sfv lib${lib}w.a ${TARGET_DIR}/usr/lib/lib${lib}.a
2438 ln -sfv libncursesw.so ${TARGET_DIR}/lib/libncurses.so
2439 #ln -sfv libncursesw.so ${TARGET_DIR}/usr/lib/libcursesw.so
2440 #ln -sfv libncursesw.a ${TARGET_DIR}/usr/lib/libcursesw.a
2441 #ln -sfv libncurses++w.a ${TARGET_DIR}/usr/lib/libncurses++.a
2442 #ln -sfv ncursesw5-config ${TARGET_DIR}/usr/bin/ncurses5-config
2443 #ln -sfv ../../usr/share/terminfo ${TARGET_DIR}/usr/lib/terminfo
2449 Option @option{--enable-widec} enables wide characters support in
2452 @c Option @option{--without-debug}
2454 Option @option{--without-ada} disables support for the Ada programming
2455 language inside ncurses.
2457 @c Option @option{--with-build-cc="gcc -D_GNU_SOURCE"}
2459 @c Option @option{--libdir=/lib}
2463 mv -v ${TARGET_DIR}/lib/lib{panel,menu,form,ncurses,ncurses++}w.a \
2464 ${TARGET_DIR}/usr/lib
2465 rm -v ${TARGET_DIR}/lib/lib{ncurses,menu,panel,form}w.so
2466 ln -svf ../../lib/libncursesw.so.5 \
2467 ${TARGET_DIR}/usr/lib/libncursesw.so
2468 ln -svf ../../lib/libmenuw.so.5 ${TARGET_DIR}/usr/lib/libmenuw.so
2469 ln -svf ../../lib/libpanelw.so.5 ${TARGET_DIR}/usr/lib/libpanelw.so
2470 ln -svf ../../lib/libformw.so.5 ${TARGET_DIR}/usr/lib/libformw.so
2473 According to the filesystem hierarchy standard (FHS), ncurses
2474 libraries should be inside @file{/usr/lib} instead of @file{/lib}.
2477 for lib in curses ncurses form panel menu ; do
2478 echo "INPUT(-l${lib}w)" > ${TARGET_DIR}/usr/lib/lib${lib}.so
2479 ln -sfv lib${lib}w.a ${TARGET_DIR}/usr/lib/lib${lib}.a
2481 ln -sfv libncursesw.so ${TARGET_DIR}/usr/lib/libcursesw.so
2482 ln -sfv libncursesw.a ${TARGET_DIR}/usr/lib/libcursesw.a
2483 ln -sfv libncurses++w.a ${TARGET_DIR}/usr/lib/libncurses++.a
2484 ln -sfv ncursesw5-config ${TARGET_DIR}/usr/bin/ncurses5-config
2487 The commands above create symlinks from libraries without support for
2488 wide characters to libraries with support for them.
2492 The command @samp{ln -sfv libncursesw.so $@{TARGET_DIR@}/lib/libncurses.so}
2493 creates the symlink @file{libcurses.so} so that programs that do not
2494 know @file{libncursesw.so} can be linked against it.
2496 @c ln -sfv ../../usr/share/terminfo ${TARGET_DIR}/usr/lib/terminfo
2502 The procps package contains utilities that give information about
2503 processes using the @file{/proc} filesystem. The package includes the
2504 commands @command{ps}, @command{top}, @command{vmstat}, @command{w},
2505 @command{kill}, @command{free}, @command{slabtop}, and
2510 tar xf ${DOWNLOAD_DIR}/procps-3.2.8.tar.gz -C ${BUILD_DIR}
2511 pushd ${BUILD_DIR}/procps-3.2.8
2516 DESTDIR=${TARGET_DIR} \
2519 install="install -D" \
2526 Option @option{CPPFLAGS= } is used so that the target system's ncurses
2527 library will be used, default value would have been
2528 @option{-I/usr/include/ncurses}.
2530 Option @option{lib64=lib} makes the directory @file{/lib} the one
2531 where to put 64 bit libraries, default would be @file{/lib64}.
2533 Option @option{ldconfig= } is used in order not to use current host's
2536 Option @option{install="install -D"} is used so that all the files
2537 installed are owned by the current user. By default, all installed
2538 files are owned by root.
2544 GNU libtool is a generic library support script. It hides the
2545 complexity of using shared libraries behind a consistent, portable
2550 tar xf ${DOWNLOAD_DIR}/libtool-2.4.tar.gz -C ${BUILD_DIR}
2551 pushd ${BUILD_DIR}/libtool-2.4
2553 --build=${CROSS_HOST} \
2554 --host=${CROSS_TARGET} \
2557 make DESTDIR=${TARGET_DIR} install
2567 The GNU Readline library provides a set of functions for use by
2568 applications that allow users to edit command lines as they are typed
2573 tar xf ${DOWNLOAD_DIR}/readline-6.2.tar.gz -C ${BUILD_DIR}
2574 pushd ${BUILD_DIR}/readline-6.2
2576 --build=${CROSS_HOST} \
2577 --host=${CROSS_TARGET} \
2581 make DESTDIR=${TARGET_DIR} install
2582 make DESTDIR=${TARGET_DIR} install-doc
2583 # For FHS compatibility:
2584 #mv -v ${TARGET_DIR}/lib/lib{readline,history}.a ${TARGET_DIR}/usr/lib
2585 #rm -v ${TARGET_DIR}/lib/lib{readline,history}.so
2586 #ln -svf ../../lib/libreadline.so.6 \
2587 # ${TARGET_DIR}/usr/lib/libreadline.so
2588 #ln -svf ../../lib/libhistory.so.6 ${TARGET_DIR}/usr/lib/libhistory.so
2594 @c sed -i 's:^SHLIB_LIBS=:SHLIB_LIBS=-lncursesw:' support/shobj-conf
2597 mv -v ${TARGET_DIR}/lib/lib{readline,history}.a ${TARGET_DIR}/usr/lib
2598 rm -v ${TARGET_DIR}/lib/lib{readline,history}.so
2599 ln -svf ../../lib/libreadline.so.6 \
2600 ${TARGET_DIR}/usr/lib/libreadline.so
2601 ln -svf ../../lib/libhistory.so.6 ${TARGET_DIR}/usr/lib/libhistory.so
2608 GNU autoconf is an extensible package of M4 macros that produce shell
2609 scripts to automatically configure software source code
2610 packages. These scripts can adapt the packages to many kinds of
2611 UNIX-like systems without manual user intervention.
2615 tar xf ${DOWNLOAD_DIR}/autoconf-2.69.tar.gz -C ${BUILD_DIR}
2616 pushd ${BUILD_DIR}/autoconf-2.69
2618 --build=${CROSS_HOST} \
2619 --host=${CROSS_TARGET} \
2622 make DESTDIR=${TARGET_DIR} install
2624 rm -rf autoconf-2.69
2632 GNU automake is a tool for automatically generating @file{Makefile.in}
2633 files compliant with the GNU Coding
2634 Standards@footnote{@uref{http://www.gnu.org/prep/standards/}}.
2638 tar xf ${DOWNLOAD_DIR}/automake-1.12.4.tar.gz -C ${BUILD_DIR}
2639 pushd ${BUILD_DIR}/automake-1.12.4
2641 --build=${CROSS_HOST} \
2642 --host=${CROSS_TARGET} \
2645 make DESTDIR=${TARGET_DIR} install
2647 rm -rf automake-1.12.4
2655 GNU @acronym{Bash} (Bourne again shell) is an sh-compatible shell that
2656 incorporates useful features from the Korn shell (ksh) and C shell
2661 tar xf ${DOWNLOAD_DIR}/bash-4.2.tar.gz -C ${BUILD_DIR}
2662 pushd ${BUILD_DIR}/bash-4.2
2663 cat > config.cache << "EOF"
2664 ac_cv_func_mmap_fixed_mapped=yes
2665 ac_cv_func_strcoll_works=yes
2666 ac_cv_func_working_mktime=yes
2667 bash_cv_func_sigsetjmp=present
2668 bash_cv_getcwd_malloc=yes
2669 bash_cv_job_control_missing=present
2670 bash_cv_printf_a_format=yes
2671 bash_cv_sys_named_pipes=present
2672 bash_cv_ulimit_maxfds=yes
2673 bash_cv_under_sys_siglist=yes
2674 bash_cv_unusable_rtsigs=no
2675 gt_cv_int_divbyzero_sigfpe=yes
2678 --build=${CROSS_HOST} \
2679 --host=${CROSS_TARGET} \
2682 --cache-file=config.cache \
2683 --without-bash-malloc \
2684 --with-installed-readline
2687 DESTDIR=${TARGET_DIR} \
2688 htmldir=/usr/share/doc/bash-4.2 \
2690 ln -sv bash ${TARGET_DIR}/bin/sh
2696 The variables listed in the file @file{config.cache} are used in order
2697 to avoid that the @file{configure} script evaluate their values:
2698 otherwise the build may fail when cross-compiling.
2700 @c --bindir=/bin instead of /usr/bin, FHS?
2702 Option @option{--without-bash-malloc} tells the @file{configure}
2703 script not to use the @code{malloc} function shipped with
2704 Bash. Glibc's version will be used instead.
2706 Option @option{--with-installed-readline} tells the configure script
2707 to use the installed readline library instead of the one shipped with
2710 @c htmldir=/usr/share/doc/bash-4.2
2712 @samp{ln -sv bash $@{TARGET_DIR@}/bin/sh} creates a symlink @file{sh}
2719 Bzip2 is a package that contains utilities to compress and decompress
2720 files with a better original size/compressed size ratio than gzip.
2724 tar xf ${DOWNLOAD_DIR}/bzip2-1.0.6.tar.gz -C ${BUILD_DIR}
2725 pushd ${BUILD_DIR}/bzip2-1.0.6
2726 sed -i.orig -e "/^all:/s/ test//" Makefile
2727 sed -i -e 's:ln -s -f $(PREFIX)/bin/:ln -s :' Makefile
2729 -f Makefile-libbz2_so \
2739 PREFIX=${TARGET_DIR}/usr \
2741 cp -v bzip2-shared ${TARGET_DIR}/bin/bzip2
2742 cp -av libbz2.so* ${TARGET_DIR}/lib
2743 ln -sv ../../lib/libbz2.so.1.0 ${TARGET_DIR}/usr/lib/libbz2.so
2744 rm -v ${TARGET_DIR}/usr/bin/{bunzip2,bzcat,bzip2}
2745 ln -sv bzip2 ${TARGET_DIR}/bin/bunzip2
2746 ln -sv bzip2 ${TARGET_DIR}/bin/bzcat
2752 @samp{sed -i.orig -e "/^all:/s/ test//" Makefile} is used to skip
2753 tests when building.
2755 @samp{sed -i -e 's:ln -s -f $(PREFIX)/bin/:ln -s :' Makefile} is used
2756 in order to have relative path symlinks instead of absolute ones.
2758 Option @option{-f Makefile-libbz2_so} is used to build shared
2761 Flags @env{CC}, @env{AR} and @env{RANLIB} are used so that bzip2 is
2762 built using cross-compilation tools instead of the host's ones.
2764 @samp{make clean} is used to clean up temporary files.
2766 The second build commands are used to build static libraries.
2769 cp -v bzip2-shared ${TARGET_DIR}/bin/bzip2
2770 cp -av libbz2.so* ${TARGET_DIR}/lib
2771 ln -sv ../../lib/libbz2.so.1.0 ${TARGET_DIR}/usr/lib/libbz2.so
2772 rm -v ${TARGET_DIR}/usr/bin/{bunzip2,bzcat,bzip2}
2773 ln -sv bzip2 ${TARGET_DIR}/bin/bunzip2
2774 ln -sv bzip2 ${TARGET_DIR}/bin/bzcat
2781 DHCPCD is a wrapper for the @acronym{DHCP} (Dynamic Host Configuration
2782 Protocol) client daemon.
2786 tar xf ${DOWNLOAD_DIR}/dhcpcd-5.6.2.tar.bz2 -C ${BUILD_DIR}
2787 pushd ${BUILD_DIR}/dhcpcd-5.6.2
2789 --build=${CROSS_HOST} \
2790 --host=${CROSS_TARGET} \
2794 --dbdir=/var/lib/dhcpcd \
2795 --libexecdir=/usr/lib/dhcpcd
2797 make DESTDIR=${TARGET_DIR} install
2803 @c Option @option{--bindir=/sbin} is used to comply with FHS?
2804 @c @option{--sysconfdir=/etc} @file{/etc} instead of ?
2805 @c @option{--dbdir=/var/lib/dhcpcd} @file{/var/lib/dhcpcd} instead of?
2806 @c @option{--libexecdir=/usr/lib/dhcpcd} @file{/usr/lib/dhcpcd} instead of ?
2812 GNU Diffutils is a package of several programs related to finding
2813 differences between files.
2817 tar xf ${DOWNLOAD_DIR}/diffutils-3.2.tar.gz -C ${BUILD_DIR}
2818 pushd ${BUILD_DIR}/diffutils-3.2
2820 --build=${CROSS_HOST} \
2821 --host=${CROSS_TARGET} \
2824 make DESTDIR=${TARGET_DIR} install
2826 rm -rf diffutils-3.2
2830 @c patch -Np1 -i ${DOWNLOAD_DIR}/diffutils-3.0-i18n-1.patch
2840 tar xf ${DOWNLOAD_DIR}/file-5.11.tar.gz -C ${BUILD_DIR}
2841 pushd ${BUILD_DIR}/file-5.11
2843 --build=${CROSS_HOST} \
2844 --host=${CROSS_TARGET} \
2847 make DESTDIR=${TARGET_DIR} install
2857 The GNU Find Utilities are typically used to provide directory search
2858 and file locating capabilities.
2862 tar xf ${DOWNLOAD_DIR}/findutils-4.4.2.tar.gz -C ${BUILD_DIR}
2863 pushd ${BUILD_DIR}/findutils-4.4.2
2864 cat > config.cache << EOF
2865 gl_cv_func_wcwidth_works=yes
2866 gl_cv_header_working_fcntl_h=yes
2867 ac_cv_func_fnmatch_gnu=yes
2870 --build=${CROSS_HOST} \
2871 --host=${CROSS_TARGET} \
2873 --libexecdir=/usr/lib/locate \
2874 --localstatedir=/var/lib/locate \
2875 --cache-file=config.cache
2877 make DESTDIR=${TARGET_DIR} install
2878 #mv -v ${TARGET_DIR}/usr/bin/find ${TARGET_DIR}/bin
2879 #sed -i.orig 's@find:=${BINDIR}@find:=/bin@' \
2880 # ${TARGET_DIR}/usr/bin/updatedb
2882 rm -rf findutils-4.4.2
2886 @c --libexecdir=/usr/lib/locate
2887 @c --localstatedir=/var/lib/locate
2890 File @file{find} is moved from target's system @file{/usr/bin} to
2891 @file{/bin} in order to comply with the FHS.
2893 Because we changed the location of @file{find}, we need to update its
2894 location in @file{/usr/bin/updatedb}.
2901 Flex is a tool for generating scanners. A scanner, sometimes called a
2902 tokenizer, is a program which recognizes lexical patterns in text.
2906 tar xf ${DOWNLOAD_DIR}/flex-2.5.37.tar.bz2 -C ${BUILD_DIR}
2907 pushd ${BUILD_DIR}/flex-2.5.37
2909 --build=${CROSS_HOST} \
2910 --host=${CROSS_TARGET} \
2912 --cache-file=config.cache
2914 make DESTDIR=${TARGET_DIR} install
2915 ln -sv libfl.a ${TARGET_DIR}/usr/lib/libl.a
2920 cat > ${TARGET_DIR}/usr/bin/lex << "EOF"
2922 exec /usr/bin/flex -l "$@"
2924 chmod -v 755 ${TARGET_DIR}/usr/bin/lex
2927 For compatibility issues, we create the symlink @file{libl.a}.
2929 We then create target system's @file{/usr/bin/lex} that will execute
2930 @command{flex} with option @option{-l} in order to behave with maximal
2931 compatibility like @command{lex}.
2934 @samp{sed -i.orig "s/-I@@includedir@@//g" Makefile.in} is used in
2935 order not to use host's headers in @file{/usr/include} during
2939 @c Variables @samp{ac_cv_func_malloc_0_nonnull=yes} and
2940 @c @samp{ac_cv_func_realloc_0_nonnull=yes} are used to get rid of
2941 @c error message: @samp{}.
2943 @c We use option @option{-fPIC} passed to the cross-compiler in order to
2944 @c generate position-independent code (PIC).
2950 GNU awk (Gawk) is a program used to select particular records in a
2951 file and perform operations upon them.
2955 tar xf ${DOWNLOAD_DIR}/gawk-4.0.1.tar.gz -C ${BUILD_DIR}
2956 pushd ${BUILD_DIR}/gawk-4.0.1
2958 --build=${CROSS_HOST} \
2959 --host=${CROSS_TARGET} \
2961 --libexecdir=/usr/lib
2963 make DESTDIR=${TARGET_DIR} install
2973 GNU gettext utilities are a set of tools that provides a framework to
2974 help packages produce multi-lingual messages.
2978 tar xf ${DOWNLOAD_DIR}/gettext-0.18.1.1.tar.gz -C ${BUILD_DIR}
2979 pushd ${BUILD_DIR}/gettext-0.18.1.1
2980 cat > config.cache << EOF
2981 am_cv_func_iconv_works=yes
2982 gl_cv_func_wcwidth_works=yes
2983 gt_cv_func_printf_posix=yes
2984 gt_cv_int_divbyzero_sigfpe=yes
2987 --build=${CROSS_HOST} \
2988 --host=${CROSS_TARGET} \
2990 --cache-file=config.cache
2992 #cp gettext-tools/gnulib-lib/.libs/libgettextlib.la{,i}
2993 #cp gettext-tools/src/.libs/libgettextsrc.la{,i}
2994 make DESTDIR=${TARGET_DIR} install
2996 rm -rf gettext-0.18.1.1
3000 @c The following patch may be skipped
3001 @c patch -Np1 -i ${DOWNLOAD_DIR}/gettext-0.18.1.1-rpath-1.patch
3003 @c cp gettext-tools/gnulib-lib/.libs/libgettextlib.la{,i} ?
3004 @c cp gettext-tools/src/.libs/libgettextsrc.la{,i} ?
3010 GNU @command{grep} command searches one or more input files for lines
3011 containing a match to a specified pattern.
3015 tar xf ${DOWNLOAD_DIR}/grep-2.14.tar.xz -C ${BUILD_DIR}
3016 pushd ${BUILD_DIR}/grep-2.14
3018 --build=${CROSS_HOST} \
3019 --host=${CROSS_TARGET} \
3022 --disable-perl-regexp
3024 make DESTDIR=${TARGET_DIR} install
3030 Option @option{--disable-perl-regexp} disables support of Perl-style
3031 regular expressions (regexp).
3039 tar xf ${DOWNLOAD_DIR}/groff-1.21.tar.gz -C ${BUILD_DIR}
3040 pushd ${BUILD_DIR}/groff-1.21
3041 patch -Np1 -i ${DOWNLOAD_DIR}/groff-1.21-cross-compilation.patch
3044 --build=${CROSS_HOST} \
3045 --host=${CROSS_TARGET} \
3051 make prefix=${TARGET_DIR}/usr install
3052 ln -sv soelim ${TARGET_DIR}/usr/bin/zsoelim
3053 ln -sv eqn ${TARGET_DIR}/usr/bin/geqn
3054 ln -sv tbl ${TARGET_DIR}/usr/bin/gtbl
3060 The patch @file{groff-1.21-cross-compilation.patch} fixes a bug in
3061 groff' @file{Makefile.in} that prevents the cross-compilation build.
3063 The variables @env{TROFFBIN=troff} and @env{GROFFBIN=groff} tell
3064 @command{make} to use @command{troff} and @command{groff} commands
3065 installed in the @ref{Building Cross-Compilation Tools} to build
3068 The variable @env{GROFF_BIN_PATH} before @env{PATH} is checked for
3069 programs @command{groff} is calling (preprocessors, troff, and output
3070 devices). If not set, it defaults to the directory where the
3071 @file{groff} binary is located.
3073 The symlinks are used for compatibility.
3079 GNU Gzip is a data compression program.
3083 tar xf ${DOWNLOAD_DIR}/gzip-1.5.tar.gz -C ${BUILD_DIR}
3084 pushd ${BUILD_DIR}/gzip-1.5
3086 --build=${CROSS_HOST} \
3087 --host=${CROSS_TARGET} \
3091 make DESTDIR=${TARGET_DIR} install
3092 # For FHS compatibility:
3093 #mv -v ${TARGET_DIR}/bin/z{egrep,cmp,diff,fgrep,force,grep,less,more} \
3094 # ${TARGET_DIR}/usr/bin
3095 #mv -v ${TARGET_DIR}/bin/znew \
3096 # ${TARGET_DIR}/usr/bin
3106 The iputils package is a set of small utilities for networking.
3110 tar xf ${DOWNLOAD_DIR}/iputils-s20071127.tar.bz2 -C ${BUILD_DIR}
3111 pushd ${BUILD_DIR}/iputils-s20071127
3112 patch -Np1 -i ${DOWNLOAD_DIR}/iputils-s20071127-fixes-2.patch
3114 install -v -m755 ping{,6} ${TARGET_DIR}/bin
3115 install -v -m755 arping ${TARGET_DIR}/usr/bin
3116 install -v -m755 clockdiff ${TARGET_DIR}/usr/bin
3117 install -v -m755 rdisc ${TARGET_DIR}/usr/bin
3118 install -v -m755 tracepath ${TARGET_DIR}/usr/bin
3119 install -v -m755 trace{path,route}6 ${TARGET_DIR}/usr/bin
3121 rm -rf iputils-s20071127
3125 @c patch -Np1 -i ${DOWNLOAD_DIR}/iputils-s20071127-manpages-2.patch
3131 Iproute2 is a collection of utilities for controlling TCP and UDP IP
3132 networking and traffic.
3136 tar xf ${DOWNLOAD_DIR}/iproute2-3.5.1.tar.bz2 -C ${BUILD_DIR}
3137 pushd ${BUILD_DIR}/iproute2-3.5.1
3138 sed -i.orig '/^TARGETS/s@arpd@@g' misc/Makefile
3140 DESTDIR=${TARGET_DIR} \
3142 DOCDIR=/usr/share/doc/iproute2 \
3143 MANDIR=/usr/share/man
3145 DESTDIR=${TARGET_DIR} \
3146 DOCDIR=/usr/share/doc/iproute2 \
3147 MANDIR=/usr/share/man \
3150 rm -rf iproute2-3.5.1
3154 @samp{sed -i.orig '/^TARGETS/s@@arpd@@@@g' misc/Makefile} is used to
3155 disable the build of @command{arpd} as it requires Berkeley DB to be
3158 @env{DOCDIR} and @env{MANDIR} indicate the location in which the
3159 documentation and the manual pages will be installed,
3160 respectively. Those are no absolute paths but use the value of
3161 @env{DESTDIR} as a prefix.
3167 Kbd contains keytable files and keyboard utilities.
3171 tar xf ${DOWNLOAD_DIR}/kbd-1.15.3.tar.gz -C ${BUILD_DIR}
3172 pushd ${BUILD_DIR}/kbd-1.15.3
3173 patch -Np1 -i ${DOWNLOAD_DIR}/kbd-1.15.3-es.po-fix-1.patch
3174 cat > config.cache << EOF
3175 ac_cv_func_setpgrp_void=yes
3176 ac_cv_func_malloc_0_nonnull=yes
3177 ac_cv_func_realloc_0_nonnull=yes
3180 --build=${CROSS_HOST} \
3181 --host=${CROSS_TARGET} \
3183 --cache-file=config.cache
3185 make DESTDIR=${TARGET_DIR} install
3186 # For FHS compatibility
3187 #mv -v ${TARGET_DIR}/usr/bin/{kbd_mode,dumpkeys,loadkeys,openvt} \
3189 #mv -v ${TARGET_DIR}/usr/bin/setfont \
3196 The patch @file{kbd-1.15.3-es.po-fix-1.patch} fixes a bug in
3203 Kmod (previously known as module-init-tools) provide userspace-side
3204 assistance in loading kernel modules and their dependencies.
3208 tar xf ${DOWNLOAD_DIR}/kmod-10.tar.gz -C ${BUILD_DIR}
3209 pushd ${BUILD_DIR}/kmod-10
3211 --build=${CROSS_HOST} \
3212 --host=${CROSS_TARGET} \
3219 DESTDIR=${TARGET_DIR} \
3227 @option{--with-zlib} enables support for modules compressed with
3230 By default, installation uses @env{INSTALL=install-with-care} which
3231 checks if old utilities have not been destroyed. To avoid this check,
3232 we use @env{INSTALL=install}.
3238 Less is a file pager. A file pager is used to view the content of a
3243 tar xf ${DOWNLOAD_DIR}/less-451.tar.gz -C ${BUILD_DIR}
3244 pushd ${BUILD_DIR}/less-451
3246 --build=${CROSS_HOST} \
3247 --host=${CROSS_TARGET} \
3251 make prefix=${TARGET_DIR}/usr install
3252 # For FHS compatibility:
3253 #mv -v ${TARGET_DIR}/usr/bin/less ${TARGET_DIR}/bin
3263 GNU @command{make} utility determines automatically which pieces of a
3264 large program need to be recompiled, and issues the commands to
3269 tar xf ${DOWNLOAD_DIR}/make-3.82.tar.bz2 -C ${BUILD_DIR}
3270 pushd ${BUILD_DIR}/make-3.82
3272 --build=${CROSS_HOST} \
3273 --host=${CROSS_TARGET} \
3276 make DESTDIR=${TARGET_DIR} install
3286 Man is an interface to the on-line reference manuals.
3290 tar xf ${DOWNLOAD_DIR}/man-1.6g.tar.gz -C ${BUILD_DIR}
3291 pushd ${BUILD_DIR}/man-1.6g
3292 sed -i.orig -e "/PREPATH=/s@=.*@=\"$(eval echo \
3293 ${TARGET_DIR}/{,usr/}{sbin,bin})\"@g" -e 's@-is@&Rc@g' configure
3294 sed -i.orig -e 's@MANPATH./usr/man@#&@g' \
3295 -e 's@MANPATH./usr/local/man@#&@g' src/man.conf.in
3298 sed -i.orig "s@${TARGET_DIR}@@" conf_script
3299 gcc src/makemsg.c -o src/makemsg
3301 make DESTDIR=${TARGET_DIR} install
3307 @c The patch below is needed to have full utf8
3308 @c patch -Np1 -i ${DOWNLOAD_DIR}/man-1.6g-i18n-1.patch
3309 @c patch -Np1 -i ${DOWNLOAD_DIR}/man-1.6g-new_compressors-1.patch
3311 In the first use of @command{sed}, the first part replaces
3312 @env{PREPATH} default value
3313 @samp{/bin:/usr/bin:/usr/ucb:/usr/local/@/bin:$PATH} with
3314 @samp{$@{TARGET_DIR@}/@{,usr/@}@{sbin,bin@}}. The variable
3315 @env{TARGET_DIR} is used to avoid errors when running the
3316 @file{configure} script.
3318 The second part is used to replace default options of the man pager
3319 @option{-is} with @option{-isRc}. Option @option{-c} will cause
3320 @command{less} to display man pages faster as this option disables
3325 The second call of @command{sed} tells @command{man} where the cat
3326 pages corresponding to given man pages should not be stored:
3327 @file{/usr/man} and @file{/usr/local/man}.
3329 Option @option{-confdir} is used to define configuration files
3330 location to target system's @file{/etc}.
3332 The third call of @command{sed} is used in order to remove the
3333 presence of @env{TARGET_DIR} on the target system's programs.
3335 @command{makemsg} will be used during the build, but because using the
3336 cross-compiler may make its build fail, we use the host's compiler.
3342 GNU nano is a lightweight text editor.
3346 tar xf ${DOWNLOAD_DIR}/nano-2.3.1.tar.gz -C ${BUILD_DIR}
3347 pushd ${BUILD_DIR}/nano-2.3.1
3349 --build=${CROSS_HOST} \
3350 --host=${CROSS_TARGET} \
3353 make DESTDIR=${TARGET_DIR} install
3360 commands in nano are displayed as in `^X'. The `^' character means
3361 @key{CTRL} key, so `^X' means @kbd{CTRL-X}.
3368 GNU patch takes a patch file containing a difference listing produced
3369 by the @command{diff} program and applies those differences to one or
3370 more original files, producing patched versions.
3374 tar xf ${DOWNLOAD_DIR}/patch-2.7.1.tar.bz2 -C ${BUILD_DIR}
3375 pushd ${BUILD_DIR}/patch-2.7.1
3376 cat > config.cache << EOF
3377 ac_cv_path_ed_PROGRAM=ed
3378 ac_cv_func_strnlen_working=yes
3381 --build=${CROSS_HOST} \
3382 --host=${CROSS_TARGET} \
3384 --cache-file=config.cache
3386 make prefix=${TARGET_DIR}/usr install
3396 This package contains utilities that use the proc filesystem.
3400 tar xf ${DOWNLOAD_DIR}/psmisc-22.20.tar.gz -C ${BUILD_DIR}
3401 pushd ${BUILD_DIR}/psmisc-22.20
3402 cat > config.cache << EOF
3403 ac_cv_func_malloc_0_nonnull=yes
3404 ac_cv_func_realloc_0_nonnull=yes
3407 --build=${CROSS_HOST} \
3408 --host=${CROSS_TARGET} \
3411 --cache-file=config.cache
3413 make DESTDIR=${TARGET_DIR} install
3414 # For FHS compatibility:
3415 #mv -v ${TARGET_DIR}/bin/pstree* ${TARGET_DIR}/usr/bin
3416 #ln -sv killall ${TARGET_DIR}/bin/pidof
3426 Rsyslog is an utility creating log messages.
3430 tar xf ${DOWNLOAD_DIR}/rsyslog-5.8.6.tar.gz -C ${BUILD_DIR}
3431 pushd ${BUILD_DIR}/rsyslog-5.8.6
3432 cat > config.cache << EOF
3433 ac_cv_func_malloc_0_nonnull=yes
3434 ac_cv_func_realloc_0_nonnull=yes
3436 PKG_CONFIG_PATH="${TARGET_DIR}/usr/lib/pkgconfig" \
3438 --build=${CROSS_HOST} \
3439 --host=${CROSS_TARGET} \
3442 --cache-file=config.cache
3444 make DESTDIR=${TARGET_DIR} install
3445 install -dv ${TARGET_DIR}/etc/rsyslog.d
3447 rm -rf rsyslog-5.8.6
3450 cat > ${TARGET_DIR}/etc/rsyslog.conf << "EOF"
3451 $ModLoad imuxsock.so
3454 $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
3458 $FileCreateMode 0640
3464 $RepeatedMsgReduction on
3466 $IncludeConfig /etc/rsyslog.d/*.conf
3468 auth,authpriv.* /var/log/auth.log
3469 *.*;auth,authpriv.none -/var/log/syslog
3470 daemon.* -/var/log/daemon.log
3471 kern.* -/var/log/kern.log
3472 lpr.* -/var/log/lpr.log
3473 mail.* -/var/log/mail.log
3474 user.* -/var/log/user.log
3478 auth,authpriv.none;\
3479 news.none;mail.none -/var/log/debug
3480 *.=info;*.=notice;*.=warn;\
3481 auth,authpriv.none;\
3483 mail,news.none -/var/log/messages
3485 # Emergency are shown to everyone
3490 @samp{install -dv $@{TARGET_DIR@}/etc/rsyslog.d} is used to create
3491 target system's @file{/etc/rsyslog.d} directory. Rsyslog looks for
3492 user-defined configuration files in this directory. The line
3493 @samp{$IncludeConfig /etc/rsyslog.d/*.conf} in the target system's
3494 configuration file @file{/etc/rsyslog.conf} has this purpose.
3496 We then create the target system's configuration file
3497 @file{/etc/rsyslog.conf}.
3505 tar xf ${DOWNLOAD_DIR}/shadow-4.1.4.3.tar.bz2 -C ${BUILD_DIR}
3506 pushd ${BUILD_DIR}/shadow-4.1.4.3
3507 patch -Np1 -i ${DOWNLOAD_DIR}/shadow-4.1.4.3-man-ru.patch
3509 echo "ac_cv_func_setpgrp_void=yes" > config.cache
3511 --build=${CROSS_HOST} \
3512 --host=${CROSS_TARGET} \
3519 --cache-file=config.cache \
3521 sed -i.orig 's/groups$(EXEEXT) //' src/Makefile
3522 for mkf in $(find man -name Makefile)
3524 sed -i.orig -e '/groups.1.xml/d' -e 's/groups.1 //' ${mkf}
3527 make DESTDIR=${TARGET_DIR} install
3528 sed -i.orig -e 's@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@' \
3529 -e 's@/var/spool/mail@/var/mail@' \
3530 ${TARGET_DIR}/etc/login.defs
3531 # For FHS compatibility:
3532 #mv -v ${TARGET_DIR}/usr/bin/passwd ${TARGET_DIR}/bin
3533 ${CROSS_TARGET}-pwconv
3534 ${CROSS_TARGET}-grpconv
3535 ${CROSS_TARGET}-passwd root
3537 rm -rf shadow-4.1.4.3
3542 Problem with those three commands with 4.1.5.1:
3544 ${CROSS_TARGET}-pwconv
3545 mips64el-unknown-linux-gnu-pwconv: failure while writing changes to /gllfsc/etc/shadow
3546 ${CROSS_TARGET}-grpconv
3547 mips64el-unknown-linux-gnu-grpconv: failure while writing changes to /gllfsc/etc/gshadow
3548 ${CROSS_TARGET}-passwd root
3549 mips64el-unknown-linux-gnu-passwd: Permission denied.
3553 ${CROSS_TARGET}-passwd root
3554 gives the following message:
3555 Cannot change ID to root.
3558 The patch @file{shadow-4.1.4.3-man-ru.patch} contains a fix to
3559 @file{man/ru/Makefile.am} preventing @samp{make install} to
3560 complete. @command{automake-1.11} is then run to update the makefile
3561 prototype @file{Makefile.in}.
3563 @c echo "ac_cv_func_setpgrp_void=yes" > config.cache
3565 The option @option{--enable-man} is used to generate man pages.
3567 The first call of @command{sed} disables the build of command
3568 @command{groups}, as coreutils already installed it.
3570 The second call of @command{sed} enables support for MD5 encrypted
3571 passwords and changes the mail default directory from
3572 @file{/var/spool/mail} to @file{/var/mail}.
3574 The @command{pwconv} command creates @file{shadow} file from file
3575 @file{passwd} and an optionally existing @file{shadow} file.
3577 The @command{grpconv} command creates @file{gshadow} file from file
3578 @file{group} and an optionally existing @file{gshadow} file.
3580 The command @samp{passwd root} will create the password for the root
3581 user, you will need it when logging in as root on your new system.
3587 Sysvinit is the system-V style init process. Init is the first process
3588 started during booting. It is started by the kernel. Init continues
3589 running as a daemon until the system is shut down. It is the direct or
3590 indirect ancestor of all other processes and automatically adopts all
3596 tar xf ${DOWNLOAD_DIR}/sysvinit-2.88dsf.tar.bz2 -C ${BUILD_DIR}
3597 pushd ${BUILD_DIR}/sysvinit-2.88dsf
3598 sed -i.orig -e 's@/dev/initctl@$(ROOT)&@g' \
3599 -e 's@\(mknod \)-m \([0-9]* \)\(.* \)p@\1\3p; chmod \2\3@g' \
3600 -e '/^ifeq/s/$(ROOT)//' \
3601 -e 's@/usr/lib@$(ROOT)&@' \
3604 make -C src ROOT=${TARGET_DIR} CC="${CC}"
3605 make -C src ROOT=${TARGET_DIR} INSTALL="install" install
3607 rm -rf sysvinit-2.88dsf
3610 cat > ${TARGET_DIR}/etc/inittab << "EOF"
3611 # Begin /etc/inittab
3615 si::sysinit:/etc/rc.d/init.d/rc sysinit
3617 l0:0:wait:/etc/rc.d/init.d/rc 0
3618 l1:S1:wait:/etc/rc.d/init.d/rc 1
3619 l2:2:wait:/etc/rc.d/init.d/rc 2
3620 l3:3:wait:/etc/rc.d/init.d/rc 3
3621 l4:4:wait:/etc/rc.d/init.d/rc 4
3622 l5:5:wait:/etc/rc.d/init.d/rc 5
3623 l6:6:wait:/etc/rc.d/init.d/rc 6
3625 ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
3627 su:S016:once:/sbin/sulogin
3629 1:2345:respawn:/sbin/agetty tty1 9600
3630 2:2345:respawn:/sbin/agetty tty2 9600
3631 3:2345:respawn:/sbin/agetty tty3 9600
3632 4:2345:respawn:/sbin/agetty tty4 9600
3633 5:2345:respawn:/sbin/agetty tty5 9600
3634 6:2345:respawn:/sbin/agetty tty6 9600
3636 #c0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100
3642 The first call of @command{sed} replaces @file{/dev/initctl} with
3643 @file{$(ROOT)/dev/initctl}, and @file{/usr/lib} with
3644 @file{$(ROOT)/usr/lib} among other things in order to install sysvinit
3645 on the target system.
3647 @samp{make -C src clobber} is used to clean up the @file{src}
3650 Then, we create the @file{inittab} file that describes which processes
3651 are started at bootup and during normal operation.
3653 The line @samp{#c0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100} is
3654 commented out (with @code{#}) in order to avoid the message:
3655 @samp{INIT: Id "c0" respawning too fast: disabled for 5 minutes} on
3658 @c patch -Np1 -i ${DOWNLOAD_DIR}/sysvinit-2.88dsf-fixes-1.patch
3664 GNU tar is an archiving utility: it stores and extracts files from a
3665 tape or disk archive.
3669 tar xf ${DOWNLOAD_DIR}/tar-1.26.tar.bz2 -C ${BUILD_DIR}
3670 pushd ${BUILD_DIR}/tar-1.26
3671 cat > config.cache << EOF
3672 gl_cv_func_btowc_eof=yes
3673 ac_cv_func_malloc_0_nonnull=yes
3674 ac_cv_func_realloc_0_nonnull=yes
3675 gl_cv_func_mbrtowc_incomplete_state=yes
3676 gl_cv_func_mbrtowc_nul_retval=yes
3677 gl_cv_func_mbrtowc_null_arg=yes
3678 gl_cv_func_mbrtowc_retval=yes
3679 gl_cv_func_wcrtomb_retval=yes
3682 --build=${CROSS_HOST} \
3683 --host=${CROSS_TARGET} \
3686 --libexecdir=/usr/sbin \
3687 --cache-file=config.cache
3689 make DESTDIR=${TARGET_DIR} install
3695 @c patch -Np1 -i ${DOWNLOAD_DIR}/tar-1.26-man_page-1.patch
3696 @c patch -Np1 -i ${DOWNLOAD_DIR}/tar-1.26-new_compressors-1.patch
3702 GNU Texinfo is a documentation system that can produce both online
3703 information and a printed manual from a single source.
3707 tar xf ${DOWNLOAD_DIR}/texinfo-4.13a.tar.gz -C ${BUILD_DIR}
3708 pushd ${BUILD_DIR}/texinfo-4.13
3710 --build=${CROSS_HOST} \
3711 --host=${CROSS_TARGET} \
3713 make -C tools/gnulib/lib
3716 make DESTDIR=${TARGET_DIR} install
3721 pushd ${TARGET_DIR}/usr/share/info
3724 do install-info $f dir 2>/dev/null
3729 @c patch -Np1 -i ${DOWNLOAD_DIR}/texinfo-4.13-new_compressors-1.patch
3731 The first three calls of @command{make} make it possible to build
3732 Texinfo by cross-compilation.
3734 For Info to work, the @file{info} directory must contain a file that
3735 serves as a top level directory for the Info system. By convention,
3736 this file is called @file{dir}. We update this file for the target
3743 Udev is the dynamic device management of the kernel Linux.
3747 tar xf ${DOWNLOAD_DIR}/udev-175.tar.gz -C ${BUILD_DIR}
3748 pushd ${BUILD_DIR}/udev-175
3750 --build=${CROSS_HOST} \
3751 --host=${CROSS_TARGET} \
3755 --with-rootlibdir=/lib \
3756 --libexecdir=/lib/udev \
3757 --docdir=/usr/share/doc/udev-175 \
3758 --disable-introspection \
3759 --with-pci-ids-path=no \
3760 --with-usb-ids-path=no \
3763 make DESTDIR=${TARGET_DIR} install
3764 install -dv ${TARGET_DIR}/lib/firmware
3765 ln -sv ../lib/udev/udevd ${TARGET_DIR}/sbin/udevd
3771 @c The option @option{--disable-introspection} depends on
3772 @c gobject-introspection which is not installed
3775 Version 182 needs blkid headers given by e2fsprogs:
3776 configure: error: Package requirements (blkid >= 2.20) were not met:
3778 No package 'blkid' found
3782 BLKID_CFLAGS="-I${TARGET_DIR}/usr/include/blkid" \
3783 BLKID_LIBS="-L${TARGET_DIR}/lib -lblkid" \
3784 KMOD_CFLAGS="-I${TARGET_DIR}/usr/include" \
3785 KMOD_LIBS="-L${TARGET_DIR}/lib -lkmod" \
3787 --build=${CROSS_HOST} \
3788 --host=${CROSS_TARGET} \
3792 --with-rootlibdir=/lib \
3793 --libexecdir=/lib/udev \
3794 --docdir=/usr/share/doc/udev-182 \
3795 --disable-introspection \
3796 --with-pci-ids-path=no \
3797 --with-usb-ids-path=no \
3800 fails after `make` with:
3802 make --no-print-directory all-recursive
3804 CC src/udevadm-udev-builtin-blkid.o
3805 src/udev-builtin-blkid.c:84:30: error: unknown type name 'blkid_probe'
3806 src/udev-builtin-blkid.c: In function 'builtin_blkid':
3807 src/udev-builtin-blkid.c:122:9: error: unknown type name 'blkid_probe'
3808 src/udev-builtin-blkid.c:160:17: error: 'BLKID_SUBLKS_LABEL' undeclared (first
3809 use in this function)
3810 src/udev-builtin-blkid.c:160:17: note: each undeclared identifier is reported
3811 only once for each function it appears in
3812 src/udev-builtin-blkid.c:160:38: error: 'BLKID_SUBLKS_UUID' undeclared (first
3813 use in this function)
3814 src/udev-builtin-blkid.c:161:17: error: 'BLKID_SUBLKS_TYPE' undeclared (first
3815 use in this function)
3816 src/udev-builtin-blkid.c:161:37: error: 'BLKID_SUBLKS_SECTYPE' undeclared
3817 (first use in this function)
3818 src/udev-builtin-blkid.c:162:17: error: 'BLKID_SUBLKS_USAGE' undeclared (first
3819 use in this function)
3820 src/udev-builtin-blkid.c:162:38: error: 'BLKID_SUBLKS_VERSION' undeclared
3821 (first use in this function)
3822 src/udev-builtin-blkid.c:165:58: error: 'BLKID_FLTR_NOTIN' undeclared (first
3823 use in this function) src/udev-builtin-blkid.c:165:76: error:
3824 'BLKID_USAGE_RAID' undeclared (first use in this function) make[2]: ***
3825 [src/udevadm-udev-builtin-blkid.o] Error 1
3826 make[1]: *** [all-recursive] Error 1
3827 make: *** [all] Error 2
3833 install -dv ${TARGET_DIR}/lib/firmware
3836 is used to install target system's @file{/lib/firmware} which will
3844 util-linux is a random collection of utilities for use with the kernel
3849 tar xf ${DOWNLOAD_DIR}/util-linux-2.19.1.tar.bz2 -C ${BUILD_DIR}
3850 pushd ${BUILD_DIR}/util-linux-2.19.1
3851 sed -i.orig 's@etc/adjtime@var/lib/hwclock/adjtime@g' \
3853 mkdir -pv ${TARGET_DIR}/var/lib/hwclock
3855 --build=${CROSS_HOST} \
3856 --host=${CROSS_TARGET} \
3861 --disable-makeinstall-chown
3863 make DESTDIR=${TARGET_DIR} install
3864 mv -v ${TARGET_DIR}/usr/bin/logger ${TARGET_DIR}/bin
3866 rm -r util-linux-2.19.1
3870 The @command{sed} command modifies the location of @file{adjtime} from
3871 the target system's @file{/etc} directory to its
3872 @file{/lib/hwclock/adjtime} to comply with FHS.
3875 Error on configure for util-linux 2.22:
3876 configure: error: login selected, but required PAM header file not available
3879 Option @option{--enable-arch} enables the build and installation of
3880 the @command{arch} command.
3882 Option @option{--enable-partx} enables the build and installation of
3883 the @command{addpart}, @command{delpart} and @command{partx} commands.
3885 Option @option{--disable-wall} disables the build of the
3886 @command{wall} command which is already provided by sysvinit.
3888 Option @option{--enable-write} enables the build and installation of
3889 the @command{write} command.
3891 Option @option{--disable-makeinstall-chown} disables the change of
3892 owner to root for installed programs.
3898 XZ Utils is a general-purpose data compression software with high
3903 tar xf ${DOWNLOAD_DIR}/xz-5.0.4.tar.bz2 -C ${BUILD_DIR}
3904 pushd ${BUILD_DIR}/xz-5.0.4
3906 --build=${CROSS_HOST} \
3907 --host=${CROSS_TARGET} \
3910 make DESTDIR=${TARGET_DIR} install
3911 # For FHS compatibility:
3912 #mv -v ${TARGET_DIR}/usr/bin/{xz,lzma,lzcat,unlzma,unxz,xzcat} \
3921 @section Bootscripts
3923 The bootscript archive contains scripts that manage services during
3924 system's bootup and shutdown.
3928 tar xf ${DOWNLOAD_DIR}/bootscripts-cross-lfs-1.2-pre11.tar.bz2 \
3930 pushd ${BUILD_DIR}/bootscripts-cross-lfs-1.2-pre11
3931 make DESTDIR=${TARGET_DIR} install-bootscripts
3932 make DESTDIR=${TARGET_DIR} install-network
3934 rm -rf bootscripts-cross-lfs-1.2-pre11
3938 This installs basic bootscripts required for bootup and shutdown, and
3939 network-related bootscripts.
3945 To avoid potential kernel lockup on Loongson 2F machines, we need to
3946 add the option @option{-mfix-loongson2f-jump} to the environment
3947 variable @env{CFLAGS}@footnote{For more information about the issue,
3949 @uref{http://groups.google.com/group/loongson-dev/browse_thread/thread/d9103283141c00fb/e9a8830b01cc1913?hide_quotes=no#msg_d44adf83639fb0bd}
3951 @uref{http://sourceware.org/ml/binutils/2009-11/msg00387.html}.}:
3954 @c @uref{http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=622844bf0b4cfa4f76d4a0ddc44266938385f5ab}
3955 @c @uref{http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=54413b825ca502b9384edabf972c512c29d64010}.}.
3959 "/CFLAGS/s/-mfix-loongson2f-nop/& -Wa,-mfix-loongson2f-jump/" \
3961 source ~/.bash_profile
3967 tar xf ${DOWNLOAD_DIR}/linux-libre-3.5.4-gnu.tar.bz2 -C ${BUILD_DIR}
3968 pushd ${BUILD_DIR}/linux-3.5.4
3972 Then, if you are compiling the kernel for an Yeeloong @samp{2f}
3976 cp arch/mips/configs/lemote2f_defconfig .config
3977 patch -Np1 -i ${DOWNLOAD_DIR}/100gnu+freedo.patch
3980 Then, if you want to change the configuration:
3983 #make ARCH=mips CROSS_COMPILE=${CROSS_TARGET}- config
3984 make ARCH=mips CROSS_COMPILE=${CROSS_TARGET}- menuconfig
3988 * CPU selection:: Selecting your CPU
3989 * Optimizations:: Optimizing your kernel
3990 * Compatibility of executables:: Configuring compatibility of
3992 * Power Management:: Configuring ower management
3993 * Network card configuration:: Configuring your network card
3994 * Flash media:: Configuring USB keys and SDcards
3995 * File Systems:: Configuring the file systems
3996 * Input devices:: Configuring keyboard and mouse
3997 * Display:: Configuring the display
3998 * Unicode support:: Supporting Unicode
3999 * Kernel Compilation:: Kernel Compilation
4002 @c ???Needed for some reason:
4004 @c Executable file formats
4005 @c <M> Kernel support for MISC binaries
4009 @subsection CPU selection
4011 To know the CPU model you have on a given computer, type @samp{cat
4012 /proc/cpuinfo} inside a terminal.
4017 (X) Loongson family of machines
4019 (X) Lemote Loongson 2F family machines
4022 As you will discover when you type @samp{lspci | grep CS5536} in a
4023 terminal, AMD CS5536 is used for a variety of things on the Yeeloong:
4024 ISA bridge, IDE interface, Multimedia audio controller and two USB
4025 Controllers. In order to get the correct time, we need to enable the
4028 @c @emph{why does CS5536 need this?}
4031 [*] CS5536 MFGPT Timer
4035 @acronym{MFGPT} stands for Multi-Function General Purpose Timer.
4038 MIPS architecture exists in two flavours: big endian and little
4039 endian. The difference resides in the order in which the Bytes are
4040 stored in the hardware: little endian's first Byte is the least
4041 significant one while big endian's first Byte is the most significant
4042 one. In our case, we have a little endian architecture, so:
4053 If your version of Binutils is 2.20.2 or later, select the following
4058 [*] Loongson 2F Workarounds
4061 It fixes some issues with the Loongson 2F processors@footnote{For more
4062 information about the issue, see
4063 @uref{http://groups.google.com/group/loongson-dev/browse_thread/thread/d9103283141c00fb/e9a8830b01cc1913?hide_quotes=no#msg_d44adf83639fb0bd}
4065 @uref{http://sourceware.org/ml/binutils/2009-11/msg00387.html}.}.
4067 Then, whatever your version of Binutils is:
4077 @subsection Optimizations
4079 If you want higher performance but with increased memory consumption,
4080 select a @option{Kernel page size} of 16kB:
4088 Then, if you want to reduce the size of your kernel (this may increase
4089 decompression time at bootup though):
4093 Kernel compression mode
4097 Then, whatever your choice:
4101 [*] Support for paging of anonymous memory (swap)
4104 To be able to copy your kernel configuration through kernel versions,
4105 you may want to select the following options:
4109 <*> Kernel .config support
4110 [*] Enable access to .config through /proc/config.gz
4113 If you want to optimize your kernel for size (but not necessarily for
4114 speed), select the following option:
4118 [*] Optimize for size
4121 Selecting this option will use option @option{-Os} of GCC instead of
4122 the default @option{-O2}.
4125 @node Compatibility of executables
4126 @subsection Compatibility of executables
4128 @acronym{ELF} (Executable and Linkable Format) is a common standard
4129 file format for executables, object code, shared libraries, and core
4133 Executable file formats
4134 [*] Kernel support for ELF binaries
4135 [*] Kernel support for Linux/MIPS 32-bit binary compatibility
4136 [*] Kernel support for o32 binaries
4137 [*] Kernel support for n32 binaries
4141 @node Power Management
4142 @subsection Power Management
4144 Power management is a feature that turns off the power or switches the
4145 system to a low-power state when inactive.
4148 Power management options
4149 [*] Power Management support
4150 [*] Power Management Debug Support
4151 [*] Verbose Power Management debugging
4152 [*] Suspend to RAM and standby
4153 [*] Hibernation (aka 'suspend to disk')
4156 To be able to get information on your battery status, select the
4161 <*> Power supply class support
4162 [*] Power supply debug
4166 @node Network card configuration
4167 @subsection Network card configuration
4169 The network card is the component of your computer that lets you
4170 browse the internet and receive emails, among other things. This
4171 section covers both wired and wireless network cards.
4174 * Ethernet card configuration:: Configuring your ethernet card
4175 * Wireless card configuration:: Configuring your wireless card
4179 @node Ethernet card configuration
4180 @subsubsection Ethernet card configuration
4182 To know which ethernet controller you have, type in a terminal:
4185 lspci | grep Ethernet
4188 In order to build the driver for the RTL-8139 ethernet controller:
4192 [*] Network device support
4193 [*] Ethernet (10 or 100Mbit)
4194 <*> Realtek RTL-8129/8130/8139 PCI Fast Ethernet Adapter
4198 @c [*] Support for uncommon RTL-8139 rev. K (automatic
4199 @c channel equalization)
4202 @node Wireless card configuration
4203 @subsubsection Wireless card configuration
4205 To know which wireless card is connected to your USB port, in a
4209 lsusb | grep Wireless
4212 To be able to build the option @option{cfg80211}, which is the current
4213 wireless configuration API, @emph{not as a module} inside the kernel,
4214 you will have to select the following option first:
4217 [*] Networking support
4218 <*> RF Switch subsystem support
4224 [*] Networking support
4226 <*> cfg80211 -wireless configuration API
4227 [*] cfg80211 wireless extensions compatibility
4228 <*> Wireless extensions sysfs files
4229 <*> Common routines for IEEE802.11 drivers
4230 [*] lib80211 debugging messages
4233 mac80211 is a framework which driver developers can use to write
4234 drivers for SoftMAC wireless devices@footnote{See
4235 @uref{http://www.linuxwireless.org/en/developers/Documentation/mac80211/}
4236 for more information.}.
4238 The following option needs to be built @emph{not as a module} in order
4239 for the option @option{Realtek 8187 and 8187B USB support} to be
4240 built inside the kernel @emph{not as a module}:
4243 [*] Networking support
4245 <*> Generic IEEE 802.11 Networking stack (mac80211)
4248 Enabling EEPROM 93CX6 is required in order to build option
4249 @option{Realtek 8187 and 8187B USB support} inside the kernel:
4255 -*- EEPROM 93CX6 support
4258 If you want built-in support for Realtek 8187 and 8187B:
4262 Network device support
4264 <*> Realtek 8187 and 8187B USB support
4272 {*} Enable Wireless USB extensions (EXPERIMENTAL)
4279 Generic Driver Options
4280 - - Userspace firmware loading support
4281 [ ] Include in-kernel firmware blobs in kernel binary
4287 @subsection Flash media
4289 To know which driver to enable in the kernel, type @samp{lsusb | grep
4290 multicard} in a terminal.
4292 If you want to enable support for USB keys and SDcard:
4297 <*> SCSI device support
4298 <*> SCSI disk support
4301 <M> USB Mass Storage support
4303 <*> MMC/SD/SDIO card support
4304 <*> USB SD Host Controller (USHC) support
4309 @subsection File Systems
4311 By default, we recommend using Ext3 filesystem:
4315 <*> Ext3 journalling file system support
4318 If you don't need support for RAID or LVM:
4322 [ ] Multiple devices driver support (RAID and LVM)
4327 @subsection Input devices
4329 To configure Keyboard:
4333 Input device support
4338 <*> Synaptics PS/2 mouse protocol extension
4345 To know your @acronym{VGA} (Video Graphics Array) controller model
4346 (@acronym{VGA} refers to display hardware), type @samp{lspci | grep
4347 VGA} in a terminal. A @dfn{framebuffer} is a video output device
4348 that drives a video display from a memory buffer containing a complete
4349 frame of data@footnote{For more information, see
4350 @uref{http://en.wikipedia.org/wiki/Framebuffer}.}.
4355 <*> Support for frame buffer devices
4356 <M> Userspace VESA VGA graphics support
4357 Console display driver support
4358 <*> Framebuffer Console support
4362 <*> Silicon Motion SM7XX Frame Buffer Support
4365 @c [*] VESA VGA graphics support
4368 @node Unicode support
4369 @subsection Unicode support
4371 Unicode is a computing industry standard for the consistent encoding,
4372 representation and handling of text expressed in most of the world's
4373 writing systems@footnote{For more information, read
4374 @uref{http://en.wikipedia.org/wiki/Unicode}.}.
4378 -*- Native language support
4383 @c [*] Multifunction device drivers
4384 @c <*> Support for CS5535 and CS5536 southbridge core functions
4386 @c In File systems, remove support for Btrfs filesystem, otherwise
4387 @c compilation will fail.
4390 @node Kernel Compilation
4391 @subsection Kernel Compilation
4394 # 2 hours and 40 minutes
4397 CROSS_COMPILE=${CROSS_TARGET}-
4400 CROSS_COMPILE=${CROSS_TARGET}- \
4401 INSTALL_MOD_PATH=${TARGET_DIR} \
4403 cp vmlinuz ${TARGET_DIR}/boot/vmlinuz
4404 cp System.map ${TARGET_DIR}/boot/System.map
4405 cp .config ${TARGET_DIR}/boot/config
4411 because future compilation may need kernel sources, the compilation
4412 directory of the kernel should be preserved.
4416 @node Configuration Files
4417 @chapter Creating Required Configuration Files for the New System
4420 * Time Setup File:: File for time setup.
4421 * Bash Keyboard Setup:: Setting up keyboard function keys
4423 * Bash Startup Files:: Setting up Bash shell startup files.
4424 * Localhost Setup:: Setting up localhost.
4425 * hosts Setup:: Setting up @file{hosts} file.
4426 * Network Address Setup:: Setting up network address.
4427 * DNS Setup:: Setting up DNS.
4428 * fstab File Creation:: Creating @file{fstab} file.
4432 @node Time Setup File
4433 @section File for Time Setup
4436 cat > ${TARGET_DIR}/etc/sysconfig/clock << "EOF"
4437 # Begin /etc/sysconfig/clock
4441 # End /etc/sysconfig/clock
4446 @node Bash Keyboard Setup
4447 @section Setting up Keyboard Function keys for the Shell
4449 Readline default configuration file is set:
4452 cat > ${TARGET_DIR}/etc/inputrc << "EOF"
4454 set convert-meta Off
4455 set horizontal-scroll-mode Off
4458 "\eOd": backward-word
4459 "\eOc": forward-word
4460 "\e[1~": beginning-of-line
4461 "\e[4~": end-of-line
4462 "\e[5~": beginning-of-history
4463 "\e[6~": end-of-history
4464 "\e[3~": delete-char
4465 "\e[2~": quoted-insert
4466 "\eOH": beginning-of-line
4468 "\e[H": beginning-of-line
4473 If @option{convert-meta} is set to @samp{on}, Readline will convert
4474 characters with the eighth bit set to an @sc{ascii} key sequence by
4475 stripping the eighth bit and prefixing an @key{ESC} character,
4476 converting them to a meta-prefixed key sequence.
4478 @option{horizontal-scroll-mode} set to @samp{off} means that the text
4479 of the lines being edited will be wrapped onto a new screen line when
4480 they are longer than the width of the screen, instead of being
4481 scrolled horizontally on a single screen line.
4485 @option{input-meta} If set to @samp{on}, Readline will enable
4486 eight-bit input (it will not clear the eighth bit in the characters it
4487 reads), regardless of what the terminal claims it can support.
4489 If @option{output-meta} is set to @samp{on}, Readline will display
4490 characters with the eighth bit set directly rather than as a
4491 meta-prefixed escape sequence.
4494 "\eOd": backward-word
4495 "\eOc": forward-word
4496 "\e[1~": beginning-of-line
4497 "\e[4~": end-of-line
4498 "\e[5~": beginning-of-history
4499 "\e[6~": end-of-history
4500 "\e[3~": delete-char
4501 "\e[2~": quoted-insert
4502 "\eOH": beginning-of-line
4504 "\e[H": beginning-of-line
4509 @node Bash Startup Files
4510 @section Setting up Bash Shell Startup Files
4513 cat > ${TARGET_DIR}/etc/profile << "EOF"
4514 # Begin /etc/profile
4516 export LANG=en_US.UTF-8
4517 export INPUTRC=/etc/inputrc
4518 export PS1='\[\e[31m\]\A-\W\[\e[00m\]\$ '
4524 The environement variable @env{LANG} defines the default language that
4525 should be used on the system. @samp{en_US.UTF-8} means ``english''
4526 language, country ``US'' and @acronym{UTF-8} (UCS Transformation
4527 Format—8-bit) encoding (Unicode).
4529 @c For a full list, see???
4531 For explanations on @env{PS1}, @pxref{Environment Variables Setup}.
4534 @node Localhost Setup
4535 @section Localhost Setup
4538 echo "HOSTNAME=gllfsc" > ${TARGET_DIR}/etc/sysconfig/network
4543 @section Setting up @file{hosts} File
4546 cat > ${TARGET_DIR}/etc/hosts << "EOF"
4549 127.0.0.1 gllfsc localhost
4556 @node Network Address Setup
4557 @section Setting up Network Address
4559 You can choose to have a network static or dynamic address.
4562 * Network Static Address Setup:: Setting up Network Static Address.
4563 * Network Dynamic Address Setup:: Setting up Network Dynamic
4568 @node Network Static Address Setup
4569 @subsection Setting up Network Static Address
4572 pushd ${TARGET_DIR}/etc/sysconfig/network-devices
4573 mkdir -v ifconfig.eth0
4574 cat > ifconfig.eth0/ipv4 << "EOF"
4580 BROADCAST=192.168.1.255
4586 @code{IP}, @code{GATEWAY}, @code{BROADCAST} addresses are set up
4587 according to one's situation.
4591 @node Network Dynamic Address Setup
4592 @subsection Setting up Network Dynamic Address
4595 pushd ${TARGET_DIR}/etc/sysconfig/network-devices
4596 mkdir -v ifconfig.eth0
4597 cat > ifconfig.eth0/ip << "EOF"
4608 @section Setting up DNS
4611 cat > ${TARGET_DIR}/etc/resolv.conf << "EOF"
4612 # Begin /etc/resolv.conf
4614 nameserver your-main-DNS-address
4615 nameserver your-secondary-DNS-address
4617 # End /etc/resolv.conf
4622 @node fstab File Creation
4623 @section @file{fstab} File Creation
4625 The file @file{/etc/fstab} is used at boot to mount partitions under
4626 the requested directories.
4629 cat > ${TARGET_DIR}/etc/fstab << "EOF"
4632 # file system mount-point type options dump fsck order
4634 /dev/hda4 / ext3 defaults 1 1
4635 /dev/hda3 swap swap pri=1 0 0
4636 proc /proc proc defaults 0 0
4637 sysfs /sys sysfs defaults 0 0
4638 devpts /dev/pts devpts gid=4,mode=620 0 0
4639 shm /dev/shm tmpfs defaults 0 0
4646 the name of the hard drive and the name of filesystem used here have
4647 to be modified to reflect @emph{your} real situation.
4655 * Archiving:: All the system archived in one
4657 * Recommendations:: Some tips.
4662 @section Archiving the System
4664 After the system has been completed, we use the command @command{exit}
4665 to logout as the @emph{gllfsc} user.
4667 Now, login as the @emph{root} user.
4669 Then fix the permissions on the new system:
4672 export TARGET_DIR=/gllfsc
4674 mknod -m 600 dev/console c 5 1
4675 mknod -m 666 dev/null c 1 3
4676 cp -a dev/{console,null} lib/udev/devices/
4677 chown -R root:root *
4680 We archive the entire system by using the following command:
4683 # 20 minutes without kernel sources nor cross-tools
4684 tar -cjf gllfsc-20121006.tar.bz2 bin boot dev etc home lib* media \
4685 mnt opt proc root sbin srv sys tmp usr var
4686 # 60 minutes with kernel sources + cross-tools
4687 #tar -cjf gllfsc-20121006.tar.bz2 *
4690 It is then easy to copy the archive to the target machine and extract.
4693 @node Recommendations
4694 @section Some Recommendations
4696 We recommend extracting the system to an empty partition. Moreover,
4697 the filesystem of the chosen partition has to be a filesystem
4698 supported by the kernel you compiled. Finally, this partition has to
4699 be consistent with the system description in the file
4700 @file{/etc/fstab} you created during setup (@pxref{fstab File
4703 Then, you will have to edit the PMON BIOS configuration file of the
4704 target machine: @file{/boot.cfg}. This file has to be put on the first
4705 partition of the hard
4706 drive@footnote{@uref{http://gnewsense.org/Projects/Lemote#Updating_of_the_PMON_configuration}}. A
4707 minimal @file{/boot.cfg} could be:
4715 kernel (wd0,3)/boot/vmlinuz
4716 args console=tty no_auto_cmd root=/dev/hda4 rootdelay=8 machtype=8.9
4720 @node Further Readings
4721 @chapter Further Readings
4723 Haiyong Sun's website (in Chinese):
4724 @uref{http://youbest.cublog.cn}. It includes documents on building a
4725 GNU/Linux system for Loongson and a GNU/Hurd system for x86.
4727 Cross [GNU/]Linux from scratch: @uref{http://www.cross-lfs.org}.
4728 Includes a lot of documentation to build a GNU/Linux system by
4729 cross-compilation on a variety of hardware, no information (yet) for
4730 cross-compiling with sysroot on MIPS though. There is also a
4731 Community-driven Beyond [GNU/]Linux From Scratch on
4732 @uref{http://cblfs.cross-lfs.org}. It documents the building of Xorg
4733 and TeXLive among other things.
4735 @c Some patches from the above project are available for download on
4736 @c @uref{http://svn.cross-lfs.org/svn/repos/patches/}.
4738 @uref{http://www.linuxfromscratch.org/hints/downloads/files/more_control_and_pkg_@/man.txt}
4739 documents an interesting way of managing packages. Quotation from the
4747 You want to know which packages your files belong to?
4750 You want to deinstall software that doesn't have make uninstall?
4753 You are bothered by programs installed setuid root behind your back?
4756 You don't like packages quietly overwriting files from other packages?
4759 You don't like package managers like RPM?
4762 YOU WANT TOTAL CONTROL USING ONLY UNIX BUILTINS?
4766 The suckless team@footnote{@uref{http://suckless.org}} is a group of
4767 programmers that share the following
4768 philosophy@footnote{@uref{http://suckless.org/philosophy}}:
4771 Focus on simplicity, clarity and frugality. Our philosophy is about
4772 keeping things simple, minimal and usable. We believe this should
4773 become the mainstream philosophy in the IT sector. Unfortunately, the
4774 tendency for complex, error-prone and slow software seems to be
4775 prevalent in the present-day software industry. We intend to prove the
4776 opposite with our software projects.
4779 The simple and lightweight programs released by this team are
4780 interesting for machines based on Loongson 2F processor as performance
4781 is limited compared to current x86 processors.
4784 @node GNU Free Documentation License
4785 @appendix GNU Free Documentation License
4786 @include fdl-1.3.texi
4789 @node GNU General Public License
4790 @appendix GNU General Public License