问题描述
我正在使用 Makefile
在 ARCH linux发行版上编译内核模块 thermal.c 。Makefile:
db.collection.find().forEach(function(doc) {
doc.field.subfield.time=new ISODate(doc.field.subfield.time);
db.collection.save(doc);
})
make命令的输出为:
obj-m += thermal.o
all:
make -C /lib/modules/$(uname -r)/build/ M=$(PWD) modules
clean:
make -C /lib/modules/$(uname -r)/build/ M=$(PWD) clean
make -C /lib/modules//build/ M=/home/user/dir modules
make[1]: *** /lib/modules//build/: No such file or directory. Stop.
make: *** [Makefile:4: all] Error 2
输出: 5.6.8-arch1-1
解决方法
make在将配方传递到外壳之前将其展开。在您的情况下,make用名为$(PWD)
的make变量的值替换PWD
(正确),但它也用名为$(uname -r)
的make变量的值替换了uname -r
。由于未定义此类make变量,因此结果为空字符串。使用$$(uname -r)
可解决此问题,因为make会将其扩展为$(uname -r)
,正是您要传递给shell的内容。
总而言之,您必须通过将它们加倍来从make扩展中逃脱要保留的$
:
all:
make -C /lib/modules/$$(uname -r)/build/ M=$(PWD) modules
clean:
make -C /lib/modules/$$(uname -r)/build/ M=$(PWD) clean