[問題] 請教Makefile將幾個*.c build成ko寫法

作者: greenlinux (GreenLinux)   2013-12-22 01:30:55
請教各位:
現在在一個folder內有 1.c, 2.c, 3.c, 4.c, 5.c 及 1.h, 2.h 等檔案
是一個driver 的 code.
其中 各 *.c 內有些參數或Function宣告是共用的. 例如:
int x = 0 在 1.c, 然後 1.h 有 extern int x=0;
1.c 有function: int test1(void){...}
5.c 也可以用 test1() 來使用..
請問(1)要如何寫Makefile 讓它們一起build 成一個 *.ko
還是一定要build 成 多個ko?
(2) 我試過寫成:
obj-m 1.o
obj-m 2.o
obj-m 3.o
obj-m 4.o
obj-m 5.o
會出現以下error:
"test1" [drivers/xxx/xx.ko] undefined
"x" [drivers/xxx/xx.ko] undefined
有些function 加 EXPORT_SYMBOL(xxxxxx)不再出現undefined
但有些可以有些還是會 show undefined.....
請問Makefile 需要怎樣修改...
謝謝各位指導

Links booklink

Contact Us: admin [ a t ] ucptt.com