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