Skip to content
Browse files

Autodetect and use the APR provided by OS X's Developer SDK, whenever…

… appropriate.
  • Loading branch information...
1 parent d790862 commit 94f3e2afe4985aedb9d3174d82abdcc3a83aca36 @FooBarWidget FooBarWidget committed
Showing with 31 additions and 18 deletions.
  1. +4 −0 lib/passenger/dependencies.rb
  2. +27 −18 lib/passenger/platform_info.rb
View
4 lib/passenger/dependencies.rb
@@ -259,6 +259,10 @@ module Dependencies # :nodoc: all
when :gentoo
dep.install_command = "emerge -av apr"
end
+ elsif RUBY_PLATFORM =~ /darwin/
+ dep.install_instructions = "Please install Apache from MacPorts, which will " <<
+ "provide APR automatically. <b>Or</b>, if you're installing against MacOS X's " <<
+ "default provided Apache, then please install the OS X Developer SDK."
end
dep.website = "http://httpd.apache.org/"
dep.website_comments = "APR is an integrated part of Apache."
View
45 lib/passenger/platform_info.rb
@@ -121,26 +121,35 @@ def self.determine_apxs2_flags
end
def self.determine_apr1_info
- flags = nil
- libs = nil
- if find_command('pkg-config')
- flags = `pkg-config --cflags apr-1 apr-util-1 2>/dev/null`.strip
- libs = `pkg-config --libs apr-1 apr-util-1 2>/dev/null`.strip
- end
- if (flags.nil? || flags.empty?) && (libs.nil? || libs.empty?)
- apr_config = find_command('apr-1-config')
- if apr_config.nil?
- apr_config = find_command('apr-config')
- end
- if apr_config.nil?
- return nil
- else
- flags = `#{apr_config} --cppflags --includes`.strip
- libs = `#{apr_config} --link-ld`.strip
+ # If we're on MacOS X, and we're compiling against the
+ # default provided Apache, then we'll want to query the
+ # correct 'apr-1-config' command. However, that command
+ # is not in $PATH by default. Instead, it lives in
+ # /Developer/SDKs/MacOSX*sdk/usr/bin.
+ # So we forcefully add this path to $PATH, if we notice
+ # that we're compiling against the default Apache.
+ if RUBY_PLATFORM =~ /darwin/ && HTTPD == "/usr/sbin/httpd"
+ sdk_dir = Dir["/Developer/SDKs/MacOSX*sdk"].sort.last
+ if sdk_dir
+ sdk_bindir = "#{sdk_dir}/usr/bin"
+ if !ENV['PATH'].split(':').include?(sdk_bindir)
+ ENV['PATH'] = "#{sdk_bindir}:#{ENV['PATH']}"
+ end
end
end
- flags.gsub!(/-O\d? /, '')
- return [flags, libs]
+
+ apr_config = find_command('apr-1-config')
+ if apr_config.nil?
+ apr_config = find_command('apr-config')
+ end
+ if apr_config.nil?
+ return nil
+ else
+ flags = `#{apr_config} --cppflags --includes`.strip
+ libs = `#{apr_config} --link-ld`.strip
+ flags.gsub!(/-O\d? /, '')
+ return [flags, libs]
+ end
end
def self.determine_multi_arch_flags

0 comments on commit 94f3e2a

Please sign in to comment.
Something went wrong with that request. Please try again.