Android是支援模組化編譯的,可以單獨對某一個模組:比如瀏覽器進行編譯。
1、進入Android源碼根目錄,執行source build/envsetup.sh;
2、可以執行mm、mmm等模組編譯命令了。如要編譯audioflinger,則執行mmm frameworks/base/services/audioflinger/ -B即可。
3、make -snod重建system.img映像。
將envsetup.sh的一些注釋摘下來如下:
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- croot: Changes directory to the top of the tree.
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory.
- mmm: Builds all of the modules in the supplied directories.
- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir: Go to the directory containing a file.
Android 源碼編譯 make命令
Makefile
在符合GNU Makefiel慣例的Makefile中,包含了一些基本的預先定義的操作:
make
根據Makefile編譯原始碼,串連,產生目標檔案,可執行檔。
make clean
清除上次的make命令所產生的object檔案(尾碼為“.o”的檔案)及可執行檔,僅僅是清除之前編譯的可執行檔及設定檔。
make distclean 要清除所有產生的檔案,包括configure產生的檔案,如Makefile檔案。
make install
將編譯成功的可執行檔安裝到系統目錄中,一般為/usr/local/bin目錄。
make dist
產生髮布軟體包檔案(即distributionpackage)。這個命令將會將可執行檔及相關檔案打包成一個tar.gz壓縮的檔案用來作為發布軟體的軟體包。
它會在目前的目錄下產生一個名字類似“PACKAGE-VERSION.tar.gz”的檔案。PACKAGE和VERSION,是我們在configure.in中定義的AM_INIT_AUTOMAKE(PACKAGE,VERSION)。
make distcheck
產生發布軟體包並對其進行測試檢查,以確定發布包的正確性。這個操作將自動把壓縮包檔案解開,然後執行configure命令,並且執行make,來確認編譯不出現錯誤,最後提示你軟體包已經準備好,發行就緒了。
make distclean類似make clean,但同時也將configure產生的檔案全部刪除掉,包括Makefile。