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