0

I´m trying to compile a kernel module which has a included .h file in it. At the moment the follow files are used;

main.c
gpiodriver.c
gpiodriver.h

The makefile:

 #CC=/usr/local/xtools/arm-unknown-linux-uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-cc

 PROG = main

 $(PROG)-objs := gpiodriver.o
 obj-m += $(PROG).o

 all: $(PROG)

 $(PROG): $(OBJ)
     make ARCH=arm CROSS_COMPILE=/usr/local/xtools/arm-unknown-linux-uclibcgnueabi/bin/arm-linux- -C 
 ~/felabs/sysdev/tinysystem/linux-2.6.34 M=$(PWD) -o $(PROG) modules

 clean:
     make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean

Honestly I'm not that good with the makefile, so my guess is that I'm doing it completly wrong..

MrEmper
  • 225
  • 1
  • 4
  • 18
  • I can only suppose that you came up with that makefile by attempting to use another module's makefile as a model. There's nothing inherently wrong with referring to examples, but you really ought to use them as a *supplement* to the documentation for [the kernel build system](https://www.kernel.org/doc/html/latest/kbuild/index.html). In this case, it sounds like the section on [building external modules](https://www.kernel.org/doc/html/latest/kbuild/modules.html) would be particularly relevant. Relying on the docs is even more important if your makefile-fu is weak. – John Bollinger Dec 06 '20 at 16:12
  • 1
    The problem is that you build a kernel module from several files, one of which has the **same name** as the module itself. See that question for possible solutions: [Building a kernel module from several source files which one of them has the same name as the module](https://stackoverflow.com/questions/13606075/building-a-kernel-module-from-several-source-files-which-one-of-them-has-the-sam) – Tsyvarev Dec 06 '20 at 17:05

0 Answers0