diff --git a/openwrt/Makefile b/openwrt/Makefile
index e2e467cd8c22b58274ea01715f049a623803a7a7..a23f478d7cec63b317103f1da84264761a1f4467 100644
--- a/openwrt/Makefile
+++ b/openwrt/Makefile
@@ -31,14 +31,17 @@ export OPENWRTVERSION
 
 all: world
 
-.pkginfo: FORCE
 ifneq ($(shell ./scripts/timestamp.pl -p .pkginfo package Makefile),.pkginfo)
+.pkginfo: FORCE
+.config: FORCE
+endif
+
+.pkginfo:
 	@echo Collecting package info...
 	@-for dir in package/*/; do \
 		echo Source-Makefile: $${dir}Makefile; \
 		$(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $$dir 2>&- || true; \
 	done > $@
-endif
 
 .config.in: .pkginfo
 	@./scripts/gen_menuconfig.pl < $< > $@ || rm -f $@
@@ -77,18 +80,25 @@ target/%: .pkginfo FORCE
 toolchain/%: FORCE
 	$(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
 
-.config: ./scripts/config/conf FORCE
+.config: ./scripts/config/conf
 	@[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
 	@$< -D .config Config.in &> /dev/null
 
-.prereq: $(TOPDIR)/include/prereq.mk .pkginfo
-	@$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq.mk prereq 2>/dev/null || { \
+.prereq-build: $(TOPDIR)/include/prereq-build.mk
+	@$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
 		echo "Prerequisite check failed. Use FORCE=1 to override."; \
 		false; \
 	}
 	@touch $@
 
-prereq: .prereq FORCE
+.prereq-packages: $(TOPDIR)/include/prereq.mk .pkginfo .config
+	@$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
+		echo "Prerequisite check failed. Use FORCE=1 to override."; \
+		false; \
+	}
+	@touch $@
+	
+prereq: .prereq-build .prereq-packages FORCE
 
 download: .config FORCE
 	$(MAKE) toolchain/download
@@ -96,7 +106,8 @@ download: .config FORCE
 	$(MAKE) target/download
 
 ifeq ($(FORCE),)
-world: .prereq
+.config ./scripts/config/conf ./scripts/config/mconf: .prereq-build
+world: .prereq-packages
 endif
 
 world: .config FORCE
diff --git a/openwrt/include/package.mk b/openwrt/include/package.mk
index e0765f7baba31a2ee26a53a7abb6636c15b9cae9..cd1a33c484874a8f271dea4a9f356bf706ce68b3 100644
--- a/openwrt/include/package.mk
+++ b/openwrt/include/package.mk
@@ -10,6 +10,8 @@ else
   all: compile
 endif
 
+include $(INCLUDE_DIR)/prereq.mk
+
 define Build/DefaultTargets
   ifeq ($(DUMP),)
     ifeq ($(CONFIG_AUTOREBUILD),y)
diff --git a/openwrt/include/prereq-build.mk b/openwrt/include/prereq-build.mk
new file mode 100644
index 0000000000000000000000000000000000000000..a6de9b270aa74d784e70071055cdd1ae10c0d517
--- /dev/null
+++ b/openwrt/include/prereq-build.mk
@@ -0,0 +1,88 @@
+# 
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/prereq.mk
+
+# Required for the toolchain
+define Require/working-make
+	echo 'all: test' > $(TMP_DIR)/check.mk
+	echo 'e0 = $$$$(foreach s,foobar,$$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
+	echo 'e1 = $$$$(foreach s,foobar, $$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
+	echo 'test: $$$$(strip $$$$(e0)) $$$$(strip $$$$(e1))' >> $(TMP_DIR)/check.mk
+	$(NO_TRACE_MAKE) -f $(TMP_DIR)/check.mk
+endef
+
+$(eval $(call Require,working-make, \
+	Your make version is buggy. Please install GNU make v3.81 or later. \
+))
+
+define Require/working-gcc
+	echo 'int main(int argc, char **argv) { return 0; }' | \
+		gcc -x c -o $(TMP_DIR)/a.out -
+endef
+
+$(eval $(call Require,working-gcc, \
+	No working GNU C Compiler (gcc) was found on your system. \
+))
+
+define Require/working-g++
+	echo 'int main(int argc, char **argv) { return 0; }' | \
+		g++ -x c++ -o $(TMP_DIR)/a.out -lstdc++ -
+endef
+
+$(eval $(call Require,working-g++, \
+	No working GNU C++ Compiler (g++) was found on your system. \
+))
+
+define Require/ncurses
+	echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
+		gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out -lncurses -
+endef
+
+$(eval $(call Require,ncurses, \
+	No ncurses development files were not found on your system. \
+))
+
+
+define Require/zlib
+	echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
+		gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -lz -
+endef
+
+$(eval $(call Require,zlib, \
+	No zlib development files were not found on your system. \
+))
+
+
+$(eval $(call RequireCommand,bison, \
+	Please install GNU bison. \
+))
+
+$(eval $(call RequireCommand,flex, \
+	Please install flex. \
+))
+
+$(eval $(call RequireCommand,python, \
+	Please install python. \
+))
+
+$(eval $(call RequireCommand,unzip, \
+	Please install unzip. \
+))
+
+$(eval $(call RequireCommand,bzip2, \
+	Please install bzip2. \
+))
+
+$(eval $(call RequireCommand,patch, \
+	Please install patch. \
+))
+
+$(eval $(call RequireCommand,perl, \
+	Please install perl. \
+))
diff --git a/openwrt/include/prereq.mk b/openwrt/include/prereq.mk
index e514855a67fdf3177a583270a22f97934097dce8..c9b82d29477f1da3f4fedd678741fe5da7e750f9 100644
--- a/openwrt/include/prereq.mk
+++ b/openwrt/include/prereq.mk
@@ -5,14 +5,12 @@
 # See /LICENSE for more information.
 #
 
-include $(TOPDIR)/rules.mk
-
 $(TMP_DIR):
 	mkdir -p $@
 
 prereq:
-	echo
 	if [ -f $(TMP_DIR)/.prereq-error ]; then \
+		echo; \
 		cat $(TMP_DIR)/.prereq-error; \
 		echo; \
 		rm -rf $(TMP_DIR); \
@@ -29,7 +27,7 @@ define Require
 
     prereq-$(1): $(TMP_DIR) FORCE
 		echo -n "Checking '$(1)'... "
-		if $(NO_TRACE_MAKE) -f $(INCLUDE_DIR)/prereq.mk check-$(1) >/dev/null 2>/dev/null; then \
+		if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
 			echo 'ok.'; \
 		else \
 			echo 'failed.'; \
@@ -53,81 +51,3 @@ define RequireCommand
   $$(eval $$(call Require,$(1),$(2)))
 endef
 
-# Required for the toolchain
-define Require/working-make
-	echo 'all: test' > $(TMP_DIR)/check.mk
-	echo 'e0 = $$$$(foreach s,foobar,$$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
-	echo 'e1 = $$$$(foreach s,foobar, $$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
-	echo 'test: $$$$(strip $$$$(e0)) $$$$(strip $$$$(e1))' >> $(TMP_DIR)/check.mk
-	$(NO_TRACE_MAKE) -f $(TMP_DIR)/check.mk
-endef
-
-$(eval $(call Require,working-make, \
-	Your make version is buggy. Please install GNU make v3.81 or later. \
-))
-
-define Require/working-gcc
-	echo 'int main(int argc, char **argv) { return 0; }' | \
-		gcc -x c -o $(TMP_DIR)/a.out -
-endef
-
-$(eval $(call Require,working-gcc, \
-	No working GNU C Compiler (gcc) was found on your system. \
-))
-
-define Require/working-g++
-	echo 'int main(int argc, char **argv) { return 0; }' | \
-		g++ -x c++ -o $(TMP_DIR)/a.out -lstdc++ -
-endef
-
-$(eval $(call Require,working-g++, \
-	No working GNU C++ Compiler (g++) was found on your system. \
-))
-
-define Require/ncurses
-	echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
-		gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out -lncurses -
-endef
-
-$(eval $(call Require,ncurses, \
-	No ncurses development files were not found on your system. \
-))
-
-
-define Require/zlib
-	echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
-		gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -lz -
-endef
-
-$(eval $(call Require,zlib, \
-	No zlib development files were not found on your system. \
-))
-
-
-$(eval $(call RequireCommand,bison, \
-	Please install GNU bison. \
-))
-
-$(eval $(call RequireCommand,flex, \
-	Please install flex. \
-))
-
-$(eval $(call RequireCommand,python, \
-	Please install python. \
-))
-
-$(eval $(call RequireCommand,unzip, \
-	Please install unzip. \
-))
-
-$(eval $(call RequireCommand,bzip2, \
-	Please install bzip2. \
-))
-
-$(eval $(call RequireCommand,patch, \
-	Please install patch. \
-))
-
-$(eval $(call RequireCommand,perl, \
-	Please install perl. \
-))
diff --git a/openwrt/package/Makefile b/openwrt/package/Makefile
index 7a3af2e6f78dea0ce0e272499fb63c26a4a244bc..629ce88109924dd3e1a77ebb0e0b6af0680df4cc 100644
--- a/openwrt/package/Makefile
+++ b/openwrt/package/Makefile
@@ -10,13 +10,17 @@ include $(TOPDIR)/rules.mk
 include $(TOPDIR)/.config
 include $(TOPDIR)/.pkgdeps
 
-SOURCE_PACKAGES:=$(patsubst %,%-download,$(package-y) $(package-m))
+PREREQ_PACKAGES:=$(patsubst %,%-prereq,$(package-y) $(package-m))
+DOWNLOAD_PACKAGES:=$(patsubst %,%-download,$(package-y) $(package-m))
 COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m))
 INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y))
 
 $(STAMP_DIR) $(TARGET_DIR):
 	mkdir -p $@
 
+%-prereq: $(STAMP_DIR) $(TARGET_DIR)
+	$(MAKE) -C $(patsubst %-prereq,%,$@) prereq MAKEFLAGS="$(BUILD_MAKEFLAGS)"
+
 %-download: $(STAMP_DIR) $(TARGET_DIR)
 	$(MAKE) -C $(patsubst %-download,%,$@) download MAKEFLAGS="$(BUILD_MAKEFLAGS)"
 
@@ -41,7 +45,8 @@ $(TOPDIR)/.pkgdeps: $(TOPDIR)/.pkginfo
 
 all: compile
 clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m))
-download: $(SOURCE_PACKAGES)
+prereq: $(PREREQ_PACKAGES)
+download: $(DOWNLOAD_PACKAGES)
 compile-targets: $(COMPILE_PACKAGES)
 compile:
 	$(MAKE) -j$(CONFIG_JLEVEL) compile-targets
diff --git a/openwrt/package/base-files/Makefile b/openwrt/package/base-files/Makefile
index 01ea9674c52c93844a3d6736a87d8df5da13ee4d..e41e1fd7987af8fb00ab9eabc9ff12452cee3ea7 100644
--- a/openwrt/package/base-files/Makefile
+++ b/openwrt/package/base-files/Makefile
@@ -22,8 +22,8 @@ include $(INCLUDE_DIR)/package.mk
 
 ifneq ($(DUMP),1)
 TARGET:=-$(BOARD)-$(KERNEL)
-UCLIBC_VERSION:=${shell cat $(STAGING_DIR)/uclibc_version}
-LIBGCC_VERSION:=${shell cat $(STAGING_DIR)/gcc_version}
+UCLIBC_VERSION:=${shell cat $(STAGING_DIR)/uclibc_version 2>/dev/null}
+LIBGCC_VERSION:=${shell cat $(STAGING_DIR)/gcc_version 2>/dev/null}
 else
 UCLIBC_VERSION:=<UCLIBC_VERSION>
 LIBGCC_VERSION:=<LIBGCC_VERSION>