Openwrt編譯環境搭建
操作系統 centos-5.8 64位
安裝gnome, 可使用Xmanager
#yum -y groupinstall "X Window System"
#yum -y groupinstall "Desktop"
安裝svn
#yum install subversion
下載openwrt源碼
#svn co svn://svn.openwrt.org/openwrt/trunk/
地址:https://dev.openwrt.org/wiki/GetSource
# make menuconfig, 報錯
不執行 ./scripts/feeds update -a和 ./scripts/feeds install -a 之前,
make menuconfig里是看不到LuCI選項的。
#vim README
"./scripts/feeds update -a" to get all the latest package definitions defined in feeds.conf/ feeds.conf.default respectively.
feeds.conf.default里需要下載的packege的幾條git 和svn 的路徑地址。
"./scripts/feeds install -a" to install symlinks of all of them into package/feeds/
在package/feeds/luci/中(原本是沒有該目錄的, package/feeds目錄是在執行完./scripts/feeds 的兩條命令之后生成的), 可以看到一些鏈接, ll看一下
例:community-profiles -> ../../../feeds/luci/contrib/package/community-profiles/
此處的feeds是trunk目錄下的feeds目錄, 原來也是沒有的, 在執行完./scripts/feeds兩條命令之后生成。
tmp目錄本來也是沒有的, 在執行完上述兩條命令后, 在tmp目錄下生成.config和其他文件, 在make menuconfig之后, tmp/.config更新。
trunk下的.config原來沒有, 也是此時下載的。 在make menuconfig之后更新。
# make menuconfig, 報錯
1. Please install the GNU C++ Compiler (g++).
#yum install gcc-c++;
2. Please install ncurses. (Missing libncurses.so or ncurses.h)
#yum install ncurses;
#yum install ncurses-devel;
3. Please install zlib. ( Missing libz.so or zlib.h)
#yum install zlib-devel
4. Please install git(git-core) v1.6.5 or later.
下載地址:http://git-scm.com/downloads, 點擊Old releases.
用wget工具: #wget https://www.kernel.org/pub/software/scm/git/git-1.9.2.tar.gz
#vim INSTALL;
#make prefix=/usr all doc info ;# as yourself
缺少ssl.h #yum install openssl-devel;
缺少curl http.h:54: error: expected specifier-qualifier-list before ‘CURLcode’
#yum install curl
還是缺少curl
#yum install curl-devel
warning: expat.h缺少
#yum install expat-devel;
/bin/sh: msgfmt command not found;
#yum install gettext;
/bin/sh: asciidoc command not found;
安裝mercurial
#wget http://mercurial.selenic.com/release/mercurial-3.0.tar.gz
#cd mercurial
#make
#make install
mercurial/base85.c:13:20: error: Python.h: No such file or directory
安裝python
#yum install python
#yum install python-devel
此時make install 時, 提示需要安裝python-docutils
wget http://cznic.dl.sourceforge.net/project/docutils/docutils/0.11/docutils-0.11.tar.gz
#wget https://www.python.org/ftp/python/3.4.0/Python-3.4.0.tgz
報錯:ERROR: certificate common name `*.c.ssl.fastly.net' doesn't match requested host name `www.python.org'.
#wget --no-check-certificate https://www.python.org/ftp/python/3.4.0/Python-3.4.0.tgz
#hg clone -r 8.6.9 https://asciidoc.googlecode.com/hg/ asciidoc-8.6.9
#autoconf: autoconf command not found
#yum install autoconf
git安裝好之后,#make menuconfig正常, 選定LuCI, 生成.config(trunk下原來是沒有.config文件的)
#make
在./tmp/.config-packge.in中(此.config-package.in也是make menuconfig生成的), 有menu "LuCI"的配置
在.config中, CONFIG_PACKAGE_luci=y
在./tmp/.config中,CONFIG_PACKAGE_luci=y
在./tmp/.packagedeps:package-$(CONFIG_PACKAGE_luci) += feeds/luci/luci 中
太多的Makefile和config.in都是后來生成的, 有必要從開始Makefile看起。
一: make menuconfig V=99過程
topdir的Makfile中, include $(TOPDIR)/include/toplevel.mk
toplevel.mk中,
menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
cp $(HOME)/.openwrt/defconfig .config; \
fi
$< Config.in
(1) scripts/config/mconf, toplevel.mk中,:
$(_SINGLE)$(SUBMAKE) -s -C scripts/config all CC="$(HOSTCC_WRAPPER)"
//export MAKEFLAGS= ;umask 022; make -w -s -C scripts/config all CC="gcc"
// topdir的Makefile中, _SINGLE=export MAKEFLAGS=$(space)
//toplevel.mk中,SUBMAKE :=umask 022; $(SUBMAKE) umask 022, 表示默認的文件夾權限為755(777-022). 文件權限為644(666-022)?
scrpts/config/Makefile中,
all:conf mconf
conf: $(conf-objs) //conf-objs :conf.o zconf.tab.o
mconf: $(mconf-objs) $(lxidag-objs)
$(CC) -o $@ $^ $(call check_lxdialog, ldflags, $(CC)) ,
生成mconf, 至此, menuconfig的第一個依賴, scripts/config/mconf 完成, 生成/scripts/config/mconf文件
(2)prepare-tmpinfo,