Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

交叉编译临时⼯具[0]

Posted on 2023年11月14日 by

此处在宿主机以lfs用户运行,将软件安装在LFS目录下

本部分属于原书第六章内容

第二次编译耗时6h,以下需要安装16个包,GCC需要安装两次

以下的工具编译到目标位置,但是不能使用,需要在chroot环境下链接使用

1)安装M4

M4 软件包包含一个宏处理器

tar xvf m4-1.4.19.tar.xz

cd m4-1.4.19
./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
make -j4
make DESTDIR=$LFS install

cd ..
rm -rf m4-1.4.19

2)安装Ncurses-6.2

Ncurses 软件包包含使用时不需考虑终端特性的字符屏幕处理函数库

tar xvf ncurses-6.2.tar.gz

cd ncurses-6.2

sed -i s/mawk// configure

mkdir build
pushd build
  ../configure
  make -C include
  make -C progs tic
popd


./configure --prefix=/usr                \
            --host=$LFS_TGT              \
            --build=$(./config.guess)    \
            --mandir=/usr/share/man      \
            --with-manpage-format=normal \
            --with-shared                \
            --without-debug              \
            --without-ada                \
            --without-normal             \
            --enable-widec

make -j4
make DESTDIR=$LFS TIC_PATH=$(pwd)/build/progs/tic install
echo "INPUT(-lncursesw)" > $LFS/usr/lib/libncurses.so

cd ..
rm -rf ncurses-6.2

3)安装Bash

这个软件包为系统提供一个 LSB core 要求的 Bourne Shell 接口

tar xvf bash-5.1.8.tar.gz

cd bash-5.1.8

./configure --prefix=/usr                   \
            --build=$(support/config.guess) \
            --host=$LFS_TGT                 \
            --without-bash-malloc
            
make -j4
make DESTDIR=$LFS install			
ln -sv bash $LFS/bin/sh

cd $LFS/sources
rm -rf bash-5.1.8

4)安装Coreutils

这个软件包包含一些用于查看和操作文件和目录的基本程序

tar xvf coreutils-8.32.tar.xz

cd coreutils-8.32

./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess) \
            --enable-install-program=hostname \
            --enable-no-install-program=kill,uptime
            
make -j4
make DESTDIR=$LFS install			

mv -v $LFS/usr/bin/chroot                 $LFS/usr/sbin
mkdir -pv $LFS/usr/share/man/man8
mv -v $LFS/usr/share/man/man1/chroot.1    $LFS/usr/share/man/man8/chroot.8
sed -i 's/"1"/"8"/'           $LFS/usr/share/man/man8/chroot.8

cd $LFS/sources 
rm -rf coreutils-8.32

5)安装Diffutils

这个软件包包含用于显示文件或目录之间的差异的程序

tar xvf diffutils-3.8.tar.xz

cd diffutils-3.8
./configure --prefix=/usr --host=$LFS_TGT
make -j4
make DESTDIR=$LFS install

cd ..
rm -rf diffutils-3.8

6)安装File

这个软件包包含用于判定给定文件类型的工具

tar xvf file-5.40.tar.gz

cd file-5.40

mkdir build
pushd build
  ../configure --disable-bzlib      \
               --disable-libseccomp \
               --disable-xzlib      \
               --disable-zlib
  make
popd

./configure --prefix=/usr --host=$LFS_TGT --build=$(./config.guess)
make FILE_COMPILE=$(pwd)/build/src/file
make DESTDIR=$LFS install

cd ..
rm -rf file-5.40

7)安装Findutils

这个软件包包含用于在文件系统中寻找文件的程序

tar xvf findutils-4.8.0.tar.xz

cd findutils-4.8.0

./configure --prefix=/usr   \
            --localstatedir=/var/lib/locate \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
            
make -j4
make DESTDIR=$LFS install

cd ..
rm -rf findutils-4.8.0

8)安装Gawk

这个软件包包含用于操作文本文件的程序

tar xvf gawk-5.1.0.tar.xz

cd gawk-5.1.0

sed -i 's/extras//' Makefile.in

        
./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(./config.guess)
            
make -j4
make DESTDIR=$LFS install

cd ..
rm -rf gawk-5.1.0

9)安装grep

这个软件包包含在文本中搜索指定模式的程序

tar xvf grep-3.7.tar.xz
cd grep-3.7

./configure --prefix=/usr   \
            --host=$LFS_TGT
make -j4
make DESTDIR=$LFS install

cd ..
rm -rf grep-3.7

10)安装Gzip

这个软件包包含用于压缩和解压缩文件的程序

tar xvf gzip-1.10.tar.xz

cd gzip-1.10

./configure --prefix=/usr --host=$LFS_TGT

make -j4
make DESTDIR=$LFS install

cd ..
rm -rf gzip-1.10

11)安装Make

这个软件包包含用于指导软件包编译过程的程序

tar xvf make-4.3.tar.gz

cd make-4.3

./configure --prefix=/usr   \
            --without-guile \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
            

make -j4
make DESTDIR=$LFS install

cd ..
rm -rf make-4.3

12)安装Patch

这个软件包包含一个通过 补丁 文件修改或创建文件的程序

tar xvf patch-2.7.6.tar.xz

cd patch-2.7.6

./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
            

make -j4
make DESTDIR=$LFS install

cd ..
rm -rf patch-2.7.6

13)安装Sed

这个软件包可以在没有文本编辑器的情况下编辑文本文件

tar xvf sed-4.8.tar.xz

cd sed-4.8

./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
            

make -j4
make DESTDIR=$LFS install

cd ..
rm -rf sed-4.8

14)安装Tar

这个软件包提供存档和提取功能

tar xvf tar-1.34.tar.xz

cd tar-1.34

./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess)
            

make -j4
make DESTDIR=$LFS install

cd ..
rm -rf tar-1.34

15)安装Xz

这个软件包包含用于压缩和解压缩文件的程序

tar xvf xz-5.2.5.tar.xz

cd xz-5.2.5

./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess) \
            --disable-static                  \
            --docdir=/usr/share/doc/xz-5.2.5
            

make -j4
make DESTDIR=$LFS install

cd ..
rm -rf xz-5.2.5

16)再次安装Binutils

该软件包包含链接器、汇编器,以及其他处理目标文件的工具

tar xvf binutils-2.37.tar.xz
cd binutils-2.37

mkdir -v build
cd       build

../configure                   \
    --prefix=/usr              \
    --build=$(../config.guess) \
    --host=$LFS_TGT            \
    --disable-nls              \
    --enable-shared            \
    --disable-werror           \
    --enable-64-bit-bfd
    
make -j4
make DESTDIR=$LFS install -j1
install -vm755 libctf/.libs/libctf.so.0.0.0 $LFS/usr/lib

cd ..
cd ..
rm -rf binutils-2.37

17)再次安装GCC

这个软件包是 GNU 编译器的集合

tar xvf gcc-11.2.0.tar.xz

cd gcc-11.2.0

tar -xf ../mpfr-4.1.0.tar.xz
mv -v mpfr-4.1.0 mpfr
tar -xf ../gmp-6.2.1.tar.xz
mv -v gmp-6.2.1 gmp
tar -xf ../mpc-1.2.1.tar.gz
mv -v mpc-1.2.1 mpc
case $(uname -m) in
  x86_64)
    sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
  ;;
esac

mkdir -v build
cd       build

mkdir -pv $LFS_TGT/libgcc
ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h

../configure                                       \
    --build=$(../config.guess)                     \
    --host=$LFS_TGT                                \
    --prefix=/usr                                  \
    CC_FOR_TARGET=$LFS_TGT-gcc                     \
    --with-build-sysroot=$LFS                      \
    --enable-initfini-array                        \
    --disable-nls                                  \
    --disable-multilib                             \
    --disable-decimal-float                        \
    --disable-libatomic                            \
    --disable-libgomp                              \
    --disable-libquadmath                          \
    --disable-libssp                               \
    --disable-libvtv                               \
    --disable-libstdcxx                            \
    --enable-languages=c,c++
    
    
make -j4	
make DESTDIR=$LFS install
ln -sv gcc $LFS/usr/bin/cc

cd ..
cd ..
rm -rf gcc-11.2.0

此处需要检查所有的工具链,避免安装不完整。

参考资料:

  1. https://bf.mengyan1223.wang/lfs/zh_CN/11.0/chapter06/introduction.html
  2. https://www.linuxfromscratch.org/lfs/view/stable-systemd/chapter06/introduction.html

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT