diff --git a/ChangeLog b/ChangeLog index 20139c60a4..dfd44abd83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Dec 18 01:15:44 2007 Nobuyoshi Nakada + + * common.mk (encs): added dependencies. + + * enc/Makefile.in, enc/depend, enc/make_encmake.rb: moved serb code. + + * lib/mkmf.rb (depend_rules): now takes content string, not file name. + + * win32/enc-setup.mak: overrides default target. + Tue Dec 18 00:26:12 2007 Yukihiro Matsumoto * re.c (rb_reg_initialize): raise error if non-Unicode fixed diff --git a/common.mk b/common.mk index c288740c73..48afbf7b00 100644 --- a/common.mk +++ b/common.mk @@ -342,7 +342,8 @@ $(RBCONFIG): $(srcdir)/mkconfig.rb config.status $(PREP) encs: enc.mk $(MAKE) -f enc.mk -enc.mk: miniruby$(EXEEXT) +enc.mk: miniruby$(EXEEXT) $(srcdir)/enc/make_encmake.rb \ + $(srcdir)/enc/Makefile.in $(srcdir)/enc/depend $(srcdir)/lib/mkmf.rb $(MINIRUBY) $(srcdir)/enc/make_encmake.rb $@ .PRECIOUS: $(MKFILES) diff --git a/enc/Makefile.in b/enc/Makefile.in index 05296dc602..792fb9fc21 100644 --- a/enc/Makefile.in +++ b/enc/Makefile.in @@ -4,7 +4,6 @@ arch = @arch@ EXTOUT = @EXTOUT@ hdrdir = $(top_srcdir)/include arch_hdrdir = $(EXTOUT)/include/$(arch) -VPATH = <% %w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(top_srcdir) $(srcdir)].join("@PATH_SEPARATOR@") %> ENCSODIR = $(EXTOUT)/$(arch)/enc DLEXT = @DLEXT@ OBJEXT = @OBJEXT@ @@ -13,30 +12,15 @@ BUILTIN_ENCS = ascii.c \ euc_jp.c sjis.c \ unicode.c utf8.c -ENCOBJS = <%encs.map {|e|"#{e}.$(OBJEXT)"}.join(" \\\n\t ")+"\n"%> -ENCSOS = <%encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")+"\n"%> empty = CC = @CC@ OUTFLAG = @OUTFLAG@$(empty) CFLAGS = @CFLAGS@ @ARCH_FLAG@ -XCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir) @XCFLAGS@ +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir) +DEFS = @DEFS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@ XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS) LIBS = @LIBS@ $(EXTLIBS) LDSHARED = @LDSHARED@ DLDFLAGS = @DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@ - -#!#! if File.exist?(depend = File.join($srcdir, "depend")) -#### depend #### -#!#<% depend_rules(depend).join%> -#!#! end -#!#! encs.each do |e| -#!# -#!#$(ENCSODIR)/<%e%>.$(DLEXT): <%e%>.$(OBJEXT) -#!# <%LINK_SO.gsub(/\n/, "\n\t")%> -#!#! end -#!#! encs.each do |e| -#!# -#!#<%e%>.$(OBJEXT): <% (RULE_SUBST || "%s") % "#{e}.c" %> -#!#! end diff --git a/enc/depend b/enc/depend index 9a7cf1a1ff..8fc836daff 100644 --- a/enc/depend +++ b/enc/depend @@ -1,3 +1,24 @@ +! encs = (Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - CONFIG["BUILTIN_ENCS"].split).each {|e| e.chomp!(".c")} + +VPATH = <% %w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(top_srcdir) $(srcdir)].join(CONFIG["PATH_SEPARATOR"]) %> + +ENCOBJS = <%encs.map {|e|"#{e}.$(OBJEXT)"}.join(" \\\n\t ")+"\n"%> + +ENCSOS = <%encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")+"\n"%> + all: $(ENCSOS) +.c.$(OBJEXT): + <%COMPILE_C%> + $(ENCOBJS): regenc.h oniguruma.h config.h defines.h + +! encs.each do |e| + +$(ENCSODIR)/<%e%>.$(DLEXT): <%e%>.$(OBJEXT) + <%LINK_SO.gsub(/\n/, "\n\t")%> +! end + +! encs.each do |e| +<%e%>.$(OBJEXT): <%e%>.c +! end diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb index fe75b2778d..593f8ba626 100644 --- a/enc/make_encmake.rb +++ b/enc/make_encmake.rb @@ -3,21 +3,17 @@ dir = File.expand_path("../..", __FILE__) $:.unshift(File.join(dir, "lib")) $:.unshift(dir) -File.directory?("enc") || File.mkdir("enc") $:.unshift(".") require 'mkmf' require 'tool/serb' -encdir = File.join($top_srcdir, "enc") - -encs = Dir.open(encdir) {|d| d.grep(/.+\.c\z/)} -encs -= CONFIG["BUILTIN_ENCS"].split -encs.each {|e| e.chomp!(".c")} -mkin = File.read(File.join(encdir, "Makefile.in")) -mkin.gsub!(/^\#!\# ?/, '') -mkin.gsub!(/@(#{RbConfig::MAKEFILE_CONFIG.keys.join('|')})@/) {CONFIG[$1]} -tmp = '' -eval(serb(mkin, 'tmp')) +mkin = File.read(File.join($srcdir, "Makefile.in")) +mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]} +if File.exist?(depend = File.join($srcdir, "depend")) + tmp = '' + eval(serb(File.read(depend), 'tmp')) + mkin << "\n#### depend ####\n\n" << depend_rules(tmp).join +end open(ARGV[0], 'w') {|f| - f.puts tmp + f.puts mkin } diff --git a/lib/mkmf.rb b/lib/mkmf.rb index f8588b4fe2..aedb376e5c 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1273,48 +1273,46 @@ def depend_rules(depend) unless suffixes.empty? depout << ".SUFFIXES: ." + suffixes.uniq.join(" .") + "\n\n" end - open(depend, "r") do |dfile| - cont = implicit = nil - impconv = proc do - COMPILE_RULES.each {|rule| depout << (rule % implicit[0]) << implicit[1]} - implicit = nil - end - ruleconv = proc do |line| - if implicit - if /\A\t/ =~ line - implicit[1] << line - next - else - impconv[] - end - end - if m = /\A\.(\w+)\.(\w+)(?:\s*:)/.match(line) - suffixes << m[1] << m[2] - implicit = [[m[1], m[2]], [m.post_match]] + cont = implicit = nil + impconv = proc do + COMPILE_RULES.each {|rule| depout << (rule % implicit[0]) << implicit[1]} + implicit = nil + end + ruleconv = proc do |line| + if implicit + if /\A\t/ =~ line + implicit[1] << line next - elsif RULE_SUBST and /\A(?!\s*\w+\s*=)[$\w][^#]*:/ =~ line - line.gsub!(%r"(?<=\s)(?!\.)([^$(){}+=:\s\/\\,]+)(?=\s|\z)", &RULE_SUBST.method(:%)) + else + impconv[] end - depout << line end - while line = dfile.gets() - line.gsub!(/\.o\b/, ".#{$OBJEXT}") - line.gsub!(/\$\((?:hdr|top)dir\)\/config.h/, $config_h) if $config_h - line.gsub!(%r"\$\(hdrdir\)/(?!ruby/)", '\&ruby/') - if /(?:^|[^\\])(?:\\\\)*\\$/ =~ line - (cont ||= []) << line - next - elsif cont - line = (cont << line).join - cont = nil - end - ruleconv.call(line) + if m = /\A\.(\w+)\.(\w+)(?:\s*:)/.match(line) + suffixes << m[1] << m[2] + implicit = [[m[1], m[2]], [m.post_match]] + next + elsif RULE_SUBST and /\A(?!\s*\w+\s*=)[$\w][^#]*:/ =~ line + line.gsub!(%r"(?<=\s)(?!\.)([^$(){}+=:\s\/\\,]+)(?=\s|\z)", &RULE_SUBST.method(:%)) end - if cont - ruleconv.call(cont.join) - elsif implicit - impconv.call + depout << line + end + depend.each_line do |line| + line.gsub!(/\.o\b/, ".#{$OBJEXT}") + line.gsub!(/\$\((?:hdr|top)dir\)\/config.h/, $config_h) if $config_h + line.gsub!(%r"\$\(hdrdir\)/(?!ruby(?![^:;/\s]))", '\&ruby/') if /^\s*\w+\s*=/ !~ line + if /(?:^|[^\\])(?:\\\\)*\\$/ =~ line + (cont ||= []) << line + next + elsif cont + line = (cont << line).join + cont = nil end + ruleconv.call(line) + end + if cont + ruleconv.call(cont.join) + elsif implicit + impconv.call end depout.flatten! depout @@ -1581,7 +1579,7 @@ site-install-rb: install-rb depend = File.join(srcdir, "depend") if File.exist?(depend) - mfile.print("###\n", *depend_rules(depend)) + mfile.print("###\n", *depend_rules(File.read(depend))) else headers = %w[ruby.h defines.h] if RULE_SUBST diff --git a/win32/enc-setup.mak b/win32/enc-setup.mak index 4c2727222b..595716a5d6 100644 --- a/win32/enc-setup.mak +++ b/win32/enc-setup.mak @@ -1,4 +1,6 @@ +BUILTIN_ENCOBJS: + !include $(srcdir)/enc/Makefile.in -all: +BUILTIN_ENCOBJS: @echo BUILTIN_ENCOBJS = $(BUILTIN_ENCS:.c=.obj) >> $(MAKEFILE)