2014-04-19 20:54:02
構(gòu)建Linux 編譯Linux BeagleBone Black
因為太長了唉匾,分了2部分。
構(gòu)建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
默認(rèn)不安那2個,這樣就安了麻顶。
help2man不能得到help信息
help2man: can`t get `--help` info from man/chroot.td/chroot
Try `--no-discard-stderr` if option outputs to stderr
help2man通過目標(biāo)程序--help選項的輸出來生成man赦抖,而我是交叉編譯,目標(biāo)程序不能
在我的系統(tǒng)中運行辅肾。所以我先編譯了一遍本地版的队萤,把運行make那個目錄中的src文件夾
復(fù)制到了/home/spy/Work/sources/coreutils
。
重新配置成交叉編譯矫钓,在make之前修改makefile文件要尔,將help2man的目標(biāo)程序指定到本地版的舍杜。
coreutils里面有我最喜歡的ls
命令,編譯完后赵辕,可在開發(fā)板中驗證下既绩。
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與認(rèn)證有關(guān),如果沒有這個还惠,編譯util-linux的時候就不會有l(wèi)ogin饲握。
util-linux的配置中并沒有指定pam的選項,所以安裝后蚕键,我把pam復(fù)制一份
放到我交叉編譯器搜索庫的目錄中了救欧。
我也嘗試過把gcc依賴的庫放到交叉編譯器搜索庫的目錄中,但遇到了新的問題锣光,
時間關(guān)系笆怠,沒有研究。
pam的庫中也有個la文件誊爹,根據(jù)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/
我當(dāng)初記錄了這個東西替废,有點忘了箍铭,可能是依賴pam頭文件的程序在那個目錄找而不是include/。
編譯其他程序的時候如果提示找不到頭文件椎镣,可改下目錄诈火。
yywrap
的問題
搜索后這個函數(shù)在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函數(shù)拍摇,
反正felx中有個libyywrap.c,里面的函數(shù)就這個樣子馆截。
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
我當(dāng)初還沒編譯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
完成以上步驟梢卸,復(fù)制一份和交叉編譯器的庫放到一起走诞。
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文件夾之外低剔,指定這個選項為安裝路徑內(nèi)部就可以了速梗,
root是我隨便起的,但最好與其他文件夾獨立襟齿。
后面那些都是可選的軟件包姻锁,我全禁用了。
今天一看猜欺,竟然有個kmod位隶,我可以告訴你,我構(gòu)建完的系統(tǒng)好像不能自動載入模塊开皿,也許和這個有關(guān)吧涧黄。
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個不是庫笋妥,編譯時被調(diào)用,又不像編譯器那樣為另一個平臺生成程序窄潭,所以應(yīng)該不必
為我構(gòu)建的系統(tǒng)編譯他們春宣,用自己Linux系統(tǒng)的包管理器安上就好了。
注意pkg-config是負(fù)責(zé)尋找?guī)斓募的悖绻盟J(rèn)的搜索路徑月帝,找到的是你正使用系統(tǒng)中的庫,
而不是應(yīng)該用在BeagleBone Black中的庫幽污。如果像我這樣把那些可選的軟件包都禁用的話嚷辅,
是不需要pkg-config的。我把pkg-config通過配置選項指定到一個目錄距误,也能編譯成功簸搞。
如果想讓pkg-config找到正確的庫的話,可看看它的手冊准潭,有幾個環(huán)境變量可影響它搜索庫
的路徑攘乒。
終于到了真正的init程序,這么偉大的程序惋鹅,竟然沒找到學(xué)習(xí)的文檔。我總結(jié)了一點殉簸。
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/中應(yīng)該放個mtab了沽讹。
systemd對一些目錄的要求。
參見http://www.freedesktop.org/wiki/Software/systemd/FileHierarchy/
/, /usr, /etc must be mounted when the host systemd is first invoked. This may
be achieved either by using the kernel`s built-in root disk mounting (
in which case /, /usr and /etc need to be on the same file system), or
via an initrd, which could mount the three directories from different sources./bin, /sbin, /lib (and /lib64 if applicable) should reside on /, or be symlinks
to the /usr file system (recommended). All of them must be available
before the host systemd is first executed./var does not have to be mounted when the host systemd is first invoked,
however, it must be configured so that it is mounted writable
before local-fs.target is reached (for example, by simply listing it in /etc/fstab)./tmp is recommended to be a tmpfs (default), but doesn`t have to. If configured,
it must be mounted before local-fs.target is reached (for example, by listing it in /etc/fstab)./dev must exist as an empty mount point and will automatically be mounted
by systemd with a devtmpfs. Non-devtmpfs boots are not supported./proc and /sys must exist as empty mount points and
will automatically be mounted by systemd with procfs and sysfs./run must exist as an empty mount point and will automatically be mounted by systemd with a tmpfs.
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.
又到了體驗成就感的時候武鲁,目前爽雄,我們已經(jīng)擁有的程序,
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吧雹,
那樣應(yīng)該會提示找不到庫的,所以先用bash涂身,執(zhí)行一下ldconfig雄卷,然后再改,
init=/usr/lib/systemd/systemd
/etc/中的文件蛤售,目前就有個mtab丁鹉,
如果沒有passwd文件,會有登陸的提示悴能,還會讓輸入密碼揣钦,然后就是登陸失敗,所以要創(chuàng)建漠酿。
/etc/passwd
root::0:0:root:/home/root:/usr/bin/bash
目前不能設(shè)置密碼冯凹,設(shè)置了會登陸失敗,不知為什么炒嘲,可能為了安全吧宇姚。所以密碼部分空著匈庭。
/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的手冊浑劳,內(nèi)容沒深入研究阱持,是我自己看了很多配置后定的。
如果沒有配置文件魔熏,登陸時會有下面的錯誤衷咽,
login: PAM failure, aborting: Critical error - immediate abort
第一部分是需要pam的程序的名字,如login蒜绽,改成login也可以镶骗。
最后的nullok選項是必要的,這允許沒有密碼的登陸滓窍,也不知道這4個中卖词,哪個需要,
臨時先參照別人的吏夯。
前面說到此蜈,不能在passwd中設(shè)置密碼,我本以為加了broken_shadow選項就可以了噪生,但不是裆赵。
pam也可以在/etc/pam.d/
中找配置文件,這個是shadow的一部分跺嗽,里面不止一個配置文件战授。
如果pam.d存在,則忽略pam.conf桨嫁≈怖迹可建個空的pam.d文件夾試試,我沒研究璃吧。
現(xiàn)在啟動BeagleBone Black吧楣导,
systemd啟動后,會在/etc/中創(chuàng)建一個machine-id文件畜挨,
最后systemd會啟動在ttyO0上的登陸服務(wù)筒繁,提示登陸,輸入root巴元,確定后就看見bash了毡咏。
我的systemd啟動過程中會有一個服務(wù)失敗,就是在另一個tty設(shè)備登陸的服務(wù)逮刨,可能是我沒連
顯示器呕缭?
一些命令,
顯示這次登陸的日志,
# journalctl -b
重啟臊旭,
$ systemctl reboot
關(guān)機(jī)
$ systemctl poweroff
但我的關(guān)上后落恼,電源指示燈還亮著,別的燈倒是滅了离熏。
曾經(jīng)沒有l(wèi)ogin時遇到的問題,
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服務(wù)戴涝,在我的系統(tǒng)中該服務(wù)調(diào)用agetty滋戳,看了agetty的手冊,
發(fā)現(xiàn)它要調(diào)用login程序啥刻,而此時我構(gòu)建的系統(tǒng)中沒有l(wèi)ogin程序奸鸯。
我想表達(dá)的是這里沒有錯誤提示。
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可帽,因為我不能在那個網(wǎng)站下載到它娄涩。
但為了能改密碼,還是安了映跟。希望有避免shadow的方法蓄拣。
shadow中有與已安裝程序相同的命令,我選擇了shadow中的努隙。
util-linux {login,nologin,su}
coreutils {groups}
它的配置文件要復(fù)制一份到/etc/中球恤。
它的配置文件不可以直接用,看看pam.d中的login文件荸镊。
內(nèi)容的格式也就是少了第一部分咽斧,這部分用文件名表示了。
奇怪的是你會在配置中發(fā)現(xiàn)include躬存,但后面的文件沒有张惹。
你也會看到額外的配置,先參照pam.conf改吧岭洲。
shadow的login命令會讀取login.defs宛逗。
登陸的時候,會提示下面這些有問題钦椭。
為了不讓他們出現(xiàn)拧额,都被我變成注釋了。
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
曾經(jīng)出現(xiàn)過的一些問題
“Login incorrect”
原因提示德挣,
通過passwd改密碼恭垦;
pam的配置文件沒配置好;
有個認(rèn)證可能需要/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
這里面有匯編器玄柏,連接器等襟衰,我的目的是可以在開發(fā)板中構(gòu)建程序。
LFS的網(wǎng)站上說粪摘,這個要在glibc和gcc之前編譯瀑晒,但我是現(xiàn)在編譯的,
難道glibc的ld.so可以根據(jù)這里的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腳本中會用到的苔悦,還有g(shù)rep,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.
安裝時的錯誤地技,短時間內(nèi)不知如何解決蜈七。
findutils
/usr/local
->
<-
在開發(fā)板中編譯的,so easy莫矗。
安裝程序的時候飒硅,有時會需要這個,比如下面的vim作谚。
在我的電腦中編譯出現(xiàn)以下問題沒解決三娩。
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
<-
系統(tǒng)中需要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放到開發(fā)板中,好了眨唬。
linux header參見內(nèi)核部分会前。
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岭妖。
好了临庇,現(xiàn)在我們的系統(tǒng)已經(jīng)可以編譯軟件了反璃。
雖然還缺少一些必要的軟件,如壓縮軟件假夺。但我構(gòu)建Linux的目的是研究Linux淮蜈,構(gòu)建的思想
已基本掌握,再這樣安軟件安下去沒什么意義了已卷。
為了充分理解構(gòu)建時遇到的問題梧田,應(yīng)該學(xué)習(xí)下更基礎(chǔ)的東西了,如
Computer Systems: A Programmer's Perspective
Randal E. Bryant and David R. O'Hallaron, Carnegie Mellon University
如果不看完這本書悼尾,我會擔(dān)心我完成的任務(wù)不夠完美柿扣。
曾經(jīng)看了一點"Linux Device Drivers",說驅(qū)動是了解內(nèi)核的一個入口闺魏。
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與模塊有關(guān),所以你的系統(tǒng)中應(yīng)該放上編譯內(nèi)核時的模塊了暖混。
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還是值得看看的柒竞,我至今未仔細(xì)看,所以標(biāo)記下辨图。
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中却桶。
下面的都是與網(wǎng)絡(luò)有關(guān)的了,網(wǎng)絡(luò)的知識沒學(xué)蔗牡,不知道怎么用颖系,可參考下安裝過程。
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区匣,但作為替代品偷拔,那個官網(wǎng)可真不怎么好蒋院。
它依賴的軟件中,我學(xué)Arch Linux莲绰,在后面括號中標(biāo)記了make欺旧,表示只在編譯的時候需要,
雖然不知道Arch Linux是不是這意思蛤签。
我確實沒有把那2個依賴放到開發(fā)版中辞友,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
臨時先讓系統(tǒng)中的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戳晌,但配置中沒有l(wèi)inux-armv7鲫尊,倒是有個與android有關(guān)的armv7,
那個armv7并沒有用與armv7有關(guān)的東西沦偎,而是armv4的疫向,所以我就用了“l(fā)inux-armv4”。
有個可疑的zlib-dynamic選項豪嚎,我沒加搔驼。
POD document had syntax errors at /usr/bin/core_perl/pod2man line 71.
看了源碼中的pod2mantest,里面說如果系統(tǒng)中沒有可用的pod2man侈询,會用openssl中自帶的舌涨。
既然系統(tǒng)中的有問題,那就用自帶的吧扔字。
# 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
系統(tǒng)中的strip無法識別交叉編譯后的程序啦租,看來要用交叉編譯器中的哗伯。
strip由install調(diào)用,看看install的手冊篷角,真的有選項可以改變調(diào)用的strip焊刹,
于是修改makefile,修改install的參數(shù)恳蹲。
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儿普,在開發(fā)板中運行以下命令生成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
驅(qū)動的知識
The major number generally specifies a particular driver within the kernel,
and the minor number specifies a particular device handled by that driver.
曾經(jīng)用過的,不用了浪汪。
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中一些基本的設(shè)備死遭,不清楚到底需要什么广恢,也不必考慮了,
因為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