呆着無聊,寫個linux配置和ramdisk相關的筆記。
由於 Linux 內核源代碼是按照樹形結構組織的,所以 Makefile 也被分佈在目錄樹中。Linux 內核中的 Makefile 以及與 Makefile 直接相關的文件有:
- Makefile:頂層 Makefile,是整個內核配置、編譯的總體控制文件。
- .config:內核配置文件,包含由用戶選擇的配置選項,用來存放內核配置後的結果(如 make config)。
- arch/*/Makefile:位於各種 CPU 體系目錄下的 Makefile,如 arch/arm/Makefile,是針對特定平臺的 Makefile。
- 各個子目錄下的 Makefile:比如 drivers/Makefile,負責所在子目錄下源代碼的管理。
- Rules.make:規則文件,被所有的 Makefile 使用。
用戶通過 make config 配置後,產生了 .config。頂層 Makefile 讀入 .config 中的配置選擇。頂層 Makefile 有兩個主要的任務:產生 vmlinux 文件和內核模塊(module)。爲了達到此目的,頂層 Makefile 遞歸的進入到內核的各個子目錄中,分別調用位於這些子目錄中的 Makefile。至於到底進入哪些子目錄,取決於內核的配置。在頂層 Makefile 中,有一句:include arch/$(ARCH)/Makefile,包含了特定 CPU 體系結構下的 Makefile,這個 Makefile 中包含了平臺相關的信息。
鄙人之前還寫過一篇文章:linux make menuconfig\Makefile\Kconfig 詳解
http://blog.csdn.net/codectq/article/details/9797031獲取linux源碼:
sudo git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
獲取交叉編譯工具
sudo apt-get install gcc-arm-linux-gnueabi
解決缺庫的問題
*** Unable to find the ncurses libraries or the
*** required header files.
*** ‘make menuconfig’ requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.
解決辦法:
sudo apt-get install ncurses-dev
解決直接編譯報錯的問題
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[2]: *** [silentoldconfig] Error 1
make[1]: *** [silentoldconfig] Error 2
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
HOSTLD arch/x86/tools/relocs
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'. Stop.
方法是需要配置ARCH和CROSS_COMPILE,設置正確值
配置ramdisk