samples: add rule to dump current .config into a defconfig
author"Yann E. MORIN" <yann.morin.1998@free.fr>
Wed Aug 15 22:06:22 2012 +0200 (2012-08-15)
changeset 303411c23aa9c9f9
parent 3033 9ddca166bb27
child 3035 cb75966698d7
samples: add rule to dump current .config into a defconfig

... and one to restore it, of course.

Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
ct-ng.comp
docs/ct-ng.1.in
kconfig/kconfig.mk
     1.1 --- a/ct-ng.comp	Sun Aug 05 00:33:27 2012 +1000
     1.2 +++ b/ct-ng.comp	Wed Aug 15 22:06:22 2012 +0200
     1.3 @@ -15,13 +15,14 @@
     1.4      stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;')
     1.5  
     1.6      actions='help menuconfig oldconfig saveconfig extractconfig
     1.7 +             defconfig olddefconfig
     1.8               build build. build-all build-all.
     1.9               wiki-samples list-samples list-samples-short list-steps
    1.10               show-tuple show-all show-config
    1.11               clean distclean updatetools
    1.12               tarball version'
    1.13  
    1.14 -    vars="RESTART= STOP= PREFIX= V="
    1.15 +    vars="RESTART= STOP= PREFIX= V= DEFCONFIG="
    1.16  
    1.17      ct_ng_opts="${samples} ${show_samples} ${build_samples}
    1.18                  ${steps} ${start_steps} ${stop_steps}
     2.1 --- a/docs/ct-ng.1.in	Sun Aug 05 00:33:27 2012 +1000
     2.2 +++ b/docs/ct-ng.1.in	Wed Aug 15 22:06:22 2012 +0200
     2.3 @@ -60,6 +60,47 @@
     2.4  with the target tuple they represent.
     2.5  ."
     2.6  .TP
     2.7 +.B defconfig
     2.8 +Save the current configuration to a mini-defconfig file, that contains only
     2.9 +the strictly required symbols to reproduce the configuraiton. defconfig files
    2.10 +are much smaller than a complete .config, so it is easy to send by mail. As
    2.11 +only non-default symbols are present in a defconfig, it easy to spot the
    2.12 +meaningfull values. Also, it is easy to use defconfig files with newer
    2.13 +versions of
    2.14 +.BR crosstool-NG .
    2.15 +By default the mini-defconfig is saved to a file named
    2.16 +.IR defconfig ,
    2.17 +unless the variable
    2.18 +.B $DEFCONFIG
    2.19 +is set, in which case the mini-defconfig will be saved to the file referenced
    2.20 +by
    2.21 +.BR $DEFCONFIG .
    2.22 +
    2.23 +Note: only the
    2.24 +.I .config
    2.25 +file for
    2.26 +.B crosstool-NG
    2.27 +is saved. Config files for the components are
    2.28 +.B not
    2.29 +saved. Use
    2.30 +.B saveconfig
    2.31 +for that
    2.32 +."
    2.33 +.TP
    2.34 +.B olddefconfig
    2.35 +Configure
    2.36 +.B crosstool-NG
    2.37 +using a mini-defconfig file (previously saved with
    2.38 +.B defconfig
    2.39 +or manually edited). The default mini-defconfig is rad from the file
    2.40 +.IR defconfig ,
    2.41 +unless the vraiable
    2.42 +.B $DEFCONFIG
    2.43 +is set, inwhich case the mini-defconfig will be read from the file referenced
    2.44 +by
    2.45 +.B $DEFCONFIG
    2.46 +."
    2.47 +.TP
    2.48  .B build
    2.49  Builds the configured toolchain.
    2.50  ."
     3.1 --- a/kconfig/kconfig.mk	Sun Aug 05 00:33:27 2012 +1000
     3.2 +++ b/kconfig/kconfig.mk	Wed Aug 15 22:06:22 2012 +0200
     3.3 @@ -5,7 +5,7 @@
     3.4  #-----------------------------------------------------------
     3.5  # The configurators rules
     3.6  
     3.7 -configurators = menuconfig nconfig oldconfig
     3.8 +configurators = menuconfig nconfig oldconfig defconfig olddefconfig
     3.9  PHONY += $(configurators)
    3.10  
    3.11  $(configurators): config_files
    3.12 @@ -27,6 +27,14 @@
    3.13  	@$(ECHO) "  CONF  $(KCONFIG_TOP)"
    3.14  	$(SILENT)$(CONF) --silent$@ $(KCONFIG_TOP)
    3.15  
    3.16 +defconfig: .config
    3.17 +	@$(ECHO) '  GEN   $@'
    3.18 +	$(SILENT)$(CONF) --savedefconfig=$${CONFIG-defconfig} $(KCONFIG_TOP)
    3.19 +
    3.20 +olddefconfig:
    3.21 +	@$(ECHO) '  CONF  $@'
    3.22 +	$(SILENT)$(CONF) --defconfig=$${CONFIG-defconfig} $(KCONFIG_TOP)
    3.23 +
    3.24  # Always be silent, the stdout an be >.config
    3.25  extractconfig:
    3.26  	@$(awk) 'BEGIN { dump=0; }                                                  \
    3.27 @@ -50,3 +58,6 @@
    3.28  	@echo  '  oldconfig          - Update current config using a provided .config as base'
    3.29  	@echo  '  extractconfig      - Extract to stdout the configuration items from a'
    3.30  	@echo  '                       build.log file piped to stdin'
    3.31 +	@echo  '  defconfig          - Save current config as a mini-defconfig to $${CONFIG}'
    3.32 +	@echo  '  olddefconfig       - Update config from a mini-defconfig $${CONFIG}'
    3.33 +	@echo  '                       (default: $${CONFIG}=./defconfig)'