Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [SOLVED] Makefile for module in and out of Kconfig/Kbuild system

    What I want to do is be able to build a module both inside and outside of the kernel build system.

    • Inside=at the top level of the Linux sources do: make menuconfig, make etc
    • Outside=just go into a working directory with the module source in and type 'make'

    In my Kbuild I have:

    obj-$(CONFIG_THING) := thing.o
    thing-y := thing_1.o \

    This works when I build within the kernel build system (make menuconfig, make etc...)
    when I set CONFIG_THING to m via the Kconfig system I get a thing.ko built.
    when I set CONFIG_THING to y via the Kconfig system I get thing support built into the kernel.

    I thought that a Makefile similar to that below would help, but obviously CONFIG_THING does not
    get set correctly.

    ifneq ($(KERNELRELEASE),)
    include Kbuild
    # Normal Makefile
    KERNELDIR := /lib/modules/`uname -r`/build
    $(MAKE) -C $(KERNELDIR) M=`pwd` $@

    # Module clean up
    $(MAKE) -C $(KERNELDIR) M=`pwd` clean


    Is there any way I can force CONFIG_THING to be 'm' in order to reuse the Kbuild file?

  2. #2

    Thumbs up


    In my Makefile I added 'CONFIG_THING=m' to the make call, thus:

    $(MAKE) -C $(KERNELDIR) M=`pwd` $@ CONFIG_THING=m

    I'm pretty sure that does what I want.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts