diff --git a/Makefile b/Makefile
index 6b1522d61e6c963e95beb10cf2c816cefbe06189..300a1fb13b61e0f9db5311465a2bf011f66f9839 100644
--- a/Makefile
+++ b/Makefile
@@ -900,6 +900,6 @@ mxml/libmxml.a:
 
 makeopts.xml: $(foreach dir,$(MOD_SUBDIRS),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml
 	@echo "Generating list of available modules ..."
-	@build_tools/prep_moduledeps 2>/dev/null > $@
+	@build_tools/prep_moduledeps > $@
 
 .PHONY: menuselect sounds clean clean-depend dist-clean distclean all _all depend cleantest uninstall _uninstall uninstall-all dont-optimize valgrind $(SUBDIRS_INSTALL) $(SUBDIRS_CLEAN) $(SUBDIRS_CLEAN_DEPEND) $(SUBDIRS_DEPEND) $(SUBDIRS_UNINSTALL) $(SUBDIRS)
diff --git a/build_tools/prep_moduledeps b/build_tools/prep_moduledeps
index 3111f57421395430cf1a7e48e62af7802fc45caa..76388d50eb1304c259f235724c9100eaafedfb83 100755
--- a/build_tools/prep_moduledeps
+++ b/build_tools/prep_moduledeps
@@ -33,8 +33,11 @@ process_dir() {
 	displayname=${4}
 
 	echo -e "\t<category name=\"MENUSELECT_${catsuffix}\" displayname=\"${displayname}\">"
-	for file in `ls ${dir}/${prefix}*.c ${dir}/${prefix}*.cc | sort`
+	for file in `ls ${dir}/${prefix}*.c ${dir}/${prefix}*.cc 2> /dev/null | sort`
 	do
+	        if [ ! -f ${file} ]; then
+			continue
+		fi
 		fname=`basename ${file} .c`
 		fname=`basename ${fname} .cc`
 		get_description ${file}