Search code examples
androidkernelgnu-makedevice-driverkbuild

How do I build just the directory containing my updated source code


I successfully created an image for Samsung Note 3 by downloading the source from Samsung and AOSP and running make as instructed in the README file. But now I want to modify a device driver, and see the result in the image. This means I really do not want to recreate an entire image; rather just the modified file, which is /drivers/char/examples directory. I have tried "m", "mm", and "mmm" but I get the following error:

sansari@ubuntu:~/WORKING_DIRECTORY$ m
m: command not found
sansari@ubuntu:~/WORKING_DIRECTORY$ mm
The program 'mm' is currently not installed. You can install it by typing:
sudo apt-get install multimail

I have also tried to run make from the example directory and I get:

sansari@ubuntu:~/WORKING_DIRECTORY/drivers/char/examples$ make 
make --directory=src
make: *** src: No such file or directory.  Stop.
make: *** [src] Error 2

Here is what I have in this directory as well as the make file:

sansari@ubuntu:~/WORKING_DIRECTORY/drivers/char/examples$ ls
backup  examples.c  hello1.c  Makefile
sansari@ubuntu:~/WORKING_DIRECTORY/drivers/char/examples$ more Makefile 
lib_src := src 
lib_headers := headers 
.PHONY: all $(lib_src) $(lib_headers)
$(lib_src) :
    $(MAKE) --directory=$@
    $(lib_*): $(MAKE) --directory=$@

obj-$(CONFIG_TOS)   += examples.o

What should I do so that when I update the c source file, I can build an updated image to flash my phone and try to see the result?

I wonder if I remove the examples.ko, make will rebuild again. The question is would this work if I issue make just for the /examples directory?

Thanks, Sean


Solution

  • There's a lot that is wrong here, so it is impossible to figure out what is supposed to happen. I'll just describe what's going on.

    sansari@ubuntu:~/WORKING_DIRECTORY/drivers/char/examples$ make 
    make --directory=src
    make: *** src: No such file or directory.  Stop.
    make: *** [src] Error 2
    

    means that the Makefile is expecting a directory called src to exist under the place where you run make. That directory should have a file called Makefile in it which will give further instructions for how to compile examples.c and hello1.c.

    Let's say the src directory is under ~/WORKING_DIRECTORY. In that case you would invoke make via make -f drivers/char/examples.

    However I'm guessing that in that directory or one of the others, you should see the programs m or mm that I guess you were instructed to run. And I'm also guessing that this is what will issue that more unusual make command.