Don't use '-z defs' if sanitizers are used
[openssl.git] / Configurations / windows-makefile.tmpl
1 ##
2 ## Makefile for OpenSSL
3 ##
4 ## {- join("\n## ", @autowarntext) -}
5 {-
6  our $sover_dirname = platform->shlib_version_as_filename();
7
8  my $build_scheme = $target{build_scheme};
9  my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
10  my $win_installenv =
11      $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
12                                   : "ProgramW6432";
13  my $win_commonenv =
14      $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
15                                   : "CommonProgramW6432";
16  our $win_installroot =
17      defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
18  our $win_commonroot =
19      defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
20
21  # expand variables early
22  $win_installroot = $ENV{$win_installroot};
23  $win_commonroot = $ENV{$win_commonroot};
24
25  # This makes sure things get built in the order they need
26  # to. You're welcome.
27  sub dependmagic {
28      my $target = shift;
29
30      return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
31  }
32  '';
33 -}
34
35 PLATFORM={- $config{target} -}
36 SRCDIR={- $config{sourcedir} -}
37 BLDDIR={- $config{builddir} -}
38
39 VERSION={- "$config{full_version}" -}
40 MAJOR={- $config{major} -}
41 MINOR={- $config{minor} -}
42
43 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
44
45 LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
46 SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
47 SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
48 MODULES={- join(" ", map { platform->dso($_) } @{$unified_info{modules}}) -}
49 MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
50 PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
51 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
52 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
53 {- output_off() if $disabled{makedepend}; "" -}
54 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
55                   grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
56                   keys %{$unified_info{sources}}); -}
57 {- output_on() if $disabled{makedepend}; "" -}
58 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
59 GENERATED={- # common0.tmpl provides @generated
60              join(" ", map { platform->convertext($_) } @generated) -}
61
62 INSTALL_LIBS={-
63         join(" ", map { quotify1(platform->sharedlib_import($_)
64                                  // platform->staticlib($_)) }
65                   grep { !$unified_info{attributes}->{$_}->{noinst} }
66                   @{$unified_info{libraries}})
67 -}
68 INSTALL_SHLIBS={-
69         join(" ", map { my $x = platform->sharedlib($_);
70                         $x ? quotify_l($x) : () }
71                   grep { !$unified_info{attributes}->{$_}->{noinst} }
72                   @{$unified_info{libraries}})
73 -}
74 INSTALL_SHLIBPDBS={-
75         join(" ", map { my $x = platform->sharedlibpdb($_);
76                         $x ? quotify_l($x) : () }
77                   grep { !$unified_info{attributes}->{$_}->{noinst} }
78                   @{$unified_info{libraries}})
79 -}
80 INSTALL_ENGINES={-
81         join(" ", map { quotify1(platform->dso($_)) }
82                   grep { !$unified_info{attributes}->{$_}->{noinst}
83                          && $unified_info{attributes}->{$_}->{engine} }
84                   @{$unified_info{modules}})
85 -}
86 INSTALL_ENGINEPDBS={-
87         join(" ", map { quotify1(platform->dsopdb($_)) }
88                   grep { !$unified_info{attributes}->{$_}->{noinst}
89                          && $unified_info{attributes}->{$_}->{engine} }
90                   @{$unified_info{modules}})
91 -}
92 INSTALL_PROGRAMS={-
93         join(" ", map { quotify1(platform->bin($_)) }
94                   grep { !$unified_info{attributes}->{$_}->{noinst} }
95                   @{$unified_info{programs}})
96 -}
97 INSTALL_PROGRAMPDBS={-
98         join(" ", map { quotify1(platform->binpdb($_)) }
99                   grep { !$unified_info{attributes}->{$_}->{noinst} }
100                   @{$unified_info{programs}})
101 -}
102 BIN_SCRIPTS={-
103         join(" ", map { quotify1($_) }
104                   grep { !$unified_info{attributes}->{$_}->{noinst}
105                          && !$unified_info{attributes}->{$_}->{misc} }
106                   @{$unified_info{scripts}})
107 -}
108 MISC_SCRIPTS={-
109         join(" ", map { quotify1($_) }
110                   grep { !$unified_info{attributes}->{$_}->{noinst}
111                          && $unified_info{attributes}->{$_}->{misc} }
112                   @{$unified_info{scripts}})
113 -}
114
115 APPS_OPENSSL={- use File::Spec::Functions;
116                 "\"".catfile("apps","openssl")."\"" -}
117
118 # Do not edit these manually. Use Configure with --prefix or --openssldir
119 # to change this!  Short explanation in the top comment in Configure
120 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
121                   #
122                   use File::Spec::Functions qw(:DEFAULT splitpath);
123                   our $prefix = canonpath($config{prefix}
124                                           || "$win_installroot\\OpenSSL");
125                   our ($prefix_dev, $prefix_dir, $prefix_file) =
126                       splitpath($prefix, 1);
127                   $prefix_dev -}
128 INSTALLTOP_dir={- canonpath($prefix_dir) -}
129 OPENSSLDIR_dev={- #
130                   # The logic here is that if no --openssldir was given,
131                   # OPENSSLDIR will get the value "$win_commonroot\\SSL".
132                   # If --openssldir was given and the value is an absolute
133                   # path, OPENSSLDIR will get its value without change.
134                   # If the value from --openssldir is a relative path,
135                   # OPENSSLDIR will get $prefix with the --openssldir
136                   # value appended as a subdirectory.
137                   #
138                   use File::Spec::Functions qw(:DEFAULT splitpath);
139                   our $openssldir =
140                       $config{openssldir} ?
141                           (file_name_is_absolute($config{openssldir}) ?
142                                canonpath($config{openssldir})
143                                : catdir($prefix, $config{openssldir}))
144                           : canonpath("$win_commonroot\\SSL");
145                   our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
146                       splitpath($openssldir, 1);
147                   $openssldir_dev -}
148 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
149 LIBDIR={- our $libdir = $config{libdir} || "lib";
150           file_name_is_absolute($libdir) ? "" : $libdir -}
151 MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath);
152                   our $modulesprefix = catdir($prefix,$libdir);
153                   our ($modulesprefix_dev, $modulesprefix_dir,
154                        $modulesprefix_file) =
155                       splitpath($modulesprefix, 1);
156                   our $modulesdir_dev = $modulesprefix_dev;
157                   our $modulesdir_dir =
158                       catdir($modulesprefix_dir, "ossl-modules");
159                   our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir);
160                   our $enginesdir_dev = $modulesprefix_dev;
161                   our $enginesdir_dir =
162                       catdir($modulesprefix_dir, "engines-$sover_dirname");
163                   our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir);
164                   $modulesdir_dev -}
165 MODULESDIR_dir={- canonpath($modulesdir_dir) -}
166 ENGINESDIR_dev={- $enginesdir_dev -}
167 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
168 !IF "$(DESTDIR)" != ""
169 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
170 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
171 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
172 MODULESDIR=$(DESTDIR)$(MODULESDIR_dir)
173 !ELSE
174 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
175 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
176 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
177 MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir)
178 !ENDIF
179
180 # $(libdir) is chosen to be compatible with the GNU coding standards
181 libdir={- file_name_is_absolute($libdir)
182           ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
183
184 ##### User defined commands and flags ################################
185
186 CC={- $config{CC} -}
187 CPP={- $config{CPP} -}
188 CPPFLAGS={- our $cppflags1 = join(" ",
189                                   (map { "-D".$_} @{$config{CPPDEFINES}}),
190                                   (map { " /I ".$_} @{$config{CPPINCLUDES}}),
191                                   @{$config{CPPFLAGS}}) -}
192 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
193 LD={- $config{LD} -}
194 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
195 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
196
197 PERL={- $config{PERL} -}
198
199 AR={- $config{AR} -}
200 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
201
202 MT={- $config{MT} -}
203 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
204
205 AS={- $config{AS} -}
206 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
207
208 RC={- $config{RC} -}
209 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -}
210
211 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
212
213 ##### Special command flags ##########################################
214
215 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
216 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
217 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
218 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
219 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
220 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
221 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
222
223 ##### Project flags ##################################################
224
225 # Variables starting with CNF_ are common variables for all product types
226
227 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
228                          @{$config{asflags}}) -}
229 CNF_CPPFLAGS={- our $cppfags2 =
230                     join(' ', $target{cppflags} || (),
231                               (map { '-D'.quotify1($_) } @{$target{defines}},
232                                                          @{$config{defines}}),
233                               (map { '-I'.quotify1($_) } @{$target{includes}},
234                                                          @{$config{includes}}),
235                               @{$config{cppflags}}) -}
236 CNF_CFLAGS={- join(' ', $target{cflags} || (),
237                         @{$config{cflags}}) -}
238 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
239                           @{$config{cxxflags}}) -}
240 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
241                          @{$config{lflags}}) -}
242 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
243                          @{$config{ex_libs}}) -}
244
245 # Variables starting with LIB_ are used to build library object files
246 # and shared libraries.
247 # Variables starting with DSO_ are used to build DSOs and their object files.
248 # Variables starting with BIN_ are used to build programs and their object
249 # files.
250
251 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
252                          @{$config{lib_asflags}},
253                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
254 LIB_CPPFLAGS={- our $lib_cppflags =
255                 join(' ', $target{lib_cppflags} || (),
256                           $target{shared_cppflag} || (),
257                           (map { '-D'.quotify1($_) }
258                                @{$target{lib_defines}},
259                                @{$target{shared_defines}},
260                                @{$config{lib_defines}},
261                                @{$config{shared_defines}}),
262                           (map { '-I'.quotify1($_) }
263                                @{$target{lib_includes}},
264                                @{$target{shared_includes}},
265                                @{$config{lib_includes}},
266                                @{$config{shared_includes}}),
267                           @{$config{lib_cppflags}},
268                           @{$config{shared_cppflag}});
269                 join(' ', $lib_cppflags,
270                           (map { '-D'.quotify1($_) }
271                                "OPENSSLDIR=\"$openssldir\"",
272                                "ENGINESDIR=\"$enginesdir\"",
273                                "MODULESDIR=\"$modulesdir\""),
274                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
275 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
276                         $target{shared_cflag} || (),
277                         @{$config{lib_cflags}},
278                         @{$config{shared_cflag}},
279                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
280 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
281                          $config{shared_ldflag} || (),
282                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
283 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
284 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
285                          $target{module_asflags} || (),
286                          @{$config{dso_asflags}},
287                          @{$config{module_asflags}},
288                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
289 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
290                           $target{module_cppflags} || (),
291                           @{$config{dso_cppflags}},
292                           @{$config{module_cppflags}},
293                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
294 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
295                         $target{module_cflags} || (),
296                         @{$config{dso_cflags}},
297                         @{$config{module_cflags}},
298                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
299 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
300                          $target{module_ldflags} || (),
301                          @{$config{dso_lflags}},
302                          @{$config{module_ldflags}},
303                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
304 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
305 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
306                          @{$config{bin_asflags}},
307                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
308 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
309                           @{$config{bin_cppflags}},
310                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
311 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
312                         @{$config{bin_cflags}},
313                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
314 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
315                          @{$config{bin_lflags}},
316                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
317 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
318
319 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
320 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
321               $cppflags2 =~ s|([\\"])|\\$1|g;
322               join(' ', $lib_cppflags || (), $cppflags2 || (),
323                         $cppflags1 || ()) -}
324
325 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
326
327 PROCESSOR= {- $config{processor} -}
328
329 # The main targets ###################################################
330
331 {- dependmagic('all'); -}: build_libs_nodep build_modules_nodep build_programs_nodep
332 {- dependmagic('build_libs'); -}: build_libs_nodep
333 {- dependmagic('build_modules'); -}: build_modules_nodep
334 {- dependmagic('build_programs'); -}: build_programs_nodep
335
336 build_generated: $(GENERATED_MANDATORY)
337 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
338 build_modules_nodep: $(MODULES)
339 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
340
341 # Kept around for backward compatibility
342 build_apps build_tests: build_programs
343
344 # Convenience target to prebuild all generated files, not just the mandatory
345 # ones
346 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
347         @{- output_off() if $disabled{makedepend}; "" -}
348         @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
349         @$(ECHO) "         target system doesn't have $(PERL),"
350         @$(ECHO) "         then make will fail..."
351         @{- output_on() if $disabled{makedepend}; "" -}
352
353 test: tests
354 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep
355         @{- output_off() if $disabled{tests}; "" -}
356         -mkdir $(BLDDIR)\test\test-runs
357         set SRCTOP=$(SRCDIR)
358         set BLDTOP=$(BLDDIR)
359         set RESULT_D=$(BLDDIR)\test\test-runs
360         set PERL=$(PERL)
361         set OPENSSL_ENGINES=$(MAKEDIR)\engines
362         set OPENSSL_DEBUG_MEMORY=on
363         "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
364         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
365         @$(ECHO) "Tests are not supported with your chosen Configure options"
366         @{- output_on() if !$disabled{tests}; "" -}
367
368 list-tests:
369         @{- output_off() if $disabled{tests}; "" -}
370         @set SRCTOP=$(SRCDIR)
371         @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
372         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
373         @$(ECHO) "Tests are not supported with your chosen Configure options"
374         @{- output_on() if !$disabled{tests}; "" -}
375
376 install: install_sw install_ssldirs install_docs
377
378 uninstall: uninstall_docs uninstall_sw
379
380 libclean:
381         "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
382         -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
383
384 clean: libclean
385         {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
386         -del /Q /F $(MODULES)
387         -del /Q /F $(SCRIPTS)
388         -del /Q /F $(GENERATED_MANDATORY)
389         -del /Q /F $(GENERATED)
390         -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
391         -del /Q /S /F engines\*.lib engines\*.exp
392         -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
393         -del /Q /S /F test\*.exp
394         -rmdir /Q /S test\test-runs
395
396 distclean: clean
397         -del /Q /F configdata.pm
398         -del /Q /F makefile
399
400 depend:
401         @ {- output_off() if $disabled{makedepend}; "" -}
402         @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
403         @ {- output_on() if $disabled{makedepend}; "" -}
404
405 # Install helper targets #############################################
406
407 install_sw: install_dev install_engines install_runtime
408
409 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
410
411 install_docs: install_html_docs
412
413 uninstall_docs: uninstall_html_docs
414
415 install_ssldirs:
416         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
417         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
418         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
419         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
420                                         "$(OPENSSLDIR)\openssl.cnf.dist"
421         @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
422          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
423                                         "$(OPENSSLDIR)\openssl.cnf"
424         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
425                                         "$(OPENSSLDIR)\misc"
426         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
427                                         "$(OPENSSLDIR)\ct_log_list.cnf.dist"
428         @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
429          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
430                                         "$(OPENSSLDIR)\ct_log_list.cnf"
431
432 install_dev: install_runtime_libs
433         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
434         @$(ECHO) "*** Installing development files"
435         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
436         @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
437         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
438                                        "$(INSTALLTOP)\include\openssl"
439         @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
440         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
441                                        "$(SRCDIR)\include\openssl\*.h" \
442                                        "$(INSTALLTOP)\include\openssl"
443         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
444                                        "$(INSTALLTOP)\include\openssl"
445         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
446         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
447         @if "$(SHLIBS)"=="" \
448          "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
449
450 uninstall_dev:
451
452 install_engines: install_runtime_libs build_modules
453         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
454         @$(ECHO) "*** Installing ENGINE modules"
455         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
456         @if not "$(INSTALL_ENGINES)"=="" \
457          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
458         @if not "$(INSTALL_ENGINES)"=="" \
459          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
460
461 uninstall_engines:
462
463 install_runtime: install_programs
464
465 install_runtime_libs: build_libs
466         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
467         @$(ECHO) "*** Installing runtime libraries"
468         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
469         @if not "$(SHLIBS)"=="" \
470          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
471         @if not "$(SHLIBS)"=="" \
472          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
473                                         "$(INSTALLTOP)\bin"
474
475 install_programs: install_runtime_libs build_programs
476         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
477         @$(ECHO) "*** Installing runtime programs"
478         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
479         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
480                                         "$(INSTALLTOP)\bin"
481         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
482                                         "$(INSTALLTOP)\bin"
483         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
484                                         "$(INSTALLTOP)\bin"
485
486 uninstall_runtime:
487
488 install_html_docs:
489         "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
490                 "--destdir=$(INSTALLTOP)\html" --type=html
491
492 uninstall_html_docs:
493
494 # Building targets ###################################################
495
496 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
497         @$(ECHO) "Detected changed: $?"
498         "$(PERL)" configdata.pm -r
499         @$(ECHO) "**************************************************"
500         @$(ECHO) "***                                            ***"
501         @$(ECHO) "***   Please run the same make command again   ***"
502         @$(ECHO) "***                                            ***"
503         @$(ECHO) "**************************************************"
504         @exit 1
505
506 reconfigure reconf:
507         "$(PERL)" configdata.pm -r
508
509 {-
510  use File::Basename;
511  use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
512
513  # Helper function to figure out dependencies on libraries
514  # It takes a list of library names and outputs a list of dependencies
515  sub compute_lib_depends {
516      if ($disabled{shared}) {
517          return map { platform->staticlib($_) } @_;
518      }
519      return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
520  }
521
522   sub generatesrc {
523       my %args = @_;
524       my ($gen0, @gens) = @{$args{generator}};
525       my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
526       my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
527       my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
528       my $defs = join("", map { " /D".$_ } @{$args{defs}});
529       my $deps = @{$args{deps}} ?
530           '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
531
532       if (platform->isdef($args{src})) {
533           my $target = platform->def($args{src});
534           my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
535                                               "util", "mkdef.pl")),
536                               rel2abs($config{builddir}));
537           my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
538           my $ord_name =
539               $args{generator}->[1] || platform->dsoname($args{product});
540           return <<"EOF";
541 $target: $args{generator}->[0] $deps $mkdef
542         \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
543 EOF
544       } elsif (!platform->isasm($args{src})) {
545           my $target = $args{src};
546           if ($args{generator}->[0] =~ m|^.*\.in$|) {
547               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
548                                                    "util", "dofile.pl")),
549                                    rel2abs($config{builddir}));
550               return <<"EOF";
551 $target: "$args{generator}->[0]" $deps
552         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
553             "-o$target{build_file}" $generator > \$@
554 EOF
555           } else {
556               return <<"EOF";
557 $target: "$args{generator}->[0]" $deps
558         "\$(PERL)"$generator_incs $generator > \$@
559 EOF
560           }
561       } else {
562           my $target = platform->asm($args{src});
563           if ($args{generator}->[0] =~ /\.pl$/) {
564               $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
565           } elsif ($args{generator}->[0] =~ /\.S$/) {
566               $generator = undef;
567           } else {
568               die "Generator type for $src unknown: $generator\n";
569           }
570
571           my $cppflags = $incs;
572           $cppflags .= {
573               shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
574               lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
575               dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
576               bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
577           } -> {$args{intent}};
578           if (defined($generator)) {
579               # If the target is named foo.S in build.info, we want to
580               # end up generating foo.s in two steps.
581               if ($args{src} =~ /\.S$/) {
582                    return <<"EOF";
583 $target: "$args{generator}->[0]" $deps
584         set ASM=\$(AS)
585         $generator \$@.S
586         \$(CPP) $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
587         del /Q \$@.S
588 EOF
589               }
590               # Otherwise....
591               return <<"EOF";
592 $target: "$args{generator}->[0]" $deps
593         set ASM=\$(AS)
594         $generator \$@
595 EOF
596           }
597           return <<"EOF";
598 $target: "$args{generator}->[0]" $deps
599         \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
600 EOF
601       }
602   }
603
604  sub src2obj {
605      my $asmext = platform->asmext();
606      my %args = @_;
607      my @srcs =
608          map { my $x = $_;
609                (platform->isasm($x) && grep { $x eq $_ } @generated)
610                ? platform->asm($x) : $x }
611          ( @{$args{srcs}} );
612      my $srcs = '"'.join('" "',  @srcs).'"';
613      my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
614      my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
615      my $defs = join("", map { " /D".$_ } @{$args{defs}});
616      my $cflags = { shlib => ' $(LIB_CFLAGS)',
617                     lib => ' $(LIB_CFLAGS)',
618                     dso => ' $(DSO_CFLAGS)',
619                     bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
620      $cflags .= $incs;
621      $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
622                   lib => ' $(LIB_CPPFLAGS)',
623                   dso => ' $(DSO_CPPFLAGS)',
624                   bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
625      my $asflags = { shlib => ' $(LIB_ASFLAGS)',
626                      lib => ' $(LIB_ASFLAGS)',
627                      dso => ' $(DSO_ASFLAGS)',
628                      bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
629      my $makedepprog = $config{makedepprog};
630      if ($srcs[0] =~ /\.rc$/) {
631          my $res = platform->res($args{obj});
632          return <<"EOF";
633 $res: $deps
634         \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
635 EOF
636      }
637      my $obj = platform->obj($args{obj});
638      my $dep = platform->dep($args{obj});
639      if ($srcs[0] =~ /\Q${asmext}\E$/) {
640          return <<"EOF";
641 $obj: $deps
642         \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
643 EOF
644      } elsif ($srcs[0] =~ /.S$/) {
645          return <<"EOF";
646 $obj: $deps
647         \$(CC) /EP /D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
648 EOF
649      }
650      my $recipe = <<"EOF";
651 $obj: $deps
652         \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
653 EOF
654      $recipe .= <<"EOF" unless $disabled{makedepend};
655         \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
656 EOF
657      return $recipe;
658  }
659
660  # We *know* this routine is only called when we've configure 'shared'.
661  # Also, note that even though the import library built here looks like
662  # a static library, it really isn't.
663  sub obj2shlib {
664      my %args = @_;
665      my $lib = $args{lib};
666      my @objs = map { platform->convertext($_) }
667                 grep { platform->isobj($_) || platform->isres($_) }
668                 @{$args{objs}};
669      my @defs = map { platform->def($_) }
670                 grep { platform->isdef($_) }
671                 @{$args{objs}};
672      my @deps = compute_lib_depends(@{$args{deps}});
673      die "More than one exported symbols list" if scalar @defs > 1;
674      my $linklibs = join("", map { "$_\n" } @deps);
675      my $objs = join("\n", @objs);
676      my $deps = join(" ", @objs, @defs, @deps);
677      my $import = platform->sharedlib_import($lib);
678      my $dll =  platform->sharedlib($lib);
679      my $shared_def = join("", map { " /def:$_" } @defs);
680      return <<"EOF"
681 # The import library may look like a static library, but it is not.
682 # We MUST make the import library depend on the DLL, in case someone
683 # mistakenly removes the latter.
684 $import: $dll
685 $dll: $deps
686         IF EXIST $full.manifest DEL /F /Q $full.manifest
687         IF EXIST \$@ DEL /F /Q \$@
688         \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
689                 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
690 $objs
691 $linklibs\$(LIB_EX_LIBS)
692 <<
693         IF EXIST $dll.manifest \\
694            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
695         IF EXIST apps\\$dll DEL /Q /F apps\\$dll
696         IF EXIST test\\$dll DEL /Q /F test\\$dll
697         IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
698         COPY $dll apps
699         COPY $dll test
700         COPY $dll fuzz
701 EOF
702  }
703  sub obj2dso {
704      my %args = @_;
705      my $dso = platform->dso($args{lib});
706      my $dso_n = platform->dsoname($args{lib});
707      my @objs = map { platform->convertext($_) }
708                 grep { platform->isobj($_) || platform->isres($_) }
709                 @{$args{objs}};
710      my @defs = map { platform->def($_) }
711                 grep { platform->isdef($_) }
712                 @{$args{objs}};
713      my @deps = compute_lib_depends(@{$args{deps}});
714      my $objs = join("\n", @objs);
715      my $linklibs = join("", map { "$_\n" } @deps);
716      my $deps = join(" ", @objs, @defs, @deps);
717      my $shared_def = join("", map { " /def:$_" } @defs);
718      return <<"EOF";
719 $dso: $deps
720         IF EXIST $dso.manifest DEL /F /Q $dso.manifest
721         \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
722                 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
723 $objs
724 $linklibs \$(DSO_EX_LIBS)
725 <<
726         IF EXIST $dso.manifest \\
727            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
728 EOF
729  }
730  sub obj2lib {
731      my %args = @_;
732      my $lib = platform->staticlib($args{lib});
733      my @objs = map { platform->obj($_) } @{$args{objs}};
734      my $objs = join("\n", @objs);
735      my $deps = join(" ", @objs);
736      return <<"EOF";
737 $lib: $deps
738         \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
739 $objs
740 <<
741 EOF
742  }
743  sub obj2bin {
744      my %args = @_;
745      my $bin = platform->bin($args{bin});
746      my @objs = map { platform->convertext($_) }
747                 grep { platform->isobj($_) || platform->isres($_) }
748                 @{$args{objs}};
749      my @deps = compute_lib_depends(@{$args{deps}});
750      my $objs = join("\n", @objs);
751      my $linklibs = join("", map { "$_\n" } @deps);
752      my $deps = join(" ", @objs, @deps);
753      return <<"EOF";
754 $bin: $deps
755         IF EXIST $bin.manifest DEL /F /Q $bin.manifest
756         \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
757 $objs
758 setargv.obj
759 $linklibs\$(BIN_EX_LIBS)
760 <<
761         IF EXIST $bin.manifest \\
762            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
763 EOF
764   }
765   sub in2script {
766       my %args = @_;
767       my $script = $args{script};
768       my $sources = '"'.join('" "', @{$args{sources}}).'"';
769       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
770                                            "util", "dofile.pl")),
771                            rel2abs($config{builddir}));
772       return <<"EOF";
773 $script: $sources
774         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
775             "-o$target{build_file}" $sources > "$script"
776 EOF
777   }
778   sub generatedir {
779       my %args = @_;
780       my $dir = $args{dir};
781       my @deps = map { platform->convertext($_) } @{$args{deps}};
782       my @actions = ();
783       my %extinfo = ( dso => platform->dsoext(),
784                       lib => platform->libext(),
785                       bin => platform->binext() );
786
787       # We already have a 'test' target, and the top directory is just plain
788       # silly
789       return if $dir eq "test" || $dir eq ".";
790
791       foreach my $type (("dso", "lib", "bin", "script")) {
792           next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
793           # For lib object files, we could update the library.  However,
794           # LIB on Windows doesn't work that way, so we won't create any
795           # actions for it, and the dependencies are already taken care of.
796           if ($type ne "lib") {
797               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
798                   if (dirname($prod) eq $dir) {
799                       push @deps, $prod.$extinfo{$type};
800                   }
801               }
802           }
803       }
804
805       my $deps = join(" ", @deps);
806       my $actions = join("\n", "", @actions);
807       return <<"EOF";
808 $dir $dir\\ : $deps$actions
809 EOF
810   }
811   ""    # Important!  This becomes part of the template result.
812 -}