-STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared$(if $(DUMP),,_$(shell find ${CURDIR} $(PKG_FILE_DEPEND) $(DEP_FINDPARAMS) | md5s))
-STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
-STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
-export CONFIG_SITE:=$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)
+override MAKEFLAGS=
+CONFIG_SITE:=$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)
+ifneq ($(CONFIG_LINUX_2_4),)
+ CONFIG_SITE:=$(subst linux-,linux2.4-,$(CONFIG_SITE))
+endif
+CUR_MAKEFILE:=$(filter-out Makefile,$(firstword $(MAKEFILE_LIST)))
+SUBMAKE:=$(NO_TRACE_MAKE) $(if $(CUR_MAKEFILE),-f $(CUR_MAKEFILE))
+
+ifeq ($(DUMP)$(filter prereq clean refresh update,$(MAKECMDGOALS)),)
+ ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
+ define Build/Autoclean
+ $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
+ $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(STAMP_PREPARED),$(PKG_BUILD_DIR)/.dep_files,-x "*/.dep_*")
+ $(if $(filter prepare,$(MAKECMDGOALS)),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),,-x "*/.dep_*" -x "*/ipkg*"))
+ endef
+ endif
+endif