Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mkmf with space #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions lib/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def quote
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
end

# Escape whitespaces for Makefile.
def unspace
gsub(/\s/, '\\\\\\&')
end

# Generates a string used as cpp macro name.
def tr_cpp
strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
Expand Down Expand Up @@ -196,10 +201,11 @@ def map_dir(dir, map = nil)
$extmk = path[0, topdir.size+1] == topdir+"/"
$extmk &&= %r"\A(?:ext|enc|tool|test(?:/.+)?)\z" =~ File.dirname(path[topdir.size+1..-1])
$extmk &&= true
if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
if not $extmk and File.exist?(RbConfig::CONFIG["rubyhdrdir"] + "/ruby/ruby.h")
$hdrdir = CONFIG["rubyhdrdir"]
$topdir = $hdrdir
$top_srcdir = $hdrdir
$arch_hdrdir = $hdrdir + "/$(arch)"
$arch_hdrdir = "$(hdrdir)/$(arch)"
elsif File.exist?(($hdrdir = ($top_srcdir ||= topdir) + "/include") + "/ruby.h")
$topdir ||= RbConfig::CONFIG["topdir"]
$arch_hdrdir = "$(extout)/include/$(arch)"
Expand Down Expand Up @@ -1722,7 +1728,7 @@ def mkintpath(path)
end
unless defined?(mkintpath)
def mkintpath(path)
path
path.unspace
end
end

Expand Down Expand Up @@ -1750,9 +1756,9 @@ def configuration(srcdir)

#### Start of system configuration section. ####
#{"top_srcdir = " + $top_srcdir.sub(%r"\A#{Regexp.quote($topdir)}/", "$(topdir)/") if $extmk}
srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {mkintpath(CONFIG[$1||$2])}.quote}
topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir).quote}
hdrdir = #{mkintpath(CONFIG["hdrdir"]).quote}
srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {mkintpath(CONFIG[$1||$2])}}
topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir)}
hdrdir = #{mkintpath(CONFIG["hdrdir"])}
arch_hdrdir = #{$arch_hdrdir.quote}
VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
}
Expand All @@ -1764,7 +1770,7 @@ def configuration(srcdir)
end
CONFIG.each do |key, var|
next unless /prefix$/ =~ key
mk << "#{key} = #{with_destdir(var)}\n"
mk << "#{key} = #{with_destdir(var).unspace}\n"
end
CONFIG.each do |key, var|
next if /^abs_/ =~ key
Expand Down Expand Up @@ -2126,14 +2132,14 @@ def create_makefile(target, srcprefix = nil)
if target
f = "$(DLLIB)"
dest = "#{dir}/#{f}"
mfile.puts dest
if $extout
mfile.puts dest
mfile.print "clean-so::\n"
mfile.print "\t-$(Q)$(RM) #{fseprepl[dest]}\n"
mfile.print "\t-$(Q)$(RMDIRS) #{fseprepl[dir]}#{$ignore_error}\n"
else
mfile.print "#{dest}: #{f}\n\t-$(Q)$(MAKEDIRS) $(@D#{sep})\n"
mfile.print "\t$(INSTALL_PROG) #{fseprepl[f]} $(@D#{sep})\n"
mfile.print "#{f} #{timestamp_file(dir)}\n"
mfile.print "\t$(INSTALL_PROG) #{fseprepl[f]} #{dir}\n"
if defined?($installed_list)
mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n"
end
Expand Down Expand Up @@ -2398,7 +2404,7 @@ def mkmf_failed(path)
"$(LDSHARED) #{OUTFLAG}$@ $(OBJS) " \
"$(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)"
end
LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L%s'
RPATHFLAG = config_string('RPATHFLAG') || ''
LIBARG = config_string('LIBARG') || '-l%s'
MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || 'int main(void) {return 0;}'
Expand Down