[PATCH 1/2] Makefile: Create empty <config.h> if this header file is not needed by board

Sascha Hauer s.hauer at pengutronix.de
Fri Apr 5 06:18:04 EDT 2013


On Fri, Apr 05, 2013 at 02:07:23PM +0400, Alexander Shiyan wrote:
> > > > On Mon, Mar 11, 2013 at 08:10:49PM +0400, Alexander Shiyan wrote:
> > > > > Patch creates empty <config.h> if this header is not needed by board.
> > > > > This will allow to remove many empty config.h files from boards.
> > > > > 
> > > > > Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
> > > > > ---
> > > > >  Makefile | 17 +++++++++++------
> > > > >  1 file changed, 11 insertions(+), 6 deletions(-)
> > > > > 
> > > > > diff --git a/Makefile b/Makefile
> > > > > index b5819fc..e8d9984 100644
> > > > > --- a/Makefile
> > > > > +++ b/Makefile
> > > > > @@ -898,13 +898,18 @@ include/asm:
> > > > >  	$(Q)$(check-symlink)
> > > > >  	$(Q)$(create-symlink)
> > > > >  
> > > > > +define symlink-config-h
> > > > > +	if [ -f $(srctree)/$(BOARD)/config.h ]; then		\
> > > > > +		$(kecho) '  SYMLINK $@ -> $(BOARD)/config.h';	\
> > > > > +		ln -fsn $(srctree)/$(BOARD)/config.h $@;	\
> > > > > +	else							\
> > > > > +		$(kecho) '  CREATE  $@';			\
> > > > > +		echo -n > $@;					\
> > > > > +	fi
> > > > > +endef
> > > > 
> > > > I dropped this patch because it autogenerates files which were
> > > > previously part of the repository. This causes git checkout to
> > > > complain about overwriting existing files when we want to checkout
> > > > earlier versions.
> > > 
> > > Patch creates include/config.h (which is in .gitignore) only
> > > or makes symlink to board/config.h. So all already as you say below.
> > 
> > It creates a arch/$arch/$board/config.h, so we get the following:
> Can you point it in the code?
> 
> > 
> > # git checkout for-next/remove-config-h
> > ...
> > # make pcm038_defconfig && make
> > ...
> > # git checkout master
> > error: The following untracked working tree files would be overwritten by checkout:
> >         arch/arm/boards/pcm038/config.h
> > Please move or remove them before you can switch branches.
> > Aborting
> > 
> > So this patch forces us to manually remove arch/$arch/$board/config.h
> > or to use git checkout -f
> 
> I am do not understand a problem. For me it works OK.
> 
> shc at shc /home/git/bb-test-cfg $ ls arch/arm/boards/pcm038/
> env  lowlevel.c  Makefile  pcm038.c  pcm038.dox  pcm970.c  pll.h
> 
> shc at shc /home/git/bb-test-cfg $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- pcm038_defconfig
>   HOSTCC  scripts/basic/fixdep
>   HOSTCC  scripts/basic/docproc
>   HOSTCC  scripts/kconfig/conf.o
>   SHIPPED scripts/kconfig/zconf.tab.c
>   SHIPPED scripts/kconfig/zconf.lex.c
>   SHIPPED scripts/kconfig/zconf.hash.c
>   HOSTCC  scripts/kconfig/zconf.tab.o
> scripts/kconfig/zconf.tab.c: В функции «header_print_comment»:
> scripts/kconfig/confdata.c:540:10: предупреждение: ignoring return value of «fwrite», declared with attribute warn_unused_result [-Wunused-result]
> scripts/kconfig/zconf.tab.c: В функции «kconfig_print_comment»:
> scripts/kconfig/confdata.c:467:10: предупреждение: ignoring return value of «fwrite», declared with attribute warn_unused_result [-Wunused-result]
>   HOSTLD  scripts/kconfig/conf
> #
> # configuration written to .config
> #
> 
> shc at shc /home/git/bb-test-cfg $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
> scripts/kconfig/conf --silentoldconfig Kconfig
>   Generating include/generated/mach-types.h
>   CHK     include/generated/version.h
>   UPD     include/generated/version.h
>   CHK     include/generated/utsrelease.h
>   UPD     include/generated/utsrelease.h
>   SYMLINK include/asm -> include/asm-arm
>   CREATE  include/config.h
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   LD      scripts/built-in.o
>   CC      scripts/mod/empty.o
>   HOSTCC  scripts/mod/mk_elfconfig
>   MKELF   scripts/mod/elfconfig.h
>   HOSTCC  scripts/mod/modpost.o
> ^Cmake[2]: *** [scripts/mod/modpost.o] Прерывание
> make[1]: *** [scripts/mod] Прерывание
> make: *** [scripts] Прерывание
> 
> shc at shc /home/git/bb-test-cfg $ ls arch/arm/boards/pcm038/
> env  lowlevel.c  Makefile  pcm038.c  pcm038.dox  pcm970.c  pll.h
> 
> shc at shc /home/git/bb-test-cfg $ git commit -a
> # On branch cfg
> nothing to commit, working directory clean
> 
> ...
> So, no board/config.h. Just a empty include/config.h.
> 
> ... Not understand a problem.

Ah, I understand now ;)

The problem here is that include/config.h previously existed as a link.
Your patch does a 'echo > include/config.h'. When this is a link then it
will empty the file the link points to instead of creating an empty
include/config.h.

So, to run into it you have to:

# git checkout master
# make pcm038_defconfig && make
# git checkout for-next/for-next/remove-config-h
# make
# git checkout master

The solution to this seems to be to remove include/config.h before
echoing into it.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list