Skip to content

Commit

Permalink
* Makefile.in, configure.in, lib/mkmf.rb, */Makefile.sub: specify
Browse files Browse the repository at this point in the history
  compiled output file name explicitly.

* enc/Makefile.in, enc/depend: now makes compiler to put generated
  files under directories corresnponding to the each source.
  enc/trans supported.

* enc/make_encmake.rb: evaluates depend file before Makefile.in so
  that the former can influence to CONFIG.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Dec 24, 2007
1 parent 7c45c61 commit 8d292a0
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 82 deletions.
14 changes: 13 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
Mon Dec 24 12:49:54 2007 Nobuyoshi Nakada <[email protected]>

* Makefile.in, configure.in, lib/mkmf.rb, */Makefile.sub: specify
compiled output file name explicitly.

* enc/Makefile.in, enc/depend: now makes compiler to put generated
files under directories corresnponding to the each source.
enc/trans supported.

* enc/make_encmake.rb: evaluates depend file before Makefile.in so
that the former can influence to CONFIG.

Mon Dec 24 12:35:03 2007 Nobuyoshi Nakada <[email protected]>

* win{32,ce}/Makefile.sub (MFLAGS): defaulted to -l.

Mon Dec 24 12:08:10 2007 Eric Hodel <[email protected]>

* /, ext/: Add svn:ignore for OS X Xcode 3's conftest.dSYM
directories.
directories.

Mon Dec 24 11:56:31 2007 Nobuyoshi Nakada <[email protected]>

Expand Down
7 changes: 4 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ VPATH = $(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir):$(srcdir)/enc:$(srcdir)/mis

empty =
OUTFLAG = @OUTFLAG@$(empty)
COUTFLAG = @COUTFLAG@$(empty)
CFLAGS = @CFLAGS@ @ARCH_FLAG@
XCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) @XCFLAGS@
CPPFLAGS = @CPPFLAGS@
Expand Down Expand Up @@ -182,13 +183,13 @@ lex.c: keywords
fi

.c.@OBJEXT@:
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c $<
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $<

.s.@OBJEXT@:
$(AS) $(ASFLAGS) -o $@ $<

.c.S:
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -S $<
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -S $<

clean-local::
@$(RM) ext/extinit.c ext/extinit.$(OBJEXT)
Expand All @@ -197,4 +198,4 @@ distclean-local::
@$(RM) ext/config.cache $(RBCONFIG)

ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP)
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(OUTFLAG)$@ -c ext/extinit.c
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c
16 changes: 9 additions & 7 deletions bcc32/Makefile.sub
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ RDOCTARGET = install-doc
!endif

OUTFLAG = -o
COUTFLAG = -o
!ifndef CFLAGS
CFLAGS = -q -tWR -tWC $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) -w- -wsus -wcpt -wdup -wext -wrng -wrpt -wzdi
!endif
Expand Down Expand Up @@ -214,10 +215,10 @@ VPATH = $(arch_hdrdir)/ruby;$(hdrdir)/ruby;$(srcdir);$(srcdir)/enc;$(srcdir)/mis
.path. = $(srcdir)

.c.obj:
$(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) -c $(<:/=\)
$(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:/=\)

.c.asm:
$(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) -S $(<:\=/)
$(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) $(COUTFLAG)$@ -S $(<:\=/)

.rc.res:
$(RC) $(RFLAGS) -I. -I$(<D). $(iconinc) -I$(srcdir)/win32 $(RFLAGS) -fo$@ $(<:/=\)
Expand Down Expand Up @@ -431,13 +432,14 @@ s,@SOLIBS@,$(SOLIBS),;t t
s,@DLDLIBS@,$(DLDLIBS),;t t
s,@ENABLE_SHARED@,yes,;t t
s,@OUTFLAG@,$(OUTFLAG),;t t
s,@COUTFLAG@,$(COUTFLAG),;t t
s,@CPPOUTFILE@,,;t t
s,@LIBPATHFLAG@, -L"%s",;t t
s,@RPATHFLAG@,,;t t
s,@LIBARG@,%s.lib,;t t
s,@LINK_SO@,$$(LDSHARED) $$(DLDFLAGS) $$(LIBPATH) $$(OBJS), $$(@:/=\), nul, $$(LIBS) $$(LOCAL_LIBS), $$(DEFFILE), $$(RESFILE),;t t
s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) -c $$(<:/=\),;t t
s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -P -c $$(<:/=\),;t t
s,@LINK_SO@,$$(LDSHARED) $$(DLDFLAGS) $$(LIBPATH) $$(OBJS:/=\), $$(@:/=\), nul, $$(LIBS) $$(LOCAL_LIBS), $$(DEFFILE:/=\), $$(RESFILE:/=\),;t t
s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) $(COUTFLAG)$$(@) -c $$(<:/=\),;t t
s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -P $(COUTFLAG)$$(@) -c $$(<:/=\),;t t
s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: {$$(topdir)}.%s{}.%s: {$$(hdrdir)}.%s{}.%s: .%s.%s:,;t t
s,@RULE_SUBST@,{.;$$(VPATH)}%s,;t t
s,@COMMON_LIBS@,m advapi32 avicap32 avifil32 cap comctl32 comdlg32 dlcapi gdi32 glu32 imagehlp imm32 inetmib1 kernel32 loadperf lsapi32 lz32 mapi32 mgmtapi mpr msacm32 msvfw32 nddeapi netapi32 ole32 oleaut32 oledlg olepro32 opengl32 pdh pkpd32 rasapi32 rasdlg rassapi rpcrt4 setupapi shell32 shfolder snmpapi sporder tapi32 url user32 vdmdbg version win32spl winmm wintrust wsock32,;t t
Expand All @@ -460,7 +462,7 @@ s,@top_srcdir@,$(srcdir),;t t

miniruby$(EXEEXT):
@echo $(LIBS)
$(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT),$@,nul,$(LIBS)
$(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS:/=\) $(DMYEXT),$@,nul,$(LIBS)

$(PROGRAM): $(MAINOBJ) $(LIBRUBY_SO) $(RUBY_INSTALL_NAME).res
$(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ),$@,nul,$(LIBRUBYARG) $(LIBS),,$(RUBY_INSTALL_NAME).res
Expand Down Expand Up @@ -518,7 +520,7 @@ distclean-local::
@$(RM) $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc

ext/extinit.obj: ext/extinit.c $(SETUP)
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -o$@ -c ext/extinit.c
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c

main.$(OBJEXT): win32.h
ascii.$(OBJEXT): win32.h
Expand Down
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ $(RBCONFIG): $(srcdir)/mkconfig.rb config.status $(PREP)
-so_name=$(RUBY_SO_NAME) rbconfig.rb

encs: enc.mk
$(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTOUT)/$(arch)/enc"
$(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTOUT)/$(arch)/enc/trans" enc/trans
$(MAKE) -f enc.mk $(MFLAGS)

enc.mk: $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc/depend \
Expand Down
2 changes: 2 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ RUBY_PROG_GNU_LD
RUBY_CPPOUTFILE

: ${OUTFLAG='-o '}
: ${COUTFLAG=${OUTFLAG}}
AC_SUBST(OUTFLAG)
AC_SUBST(COUTFLAG)

RUBY_MINGW32

Expand Down
16 changes: 13 additions & 3 deletions enc/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
srcdir = @srcdir@
encsrcdir = @srcdir@
topdir = .
libdir = @libdir@
top_srcdir = $(srcdir:/enc=)
top_srcdir = $(encsrcdir:/enc=)
srcdir = $(top_srcdir)
arch = @arch@
EXTOUT = @EXTOUT@
hdrdir = $(top_srcdir)/include
hdrdir = $(srcdir)/include
arch_hdrdir = $(EXTOUT)/include/$(arch)
ENCSODIR = $(EXTOUT)/$(arch)/enc
TRANSSODIR = $(ENCSODIR)/trans
DLEXT = @DLEXT@
OBJEXT = @OBJEXT@

Expand All @@ -22,6 +24,7 @@ LIBRUBYARG_STATIC = $(LIBRUBYARG_SHARED)
empty =
CC = @CC@
OUTFLAG = @OUTFLAG@$(empty)
COUTFLAG = @COUTFLAG@$(empty)
CFLAGS = $(CCDLFLAGS) @CFLAGS@ @ARCH_FLAG@
CCDLFLAGS = @CCDLFLAGS@
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir)
Expand All @@ -34,3 +37,10 @@ LDSHARED = @LDSHARED@
DLDFLAGS = @DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@

RM = @RM@

all:

clean:

distclean: clean
$(RM) enc.mk
67 changes: 38 additions & 29 deletions enc/depend
Original file line number Diff line number Diff line change
@@ -1,54 +1,63 @@
% deffile = (true if /\$\(DEFFILE\)/ =~ CONFIG["LINK_SO"])
% encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS
% encs.each {|e| e.chomp!(".c")}
% encs = encs.sort_by {|e| e.split(/(\d+)/).map {|n| Integer(n) rescue n}}

VPATH = <%=%w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(top_srcdir) $(srcdir)].join(CONFIG["PATH_SEPARATOR"])%>
% alphanumeric_order = proc {|e| e.split(/(\d+)/).map {|n| Integer(n) rescue n}}
% encs = encs.sort_by(&alphanumeric_order)
% trans = Dir.open($srcdir+"/trans") {|d| d.select {|e| e.chomp!('.c')}}
% trans = trans.sort_by(&alphanumeric_order)
% trans.map! {|e| "trans/#{e}"}
% dependencies = encs + trans

VPATH = <%=%w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(srcdir) $(encsrcdir)].join(CONFIG["PATH_SEPARATOR"])%>
LIBPATH = <%=libpathflag($DEFLIBPATH)%>

ENCOBJS = <%=encs.map {|e|"#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if encs.size>1%>
ENCDEFS = <%=encs.map {|e|"#{e}.def"}.join(" \\\n\t ") if DEFFILE%><%="\n" if encs.size>1%>
ENCOBJS = <%=encs.map {|e|"enc/#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if encs.size>1%>
ENCDEFS = <%=encs.map {|e|"enc/#{e}.def"}.join(" \\\n\t ") if deffile%><%="\n" if encs.size>1%>
ENCSOS = <%=encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%>

all: $(ENCSOS)
TRANSOBJS = <%=trans.map {|e|"enc/#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
TRANSDEFS = <%=trans.map {|e|"enc/#{e}.def"}.join(" \\\n\t ") if deffile%><%="\n" if trans.size>1%>
TRANSSOS = <%=trans.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%>

all: $(ENCSOS) $(TRANSSOS)

% COMPILE_RULES.each do |rule|
<%= rule % %w[c $(OBJEXT)] %>
<%=COMPILE_C%>

% end
% unless encs.empty?
% unless encs.empty? or trans.empty?

% unless encs.empty?
$(ENCOBJS): regenc.h oniguruma.h config.h defines.h

% encs.each do |e|
<%=e%>.so: $(ENCSODIR)/<%=e%>.$(DLEXT)
% end
% end
% unless trans.empty?
$(TRANSOBJS): ruby.h intern.h config.h defines.h transcode_data.h
% end

% end
% link_so = LINK_SO.gsub(/\n/, "\n\t")
% encs.each do |e|
% deps = "#{e}.$(OBJEXT)"
% deps << " #{e}-$(arch).def" if DEFFILE
$(ENCSODIR)/<%=e%>.$(DLEXT): <%=deps%>
<%=link_so.sub(/\$\(OBJS\)/, deps)%>

% end
% if DEFFILE
% encs.each do |e|
<%=e%>-$(arch).def: enc.mk
echo EXPORTS > $@
echo <%=EXPORT_PREFIX%>Init_<%=e%> >> $@

% link_so.gsub!(/(-(?:implib|pdb):\S+)-\$\(arch\)\./, '\1.')
% dependencies.each do |e|
% obj = "enc/#{e}.$(OBJEXT)"
% df = ("enc/#{e}.def" if deffile)
$(ENCSODIR)/<%=e%>.$(DLEXT): <%=obj%>
% if df
echo EXPORTS > <%=df%>
echo <%=EXPORT_PREFIX%>Init_<%=File.basename(e)%> >> <%=df%>
% end
<%=link_so.sub(/\$\(OBJS\)/) {obj}.sub(/\$\(DEFFILE\)/) {df}.gsub(/-(?:implib|pdb):/) {|s|"#{s}enc/#{e.sub(/[^\/]+\z/, '')}"}%>

% end
% encs.each do |e|
<%=e%>.$(OBJEXT): <%=e%>.c
% dependencies.each do |e|
enc/<%=e%>.$(OBJEXT): $(srcdir)/enc/<%=e%>.c
<%=COMPILE_C.sub(/\$\(<(?:.*)\)/) {"$(srcdir)/enc/#{e}.c"}%>
% end

clean:
$(RM) $(ENCSOS)
$(RM) $(ENCDEFS)
$(RM) $(ENCOBJS)

distclean: clean
$(RM) enc.mk
$(RM) $(TRANSSOS)
$(RM) $(TRANSDEFS)
$(RM) $(TRANSOBJS)
12 changes: 6 additions & 6 deletions enc/make_encmake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
BUILTIN_ENCS = []
end

DEFFILE = (true if CONFIG["DLDFLAGS"].sub!(/\s+-def:\$\(DEFFILE\)\s+/, ' '))

mkin = File.read(File.join($srcdir, "Makefile.in"))
mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]}
if File.exist?(depend = File.join($srcdir, "depend"))
erb = ERB.new(File.read(depend), nil, '%')
erb.filename = depend
tmp = erb.result(binding)
mkin << "\n#### depend ####\n\n" << depend_rules(tmp).join
dep = "\n#### depend ####\n\n" << depend_rules(tmp).join
else
dep = ""
end
mkin = File.read(File.join($srcdir, "Makefile.in"))
mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]}
open(ARGV[0], 'wb') {|f|
f.puts mkin
f.puts mkin, dep
}
9 changes: 6 additions & 3 deletions lib/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def map_dir(dir, map = nil)
end

OUTFLAG = CONFIG['OUTFLAG']
COUTFLAG = CONFIG['COUTFLAG']
CPPOUTFILE = CONFIG['CPPOUTFILE']

CONFTEST_C = "conftest.c".freeze
Expand Down Expand Up @@ -1211,6 +1212,8 @@ def configuration(srcdir)
LIBRUBY_A = #{CONFIG['LIBRUBY_A']}
LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED
LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
OUTFLAG = #{OUTFLAG}
COUTFLAG = #{COUTFLAG}
RUBY_EXTCONF_H = #{$extconf_h}
CFLAGS = #{$static ? '' : CONFIG['CCDLFLAGS']} #$CFLAGS #$ARCH_FLAG
Expand Down Expand Up @@ -1289,7 +1292,7 @@ def depend_rules(depend)
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(:%))
line.gsub!(%r"(?<=\s)(?![./\\])([^$(){}+=:\s,]+)(?=\s|\z)", &RULE_SUBST.method(:%))
end
depout << line
end
Expand Down Expand Up @@ -1700,8 +1703,8 @@ def mkmf_failed(path)

COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
RULE_SUBST = config_string('RULE_SUBST')
COMPILE_C = config_string('COMPILE_C') || '$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<'
COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<'
COMPILE_C = config_string('COMPILE_C') || '$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<'
COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<'
TRY_LINK = config_string('TRY_LINK') ||
"$(CC) #{OUTFLAG}conftest $(INCFLAGS) $(CPPFLAGS) " \
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
Expand Down
Loading

0 comments on commit 8d292a0

Please sign in to comment.