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