亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Linux 內核的編譯系統

系統 1843 0

?

?

Linux? 的編譯使用 GNU make 工具來檢查整個系統的文件和調用 gcc 工具以及腳本完畢編譯源碼生成 image 等操作。要了解整個編譯系統,我們首先要了解 Linux 內核的 Makefile 文件。

?

Linux 的 編譯系統包含 5 個部分

Makefile ? ? ? ? 頂層的 Makefile 文件
.config 內核配置文件
arch/$(ARCH)/Makefile 平臺 Makefile 文件
scripts/Makefile.* ? ? ? ? ? ? ? ?腳本規則
kbuild Makefiles ? ? ? ? ? ? 大概 500 多個其它的 Makefile 文件


Makefile

?

查看版本號

?

在內核源碼的根文件夾有一個 Makefile 文件,這是編譯內核的入口,無論運行配置還是編譯,make 命令首先讀取這個文件。這個文件首先指明了內核的版本號:

我們這里是 3.10

VERSION = 3
PATCHLEVEL = 10
SUBLEVEL = 0
EXTRAVERSION =
NAME = Unicycling Gorilla

?

處理參數

?

然后處理 command line ,一共同擁有 5 ?個 command line

V?: 設定編譯時,輸出信息的等級,比如你能夠用 make V=1, 查看編譯時運行的全部命令,包含 gcc 參數都會打印出來

C :? 代碼檢查,使用 sparse,檢查源文件。

M : 指定不在當前文件夾(外部模塊)的編譯,也能夠指定當前文件夾的子文件夾,那么將僅僅會編譯子文件夾的內容

O :指定編譯生成的目標文件位置,當設置了 O 參數,內核生成的 obj 和 builtin 文件都會依照文件夾結構組織到 O 參數指定的文件夾里面

W: 使能外部 gcc 檢查

?

這幾個命令參數,在特定的情況下,將會很實用,比方我們想編譯一個單獨的模塊就常常使用 M 參數,用 M 指定模塊的路徑,make 的時候將會不編譯整個內核,而編譯我們須要的模塊:(M 參數會覆蓋? KBUILD_EXTMOD 變量)

      make M=drivers/misc/
 LD      drivers/misc/eeprom/built-in.o
 CC [M]  drivers/misc/eeprom/eeprom_93cx6.o
 LD      drivers/misc/built-in.o
 Building modules, stage 2.
 MODPOST 1 modules
 CC      drivers/misc/eeprom/eeprom_93cx6.mod.o
 LD [M]  drivers/misc/eeprom/eeprom_93cx6.ko
    


?

O 參數的指定,會改變整個編譯出來的文件的結構,比如哦我們有多個平臺要編譯,你就須要為每一個平臺 clone 一份內核代碼了,僅僅須要設置不同的輸出路徑就可以:

make O=atmel,? make O=asus? (O 參數會覆蓋 KBUILD_OUTPUT 變量),對應的文件也會生成在目標路徑下,比如 uImage 就在 atmel/arch/arm/boot/uImage

?

獲取信息

?

接下來系統就會獲取交叉編譯環境和選擇不同的 gcc 和 bin 工具集

      ARCH            ?= $(SUBARCH)
CROSS_COMPILE   ?= $(CONFIG_CROSS_COMPILE:"%"=%)
    


arch 變量設置目標平臺, cross compile 設置交叉編譯鏈。

?

偽目標

?

當系統信息獲取成功,就能夠運行編譯命令了,每個偽目標都能夠作為一個編譯命令:(大概有 40 個左右的偽目標),可是我們會使用到的并沒有這么多,能夠用 make help 查看我們使用的編譯命令:

       make help
Cleaning targets:
  clean           - Remove most generated files but keep the config and
                    enough build support to build external modules
  mrproper        - Remove all generated files + config + various backup files
  distclean       - mrproper + remove editor backup and patch files
Configuration targets:
  config          - Update current config utilising a line-oriented program
  nconfig         - Update current config utilising a ncurses menu based program
  menuconfig      - Update current config utilising a menu based program
  xconfig         - Update current config utilising a QT based front-end
  gconfig         - Update current config utilising a GTK based front-end
  oldconfig       - Update current config utilising a provided .config as base
  localmodconfig  - Update current config disabling modules not loaded
  localyesconfig  - Update current config converting local mods to core
  silentoldconfig - Same as oldconfig, but quietly, additionally update deps
  defconfig       - New config with default from ARCH supplied defconfig
  savedefconfig   - Save current config as ./defconfig (minimal config)
  allnoconfig     - New config where all options are answered with no
  allyesconfig    - New config where all options are accepted with yes
  allmodconfig    - New config selecting modules when possible
  alldefconfig    - New config with all symbols set to default
  randconfig      - New config with random answer to all options
  listnewconfig   - List new options
  olddefconfig    - Same as silentoldconfig but sets new symbols to their default value
Other generic targets:
  all             - Build all targets marked with [*]
* vmlinux         - Build the bare kernel
* modules         - Build all modules
  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)
  firmware_install- Install all firmware to INSTALL_FW_PATH
                    (default: $(INSTALL_MOD_PATH)/lib/firmware)
  dir/            - Build all files in dir and below
  dir/file.[oisS] - Build specified target only
  dir/file.lst    - Build specified mixed source/assembly target only
                    (requires a recent binutils and recent build (System.map))
  dir/file.ko     - Build module including final link
  modules_prepare - Set up for building external modules
  tags/TAGS       - Generate tags file for editors
  cscope          - Generate cscope index
  gtags           - Generate GNU GLOBAL index
  kernelrelease   - Output the release version string
  kernelversion   - Output the version stored in Makefile
  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH
                    (default: /media/android/jiangxd/workspace/Miura/kernel/usr)
Static analysers
  checkstack      - Generate a list of stack hogs
  namespacecheck  - Name space analysis on compiled kernel
  versioncheck    - Sanity check on version.h usage
  includecheck    - Check for duplicate included header files
  export_report   - List the usages of all exported symbols
  headers_check   - Sanity check on exported headers
  headerdep       - Detect inclusion cycles in headers
  coccicheck      - Check with Coccinelle.
Kernel packaging:
  rpm-pkg             - Build both source and binary RPM kernel packages
  binrpm-pkg          - Build only the binary kernel package
  deb-pkg             - Build the kernel as a deb package
  tar-pkg             - Build the kernel as an uncompressed tarball
  targz-pkg           - Build the kernel as a gzip compressed tarball
  tarbz2-pkg          - Build the kernel as a bzip2 compressed tarball
  tarxz-pkg           - Build the kernel as a xz compressed tarball
  perf-tar-src-pkg    - Build perf-3.10.0.tar source tarball
  perf-targz-src-pkg  - Build perf-3.10.0.tar.gz source tarball
  perf-tarbz2-src-pkg - Build perf-3.10.0.tar.bz2 source tarball
  perf-tarxz-src-pkg  - Build perf-3.10.0.tar.xz source tarball
Documentation targets:
 Linux kernel internal documentation in different formats:
  htmldocs        - HTML
  pdfdocs         - PDF
  psdocs          - Postscript
  xmldocs         - XML DocBook
  mandocs         - man pages
  installmandocs  - install man pages generated by mandocs
  cleandocs       - clean all generated DocBook files
Architecture specific targets (arm):
* zImage        - Compressed kernel image (arch/arm/boot/zImage)
  Image         - Uncompressed kernel image (arch/arm/boot/Image)
* xipImage      - XIP kernel image, if configured (arch/arm/boot/xipImage)
  uImage        - U-Boot wrapped zImage
  bootpImage    - Combined zImage and initial RAM disk
                  (supply initrd image via make variable INITRD=<path>)
* dtbs          - Build device tree blobs for enabled boards
  install       - Install uncompressed kernel
  zinstall      - Install compressed kernel
  uinstall      - Install U-Boot wrapped compressed kernel
                  Install using (your) ~/bin/installkernel or
                  (distribution) /sbin/installkernel or
                  install to $(INSTALL_PATH) and run lilo
    

內容很之多。這里僅僅介紹幾個經常使用的:

make menuconfig ?圖形化配置 config

make uImage ? ? ? ? ?編譯生成 uImage

make clean ? ? ? ? ? ? ?刪除大部分生成的文件,可是保留配置,以便能夠編譯模塊

make distclean ? ? ? 刪除全部生成的文件,補丁和配置,以及一些備份文件

make mrproper ? ? ??刪除全部生成的文件,補丁和配置


總的來說,頂層 Makefile 文件讀取 config 文件生成 Linux 的兩大目標文件 vmlinux 和 模塊文件

Linux 內核的編譯系統


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 国产精品一区三区 | 毛片大全在线 | 99视频免费播放 | 日本中文一区 | 伊人焦久影院 | 成人窝窝午夜看片 | 亚洲成人在线免费视频 | 欧美a视频 | 香蕉视频看片 | 久久91精品国产91久久户 | 99免费在线观看视频 | 国产精品九九九久久九九 | 九九99热久久精品在线9 | 成年午夜视频免费观看视频 | 一区二区中文字幕亚洲精品 | a免费毛片在线播放 | 26uuu久久| 精品中文字幕不卡在线视频 | 精品免费久久久久久久 | 夜夜操操 | 中文字幕在线观看国产 | 国产欧美国产精品第一区 | 夜夜艹日日干 | 男人资源站 | 久久精品欧美日韩精品 | a级毛片在线观看 | 亚洲欧美在线视频免费 | 欧美肥老太婆交 | 日韩欧美中文字幕一区 | 亚洲第一a | 国产精品久久久久无毒 | 最新午夜韩国理论片77网 | 久久精品国产色蜜蜜麻豆 | 亚洲欧美在线观看91偷拍 | 男人猛桶女人下面视频国产 | 在线播放 亚洲 | 国内精品视频成人一区二区 | 国产精品免费在线播放 | 99爱这里只有精品 | 免费精品99久久国产综合精品 | 97久久久久国产精品嫩草影院 |