diff --git a/build/Makefile b/build/Makefile
index 4ff73bb469971a51c75e39fffa9ee91a1ba5869e..8e5880999e25695dbb4070bb1468079e3bb23939 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -159,7 +159,7 @@ release: tarball macos
 	zip -r mongoose-php-$(VERSION).zip mongoose_php_bundle/
 
 clean:
-	cd ../examples && $(MAKE) clean
-	rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz \
+	@cd ../examples && $(MAKE) clean
+	@rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz \
 	$(PROG).exe *.dll *.lib res.o res.RES *.dSYM *.zip *.pdb \
 	*.exe *dmg* $(PROG)-* unix_unit_test
diff --git a/build/test/all_build_flags.pl b/build/test/all_build_flags.pl
index ee225f9a2cba97c116abc0027f78321750450ac6..7e9400c02569b4df4d18c5e15a3fc00887a2cd5f 100644
--- a/build/test/all_build_flags.pl
+++ b/build/test/all_build_flags.pl
@@ -1,28 +1,39 @@
 #!/usr/bin/env perl
-
-@flags = ("NO_POPEN", "NO_SSL", "NDEBUG", "DEBUG", "NO_CGI");
+use Data::Dumper;
+@flags = split /\s+/,
+  `egrep -o 'NO_[A-Z0-9_]*|USE_[A-Z0-9_]*' ../mongoose.c  | sort | uniq`;
+#@flags = ("NO_POPEN", "NO_SSL", "NDEBUG", "DEBUG", "NO_CGI");
 my $num_flags = @flags;
 
 sub fail {
-	print "FAILED: @_\n";
-	exit 1;
+  print "FAILED: @_\n";
+  exit 1;
 }
 
-my $platform = $ARGV[0] || "linux";
+my $extra = {
+  'USE_SSL' => '-lssl',
+  'USE_LUA' => 'lua_5.2.1.c',
+};
+
+#my $platform = $ARGV[0] || "linux";
 
 for (my $i = 0; $i < 2 ** $num_flags; $i++) {
-	my $bitmask = sprintf("%*.*b", $num_flags, $num_flags, $i);
-	my @combination = ();
-	for (my $j = 0; $j < $num_flags; $j++) {
-		push @combination, $flags[$j] if substr($bitmask, $j, 1);
-	}
-	my $defines = join(" ", map { "-D$_" } @combination);
-	my $cmd = "CFLAGS=\"$defines\" make clean $platform >/dev/null";
-	system($cmd) == 0 or fail "build failed: $_";
-	print "Build succeeded, flags: [$defines]\n";
-	system("perl test/test.pl basic_tests >/dev/null") == 0
-		or fail "basic tests";
-	print "Basic tests: OK\n";
+  my $bitmask = sprintf("%*.*b", $num_flags, $num_flags, $i);
+  my @combination = ();
+  for (my $j = 0; $j < $num_flags; $j++) {
+    next unless substr($bitmask, $j, 1);
+    my $def = $flags[$j];
+    next if $def eq 'USE_LUA_SQLITE3';
+    push @combination, "-D$def";
+    push @combination, $extra->{$def} if $extra->{$def};
+  }
+  my $defines = join(" ", @combination);
+  my $cmd = "make clean all CFLAGS_EXTRA=\"-O0 $defines\"";
+  #print "Testing [$defines]\n";
+  system($cmd) == 0 or fail "build failed: $_";
+  #system("perl test/test.pl basic_tests >/dev/null") == 0
+  #  or fail "basic tests";
+  #print "Basic tests: OK\n";
 }
 
 print "PASS: All builds passed!\n";
diff --git a/examples/Makefile b/examples/Makefile
index 8204e409daf39578f247544188ca9a827843db45..a7544ad7eed06a9841cc2cf20c5c6a4ab4ba25ab 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -43,4 +43,4 @@ windows:
 #$(CL) lua_dll.c $(CLFLAGS) $(DLL_FLAGS) /DLL $(LFLAGS) /SUBSYSTEM:WINDOWS /ENTRY:luaopen_lua_dll /EXPORT:luaopen_lua_dll /out:lua_dll.dll
 
 clean:
-	rm -rf hello upload post websocket chat *.exe *.dSYM *.obj .*o
+	@rm -rf hello upload post websocket chat *.exe *.dSYM *.obj .*o