]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
winbuild: fix makefile clean
authorJay Satiro <raysatiro@yahoo.com>
Tue, 21 Feb 2023 08:38:37 +0000 (03:38 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Thu, 23 Feb 2023 08:49:37 +0000 (03:49 -0500)
- Fix and move 'clean' code that removes the output and obj directories
  trees from MakefileBuild.vc to Makefile.vc.

Prior to this change the 'clean' code did not work right because the
variables containing the directory names were not fully initialized and
the rmdir syntax was sometimes incorrect (typos). DIRDIST for example
was set to ..\builds\ and not ..\builds\$(CONFIG_NAME_LIB)\ so it would
remove the former and not the latter. If WITH_PREFIX was set then that
directory was removed instead.

Also, DIRDIST (the output directory) even if initialized should not be
removed by MakefileBuild.vc because by that time it could be set to a
user directory that may contain other files if WITH_PREFIX is set (eg we
don't want rmdir /s /q C:\usr\local). Therefore we remove from
Makefile.vc before any of that happens. I added a comment in both
makefiles explaining this.

Closes https://github.com/curl/curl/pull/10576

winbuild/Makefile.vc
winbuild/MakefileBuild.vc

index d2498b7a4453cfbd96c37ba734cbb77a94621f02..44d9604baca8bc6203ec729da6ed64e81283a472 100644 (file)
@@ -265,6 +265,10 @@ CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-msh3
 
 !MESSAGE configuration name: $(CONFIG_NAME_LIB)
 
+# Note these directories are removed by this makefile's 'clean' so they should
+# not be changed to point to user-specified directories that may contain other
+# data. MakefileBuild.vc uses the same variable names but allows some user
+# changes and therefore does not remove the directories.
 BUILD_DIR=../builds/$(CONFIG_NAME_LIB)
 LIBCURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-lib
 CURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-curl
@@ -300,4 +304,7 @@ copy_from_lib:
        FOR %%i IN ($(CURLX_CFILES:/=\)) DO copy %%i ..\src\
 
 clean:
+       @if exist $(LIBCURL_DIROBJ) rd /s /q $(LIBCURL_DIROBJ)
+       @if exist $(CURL_DIROBJ) rd /s /q $(CURL_DIROBJ)
+       @if exist $(DIRDIST) rd /s /q $(DIRDIST)
        $(MAKE) /NOLOGO /F MakefileBuild.vc $@
index 10a93b054669350195543d4711081418f905b3ef..5cf65dcd7fa4108460df68018fcee56212da4b1a 100644 (file)
@@ -692,6 +692,12 @@ $(CURL_DIROBJ)\curl.res: $(CURL_SRC_DIR)\curl.rc
 \r
 !ENDIF  # End of case where a config was provided.\r
 \r
+# Makefile.vc's clean removes (LIB)CURL_DIROBJ and DIRDIST dirs then calls\r
+# this clean. Note those are the original directories we control and not the\r
+# directories possibly modified by this makefile to point to user-specified\r
+# directories.\r
+# For example, don't remove DIRDIST here since it may contain user files if it\r
+# has been changed by WITH_PREFIX to a different output dir (eg C:\usr\local).\r
 clean:\r
        @-erase /s *.dll 2> NUL\r
        @-erase /s *.exp 2> NUL\r
@@ -701,6 +707,3 @@ clean:
        @-erase /s *.pch 2> NUL\r
        @-erase /s *.pdb 2> NUL\r
        @-erase /s *.res 2> NUL\r
-       @if exist $(LIB_DIROBJ) rd /s/q $(LIB_DIROBJ)\r
-       @if exist $(CURL_DIROBJ)rd /s/q $(CURL_DIROBJ)\r
-       @if exist $(DIRDIST) rd /s/q $(DIRDIST)\r