aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2014-05-15 23:45:42 -0500
committerJack Nagel2014-05-16 00:14:11 -0500
commitb623d43a14dccff6de23d4e8653ace26be23dd98 (patch)
tree11d64b50b34a7377e31f442e670946fa0024c025
parent8e29695ff35506cf4156c5075e71e4e3903f86ac (diff)
downloadhomebrew-b623d43a14dccff6de23d4e8653ace26be23dd98.tar.bz2
openssl: add universal option
Closes #28448.
-rw-r--r--Library/Formula/openssl.rb86
1 files changed, 69 insertions, 17 deletions
diff --git a/Library/Formula/openssl.rb b/Library/Formula/openssl.rb
index 2448c3163..91e62ea12 100644
--- a/Library/Formula/openssl.rb
+++ b/Library/Formula/openssl.rb
@@ -12,33 +12,85 @@ class Openssl < Formula
sha1 "f12f352e67e5b131c1935040f8d2ca24107ebfca" => :lion
end
- depends_on "makedepend" => :build if MacOS.prefer_64_bit?
+ option :universal
+
+ depends_on "makedepend" => :build
keg_only :provided_by_osx,
"The OpenSSL provided by OS X is too old for some software."
+ def arch_args
+ {
+ :x86_64 => %w[darwin64-x86_64-cc enable-ec_nistp-64_gcc_128],
+ :i386 => %w[darwin-i386-cc],
+ }
+ end
+
+ def configure_args; %W[
+ --prefix=#{prefix}
+ --openssldir=#{openssldir}
+ zlib-dynamic
+ shared
+ enable-cms
+ ]
+ end
+
def install
- args = %W[./Configure
- --prefix=#{prefix}
- --openssldir=#{openssldir}
- zlib-dynamic
- shared
- enable-cms
- ]
-
- if MacOS.prefer_64_bit?
- args << "darwin64-x86_64-cc" << "enable-ec_nistp_64_gcc_128"
+ if build.universal?
+ ENV.permit_arch_flags
+ archs = Hardware::CPU.universal_archs
+ elsif MacOS.prefer_64_bit?
+ archs = [Hardware::CPU.arch_64_bit]
else
- args << "darwin-i386-cc"
+ archs = [Hardware::CPU.arch_32_bit]
end
- system "perl", *args
+ dirs = []
+
+ archs.each do |arch|
+ if build.universal?
+ dir = "build-#{arch}"
+ dirs << dir
+ mkdir dir
+ mkdir "#{dir}/engines"
+ system "make", "clean"
+ end
+
+ ENV.deparallelize
+ system "perl", "./Configure", *(configure_args + arch_args[arch])
+ system "make", "depend"
+ system "make"
+ system "make", "test"
+
+ if build.universal?
+ cp Dir["*.?.?.?.dylib", "*.a", "apps/openssl"], dir
+ cp Dir["engines/**/*.dylib"], "#{dir}/engines"
+ end
+ end
- ENV.deparallelize
- system "make", "depend" if MacOS.prefer_64_bit?
- system "make"
- system "make", "test"
system "make", "install", "MANDIR=#{man}", "MANSUFFIX=ssl"
+
+ if build.universal?
+ %w[libcrypto libssl].each do |libname|
+ system "lipo", "-create", "#{dirs.first}/#{libname}.1.0.0.dylib",
+ "#{dirs.last}/#{libname}.1.0.0.dylib",
+ "-output", "#{lib}/#{libname}.1.0.0.dylib"
+ system "lipo", "-create", "#{dirs.first}/#{libname}.a",
+ "#{dirs.last}/#{libname}.a",
+ "-output", "#{lib}/#{libname}.a"
+ end
+
+ Dir.glob("#{dirs.first}/engines/*.dylib") do |engine|
+ libname = File.basename(engine)
+ system "lipo", "-create", "#{dirs.first}/engines/#{libname}",
+ "#{dirs.last}/engines/#{libname}",
+ "-output", "#{lib}/engines/#{libname}"
+ end
+
+ system "lipo", "-create", "#{dirs.first}/openssl",
+ "#{dirs.last}/openssl",
+ "-output", "#{bin}/openssl"
+ end
end
def openssldir