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