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