Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
189 lines (173 sloc) 5.24 KB
$MAJOR, $MINOR, $TEENY =
open(File.join($srcdir, "eruby.h")).grep(/ERUBY_VERSION/)[0].scan(/(\d+).(\d+).(\d+)/)[0]
$MAJOR_MINOR = format("%02d", ($MAJOR.to_i * 10 + $MINOR.to_i))
AC_SUBST("MAJOR")
AC_SUBST("MINOR")
AC_SUBST("TEENY")
AC_SUBST("MAJOR_MINOR")
AC_MSG_CHECKING("whether we are using gcc")
if $CC == "gcc" || `#{$CC} -v 2>&1` =~ /gcc/
$using_gcc = true
$CFLAGS += " -Wall"
else
$using_gcc = false
end
AC_MSG_RESULT($using_gcc)
AC_MSG_CHECKING("Ruby version")
AC_MSG_RESULT(RUBY_VERSION)
if RUBY_VERSION < "1.6"
AC_MSG_ERROR("eruby requires Ruby 1.6.x or later.")
end
AC_MSG_CHECKING("for default charset")
$DEFAULT_CHARSET = "iso-8859-1"
AC_ARG_WITH("charset",
" --with-charset=CHARSET default charset is CHARSET [iso-8859-1]") { |withval|
$DEFAULT_CHARSET = withval
}
AC_MSG_RESULT($DEFAULT_CHARSET)
AC_DEFINE("ERUBY_DEFAULT_CHARSET", $DEFAULT_CHARSET)
AC_MSG_CHECKING("whether enable shared")
$ENABLE_SHARED = false
AC_ARG_ENABLE("shared",
" --enable-shared build a shared library for eruby") { |enableval|
if enableval == "yes"
if /-mswin32/ =~ RUBY_PLATFORM
AC_MSG_ERROR("can't enable shared on mswin32")
end
$ENABLE_SHARED = true
end
}
AC_MSG_RESULT($ENABLE_SHARED)
$LIBERUBY_A = "liberuby.a"
$LIBERUBY = "${LIBERUBY_A}"
$LIBERUBYARG="$(LIBERUBY_A)"
$LIBERUBY_SO = "liberuby.#{CONFIG['DLEXT']}.$(MAJOR).$(MINOR).$(TEENY)"
$LIBERUBY_ALIASES = "liberuby.#{CONFIG['DLEXT']}"
if $ENABLE_SHARED
$LIBERUBY = "${LIBERUBY_SO}"
$LIBERUBYARG = "-L. -leruby"
case RUBY_PLATFORM
when /-sunos4/
$LIBERUBY_ALIASES = "liberuby.so.$(MAJOR).$(MINOR) liberuby.so"
when /-linux/
$DLDFLAGS = '-Wl,-soname,liberuby.so.$(MAJOR).$(MINOR)'
$LIBERUBY_ALIASES = "liberuby.so.$(MAJOR).$(MINOR) liberuby.so"
when /-(freebsd|netbsd)/
$LIBERUBY_SO = "liberuby.so.$(MAJOR).$(MINOR)"
if /elf/ =~ RUBY_PLATFORM || /-freebsd[3-9]/ =~ RUBY_PLATFORM
$LIBERUBY_SO = "liberuby.so.$(MAJOR_MINOR)"
$LIBERUBY_ALIASES = "liberuby.so"
else
$LIBERUBY_ALIASES = "liberuby.so.$(MAJOR) liberuby.so"
end
when /-solaris/
$XLDFLAGS = "-R$(prefix)/lib"
when /-hpux/
$XLDFLAGS = "-Wl,+s,+b,$(prefix)/lib"
$LIBERUBY_SO = "liberuby.sl.$(MAJOR).$(MINOR).$(TEENY)"
$LIBERUBY_ALIASES = 'liberuby.sl.$(MAJOR).$(MINOR) liberuby.sl'
when /-aix/
$DLDFLAGS = '-Wl,-bE:eruby.imp'
$LIBERUBYARG = "-L$(prefix)/lib -Wl,liberuby.so"
if $DLDFLAGS !~ /-Wl,/
$LIBRUBYARG.gsub!(/-Wl,/, '')
$XLDFLAGS.gsub!(/-Wl,/, '')
$DLDFLAGS.gsub!(/-Wl,/, '')
end
print "creating eruby.imp\n"
ifile = open("eruby.imp", "w")
begin
ifile.write <<EOIF
#!
ruby_filename
eruby_mode
eruby_noheader
eruby_charset
EOIF
ensure
ifile.close
end
end
end
if /-mswin32/ =~ RUBY_PLATFORM
$AR = "lib"
$AROPT = "/out:$@"
$LIBERUBY_A = "liberuby.lib"
$LIBERUBY = "$(LIBERUBY_A)"
$LIBRUBYARG.gsub!(Regexp.compile(Regexp.quote(CONFIG["RUBY_SO_NAME"] + ".lib")), CONFIG["LIBRUBY_A"])
if /nmake/i =~ $make
$LD = "$(CC)"
$VPATH = "{$(VPATH)}"
elsif RUBY_VERSION < "1.8"
$LD = "env LIB='$(subst /,\\\\,$(libdir));$(LIB)' $(CC)"
else
$LD = "$(CC)"
end
else
$AROPT = "rcu $@"
end
AC_SUBST("LIBERUBY_A")
AC_SUBST("LIBERUBY")
AC_SUBST("LIBERUBYARG")
AC_SUBST("LIBERUBY_SO")
AC_SUBST("LIBERUBY_ALIASES")
AC_SUBST("AROPT")
$EXT_DLDFLAGS = CONFIG["DLDFLAGS"]
if $RUBY_SHARED || /mswin32/ =~ RUBY_PLATFORM
$EXT_LIBRUBYARG = "$(LIBRUBYARG)"
else
$EXT_LIBRUBYARG = ""
end
if /mswin32/ =~ RUBY_PLATFORM
if RUBY_VERSION < "1.8"
if /nmake/i =~ $make
$MKERUBY = "set LIB=$(libdir:/=\\);$(LIB)\n\t"
else
$MKERUBY = "\tenv LIB='$(subst /,\\\\,$(LIBPATH)); $(EXT_LIBRUBYARG) $(LIB)' \\\n\t"
end
$MKERUBY << "$(LD) $(LDFLAGS) $(XLDFLAGS) $(OBJS) $(LIBERUBYARG) $(LIBRUBYARG) $(LIBS) -Fe$@"
else
$MKERUBY = "$(LD) $(OBJS) $(LIBERUBYARG) $(LIBRUBYARG) $(LIBS) -Fe$@ $(LDFLAGS) $(XLDFLAGS)"
end
else
$MKERUBY = "$(LD) $(LDFLAGS) $(XLDFLAGS) $(OBJS) $(LIBERUBYARG) $(LIBRUBYARG) $(LIBS) -o $@"
end
if $DLEXT != $OBJEXT
if /mswin32/ =~ RUBY_PLATFORM
if RUBY_VERSION < "1.8"
if /nmake/i =~ $make
$MKDLLIB = "set LIB=$(libdir:/=\\);$(LIB)\n\t"
else
$MKDLLIB = "\tenv LIB='$(subst /,\\\\,$(LIBPATH)); $(EXT_LIBRUBYARG) $(LIB)' \\\n\t"
end
$MKDLLIB << "$(LDSHARED) $(EXT_DLDFLAGS) -Fe$(DLLIB) $(EXT_OBJS) $(XLDFLAGS) $(LIBERUBYARG) $(EXT_LIBRUBYARG) $(LIBS) -link /INCREMENTAL:no /EXPORT:Init_eruby"
else
$DEFFILE = 'eruby.def'
File.open($DEFFILE, 'w') do |deffile|
deffile.puts "EXPORTS"
deffile.puts "Init_eruby"
end
$MKDLLIB = "$(LDSHARED) $(EXT_OBJS) $(LIBS) $(LIBERUBYARG) $(EXT_LIBRUBYARG) -Fe$(DLLIB) $(EXT_DLDFLAGS) $(XLDFLAGS)"
end
else
$MKDLLIB = "$(LDSHARED) $(EXT_DLDFLAGS) -o $(DLLIB) $(EXT_OBJS) $(XLDFLAGS) $(LIBERUBYARG) $(EXT_LIBRUBYARG) $(LIBS)"
end
else
case RUBY_PLATFORM
when "m68k-human"
$MKDLLIB = "ar cru $(DLLIB) $(EXT_OBJS) $(LIBS)"
else
$MKDLLIB = "ld $(DLL_DLDFLAGS) -r -o $(DLLIB) $(EXT_OBJS) $(LIBERUBYARG) $(EXT_LIBRUBYARG) $(LIBS)"
end
end
AC_SUBST("EXT_DLDFLAGS")
AC_SUBST("EXT_LIBRUBYARG")
AC_SUBST("MKERUBY")
AC_SUBST("MKDLLIB")
AC_SUBST("DEFFILE")
AC_CONFIG_HEADER("config.h")
AC_OUTPUT("Makefile")
# Local variables:
# mode: Ruby
# tab-width: 8
# End: