Skip to content

Commit 80b7f05

Browse files
committed
winbuild: fix makefile clean
- 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 curl#10576
1 parent 47129b2 commit 80b7f05

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

winbuild/Makefile.vc

+7
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-msh3
265265

266266
!MESSAGE configuration name: $(CONFIG_NAME_LIB)
267267

268+
# Note these directories are removed by this makefile's 'clean' so they should
269+
# not be changed to point to user-specified directories that may contain other
270+
# data. MakefileBuild.vc uses the same variable names but allows some user
271+
# changes and therefore does not remove the directories.
268272
BUILD_DIR=../builds/$(CONFIG_NAME_LIB)
269273
LIBCURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-lib
270274
CURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-curl
@@ -300,4 +304,7 @@ copy_from_lib:
300304
FOR %%i IN ($(CURLX_CFILES:/=\)) DO copy %%i ..\src\
301305

302306
clean:
307+
@if exist $(LIBCURL_DIROBJ) rd /s /q $(LIBCURL_DIROBJ)
308+
@if exist $(CURL_DIROBJ) rd /s /q $(CURL_DIROBJ)
309+
@if exist $(DIRDIST) rd /s /q $(DIRDIST)
303310
$(MAKE) /NOLOGO /F MakefileBuild.vc $@

winbuild/MakefileBuild.vc

+6-3
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,12 @@ $(CURL_DIROBJ)\curl.res: $(CURL_SRC_DIR)\curl.rc
692692

693693
!ENDIF # End of case where a config was provided.
694694

695+
# Makefile.vc's clean removes (LIB)CURL_DIROBJ and DIRDIST dirs then calls
696+
# this clean. Note those are the original directories we control and not the
697+
# directories possibly modified by this makefile to point to user-specified
698+
# directories.
699+
# For example, don't remove DIRDIST here since it may contain user files if it
700+
# has been changed by WITH_PREFIX to a different output dir (eg C:\usr\local).
695701
clean:
696702
@-erase /s *.dll 2> NUL
697703
@-erase /s *.exp 2> NUL
@@ -701,6 +707,3 @@ clean:
701707
@-erase /s *.pch 2> NUL
702708
@-erase /s *.pdb 2> NUL
703709
@-erase /s *.res 2> NUL
704-
@if exist $(LIB_DIROBJ) rd /s/q $(LIB_DIROBJ)
705-
@if exist $(CURL_DIROBJ)rd /s/q $(CURL_DIROBJ)
706-
@if exist $(DIRDIST) rd /s/q $(DIRDIST)

0 commit comments

Comments
 (0)