android 如何添加第3方lib庫到kernel中

來源:互聯網
上載者:User

android 如何添加第3方lib庫到kernel中
注意:只能將lib庫放在kernel編譯到的地方,如下:
alps/kernel/
alps/mediatek/custom/common/kernel/
alps/mediatek/custom/$platform/kernel/
alps/mediatek/custom/$proj/kernel/
alps/mediatek/kernel/
alps/mediatek/platform/$platform/kernel/core/
alps/mediatek/platform/$platform/kernel/drivers/
假設第3方庫名稱為test.a
(1). 如果存放的目錄存在Makefile,那麼只需在該Makefile最後添加:
obj-y += test.a
然後將test.a檔案複製到該目錄下,
重新命名為test.a_shipped,目的是防止clean kernel階段把該庫給清除掉!
重新編譯kernel即可。
(2). 如果存放的目錄不存在Makefile,比如在alps/mediatek/custom/目錄下的kernel目錄都沒有Makefile,這時需要自行添加一個Makefile,內容和第1種方法差不多:
obj-y := xxx.o yyy.o test.a
以上表示將xxx.c/yyy.c和test.a編譯到kernel
然後將test.a檔案複製到該目錄下並重新命名為test.a_shipped
重新編譯kernel即可。
注意:alps/mediatek/custom/common/kernel/touchpanel/xxx目錄下的檔案會和alps/mediatek/custom/common/kernel/touchpanel/src目錄合并,obj-y要將兩個目錄下的obj全部加入才行,否則編譯失敗。也可以用以下Makefile,自動將所有obj加入obj-y,省卻麻煩。其他目錄如有類似的情形一樣處理。
添加的Makefile(將所有*.c變為*.o並加入obj-y):
include $(MTK_PATH_BUILD)/common.mk
path := $(if $(filter yes,$(KBUILD_OUTPUT_SUPPORT)),$(srctree)/$(obj),$(obj))
obj-y := $(patsubst %.c,%.o,$(subst $(path)/,,$(call wildcard2,$(path)/*.c)))
obj-y += test.a

說明:對於kernel的Makefile編寫規則說明,可以到網路搜尋相關材料參考,比如obj-y表示要編譯到kernel,而obj-m表示要編譯成module,obj-n或obj-表示不編譯

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.