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