How to see the preprocessed output of a module source file

Aruna Hewapathirane aruna.hewapathirane at gmail.com
Mon Nov 2 08:41:09 EST 2015


>> On Mon, Nov 2, 2015 at 7:02 AM, Shiyao Ma <i at introo.me> wrote:
>> Hi,
>> Say I am writing a module. Instead of directly compile it into a ko
file, I'd like to see the preprocessed output of that file,
>> similarly the way it's done in gcc -E.

lets say you have a module named shiyao.c the makefile will look similar
to:

-----------------------------------------------------------------------------
obj-m += shiyao.o

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD       := $(shell pwd)

all:
    $(MAKE) -C $(KERNELDIR) M=$(PWD)

clean:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
-----------------------------------------------------------------------------

change the target all to:

all:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) *shiyao.i*

run make as usual then open shiyao.i in vi(m) or your preferred editor -
done !

Thank's - Aruna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20151102/de16c4fb/attachment.html 


More information about the Kernelnewbies mailing list