This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.rb.in
188 lines (173 loc) · 5.24 KB
/
configure.rb.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
$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: