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 </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: