From c1cf1b3ce63a2bcd3f2c4c275bab144dd0e4b6ec Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 25 Jan 2009 02:06:29 +0000 Subject: * Makefile.in, win32/Makefile.sub (RMDIRS): remove directory and parents. * Makefile.in, win32/Makefile.sub (distclean-rdoc): added to remove temprary rdoc. * Makefile.in, win32/Makefile.sub (distclean): removes extout directory. * Makefile.in, win32/Makefile.sub (clean-ext): skips non-existent directories. * common.mk (clean, distclean): cleans rdoc. * configure.in (RMDIRS, RMALL): added to clean extout. * lib/fileutils.rb (FileUtils#rmdir): added :parents option. * lib/mkmf.rb (create_makefile): cleans installed files at clean instead of distclean. * lib/mkmf.rb (create_makefile): added clean-so and clean-rb. * lib/mkmf.rb (def init_mkmf): added DISTCLEANDIRS. * lib/un.rb (rmdir): added -p option. * tool/rmdirs, win32/rmdirs.bat: removes directory and the parents. * win32/rm.bat: added -r option. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/Makefile.sub | 25 +++++++++++++++++++++---- win32/rm.bat | 11 +++++++++++ win32/rmdirs.bat | 29 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100755 win32/rmdirs.bat (limited to 'win32') diff --git a/win32/Makefile.sub b/win32/Makefile.sub index a57e79bd4..4092b3c73 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -64,6 +64,7 @@ PURIFY = AUTOCONF = autoconf IFCHANGE = $(COMSPEC) /C $(srcdir:/=\)\win32\ifchange.bat RM = $(COMSPEC) /C $(srcdir:/=\)\win32\rm.bat +RMDIRS = $(COMSPEC) /C $(srcdir:/=\)\win32\rmdirs.bat CP = copy > nul MV = move > nul !if !defined(BASERUBY) @@ -575,6 +576,8 @@ s,@ARFLAGS@,$(ARFLAGS),;t t s,@LN_S@,$(LN_S),;t t s,@SET_MAKE@,MFLAGS = -$$(MAKEFLAGS),;t t s,@RM@,$$(COMSPEC) /C $$(top_srcdir:/=\)\win32\rm.bat,;t t +s,@RMDIRS@,$$(COMSPEC) /C $$(top_srcdir:/=\)\win32\rmdirs.bat,;t t +s,@RMALL@,$$(COMSPEC) /C rmdir /s /q,;t t s,@CP@,copy > nul,;t t s,@LIBOBJS@,$(LIBOBJS),;t t s,@ALLOCA@,$(ALLOCA),;t t @@ -712,15 +715,29 @@ clean-local:: distclean-local:: @$(RM) ext\config.cache $(RBCONFIG:/=\) $(CONFIG_H:/=\) @$(RM) $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc + @-$(RM) $(INSTALLED_LIST:/=\) $(arch_hdrdir:/=\)\ruby\config.h + @-$(RMDIRS) $(arch_hdrdir:/=\)\ruby + +distclean-rdoc: + @-$(RMALL) $(RDOCOUT:/=\) + +distclean: + @-rmdir $(EXTOUT:/=\)\$(arch) + @-rmdir $(EXTOUT:/=\) clean-ext distclean-ext realclean-ext:: - @for /R ext %I in (.) do @if exist %I\Makefile ( \ +!if "$(EXTS)" == "" + @for %I in ($(EXTS)) \ +!else + @for /R ext %I in (.) \ +!endif + do @if exist %I\Makefile ( \ + cd %I && ( \ echo $(@:-ext=)ing %~nI & \ - cd %I & \ $(MAKE) $(MFLAGS) $(@:-ext=) & \ cd %CD% & \ - rmdir %I \ - ) + $(RMDIRS) %I \ + ) ) distclean-ext realclean-ext:: @-rmdir ext diff --git a/win32/rm.bat b/win32/rm.bat index eb415d67f..83e381728 100755 --- a/win32/rm.bat +++ b/win32/rm.bat @@ -1,8 +1,19 @@ @echo off +:optloop if "%1" == "-f" shift +if "%1" == "-r" (set recursive=1 & goto :optloop) +if "%recursive%" == "1" goto :recursive :begin if "%1" == "" goto :end if exist "%1" del "%1" +set p=%1 +if exist "%p:/=\%" del "%p:/=\%" shift goto :begin +:recursive +if "%1" == "" goto :end +set p=%1 +if exist "%p:/=\%" rd /s /q "%p:/=\%" +shift +goto :recursive :end diff --git a/win32/rmdirs.bat b/win32/rmdirs.bat new file mode 100755 index 000000000..a8549cc12 --- /dev/null +++ b/win32/rmdirs.bat @@ -0,0 +1,29 @@ +::-*- batch -*- +@echo off +if "%1" == "-p" shift +:begin +if "%1" == "" goto :end + set dir=%1 + shift + set dir=%dir:/=\% + :rmdirs + if not exist "%dir%\." goto :begin + if "%dir%" == "." goto :begin + if "%dir%" == ".." goto :begin + rd "%dir%" || goto :begin + :trim_sep + if not /%dir:~-1%/ == /\/ goto :trim_base + set dir=%dir:~0,-1% + if not "%dir%" == "" goto :trim_sep + :trim_base + if /%dir:~-1%/ == /\/ goto :parent + set dir=%dir:~0,-1% + if not "%dir%" == "" goto :trim_base + :parent + set dir=%dir:~0,-1% + if "%dir%" == "" goto :begin + if "%dir:~-1%" == ":" goto :begin + goto :rmdirs +shift +goto :begin +:end -- cgit