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 8
/
Copy pathconfigure.rb.in
199 lines (182 loc) · 5.27 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
189
190
191
192
193
194
195
196
197
198
199
version =
open(File.join($srcdir, "mod_ruby.h")).grep(/MOD_RUBY_STRING_VERSION/)[0]
$MAJOR, $MINOR, $TEENY = version.scan(/mod_ruby\/(\d+).(\d+).(\d+)/)[0] #/
AC_SUBST("MAJOR")
AC_SUBST("MINOR")
AC_SUBST("TEENY")
AC_PROG_INSTALL()
AC_MSG_CHECKING("whether we are using gcc")
if $CC == "gcc" || `#{$CC} -v 2>&1` =~ /gcc/
$using_gcc = true
$CFLAGS += " -Wall"
$CFLAGS += " " + ENV["CFLAGS"] if ENV.include?("CFLAGS")
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.4"
AC_MSG_ERROR("mod_ruby requires Ruby 1.6.4 or later.")
end
AC_MSG_CHECKING("for static Apache module support")
AC_ARG_WITH("apache",
" --with-apache=DIR Build static Apache module. DIR is the path
to the top-level Apache source directory") { |withval|
if withval == "yes"
AC_MSG_ERROR("You need to specify a directory with --with-apache")
end
$APACHE_SRCDIR = File.expand_path(withval)
if File.file?("#{$APACHE_SRCDIR}/src/include/httpd.h")
$APACHE_INCLUDES = "-I#{$APACHE_SRCDIR}/src/include -I#{$APACHE_SRCDIR}/src/os/unix"
elsif File.file?("#{$APACHE_SRCDIR}/include/httpd.h")
AC_MSG_ERROR("static module is not supported for Apache2. Please use --with-apxs option")
else
AC_MSG_ERROR("Unable to locate #{withval}/src/include/httpd.h")
end
$TARGET = "libruby.a"
$INSTALL_TARGET = "install-static"
st = File.stat($APACHE_SRCDIR)
$APACHE_SRC_UID = st.uid
$APACHE_SRC_GID = st.gid
AC_MSG_RESULT("yes")
}.if_not_given {
AC_MSG_RESULT("no")
}
AC_MSG_CHECKING("for dynamic Apache module support")
AC_ARG_WITH("apxs",
" --with-apxs[=FILE] Build shared Apache module. FILE is the optional
pathname to the Apache apxs tool; [apxs]") { |withval|
if $TARGET
AC_MSG_ERROR("--with-apache and --with-apxs are mutually exclusive")
end
if withval == "yes"
$APXS = "apxs"
else
$APXS = withval
end
}.if_not_given {
unless $TARGET
$APXS = "apxs"
catch :found do
for cmd in [ "apxs", "apxs2" ]
for dir in [
"/sbin", "/bin",
"/usr/sbin", "/usr/bin",
"/usr/local/sbin", "/usr/local/bin"
]
path = File.expand_path(cmd, dir)
if File.executable?(path)
$APXS = path
throw :found
end
end
end
end
end
}
if $APXS
$APACHE_INCLUDES = "-I" + `#{$APXS} -q INCLUDEDIR`.chomp
apache_cflags = ""
for x in %w(CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS)
s = `#{$APXS} -q #{x} 2> /dev/null`.chomp
if $? == 0
apache_cflags += " #{s}"
end
end
apache_cflags.gsub!(/-I\S+/) do |inc|
$APACHE_INCLUDES += " " + inc
""
end
$CFLAGS += " " + apache_cflags
$APACHE_LIBEXECDIR = `#{$APXS} -q LIBEXECDIR`.chomp
if $? != 0
AC_MSG_ERROR("failed to exec #{$APXS}")
end
if /mswin32/ =~ RUBY_PLATFORM
$APACHE_LIBDIR = `#{$APXS} -q LIBDIR 2> nul`.chomp
else
$APACHE_LIBDIR = `#{$APXS} -q LIBDIR 2> /dev/null`.chomp
end
$APACHE_LIBS = 'libapr.lib libaprutil.lib libhttpd.lib' if /mswin32/ =~ RUBY_PLATFORM
$TARGET = "mod_ruby.so"
$INSTALL_TARGET = "install-shared"
AC_MSG_RESULT("yes")
else
AC_MSG_RESULT("no")
end
AC_ARG_WITH("apr-includes",
" --with-apr-includes=DIR APR include files are in DIR") { |withval|
$APACHE_INCLUDES += " -I#{withval}"
}.if_not_given {
for dir in [ "/usr/include/apr-0" ]
if File.exist?(File.expand_path("apr.h", dir))
$APACHE_INCLUDES += " -I#{dir}"
break
end
end
}
AC_SUBST("TARGET")
AC_SUBST("INSTALL_TARGET")
AC_SUBST("APACHE_SRCDIR")
AC_SUBST("APACHE_INCLUDES")
AC_SUBST("APACHE_LIBEXECDIR")
AC_SUBST("APACHE_LIBDIR")
AC_SUBST("APACHE_LIBS")
AC_SUBST("APACHE_SRC_UID")
AC_SUBST("APACHE_SRC_GID")
AC_SUBST("LIBAPREQ_INCLUDES")
AC_SUBST("LIBAPREQ_OBJS")
case RUBY_PLATFORM
when /-aix/
$DLDFLAGS = "-Wl,-bE:mod_ruby.imp -Wl,-bI:httpd.exp -Wl,-bM:SRE -Wl,-bnoentry -lc"
open("mod_ruby.imp", "w") do |ifile|
ifile.write <<EOF
#!
ruby_module
EOF
end
print <<EOF
To build mod_ruby on the AIX platform, you need to have the apache
export file `httpd.exp' in the current directory.
Please copy <apache-src-directory>/support/httpd.exp to the current
directory before making `mod_ruby.so'.
EOF
#'
when /cygwin/
if $INSTALL_TARGET == "install-shared"
$LIBS += ' ' + File.join($APACHE_LIBEXECDIR, "cyghttpd.dll")
end
when /(ms|bcc)win32|mingw/
$DEFS = "-DWIN32"
end
librubyarg = $LIBRUBYARG.dup
Config.expand(librubyarg)
$MODULE_LIBS = "#{librubyarg} #{$LIBS}"
AC_SUBST("MODULE_LIBS")
if defined?(LINK_SO)
$LINK_SO = LINK_SO.gsub(/\$\(DLLIB\)/, '$(TARGET)').gsub(/\$\(DLDFLAGS\)/, '$(DLDFLAGS) $(XLDFLAGS)')
else
$LINK_SO = '$(LDSHARED) $(DLDFLAGS) $(XLDFLAGS) -o $(TARGET) $(OBJS) $(LIBRUBYARG) $(LIBS)'
end
AC_SUBST("LINK_SO")
unless $APACHE_LIBDIR.empty?
begin
$libpath = libpathflag("$(APACHE_LIBDIR)")
rescue NameError
$libpath = "-L$(APACHE_LIBDIR)"
end
end
AC_SUBST("libpath")
$DEFFILE = "mod_ruby-#{$arch}.def" if /(ms|bcc)win32|mingw32/ =~ RUBY_PLATFORM
AC_SUBST("DEFFILE")
AC_OUTPUT("Makefile",
"libruby.module",
"doc/Makefile")
open("mod_ruby-#{$arch}.def", "w") do |file|
file.print ""
end if /(ms|bcc)win32|mingw32/ =~ RUBY_PLATFORM
# Local variables:
# mode: Ruby
# tab-width: 8
# End: