1

I am building an out-of-tree kernel module for a device driver. Overall, things are going well, but I had a few questions about using kbuild and the build system:

  1. I found this excellent post: Is it possible to set CFLAGS to a linux kernel module Makefile?, which shows how to modify the compiler flags. As a result, I am now setting my compiler flags as: ccflags-y := -O2 -Wall -Wextra -I $(DRIVER_INC_DIR), where $(DRIVER_INC_DIR) is various header files for my driver. Note that my driver is made up of several .o files that get merged into a single .ko. I want to show warnings generated by the compiler for my own code, but not code in Linux (e.g., linux/module.h). How can I accomplish that? I know in user space applications there is the -isystem option, but I'm wondering how that would apply here (if at all).
  2. Is there any difference between using modules_install versus just doing a copy of the .ko file after it has been compiled? The reason I ask is because I think its easier for me to follow doing a manual copy, since I also need to support a "make uninstall" target (and there is no modules_uninstall, just a clean, which does not appear to remove the .ko from where it was installed).

Thanks in advance for the help.

It'sPete
  • 5,083
  • 8
  • 39
  • 72

1 Answers1

2

I have been able to answer #1. Basically, inside of kbuild, the LINUXINCLUDE variable is using -I to pull in all the source code from the Linux headers. As a result, I added this line to my Makefile:

LINUXINCLUDE := $(subst -I, -isystem, $(LINUXINCLUDE))

This replaces all the -I flags with -isystem and therefore, the warnings are ignored.

It'sPete
  • 5,083
  • 8
  • 39
  • 72