Makefile
最初、obj-y とか obj-m とか何のコトかと思いましたが、.config の中のソレですな。
で、とりあえず Makefile をでっち上げてみる事にして gcc -MM -w してみたら以下
$ gcc -MM -w *.c dir.o: dir.c tarfs.h tarinf.h file.o: file.c tarfs.h tarinf.h inode.o: inode.c tarfs.h tarinf.h namei.o: namei.c tarfs.h tarinf.h In file included from /usr/include/asm/module.h:8, from /usr/include/linux/module.h:22, from super.c:26: /usr/include/asm-i486/module.h:60:2: error: #error unknown processor family tarent.o: tarent.c tarfs.h tarinf.h $
微妙なエラーはスルー。これを基に以下をでっち上げてみた。
obj-m:= tarfs.o KDIR:= /lib/modules/${shell uname -r}/build PWD:= ${shell pwd} TARGET:= tarfs.ko all: ${TARGET} tarfs-objs:= dir.o file.o inode.o namei.o tarent.o tarfs.ko: ${tarfs-objs} ${MAKE} -C ${KDIR} M=${PWD} modules clean-files:= *.o *.ko *.mod.[co] *~
動作するかどうかは微妙。とりあえず忘れないように、という事で。
追記
しまった。gcc -MM でナニしたソレを盛り込んでないや。
こんなカンジかなぁ。
obj-m:= tarfs.o KDIR:= /lib/modules/${shell uname -r}/build PWD:= ${shell pwd} TARGET:= tarfs.ko all: ${TARGET} tarfs-objs:= dir.o file.o inode.o namei.o tarent.o tarfs.ko: ${tarfs-objs} ${MAKE} -C ${KDIR} M=${PWD} modules dir.o: dir.c tarfs.h tarinf.h file.o: file.c tarfs.h tarinf.h inode.o: inode.c tarfs.h tarinf.h namei.o: namei.c tarfs.h tarinf.h tarent.o: tarent.c tarfs.h tarinf.h clean-files:= *.o *.ko *.mod.[co] *~
clean なターゲットの記述が無いのが微妙。
さらに追記
オリジナルの Makefile を見てなかった。
# makefile for tarfs # Version: $Id: Makefile,v 1.4 2001/02/25 20:25:31 kaz Exp $ HEADERS = tarfs.h tarinf.h OBJS = file.o inode.o super.o dir.o tarent.o namei.o CFLAGS = -Wall -O2 -D__KERNEL__ -DMODULE all: tarfs.o $(OBJS): $(HEADERS) tarfs.o : $(OBJS) Makefile ld -r -o tarfs.o $(OBJS) clean: rm $(OBJS) tarfs.o
これをパクると先のナニは以下のように書けるか
obj-m:= tarfs.o KDIR:= /lib/modules/${shell uname -r}/build PWD:= ${shell pwd} tarfs-objs:= file.o inode.o super.o dir.o tarent.o namei.o HEADERS:= tarfs.h tarinf.h TARGET:= tarfs.ko clean-files:= *.o *.ko *.mod.[co] *~ all: ${TARGET} ${tarfs-objs}: ${HEADERS} tarfs.ko: ${tarfs-objs} ${MAKE} -C ${KDIR} M=${PWD} modules clean: rm -rf ${clean-files}
ちょっとすっきり。でもこれだと
$ make file.o
みたいなナニは不可能??