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