嵌入式

构建Linux笔记v1.0(第二部分)

2020-05-17  本文已影响0人  外星间谍

2014-04-19 20:54:02
构建Linux 编译Linux BeagleBone Black

因为太长了,分了2部分。
构建Linux笔记v1.0(第一部分)


coreutils

->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/coreutils/coreutils-build

也许要先编译一遍本地版的,先看下面的解释。

$ ../coreutils-8.22/configure --prefix=/usr/app/coreutils --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi --enable-install-program=arch,hostname
修改Makefile,.x.1对象,$(abs_top_builddir) 改 /home/spy/Work/sources/coreutils
$ make
$ make install DESTDIR=/home/spy/Work/sources/coreutils/coreutils

--enable-install-program=arch,hostname
默认不安那2个,这样就安了。

help2man不能得到help信息

help2man: can`t get `--help` info from man/chroot.td/chroot
Try `--no-discard-stderr` if option outputs to stderr

help2man通过目标程序--help选项的输出来生成man,而我是交叉编译,目标程序不能
在我的系统中运行。所以我先编译了一遍本地版的,把运行make那个目录中的src文件夹
复制到了/home/spy/Work/sources/coreutils
重新配置成交叉编译,在make之前修改makefile文件,将help2man的目标程序指定到本地版的。

coreutils里面有我最喜欢的ls命令,编译完后,可在开发板中验证下。

linux-pam

/usr

->
<- util-linux,libcap,

$ cd /home/spy/Work/sources/pam/linux-pam-build
$ ../Linux-PAM-1.1.8/configure --prefix=/usr/app/linux-pam --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/pam/linux-pam

pam与认证有关,如果没有这个,编译util-linux的时候就不会有login。
util-linux的配置中并没有指定pam的选项,所以安装后,我把pam复制一份
放到我交叉编译器搜索库的目录中了。
我也尝试过把gcc依赖的库放到交叉编译器搜索库的目录中,但遇到了新的问题,
时间关系,没有研究。

pam的库中也有个la文件,根据pam所放的目录,做类似下面的修改。
libpam_misc.la

# Libraries that this one depends upon.
dependency_libs=` /home/spy/Software/arm-2013.11/arm-none-linux-gnueabi/libc/usr/lib/libpam.la -ldl`

include/security/
我当初记录了这个东西,有点忘了,可能是依赖pam头文件的程序在那个目录找而不是include/。
编译其他程序的时候如果提示找不到头文件,可改下目录。

yywrap的问题

搜索后这个函数在flex中,安装后,我也不太会用,

conf/pam_conv1/Makefile
LIBS = -lfl

doc/specs/Makefile

还有一些其他新问题,于是换策略。

conf/pam_conv1/pam_conv_l.c

int     yywrap (void)
{
    return 1;
}

doc/specs/parse_l.c

int     yywrap (void)
{
    return 1;
}

就是在那2个c源文件中添加yywrap函数,
反正felx中有个libyywrap.c,里面的函数就这个样子。

util-linux

-> pam, ncurses
<-

我这里的编译并没有用ncurses,如果你要用的话,可先看看后面我编译ncurses的步骤。

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/util-linux/util-linux-build

$ ../util-linux-2.24.1/configure --prefix=/usr/app/util-linux --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi --without-ncurses
$ make
$ su
# make install DESTDIR=/home/spy/Work/sources/util-linux/util-linux

--without-ncurses
我当初还没编译ncurses,所以加了这个选项,我不知道ncurses是干什么的,这样等以后
出问题的时候就知道它是干什么的了。


安装时,不能改变bin/wall的用户组为tty
我采用了安装时切换用户为root的方法。

带pam库编译时

cannot find the library '/usr/app/linux-pam/lib/libpam.la' or unhandled argument '/usr/app/linux-pam/lib/libpam.la'

修改libpam_misc.la中的路径,见pam中的修改。

libcap

-> pam
<- systemd,

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin

将makefile要引入的文件做如下修改。

CC := arm-none-linux-gnueabi-gcc
BUILD_CC := gcc
AR := arm-none-linux-gnueabi-ar
RANLIB := arm-none-linux-gnueabi-ranlib
LIBATTR := no
$ cd /home/spy/Work/sources/libcap/libcap-2.24
$ make
$ make prefix=/usr/app/libcap lib=lib FAKEROOT=/home/spy/Work/sources/libcap/libcap install

完成以上步骤,复制一份和交叉编译器的库放到一起。

systemd

/usr

-> libcap
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/systemd/systemd-build

修改configure,避免rpl_malloc的错误

  if test "$cross_compiling" = yes; then :
  ac_cv_func_malloc_0_nonnull=no 改成 yes
$ ../systemd-211/configure --prefix=/usr/app/systemd --with-rootprefix=/usr/app/systemd/root --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi --disable-seccomp --disable-blkid --disable-kmod --disable-pam --disable-libcryptsetup --disable-audit --disable-acl --disable-xattr --disable-selinux --disable-xz --disable-tcpwrap --disable-gcrypt --disable-qrencode --disable-microhttpd --disable-python-devel --without-python --disable-gudev --disable-apparmor --disable-dbus
$ make
$ make install DESTDIR=/home/spy/Work/sources/systemd/systemd

--with-rootprefix=/usr/app/systemd/root
由于安装的时候会有一些东西安装在了app文件夹之外,指定这个选项为安装路径内部就可以了,
root是我随便起的,但最好与其他文件夹独立。

后面那些都是可选的软件包,我全禁用了。
今天一看,竟然有个kmod,我可以告诉你,我构建完的系统好像不能自动载入模块,也许和这个有关吧。
kmod我后面也安了。


编译时看到了很多这样的信息,不知道是什么:

libsystemd_internal_la-bus-message.o (symbol from plugin): warning: memset used with constant zero length parameter; this could be due to transposed parameters
/home/spy/Software/arm-2013.11/arm-none-linux-gnueabi/libc/usr/include/bits/poll2.h: In function 'bus_poll':
/home/spy/Software/arm-2013.11/arm-none-linux-gnueabi/libc/usr/include/bits/poll2.h:71:2: warning: call to '__ppoll_chk_warn' declared with attribute warning: ppoll called with fds buffer too small file nfds entries [enabled by default]
  return __ppoll_chk (__fds, __nfds, __timeout, __ss, __bos (__fds));

配置出错时提示过的
sys/capability.h 在libcap中
pkg-config
intltool
gperf

后3个不是库,编译时被调用,又不像编译器那样为另一个平台生成程序,所以应该不必
为我构建的系统编译他们,用自己Linux系统的包管理器安上就好了。

注意pkg-config是负责寻找库的,如果用他默认的搜索路径,找到的是你正使用系统中的库,
而不是应该用在BeagleBone Black中的库。如果像我这样把那些可选的软件包都禁用的话,
是不需要pkg-config的。我把pkg-config通过配置选项指定到一个目录,也能编译成功。
如果想让pkg-config找到正确的库的话,可看看它的手册,有几个环境变量可影响它搜索库
的路径。


终于到了真正的init程序,这么伟大的程序,竟然没找到学习的文档。我总结了一点。

systemd包含了udev。

At boot time we now print warnings if:
/usr is on a split-off partition but not already mounted by an initrd; if
/etc/mtab is not a symlink to /proc/mounts;
CONFIG_CGROUPS is not enabled in the kernel.
We`ll also expose this as tainted flag on the bus.

