分类: LINUX
2010-09-21 18:58:13
2.2. Creating a New Partition
扩大vmware硬盘大小,在cmd里:
d:
"Program Files\VMware Workstation\vmware-vdiskmanager.exe" -x 56Gb lfs_ubuntu\Ubuntu.vmdk
在linux里创建分区
fdisk /dev/sda
2.3. Creating a File System on the Partition
mke2fs -jv /dev/sda3
2.4. Mounting the New Partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount -v -t ext3 /dev/sda3 $LFS
4.2. Creating the $LFS/tools Directory
mkdir -v $LFS/sources
mkdir -v $LFS/tools
ln -sv $LFS/tools /
4.3. Adding the LFS User
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
chown -v lfs $LFS/tools
chown -v lfs $LFS/sources
su - lfs
4.4. Setting Up the Environment
cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
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
source ~/.bash_profile
5.4. Binutils-2.20.1 - Pass 1
tar -jxf binutils-2.20.1.tar.bz2
cd binutils-2.20.1
mkdir -v ../binutils-build
cd ../binutils-build
../binutils-2.20.1/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 ..
rm -rf binutils-2.20.1 binutils-build
5.5. GCC-4.5.1 - Pass 1
tar -jxf gcc-4.5.1.tar.bz2
cd gcc-4.5.1
tar -jxf ../mpfr-3.0.0.tar.bz2
mv -v mpfr-3.0.0 mpfr
tar -jxf ../gmp-5.0.1.tar.bz2
mv -v gmp-5.0.1 gmp
tar -zxf ../mpc-0.8.2.tar.gz
mv -v mpc-0.8.2 mpc
mkdir -v ../gcc-build
cd ../gcc-build
../gcc-4.5.1/configure \
--target=$LFS_TGT --prefix=/tools \
--disable-nls --disable-shared --disable-multilib \
--disable-decimal-float --disable-threads \
--disable-libmudflap --disable-libssp \
--disable-libgomp --enable-languages=c \
--with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs \
--without-ppl --without-cloog;
make
make install
ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
sed 's/libgcc/&_eh/'`
cd ..
rm -rf gcc-4.5.1 gcc-build
5.6. Linux-2.6.35.4 API Headers
tar -jxf linux-2.6.35.4.tar.bz2
cd linux-2.6.35.4
make mrproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include
cd ..
5.7. Glibc-2.12.1
tar -jxf glibc-2.12.1.tar.bz2
cd glibc-2.12.1
patch -Np1 -i ../glibc-2.12.1-gcc_fix-1.patch
patch -Np1 -i ../glibc-2.12.1-makefile_fix-1.patch
mkdir -v ../glibc-build
cd ../glibc-build
case `uname -m` in
i?86) echo "CFLAGS += -march=i486 -mtune=native" > configparms ;;
esac
../glibc-2.12.1/configure --prefix=/tools \
--host=$LFS_TGT --build=$(../glibc-2.12.1/scripts/config.guess) \
--disable-profile --enable-add-ons \
--enable-kernel=2.6.16.1 --with-headers=/tools/include \
libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes
make
make install;
cd ..
rm -rf glibc-2.12.1 glibc-build
5.8. Adjusting the Toolchain
SPECS=`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/specs
$LFS_TGT-gcc -dumpspecs | sed \
-e \
-e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS
echo "New specs file is: $SPECS"
unset SPECS
echo 'main(){}' > dummy.c
$LFS_TGT-gcc -B/tools/lib dummy.c
readelf -l a.out | grep ': /tools'
rm -v dummy.c a.out
5.9. Binutils-2.20.1 - Pass 2
tar -jxf binutils-2.20.1.tar.bz2
cd binutils-2.20.1
mkdir -v ../binutils-build
cd ../binutils-build
CC="$LFS_TGT-gcc -B/tools/lib/" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../binutils-2.20.1/configure --prefix=/tools \
--disable-nls --with-lib-path=/tools/lib
make
make install
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin
cd ..
rm -rf binutils-2.20.1 binutils-build
5.10. GCC-4.5.1 - Pass 2
tar -jxf gcc-4.5.1.tar.bz2
cd gcc-4.5.1
patch -Np1 -i ../gcc-4.5.1-startfiles_fix-1.patch
cp -v gcc/Makefile.in{,.orig}
sed gcc/Makefile.in.orig > gcc/Makefile.in
cp -v gcc/Makefile.in{,.tmp}
sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \
> gcc/Makefile.in
for file in \
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
cp -uv $file{,.orig}
sed -e \
-e $file.orig > $file
echo '
#undef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR 0
#define STANDARD_STARTFILE_PREFIX_1 ""
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
touch $file.orig
done
case $(uname -m) in
x86_64)
for file in $(find gcc/config -name t-linux64) ; do \
cp -v $file{,.orig}
sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file
done
;;
esac
tar -jxf ../mpfr-3.0.0.tar.bz2
mv -v mpfr-3.0.0 mpfr
tar -jxf ../gmp-5.0.1.tar.bz2
mv -v gmp-5.0.1 gmp
tar -zxf ../mpc-0.8.2.tar.gz
mv -v mpc-0.8.2 mpc
mkdir -v ../gcc-build
cd ../gcc-build
CC="$LFS_TGT-gcc -B/tools/lib/" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../gcc-4.5.1/configure --prefix=/tools \
--with-local-prefix=/tools --enable-clocale=gnu \
--enable-shared --enable-threads=posix \
--enable-__cxa_atexit --enable-languages=c,c++ \
--disable-libstdcxx-pch --disable-multilib \
--disable-bootstrap \
--with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs \
--without-ppl --without-cloog
make LD_LIBRARY_PATH=$(pwd)/$(../gcc-4.5.1/config.guess)/libgcc
make install
ln -vs gcc /tools/bin/cc
cd ..
rm -rf gcc-4.5.1 gcc-build
echo 'main(){}' > dummy.c
cc dummy.c
readelf -l a.out | grep ': /tools'
rm -v dummy.c a.out
5.11. Tcl-8.5.8
tar -xf tcl8.5.8-src.tar.gz
cd tcl8.5.8
cd unix
./configure --prefix=/tools
make
TZ=UTC make test
make install
chmod -v u+w /tools/lib/libtcl8.5.so
make install-private-headers
ln -sv tclsh8.5 /tools/bin/tclsh
cd ../..
rm -rf tcl8.5.8
5.12. Expect-5.44.1.15
tar -xf expect-5.44.1.15.tar.bz2
cd expect-5.44.1.15
patch -Np1 -i ../expect-5.44.1.15-no_tk-1.patch
cp -v configure{,.orig}
sed 's:/usr/local/bin:/bin:' configure.orig > configure
./configure --prefix=/tools --with-tcl=/tools/lib \
--with-tclinclude=/tools/include --with-tk=no
make
make test
make SCRIPTS="" install
cd ..
rm -rf expect-5.44.1.15
5.13. DejaGNU-1.4.4
tar -xf dejagnu-1.4.4.tar.gz
cd dejagnu-1.4.4
patch -Np1 -i ../dejagnu-1.4.4-consolidated-1.patch
./configure --prefix=/tools
make install
make check
cd ..
rm -rf dejagnu-1.4.4