Linux Kernel Makefiles

This is a discussion on Linux Kernel Makefiles within the Linux Programming forums, part of the Platform Specific Boards category; I want to distribute my make environment into several sub-dirs. These are modules to the kernel, but all the sub-dirs ...

  1. #1
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065

    Linux Kernel Makefiles

    I want to distribute my make environment into several sub-dirs. These are modules to the kernel, but all the sub-dirs will be out-of-stream builds. I was attempting to mimic the way the Linux kernel build works, but something is seriously missing from these files. The main directory make file looks something like this:
    Code:
    ifeq ($(KERNELRELEASE), )
    KERNELDIR       ?= ../../../kernel/linux-2.6.24.5/linux-2.6.24.5
    ARCH            ?= arm
    CROSS_COMPILE   ?= arm-unknown-linux-gnueabi-
    PWD             := $(shell pwd)
    
    modules:
            $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
    
    else
    
    EXTRA_CFLAGS    += -I$(PWD)/include
    obj-y           += common/
    obj-y           += convert/
    obj-y           += drivers/
    
    endif
    One of the sub-dir Makefiles looks like this:
    Code:
    obj-y   += safe_inc.o
    obj-y   += callback.o safe_inc.o
    So, what am I doing wrong? Any ideas?

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Doh!!! I think I found it. I may need more work, but here is the bottom line:

    All the obj-y stuff, should be replaced with obj-m (Modules, man, Modules!!!!).

    I'll post more if I find more corrections.

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Code:
    ifeq ($(KERNELRELEASE), )
    KERNELDIR         ?= <path to kernel>
    ARCH              ?= <if you are using a different arch>
    CROSS_COMPILE     ?= <your cross compiler>
    PWD               := $(shell pwd)
    
    modules:
            @$(MAKE) MYPWD=$(PWD) -C $(KERNELDIR) M=$(PWD) modules
    
    clean:
            @rm -r *.o */*.o *.ko *.mod.c .*cmd */.*cmd .tmp_versions Module.symvers
    
    else
    EXTRA_CFLAGS      := -I$(MYPWD)/include
    
    obj-m             += mydriver.o
    mydriver-y        := drivers/mydriver.o
    mydriver-y        += common/some.o
    
    obj-m                   += mydriver2.o
    mydriver2-y       := drivers/mydriver2.o
    mydriver2-y       += common/callback.o
    mydriver2-y       += convert/mydriver2.o
    mydriver2-y       += common/mymemory.o
    mydriver2-y       += common/some.o
    
    #etc. . .
    
    endif

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. priorities in Linux kernel??
    By micke_b in forum Linux Programming
    Replies: 0
    Last Post: 02-22-2008, 08:10 AM
  2. OpenGL on Linux - Kernel Panic
    By psychopath in forum Game Programming
    Replies: 2
    Last Post: 04-15-2006, 05:07 PM
  3. Compiling Linux kernel on Windows
    By jmd15 in forum Linux Programming
    Replies: 9
    Last Post: 04-10-2006, 08:28 AM
  4. Linux kernel not compiling
    By frenchfry164 in forum Tech Board
    Replies: 2
    Last Post: 04-29-2003, 05:10 PM
  5. linux kernel 2.5
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-01-2002, 12:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21