所以/etc/中应该放个mtab了。

systemd对一些目录的要求。
参见http://www.freedesktop.org/wiki/Software/systemd/FileHierarchy/

If a process belonging to a specific cgroup fork()s, its child will become a member of the same group.
You can find the cgroups of a process by reading /proc/$PID/cgroup.
cgroups hence make a very good choice to keep track of processes for babysitting purposes.


又到了体验成就感的时候,目前,我们已经拥有的程序,
glibc,gmp,mpfr,mpc,isl,cloog,gcc,bash,
coreutils,linux-pam,util-linux,libcap,systemd。
放到SD卡中。
也许最好把SD卡中文件的用户和组改成root,但是util-linux中的wall属于tty组。
我下面这2条命令是不全的。

# chown -R 0:0
# chgrp -v tty /usr/app/util-linux/bin/wall

由于有了新的程序库,而且是systemd需要用到的,所以先别急着改把init改成systemd,
那样应该会提示找不到库的,所以先用bash,执行一下ldconfig,然后再改,
init=/usr/lib/systemd/systemd

/etc/中的文件,目前就有个mtab,
如果没有passwd文件,会有登陆的提示,还会让输入密码,然后就是登陆失败,所以要创建。

/etc/passwd

root::0:0:root:/home/root:/usr/bin/bash

目前不能设置密码,设置了会登陆失败,不知为什么,可能为了安全吧。所以密码部分空着。

/etc/pam.conf

other auth    required  pam_unix.so nullok
other account   required  pam_unix.so broken_shadow
other session   required  pam_unix.so
other password  required  pam_unix.so nullok

这是pam的配置文件,可看看pam的手册,内容没深入研究,是我自己看了很多配置后定的。
如果没有配置文件,登陆时会有下面的错误,

login: PAM failure, aborting: Critical error - immediate abort

第一部分是需要pam的程序的名字,如login,改成login也可以。
最后的nullok选项是必要的,这允许没有密码的登陆,也不知道这4个中,哪个需要,
临时先参照别人的。

前面说到,不能在passwd中设置密码,我本以为加了broken_shadow选项就可以了,但不是。

pam也可以在/etc/pam.d/中找配置文件,这个是shadow的一部分,里面不止一个配置文件。
如果pam.d存在,则忽略pam.conf。可建个空的pam.d文件夹试试,我没研究。


现在启动BeagleBone Black吧,
systemd启动后,会在/etc/中创建一个machine-id文件,
最后systemd会启动在ttyO0上的登陆服务,提示登陆,输入root,确定后就看见bash了。

我的systemd启动过程中会有一个服务失败,就是在另一个tty设备登陆的服务,可能是我没连
显示器?

一些命令,
显示这次登陆的日志,

# journalctl -b

重启,

$ systemctl reboot

关机

$ systemctl poweroff

但我的关上后,电源指示灯还亮着,别的灯倒是灭了。


曾经没有login时遇到的问题,

localhost login: root
[   30.279467] systemd[1]: serial-getty@ttyO0.service has no holdoff time, scheduling restart.
[   30.314721] systemd[1]: Stopping Serial Getty on ttyO0...
[   30.321039] systemd[1]: Starting Serial Getty on ttyO0...
[   30.332073] systemd[1]: Started Serial Getty on ttyO0.

这是systemd的getty服务,在我的系统中该服务调用agetty,看了agetty的手册,
发现它要调用login程序,而此时我构建的系统中没有login程序。
我想表达的是这里没有错误提示。


shadow

/usr/local

->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/Shadow/shadow-build

$ ../shadow-4.1.5.1/configure --prefix=/usr/app/shadow --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/Shadow/shadow

我不太喜欢shadow,因为我不能在那个网站下载到它。
但为了能改密码,还是安了。希望有避免shadow的方法。

shadow中有与已安装程序相同的命令,我选择了shadow中的。
util-linux {login,nologin,su}
coreutils {groups}

它的配置文件要复制一份到/etc/中。
它的配置文件不可以直接用,看看pam.d中的login文件。
内容的格式也就是少了第一部分,这部分用文件名表示了。
奇怪的是你会在配置中发现include,但后面的文件没有。
你也会看到额外的配置,先参照pam.conf改吧。

shadow的login命令会读取login.defs。
登陆的时候,会提示下面这些有问题。
为了不让他们出现,都被我变成注释了。

FAILLOG_ENAB
LASTLOG_ENAB
MAIL_CHECK_ENAB
OBSCURE_CHECKS_ENAB
PORTTIME_CHECKS_ENAB
QUOTAS_ENAB
MOTD_FILE
FTMP_FILE
NOLOGINS_FILE
ENV_HZ
PASS_MIN_LEN
SU_WHEEL_ONLY
CRACKLIB_DICTPATH
PASS_CHANGE_TRIES
PASS_ALWAYS_WARN
CHFN_AUTH
ENVIRON_FILE

如果你要改密码,那么首先/etc/中要有shadow文件,空的就可以。

-bash-4.3# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token manipulation error
passwd: password unchanged

添加空的shadow文件后

-bash-4.3# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

曾经出现过的一些问题

“Login incorrect”
原因提示,
通过passwd改密码;
pam的配置文件没配置好;
有个认证可能需要/etc/shells文件,里面是可用shell的路径。

“Module is unknown”
忘了怎么引起的了。

“Permission denied”
忘了。

binutils

/usr/local

->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/binutils/binutils-build

$ ../binutils-2.24/configure --prefix=/usr/app/binutils --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/binutils/binutils

这里面有汇编器,连接器等,我的目的是可以在开发板中构建程序。
LFS的网站上说,这个要在glibc和gcc之前编译,但我是现在编译的,
难道glibc的ld.so可以根据这里的ld确定搜索路径?

make

/usr/local

->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/make/make-build

$ ../make-4.0/configure --prefix=/usr/app/make --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/make/make

sed

/usr/local

->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/sed/sed-build

$ ../sed-4.2.2/configure --prefix=/usr/app/sed --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/sed/sed

configure脚本中会用到的,还有grep,gawk。

grep

/usr/local

->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/grep/grep-build

$ ../grep-2.9/configure --prefix=/usr/app/grep --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/grep/grep

gawk

/usr/local

->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/gawk/gawk-build

可能还是要先编译一遍本地版的,好像这个错误也没什么问题吧。
而且这样改也不太好。

$ ../gawk-4.1.0/configure --prefix=/usr/app/gawk --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi

修改makefile如下

$ make
$ make install DESTDIR=/home/spy/Work/sources/gawk/gawk
/bin/sh: ../gawk: cannot execute binary file: Exec format error
check-for-shared-lib-support:
    @if /home/spy/Work/sources/gawk/gawk.build/build/gawk$(EXEEXT) --version | sed 1q | grep API > /dev/null; \
    then    : do nothing ; \
    else    echo Building the extensions is not supported on this platform ; \
        exit 1; \
    fi

ncurses

/usr/local

->
<- nano,vim

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/ncurses/ncurses-build

$ ../ncurses-5.9/configure --prefix=/usr/app/ncurses --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi --with-build-cc=gcc --enable-widec --with-shared
$ make
$ make install DESTDIR=/home/spy/Work/sources/ncurses/ncurses

nano

/usr/local

-> ncurses
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/nano/nano-build

好像要修改源文件。

$ ../nano-2.2.6/configure --prefix=/usr/app/nano --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/nano/nano
src/nano.h:92:20: fatal error: curses.h: No such file or directory
#elif defined(HAVE_NCURSES_H)
#include <ncursesw/ncurses.h>
#else
/* Curses support. */
#include <ncursesw/curses.h>
#endif /* CURSES_H */

我在BeagleBone Black中也编译过这个没成功

checking whether build environment is sane... configure: error: newly created file is older than distributed files!
Check your system clock

这是我BeagleBone Black时间的问题。

date -s 20140402
./config.status: line 1095: awk: command not found

安gawk

/bin/install: missing destination file operand after ''
Try '/bin/install --help' for more information.

安装时的错误,短时间内不知如何解决。

findutils

/usr/local

->
<-

在开发板中编译的,so easy。
安装程序的时候,有时会需要这个,比如下面的vim。

在我的电脑中编译出现以下问题没解决。

stdio.h:749:12: error: expected declaration specifiers or `...` before `(` token
 extern int fseek (FILE *__stream, long int __off, int __whence);
            ^

vim

/usr/local

-> ncurses
<-

系统中需要linux header。

# ./configure --prefix=/usr/app/vim --with-tlib=ncursesw
# make
# make install
checking how to run the C preprocessor... /lib/cpp
configure: error: in '/home/root/vim/vim74/src':
configure: error: C preprocessor "/lib/cpp" fails sanity check

配置时出错。

linux/limits.h: No such file or directory

好像是config.log里的。

好像我把linux header放到开发板中,好了。
linux header参见内核部分。

no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.

--with-tlib=ncurses

checking for linking with ncurses library... configure: error: FAILED

--with-tlib=ncursesw

checking size of off_t... configure: error: in `/home/root/vim/vim74/src`:
configure: error: cannot compute sizeof (off_t)
See `config.log` for more details.
# ldconfig
./osdef.sh: line 92: diff: command not found

好像是make的时候,没有错误,没有警告。

/bin/sh: find: command not found

这就是安装的时候,暗示你需要findutils。


好了,现在我们的系统已经可以编译软件了。
虽然还缺少一些必要的软件,如压缩软件。但我构建Linux的目的是研究Linux,构建的思想
已基本掌握,再这样安软件安下去没什么意义了。

为了充分理解构建时遇到的问题,应该学习下更基础的东西了,如

Computer Systems: A Programmer's Perspective
Randal E. Bryant and David R. O'Hallaron, Carnegie Mellon University

如果不看完这本书,我会担心我完成的任务不够完美。

曾经看了一点"Linux Device Drivers",说驱动是了解内核的一个入口。

kmod

/usr

->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/kmod/kmod-build

$ ../kmod-16/configure --prefix=/usr/app/kmod --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi --disable-manpages
$ make
$ make install DESTDIR=/home/spy/Work/sources/kmod/kmod

编译完的目录中是有一些软链接指向kmod命令的,但安装完的目录里没有那些软链接。
这些软链接很有意思啊,比如insmod指向kmod,输入insmod,实际运行的不是kmod,而是
kmod insmod。大概是这样的。

kmod与模块有关,所以你的系统中应该放上编译内核时的模块了。

libpipeline

/usr/local

->
<- man-db

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/libpipeline/libpipeline-build

$ ../libpipeline-1.3.0/configure --prefix=/usr/app/libpipeline --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/libpipeline/libpipeline

gdbm

/usr/local

->
<- man-db

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/gdbm/gdbm-build

$ ../gdbm-1.11/configure --prefix=/usr/app/gdbm --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/gdbm/gdbm

man-db

/usr/local

-> gdbm,libpipeline
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/man-db/man-db-build

$ ../man-db-2.6.6/configure --prefix=/usr/app/man-db --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi libpipeline_CFLAGS=`-I/home/spy/Work/sources/libpipeline/libpipeline/usr/app/libpipeline/include` libpipeline_LIBS=`-L/home/spy/Work/sources/libpipeline/libpipeline/usr/app/libpipeline/lib -lpipeline` --disable-setuid
$ make
$ make install DESTDIR=/home/spy/Work/sources/man-db/man-db

这个程序的README还是值得看看的,我至今未仔细看,所以标记下。

undefined reference

src/Makefile
manpath$(EXEEXT):
globbing$(EXEEXT):
accessdb$(EXEEXT):
LINK OBJECTS
-rpath /home/spy/Work/sources/libpipeline/libpipeline/usr/app/libpipeline/lib

很遗憾,我没有成功的显示manual,还没时间研究。

less

/usr/local
->
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/less/less-build

$ ../less-458/configure --prefix=/usr/app/less --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/less/less

