Skip to content

Commit

Permalink
Both apr and apr-util are required to build passenger.
Browse files Browse the repository at this point in the history
The are not neccessarily installed in the same --prefix
(see ./configure)
(note, the apu-1-config does not accept the --cppflags option

With my pgollucci@apache.org HTTPD PMC hat on:

Technicallly, this is still wrong, this should be using apxs alone,
but that would have required me to refactor this and I did not have
time at the moment.   For an example of the correct way to do this,
see the apreq (libapreq2) httpd module (c-binding portion).
[apreq-dev@httpd.apache.org]

Note, Eventually, httpd will have an httpd-config similiar to
gnome-config, neon-config, serf-config, etc.... at which point
it should switch to that.
  • Loading branch information
pgollucci committed Nov 17, 2008
1 parent 54b6ecf commit 74e318f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Rakefile
Expand Up @@ -37,6 +37,7 @@ APXS2.nil? and raise "Could not find 'apxs' or 'apxs2'."
APACHE2CTL.nil? and raise "Could not find 'apachectl' or 'apache2ctl'."
HTTPD.nil? and raise "Could not find the Apache web server binary."
APR_FLAGS.nil? and raise "Could not find Apache Portable Runtime (APR)."
APU_FLAGS.nil? and raise "Could not find Apache Portable Runtime Utility (APU)."

CXX = "g++"
# _GLIBCPP__PTHREADS is for fixing Boost compilation on OpenBSD.
Expand Down Expand Up @@ -120,7 +121,7 @@ end
##### Apache module

class APACHE2
CXXFLAGS = "-I.. -fPIC #{OPTIMIZATION_FLAGS} #{APR_FLAGS} #{APXS2_FLAGS} #{CXXFLAGS}"
CXXFLAGS = "-I.. -fPIC #{OPTIMIZATION_FLAGS} #{APR_FLAGS} #{APU_FLAGS} #{APXS2_FLAGS} #{CXXFLAGS}"
OBJECTS = {
'Configuration.o' => %w(Configuration.cpp Configuration.h),
'Bucket.o' => %w(Bucket.cpp Bucket.h),
Expand Down Expand Up @@ -202,7 +203,7 @@ end
class TEST
CXXFLAGS = "#{::CXXFLAGS} -DTESTING_SPAWN_MANAGER -DTESTING_APPLICATION_POOL "

AP2_FLAGS = "-I../ext/apache2 -I../ext -Isupport #{APR_FLAGS}"
AP2_FLAGS = "-I../ext/apache2 -I../ext -Isupport #{APR_FLAGS} #{APU_FLAGS}"
AP2_OBJECTS = {
'CxxTestMain.o' => %w(CxxTestMain.cpp),
'MessageChannelTest.o' => %w(MessageChannelTest.cpp
Expand Down
1 change: 1 addition & 0 deletions bin/passenger-install-apache2-module
Expand Up @@ -48,6 +48,7 @@ class Installer
Dependencies::Apache2,
Dependencies::Apache2_DevHeaders,
Dependencies::APR_DevHeaders,
Dependencies::APU_DevHeaders,
Dependencies::FastThread,
Dependencies::Rack
]
Expand Down
11 changes: 10 additions & 1 deletion lib/passenger/dependencies.rb
Expand Up @@ -216,7 +216,7 @@ module Dependencies # :nodoc: all
end
elsif RUBY_PLATFORM =~ /freebsd/
dep.install_command = "make -C /usr/ports/www/apache22 install"
dep.provides = [Apache2_DevHeaders, APR_DevHeaders]
dep.provides = [Apache2_DevHeaders, APR_DevHeaders, APU_DevHeaders]
end
dep.website = "http://httpd.apache.org/"
end
Expand Down Expand Up @@ -270,6 +270,15 @@ module Dependencies # :nodoc: all
dep.website = "http://httpd.apache.org/"
dep.website_comments = "APR is an integrated part of Apache."
end

APU_DevHeaders = Dependency.new do |dep|
dep.name = "Apache Portable Runtime Utility (APR) development headers"
dep.define_checker do |result|
result.found(APU_CONFIG)
end
dep.website = "http://httpd.apache.org/"
dep.website_comments = "APR Utility is an integrated part of Apache."
end

FastThread = Dependency.new do |dep|
dep.name = "fastthread"
Expand Down
40 changes: 39 additions & 1 deletion lib/passenger/platform_info.rb
Expand Up @@ -164,6 +164,42 @@ def self.determine_apr_info
return [flags, libs]
end
end

def self.find_apu_config
if env_defined?('APU_CONFIG')
apr_config = ENV['APU_CONFIG']
elsif RUBY_PLATFORM =~ /darwin/ && HTTPD == "/usr/sbin/httpd"
# If we're on MacOS X, and we're compiling against the
# default provided Apache, then we'll want to query the
# correct 'apu-1-config' command. However, that command
# is not in $PATH by default. Instead, it lives in
# /Developer/SDKs/MacOSX*sdk/usr/bin.
sdk_dir = Dir["/Developer/SDKs/MacOSX*sdk"].sort.last
if sdk_dir
apu_config = "#{sdk_dir}/usr/bin/apu-1-config"
if !File.executable?(apu_config)
apu_config = nil
end
end
else
apu_config = find_command('apu-1-config')
if apu_config.nil?
apu_config = find_command('apu-config')
end
end
return apu_config
end

def self.determine_apu_info
if APU_CONFIG.nil?
return nil
else
flags = `#{APU_CONFIG} --includes`.strip
libs = `#{APU_CONFIG} --link-ld`.strip
flags.gsub!(/-O\d? /, '')
return [flags, libs]
end
end

def self.determine_multi_arch_flags
if RUBY_PLATFORM =~ /darwin/ && !HTTPD.nil?
Expand Down Expand Up @@ -269,12 +305,14 @@ def self.find_command(name)
HTTPD = find_httpd
# The absolute path to the 'apr-config' or 'apr-1-config' executable.
APR_CONFIG = find_apr_config
APU_CONFIG = find_apu_config

# The C compiler flags that are necessary to compile an Apache module.
APXS2_FLAGS = determine_apxs2_flags
# The C compiler flags that are necessary for programs that use APR.
APR_FLAGS, APR_LIBS = determine_apr_info

APU_FLAGS, APU_LIBS = determine_apu_info

# The C compiler flags that are necessary for building binaries in the same architecture(s) as Apache.
MULTI_ARCH_FLAGS = determine_multi_arch_flags

Expand Down

0 comments on commit 74e318f

Please sign in to comment.