From 395bed2b14fe9add4f2ce396548ea3ed6d04c386 Mon Sep 17 00:00:00 2001
From: "Yichun Zhang (agentzh)" <yichun@openresty.com>
Date: Sat, 7 Sep 2019 23:40:52 -0700
Subject: [PATCH] bugfix: windows: make clean: we did not clear many
 windows-specific files.

---
 t/sanity.t     | 179 +++++++++++++++++++++++++------------------------
 util/configure |   2 +-
 2 files changed, 91 insertions(+), 90 deletions(-)

diff --git a/t/sanity.t b/t/sanity.t
index 4197f05..bf5dbcb 100644
--- a/t/sanity.t
+++ b/t/sanity.t
@@ -355,7 +355,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -443,7 +443,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -531,7 +531,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -619,7 +619,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -706,7 +706,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -793,7 +793,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -1132,7 +1132,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -1221,7 +1221,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -1323,7 +1323,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -1411,7 +1411,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 --- err
 Can't exec "gcc-4.2": No such file or directory at ./configure line 710.
 Can't exec "gcc-4.2": No such file or directory at ./configure line 756.
@@ -1503,7 +1503,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -1592,7 +1592,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 --- err
 Can't exec "cl": No such file or directory at ./configure line 710.
 Can't exec "cl": No such file or directory at ./configure line 756.
@@ -1697,7 +1697,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -1786,7 +1786,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -1812,43 +1812,43 @@ clean:
 
 === TEST 22: ngx_postgres enabled and --with-pg_config is specified
 --- cmd: ./configure --with-pg_config=pg_config --with-http_postgres_module --dry-run
---- out_like
-platform: linux \(linux\)
+--- out
+platform: linux (linux)
 cp -rp bundle/ build
 cd build
-export LIBPQ_LIB='(/usr/lib64|/usr/lib/x86_64-linux-gnu)'
-export LIBPQ_INC='(?:/usr/include|/usr/include/postgresql)'
+export LIBPQ_LIB='/usr/lib64'
+export LIBPQ_INC='/usr/include'
 cd LuaJIT-2.1-20190626
 INFO: found -msse4.2 in cc.
 gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -DLUAJIT_ENABLE_GC64 -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit
-gmake install TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -DLUAJIT_ENABLE_GC64 -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit DESTDIR=\$OPENRESTY_BUILD_DIR/luajit-root/
-export LUAJIT_LIB='\$OPENRESTY_BUILD_DIR/luajit-root/usr/local/openresty/luajit/lib'
-export LUAJIT_INC='\$OPENRESTY_BUILD_DIR/luajit-root/usr/local/openresty/luajit/include/luajit-2.1'
+gmake install TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -DLUAJIT_ENABLE_GC64 -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit DESTDIR=$OPENRESTY_BUILD_DIR/luajit-root/
+export LUAJIT_LIB='$OPENRESTY_BUILD_DIR/luajit-root/usr/local/openresty/luajit/lib'
+export LUAJIT_INC='$OPENRESTY_BUILD_DIR/luajit-root/usr/local/openresty/luajit/include/luajit-2.1'
 cd ..
 patching the resty script with hard-coded nginx binary path...
 cd nginx-1.17.1
-sh ./configure --prefix=/usr/local/openresty/nginx \\
-  --with-cc-opt='-O2' \\
-  --add-module=../ngx_devel_kit-0.3.1rc1 \\
-  --add-module=../echo-nginx-module-0.61 \\
-  --add-module=../xss-nginx-module-0.06 \\
-  --add-module=../ngx_coolkit-0.2 \\
-  --add-module=../set-misc-nginx-module-0.32 \\
-  --add-module=../form-input-nginx-module-0.12 \\
-  --add-module=../encrypted-session-nginx-module-0.08 \\
-  --add-module=../ngx_postgres-1.0 \\
-  --add-module=../srcache-nginx-module-0.31 \\
-  --add-module=../ngx_lua-0.10.15 \\
-  --add-module=../ngx_lua_upstream-0.07 \\
-  --add-module=../headers-more-nginx-module-0.33 \\
-  --add-module=../array-var-nginx-module-0.05 \\
-  --add-module=../memc-nginx-module-0.19 \\
-  --add-module=../redis2-nginx-module-0.15 \\
-  --add-module=../redis-nginx-module-0.3.7 \\
-  --add-module=../rds-json-nginx-module-0.15 \\
-  --add-module=../rds-csv-nginx-module-0.09 \\
-  --add-module=../ngx_stream_lua-0.0.7 \\
-  --with-ld-opt='-Wl,-rpath,\1:/usr/local/openresty/luajit/lib' \\
+sh ./configure --prefix=/usr/local/openresty/nginx \
+  --with-cc-opt='-O2' \
+  --add-module=../ngx_devel_kit-0.3.1rc1 \
+  --add-module=../echo-nginx-module-0.61 \
+  --add-module=../xss-nginx-module-0.06 \
+  --add-module=../ngx_coolkit-0.2 \
+  --add-module=../set-misc-nginx-module-0.32 \
+  --add-module=../form-input-nginx-module-0.12 \
+  --add-module=../encrypted-session-nginx-module-0.08 \
+  --add-module=../ngx_postgres-1.0 \
+  --add-module=../srcache-nginx-module-0.31 \
+  --add-module=../ngx_lua-0.10.15 \
+  --add-module=../ngx_lua_upstream-0.07 \
+  --add-module=../headers-more-nginx-module-0.33 \
+  --add-module=../array-var-nginx-module-0.05 \
+  --add-module=../memc-nginx-module-0.19 \
+  --add-module=../redis2-nginx-module-0.15 \
+  --add-module=../redis-nginx-module-0.3.7 \
+  --add-module=../rds-json-nginx-module-0.15 \
+  --add-module=../rds-csv-nginx-module-0.09 \
+  --add-module=../ngx_stream_lua-0.0.7 \
+  --with-ld-opt='-Wl,-rpath,/usr/lib64:/usr/local/openresty/luajit/lib' \
   --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_ssl_module
 cd ../..
 Type the following commands to build and install:
@@ -1897,7 +1897,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -1996,7 +1996,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2084,7 +2084,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2172,7 +2172,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2260,7 +2260,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2348,7 +2348,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2436,7 +2436,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 --- err
 Can't exec "sw_vers": No such file or directory at ./configure line 824.
 
@@ -2526,7 +2526,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 --- err
 Can't exec "sw_vers": No such file or directory at ./configure line 824.
 
@@ -2617,7 +2617,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2703,7 +2703,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2789,7 +2789,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2876,7 +2876,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -2961,7 +2961,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3045,7 +3045,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3131,7 +3131,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3212,7 +3212,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3311,7 +3311,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3399,7 +3399,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3487,7 +3487,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3575,7 +3575,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3662,7 +3662,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3749,7 +3749,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3837,7 +3837,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -3926,7 +3926,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4014,7 +4014,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4102,7 +4102,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4190,7 +4190,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4278,7 +4278,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4366,7 +4366,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4453,7 +4453,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4543,7 +4543,7 @@ install: all
 	ln -sf ./nginx/sbin/nginx $(DESTDIR)./bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4633,7 +4633,7 @@ install: all
 	ln -sf ./nginx/sbin/nginx $(DESTDIR)./bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4723,7 +4723,7 @@ install: all
 	ln -sf ./nginx/sbin/nginx $(DESTDIR)./bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4811,7 +4811,7 @@ install: all
 	mkdir -p $(DESTDIR)./site/lualib $(DESTDIR)./site/pod $(DESTDIR)./site/manifest
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4899,7 +4899,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -4987,7 +4987,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5075,7 +5075,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5163,7 +5163,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5251,7 +5251,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5339,7 +5339,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5427,7 +5427,7 @@ install: all
 	ln -sf /opt/blah/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5515,7 +5515,7 @@ install: all
 	ln -sf ../bin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5602,7 +5602,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5656,7 +5656,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5744,7 +5744,7 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
 
 
 
@@ -5886,4 +5886,5 @@ install: all
 	ln -sf /usr/local/openresty/nginx/sbin/nginx $(DESTDIR)/usr/local/openresty/bin/openresty
 
 clean:
-	rm -rf build
+	rm -rf build *.exe *.dll openresty-*
+
diff --git a/util/configure b/util/configure
index 4101f9f..119f155 100755
--- a/util/configure
+++ b/util/configure
@@ -1607,7 +1607,7 @@ sub gen_makefile {
 
     print $out "install: all\n\t" . join("\n\t", @make_install_cmds) . "\n\n";
 
-    print $out "clean:\n\trm -rf build\n";
+    print $out "clean:\n\trm -rf build *.exe *.dll openresty-*\n";
 
     close $out;
 }