有了它,journalctl的输出就舒服了。man的输出也是放到less中。

下面的都是与网络有关的了,网络的知识没学,不知道怎么用,可参考下安装过程。

db

/usr/local/BerkeleyDB.6.0

< iproute

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/db/db-build

$ ../db-6.0.30/dist/configure --prefix=/usr/app/db --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi --enable-compat185
$ make
$ make install DESTDIR=/home/spy/Work/sources/db/db

$ make uninstall
$ make clean
$ make realclean

iptables

/usr/local

->
<- iproute

$ export PKG_CONFIG_LIBDIR=/home/spy/Software/arm-2013.11/arm-none-linux-gnueabi/libc/usr/lib/pkgconfig
$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/iptables/iptables-build

$ ../iptables-1.4.21/configure --prefix=/usr/app/iptables --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/iptables/iptables

看来我是在这里被迫开始用了pkg-config,要不就是iproute。

iproute

-> db(make),iptables(make)
<-

ROOTDIR=/home/spy/Software/arm-2013.11/arm-none-linux-gnueabi/libc
PREFIX=/usr/app/iproute
SBINDIR=$(PREFIX)/sbin
CONFDIR=$(PREFIX)/etc/iproute2

CC = arm-none-linux-gnueabi-gcc
HOSTCC = gcc
AR = arm-none-linux-gnueabi-ar

$ export PKG_CONFIG_LIBDIR=/home/spy/Software/arm-2013.11/arm-none-linux-gnueabi/libc/usr/lib/pkgconfig
$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin

$ make DESTDIR=/home/spy/Work/sources/iproute/iproute
$ make install DESTDIR=/home/spy/Work/sources/iproute/iproute

IP_CONFIG_SETNS,
TC_CONFIG_IPSET,TC_CONFIG_XT,TC_CONFIG_ATM,TC_CONFIG_XT_OLD,TC_CONFIG_XT_OLD_H,

编译的时候需要pkg-config, bison, flex。

这个程序替代了net-tools,但作为替代品,那个官网可真不怎么好。

它依赖的软件中,我学Arch Linux,在后面括号中标记了make,表示只在编译的时候需要,
虽然不知道Arch Linux是不是这意思。
我确实没有把那2个依赖放到开发版中,iproute可以使用,但不知道有没有什么问题。

zlib

->
<- openssh,

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/zlib/zlib-1.2.8

$ CHOST=arm-none-linux-gnueabi ./configure --prefix=/usr/app/zlib
$ make
$ make install DESTDIR=/home/spy/Work/sources/zlib/zlib

openssl

->
<- openssh

临时先让系统中的pod2man不可用,见下面解释。

$ ./Configure linux-armv4 --prefix=/usr/app/openssl --cross-compile-prefix=arm-none-linux-gnueabi- shared
$ make
$ make install INSTALL_PREFIX=/home/spy/Work/sources/openssl/openssl

BeagleBone Black是armv7,但配置中没有linux-armv7,倒是有个与android有关的armv7,
那个armv7并没有用与armv7有关的东西,而是armv4的,所以我就用了“linux-armv4”。

有个可疑的zlib-dynamic选项,我没加。

POD document had syntax errors at /usr/bin/core_perl/pod2man line 71.

看了源码中的pod2mantest,里面说如果系统中没有可用的pod2man,会用openssl中自带的。
既然系统中的有问题,那就用自带的吧。

