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的定义:












你可能感兴趣的:(openwrt--内核编译及生成)