Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1 | ## |
| 2 | ## Makefile for OpenSSL |
| 3 | ## |
| 4 | ## {- join("\n## ", @autowarntext) -} |
| 5 | {- |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 6 | our $objext = $target{obj_extension} || ".o"; |
| 7 | our $depext = $target{dep_extension} || ".d"; |
| 8 | our $exeext = $target{exe_extension} || ""; |
| 9 | our $libext = $target{lib_extension} || ".a"; |
| 10 | our $shlibext = $target{shared_extension} || ".so"; |
Viktor Dukhovni | 822b5e2 | 2017-11-20 21:30:04 -0500 | [diff] [blame] | 11 | our $shlibvariant = $target{shlib_variant} || ""; |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 12 | our $shlibextsimple = $target{shared_extension_simple} || ".so"; |
| 13 | our $shlibextimport = $target{shared_import_extension} || ""; |
| 14 | our $dsoext = $target{dso_extension} || ".so"; |
Richard Levitte | c39785d | 2018-03-15 18:06:18 +0100 | [diff] [blame] | 15 | our $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog}; |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 16 | |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 17 | sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ } |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 18 | |
Richard Levitte | d445302 | 2017-07-19 10:13:41 +0200 | [diff] [blame] | 19 | our $sover_dirname = $config{shlib_version_number}; |
| 20 | $sover_dirname =~ s|\.|_|g |
| 21 | if $config{target} =~ /^mingw/; |
Richard Levitte | b2de11c | 2016-07-06 18:50:47 +0200 | [diff] [blame] | 22 | |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 23 | # shlib and shlib_simple both take a static library name and figure |
| 24 | # out what the shlib name should be. |
| 25 | # |
| 26 | # When OpenSSL is configured "no-shared", these functions will just |
| 27 | # return empty lists, making them suitable to join(). |
| 28 | # |
| 29 | # With Windows DLL producers, shlib($libname) will return the shared |
| 30 | # library name (which usually is different from the static library |
| 31 | # name) with the default shared extension appended to it, while |
| 32 | # shlib_simple($libname) will return the static library name with |
| 33 | # the shared extension followed by ".a" appended to it. The former |
| 34 | # result is used as the runtime shared library while the latter is |
| 35 | # used as the DLL import library. |
| 36 | # |
| 37 | # On all Unix systems, shlib($libname) will return the library name |
| 38 | # with the default shared extension, while shlib_simple($libname) |
| 39 | # will return the name from shlib($libname) with any SO version number |
| 40 | # removed. On some systems, they may therefore return the exact same |
| 41 | # string. |
| 42 | sub shlib { |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 43 | my $lib = shift; |
Richard Levitte | 3310581 | 2017-04-18 16:24:23 +0200 | [diff] [blame] | 44 | return () if $disabled{shared} || $lib =~ /\.a$/; |
Viktor Dukhovni | 822b5e2 | 2017-11-20 21:30:04 -0500 | [diff] [blame] | 45 | return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)'; |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 46 | } |
| 47 | sub shlib_simple { |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 48 | my $lib = shift; |
Richard Levitte | 3310581 | 2017-04-18 16:24:23 +0200 | [diff] [blame] | 49 | return () if $disabled{shared} || $lib =~ /\.a$/; |
| 50 | |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 51 | if (windowsdll()) { |
Richard Levitte | d445302 | 2017-07-19 10:13:41 +0200 | [diff] [blame] | 52 | return $lib . '$(SHLIB_EXT_IMPORT)'; |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 53 | } |
Richard Levitte | d445302 | 2017-07-19 10:13:41 +0200 | [diff] [blame] | 54 | return $lib . '$(SHLIB_EXT_SIMPLE)'; |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Richard Levitte | 3310581 | 2017-04-18 16:24:23 +0200 | [diff] [blame] | 57 | # Easy fixing of static library names |
| 58 | sub lib { |
| 59 | (my $lib = shift) =~ s/\.a$//; |
| 60 | return $lib . $libext; |
| 61 | } |
| 62 | |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 63 | # dso is a complement to shlib / shlib_simple that returns the |
| 64 | # given libname with the simple shared extension (possible SO version |
| 65 | # removed). This differs from shlib_simple() by being unconditional. |
| 66 | sub dso { |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 67 | my $engine = shift; |
| 68 | |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 69 | return $engine . $dsoext; |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 70 | } |
Ben Laurie | 27c40a9 | 2016-06-26 13:09:23 +0100 | [diff] [blame] | 71 | # This makes sure things get built in the order they need |
| 72 | # to. You're welcome. |
| 73 | sub dependmagic { |
| 74 | my $target = shift; |
| 75 | |
| 76 | return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target"; |
| 77 | } |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 78 | ''; |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 79 | -} |
| 80 | PLATFORM={- $config{target} -} |
| 81 | OPTIONS={- $config{options} -} |
| 82 | CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -}) |
| 83 | SRCDIR={- $config{sourcedir} -} |
| 84 | BLDDIR={- $config{builddir} -} |
| 85 | |
| 86 | VERSION={- $config{version} -} |
| 87 | MAJOR={- $config{major} -} |
| 88 | MINOR={- $config{minor} -} |
| 89 | SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -} |
| 90 | SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -} |
| 91 | SHLIB_MAJOR={- $config{shlib_major} -} |
| 92 | SHLIB_MINOR={- $config{shlib_minor} -} |
| 93 | SHLIB_TARGET={- $target{shared_target} -} |
Richard Levitte | d445302 | 2017-07-19 10:13:41 +0200 | [diff] [blame] | 94 | SHLIB_EXT={- $shlibext -} |
| 95 | SHLIB_EXT_SIMPLE={- $shlibextsimple -} |
| 96 | SHLIB_EXT_IMPORT={- $shlibextimport -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 97 | |
Richard Levitte | 3310581 | 2017-04-18 16:24:23 +0200 | [diff] [blame] | 98 | LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -} |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 99 | SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -} |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 100 | SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -} |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 101 | ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -} |
Richard Levitte | 1e3d16b | 2016-07-08 17:58:36 +0200 | [diff] [blame] | 102 | PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 103 | SCRIPTS={- join(" ", @{$unified_info{scripts}}) -} |
Richard Levitte | 29eed3d | 2016-03-09 01:17:27 +0100 | [diff] [blame] | 104 | {- output_off() if $disabled{makedepend}; "" -} |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 105 | DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; } |
Richard Levitte | c058fcd | 2016-02-18 19:41:57 +0100 | [diff] [blame] | 106 | grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } |
| 107 | keys %{$unified_info{sources}}); -} |
Richard Levitte | 29eed3d | 2016-03-09 01:17:27 +0100 | [diff] [blame] | 108 | {- output_on() if $disabled{makedepend}; "" -} |
Richard Levitte | 8258975 | 2018-04-11 13:13:22 +0200 | [diff] [blame] | 109 | GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -} |
| 110 | GENERATED={- # common0.tmpl provides @generated |
| 111 | join(" ", @generated ) -} |
Richard Levitte | c058fcd | 2016-02-18 19:41:57 +0100 | [diff] [blame] | 112 | |
Richard Levitte | 3310581 | 2017-04-18 16:24:23 +0200 | [diff] [blame] | 113 | INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -} |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 114 | INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -} |
| 115 | INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -} |
| 116 | INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -} |
| 117 | INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -} |
Richard Levitte | df65337 | 2016-04-14 16:04:56 +0100 | [diff] [blame] | 118 | {- output_off() if $disabled{apps}; "" -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 119 | BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash |
Rich Salz | b8a9af6 | 2016-05-20 16:16:07 -0400 | [diff] [blame] | 120 | MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget |
Richard Levitte | df65337 | 2016-04-14 16:04:56 +0100 | [diff] [blame] | 121 | {- output_on() if $disabled{apps}; "" -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 122 | |
Richard Levitte | 6a74806 | 2017-06-15 19:31:01 +0200 | [diff] [blame] | 123 | APPS_OPENSSL={- use File::Spec::Functions; |
| 124 | catfile("apps","openssl") -} |
| 125 | |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 126 | # DESTDIR is for package builders so that they can configure for, say, |
| 127 | # /usr/ and yet have everything installed to /tmp/somedir/usr/. |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 128 | # Normally it is left empty. |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 129 | DESTDIR= |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 130 | |
| 131 | # Do not edit these manually. Use Configure with --prefix or --openssldir |
| 132 | # to change this! Short explanation in the top comment in Configure |
| 133 | INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet |
| 134 | # |
| 135 | our $prefix = $config{prefix} || "/usr/local"; |
| 136 | $prefix -} |
| 137 | OPENSSLDIR={- # |
| 138 | # The logic here is that if no --openssldir was given, |
| 139 | # OPENSSLDIR will get the value from $prefix plus "/ssl". |
| 140 | # If --openssldir was given and the value is an absolute |
| 141 | # path, OPENSSLDIR will get its value without change. |
| 142 | # If the value from --openssldir is a relative path, |
| 143 | # OPENSSLDIR will get $prefix with the --openssldir |
| 144 | # value appended as a subdirectory. |
| 145 | # |
| 146 | use File::Spec::Functions; |
| 147 | our $openssldir = |
| 148 | $config{openssldir} ? |
| 149 | (file_name_is_absolute($config{openssldir}) ? |
| 150 | $config{openssldir} |
| 151 | : catdir($prefix, $config{openssldir})) |
| 152 | : catdir($prefix, "ssl"); |
| 153 | $openssldir -} |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 154 | LIBDIR={- our $libdir = $config{libdir}; |
| 155 | unless ($libdir) { |
| 156 | # |
| 157 | # if $prefix/lib$target{multilib} is not an existing |
| 158 | # directory, then assume that it's not searched by linker |
| 159 | # automatically, in which case adding $target{multilib} suffix |
| 160 | # causes more grief than we're ready to tolerate, so don't... |
| 161 | our $multilib = |
| 162 | -d "$prefix/lib$target{multilib}" ? $target{multilib} : ""; |
| 163 | $libdir = "lib$multilib"; |
| 164 | } |
| 165 | file_name_is_absolute($libdir) ? "" : $libdir -} |
| 166 | # $(libdir) is chosen to be compatible with the GNU coding standards |
| 167 | libdir={- file_name_is_absolute($libdir) |
| 168 | ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -} |
| 169 | ENGINESDIR=$(libdir)/engines-{- $sover_dirname -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 170 | |
Richard Levitte | fad599f | 2016-10-12 17:05:35 +0200 | [diff] [blame] | 171 | # Convenience variable for those who want to set the rpath in shared |
| 172 | # libraries and applications |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 173 | LIBRPATH=$(libdir) |
Richard Levitte | fad599f | 2016-10-12 17:05:35 +0200 | [diff] [blame] | 174 | |
Richard Levitte | dde10ab | 2016-02-13 17:55:48 +0100 | [diff] [blame] | 175 | MANDIR=$(INSTALLTOP)/share/man |
Richard Levitte | 8be7bdb | 2016-02-19 10:38:15 +0100 | [diff] [blame] | 176 | DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME) |
| 177 | HTMLDIR=$(DOCDIR)/html |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 178 | |
Richard Levitte | 3544091 | 2016-02-15 13:37:17 +0100 | [diff] [blame] | 179 | # MANSUFFIX is for the benefit of anyone who may want to have a suffix |
| 180 | # appended after the manpage file section number. "ssl" is popular, |
| 181 | # resulting in files such as config.5ssl rather than config.5. |
| 182 | MANSUFFIX= |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 183 | HTMLSUFFIX=html |
| 184 | |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 185 | # For "optional" echo messages, to get "real" silence |
| 186 | ECHO = echo |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 187 | |
Richard Levitte | abe256e | 2018-03-06 20:35:30 +0100 | [diff] [blame] | 188 | ##### User defined commands and flags ################################ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 189 | |
| 190 | # We let the C compiler driver to take care of .s files. This is done in |
| 191 | # order to be excused from maintaining a separate set of architecture |
| 192 | # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC |
| 193 | # gcc, then the driver will automatically translate it to -xarch=v8plus |
Richard Levitte | 61ab691 | 2018-03-07 14:52:47 +0100 | [diff] [blame] | 194 | # and pass it down to assembler. In any case, we do not define AS or |
| 195 | # ASFLAGS for this reason. |
Richard Levitte | abe256e | 2018-03-06 20:35:30 +0100 | [diff] [blame] | 196 | |
| 197 | CROSS_COMPILE={- $config{CROSS_COMPILE} -} |
| 198 | CC=$(CROSS_COMPILE){- $config{CC} -} |
| 199 | CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -} |
| 200 | CPPFLAGS={- our $cppflags1 = join(" ", |
| 201 | (map { "-D".$_} @{$config{CPPDEFINES}}), |
| 202 | (map { "-I".$_} @{$config{CPPINCLUDES}}), |
| 203 | @{$config{CPPFLAGS}}) -} |
| 204 | CFLAGS={- join(' ', @{$config{CFLAGS}}) -} |
| 205 | CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -} |
| 206 | LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -} |
| 207 | EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -} |
| 208 | |
| 209 | MAKEDEPEND={- $config{makedepprog} -} |
| 210 | |
| 211 | PERL={- $config{perl} -} |
| 212 | |
| 213 | AR=$(CROSS_COMPILE){- $config{AR} -} |
| 214 | ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -} |
| 215 | RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -} |
| 216 | RC= $(CROSS_COMPILE){- $config{RC} -} |
| 217 | RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -} |
| 218 | |
| 219 | RM= rm -f |
| 220 | RMDIR= rmdir |
| 221 | TAR= {- $target{TAR} || "tar" -} |
| 222 | TARFLAGS= {- $target{TARFLAGS} -} |
| 223 | |
| 224 | BASENAME= openssl |
| 225 | NAME= $(BASENAME)-$(VERSION) |
| 226 | TARFILE= ../$(NAME).tar |
| 227 | |
| 228 | ##### Project flags ################################################## |
| 229 | |
| 230 | # Variables starting with CNF_ are common variables for all product types |
| 231 | |
| 232 | CNF_CPPFLAGS={- our $cppflags2 = |
| 233 | join(' ', $target{cppflags} || (), |
| 234 | (map { "-D".$_} @{$target{defines}}, |
| 235 | @{$config{defines}}), |
| 236 | (map { "-I".$_} @{$target{includes}}, |
| 237 | @{$config{includes}}), |
| 238 | @{$config{cppflags}}) -} |
| 239 | CNF_CFLAGS={- join(' ', $target{cflags} || (), |
| 240 | @{$config{cflags}}) -} |
| 241 | CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (), |
| 242 | @{$config{cxxflags}}) -} |
| 243 | CNF_LDFLAGS={- join(' ', $target{lflags} || (), |
| 244 | @{$config{lflags}}) -} |
| 245 | CNF_EX_LIBS={- join(' ', $target{ex_libs} || (), |
| 246 | @{$config{ex_libs}}) -} |
| 247 | |
| 248 | # Variables starting with LIB_ are used to build library object files |
| 249 | # and shared libraries. |
| 250 | # Variables starting with DSO_ are used to build DSOs and their object files. |
| 251 | # Variables starting with BIN_ are used to build programs and their object |
| 252 | # files. |
| 253 | |
Richard Levitte | 58d6be5 | 2018-03-09 12:39:01 +0100 | [diff] [blame] | 254 | LIB_CPPFLAGS={- our $lib_cppflags = |
| 255 | join(' ', $target{lib_cppflags} || (), |
Richard Levitte | abe256e | 2018-03-06 20:35:30 +0100 | [diff] [blame] | 256 | $target{shared_cppflag} || (), |
| 257 | (map { '-D'.$_ } |
| 258 | @{$config{lib_defines}}, |
Richard Levitte | 58d6be5 | 2018-03-09 12:39:01 +0100 | [diff] [blame] | 259 | @{$config{shared_defines}}), |
| 260 | @{$config{lib_cppflags}}, |
| 261 | @{$config{shared_cppflag}}); |
| 262 | join(' ', $lib_cppflags, |
| 263 | (map { '-D'.$_ } |
Richard Levitte | abe256e | 2018-03-06 20:35:30 +0100 | [diff] [blame] | 264 | 'OPENSSLDIR="\"$(OPENSSLDIR)\""', |
| 265 | 'ENGINESDIR="\"$(ENGINESDIR)\""'), |
Richard Levitte | abe256e | 2018-03-06 20:35:30 +0100 | [diff] [blame] | 266 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 267 | LIB_CFLAGS={- join(' ', $target{lib_cflags} || (), |
| 268 | $target{shared_cflag} || (), |
| 269 | @{$config{lib_cflags}}, |
| 270 | @{$config{shared_cflag}}, |
| 271 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 272 | LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (), |
| 273 | $target{shared_cxxflag} || (), |
| 274 | @{$config{lib_cxxflags}}, |
| 275 | @{$config{shared_cxxflag}}, |
| 276 | '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} |
| 277 | LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (), |
| 278 | $config{shared_ldflag} || (), |
| 279 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 280 | LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) |
| 281 | DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (), |
| 282 | $target{module_cppflags} || (), |
| 283 | @{$config{dso_cppflags}}, |
| 284 | @{$config{module_cppflags}}, |
| 285 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 286 | DSO_CFLAGS={- join(' ', $target{dso_cflags} || (), |
| 287 | $target{module_cflags} || (), |
| 288 | @{$config{dso_cflags}}, |
| 289 | @{$config{module_cflags}}, |
| 290 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 291 | DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (), |
| 292 | $target{module_cxxflags} || (), |
| 293 | @{$config{dso_cxxflags}}, |
| 294 | @{$config{module_cxxflag}}, |
| 295 | '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} |
| 296 | DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (), |
| 297 | $target{module_ldflags} || (), |
| 298 | @{$config{dso_ldflags}}, |
| 299 | @{$config{module_ldflags}}, |
| 300 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 301 | DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) |
| 302 | BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (), |
| 303 | @{$config{bin_cppflags}}, |
| 304 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 305 | BIN_CFLAGS={- join(' ', $target{bin_cflags} || (), |
| 306 | @{$config{bin_cflags}}, |
| 307 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 308 | BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (), |
| 309 | @{$config{bin_cxxflags}}, |
| 310 | '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} |
| 311 | BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (), |
| 312 | @{$config{bin_lflags}}, |
| 313 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 314 | BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) |
| 315 | |
| 316 | # CPPFLAGS_Q is used for one thing only: to build up buildinf.h |
| 317 | CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g; |
| 318 | $cppflags2 =~ s|([\\"])|\\$1|g; |
Richard Levitte | 58d6be5 | 2018-03-09 12:39:01 +0100 | [diff] [blame] | 319 | $lib_cppflags =~ s|([\\"])|\\$1|g; |
| 320 | join(' ', $lib_cppflags || (), $cppflags2 || (), |
| 321 | $cppflags1 || ()) -} |
Richard Levitte | abe256e | 2018-03-06 20:35:30 +0100 | [diff] [blame] | 322 | |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 323 | PERLASM_SCHEME= {- $target{perlasm_scheme} -} |
| 324 | |
| 325 | # For x86 assembler: Set PROCESSOR to 386 if you want to support |
| 326 | # the 80386. |
| 327 | PROCESSOR= {- $config{processor} -} |
| 328 | |
Andy Polyakov | 9c7ce40 | 2016-07-28 23:05:32 +0200 | [diff] [blame] | 329 | # We want error [and other] messages in English. Trouble is that make(1) |
| 330 | # doesn't pass macros down as environment variables unless there already |
| 331 | # was corresponding variable originally set. In other words we can only |
| 332 | # reassign environment variables, but not set new ones, not in portable |
| 333 | # manner that is. That's why we reassign several, just to be sure... |
| 334 | LC_ALL=C |
| 335 | LC_MESSAGES=C |
| 336 | LANG=C |
| 337 | |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 338 | # The main targets ################################################### |
| 339 | |
Richard Levitte | 1e3d16b | 2016-07-08 17:58:36 +0200 | [diff] [blame] | 340 | {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils |
Ben Laurie | 27c40a9 | 2016-06-26 13:09:23 +0100 | [diff] [blame] | 341 | {- dependmagic('build_libs'); -}: build_libs_nodep |
| 342 | {- dependmagic('build_engines'); -}: build_engines_nodep |
Richard Levitte | 1e3d16b | 2016-07-08 17:58:36 +0200 | [diff] [blame] | 343 | {- dependmagic('build_programs'); -}: build_programs_nodep |
Richard Levitte | 68a5f1a | 2016-02-13 18:15:51 +0100 | [diff] [blame] | 344 | |
Richard Levitte | 932eaf0 | 2016-06-14 21:39:13 +0200 | [diff] [blame] | 345 | build_generated: $(GENERATED_MANDATORY) |
Ben Laurie | 27c40a9 | 2016-06-26 13:09:23 +0100 | [diff] [blame] | 346 | build_libs_nodep: libcrypto.pc libssl.pc openssl.pc |
| 347 | build_engines_nodep: $(ENGINES) |
Richard Levitte | 1e3d16b | 2016-07-08 17:58:36 +0200 | [diff] [blame] | 348 | build_programs_nodep: $(PROGRAMS) $(SCRIPTS) |
| 349 | |
| 350 | # Kept around for backward compatibility |
| 351 | build_apps build_tests: build_programs |
Richard Levitte | 932eaf0 | 2016-06-14 21:39:13 +0200 | [diff] [blame] | 352 | |
Richard Levitte | 9b03b91 | 2017-06-16 03:46:41 +0200 | [diff] [blame] | 353 | # Convenience target to prebuild all generated files, not just the mandatory |
| 354 | # ones |
| 355 | build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) |
Andy Polyakov | 18d1588 | 2018-04-11 10:11:07 +0200 | [diff] [blame] | 356 | @ : {- output_off() if $disabled{makedepend}; "" -} |
| 357 | @echo "Warning: consider configuring with no-makedepend, because if" |
| 358 | @echo " target system doesn't have $(PERL)," |
| 359 | @echo " then make will fail..." |
| 360 | @ : {- output_on() if $disabled{makedepend}; "" -} |
Richard Levitte | 9b03b91 | 2017-06-16 03:46:41 +0200 | [diff] [blame] | 361 | |
Richard Levitte | 1b74165 | 2016-04-18 14:09:36 +0200 | [diff] [blame] | 362 | test: tests |
Richard Levitte | 1e3d16b | 2016-07-08 17:58:36 +0200 | [diff] [blame] | 363 | {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils |
Matt Caswell | d90a6be | 2016-04-14 13:44:15 +0100 | [diff] [blame] | 364 | @ : {- output_off() if $disabled{tests}; "" -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 365 | ( cd test; \ |
Richard Levitte | 41f571e | 2017-10-09 17:57:13 +0200 | [diff] [blame] | 366 | mkdir -p test-runs; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 367 | SRCTOP=../$(SRCDIR) \ |
| 368 | BLDTOP=../$(BLDDIR) \ |
Richard Levitte | 41f571e | 2017-10-09 17:57:13 +0200 | [diff] [blame] | 369 | RESULT_D=test-runs \ |
Richard Levitte | cbece22 | 2016-05-27 17:18:57 +0200 | [diff] [blame] | 370 | PERL="$(PERL)" \ |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 371 | EXE_EXT={- $exeext -} \ |
Andy Polyakov | 06444da | 2018-04-26 19:22:30 +0200 | [diff] [blame] | 372 | OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \ |
Richard Levitte | 6d4bc8a | 2016-11-03 17:08:10 +0100 | [diff] [blame] | 373 | OPENSSL_DEBUG_MEMORY=on \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 374 | $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) ) |
Matt Caswell | d90a6be | 2016-04-14 13:44:15 +0100 | [diff] [blame] | 375 | @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} |
| 376 | @echo "Tests are not supported with your chosen Configure options" |
| 377 | @ : {- output_on() if !$disabled{tests}; "" -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 378 | |
| 379 | list-tests: |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 380 | @ : {- output_off() if $disabled{tests}; "" -} |
| 381 | @SRCTOP="$(SRCDIR)" \ |
| 382 | $(PERL) $(SRCDIR)/test/run_tests.pl list |
| 383 | @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} |
| 384 | @echo "Tests are not supported with your chosen Configure options" |
| 385 | @ : {- output_on() if !$disabled{tests}; "" -} |
| 386 | |
| 387 | install: install_sw install_ssldirs install_docs |
| 388 | |
| 389 | uninstall: uninstall_docs uninstall_sw |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 390 | |
| 391 | libclean: |
Richard Levitte | f99f91f | 2016-02-15 22:13:41 +0100 | [diff] [blame] | 392 | @set -e; for s in $(SHLIB_INFO); do \ |
Bernd Edlinger | 49bb4dd | 2018-04-13 21:41:14 +0200 | [diff] [blame] | 393 | if [ "$$s" = ";" ]; then continue; fi; \ |
Richard Levitte | f99f91f | 2016-02-15 22:13:41 +0100 | [diff] [blame] | 394 | s1=`echo "$$s" | cut -f1 -d";"`; \ |
| 395 | s2=`echo "$$s" | cut -f2 -d";"`; \ |
Bernd Edlinger | 49bb4dd | 2018-04-13 21:41:14 +0200 | [diff] [blame] | 396 | $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\ |
| 397 | $(RM) apps/$$s1; \ |
| 398 | $(RM) test/$$s1; \ |
| 399 | $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\ |
Richard Levitte | f99f91f | 2016-02-15 22:13:41 +0100 | [diff] [blame] | 400 | $(RM) $$s1; \ |
| 401 | if [ "$$s1" != "$$s2" ]; then \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 402 | $(ECHO) $(RM) $$s2; \ |
Richard Levitte | f99f91f | 2016-02-15 22:13:41 +0100 | [diff] [blame] | 403 | $(RM) $$s2; \ |
| 404 | fi; \ |
| 405 | done |
| 406 | $(RM) $(LIBS) |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 407 | $(RM) *.map |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 408 | |
| 409 | clean: libclean |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 410 | $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS) |
Bernd Edlinger | b0a9793 | 2018-04-13 23:24:01 +0200 | [diff] [blame] | 411 | $(RM) $(GENERATED_MANDATORY) $(GENERATED) |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 412 | -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"` |
| 413 | -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"` |
| 414 | $(RM) core |
Rich Salz | 9e183d2 | 2017-03-11 08:56:44 -0500 | [diff] [blame] | 415 | $(RM) tags TAGS doc-nits |
Bernd Edlinger | d016d1e | 2017-12-14 21:16:41 +0100 | [diff] [blame] | 416 | $(RM) -r test/test-runs |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 417 | $(RM) openssl.pc libcrypto.pc libssl.pc |
| 418 | -$(RM) `find . -type l -a \! -path "./.git/*"` |
| 419 | $(RM) $(TARFILE) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 420 | |
Richard Levitte | 7cae386 | 2016-06-13 22:02:11 +0200 | [diff] [blame] | 421 | distclean: clean |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 422 | $(RM) configdata.pm |
| 423 | $(RM) Makefile |
Richard Levitte | 7cae386 | 2016-06-13 22:02:11 +0200 | [diff] [blame] | 424 | |
Richard Levitte | f8d9d6e | 2016-02-21 16:09:36 +0100 | [diff] [blame] | 425 | # We check if any depfile is newer than Makefile and decide to |
Richard Levitte | a6adf09 | 2016-03-18 20:52:29 +0100 | [diff] [blame] | 426 | # concatenate only if that is true. |
Richard Levitte | ea80a25 | 2016-02-20 17:29:23 +0100 | [diff] [blame] | 427 | depend: |
Richard Levitte | 29eed3d | 2016-03-09 01:17:27 +0100 | [diff] [blame] | 428 | @: {- output_off() if $disabled{makedepend}; "" -} |
Richard Levitte | c39785d | 2018-03-15 18:06:18 +0100 | [diff] [blame] | 429 | @$(PERL) $(SRCDIR)/util/add-depends.pl {- |
| 430 | defined $makedepprog && $makedepprog =~ /\/makedepend/ |
| 431 | ? 'makedepend' : 'gcc' -} |
Richard Levitte | 29eed3d | 2016-03-09 01:17:27 +0100 | [diff] [blame] | 432 | @: {- output_on() if $disabled{makedepend}; "" -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 433 | |
| 434 | # Install helper targets ############################################# |
| 435 | |
| 436 | install_sw: all install_dev install_engines install_runtime |
| 437 | |
Richard Levitte | f99f91f | 2016-02-15 22:13:41 +0100 | [diff] [blame] | 438 | uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 439 | |
| 440 | install_docs: install_man_docs install_html_docs |
| 441 | |
| 442 | uninstall_docs: uninstall_man_docs uninstall_html_docs |
Richard Levitte | 8be7bdb | 2016-02-19 10:38:15 +0100 | [diff] [blame] | 443 | $(RM) -r -v $(DESTDIR)$(DOCDIR) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 444 | |
Richard Levitte | dde10ab | 2016-02-13 17:55:48 +0100 | [diff] [blame] | 445 | install_ssldirs: |
| 446 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs |
| 447 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private |
Richard Levitte | 66c2eb8 | 2016-08-01 23:15:50 +0200 | [diff] [blame] | 448 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 449 | @set -e; for x in dummy $(MISC_SCRIPTS); do \ |
| 450 | if [ "$$x" = "dummy" ]; then continue; fi; \ |
| 451 | fn=`basename $$x`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 452 | $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 453 | cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \ |
| 454 | chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \ |
| 455 | mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \ |
| 456 | $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \ |
| 457 | done |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 458 | @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist" |
Richard Levitte | 4813ad2 | 2016-06-17 00:23:43 +0200 | [diff] [blame] | 459 | @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new |
| 460 | @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new |
Richard Levitte | cb926df | 2016-08-01 23:18:25 +0200 | [diff] [blame] | 461 | @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist |
Rich Salz | c7af65c | 2016-09-09 18:05:41 -0400 | [diff] [blame] | 462 | @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 463 | $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \ |
Richard Levitte | cb926df | 2016-08-01 23:18:25 +0200 | [diff] [blame] | 464 | cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \ |
| 465 | chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \ |
| 466 | fi |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 467 | @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist" |
Rich Salz | c7af65c | 2016-09-09 18:05:41 -0400 | [diff] [blame] | 468 | @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new |
| 469 | @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new |
| 470 | @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist |
| 471 | @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 472 | $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \ |
Rich Salz | c7af65c | 2016-09-09 18:05:41 -0400 | [diff] [blame] | 473 | cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \ |
| 474 | chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \ |
| 475 | fi |
Richard Levitte | dde10ab | 2016-02-13 17:55:48 +0100 | [diff] [blame] | 476 | |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 477 | install_dev: |
| 478 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 479 | @$(ECHO) "*** Installing development files" |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 480 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl |
Richard Levitte | 24c4f73 | 2016-07-14 21:11:46 +0200 | [diff] [blame] | 481 | @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -} |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 482 | @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" |
Richard Levitte | 24c4f73 | 2016-07-14 21:11:46 +0200 | [diff] [blame] | 483 | @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c |
| 484 | @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c |
| 485 | @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 486 | @set -e; for i in $(SRCDIR)/include/openssl/*.h \ |
| 487 | $(BLDDIR)/include/openssl/*.h; do \ |
| 488 | fn=`basename $$i`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 489 | $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 490 | cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ |
| 491 | chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 492 | done |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 493 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir) |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 494 | @set -e; for l in $(INSTALL_LIBS); do \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 495 | fn=`basename $$l`; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 496 | $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \ |
| 497 | cp $$l $(DESTDIR)$(libdir)/$$fn.new; \ |
| 498 | $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \ |
| 499 | chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \ |
| 500 | mv -f $(DESTDIR)$(libdir)/$$fn.new \ |
| 501 | $(DESTDIR)$(libdir)/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 502 | done |
Richard Levitte | 84af1ba | 2016-02-22 13:52:46 +0100 | [diff] [blame] | 503 | @ : {- output_off() if $disabled{shared}; "" -} |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 504 | @set -e; for s in $(INSTALL_SHLIB_INFO); do \ |
Richard Levitte | c8c2b77 | 2016-02-15 18:39:49 +0100 | [diff] [blame] | 505 | s1=`echo "$$s" | cut -f1 -d";"`; \ |
| 506 | s2=`echo "$$s" | cut -f2 -d";"`; \ |
| 507 | fn1=`basename $$s1`; \ |
| 508 | fn2=`basename $$s2`; \ |
| 509 | : {- output_off() if windowsdll(); "" -}; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 510 | $(ECHO) "install $$s1 -> $(DESTDIR)$(libdir)/$$fn1"; \ |
| 511 | cp $$s1 $(DESTDIR)$(libdir)/$$fn1.new; \ |
| 512 | chmod 755 $(DESTDIR)$(libdir)/$$fn1.new; \ |
| 513 | mv -f $(DESTDIR)$(libdir)/$$fn1.new \ |
| 514 | $(DESTDIR)$(libdir)/$$fn1; \ |
Richard Levitte | c8c2b77 | 2016-02-15 18:39:49 +0100 | [diff] [blame] | 515 | if [ "$$fn1" != "$$fn2" ]; then \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 516 | $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \ |
| 517 | ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 518 | fi; \ |
Richard Levitte | c8c2b77 | 2016-02-15 18:39:49 +0100 | [diff] [blame] | 519 | : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 520 | $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \ |
| 521 | cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \ |
| 522 | chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \ |
| 523 | mv -f $(DESTDIR)$(libdir)/$$fn2.new \ |
| 524 | $(DESTDIR)$(libdir)/$$fn2; \ |
Richard Levitte | ce5ed82 | 2016-02-19 22:23:28 +0100 | [diff] [blame] | 525 | : {- output_on() unless windowsdll(); "" -}; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 526 | done |
Richard Levitte | 84af1ba | 2016-02-22 13:52:46 +0100 | [diff] [blame] | 527 | @ : {- output_on() if $disabled{shared}; "" -} |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 528 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig |
| 529 | @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc" |
| 530 | @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig |
| 531 | @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc |
| 532 | @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc" |
| 533 | @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig |
| 534 | @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc |
| 535 | @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc" |
| 536 | @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig |
| 537 | @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 538 | |
| 539 | uninstall_dev: |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 540 | @$(ECHO) "*** Uninstalling development files" |
Richard Levitte | 24c4f73 | 2016-07-14 21:11:46 +0200 | [diff] [blame] | 541 | @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -} |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 542 | @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" |
Richard Levitte | 24c4f73 | 2016-07-14 21:11:46 +0200 | [diff] [blame] | 543 | @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c |
| 544 | @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 545 | @set -e; for i in $(SRCDIR)/include/openssl/*.h \ |
| 546 | $(BLDDIR)/include/openssl/*.h; do \ |
| 547 | fn=`basename $$i`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 548 | $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 549 | $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 550 | done |
Richard Levitte | 98e5534 | 2016-02-15 22:12:24 +0100 | [diff] [blame] | 551 | -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl |
| 552 | -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 553 | @set -e; for l in $(INSTALL_LIBS); do \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 554 | fn=`basename $$l`; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 555 | $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \ |
| 556 | $(RM) $(DESTDIR)$(libdir)/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 557 | done |
Richard Levitte | 84af1ba | 2016-02-22 13:52:46 +0100 | [diff] [blame] | 558 | @ : {- output_off() if $disabled{shared}; "" -} |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 559 | @set -e; for s in $(INSTALL_SHLIB_INFO); do \ |
Richard Levitte | c8c2b77 | 2016-02-15 18:39:49 +0100 | [diff] [blame] | 560 | s1=`echo "$$s" | cut -f1 -d";"`; \ |
| 561 | s2=`echo "$$s" | cut -f2 -d";"`; \ |
| 562 | fn1=`basename $$s1`; \ |
| 563 | fn2=`basename $$s2`; \ |
| 564 | : {- output_off() if windowsdll(); "" -}; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 565 | $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \ |
| 566 | $(RM) $(DESTDIR)$(libdir)/$$fn1; \ |
Richard Levitte | c8c2b77 | 2016-02-15 18:39:49 +0100 | [diff] [blame] | 567 | if [ "$$fn1" != "$$fn2" ]; then \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 568 | $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \ |
| 569 | $(RM) $(DESTDIR)$(libdir)/$$fn2; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 570 | fi; \ |
Richard Levitte | c8c2b77 | 2016-02-15 18:39:49 +0100 | [diff] [blame] | 571 | : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 572 | $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \ |
| 573 | $(RM) $(DESTDIR)$(libdir)/$$fn2; \ |
Richard Levitte | ce5ed82 | 2016-02-19 22:23:28 +0100 | [diff] [blame] | 574 | : {- output_on() unless windowsdll(); "" -}; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 575 | done |
Richard Levitte | c8cca98 | 2016-03-04 05:43:15 +0100 | [diff] [blame] | 576 | @ : {- output_on() if $disabled{shared}; "" -} |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 577 | $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc |
| 578 | $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc |
| 579 | $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc |
| 580 | -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig |
| 581 | -$(RMDIR) $(DESTDIR)$(libdir) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 582 | |
| 583 | install_engines: |
| 584 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) |
Richard Levitte | b2de11c | 2016-07-06 18:50:47 +0200 | [diff] [blame] | 585 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 586 | @$(ECHO) "*** Installing engines" |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 587 | @set -e; for e in dummy $(INSTALL_ENGINES); do \ |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 588 | if [ "$$e" = "dummy" ]; then continue; fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 589 | fn=`basename $$e`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 590 | $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \ |
Richard Levitte | b2de11c | 2016-07-06 18:50:47 +0200 | [diff] [blame] | 591 | cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \ |
| 592 | chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \ |
| 593 | mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \ |
| 594 | $(DESTDIR)$(ENGINESDIR)/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 595 | done |
| 596 | |
| 597 | uninstall_engines: |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 598 | @$(ECHO) "*** Uninstalling engines" |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 599 | @set -e; for e in dummy $(INSTALL_ENGINES); do \ |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 600 | if [ "$$e" = "dummy" ]; then continue; fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 601 | fn=`basename $$e`; \ |
Richard Levitte | f0c93a8 | 2016-02-19 10:39:12 +0100 | [diff] [blame] | 602 | if [ "$$fn" = '{- dso("ossltest") -}' ]; then \ |
| 603 | continue; \ |
| 604 | fi; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 605 | $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \ |
Richard Levitte | b2de11c | 2016-07-06 18:50:47 +0200 | [diff] [blame] | 606 | $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 607 | done |
Richard Levitte | b2de11c | 2016-07-06 18:50:47 +0200 | [diff] [blame] | 608 | -$(RMDIR) $(DESTDIR)$(ENGINESDIR) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 609 | |
| 610 | install_runtime: |
| 611 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 612 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin |
Richard Levitte | 36b5372 | 2016-07-19 13:24:57 +0200 | [diff] [blame] | 613 | @ : {- output_off() if windowsdll(); "" -} |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 614 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir) |
Richard Levitte | 36b5372 | 2016-07-19 13:24:57 +0200 | [diff] [blame] | 615 | @ : {- output_on() if windowsdll(); "" -} |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 616 | @$(ECHO) "*** Installing runtime files" |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 617 | @set -e; for s in dummy $(INSTALL_SHLIBS); do \ |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 618 | if [ "$$s" = "dummy" ]; then continue; fi; \ |
Richard Levitte | f99f91f | 2016-02-15 22:13:41 +0100 | [diff] [blame] | 619 | fn=`basename $$s`; \ |
Richard Levitte | 36b5372 | 2016-07-19 13:24:57 +0200 | [diff] [blame] | 620 | : {- output_off() unless windowsdll(); "" -}; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 621 | $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 622 | cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ |
| 623 | chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ |
| 624 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ |
| 625 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ |
Richard Levitte | 36b5372 | 2016-07-19 13:24:57 +0200 | [diff] [blame] | 626 | : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 627 | $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \ |
| 628 | cp $$s $(DESTDIR)$(libdir)/$$fn.new; \ |
| 629 | chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \ |
| 630 | mv -f $(DESTDIR)$(libdir)/$$fn.new \ |
| 631 | $(DESTDIR)$(libdir)/$$fn; \ |
Richard Levitte | 36b5372 | 2016-07-19 13:24:57 +0200 | [diff] [blame] | 632 | : {- output_on() if windowsdll(); "" -}; \ |
Richard Levitte | fcf80c4 | 2016-01-30 05:45:29 +0100 | [diff] [blame] | 633 | done |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 634 | @set -e; for x in dummy $(INSTALL_PROGRAMS); do \ |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 635 | if [ "$$x" = "dummy" ]; then continue; fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 636 | fn=`basename $$x`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 637 | $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 638 | cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ |
| 639 | chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ |
| 640 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ |
| 641 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 642 | done |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 643 | @set -e; for x in dummy $(BIN_SCRIPTS); do \ |
| 644 | if [ "$$x" = "dummy" ]; then continue; fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 645 | fn=`basename $$x`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 646 | $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 647 | cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ |
| 648 | chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ |
| 649 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ |
| 650 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 651 | done |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 652 | |
| 653 | uninstall_runtime: |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 654 | @$(ECHO) "*** Uninstalling runtime files" |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 655 | @set -e; for x in dummy $(INSTALL_PROGRAMS); \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 656 | do \ |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 657 | if [ "$$x" = "dummy" ]; then continue; fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 658 | fn=`basename $$x`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 659 | $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 660 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 661 | done; |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 662 | @set -e; for x in dummy $(BIN_SCRIPTS); \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 663 | do \ |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 664 | if [ "$$x" = "dummy" ]; then continue; fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 665 | fn=`basename $$x`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 666 | $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 667 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 668 | done |
Richard Levitte | b1837ab | 2016-07-14 21:13:24 +0200 | [diff] [blame] | 669 | @ : {- output_off() unless windowsdll(); "" -} |
Richard Levitte | 0f01b7b | 2016-07-08 14:52:09 +0200 | [diff] [blame] | 670 | @set -e; for s in dummy $(INSTALL_SHLIBS); do \ |
Richard Levitte | 2b364f6 | 2016-03-21 08:11:14 +0100 | [diff] [blame] | 671 | if [ "$$s" = "dummy" ]; then continue; fi; \ |
Richard Levitte | f99f91f | 2016-02-15 22:13:41 +0100 | [diff] [blame] | 672 | fn=`basename $$s`; \ |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 673 | $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ |
Richard Levitte | 3c65577 | 2016-02-12 21:14:03 +0100 | [diff] [blame] | 674 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ |
Richard Levitte | fcf80c4 | 2016-01-30 05:45:29 +0100 | [diff] [blame] | 675 | done |
Richard Levitte | b1837ab | 2016-07-14 21:13:24 +0200 | [diff] [blame] | 676 | @ : {- output_on() unless windowsdll(); "" -} |
Richard Levitte | b894054 | 2016-03-03 17:45:14 +0100 | [diff] [blame] | 677 | -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 678 | |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 679 | |
| 680 | install_man_docs: |
| 681 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 682 | @$(ECHO) "*** Installing manpages" |
Richard Levitte | cadb015 | 2017-03-06 21:17:32 +0100 | [diff] [blame] | 683 | $(PERL) $(SRCDIR)/util/process_docs.pl \ |
| 684 | --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 685 | |
| 686 | uninstall_man_docs: |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 687 | @$(ECHO) "*** Uninstalling manpages" |
Richard Levitte | cadb015 | 2017-03-06 21:17:32 +0100 | [diff] [blame] | 688 | $(PERL) $(SRCDIR)/util/process_docs.pl \ |
| 689 | --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \ |
| 690 | --remove |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 691 | |
| 692 | install_html_docs: |
| 693 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 694 | @$(ECHO) "*** Installing HTML manpages" |
Richard Levitte | cadb015 | 2017-03-06 21:17:32 +0100 | [diff] [blame] | 695 | $(PERL) $(SRCDIR)/util/process_docs.pl \ |
| 696 | --destdir=$(DESTDIR)$(HTMLDIR) --type=html |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 697 | |
| 698 | uninstall_html_docs: |
Rich Salz | 5407338 | 2017-06-29 11:40:19 -0400 | [diff] [blame] | 699 | @$(ECHO) "*** Uninstalling manpages" |
Richard Levitte | cadb015 | 2017-03-06 21:17:32 +0100 | [diff] [blame] | 700 | $(PERL) $(SRCDIR)/util/process_docs.pl \ |
| 701 | --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 702 | |
| 703 | |
| 704 | # Developer targets (note: these are only available on Unix) ######### |
| 705 | |
Richard Levitte | 6bb2106 | 2016-02-11 20:00:57 +0100 | [diff] [blame] | 706 | update: generate errors ordinals |
| 707 | |
Richard Levitte | b7650c6 | 2016-05-01 15:09:20 +0200 | [diff] [blame] | 708 | generate: generate_apps generate_crypto_bn generate_crypto_objects \ |
Richard Levitte | 8e32e1a | 2017-10-31 20:06:39 +0100 | [diff] [blame] | 709 | generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 710 | |
Rich Salz | 65c1f97 | 2017-01-12 08:20:54 -0500 | [diff] [blame] | 711 | doc-nits: |
Rich Salz | 1722496 | 2017-06-08 15:18:38 -0400 | [diff] [blame] | 712 | (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits |
Rich Salz | 9e183d2 | 2017-03-11 08:56:44 -0500 | [diff] [blame] | 713 | if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi |
Rich Salz | 65c1f97 | 2017-01-12 08:20:54 -0500 | [diff] [blame] | 714 | |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 715 | # Test coverage is a good idea for the future |
| 716 | #coverage: $(PROGRAMS) $(TESTPROGRAMS) |
| 717 | # ... |
| 718 | |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 719 | lint: |
| 720 | lint -DLINT $(INCLUDES) $(SRCS) |
| 721 | |
Richard Levitte | 9a9f8ee | 2016-03-19 20:04:51 +0100 | [diff] [blame] | 722 | generate_apps: |
| 723 | ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \ |
| 724 | < apps/openssl.cnf > apps/openssl-vms.cnf ) |
Richard Levitte | 6bb2106 | 2016-02-11 20:00:57 +0100 | [diff] [blame] | 725 | |
Richard Levitte | 9a9f8ee | 2016-03-19 20:04:51 +0100 | [diff] [blame] | 726 | generate_crypto_bn: |
| 727 | ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h ) |
Richard Levitte | 6bb2106 | 2016-02-11 20:00:57 +0100 | [diff] [blame] | 728 | |
Richard Levitte | 9a9f8ee | 2016-03-19 20:04:51 +0100 | [diff] [blame] | 729 | generate_crypto_objects: |
Rich Salz | 22defb4 | 2018-02-27 15:14:18 -0500 | [diff] [blame] | 730 | ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \ |
| 731 | crypto/objects/objects.txt \ |
| 732 | crypto/objects/obj_mac.num \ |
| 733 | > crypto/objects/obj_mac.new && \ |
| 734 | mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num ) |
Richard Levitte | 9a9f8ee | 2016-03-19 20:04:51 +0100 | [diff] [blame] | 735 | ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \ |
| 736 | crypto/objects/objects.txt \ |
| 737 | crypto/objects/obj_mac.num \ |
Rich Salz | 22defb4 | 2018-02-27 15:14:18 -0500 | [diff] [blame] | 738 | > include/openssl/obj_mac.h ) |
Kirill Marinushkin | e6f2bb6 | 2016-04-24 02:01:25 +0200 | [diff] [blame] | 739 | ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \ |
| 740 | include/openssl/obj_mac.h \ |
Rich Salz | 22defb4 | 2018-02-27 15:14:18 -0500 | [diff] [blame] | 741 | > crypto/objects/obj_dat.h ) |
Richard Levitte | 9a9f8ee | 2016-03-19 20:04:51 +0100 | [diff] [blame] | 742 | ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \ |
| 743 | crypto/objects/obj_mac.num \ |
| 744 | crypto/objects/obj_xref.txt \ |
| 745 | > crypto/objects/obj_xref.h ) |
Richard Levitte | 6bb2106 | 2016-02-11 20:00:57 +0100 | [diff] [blame] | 746 | |
Richard Levitte | b7650c6 | 2016-05-01 15:09:20 +0200 | [diff] [blame] | 747 | generate_crypto_conf: |
| 748 | ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \ |
| 749 | > crypto/conf/conf_def.h ) |
| 750 | |
| 751 | generate_crypto_asn1: |
| 752 | ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \ |
| 753 | > crypto/asn1/charmap.h ) |
| 754 | |
Richard Levitte | 8e32e1a | 2017-10-31 20:06:39 +0100 | [diff] [blame] | 755 | generate_fuzz_oids: |
| 756 | ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \ |
| 757 | crypto/objects/obj_dat.h \ |
| 758 | > fuzz/oids.txt ) |
| 759 | |
Rich Salz | 52df25c | 2017-06-07 15:12:03 -0400 | [diff] [blame] | 760 | # Set to -force to force a rebuild |
| 761 | ERROR_REBUILD= |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 762 | errors: |
| 763 | ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c ) |
Richard Levitte | cb7b727 | 2018-02-07 19:23:39 +0100 | [diff] [blame] | 764 | ( b=`pwd`; cd $(SRCDIR); \ |
| 765 | $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal ) |
| 766 | ( b=`pwd`; cd $(SRCDIR)/engines; \ |
Rich Salz | 52df25c | 2017-06-07 15:12:03 -0400 | [diff] [blame] | 767 | for E in *.ec ; do \ |
Richard Levitte | cb7b727 | 2018-02-07 19:23:39 +0100 | [diff] [blame] | 768 | $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \ |
Rich Salz | 52df25c | 2017-06-07 15:12:03 -0400 | [diff] [blame] | 769 | -conf $$E `basename $$E .ec`.c ; \ |
| 770 | done ) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 771 | |
| 772 | ordinals: |
| 773 | ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update ) |
| 774 | ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update ) |
| 775 | |
| 776 | test_ordinals: |
| 777 | ( cd test; \ |
| 778 | SRCTOP=../$(SRCDIR) \ |
| 779 | BLDTOP=../$(BLDDIR) \ |
| 780 | $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals ) |
| 781 | |
| 782 | tags TAGS: FORCE |
| 783 | rm -f TAGS tags |
| 784 | -ctags -R . |
| 785 | -etags `find . -name '*.[ch]' -o -name '*.pm'` |
| 786 | |
| 787 | # Release targets (note: only available on Unix) ##################### |
| 788 | |
Richard Levitte | 77a9c26 | 2017-08-17 14:08:43 +0200 | [diff] [blame] | 789 | # If your tar command doesn't support --owner and --group, make sure to |
| 790 | # use one that does, for example GNU tar |
Michael Richardson | 9967a9e | 2018-03-06 14:18:43 -0500 | [diff] [blame] | 791 | TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cf - |
Richard Levitte | 54bb8f7 | 2016-03-08 11:49:26 +0100 | [diff] [blame] | 792 | PREPARE_CMD=: |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 793 | tar: |
Richard Levitte | 34a5b7d | 2017-08-17 14:04:18 +0200 | [diff] [blame] | 794 | set -e; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 795 | TMPDIR=/var/tmp/openssl-copy.$$$$; \ |
Richard Levitte | 54bb8f7 | 2016-03-08 11:49:26 +0100 | [diff] [blame] | 796 | DISTDIR=$(NAME); \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 797 | mkdir -p $$TMPDIR/$$DISTDIR; \ |
| 798 | (cd $(SRCDIR); \ |
Richard Levitte | 5b7b011 | 2017-08-17 09:38:02 +0200 | [diff] [blame] | 799 | excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \ |
Richard Levitte | 918388b | 2018-04-02 10:24:33 +0200 | [diff] [blame] | 800 | excl_re="^(fuzz/corpora|Configurations/.*\.norelease\.conf|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \ |
Richard Levitte | 5b7b011 | 2017-08-17 09:38:02 +0200 | [diff] [blame] | 801 | echo "$$excl_re"; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 802 | git ls-tree -r --name-only --full-tree HEAD \ |
Richard Levitte | 17c84aa | 2017-08-17 14:04:36 +0200 | [diff] [blame] | 803 | | egrep -v "$$excl_re" \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 804 | | while read F; do \ |
| 805 | mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \ |
| 806 | cp $$F $$TMPDIR/$$DISTDIR/$$F; \ |
| 807 | done); \ |
Richard Levitte | 17c84aa | 2017-08-17 14:04:36 +0200 | [diff] [blame] | 808 | (cd $$TMPDIR/$$DISTDIR; \ |
Richard Levitte | 54bb8f7 | 2016-03-08 11:49:26 +0100 | [diff] [blame] | 809 | $(PREPARE_CMD); \ |
Richard Levitte | 17c84aa | 2017-08-17 14:04:36 +0200 | [diff] [blame] | 810 | find . -type d -print | xargs chmod 755; \ |
| 811 | find . -type f -print | xargs chmod a+r; \ |
| 812 | find . -type f -perm -0100 -print | xargs chmod a+x); \ |
| 813 | (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 814 | | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \ |
| 815 | rm -rf $$TMPDIR |
| 816 | cd $(SRCDIR); ls -l $(TARFILE).gz |
| 817 | |
| 818 | dist: |
Meena Vyas | bffa1ff | 2017-08-25 02:38:45 +1000 | [diff] [blame] | 819 | @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 820 | |
| 821 | # Helper targets ##################################################### |
| 822 | |
Richard Levitte | 342a1a2 | 2016-09-07 20:56:20 +0200 | [diff] [blame] | 823 | link-utils: $(BLDDIR)/util/opensslwrap.sh |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 824 | |
Richard Levitte | 27f42b4 | 2016-02-19 02:30:51 +0100 | [diff] [blame] | 825 | $(BLDDIR)/util/opensslwrap.sh: configdata.pm |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 826 | @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ |
| 827 | mkdir -p "$(BLDDIR)/util"; \ |
| 828 | ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \ |
| 829 | fi |
Richard Levitte | 342a1a2 | 2016-09-07 20:56:20 +0200 | [diff] [blame] | 830 | |
Richard Levitte | c058fcd | 2016-02-18 19:41:57 +0100 | [diff] [blame] | 831 | FORCE: |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 832 | |
| 833 | # Building targets ################################################### |
| 834 | |
Richard Levitte | 8478a70 | 2016-07-06 03:07:16 +0200 | [diff] [blame] | 835 | libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -} |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 836 | libcrypto.pc: |
| 837 | @ ( echo 'prefix=$(INSTALLTOP)'; \ |
| 838 | echo 'exec_prefix=$${prefix}'; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 839 | if [ -n "$(LIBDIR)" ]; then \ |
| 840 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ |
| 841 | else \ |
| 842 | echo 'libdir=$(libdir)'; \ |
| 843 | fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 844 | echo 'includedir=$${prefix}/include'; \ |
Richard Levitte | d445302 | 2017-07-19 10:13:41 +0200 | [diff] [blame] | 845 | echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 846 | echo ''; \ |
| 847 | echo 'Name: OpenSSL-libcrypto'; \ |
| 848 | echo 'Description: OpenSSL cryptography library'; \ |
| 849 | echo 'Version: '$(VERSION); \ |
| 850 | echo 'Libs: -L$${libdir} -lcrypto'; \ |
Richard Levitte | abe256e | 2018-03-06 20:35:30 +0100 | [diff] [blame] | 851 | echo 'Libs.private: $(LIB_EX_LIBS)'; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 852 | echo 'Cflags: -I$${includedir}' ) > libcrypto.pc |
| 853 | |
| 854 | libssl.pc: |
| 855 | @ ( echo 'prefix=$(INSTALLTOP)'; \ |
| 856 | echo 'exec_prefix=$${prefix}'; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 857 | if [ -n "$(LIBDIR)" ]; then \ |
| 858 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ |
| 859 | else \ |
| 860 | echo 'libdir=$(libdir)'; \ |
| 861 | fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 862 | echo 'includedir=$${prefix}/include'; \ |
| 863 | echo ''; \ |
| 864 | echo 'Name: OpenSSL-libssl'; \ |
| 865 | echo 'Description: Secure Sockets Layer and cryptography libraries'; \ |
| 866 | echo 'Version: '$(VERSION); \ |
| 867 | echo 'Requires.private: libcrypto'; \ |
| 868 | echo 'Libs: -L$${libdir} -lssl'; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 869 | echo 'Cflags: -I$${includedir}' ) > libssl.pc |
| 870 | |
| 871 | openssl.pc: |
| 872 | @ ( echo 'prefix=$(INSTALLTOP)'; \ |
| 873 | echo 'exec_prefix=$${prefix}'; \ |
Richard Levitte | e454f3a | 2018-02-23 12:10:42 +0100 | [diff] [blame] | 874 | if [ -n "$(LIBDIR)" ]; then \ |
| 875 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ |
| 876 | else \ |
| 877 | echo 'libdir=$(libdir)'; \ |
| 878 | fi; \ |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 879 | echo 'includedir=$${prefix}/include'; \ |
| 880 | echo ''; \ |
| 881 | echo 'Name: OpenSSL'; \ |
| 882 | echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \ |
| 883 | echo 'Version: '$(VERSION); \ |
| 884 | echo 'Requires: libssl libcrypto' ) > openssl.pc |
| 885 | |
Richard Levitte | 41240e6 | 2016-09-17 20:50:56 +0200 | [diff] [blame] | 886 | configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -} |
Richard Levitte | 27f42b4 | 2016-02-19 02:30:51 +0100 | [diff] [blame] | 887 | @echo "Detected changed: $?" |
Richard Levitte | a1b6933 | 2018-02-02 20:33:13 +0100 | [diff] [blame] | 888 | $(PERL) configdata.pm -r |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 889 | @echo "**************************************************" |
| 890 | @echo "*** ***" |
| 891 | @echo "*** Please run the same make command again ***" |
| 892 | @echo "*** ***" |
| 893 | @echo "**************************************************" |
| 894 | @false |
| 895 | |
Richard Levitte | bf01fbb | 2018-01-29 23:17:43 +0100 | [diff] [blame] | 896 | reconfigure reconf: |
Richard Levitte | a1b6933 | 2018-02-02 20:33:13 +0100 | [diff] [blame] | 897 | $(PERL) configdata.pm -r |
Richard Levitte | bf01fbb | 2018-01-29 23:17:43 +0100 | [diff] [blame] | 898 | |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 899 | {- |
| 900 | use File::Basename; |
| 901 | use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; |
Richard Levitte | cedbb14 | 2016-02-11 13:10:11 +0100 | [diff] [blame] | 902 | |
| 903 | # Helper function to figure out dependencies on libraries |
| 904 | # It takes a list of library names and outputs a list of dependencies |
| 905 | sub compute_lib_depends { |
Richard Levitte | 84af1ba | 2016-02-22 13:52:46 +0100 | [diff] [blame] | 906 | if ($disabled{shared}) { |
Richard Levitte | 3310581 | 2017-04-18 16:24:23 +0200 | [diff] [blame] | 907 | return map { lib($_) } @_; |
Richard Levitte | cedbb14 | 2016-02-11 13:10:11 +0100 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | # Depending on shared libraries: |
| 911 | # On Windows POSIX layers, we depend on {libname}.dll.a |
| 912 | # On Unix platforms, we depend on {shlibname}.so |
Richard Levitte | 186a31e | 2016-11-09 20:01:51 +0100 | [diff] [blame] | 913 | return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_; |
Richard Levitte | cedbb14 | 2016-02-11 13:10:11 +0100 | [diff] [blame] | 914 | } |
| 915 | |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 916 | sub generatesrc { |
| 917 | my %args = @_; |
| 918 | my $generator = join(" ", @{$args{generator}}); |
Richard Levitte | 8d34daf | 2016-04-21 14:30:08 +0200 | [diff] [blame] | 919 | my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}}); |
Richard Levitte | d460572 | 2016-03-10 09:04:09 +0100 | [diff] [blame] | 920 | my $incs = join("", map { " -I".$_ } @{$args{incs}}); |
Richard Levitte | 8d34daf | 2016-04-21 14:30:08 +0200 | [diff] [blame] | 921 | my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}}); |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 922 | |
| 923 | if ($args{src} !~ /\.[sS]$/) { |
Richard Levitte | 7cae386 | 2016-06-13 22:02:11 +0200 | [diff] [blame] | 924 | if ($args{generator}->[0] =~ m|^.*\.in$|) { |
| 925 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, |
| 926 | "util", "dofile.pl")), |
| 927 | rel2abs($config{builddir})); |
| 928 | return <<"EOF"; |
| 929 | $args{src}: $args{generator}->[0] $deps |
| 930 | \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ |
| 931 | "-o$target{build_file}" $generator > \$@ |
| 932 | EOF |
| 933 | } else { |
| 934 | return <<"EOF"; |
Richard Levitte | 769777b | 2016-03-19 00:57:35 +0100 | [diff] [blame] | 935 | $args{src}: $args{generator}->[0] $deps |
Richard Levitte | 8d34daf | 2016-04-21 14:30:08 +0200 | [diff] [blame] | 936 | \$(PERL)$generator_incs $generator > \$@ |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 937 | EOF |
Richard Levitte | 7cae386 | 2016-06-13 22:02:11 +0200 | [diff] [blame] | 938 | } |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 939 | } else { |
Richard Levitte | 8458f1b | 2016-03-08 19:19:53 +0100 | [diff] [blame] | 940 | if ($args{generator}->[0] =~ /\.pl$/) { |
Richard Levitte | 8d34daf | 2016-04-21 14:30:08 +0200 | [diff] [blame] | 941 | $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator; |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 942 | } elsif ($args{generator}->[0] =~ /\.m4$/) { |
Richard Levitte | 8d34daf | 2016-04-21 14:30:08 +0200 | [diff] [blame] | 943 | $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >' |
Richard Levitte | 8458f1b | 2016-03-08 19:19:53 +0100 | [diff] [blame] | 944 | } elsif ($args{generator}->[0] =~ /\.S$/) { |
| 945 | $generator = undef; |
| 946 | } else { |
| 947 | die "Generator type for $args{src} unknown: $generator\n"; |
| 948 | } |
| 949 | |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 950 | my $cppflags = { |
Richard Levitte | 8bc0147 | 2018-02-22 16:33:58 +0100 | [diff] [blame] | 951 | lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', |
| 952 | dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', |
| 953 | bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 954 | } -> {$args{intent}}; |
Richard Levitte | 8458f1b | 2016-03-08 19:19:53 +0100 | [diff] [blame] | 955 | if (defined($generator)) { |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 956 | return <<"EOF"; |
Richard Levitte | 769777b | 2016-03-19 00:57:35 +0100 | [diff] [blame] | 957 | $args{src}: $args{generator}->[0] $deps |
Richard Levitte | 8458f1b | 2016-03-08 19:19:53 +0100 | [diff] [blame] | 958 | $generator \$@ |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 959 | EOF |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 960 | } |
Richard Levitte | 8458f1b | 2016-03-08 19:19:53 +0100 | [diff] [blame] | 961 | return <<"EOF"; |
Richard Levitte | 769777b | 2016-03-19 00:57:35 +0100 | [diff] [blame] | 962 | $args{src}: $args{generator}->[0] $deps |
Richard Levitte | d3f9268 | 2018-04-04 15:23:30 +0200 | [diff] [blame] | 963 | \$(CC) $incs $cppflags -E $args{generator}->[0] | \\ |
Andy Polyakov | 39199fb | 2016-05-02 23:38:11 +0200 | [diff] [blame] | 964 | \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@ |
Richard Levitte | 8458f1b | 2016-03-08 19:19:53 +0100 | [diff] [blame] | 965 | EOF |
Richard Levitte | 66ddf17 | 2016-03-07 14:38:54 +0100 | [diff] [blame] | 966 | } |
| 967 | } |
| 968 | |
Richard Levitte | bb26842 | 2016-03-11 13:25:48 +0100 | [diff] [blame] | 969 | # Should one wonder about the end of the Perl snippet, it's because this |
| 970 | # second regexp eats up line endings as well, if the removed path is the |
| 971 | # last in the line. We may therefore need to put back a line ending. |
Richard Levitte | 8829728 | 2016-02-18 13:04:05 +0100 | [diff] [blame] | 972 | sub src2obj { |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 973 | my %args = @_; |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 974 | (my $obj = $args{obj}) =~ s|\.o$||; |
Andy Polyakov | a23f031 | 2018-03-09 13:57:38 +0100 | [diff] [blame] | 975 | my @srcs = @{$args{srcs}}; |
Richard Levitte | 8458f1b | 2016-03-08 19:19:53 +0100 | [diff] [blame] | 976 | my $srcs = join(" ", @srcs); |
| 977 | my $deps = join(" ", @srcs, @{$args{deps}}); |
Richard Levitte | 45502bf | 2016-02-19 22:02:41 +0100 | [diff] [blame] | 978 | my $incs = join("", map { " -I".$_ } @{$args{incs}}); |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 979 | my $cmd; |
| 980 | my $cmdflags; |
| 981 | my $cmdcompile; |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 982 | if (grep /\.rc$/, @srcs) { |
| 983 | $cmd = '$(RC)'; |
| 984 | $cmdflags = '$(RCFLAGS)'; |
Richard Levitte | 8c3bc59 | 2018-01-23 13:54:55 +0100 | [diff] [blame] | 985 | $cmdcompile = ''; |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 986 | } elsif (grep /\.(cc|cpp)$/, @srcs) { |
| 987 | $cmd = '$(CXX)'; |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 988 | $cmdcompile = ' -c'; |
| 989 | $cmdflags = { |
| 990 | lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)', |
| 991 | dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)', |
| 992 | bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)' |
| 993 | } -> {$args{intent}}; |
Richard Levitte | 7763472 | 2016-10-12 15:30:43 +0200 | [diff] [blame] | 994 | } else { |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 995 | $cmd = '$(CC)'; |
| 996 | $cmdcompile = ' -c'; |
| 997 | $cmdflags = { |
| 998 | lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', |
| 999 | dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', |
| 1000 | bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' |
| 1001 | } -> {$args{intent}}; |
Richard Levitte | 7763472 | 2016-10-12 15:30:43 +0200 | [diff] [blame] | 1002 | } |
Andy Polyakov | a23f031 | 2018-03-09 13:57:38 +0100 | [diff] [blame] | 1003 | my $recipe; |
| 1004 | # extension-specific rules |
| 1005 | if (grep /\.s$/, @srcs) { |
Richard Levitte | 29eed3d | 2016-03-09 01:17:27 +0100 | [diff] [blame] | 1006 | $recipe .= <<"EOF"; |
Andy Polyakov | a23f031 | 2018-03-09 13:57:38 +0100 | [diff] [blame] | 1007 | $obj$objext: $deps |
| 1008 | $cmd $cmdflags -c -o \$\@ $srcs |
| 1009 | EOF |
| 1010 | } elsif (grep /\.S$/, @srcs) { |
Andy Polyakov | 18d1588 | 2018-04-11 10:11:07 +0200 | [diff] [blame] | 1011 | # Originally there was mutli-step rule with $(CC) -E file.S |
| 1012 | # followed by $(CC) -c file.s. It compensated for one of |
| 1013 | # legacy platform compiler's inability to handle .S files. |
| 1014 | # The platform is long discontinued by vendor so there is |
| 1015 | # hardly a point to drag it along... |
Andy Polyakov | a23f031 | 2018-03-09 13:57:38 +0100 | [diff] [blame] | 1016 | $recipe .= <<"EOF"; |
| 1017 | $obj$objext: $deps |
Andy Polyakov | 18d1588 | 2018-04-11 10:11:07 +0200 | [diff] [blame] | 1018 | $cmd $incs $cmdflags -c -o \$\@ $srcs |
Andy Polyakov | a23f031 | 2018-03-09 13:57:38 +0100 | [diff] [blame] | 1019 | EOF |
Bernd Edlinger | 49bb4dd | 2018-04-13 21:41:14 +0200 | [diff] [blame] | 1020 | } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/ |
| 1021 | && !grep /\.rc$/, @srcs) { |
Andy Polyakov | a23f031 | 2018-03-09 13:57:38 +0100 | [diff] [blame] | 1022 | $recipe .= <<"EOF"; |
| 1023 | $obj$objext: $deps |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1024 | $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs |
Richard Levitte | 340da94 | 2016-02-28 00:20:50 +0100 | [diff] [blame] | 1025 | \@touch $obj$depext.tmp |
Richard Levitte | 29b28ee | 2016-03-15 09:05:20 +0100 | [diff] [blame] | 1026 | \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\ |
Richard Levitte | 987dbc7 | 2016-03-11 09:26:49 +0100 | [diff] [blame] | 1027 | rm -f $obj$depext.tmp; \\ |
Richard Levitte | 29b28ee | 2016-03-15 09:05:20 +0100 | [diff] [blame] | 1028 | else \\ |
| 1029 | mv $obj$depext.tmp $obj$depext; \\ |
Richard Levitte | 340da94 | 2016-02-28 00:20:50 +0100 | [diff] [blame] | 1030 | fi |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1031 | EOF |
Richard Levitte | 7e5b8b9 | 2016-09-04 08:10:22 +0200 | [diff] [blame] | 1032 | } else { |
| 1033 | $recipe .= <<"EOF"; |
Andy Polyakov | a23f031 | 2018-03-09 13:57:38 +0100 | [diff] [blame] | 1034 | $obj$objext: $deps |
| 1035 | $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs |
Richard Levitte | 7e5b8b9 | 2016-09-04 08:10:22 +0200 | [diff] [blame] | 1036 | EOF |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1037 | if (defined $makedepprog && $makedepprog =~ /\/makedepend/) { |
Richard Levitte | 7e5b8b9 | 2016-09-04 08:10:22 +0200 | [diff] [blame] | 1038 | $recipe .= <<"EOF"; |
Richard Levitte | c39785d | 2018-03-15 18:06:18 +0100 | [diff] [blame] | 1039 | \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\ |
| 1040 | > $obj$depext |
Richard Levitte | 7e5b8b9 | 2016-09-04 08:10:22 +0200 | [diff] [blame] | 1041 | EOF |
| 1042 | } |
Richard Levitte | 29eed3d | 2016-03-09 01:17:27 +0100 | [diff] [blame] | 1043 | } |
| 1044 | return $recipe; |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1045 | } |
| 1046 | # On Unix, we build shlibs from static libs, so we're ignoring the |
| 1047 | # object file array. We *know* this routine is only called when we've |
| 1048 | # configure 'shared'. |
| 1049 | sub libobj2shlib { |
| 1050 | my %args = @_; |
| 1051 | my $lib = $args{lib}; |
| 1052 | my $shlib = $args{shlib}; |
| 1053 | my $libd = dirname($lib); |
| 1054 | my $libn = basename($lib); |
| 1055 | (my $libname = $libn) =~ s/^lib//; |
Richard Levitte | 47eeaf4 | 2018-01-08 12:28:08 +0100 | [diff] [blame] | 1056 | my @linkdirs = (); |
| 1057 | foreach (@{args{deps}}) { |
| 1058 | my $d = dirname($_); |
| 1059 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; |
| 1060 | } |
| 1061 | my $linkflags = join("", map { "-L$_ " } @linkdirs); |
| 1062 | my $linklibs = join("", map { my $f = basename($_); |
Richard Levitte | cedbb14 | 2016-02-11 13:10:11 +0100 | [diff] [blame] | 1063 | (my $l = $f) =~ s/^lib//; |
Richard Levitte | 47eeaf4 | 2018-01-08 12:28:08 +0100 | [diff] [blame] | 1064 | " -l$l" } @{$args{deps}}); |
Richard Levitte | 29f3cfd | 2018-03-22 22:15:04 +0100 | [diff] [blame] | 1065 | my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" } |
| 1066 | grep { $_ !~ m/\.(?:def|map)$/ } |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1067 | @{$args{objs}}; |
Richard Levitte | 29f3cfd | 2018-03-22 22:15:04 +0100 | [diff] [blame] | 1068 | my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}}; |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1069 | my @deps = compute_lib_depends(@{$args{deps}}); |
| 1070 | die "More than one exported symbol map" if scalar @defs > 1; |
| 1071 | my $objs = join(" ", @objs); |
| 1072 | my $deps = join(" ", @objs, @defs, @deps); |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 1073 | my $target = shlib_simple($lib); |
Richard Levitte | d07abe1 | 2017-07-21 18:04:51 +0200 | [diff] [blame] | 1074 | my $target_full = shlib($lib); |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1075 | my $shared_soname = ""; |
| 1076 | $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full) |
| 1077 | if defined $target{shared_sonameflag}; |
| 1078 | my $shared_imp = ""; |
| 1079 | $shared_imp .= ' '.$target{shared_impflag}.basename($target) |
| 1080 | if defined $target{shared_impflag}; |
| 1081 | my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); |
| 1082 | my $recipe = <<"EOF"; |
| 1083 | # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact |
Richard Levitte | cedbb14 | 2016-02-11 13:10:11 +0100 | [diff] [blame] | 1084 | # that two files get produced, {shlibname}.dll and {libname}.dll.a. |
| 1085 | # With all other Unix platforms, we often build a shared library with the |
| 1086 | # SO version built into the file name and a symlink without the SO version |
| 1087 | # It's not necessary to have both as targets. The choice falls on the |
Richard Levitte | d445302 | 2017-07-19 10:13:41 +0200 | [diff] [blame] | 1088 | # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and |
| 1089 | # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms. |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1090 | $target: $deps |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 1091 | \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\ |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1092 | -o $target_full$shared_def $objs \\ |
Richard Levitte | 150624b | 2018-03-08 00:16:47 +0100 | [diff] [blame] | 1093 | $linklibs \$(LIB_EX_LIBS) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1094 | EOF |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1095 | if (windowsdll()) { |
| 1096 | $recipe .= <<"EOF"; |
Richard Levitte | d445302 | 2017-07-19 10:13:41 +0200 | [diff] [blame] | 1097 | rm -f apps/$shlib'\$(SHLIB_EXT)' |
| 1098 | rm -f test/$shlib'\$(SHLIB_EXT)' |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1099 | rm -f fuzz/$shlib'\$(SHLIB_EXT)' |
Richard Levitte | d445302 | 2017-07-19 10:13:41 +0200 | [diff] [blame] | 1100 | cp -p $shlib'\$(SHLIB_EXT)' apps/ |
| 1101 | cp -p $shlib'\$(SHLIB_EXT)' test/ |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1102 | cp -p $shlib'\$(SHLIB_EXT)' fuzz/ |
Richard Levitte | fcf80c4 | 2016-01-30 05:45:29 +0100 | [diff] [blame] | 1103 | EOF |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1104 | } else { |
| 1105 | $recipe .= <<"EOF"; |
Richard Levitte | 50625bf | 2018-01-22 22:02:36 +0100 | [diff] [blame] | 1106 | if [ '$target' != '$target_full' ]; then \\ |
| 1107 | rm -f $target; \\ |
| 1108 | ln -s $target_full $target; \\ |
| 1109 | fi |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1110 | EOF |
| 1111 | } |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1112 | } |
Richard Levitte | 5386287 | 2016-02-15 18:45:54 +0100 | [diff] [blame] | 1113 | sub obj2dso { |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1114 | my %args = @_; |
Richard Levitte | d07abe1 | 2017-07-21 18:04:51 +0200 | [diff] [blame] | 1115 | my $dso = $args{lib}; |
| 1116 | my $dsod = dirname($dso); |
| 1117 | my $dson = basename($dso); |
Richard Levitte | 47eeaf4 | 2018-01-08 12:28:08 +0100 | [diff] [blame] | 1118 | my @linkdirs = (); |
| 1119 | foreach (@{args{deps}}) { |
| 1120 | my $d = dirname($_); |
| 1121 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; |
| 1122 | } |
| 1123 | my $linkflags = join("", map { "-L$_ " } @linkdirs); |
| 1124 | my $linklibs = join("", map { my $f = basename($_); |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1125 | (my $l = $f) =~ s/^lib//; |
Richard Levitte | 47eeaf4 | 2018-01-08 12:28:08 +0100 | [diff] [blame] | 1126 | " -l$l" } @{$args{deps}}); |
Richard Levitte | 29f3cfd | 2018-03-22 22:15:04 +0100 | [diff] [blame] | 1127 | my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" } |
| 1128 | grep { $_ !~ m/\.(?:def|map)$/ } |
| 1129 | @{$args{objs}}; |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1130 | my @deps = compute_lib_depends(@{$args{deps}}); |
| 1131 | my $objs = join(" ", @objs); |
| 1132 | my $deps = join(" ", @deps); |
Richard Levitte | d07abe1 | 2017-07-21 18:04:51 +0200 | [diff] [blame] | 1133 | my $target = dso($dso); |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1134 | return <<"EOF"; |
Richard Levitte | f5c174f | 2016-02-15 17:42:14 +0100 | [diff] [blame] | 1135 | $target: $objs $deps |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 1136 | \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\ |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1137 | -o $target $objs \\ |
Richard Levitte | 150624b | 2018-03-08 00:16:47 +0100 | [diff] [blame] | 1138 | $linklibs \$(DSO_EX_LIBS) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1139 | EOF |
| 1140 | } |
| 1141 | sub obj2lib { |
| 1142 | my %args = @_; |
Richard Levitte | 3310581 | 2017-04-18 16:24:23 +0200 | [diff] [blame] | 1143 | (my $lib = $args{lib}) =~ s/\.a$//; |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1144 | my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}}; |
| 1145 | my $objs = join(" ", @objs); |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1146 | return <<"EOF"; |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 1147 | $lib$libext: $objs |
Richard Levitte | 5b18235 | 2018-01-26 19:56:44 +0100 | [diff] [blame] | 1148 | \$(AR) \$(ARFLAGS) \$\@ \$\? |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1149 | \$(RANLIB) \$\@ || echo Never mind. |
| 1150 | EOF |
| 1151 | } |
| 1152 | sub obj2bin { |
| 1153 | my %args = @_; |
| 1154 | my $bin = $args{bin}; |
| 1155 | my $bind = dirname($bin); |
| 1156 | my $binn = basename($bin); |
Richard Levitte | 29f3cfd | 2018-03-22 22:15:04 +0100 | [diff] [blame] | 1157 | my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" } |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1158 | @{$args{objs}}); |
Richard Levitte | cedbb14 | 2016-02-11 13:10:11 +0100 | [diff] [blame] | 1159 | my $deps = join(" ",compute_lib_depends(@{$args{deps}})); |
Richard Levitte | 47eeaf4 | 2018-01-08 12:28:08 +0100 | [diff] [blame] | 1160 | my @linkdirs = (); |
| 1161 | foreach (@{args{deps}}) { |
| 1162 | next if $_ =~ /\.a$/; |
| 1163 | my $d = dirname($_); |
| 1164 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; |
| 1165 | } |
| 1166 | my $linkflags = join("", map { "-L$_ " } @linkdirs); |
Richard Levitte | 186a31e | 2016-11-09 20:01:51 +0100 | [diff] [blame] | 1167 | my $linklibs = join("", map { if ($_ =~ /\.a$/) { |
| 1168 | " $_"; |
| 1169 | } else { |
Richard Levitte | 186a31e | 2016-11-09 20:01:51 +0100 | [diff] [blame] | 1170 | my $f = basename($_); |
Richard Levitte | 186a31e | 2016-11-09 20:01:51 +0100 | [diff] [blame] | 1171 | (my $l = $f) =~ s/^lib//; |
Richard Levitte | 47eeaf4 | 2018-01-08 12:28:08 +0100 | [diff] [blame] | 1172 | " -l$l" |
Richard Levitte | 186a31e | 2016-11-09 20:01:51 +0100 | [diff] [blame] | 1173 | } |
| 1174 | } @{$args{deps}}); |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1175 | my $cmd = '$(CC)'; |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 1176 | my $cmdflags = '$(BIN_CFLAGS)'; |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1177 | if (grep /_cc\.o$/, @{$args{objs}}) { |
| 1178 | $cmd = '$(CXX)'; |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 1179 | $cmdflags = '$(BIN_CXXFLAGS)'; |
Richard Levitte | 7763472 | 2016-10-12 15:30:43 +0200 | [diff] [blame] | 1180 | } |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1181 | return <<"EOF"; |
Ben Laurie | 834aae2 | 2016-02-20 15:27:27 +0000 | [diff] [blame] | 1182 | $bin$exeext: $objs $deps |
Richard Levitte | 8118368 | 2017-12-04 14:27:58 +0100 | [diff] [blame] | 1183 | rm -f $bin$exeext |
Richard Levitte | 722c976 | 2018-02-13 20:32:42 +0100 | [diff] [blame] | 1184 | \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\ |
Richard Levitte | 47eeaf4 | 2018-01-08 12:28:08 +0100 | [diff] [blame] | 1185 | -o $bin$exeext $objs \\ |
Richard Levitte | 150624b | 2018-03-08 00:16:47 +0100 | [diff] [blame] | 1186 | $linklibs \$(BIN_EX_LIBS) |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1187 | EOF |
| 1188 | } |
| 1189 | sub in2script { |
| 1190 | my %args = @_; |
| 1191 | my $script = $args{script}; |
| 1192 | my $sources = join(" ", @{$args{sources}}); |
| 1193 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, |
| 1194 | "util", "dofile.pl")), |
| 1195 | rel2abs($config{builddir})); |
| 1196 | return <<"EOF"; |
Richard Levitte | 8829728 | 2016-02-18 13:04:05 +0100 | [diff] [blame] | 1197 | $script: $sources |
Richard Levitte | 4b799ce | 2016-02-14 06:55:45 +0100 | [diff] [blame] | 1198 | \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ |
Richard Levitte | ba327ad | 2016-02-14 08:47:47 +0100 | [diff] [blame] | 1199 | "-o$target{build_file}" $sources > "$script" |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1200 | chmod a+x $script |
| 1201 | EOF |
| 1202 | } |
Richard Levitte | 0ad1d94 | 2016-04-02 22:26:38 +0200 | [diff] [blame] | 1203 | sub generatedir { |
| 1204 | my %args = @_; |
| 1205 | my $dir = $args{dir}; |
| 1206 | my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}}; |
| 1207 | my @actions = (); |
| 1208 | my %extinfo = ( dso => $dsoext, |
| 1209 | lib => $libext, |
| 1210 | bin => $exeext ); |
| 1211 | |
| 1212 | foreach my $type (("dso", "lib", "bin", "script")) { |
| 1213 | next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); |
Richard Levitte | 850000a | 2016-06-28 14:02:44 +0200 | [diff] [blame] | 1214 | # For lib object files, we could update the library. However, it |
| 1215 | # was decided that it's enough to build the directory local object |
| 1216 | # files, so we don't need to add any actions, and the dependencies |
| 1217 | # are already taken care of. |
| 1218 | if ($type ne "lib") { |
Richard Levitte | 0ad1d94 | 2016-04-02 22:26:38 +0200 | [diff] [blame] | 1219 | foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { |
| 1220 | if (dirname($prod) eq $dir) { |
| 1221 | push @deps, $prod.$extinfo{$type}; |
| 1222 | } else { |
| 1223 | push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); |
| 1224 | } |
| 1225 | } |
| 1226 | } |
| 1227 | } |
| 1228 | |
| 1229 | my $deps = join(" ", @deps); |
| 1230 | my $actions = join("\n", "", @actions); |
| 1231 | return <<"EOF"; |
| 1232 | $args{dir} $args{dir}/: $deps$actions |
| 1233 | EOF |
| 1234 | } |
Richard Levitte | 567a9e6 | 2016-01-30 03:25:40 +0100 | [diff] [blame] | 1235 | "" # Important! This becomes part of the template result. |
| 1236 | -} |