openwrt--內核編譯及生成

0:重要文件

在下面的目錄中包含了編譯過程中調用的makefile.很重要的。

[root@localhost /openwrt/openwrt/trunk/include]$ls
autotools.mk      device_table.txt.bak  kernel-build.mk     Makefile             package-dumpinfo.mk  quilt.mk  site                uclibc++.mk
cmake.mk          download.mk           kernel-defaults.mk  netfilter.mk         package-ipkg.mk      rules.mk  subdir.mk           unpack.mk
debug.mk          host-build.mk         kernel.mk           nls.mk               package.mk           scan.mk   target.mk      verbose.mk
depends.mk        host.mk               kernel-version.mk   package-bin.mk       prereq-build.mk      scons.mk  toolchain-build.mk  version.mk
device_table.txt  image.mk              ltqtapi.mk   


1:內核編譯:

現在了最新的open的trunk之後, /openwrt/openwrt/trunk中的makefile是總的編譯開始,其中有如下內容:

 include $(TOPDIR)/include/host.mk
ifneq ($(OPENWRT_BUILD),1)
  _SINGLE=export MAKEFLAGS=$(space);
  override OPENWRT_BUILD=1
  export OPENWRT_BUILD
  GREP_OPTIONS=
  export GREP_OPTIONS
  include $(TOPDIR)/include/debug.mk
  include $(TOPDIR)/include/depends.mk
  include $(TOPDIR)/include/toplevel.mk
else
  include rules.mk
  include $(INCLUDE_DIR)/depends.mk
  include $(INCLUDE_DIR)/subdir.mk
  include target/Makefile
  include package/Makefile
  include tools/Makefile
  include toolchain/Makefile

其中在此處關注的是文件   include target/Makefile  

其中首先看看

$(curdir)/builddirs:=linux sdk imagebuilder toolchain
$(curdir)/builddirs-default:=linux 可以看到在此目錄下面有:/openwrt/openwrt/trunk/target/linux中的makefile 

include $(INCLUDE_DIR)/target.mk
export TARGET_BUILD=1
prereq clean download prepare compile install menuconfig nconfig oldconfig update refresh: FORCE
@+$(NO_TRACE_MAKE) -C $(BOARD) $@

其中NO_TRACE_MAKE 就是在頂層通過make menuconfig時配置的目標是什麼,此處選擇是ar71xx。

因此在看看ar71xx中的makefile是怎麼定義的。

include $(TOPDIR)/rules.mk
ARCH:=mips  當前的CPU是MIPS
BOARD:=ar71xx 板子類型
BOARDNAME:=Atheros AR7xxx/AR9xxx
FEATURES:=mips16
CPU_TYPE=34kc
SUBTARGETS:=generic nand mikrotik
LINUX_VERSION:=3.10.36  內核版本
include $(INCLUDE_DIR)/target.mk
DEFAULT_PACKAGES += \
        kmod-gpio-button-hotplug swconfig  kmod-ath9k wpad-mini uboot-envtools 必須編譯的模塊
$(eval $(call BuildTarget)) 需要實際執行的目標。

下面來看看BuildTarget的定義:












發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章