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