Host System Requirements:
Note :Ubuntu is not compliant out of the box, copy-paste the script and run it:
you might need to install some packages which are not present in ubuntu 14.04
bhargav@Inspiron:~$
sudo apt-get install texinfo gawk make sed php gcc g++
Use scripts from documentation to check for packages and libraries
on your host system : sudo blkid -o list
bhargav@Inspiron:~$ sudo ./version-check.sh
script code version-check.sh : Refer documentation for scrip code.
Note : you might need to install few packages showed after running the script :
bhargav@Inspiron:~$ sudo ./
library-check.sh
script code library-check.sh : Refer documentation for script code.
Install gmp mpfr mpc
Installation is done manually by going onto site for each package and then
download and install it asshown in documentation of each package.
You might get problem while installing mpfr hence just run this command:
sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg
Making a partition on disk for lfs using parted application :
Note : If you are not sure how PARTED work then refer to below
link before going forward:
http://www.thegeekstuff.com/2011/09/parted-command-examples/
bhargav-Inspiron:/$ sudo parted
(parted) print free
Now look for space which is free to use and remember the start and end
size to make partition:
Note : Please re-check or make sure before running any command.
Any mistake might lead to losing your data onto disk or HD.
(parted) mkpart
Partition name? []? lfs
File system type? [ext2]? ext4
Start? 238GB
End? 248GB
(parted) print
Model: ATA WDC WD5000LPVX-7 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 525MB 524MB fat32 EFI system partition boot
2 525MB 567MB 41.9MB fat32 Basic data partition hidden
3 567MB 701MB 134MB Microsoft reserved partition msftres
4 701MB 1488MB 786MB ntfs Basic data partition hidden, diag
5 1488MB 70.1GB 68.6GB ntfs Basic data partition msftdata
6 70.1GB 238GB 168GB ntfs Basic data partition msftdata
11 238GB 248GB 10.5GB lfs
7 248GB 459GB 211GB ntfs Basic data partition msftdata
9 459GB 463GB 4200MB linux-swap(v1)
10 463GB 491GB 27.3GB ext4
8 491GB 500GB 9412MB ntfs Microsoft recovery partition hidden, diag
Format ext2 partition to ext4 partition :
bhargav@Inspiron:~$sudo blkid -o list
//this will show partition blkid
mkfs.ext4 /dev/sda11
bhargav@Inspiron:~$ sudo
We will make a variable link: (OPTIONAL you can use /mnt/lfs in $LFS or viceversa)
bhargav@Inspiron:~$ export LFS=/mnt/lfs
Make directory at /mnt/ name lfs:
bhargav@Inspiron:~$ sudo mkdir -pv /mnt/lfs
Mounting the partition on the location of lfs directory:
bhargav@Inspiron:~$ sudo mount -v -t ext4 /dev/sda11 /mnt/lfs /dev/sda11 on /mnt/lfs type ext4 (rw)
Make directory inside /mnt/lfs named "sources" :
bhargav@Inspiron:~$ sudo mkdir -v $LFS/sources mkdir: created directory ‘/mnt/lfs/sources’
Give permission to /mnt/lfs/sources :
bhargav@Inspiron:~$ sudo chmod -v a+wt $LFS/sources mode of ‘/mnt/lfs/sources’ changed from 0755 (rwxr-xr-x) to 1777 (rwxrwxrwt)
Download all the packages from site :
It includes total 77 files including patches
ftp://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-7.7-systemd.tar
bhargav@Inspiron:/$
groupadd lfs
bhargav@Inspiron:/$ sudo useradd -s /bin/bash -g lfs -m -k /dev/null lfs
bhargav@Inspiron:/$
sudo adduser lfs sudo
bhargav@Inspiron:/$
sudo passwd lfs Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
lfs@Inspiron:/mnt/lfs$ sudo mkdir -v $LFS/tools
mkdir: created directory '/mnt/lfs/tools'
lfs@bhargav-Inspiron-3443:/mnt/lfs$ sudo ln -sv $LFS/tools /
'/tools' -> '/mnt/lfs/tools'
lfs@Inspiron
:/mnt/lfs$
bhargav@Inspiron:/$ sudo chown -v lfs /mnt/lfs/tools
changed ownership of ‘/mnt/lfs/tools’ from root to lfs
bhargav@Inspiron:/$ sudo chown -v lfs /mnt/lfs/sources
changed ownership of ‘/mnt/lfs/sources’ from root to lfs
bhargav@Inspiron:/$
bhargav@Inspiron:/$ su - lfs
Password:
Setting Up the Environment :
lfs@Inspiron:
~$ ~/.bash_profile << "EOF" > exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash > EOF -su: /home/lfs/.bash_profile: No such file or directory
lfs@Inspiron:
~$ cat > ~/.bash_profile << "EOF" exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash EOF
lfs@Inspiron:
~$ cat > ~/.bashrc << "EOF" > set +h > umask 022 > LFS=/mnt/lfs > LC_ALL=POSIX > LFS_TGT=$(uname -m)-lfs-linux-gnu > PATH=/tools/bin:/bin:/usr/bin > export LFS LC_ALL LFS_TGT PATH > EOF
lfs@Inspiron:
~$ source ~/.bash_profile
IMP change it back to dash to run in normal enviroment
To change symblic link of sh to bash
sudo ln -sf bash /bin/sh
Change it to dash when it is done
sudo ln -sf dash /bin/sh
Build Binutils package :
cd $LFS/sources tar xf binutils-2.22.tar.bz2 cd binutils-2.22 mkdir -v ../binutils-build cd ../binutils-build ../binutils-2.22/configure \ --target=$LFS_TGT --prefix=/tools \ --disable-nls --disable-werror make case $(uname -m) in x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;; esac make install cd $LFS/sources rm -rf binutils-build binutils-2.22
Buils GCC package:
cd $LFS/sources tar xf gcc-4.6.2.tar.bz2 cd gcc-4.6.2 tar -jxf ../mpfr-3.1.0.tar.bz2 mv -v mpfr-3.1.0 mpfr tar -Jxf ../gmp-5.0.4.tar.xz mv -v gmp-5.0.4 gmp tar -zxf ../mpc-0.9.tar.gz mv -v mpc-0.9 mpc
The following command
ill change the location of GCC's default dynamic linker to use the one installed in
for file in \$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)docp -uv $file{,.orig}sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \-e 's@/usr@/tools@g' $file.orig > $fileecho '#undef STANDARD_STARTFILE_PREFIX_1#undef STANDARD_STARTFILE_PREFIX_2#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"#define STANDARD_STARTFILE_PREFIX_2 ""' >> $filetouch $file.origdone
then making a gcc-build directory:
mkdir -v ../gcc-build cd ../gcc-build
Installing gcc by running this command :
../gcc-4.9.2/configure \--target=$LFS_TGT \--prefix=/tools \--with-sysroot=$LFS \--with-newlib \--without-headers \--with-local-prefix=/tools \--with-native-system-header-dir=/tools/include \--disable-nls \--disable-shared \--disable-multilib \--disable-decimal-float \--disable-threads \--disable-libatomic \--disable-libgomp \--disable-libitm \--disable-libquadmath \--disable-libsanitizer \--disable-libssp \--disable-libvtv \--disable-libcilkrts \--disable-libstdc++-v3 \--enable-languages=c,c++
make make install cd $LFS/sources rm -rf gcc-build gcc-4.9.2
Installation of Linux API Headers:
cd $LFS/sources
tar -xf linux-3.19.tar.xz
cd linux-3.19
make mrproper
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include
cd $LFS/sources/
sudo rm -rf linux-3.19
Installation of Glibc-2.21 :
tar xf glibc-2.21.tar.xz
cd glibc-2.21
sudo mkdir -v ../glibc-build
cd ../glibc-build/
../glibc-2.21/configure \
--prefix=/tools \
--host=$LFS_TGT \
--build=$(../glibc-2.21/scripts/config.guess) \
--disable-profile \
--enable-kernel=2.6.32 \
--with-headers=/tools/include \
libc_cv_forced_unwind=yes \
libc_cv_ctors_header=yes \
libc_cv_c_cleanup=yes
make
make install
At this point, it is imperative to stop and ensure that the
basic functions (compiling and linking) of the new toolchain are working as expected. To perform a sanity check, run the following commands:
echo 'main(){}' > dummy.c $LFS_TGT-gcc dummy.c readelf -l a.out | grep ': /tools'
If everything is working correctly, there should be no errors, and the output of the last command will be of the form:
[Requesting program interpreter: /tools/lib/ld-linux.so.2]
rm -v dummy.c a.out
Binutils-2.22 - Pass 2
tar xf binutils-2.25.tar.bz2 cd binutils-2.25
mkdir -v ../binutils-build cd ../binutils-build
CC=$LFS_TGT-gcc \ AR=$LFS_TGT-ar \ RANLIB=$LFS_TGT-ranlib \ ../binutils-2.25/configure \ --prefix=/tools \ --disable-nls \ --disable-werror \ --with-lib-path=/tools/lib \ --with-sysroot
make
make install
Now prepare the linker for the “Re-adjusting” phase in the next chapter:
make -C ld clean make -C ld LIB_PATH=/usr/lib:/lib cp -v ld/ld-new /tools/bin
5.10.1. Installation of GCC
tar xf gcc-4.9.2.tar.bz2 cd gcc-4.9.2
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h
Once again, change the location of GCC's default dynamic
linker to use the one installed in /tools
.
for file in \ $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h) do cp -uv $file{,.orig} sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ -e 's@/usr@/tools@g' $file.orig > $file echo ' #undef STANDARD_STARTFILE_PREFIX_1 #undef STANDARD_STARTFILE_PREFIX_2 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file touch $file.orig done
As in the first build of GCC it requires the GMP, MPFR and
MPC packages. Unpack the tarballs and move them into the
required directory names:
tar -xf ../mpfr-3.1.2.tar.xz mv -v mpfr-3.1.2 mpfr tar -xf ../gmp-6.0.0a.tar.xz mv -v gmp-6.0.0 gmp tar -xf ../mpc-1.0.2.tar.gz mv -v mpc-1.0.2 mpc
Before starting to build GCC, remember to unset any environment variables that override the default optimization flags.
Now prepare GCC for compilation:
CC=$LFS_TGT-gcc \ CXX=$LFS_TGT-g++ \ AR=$LFS_TGT-ar \ RANLIB=$LFS_TGT-ranlib \ ../gcc-4.9.2/configure \ --prefix=/tools \ --with-local-prefix=/tools \ --with-native-system-header-dir=/tools/include \ --enable-languages=c,c++ \ --disable-libstdcxx-pch \ --disable-multilib \ --disable-bootstrap \ --disable-libgomp
Compile the package:
make
Install the package:
make install
As a finishing touch, create a symlink. Many programs and scripts run cc instead of gcc,which is used to keep programs generic and therefore usable on all kinds of UNIX systems where the GNU C compiler is not always installed. Running cc leaves the system administrator free to decide which C compiler to install:
echo 'main(){}' > dummy.c cc dummy.c readelf -l a.out | grep ': /tools'
If everything is working correctly, there should be no errors,
and the output of the last command will be of the form:
[Requesting program interpreter: /tools/lib/ld-linux.so.2]
Once all is well, clean up the test files:
rm -v dummy.c a.out
Once all is well, clean up the test files:
HERE YOU HAVE COMPLETED THE TOUGH PART OF LFS.
5.11. Tcl8.6.3 Installation :
tar xf tcl8.6.3-src.tar.gz
cd tcl8.6.3/unix
Prepare Tcl for compilation:
cd tcl8.6.3/unix
./configure --prefix=/tools
Build the package:
make
Install the package:
make install
Make the installed library writable so debugging symbols can be removed later:
chmod -v u+w /tools/lib/libtcl8.6.so
Install Tcl's headers. The next package, Expect, requires them to build.
make install-private-headers
Now make a necessary symbolic link:
ln -sv tclsh8.6 /tools/bin/tclsh
|
|
cp -v perl cpan/podlators/pod2man /tools/bin mkdir -pv /tools/lib/perl5/5.20.2 cp -Rv lib/* /tools/lib/perl5/5.20.2
5.30.
Sed-4.2.2 package Installation :
tar xf sed-4.2.2.tar.gz
cd sed-4.2.2
Prepare Sed for compilation:
Build the package:
make
Install the package:
make install
5.31.
Tar-1.28 package Installation :
tar xf tar-1.28.tar.xz
cd tar-1.28
Prepare Tar for compilation:
Build the package:
make
Install the package:
make install
5.32.
Texinfo-5.2 package Installation :
tar xf texinfo-5.2.tar.xz
cd texinfo-5.2
Prepare
Texinfo
for compilation:
Build the package:
make
Install the package:
make install
5.33.
Util-linux-2.26 package Installation :
tar xf util-linux-2.26.tar.xz
cdutil-linux-2.26
Prepare Util-linux for compilation:
./configure --prefix=/tools \ --without-python \ --disable-makeinstall-chown \ --without-systemdsystemunitdir \ PKG_CONFIG=""
Build the package:
make
Install the package:
make install
5.34. Xz-5.2.0
package Installation :
tar xf xz-5.2.0.tar.xz
cd xz-5.2.0
Prepare
Xz
for compilation:
Build the package:
make
Install the package:
make install
No comments:
Post a Comment