如何在Make中正确使用-C选项

问题描述 投票:0回答:2

我需要在我的 archlinux 安装中编译this程序。

当我这样做时,按照该线程中的指示:

make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules

我收到以下错误:

 make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules
scripts/Makefile.build:41: /home/jenia/Documents/kernel-modules/camera/Makefile: No such file or directory
make[1]: *** No rule to make target '/home/jenia/Documents/kernel-modules/camera/Makefile'.  Stop.
make: *** [Makefile:2021: /home/jenia/Documents/kernel-modules/camera] Error 2

makefile 确实不在

/home/jenia/Documents/kernel-modules/camera/Makefile
,而是在:

ls -l /lib/modules/$(uname -r)/build/Makefile
-rw-r--r-- 1 root root 71855 Mar  3 10:58 /lib/modules/6.2.2-arch1-1/build/Makefile

如何正确指向

lib/modules/$(uname -r)/build/Makefile
?请注意,我已经在使用
-C
标志但无济于事。

c makefile build linux-kernel linux-device-driver
2个回答
0
投票

半消息灵通的猜测。

你有:

make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules

M=$(pwd)
记录了您从中运行构建的目录,并且可能在
makefile
中用于确定应在何处找到包含的 makefile(
kernel-modules/camera/Makefile
的某些子集)。但是您的
/home/jenia/Documents
目录中没有它。

丝毫没有测试过,我认为你的问题是你当前的目录需要更接近软件所在的位置。我不确定具体是哪个目录,但

/lib/modules
可能是一个合理的猜测(因此,它可能是错误的)。

但重点是:

  • 确保从正确/预期的目录启动构建。

您使用

-C
没问题;问题是
M=$(pwd)
部分。

请注意,文件

/lib/modules/6.2.2-arch1-1/build/Makefile
可能不是
scripts/Makefile.build
正在寻找的文件;那应该在某处的子目录
camera
中。


为了支持我关于“从正确的目录开始”的理论,我注意到链接文章中的评论 #19 说:

首先,启用源代码存储库,然后在终端中使用以下命令获取源代码

apt-get source linux-modules-extra-$(uname -r)

然后导航到

/drivers/media/usb/uvc
目录并将
uvcdriver.c
重命名为
uvcdriver.old
,然后在终端中选择打开目录

wget https://raw.githubusercontent.com/Giuliano69/uvc_driver-for-Quanta-HD-User-Facing-0x0408-0x4035-/main/uvc_driver.c

make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules
sudo cp uvcvideo.ko /lib/modules/$(uname -r)/kernel/drivers/media/usb/uvc/

然后看看它是否有效

这表明您应该从

/drivers/media/usb/uvc
目录启动您的构建。


0
投票

如何正确指向

lib/modules/$(uname -r)/build/Makefile

根据您正在执行的

make
命令,您报告的错误消息表明您已经将
make
定向到该 makefile。主要错误来自子
make
,因此必须找到顶层makefile。

当我这样做时,按照该线程中的指示:

make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules

我收到以下错误:

 make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules
scripts/Makefile.build:41: /home/jenia/Documents/kernel-modules/camera/Makefile: No such file or directory
make[1]: *** No rule to make target '/home/jenia/Documents/kernel-modules/camera/Makefile'.  Stop.
make: *** [Makefile:2021: /home/jenia/Documents/kernel-modules/camera] Error 2

该错误似乎表明尽管您正在执行从引用线程中提取的命令,但您没有完全按照那里的说明进行操作:

首先,启用源代码存储库,然后在终端中使用以下命令获取源代码

apt-get source linux-modules-extra-$(uname -r)

Then导航到

/drivers/media/usb/uvc
目录并将
uvcdriver.c
重命名为
uvcdriver.old
,在终端中选择打开目录then

wget https://raw.githubusercontent.com/Giuliano69/uvc_driver-for-Quanta-HD-User-Facing-0x0408-0x4035-/main/uvc_driver.c

make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules

sudo cp uvcvideo.ko /lib/modules/$(uname -r)/kernel/drivers/media/usb/uvc/

(添加了强调和一些格式。)

不清楚您究竟遵循了哪些说明,哪些没有,但可以肯定的是,您是从与

make
不同的目录运行
/drivers/media/usb/uvc
命令。可能您也在从中运行构建的任何目录中执行了
wget
命令,而不是在说明中指定的目录中。不知道你有没有运行
apt-get
命令

可能有其他方法可以做到这一点,但你不能指望它能只选择一组特定指令中的一部分。

© www.soinside.com 2019 - 2024. All rights reserved.