|
| 1 | +component 'openssl' do |pkg, settings, platform| |
| 2 | + pkg.version '1.1.0h' |
| 3 | + pkg.md5sum '5271477e4d93f4ea032b665ef095ff24' |
| 4 | + pkg.url "https://openssl.org/source/openssl-#{pkg.get_version}.tar.gz" |
| 5 | + pkg.mirror "#{settings[:buildsources_url]}/openssl-#{pkg.get_version}.tar.gz" |
| 6 | + |
| 7 | + ############################# |
| 8 | + # ENVIRONMENT, FLAGS, TARGETS |
| 9 | + ############################# |
| 10 | + |
| 11 | + target = cflags = ldflags = sslflags = '' |
| 12 | + |
| 13 | + if platform.is_windows? |
| 14 | + pkg.environment 'PATH', "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)" |
| 15 | + pkg.environment 'CYGWIN', settings[:cygwin] |
| 16 | + pkg.environment 'CC', settings[:cc] |
| 17 | + pkg.environment 'CXX', settings[:cxx] |
| 18 | + pkg.environment 'MAKE', platform[:make] |
| 19 | + |
| 20 | + target = platform.architecture == 'x64' ? 'mingw64' : 'mingw' |
| 21 | + cflags = settings[:cflags] |
| 22 | + ldflags = settings[:ldflags] |
| 23 | + elsif platform.is_cross_compiled_linux? |
| 24 | + pkg.environment 'PATH', "/opt/pl-build-tools/bin:$$PATH" |
| 25 | + pkg.environment 'CC', "/opt/pl-build-tools/bin/#{settings[:platform_triple]}-gcc" |
| 26 | + |
| 27 | + cflags = "#{settings[:cflags]} -fPIC" |
| 28 | + ldflags = "-Wl,-rpath=/opt/pl-build-tools/#{settings[:platform_triple]}/lib -Wl,-rpath=#{settings[:libdir]} -L/opt/pl-build-tools/#{settings[:platform_triple]}/lib" |
| 29 | + target = if platform.architecture == 'aarch64' |
| 30 | + 'linux-aarch64' |
| 31 | + elsif platform.name =~ /debian-8-arm/ |
| 32 | + 'linux-armv4' |
| 33 | + elsif platform.architecture =~ /ppc64/ |
| 34 | + 'linux-ppc64le' |
| 35 | + elsif platform.architecture == 's390x' |
| 36 | + 'linux64-s390x' |
| 37 | + end |
| 38 | + elsif platform.is_aix? |
| 39 | + pkg.environment 'CC', '/opt/pl-build-tools/bin/gcc' |
| 40 | + |
| 41 | + cflags = '$${CFLAGS} -static-libgcc' |
| 42 | + target = 'aix-gcc' |
| 43 | + elsif platform.is_solaris? |
| 44 | + pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin:/usr/ccs/bin:/usr/sfw/bin' |
| 45 | + pkg.environment 'CC', "/opt/pl-build-tools/bin/#{settings[:platform_triple]}-gcc" |
| 46 | + |
| 47 | + cflags = "#{settings[:cflags]} -fPIC" |
| 48 | + ldflags = "-R/opt/pl-build-tools/#{settings[:platform_triple]}/lib -Wl,-rpath=#{settings[:libdir]} -L/opt/pl-build-tools/#{settings[:platform_triple]}/lib" |
| 49 | + target = platform.architecture =~ /86/ ? 'solaris-x86-gcc' : 'solaris-sparcv9-gcc' |
| 50 | + elsif platform.is_macos? |
| 51 | + pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' |
| 52 | + |
| 53 | + cflags = settings[:cflags] |
| 54 | + target = 'darwin64-x86_64-cc' |
| 55 | + elsif platform.is_linux? |
| 56 | + pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' |
| 57 | + |
| 58 | + cflags = settings[:cflags] |
| 59 | + ldflags = "#{settings[:ldflags]} -Wl,-z,relro" |
| 60 | + if platform.architecture =~ /86$/ |
| 61 | + target = 'linux-elf' |
| 62 | + sslflags = '386' |
| 63 | + elsif platform.architecture =~ /64$/ |
| 64 | + target = 'linux-x86_64' |
| 65 | + end |
| 66 | + end |
| 67 | + |
| 68 | + #################### |
| 69 | + # BUILD REQUIREMENTS |
| 70 | + #################### |
| 71 | + |
| 72 | + pkg.build_requires "runtime-#{settings[:runtime_project]}" |
| 73 | + |
| 74 | + ########### |
| 75 | + # CONFIGURE |
| 76 | + ########### |
| 77 | + |
| 78 | + # OpenSSL fails to work on aarch unless we turn down the compiler optimization. |
| 79 | + # See PA-2135 for details |
| 80 | + if platform.architecture =~ /aarch/ |
| 81 | + pkg.apply_patch 'resources/patches/openssl/turn-down-optimization-on-aarch.patch' |
| 82 | + end |
| 83 | + |
| 84 | + # OpenSSL Configure doesn't honor CFLAGS or LDFLAGS as environment variables. |
| 85 | + # Instead, those should be passed to Configure at the end of its options, as |
| 86 | + # any unrecognized options are passed straight through to ${CC}. Defining |
| 87 | + # --libdir ensures that we avoid the multilib (lib/ vs. lib64/) problem, |
| 88 | + # since configure uses the existence of a lib64 directory to determine |
| 89 | + # if it should install its own libs into a multilib dir. Yay OpenSSL! |
| 90 | + configure_flags = [ |
| 91 | + "--prefix=#{settings[:prefix]}", |
| 92 | + '--libdir=lib', |
| 93 | + "--openssldir=#{settings[:prefix]}/ssl", |
| 94 | + 'shared', |
| 95 | + 'no-asm', |
| 96 | + target, |
| 97 | + sslflags, |
| 98 | + 'no-camellia', |
| 99 | + 'no-ec2m', |
| 100 | + 'no-md2', |
| 101 | + 'no-ssl3', |
| 102 | + ] |
| 103 | + |
| 104 | + # Individual projects may provide their own openssl configure flags: |
| 105 | + project_flags = settings[:openssl_extra_configure_flags] || [] |
| 106 | + perl_exec = '' |
| 107 | + if platform.is_aix? |
| 108 | + perl_exec = '/opt/freeware/bin/perl' |
| 109 | + elsif platform.is_solaris? && platform.os_version == '10' |
| 110 | + perl_exec = '/opt/csw/bin/perl' |
| 111 | + end |
| 112 | + configure_flags << project_flags << cflags << ldflags |
| 113 | + |
| 114 | + pkg.configure do |
| 115 | + ["#{perl_exec} ./Configure #{configure_flags.join(' ')}"] |
| 116 | + end |
| 117 | + |
| 118 | + ####### |
| 119 | + # BUILD |
| 120 | + ####### |
| 121 | + |
| 122 | + pkg.build do |
| 123 | + [ |
| 124 | + "#{platform[:make]} depend", |
| 125 | + "#{platform[:make]}" |
| 126 | + ] |
| 127 | + end |
| 128 | + |
| 129 | + ######### |
| 130 | + # INSTALL |
| 131 | + ######### |
| 132 | + |
| 133 | + install_prefix = platform.is_windows? ? '' : 'INSTALL_PREFIX=/' |
| 134 | + install_commands = [] |
| 135 | + |
| 136 | + if platform.is_aix? |
| 137 | + install_commands << "slibclean" |
| 138 | + end |
| 139 | + |
| 140 | + install_commands << "#{platform[:make]} #{install_prefix} install" |
| 141 | + |
| 142 | + if settings[:runtime_project] == 'pdk' |
| 143 | + install_commands << "rm -f #{settings[:prefix]}/bin/{openssl,c_rehash}" |
| 144 | + end |
| 145 | + |
| 146 | + pkg.install do |
| 147 | + install_commands |
| 148 | + end |
| 149 | + |
| 150 | + pkg.install_file 'LICENSE', "#{settings[:prefix]}/share/doc/openssl-#{pkg.get_version}/LICENSE" |
| 151 | +end |
0 commit comments