diff --git a/scripts/target_config_check.lua b/scripts/target_config_check.lua
index 160c32a388aac03de6b63fac8aaae2e40aec933c..373cf430b6ab3dbaa6d2f44c0f61d248daa25fde 100755
--- a/scripts/target_config_check.lua
+++ b/scripts/target_config_check.lua
@@ -1,13 +1,16 @@
-local ret = 0
+local errors = {}
 
 
 local function fail(...)
-	if ret == 0 then
-		ret = 1
+	if not next(errors) then
 		io.stderr:write('Configuration failed:', '\n')
 	end
 
-	io.stderr:write(' * ', string.format(...), '\n')
+	local msg = string.format(...)
+	if not errors[msg] then
+		errors[msg] = true
+		io.stderr:write(' * ', msg, '\n')
+	end
 end
 
 local function match_config(f)
@@ -63,4 +66,6 @@ for config, v in pairs(lib.configs) do
 	end
 end
 
-os.exit(ret)
+if next(errors) then
+	os.exit(1)
+end