build: improve ccache support
[openwrt/staging/hauke.git] / include / toplevel.mk
index 133da9d830b5534ca39cc863b5be487252c635fb..0a64afe153c002210cc812aa0db8de7953cb4a38 100644 (file)
@@ -99,20 +99,22 @@ prepare-tmpinfo: FORCE
                $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
        fi
 
-scripts/config/mconf:
-       @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all CC="$(HOSTCC_WRAPPER)"
+ifeq ($(RECURSIVE_DEP_IS_ERROR),1)
+  KCONF_FLAGS=--fatalrecursive
+endif
+ifneq ($(DISTRO_PKG_CONFIG),)
+scripts/config/%onf: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
+endif
+scripts/config/%onf: CFLAGS+= -O2
+scripts/config/%onf:
+       @$(_SINGLE)$(SUBMAKE) $(if $(findstring s,$(OPENWRT_VERBOSE)),,-s) \
+               -C scripts/config $(notdir $@) CC="$(HOSTCC_WRAPPER)"
 
 $(eval $(call rdep,scripts/config,scripts/config/mconf))
 
-scripts/config/qconf:
-       @$(_SINGLE)$(SUBMAKE) -s -C scripts/config qconf CC="$(HOSTCC_WRAPPER)"
-
-scripts/config/conf:
-       @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC_WRAPPER)"
-
 config: scripts/config/conf prepare-tmpinfo FORCE
        [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
-               $< Config.in
+               $< $(KCONF_FLAGS) Config.in
 
 config-clean: FORCE
        $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
@@ -121,7 +123,7 @@ defconfig: scripts/config/conf prepare-tmpinfo FORCE
        touch .config
        @if [ ! -s .config -a -e $(HOME)/.openwrt/defconfig ]; then cp $(HOME)/.openwrt/defconfig .config; fi
        [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
-               $< --defconfig=.config Config.in
+               $< $(KCONF_FLAGS) --defconfig=.config Config.in
 
 confdefault-y=allyes
 confdefault-m=allmod
@@ -130,7 +132,7 @@ confdefault:=$(confdefault-$(CONFDEFAULT))
 
 oldconfig: scripts/config/conf prepare-tmpinfo FORCE
        [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
-               $< --$(if $(confdefault),$(confdefault),old)config Config.in
+               $< $(KCONF_FLAGS) --$(if $(confdefault),$(confdefault),old)config Config.in
 
 menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
        if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
@@ -139,6 +141,13 @@ menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
        [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
                $< Config.in
 
+nconfig: scripts/config/nconf prepare-tmpinfo FORCE
+       if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
+               cp $(HOME)/.openwrt/defconfig .config; \
+       fi
+       [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
+               $< Config.in
+
 xconfig: scripts/config/qconf prepare-tmpinfo FORCE
        if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
                cp $(HOME)/.openwrt/defconfig .config; \
@@ -157,12 +166,20 @@ endif
 kernel_oldconfig: prepare_kernel_conf
        $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
 
+ifneq ($(DISTRO_PKG_CONFIG),)
+kernel_menuconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
+kernel_nconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
+kernel_xconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
+endif
 kernel_menuconfig: prepare_kernel_conf
        $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
 
 kernel_nconfig: prepare_kernel_conf
        $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
 
+kernel_xconfig: prepare_kernel_conf
+       $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux xconfig
+
 staging_dir/host/.prereq-build: include/prereq-build.mk
        mkdir -p tmp
        @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
@@ -207,7 +224,7 @@ ifeq ($(SDK),1)
 
 %::
        @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
-       @./scripts/config/conf --defconfig=.config Config.in
+       @./scripts/config/conf $(KCONF_FLAGS) --defconfig=.config Config.in
        @+$(ULIMIT_FIX) $(SUBMAKE) -r $@
 
 else
@@ -216,7 +233,7 @@ else
        @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
        @( \
                cp .config tmp/.config; \
-               ./scripts/config/conf --defconfig=tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \
+               ./scripts/config/conf $(KCONF_FLAGS) --defconfig=tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \
                if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q CONFIG; then \
                        printf "$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
                fi \
@@ -245,7 +262,7 @@ package/symlinks-clean:
 help:
        cat README
 
-distclean:
+distclean: cacheclean
        rm -rf bin build_dir .config* dl feeds key-build* logs package/feeds package/openwrt-packages staging_dir tmp
        @$(_SINGLE)$(SUBMAKE) -C scripts/config clean