Centos7下編譯openwrt
1.下載openwrt最新源碼
git clone https://github.com/openwrt/openwrt.git
2.下載feeds
執行$ ./scripts/feeds update -a$ ./scripts/feeds install -a
3.配置環境
make defconfig可檢查所需依賴$sudo yum -y install gcc binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils libncurses5-dev ncurses-term zlib1g-dev wget perl-Thread-Queue openssl-devel zlib-static ncurses-devel gcc-c++$ make prereq$ make menuconfig
通過文本對話方塊進行選項配置,最主要的配置項有:
Target system(目標系統類別型)
Package selection(軟體包選擇)
Build system settings (編譯系統設定)
Kernel modules (核心模組)
[*]表示:這個包裹選中編譯,並安裝在firmware中;
[M]表示:這個軟體包選中編譯,但並不安裝在firmware中。
在退出Menuconfig的時,會提示是否儲存配置。
4.編譯
-
一般情況,使用一個簡單的命令:
$ make
-
在多核處理器系統上為提高速度,可使用(例如用3核處理器):
$ make –j 3
-
在後台進行編譯,使用閒置I/O資源和CPU效能,可使用(例如使用雙核處理器)
$ onice -c 3 nice -n 20 make -j 2
-
編譯一個單獨的軟體包(例如在cups軟體包):
$ make package/cups/compile V=99
-
如果特殊原因需要分析編譯報錯資訊:
$ make V=99 2>&1 |tee build.log |grep -i error
說明:將編譯的所有輸出資訊儲存在build.log中,將error資訊列印在螢幕上。
-
一個複雜指令的應用
$ ionice -c 3 nice -n 20 make -j 2 V=99 CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 |tee build.log |egrep -i '(warn|error)'
說明:將編譯的所有輸出資訊儲存在build.log中,將error和warning資訊列印在螢幕上。編譯過程使用雙核CPU,佔用後台資源。
5.產生鏡像(Image)位置
新產生的鏡像會預設放在建立的一個bin目錄下。
$ ls bin/*
6.清理工作
$ make clean
除了清除產生的目錄,還想清除交叉編譯工具(以及工具鏈目錄)
$ make dirclean
清除所有相關的東西,包括下載的軟體包,設定檔,feed內容等:
$ make distclean
7.安裝openwrt