使用make在linux上编译驱动程序

时间:2016-01-14 20:09:18

标签: c compilation makefile drivers

此错误消息是什么意思?我正在尝试运行make。看起来缺少配置。 Configure是内核源代码的一部分吗?

make -C /lib/modules/4.2.0-19-generic/build SUBDIRS=/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE modules
make[1]: Entering directory '/usr/src/linux-headers-4.2.0-19-generic'
  CC [M]  /home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.o
/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.c:55:6: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]
  " " __TIME__ " " __DATE__ "\n"
      ^
/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.c:55:19: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]
  " " __TIME__ " " __DATE__ "\n"
                   ^
cc1: some warnings being treated as errors
scripts/Makefile.build:264: recipe for target '/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.o' failed
make[2]: *** [/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.o] Error 1
Makefile:1398: recipe for target '_module_/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE' failed
make[1]: *** [_module_/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-19-generic'
Makefile:30: recipe for target 'default' failed
make: *** [default] Error 2

2 个答案:

答案 0 :(得分:2)

Makefile 中,将其添加到CFLAGS变量中

-Wno-date-time

这将禁用警告,因为警告被视为错误,因为 Makefile 正在通过-Werror传递CFLAGS代码无法编译。

答案 1 :(得分:1)

我理解这是因为警告被添加到GCC的更高版本中,最初将使用例如-Wall进行编译,但由于此额外限制现在不再这样做了。

如果您无法使用上面的makefile mod修复它,我已经将它固定在我自己的驱动程序版本中,只需将源代码的错误行包括在内:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdate-time"
... code with __DATE_ __TIME__
#pragma GCC diagnostic pop

这使得新的'仅对受影响的线路进行诊断。