Document the functions EVP_MD_fetch() and EVP_MD_upref()
[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
210 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
211
212 ##### Special command flags ##########################################
213
214 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
215 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
216 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
217 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
218 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
219 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
220 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
221
222 ##### Project flags ##################################################
223
224 # Variables starting with CNF_ are common variables for all product types
225
226 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
227                          @{$config{asflags}}) -}
228 CNF_CPPFLAGS={- our $cppfags2 =
229                     join(' ', $target{cppflags} || (),
230                               (map { '-D'.quotify1($_) } @{$target{defines}},
231                                                          @{$config{defines}}),
232                               (map { '-I'.quotify1($_) } @{$target{includes}},
233                                                          @{$config{includes}}),
234                               @{$config{cppflags}}) -}
235 CNF_CFLAGS={- join(' ', $target{cflags} || (),
236                         @{$config{cflags}}) -}
237 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
238                           @{$config{cxxflags}}) -}
239 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
240                          @{$config{lflags}}) -}
241 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
242                          @{$config{ex_libs}}) -}
243
244 # Variables starting with LIB_ are used to build library object files
245 # and shared libraries.
246 # Variables starting with DSO_ are used to build DSOs and their object files.
247 # Variables starting with BIN_ are used to build programs and their object
248 # files.
249
250 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
251                          @{$config{lib_asflags}},
252                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
253 LIB_CPPFLAGS={- our $lib_cppflags =
254                 join(' ', $target{lib_cppflags} || (),
255                           $target{shared_cppflag} || (),
256                           (map { '-D'.quotify1($_) }
257                                @{$target{lib_defines}},
258                                @{$target{shared_defines}},
259                                @{$config{lib_defines}},
260                                @{$config{shared_defines}}),
261                           (map { '-I'.quotify1($_) }
262                                @{$target{lib_includes}},
263                                @{$target{shared_includes}},
264                                @{$config{lib_includes}},
265                                @{$config{shared_includes}}),
266                           @{$config{lib_cppflags}},
267                           @{$config{shared_cppflag}});
268                 join(' ', $lib_cppflags,
269                           (map { '-D'.quotify1($_) }
270                                "OPENSSLDIR=\"$openssldir\"",
271                                "ENGINESDIR=\"$enginesdir\"",
272                                "MODULESDIR=\"$modulesdir\""),
273                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
274 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
275                         $target{shared_cflag} || (),
276                         @{$config{lib_cflags}},
277                         @{$config{shared_cflag}},
278                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
279 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
280                          $config{shared_ldflag} || (),
281                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
282 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
283 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
284                          $target{module_asflags} || (),
285                          @{$config{dso_asflags}},
286                          @{$config{module_asflags}},
287                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
288 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
289                           $target{module_cppflags} || (),
290                           @{$config{dso_cppflags}},
291                           @{$config{module_cppflags}},
292                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
293 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
294                         $target{module_cflags} || (),
295                         @{$config{dso_cflags}},
296                         @{$config{module_cflags}},
297                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
298 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
299                          $target{module_ldflags} || (),
300                          @{$config{dso_lflags}},
301                          @{$config{module_ldflags}},
302                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
303 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
304 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
305                          @{$config{bin_asflags}},
306                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
307 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
308                           @{$config{bin_cppflags}},
309                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
310 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
311                         @{$config{bin_cflags}},
312                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
313 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
314                          @{$config{bin_lflags}},
315                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
316 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
317
318 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
319 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
320               $cppflags2 =~ s|([\\"])|\\$1|g;
321               join(' ', $lib_cppflags || (), $cppflags2 || (),
322                         $cppflags1 || ()) -}
323
324 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
325
326 PROCESSOR= {- $config{processor} -}
327
328 # The main targets ###################################################
329
330 {- dependmagic('all'); -}: build_libs_nodep build_modules_nodep build_programs_nodep
331 {- dependmagic('build_libs'); -}: build_libs_nodep
332 {- dependmagic('build_modules'); -}: build_modules_nodep
333 {- dependmagic('build_programs'); -}: build_programs_nodep
334
335 build_generated: $(GENERATED_MANDATORY)
336 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
337 build_modules_nodep: $(MODULES)
338 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
339
340 # Kept around for backward compatibility
341 build_apps build_tests: build_programs
342
343 # Convenience target to prebuild all generated files, not just the mandatory
344 # ones
345 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
346         @{- output_off() if $disabled{makedepend}; "" -}
347         @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
348         @$(ECHO) "         target system doesn't have $(PERL),"
349         @$(ECHO) "         then make will fail..."
350         @{- output_on() if $disabled{makedepend}; "" -}
351
352 test: tests
353 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep
354         @{- output_off() if $disabled{tests}; "" -}
355         -mkdir $(BLDDIR)\test\test-runs
356         set SRCTOP=$(SRCDIR)
357         set BLDTOP=$(BLDDIR)
358         set RESULT_D=$(BLDDIR)\test\test-runs
359         set PERL=$(PERL)
360         set OPENSSL_ENGINES=$(MAKEDIR)\engines
361         set OPENSSL_DEBUG_MEMORY=on
362         "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
363         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
364         @$(ECHO) "Tests are not supported with your chosen Configure options"
365         @{- output_on() if !$disabled{tests}; "" -}
366
367 list-tests:
368         @{- output_off() if $disabled{tests}; "" -}
369         @set SRCTOP=$(SRCDIR)
370         @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
371         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
372         @$(ECHO) "Tests are not supported with your chosen Configure options"
373         @{- output_on() if !$disabled{tests}; "" -}
374
375 install: install_sw install_ssldirs install_docs
376
377 uninstall: uninstall_docs uninstall_sw
378
379 libclean:
380         "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
381         -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
382
383 clean: libclean
384         {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
385         -del /Q /F $(MODULES)
386         -del /Q /F $(SCRIPTS)
387         -del /Q /F $(GENERATED_MANDATORY)
388         -del /Q /F $(GENERATED)
389         -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
390         -del /Q /S /F engines\*.lib engines\*.exp
391         -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
392         -del /Q /S /F test\*.exp
393         -rmdir /Q /S test\test-runs
394
395 distclean: clean
396         -del /Q /F configdata.pm
397         -del /Q /F makefile
398
399 depend:
400         @ {- output_off() if $disabled{makedepend}; "" -}
401         @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
402         @ {- output_on() if $disabled{makedepend}; "" -}
403
404 # Install helper targets #############################################
405
406 install_sw: install_dev install_engines install_runtime
407
408 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
409
410 install_docs: install_html_docs
411
412 uninstall_docs: uninstall_html_docs
413
414 install_ssldirs:
415         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
416         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
417         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
418         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
419                                         "$(OPENSSLDIR)\openssl.cnf.dist"
420         @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
421          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
422                                         "$(OPENSSLDIR)\openssl.cnf"
423         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
424                                         "$(OPENSSLDIR)\misc"
425         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
426                                         "$(OPENSSLDIR)\ct_log_list.cnf.dist"
427         @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
428          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
429                                         "$(OPENSSLDIR)\ct_log_list.cnf"
430
431 install_dev: install_runtime_libs
432         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
433         @$(ECHO) "*** Installing development files"
434         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
435         @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
436         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
437                                        "$(INSTALLTOP)\include\openssl"
438         @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
439         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
440                                        "$(SRCDIR)\include\openssl\*.h" \
441                                        "$(INSTALLTOP)\include\openssl"
442         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
443                                        "$(INSTALLTOP)\include\openssl"
444         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
445         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
446         @if "$(SHLIBS)"=="" \
447          "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
448
449 uninstall_dev:
450
451 install_engines: install_runtime_libs build_modules
452         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
453         @$(ECHO) "*** Installing ENGINE modules"
454         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
455         @if not "$(INSTALL_ENGINES)"=="" \
456          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
457         @if not "$(INSTALL_ENGINES)"=="" \
458          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
459
460 uninstall_engines:
461
462 install_runtime: install_programs
463
464 install_runtime_libs: build_libs
465         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
466         @$(ECHO) "*** Installing runtime libraries"
467         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
468         @if not "$(SHLIBS)"=="" \
469          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
470         @if not "$(SHLIBS)"=="" \
471          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
472                                         "$(INSTALLTOP)\bin"
473
474 install_programs: install_runtime_libs build_programs
475         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
476         @$(ECHO) "*** Installing runtime programs"
477         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
478         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
479                                         "$(INSTALLTOP)\bin"
480         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
481                                         "$(INSTALLTOP)\bin"
482         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
483                                         "$(INSTALLTOP)\bin"
484
485 uninstall_runtime:
486
487 install_html_docs:
488         "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
489                 "--destdir=$(INSTALLTOP)\html" --type=html
490
491 uninstall_html_docs:
492
493 # Building targets ###################################################
494
495 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
496         @$(ECHO) "Detected changed: $?"
497         "$(PERL)" configdata.pm -r
498         @$(ECHO) "**************************************************"
499         @$(ECHO) "***                                            ***"
500         @$(ECHO) "***   Please run the same make command again   ***"
501         @$(ECHO) "***                                            ***"
502         @$(ECHO) "**************************************************"
503         @exit 1
504
505 reconfigure reconf:
506         "$(PERL)" configdata.pm -r
507
508 {-
509  use File::Basename;
510  use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
511
512  # Helper function to figure out dependencies on libraries
513  # It takes a list of library names and outputs a list of dependencies
514  sub compute_lib_depends {
515      if ($disabled{shared}) {
516          return map { platform->staticlib($_) } @_;
517      }
518      return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
519  }
520
521   sub generatesrc {
522       my %args = @_;
523       my ($gen0, @gens) = @{$args{generator}};
524       my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
525       my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
526       my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
527       my $defs = join("", map { " /D".$_ } @{$args{defs}});
528       my $deps = @{$args{deps}} ?
529           '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
530
531       if (platform->isdef($args{src})) {
532           my $target = platform->def($args{src});
533           my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
534                                               "util", "mkdef.pl")),
535                               rel2abs($config{builddir}));
536           my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
537           my $ord_name =
538               $args{generator}->[1] || platform->dsoname($args{product});
539           return <<"EOF";
540 $target: $args{generator}->[0] $deps $mkdef
541         \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
542 EOF
543       } elsif (!platform->isasm($args{src})) {
544           my $target = $args{src};
545           if ($args{generator}->[0] =~ m|^.*\.in$|) {
546               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
547                                                    "util", "dofile.pl")),
548                                    rel2abs($config{builddir}));
549               return <<"EOF";
550 $target: "$args{generator}->[0]" $deps
551         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
552             "-o$target{build_file}" $generator > \$@
553 EOF
554           } else {
555               return <<"EOF";
556 $target: "$args{generator}->[0]" $deps
557         "\$(PERL)"$generator_incs $generator > \$@
558 EOF
559           }
560       } else {
561           my $target = platform->asm($args{src});
562           if ($args{generator}->[0] =~ /\.pl$/) {
563               $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
564           } elsif ($args{generator}->[0] =~ /\.S$/) {
565               $generator = undef;
566           } else {
567               die "Generator type for $src unknown: $generator\n";
568           }
569
570           my $cppflags = $incs;
571           $cppflags .= {
572               shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
573               lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
574               dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
575               bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
576           } -> {$args{intent}};
577           if (defined($generator)) {
578               # If the target is named foo.S in build.info, we want to
579               # end up generating foo.s in two steps.
580               if ($args{src} =~ /\.S$/) {
581                    return <<"EOF";
582 $target: "$args{generator}->[0]" $deps
583         set ASM=\$(AS)
584         $generator \$@.S
585         \$(CPP) $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
586         del /Q \$@.S
587 EOF
588               }
589               # Otherwise....
590               return <<"EOF";
591 $target: "$args{generator}->[0]" $deps
592         set ASM=\$(AS)
593         $generator \$@
594 EOF
595           }
596           return <<"EOF";
597 $target: "$args{generator}->[0]" $deps
598         \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
599 EOF
600       }
601   }
602
603  sub src2obj {
604      my %args = @_;
605      my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x } ( @{$args{srcs}} );
606      my $srcs = '"'.join('" "',  @srcs).'"';
607      my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
608      my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
609      my $defs = join("", map { " /D".$_ } @{$args{defs}});
610      my $cflags = { shlib => ' $(LIB_CFLAGS)',
611                     lib => ' $(LIB_CFLAGS)',
612                     dso => ' $(DSO_CFLAGS)',
613                     bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
614      $cflags .= $incs;
615      $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
616                   lib => ' $(LIB_CPPFLAGS)',
617                   dso => ' $(DSO_CPPFLAGS)',
618                   bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
619      my $asflags = { shlib => ' $(LIB_ASFLAGS)',
620                      lib => ' $(LIB_ASFLAGS)',
621                      dso => ' $(DSO_ASFLAGS)',
622                      bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
623      my $makedepprog = $config{makedepprog};
624      if ($srcs[0] =~ /\.rc$/) {
625          my $res = platform->res($args{obj});
626          return <<"EOF";
627 $res: $deps
628         \$(RC) \$(RCOUTFLAG)\$\@ $srcs
629 EOF
630      }
631      my $obj = platform->obj($args{obj});
632      my $dep = platform->dep($args{obj});
633      if ($srcs[0] =~ /\.asm$/) {
634          return <<"EOF";
635 $obj: $deps
636         \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
637 EOF
638      } elsif ($srcs[0] =~ /.S$/) {
639          return <<"EOF";
640 $obj: $deps
641         \$(CC) /EP /D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
642 EOF
643      }
644      my $recipe = <<"EOF";
645 $obj: $deps
646         \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
647 EOF
648      $recipe .= <<"EOF" unless $disabled{makedepend};
649         \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
650 EOF
651      return $recipe;
652  }
653
654  # We *know* this routine is only called when we've configure 'shared'.
655  # Also, note that even though the import library built here looks like
656  # a static library, it really isn't.
657  sub obj2shlib {
658      my %args = @_;
659      my $lib = $args{lib};
660      my @objs = map { platform->convertext($_) }
661                 grep { platform->isobj($_) || platform->isres($_) }
662                 @{$args{objs}};
663      my @defs = map { platform->def($_) }
664                 grep { platform->isdef($_) }
665                 @{$args{objs}};
666      my @deps = compute_lib_depends(@{$args{deps}});
667      die "More than one exported symbols list" if scalar @defs > 1;
668      my $linklibs = join("", map { "$_\n" } @deps);
669      my $objs = join("\n", @objs);
670      my $deps = join(" ", @objs, @defs, @deps);
671      my $import = platform->sharedlib_import($lib);
672      my $dll =  platform->sharedlib($lib);
673      my $shared_def = join("", map { " /def:$_" } @defs);
674      return <<"EOF"
675 # The import library may look like a static library, but it is not.
676 # We MUST make the import library depend on the DLL, in case someone
677 # mistakenly removes the latter.
678 $import: $dll
679 $dll: $deps
680         IF EXIST $full.manifest DEL /F /Q $full.manifest
681         IF EXIST \$@ DEL /F /Q \$@
682         \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
683                 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
684 $objs
685 $linklibs\$(LIB_EX_LIBS)
686 <<
687         IF EXIST $dll.manifest \\
688            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
689         IF EXIST apps\\$dll DEL /Q /F apps\\$dll
690         IF EXIST test\\$dll DEL /Q /F test\\$dll
691         IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
692         COPY $dll apps
693         COPY $dll test
694         COPY $dll fuzz
695 EOF
696  }
697  sub obj2dso {
698      my %args = @_;
699      my $dso = platform->dso($args{lib});
700      my $dso_n = platform->dsoname($args{lib});
701      my @objs = map { platform->convertext($_) }
702                 grep { platform->isobj($_) || platform->isres($_) }
703                 @{$args{objs}};
704      my @defs = map { platform->def($_) }
705                 grep { platform->isdef($_) }
706                 @{$args{objs}};
707      my @deps = compute_lib_depends(@{$args{deps}});
708      my $objs = join("\n", @objs);
709      my $linklibs = join("", map { "$_\n" } @deps);
710      my $deps = join(" ", @objs, @defs, @deps);
711      my $shared_def = join("", map { " /def:$_" } @defs);
712      return <<"EOF";
713 $dso: $deps
714         IF EXIST $dso.manifest DEL /F /Q $dso.manifest
715         \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
716                 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
717 $objs
718 $linklibs \$(DSO_EX_LIBS)
719 <<
720         IF EXIST $dso.manifest \\
721            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
722 EOF
723  }
724  sub obj2lib {
725      my %args = @_;
726      my $lib = platform->staticlib($args{lib});
727      my @objs = map { platform->obj($_) } @{$args{objs}};
728      my $objs = join("\n", @objs);
729      my $deps = join(" ", @objs);
730      return <<"EOF";
731 $lib: $deps
732         \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
733 $objs
734 <<
735 EOF
736  }
737  sub obj2bin {
738      my %args = @_;
739      my $bin = platform->bin($args{bin});
740      my @objs = map { platform->convertext($_) }
741                 grep { platform->isobj($_) || platform->isres($_) }
742                 @{$args{objs}};
743      my @deps = compute_lib_depends(@{$args{deps}});
744      my $objs = join("\n", @objs);
745      my $linklibs = join("", map { "$_\n" } @deps);
746      my $deps = join(" ", @objs, @deps);
747      return <<"EOF";
748 $bin: $deps
749         IF EXIST $bin.manifest DEL /F /Q $bin.manifest
750         \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
751 $objs
752 setargv.obj
753 $linklibs\$(BIN_EX_LIBS)
754 <<
755         IF EXIST $bin.manifest \\
756            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
757 EOF
758   }
759   sub in2script {
760       my %args = @_;
761       my $script = $args{script};
762       my $sources = '"'.join('" "', @{$args{sources}}).'"';
763       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
764                                            "util", "dofile.pl")),
765                            rel2abs($config{builddir}));
766       return <<"EOF";
767 $script: $sources
768         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
769             "-o$target{build_file}" $sources > "$script"
770 EOF
771   }
772   sub generatedir {
773       my %args = @_;
774       my $dir = $args{dir};
775       my @deps = map { platform->convertext($_) } @{$args{deps}};
776       my @actions = ();
777       my %extinfo = ( dso => platform->dsoext(),
778                       lib => platform->libext(),
779                       bin => platform->binext() );
780
781       # We already have a 'test' target, and the top directory is just plain
782       # silly
783       return if $dir eq "test" || $dir eq ".";
784
785       foreach my $type (("dso", "lib", "bin", "script")) {
786           next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
787           # For lib object files, we could update the library.  However,
788           # LIB on Windows doesn't work that way, so we won't create any
789           # actions for it, and the dependencies are already taken care of.
790           if ($type ne "lib") {
791               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
792                   if (dirname($prod) eq $dir) {
793                       push @deps, $prod.$extinfo{$type};
794                   }
795               }
796           }
797       }
798
799       my $deps = join(" ", @deps);
800       my $actions = join("\n", "", @actions);
801       return <<"EOF";
802 $dir $dir\\ : $deps$actions
803 EOF
804   }
805   ""    # Important!  This becomes part of the template result.
806 -}