]> rtime.felk.cvut.cz Git - linux-imx.git/commit
kbuild: create directory for dir/file.o
author张忠山 <zzs0213@gmail.com>
Sun, 30 Jun 2013 09:09:28 +0000 (17:09 +0800)
committerMichal Marek <mmarek@suse.cz>
Wed, 3 Jul 2013 20:47:08 +0000 (22:47 +0200)
commit4d47dde47f7dd95042fa56283d948f50dd4b509c
treef64f3c9a842894e6ca208f311ecfe5d4d101bdf8
parentb35310627f396efcc25d71fb343b3aa02039d20d
kbuild: create directory for dir/file.o

When add a obj with dir to obj-y, like this

    obj-y += dir/file.o

The $(obj)/dir not created, this patch fix this.

When try to add a file(which in a subdir) to my board's obj-y, the build
progress crashed.

For example, I use at91rm9200ek board, and in kernel dir run:

  mkdir objtree
  make O=objtree at91rm9200_defconfig
  mkdir arch/arm/mach-at91/dir
  touch arch/arm/mach-at91/dir/file.c

and edit arch/arm/mach-at91/dir/file.c to add some code.
then edit arch/arm/mach-at91/Makefile, change the following line:

  obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o

to:

  obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o dir/file.o

Now build it:

  make O=objtree

Then the error appears:
  ...
  CC      arch/arm/mach-at91/board-rm9200dk.o
  CC      arch/arm/mach-at91/board-rm9200ek.o
  CC      arch/arm/mach-at91/dir/file.o
  linux-2.6/arch/arm/mach-at91/dir/file.c:5:
    fatal error: opening dependency file
    arch/arm/mach-at91/dir/.file.o.d: No such file or directory

Check the objtree:
  LANG=en ls objtree/arch/arm/mach-at91/dir
  ls: cannot access objtree/arch/arm/mach-at91/dir: No such file or directory

It's apparently that the target dir not created for file.o

Check kbuild source code. It seems that kbuild create dirs for that in
$(obj-dirs).  But if the dir need not to create a built-in.o, It should
never in  $(obj-dirs).

So I make this patch to make sure It in  $(obj-dirs)

this bug caused by commit
   f5fb976520a53f45f8bbf2e851f16b3b5558d485

Signed-off-by: 张忠山 <zzs0213@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/Makefile.lib