我试图编译内核模块源代码,直到我注意到一些空格导致路径名不匹配。我发现自己的目录是:
axor@vacuum:~/software/CS 8803/Operating System Concepts/Chapter 2/ch2$ ls
Makefile simple.c
我发生的错误:
axor@vacuum:~/software/CS 8803/Operating System Concepts/Chapter 2/ch2$ make
make -C /lib/modules/4.9.0-3-amd64/build M="/home/none/software/CS 8803/Operating System Concepts/Chapter 2/ch2" modules
make[1]: Entering directory '/usr/src/linux-headers-4.9.0-3-amd64'
/usr/src/linux-headers-4.9.0-3-common/scripts/Makefile.build:44: /home/none/software/CS/Makefile: No such file or directory
make[4]: *** No rule to make target '/home/none/software/CS/Makefile'. Stop.
make[3]: *** [/usr/src/linux-headers-4.9.0-3-common/Makefile:1507: _module_/home/none/software/CS] Error 2
make[2]: *** [Makefile:150: sub-make] Error 2
make[1]: *** [Makefile:8: all] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.9.0-3-amd64'
make: *** [Makefile:4: all] Error 2
现在,我很清楚目录名称中的空格导致了问题。我将感兴趣的目录树重命名为~/software/CS-8803/Operating-System-Concepts/Chapter-2/ch2
,所有这些都有效。
问题:即使在包含空格的目录名称下,我如何才能使以下 makefile 正常工作?
obj-m += simple.o
all:
make -C /lib/modules/$(shell uname -r)/build M="$(PWD)" modules
clean:
make -C /lib/modules/$(shell uname -r)/build M="$(PWD)" clean