summaryrefslogtreecommitdiff
path: root/lib/mkmf.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-25 02:06:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-25 02:06:29 +0000
commit97de7d1081e69ad9d63c03b0f6a700954f8e4402 (patch)
tree7cab17680e1e1f5c6b9340fb0102ef661f4db6c6 /lib/mkmf.rb
parent0506348ef501d5f2e3dc64666b6bb6785870583c (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@21764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/mkmf.rb')
-rw-r--r--lib/mkmf.rb74
1 files changed, 49 insertions, 25 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index e3fd6ea619..1d46f6c299 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -1407,6 +1407,7 @@ ruby = #{$ruby}
RUBY = $(ruby#{sep})
RM = #{config_string('RM', &possible_command) || '$(RUBY) -run -e rm -- -f'}
RM_RF = #{'$(RUBY) -run -e rm -- -rf'}
+RMDIRS = #{config_string('RMDIRS', &possible_command) || '$(RUBY) -run -e rmdir -- -p'}
MAKEDIRS = #{config_string('MAKEDIRS', &possible_command) || '@$(RUBY) -run -e mkdir -- -p'}
INSTALL = #{config_string('INSTALL', &possible_command) || '@$(RUBY) -run -e install -- -vp'}
INSTALL_PROG = #{config_string('INSTALL_PROG') || '$(INSTALL) -m 0755'}
@@ -1606,7 +1607,8 @@ def create_makefile(target, srcprefix = nil)
origdef ||= ''
if $extout and $INSTALLFILES
- $distcleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.sub(/\A\.\//, ''))})
+ $cleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.sub(/\A\.\//, ''))})
+ $distcleandirs.concat($INSTALLFILES.collect {|files, dir| dir})
end
if $extmk and not $extconf_h
@@ -1626,6 +1628,7 @@ DEFFILE = #{deffile}
CLEANFILES = #{$cleanfiles.join(' ')}
DISTCLEANFILES = #{$distcleanfiles.join(' ')}
+DISTCLEANDIRS = #{$distcleandirs.join(' ')}
extout = #{$extout}
extout_prefix = #{$extout_prefix}
@@ -1652,6 +1655,18 @@ all: #{$extout ? "install" : target ? "$(DLLIB)" : "Makefile"}
static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
"
mfile.print CLEANINGS
+ fsep = config_string('BUILD_FILE_SEPARATOR') {|s| s unless s == "/"}
+ if fsep
+ fseprepl = proc {|s|
+ s = s.gsub("/", fsep)
+ s = s.gsub(/(\$\(\w+)(\))/) {$1+sep+$2}
+ s = s.gsub(/(\$\{\w+)(\})/) {$1+sep+$2}
+ }
+ sep = ":/=#{fsep}"
+ else
+ fseprepl = proc {|s| s}
+ sep = ""
+ end
dirs = []
mfile.print "install: install-so install-rb\n\n"
sodir = (dir = "$(RUBYARCHDIR)").dup
@@ -1660,18 +1675,13 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
f = "$(DLLIB)"
dest = "#{dir}/#{f}"
mfile.puts dir, "install-so: #{dest}"
- unless $extout
+ if $extout
+ mfile.print "clean-so::\n"
+ mfile.print "\t@-$(RM) #{fseprepl[dest]}\n"
+ mfile.print "\t@-$(RMDIRS) #{fseprepl[dir]}\n"
+ else
mfile.print "#{dest}: #{f}\n"
- if (sep = config_string('BUILD_FILE_SEPARATOR'))
- f.gsub!("/", sep)
- dir.gsub!("/", sep)
- sep = ":/="+sep
- f.gsub!(/(\$\(\w+)(\))/) {$1+sep+$2}
- f.gsub!(/(\$\{\w+)(\})/) {$1+sep+$2}
- dir.gsub!(/(\$\(\w+)(\))/) {$1+sep+$2}
- dir.gsub!(/(\$\{\w+)(\})/) {$1+sep+$2}
- end
- mfile.print "\t$(INSTALL_PROG) #{f} #{dir}\n"
+ mfile.print "\t$(INSTALL_PROG) #{fseprepl[f]} #{fseprepl[dir]}\n"
if defined?($installed_list)
mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n"
end
@@ -1683,35 +1693,41 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
mfile.print("install-rb-default: pre-install-rb-default\n")
mfile.print("pre-install-rb: Makefile\n")
mfile.print("pre-install-rb-default: Makefile\n")
- fsep = config_string('BUILD_FILE_SEPARATOR') {|s| s unless s == "/"}
- sep = fsep ? ":/=#{fsep}" : ""
for sfx, i in [["-default", [["lib/**/*.rb", "$(RUBYLIBDIR)", "lib"]]], ["", $INSTALLFILES]]
files = install_files(mfile, i, nil, srcprefix) or next
for dir, *files in files
unless dirs.include?(dir)
dirs << dir
mfile.print "pre-install-rb#{sfx}: #{dir}\n"
- end if $nmake
+ end
for f in files
dest = "#{dir}/#{File.basename(f)}"
mfile.print("install-rb#{sfx}: #{dest}\n")
mfile.print("#{dest}: #{f}\n")
- mfile.print("\t$(MAKEDIRS) $(@D)\n") unless $nmake
mfile.print("\t$(#{$extout ? 'COPY' : 'INSTALL_DATA'}) ")
- if fsep
- f = f.gsub("/", fsep)
- f = f.gsub(/(\$\(\w+)(\))/) {$1+sep+$2}
- f = f.gsub(/(\$\{\w+)(\})/) {$1+sep+$2}
- end
- mfile.print("#{f} $(@D#{sep})\n")
+ mfile.print("#{fseprepl[f]} $(@D#{sep})\n")
if defined?($installed_list) and !$extout
mfile.print("\t@echo #{dest}>>$(INSTALLED_LIST)\n")
end
+ if $extout
+ mfile.print("clean-rb#{sfx}::\n")
+ mfile.print("\t@-$(RM) #{fseprepl[dest]}\n")
+ end
+ end
+ end
+ if $extout
+ dirs.uniq!
+ dirs.reverse!
+ unless dirs.empty?
+ mfile.print("clean-rb#{sfx}::\n")
+ for dir in dirs
+ mfile.print("\t@-$(RMDIRS) #{fseprepl[dir]}\n")
+ end
end
end
end
dirs.unshift(sodir) if target and !dirs.include?(sodir)
- dirs.each {|d| mfile.print "#{d}:\n\t$(MAKEDIRS) $@\n" if $nmake || d == sodir}
+ dirs.each {|d| mfile.print "#{d}:\n\t$(MAKEDIRS) $@\n"}
mfile.print <<-SITEINSTALL
@@ -1823,6 +1839,7 @@ def init_mkmf(config = CONFIG)
$cleanfiles = config_string('CLEANFILES') {|s| Shellwords.shellwords(s)} || []
$cleanfiles << "mkmf.log"
$distcleanfiles = config_string('DISTCLEANFILES') {|s| Shellwords.shellwords(s)} || []
+ $distcleandirs = config_string('DISTCLEANDIRS') {|s| Shellwords.shellwords(s)} || []
$extout ||= nil
$extout_prefix ||= nil
@@ -1917,12 +1934,19 @@ MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || 'int main() {return 0;
sep = config_string('BUILD_FILE_SEPARATOR') {|s| ":/=#{s}" if sep != "/"} || ""
CLEANINGS = "
-clean:
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-rb-default clean-rb
\t\t@-$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep})
-distclean: clean
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean: clean distclean-so distclean-rb-default distclean-rb
\t\t@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
\t\t@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep})
+\t\t@-$(RMDIRS) $(DISTCLEANDIRS#{sep})
realclean: distclean
"