Let generate_testapi.py
be a script in my Linux kernel module's source tree, that ingests mymod_test.h
and generates a interface source file toward userland (ioctl, debugfs, you name it), and lets name this $(obj)/mymod_test_interfaces.gen.c
.
In the Kbuild makefile let mymod-y
be the variable containing the list of object files that form the module, i.e.
How does a Kbuild-ish rule look like, that adds the object file compiles from the generates source as a dependency of mymod and describes the generation process.
The following, my first naive attempt on such a rule set does not work.
obj-m := mymod.o
mymod-y := \
mymod_kmod.o \
$(obj)/mymod_test_interfaces.gen.o
$(obj)/mymod_test_interfaces.gen.o: $(src)/mymod_test.h $(src)/generate_testapi.py
$(src)/generate_testapi.py < $(src)/mymod_test.h > $<
Trying to make
with that, the resulting error is, that there is no rule to make mymod_test_interfaces.gen.o
.
Update (due to comment by Alexandre Belloni)
Yes, I also tried a generator rule of the form
$(obj)/mymod_test_interfaces.gen.c: $(src)/mymod_test.h $(src)/generate_testapi.py
$(src)/generate_testapi.py < $(src)/mymod_test.h > $<
with the same result, which is, that it does not work.