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