# mv /usr/bin/core_perl/pod2man /usr/bin/core_perl/pod2man.a
./pod2mantest: line 34: pod2man: command not found
pod2man does not work properly (`BasicTest` failed).  Looking for another pod2man ...
No working pod2man found.  Consider installing a new version.
As a workaround, we`ll use a bundled old copy of pod2man.pl.

openssh

/usr/local

-> zlib,openssl
<-

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/openssh/openssh-build

$ ../openssh-6.6p1/configure --prefix=/usr/app/openssh --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi --with-zlib=/home/spy/Work/sources/zlib/zlib/usr/app/zlib --with-ssl-dir=/home/spy/Work/sources/openssl/openssl/usr/app/openssl
修改makefile。
$ make
$ make install DESTDIR=/home/spy/Work/sources/openssh/openssh

可疑选项,
--with-pam
--without-shadow

strip: Unable to recognise the format of the input file

系统中的strip无法识别交叉编译后的程序,看来要用交叉编译器中的。
strip由install调用,看看install的手册,真的有选项可以改变调用的strip,
于是修改makefile,修改install的参数。

STRIP_OPT=-s --strip-program=/home/spy/Software/arm-2013.11/bin/arm-none-linux-gnueabi-strip
sshd: cannot execute binary file

呵,竟然想运行sshd,看看makefile,位于检测的部分,那就别检测了,
删掉install对象中的“check-config”。

编译完,并没有生成ssh-key,也没提示。
参考了makefile,在开发板中运行以下命令生成ssh-key。

ssh-keygen -t rsa1 -f  /usr/app/openssh/etc/ssh_host_key -N ""
ssh-keygen -t rsa -f /usr/app/openssh/etc/ssh_host_rsa_key -N ""
ssh-keygen -t dsa -f /usr/app/openssh/etc/ssh_host_dsa_key -N ""
ssh-keygen -t ed25519 -f /usr/app/openssh/etc/ssh_host_ed25519_key -N ""
ssh-keygen -t ecdsa -f /usr/app/openssh/etc/ssh_host_ecdsa_key -N ""

iana-etc

->
<-

$ make PREFIX=/usr/app/iana-etc DESTDIR=/home/spy/Work/sources/iana-etc/iana-etc STRIP=yes
$ make install PREFIX=/usr/app/iana-etc DESTDIR=/home/spy/Work/sources/iana-etc/iana-etc STRIP=yes

不知干什么的,就是些文本文件。

以下是没用的。

flex(http://flex.sourceforge.net/)

/usr/local

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ cd /home/spy/Work/sources/flex/flex-build

$ ../flex-2.5.39/configure --prefix=/usr/app/flex --build=x86_64-unknown-linux-gnu --host=arm-none-linux-gnueabi
$ make
$ make install DESTDIR=/home/spy/Work/sources/flex/flex
rpl_malloc
  if test "$cross_compiling" = yes; then :
  ac_cv_func_malloc_0_nonnull=no --> yes

rpl_realloc
  if test "$cross_compiling" = yes; then :
  ac_cv_func_realloc_0_nonnull=yes

驱动的知识

The major number generally specifies a particular driver within the kernel,
and the minor number specifies a particular device handled by that driver.

曾经用过的,不用了。

BusyBox

$ export PATH=$PATH:/home/spy/Software/arm-2013.11/bin
$ make CROSS_COMPILE=arm-none-linux-gnueabi- help
$ make CROSS_COMPILE=arm-none-linux-gnueabi- distclean
$ make CROSS_COMPILE=arm-none-linux-gnueabi- allnoconfig
$ make CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
$ make CROSS_COMPILE=arm-none-linux-gnueabi- all
$ make CROSS_COMPILE=arm-none-linux-gnueabi- CONFIG_PREFIX=../busybox-build install

一开始没用systemd,用的Busybox的init。

/dev中一些基本的设备,不清楚到底需要什么,也不必考虑了,
因为systemd不需要,但前期我用BusyBox的话,还是要添加的。

# mknod -m 666 null c 1 3
# mknod -m 666 zero c 1 5

# mknod -m 600 console c 5 1
# mknod -m 666 tty c 5 0
# mknod -m 600 tty0 c 4 0
# mknod -m 600 tty1 c 4 1
# mknod -m 600 ttyS0 c 4 64

# mknod -m 600 mem c 1 1
# mknod -m 644 random c 1 8
上一篇下一篇

猜你喜欢

热点阅读