]>
Commit | Line | Data |
---|---|---|
7c0e1aa6 RL |
1 | ## |
2 | ## Makefile for OpenSSL | |
3 | ## | |
4 | ## {- join("\n## ", @autowarntext) -} | |
5 | {- | |
6 | our $objext = $target{obj_extension} || ".obj"; | |
7 | our $depext = $target{dep_extension} || ".d"; | |
8 | our $exeext = $target{exe_extension} || ".exe"; | |
9 | our $libext = $target{lib_extension} || ".lib"; | |
10 | our $shlibext = $target{shared_extension} || ".dll"; | |
11 | our $shlibextimport = $target{shared_import_extension} || ".lib"; | |
12 | our $dsoext = $target{dso_extension} || ".dll"; | |
13 | ||
ee0a61cf RL |
14 | our $sover = $config{shlib_major}."_".$config{shlib_minor}; |
15 | ||
8c16829e RL |
16 | my $win_installenv = |
17 | $target{build_scheme}->[2] eq "VC-W32" ? | |
18 | "ProgramFiles(x86)" : "ProgramW6432"; | |
19 | my $win_commonenv = | |
20 | $target{build_scheme}->[2] eq "VC-W32" | |
21 | ? "CommonProgramFiles(x86)" : "CommonProgramW6432"; | |
22 | our $win_installroot = | |
23 | defined($ENV{$win_installenv}) | |
9921b7b6 | 24 | ? $win_installenv : 'ProgramFiles'; |
8c16829e RL |
25 | our $win_commonroot = |
26 | defined($ENV{$win_commonenv}) | |
9921b7b6 AP |
27 | ? $win_commonenv : 'CommonProgramFiles'; |
28 | ||
29 | # expand variables early | |
30 | $win_installroot = $ENV{$win_installroot}; | |
31 | $win_commonroot = $ENV{$win_commonroot}; | |
8c16829e | 32 | |
7c0e1aa6 RL |
33 | sub shlib { |
34 | return () if $disabled{shared}; | |
35 | my $lib = shift; | |
36 | return $unified_info{sharednames}->{$lib} . $shlibext; | |
37 | } | |
38 | ||
39 | sub shlib_import { | |
40 | return () if $disabled{shared}; | |
41 | my $lib = shift; | |
42 | return $lib . $shlibextimport; | |
43 | } | |
44 | ||
45 | sub dso { | |
46 | my $dso = shift; | |
47 | ||
48 | return $dso . $dsoext; | |
49 | } | |
50 | ''; | |
51 | -} | |
52 | ||
53 | PLATFORM={- $config{target} -} | |
54 | SRCDIR={- $config{sourcedir} -} | |
55 | BLDDIR={- $config{builddir} -} | |
56 | ||
57 | VERSION={- $config{version} -} | |
58 | MAJOR={- $config{major} -} | |
59 | MINOR={- $config{minor} -} | |
60 | ||
61 | SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -} | |
62 | ||
63 | LIBS={- join(" ", map { $_.$libext } @{$unified_info{libraries}}) -} | |
64 | SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -} | |
3ec8a1cf | 65 | SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -} |
7c0e1aa6 | 66 | ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -} |
3ec8a1cf | 67 | ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -} |
1e3d16b0 RL |
68 | PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -} |
69 | PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -} | |
7c0e1aa6 | 70 | SCRIPTS={- join(" ", @{$unified_info{scripts}}) -} |
bb6b950e | 71 | {- output_off() if $disabled{makedepend}; "" -} |
7c0e1aa6 RL |
72 | DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; } |
73 | grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } | |
74 | keys %{$unified_info{sources}}); -} | |
bb6b950e | 75 | {- output_on() if $disabled{makedepend}; "" -} |
7cae3864 | 76 | GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -} |
05a7aee0 RL |
77 | GENERATED={- join(" ", |
78 | ( map { (my $x = $_) =~ s|\.[sS]$|\.asm|; $x } | |
79 | grep { defined $unified_info{generate}->{$_} } | |
80 | map { @{$unified_info{sources}->{$_}} } | |
81 | grep { /\.o$/ } keys %{$unified_info{sources}} ), | |
82 | ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -} | |
7c0e1aa6 | 83 | |
0f01b7bc RL |
84 | INSTALL_LIBS={- join(" ", map { $_.$libext } @{$unified_info{install}->{libraries}}) -} |
85 | INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -} | |
86 | INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{install}->{libraries}}) -} | |
87 | INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -} | |
88 | INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{install}->{engines}}) -} | |
89 | INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -} | |
90 | INSTALL_PROGRAMPDBS={- join(" ", map { $_.".pdb" } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -} | |
91 | {- output_off() if $disabled{apps}; "" -} | |
92 | BIN_SCRIPTS=$(BLDDIR)\tools\c_rehash.pl | |
93 | MISC_SCRIPTS=$(BLDDIR)\apps\CA.pl $(BLDDIR)\apps\tsget.pl | |
94 | {- output_on() if $disabled{apps}; "" -} | |
95 | ||
7c0e1aa6 RL |
96 | # Do not edit these manually. Use Configure with --prefix or --openssldir |
97 | # to change this! Short explanation in the top comment in Configure | |
b8bbd8b1 RL |
98 | INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet |
99 | # | |
100 | use File::Spec::Functions qw(:DEFAULT splitpath); | |
0685b15a | 101 | our $prefix = $config{prefix} || "$win_installroot\\OpenSSL"; |
b8bbd8b1 | 102 | our ($prefix_dev, $prefix_dir, $prefix_file) = |
0685b15a | 103 | splitpath($prefix, 1); |
b8bbd8b1 RL |
104 | $prefix_dev -} |
105 | INSTALLTOP_dir={- $prefix_dir -} | |
106 | OPENSSLDIR_dev={- # | |
107 | # The logic here is that if no --openssldir was given, | |
108 | # OPENSSLDIR will get the value from $prefix plus "/ssl". | |
109 | # If --openssldir was given and the value is an absolute | |
110 | # path, OPENSSLDIR will get its value without change. | |
111 | # If the value from --openssldir is a relative path, | |
112 | # OPENSSLDIR will get $prefix with the --openssldir | |
113 | # value appended as a subdirectory. | |
114 | # | |
115 | use File::Spec::Functions qw(:DEFAULT splitpath); | |
3ffb060e | 116 | our $openssldir = |
b8bbd8b1 RL |
117 | $config{openssldir} ? |
118 | (file_name_is_absolute($config{openssldir}) ? | |
119 | $config{openssldir} | |
120 | : catdir($prefix, $config{openssldir})) | |
121 | : "$win_commonroot\\SSL"; | |
122 | our ($openssldir_dev, $openssldir_dir, $openssldir_file) = | |
123 | splitpath($openssldir, 1); | |
124 | $openssldir_dev -} | |
125 | OPENSSLDIR_dir={- $openssldir_dir -} | |
8c16829e | 126 | LIBDIR={- our $libdir = $config{libdir} || "lib"; |
7c0e1aa6 | 127 | $libdir -} |
b8bbd8b1 | 128 | ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath); |
3ffb060e | 129 | our $enginesdir = catdir($prefix,$libdir,"engines-$sover"); |
b8bbd8b1 RL |
130 | our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) = |
131 | splitpath($enginesdir, 1); | |
132 | $enginesdir_dev -} | |
133 | ENGINESDIR_dir={- $enginesdir_dir -} | |
134 | !IF "$(DESTDIR)" != "" | |
135 | INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir) | |
136 | OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir) | |
137 | ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir) | |
138 | !ELSE | |
139 | INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir) | |
140 | OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir) | |
141 | ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir) | |
142 | !ENDIF | |
7c0e1aa6 RL |
143 | |
144 | CC={- $target{cc} -} | |
145 | CFLAGS={- join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}})) -} {- join(" ", quotify_l("-DENGINESDIR=\"$enginesdir\"", "-DOPENSSLDIR=\"$openssldir\"")) -} {- $target{cflags} -} {- $config{cflags} -} | |
1fc431ba | 146 | COUTFLAG={- $target{coutflag} || "/Fo" -}$(OSSL_EMPTY) |
0ef1ce49 | 147 | RC={- $target{rc} || "rc" -} |
1fc431ba | 148 | RCOUTFLAG={- $target{rcoutflag} || "/fo" -}$(OSSL_EMPTY) |
7c0e1aa6 RL |
149 | LD={- $target{ld} || "link" -} |
150 | LDFLAGS={- $target{lflags} -} | |
1fc431ba | 151 | LDOUTFLAG={- $target{loutflag} || "/out:" -}$(OSSL_EMPTY) |
2fe73036 RL |
152 | EX_LIBS={- $target{ex_libs} -} |
153 | LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -} | |
bbd9a50f | 154 | LIB_LDFLAGS={- $target{shared_ldflag} || "" -} |
2fe73036 RL |
155 | DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -} |
156 | DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -} | |
7c0e1aa6 | 157 | BIN_CFLAGS={- $target{bin_cflags} -} |
2fe73036 | 158 | BIN_LDFLAGS={- $target{bin_lflags} -} |
7c0e1aa6 RL |
159 | |
160 | PERL={- $config{perl} -} | |
161 | ||
162 | AR={- $target{ar} -} | |
163 | ARFLAGS= {- $target{arflags} -} | |
1fc431ba | 164 | AROUTFLAG={- $target{aroutflag} || "/out:" -}$(OSSL_EMPTY) |
7c0e1aa6 | 165 | |
755542cb RL |
166 | MT={- $target{mt} -} |
167 | MTFLAGS= {- $target{mtflags} -} | |
1fc431ba RL |
168 | MTINFLAG={- $target{mtinflag} || "-manifest " -}$(OSSL_EMPTY) |
169 | MTOUTFLAG={- $target{mtoutflag} || "-outputresource:" -}$(OSSL_EMPTY) | |
755542cb | 170 | |
7c0e1aa6 RL |
171 | AS={- $target{as} -} |
172 | ASFLAGS={- $target{asflags} -} | |
1fc431ba | 173 | ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY) |
7c0e1aa6 RL |
174 | PERLASM_SCHEME= {- $target{perlasm_scheme} -} |
175 | ||
176 | PROCESSOR= {- $config{processor} -} | |
177 | ||
178 | # The main targets ################################################### | |
179 | ||
932eaf00 | 180 | all: build_generated \ |
1e3d16b0 | 181 | build_libs_nodep build_engines_nodep build_programs_nodep depend |
7c0e1aa6 | 182 | |
932eaf00 | 183 | build_libs: build_generated build_libs_nodep depend |
8478a703 | 184 | build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -} |
932eaf00 | 185 | build_engines: build_generated build_engines_nodep depend |
7c0e1aa6 | 186 | build_engines_nodep: $(ENGINES) |
1e3d16b0 RL |
187 | build_programs: build_generated build_programs_nodep depend |
188 | build_programs_nodep: $(PROGRAMS) $(SCRIPTS) | |
7c0e1aa6 | 189 | |
932eaf00 RL |
190 | build_generated: $(GENERATED_MANDATORY) |
191 | ||
1e3d16b0 RL |
192 | # Kept around for backward compatibility |
193 | build_apps build_tests: build_programs | |
194 | ||
1b741653 | 195 | test: tests |
1e3d16b0 | 196 | tests: build_generated build_programs_nodep build_engines_nodep depend |
d90a6beb | 197 | @rem {- output_off() if $disabled{tests}; "" -} |
7c0e1aa6 RL |
198 | set SRCTOP=$(SRCDIR) |
199 | set BLDTOP=$(BLDDIR) | |
200 | set PERL=$(PERL) | |
6d4bc8a3 | 201 | set OPENSSL_DEBUG_MEMORY=on |
cb663908 | 202 | "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS) |
d90a6beb MC |
203 | @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} |
204 | @echo "Tests are not supported with your chosen Configure options" | |
205 | @rem {- output_on() if !$disabled{tests}; "" -} | |
7c0e1aa6 RL |
206 | |
207 | list-tests: | |
4813ad2d RL |
208 | @rem {- output_off() if $disabled{tests}; "" -} |
209 | @set SRCTOP=$(SRCDIR) | |
cb663908 | 210 | @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list |
4813ad2d RL |
211 | @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} |
212 | @echo "Tests are not supported with your chosen Configure options" | |
213 | @rem {- output_on() if !$disabled{tests}; "" -} | |
7c0e1aa6 | 214 | |
8c16829e RL |
215 | install: install_sw install_ssldirs install_docs |
216 | ||
217 | uninstall: uninstall_docs uninstall_sw | |
218 | ||
3415c711 | 219 | libclean: |
cb663908 RL |
220 | "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """$$1.*"""; } @ARGV" $(SHLIBS) |
221 | "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """apps/$$1.*"""; } @ARGV" $(SHLIBS) | |
222 | "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """test/$$1.*"""; } @ARGV" $(SHLIBS) | |
c3ad47f5 | 223 | -del /Q /F $(LIBS) |
592b6fb4 | 224 | -del /Q ossl_static.pdb |
3415c711 RL |
225 | |
226 | clean: libclean | |
1e3d16b0 | 227 | -del /Q /F $(PROGRAMS) $(ENGINES) $(SCRIPTS) |
4813ad2d | 228 | -del /Q /F $(GENERATED) |
c3ad47f5 AP |
229 | -del /Q /S /F *.d |
230 | -del /Q /S /F *.obj | |
231 | -del /Q /S /F *.pdb | |
232 | -del /Q /S /F *.exp | |
233 | -del /Q /S /F engines\*.ilk | |
234 | -del /Q /S /F engines\*.lib | |
b202bf67 RL |
235 | -del /Q /S /F apps\*.lib |
236 | -del /Q /S /F engines\*.manifest | |
237 | -del /Q /S /F apps\*.manifest | |
67152812 | 238 | -del /Q /S /F test\*.manifest |
3415c711 | 239 | |
7cae3864 RL |
240 | distclean: clean |
241 | -del /Q /F configdata.pm | |
242 | -del /Q /F makefile | |
243 | ||
7c0e1aa6 RL |
244 | depend: |
245 | ||
8c16829e RL |
246 | # Install helper targets ############################################# |
247 | ||
248 | install_sw: all install_dev install_engines install_runtime | |
249 | ||
250 | uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev | |
251 | ||
4813ad2d | 252 | install_docs: install_html_docs |
8c16829e | 253 | |
4813ad2d | 254 | uninstall_docs: uninstall_html_docs |
8c16829e RL |
255 | |
256 | install_ssldirs: | |
b8bbd8b1 RL |
257 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs" |
258 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private" | |
259 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc" | |
cb663908 | 260 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \ |
cb926df2 RL |
261 | "$(OPENSSLDIR)\openssl.cnf.dist" |
262 | @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \ | |
263 | "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \ | |
264 | "$(OPENSSLDIR)\openssl.cnf" | |
cb663908 | 265 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \ |
b8bbd8b1 | 266 | "$(OPENSSLDIR)\misc" |
c7af65c7 RS |
267 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \ |
268 | "$(OPENSSLDIR)\ct_log_list.cnf.dist" | |
269 | @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \ | |
270 | "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \ | |
271 | "$(OPENSSLDIR)\ct_log_list.cnf" | |
8c16829e RL |
272 | |
273 | install_dev: | |
274 | @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) | |
275 | @echo *** Installing development files | |
b8bbd8b1 | 276 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl" |
24c4f736 RL |
277 | @rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -} |
278 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \ | |
279 | "$(INSTALLTOP)\include\openssl" | |
280 | @rem {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -} | |
cb663908 | 281 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\include\openssl\*.h" \ |
b8bbd8b1 | 282 | "$(INSTALLTOP)\include\openssl" |
cb663908 | 283 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\include\openssl\*.h \ |
b8bbd8b1 RL |
284 | "$(INSTALLTOP)\include\openssl" |
285 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\$(LIBDIR)" | |
0f01b7bc | 286 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) \ |
b8bbd8b1 | 287 | "$(INSTALLTOP)\$(LIBDIR)" |
3ec8a1cf | 288 | @if "$(SHLIBS)"=="" \ |
cb663908 | 289 | "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb \ |
b8bbd8b1 | 290 | "$(INSTALLTOP)\$(LIBDIR)" |
8c16829e RL |
291 | |
292 | uninstall_dev: | |
293 | ||
294 | install_engines: | |
295 | @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) | |
296 | @echo *** Installing engines | |
b8bbd8b1 | 297 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)" |
8c16829e | 298 | @if not "$(ENGINES)"=="" \ |
0f01b7bc | 299 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)" |
3ec8a1cf | 300 | @if not "$(ENGINES)"=="" \ |
0f01b7bc | 301 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)" |
8c16829e RL |
302 | |
303 | uninstall_engines: | |
304 | ||
305 | install_runtime: | |
306 | @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) | |
307 | @echo *** Installing runtime files | |
b8bbd8b1 | 308 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin" |
8c16829e | 309 | @if not "$(SHLIBS)"=="" \ |
0f01b7bc | 310 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin" |
3ec8a1cf | 311 | @if not "$(SHLIBS)"=="" \ |
0f01b7bc | 312 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \ |
b8bbd8b1 | 313 | "$(INSTALLTOP)\bin" |
0f01b7bc | 314 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \ |
b8bbd8b1 | 315 | "$(INSTALLTOP)\bin" |
0f01b7bc | 316 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \ |
b8bbd8b1 | 317 | "$(INSTALLTOP)\bin" |
cb663908 | 318 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \ |
b8bbd8b1 | 319 | "$(INSTALLTOP)\bin" |
8c16829e RL |
320 | |
321 | uninstall_runtime: | |
322 | ||
4813ad2d RL |
323 | install_html_docs: |
324 | "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \ | |
b8bbd8b1 | 325 | "--destdir=$(INSTALLTOP)\html" --type=html |
4813ad2d RL |
326 | |
327 | uninstall_html_docs: | |
328 | ||
7c0e1aa6 RL |
329 | # Building targets ################################################### |
330 | ||
41240e68 | 331 | configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -} |
7c0e1aa6 RL |
332 | @echo "Detected changed: $?" |
333 | @echo "Reconfiguring..." | |
cb663908 | 334 | "$(PERL)" "$(SRCDIR)\Configure" reconf |
7c0e1aa6 RL |
335 | @echo "**************************************************" |
336 | @echo "*** ***" | |
337 | @echo "*** Please run the same make command again ***" | |
338 | @echo "*** ***" | |
339 | @echo "**************************************************" | |
6ddb62a5 | 340 | @exit 1 |
7c0e1aa6 RL |
341 | |
342 | {- | |
343 | use File::Basename; | |
344 | use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; | |
345 | ||
346 | # Helper function to figure out dependencies on libraries | |
347 | # It takes a list of library names and outputs a list of dependencies | |
348 | sub compute_lib_depends { | |
349 | if ($disabled{shared}) { | |
186a31e5 | 350 | return map { $_ =~ /\.a$/ ? $`.$libext : $_.$libext } @_; |
7c0e1aa6 | 351 | } |
186a31e5 RL |
352 | die "Linking with static OpenSSL libraries is not supported in this configuration\n" |
353 | if grep /\.a$/, @_; | |
7c0e1aa6 RL |
354 | return map { shlib_import($_) } @_; |
355 | } | |
356 | ||
9a1394c5 RL |
357 | sub generatesrc { |
358 | my %args = @_; | |
359 | (my $target = $args{src}) =~ s/\.[sS]$/.asm/; | |
cb663908 RL |
360 | my $generator = '"'.join('" "', @{$args{generator}}).'"'; |
361 | my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}}); | |
362 | my $incs = join("", map { " /I \"$_\"" } @{$args{incs}}); | |
363 | my $deps = @{$args{deps}} ? | |
364 | '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : ''; | |
9a1394c5 RL |
365 | |
366 | if ($target !~ /\.asm$/) { | |
7cae3864 RL |
367 | if ($args{generator}->[0] =~ m|^.*\.in$|) { |
368 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, | |
369 | "util", "dofile.pl")), | |
370 | rel2abs($config{builddir})); | |
371 | return <<"EOF"; | |
372 | $target: "$args{generator}->[0]" $deps | |
373 | "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ | |
374 | "-o$target{build_file}" $generator > \$@ | |
375 | EOF | |
376 | } else { | |
377 | return <<"EOF"; | |
cb663908 RL |
378 | $target: "$args{generator}->[0]" $deps |
379 | "\$(PERL)"$generator_incs $generator > \$@ | |
9a1394c5 | 380 | EOF |
7cae3864 | 381 | } |
9a1394c5 RL |
382 | } else { |
383 | if ($args{generator}->[0] =~ /\.pl$/) { | |
cb663908 | 384 | $generator = '"$(PERL)"'.$generator_incs.' '.$generator; |
9a1394c5 RL |
385 | } elsif ($args{generator}->[0] =~ /\.S$/) { |
386 | $generator = undef; | |
387 | } else { | |
388 | die "Generator type for $src unknown: $generator\n"; | |
389 | } | |
390 | ||
391 | if (defined($generator)) { | |
392 | # If the target is named foo.S in build.info, we want to | |
393 | # end up generating foo.s in two steps. | |
394 | if ($args{src} =~ /\.S$/) { | |
395 | return <<"EOF"; | |
cb663908 | 396 | $target: "$args{generator}->[0]" $deps |
9a1394c5 | 397 | set ASM=\$(AS) |
9a1394c5 | 398 | $generator \$@.S |
57ade571 | 399 | \$(CC) $incs \$(CFLAGS) /EP /C \$@.S > \$@.i && move /Y \$@.i \$@ |
9a1394c5 RL |
400 | del /Q \$@.S |
401 | EOF | |
402 | } | |
403 | # Otherwise.... | |
404 | return <<"EOF"; | |
cb663908 | 405 | $target: "$args{generator}->[0]" $deps |
9a1394c5 | 406 | set ASM=\$(AS) |
9a1394c5 RL |
407 | $generator \$@ |
408 | EOF | |
409 | } | |
410 | return <<"EOF"; | |
cb663908 | 411 | $target: "$args{generator}->[0]" $deps |
57ade571 | 412 | \$(CC) $incs \$(CFLAGS) /EP /C "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@ |
9a1394c5 RL |
413 | EOF |
414 | } | |
415 | } | |
416 | ||
7c0e1aa6 RL |
417 | sub src2obj { |
418 | my %args = @_; | |
419 | my $obj = $args{obj}; | |
6ddb62a5 AP |
420 | my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x |
421 | } ( @{$args{srcs}} ); | |
cb663908 RL |
422 | my $srcs = '"'.join('" "', @srcs).'"'; |
423 | my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"'; | |
424 | my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}}); | |
da430a55 RL |
425 | unless ($disabled{zlib}) { |
426 | if ($withargs{zlib_include}) { | |
cb663908 | 427 | $incs .= ' /I "'.$withargs{zlib_include}.'"'; |
da430a55 RL |
428 | } |
429 | } | |
2fe73036 | 430 | my $ecflags = { lib => '$(LIB_CFLAGS)', |
7c0e1aa6 RL |
431 | dso => '$(DSO_CFLAGS)', |
432 | bin => '$(BIN_CFLAGS)' } -> {$args{intent}}; | |
433 | my $makedepprog = $config{makedepprog}; | |
434 | if ($srcs[0] =~ /\.asm$/) { | |
435 | return <<"EOF"; | |
436 | $obj$objext: $deps | |
437 | \$(AS) \$(ASFLAGS) \$(ASOUTFLAG)\$\@ $srcs | |
438 | EOF | |
439 | } | |
bb6b950e | 440 | return <<"EOF" if (!$disabled{makedepend}); |
7c0e1aa6 RL |
441 | $obj$depext: $deps |
442 | \$(CC) \$(CFLAGS) $ecflags$inc /Zs /showIncludes $srcs 2>&1 | \\ | |
cb663908 | 443 | "\$(PERL)" -n << > $obj$depext |
7c0e1aa6 RL |
444 | chomp; |
445 | s/^Note: including file: *//; | |
446 | \$\$collect{\$\$_} = 1; | |
447 | END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" } | |
dc8941f0 | 448 | << |
7c0e1aa6 | 449 | $obj$objext: $obj$depext |
57ade571 | 450 | \$(CC) $incs \$(CFLAGS) $ecflags -c \$(COUTFLAG)\$\@ @<< |
7c0e1aa6 | 451 | $srcs |
dc8941f0 | 452 | << |
bb6b950e AP |
453 | EOF |
454 | return <<"EOF" if ($disabled{makedepend}); | |
455 | $obj$objext: $deps | |
57ade571 | 456 | \$(CC) $incs \$(CFLAGS) $ecflags -c \$(COUTFLAG)\$\@ $srcs |
7c0e1aa6 RL |
457 | EOF |
458 | } | |
459 | ||
460 | # On Unix, we build shlibs from static libs, so we're ignoring the | |
461 | # object file array. We *know* this routine is only called when we've | |
462 | # configure 'shared'. | |
463 | sub libobj2shlib { | |
464 | my %args = @_; | |
465 | my $lib = $args{lib}; | |
466 | my $shlib = $args{shlib}; | |
467 | (my $mkdef_key = $lib) =~ s/^lib//i; | |
468 | my $objs = join("\n", map { $_.$objext } @{$args{objs}}); | |
469 | my $linklibs = join("", | |
470 | map { "\n$_" } compute_lib_depends(@{$args{deps}})); | |
471 | my $deps = join(" ", | |
472 | (map { $_.$objext } @{$args{objs}}), | |
473 | compute_lib_depends(@{$args{deps}})); | |
474 | my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : ""; | |
475 | my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir}, | |
476 | "util", "mkdef.pl")), | |
477 | rel2abs($config{builddir})); | |
0ef1ce49 RL |
478 | my $mkrc_pl = abs2rel(rel2abs(catfile($config{sourcedir}, |
479 | "util", "mkrc.pl")), | |
480 | rel2abs($config{builddir})); | |
7c0e1aa6 RL |
481 | my $target = shlib_import($lib); |
482 | return <<"EOF" | |
cb663908 RL |
483 | $target: $deps "$ordinalsfile" "$mkdef_pl" |
484 | "\$(PERL)" "$mkdef_pl" "$mkdef_key" 32 > $shlib.def | |
485 | "\$(PERL)" -i.tmp -pe "s|^LIBRARY\\s+${mkdef_key}32|LIBRARY $shlib|;" $shlib.def | |
685b6f29 | 486 | DEL $shlib.def.tmp |
cb663908 | 487 | "\$(PERL)" "$mkrc_pl" $shlib$shlibext > $shlib.rc |
0ef1ce49 | 488 | \$(RC) \$(RCOUTFLAG)$shlib.res $shlib.rc |
755542cb | 489 | IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest |
bbd9a50f | 490 | \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\ |
d237d699 | 491 | /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1) |
0ef1ce49 | 492 | $objs $shlib.res$linklibs \$(EX_LIBS) |
7c0e1aa6 | 493 | << |
755542cb | 494 | IF EXIST $shlib$shlibext.manifest \\ |
1fc431ba | 495 | \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext |
7d52e554 RL |
496 | IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext |
497 | IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext | |
685b6f29 RL |
498 | COPY $shlib$shlibext apps |
499 | COPY $shlib$shlibext test | |
7c0e1aa6 RL |
500 | EOF |
501 | } | |
502 | sub obj2dso { | |
503 | my %args = @_; | |
504 | my $dso = $args{lib}; | |
2fe73036 | 505 | my $dso_n = basename($dso); |
7c0e1aa6 RL |
506 | my $objs = join("\n", map { $_.$objext } @{$args{objs}}); |
507 | my $linklibs = join("", | |
508 | map { "\n$_" } compute_lib_depends(@{$args{deps}})); | |
509 | my $deps = join(" ", | |
510 | (map { $_.$objext } @{$args{objs}}), | |
511 | compute_lib_depends(@{$args{deps}})); | |
512 | return <<"EOF"; | |
513 | $dso$dsoext: $deps | |
755542cb | 514 | IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest |
2fe73036 RL |
515 | \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<< |
516 | LIBRARY $dso_n | |
7c0e1aa6 RL |
517 | EXPORTS |
518 | bind_engine @1 | |
519 | v_check @2 | |
520 | << | |
521 | $objs$linklibs \$(EX_LIBS) | |
522 | << | |
755542cb | 523 | IF EXIST $dso$dsoext.manifest \\ |
1fc431ba | 524 | \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext |
7c0e1aa6 RL |
525 | EOF |
526 | } | |
527 | sub obj2lib { | |
b805b444 RL |
528 | # Because static libs and import libs are both named the same in native |
529 | # Windows, we can't have both. We skip the static lib in that case, | |
530 | # as the shared libs are what we use anyway. | |
531 | return "" unless $disabled{"shared"}; | |
532 | ||
7c0e1aa6 RL |
533 | my %args = @_; |
534 | my $lib = $args{lib}; | |
535 | my $objs = join("\n", map { $_.$objext } @{$args{objs}}); | |
536 | my $deps = join(" ", map { $_.$objext } @{$args{objs}}); | |
537 | return <<"EOF"; | |
538 | $lib$libext: $deps | |
539 | \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<< | |
cfef7e9e | 540 | \$** |
7c0e1aa6 RL |
541 | << |
542 | EOF | |
543 | } | |
544 | sub obj2bin { | |
545 | my %args = @_; | |
546 | my $bin = $args{bin}; | |
547 | my $objs = join("\n", map { $_.$objext } @{$args{objs}}); | |
548 | my $linklibs = join("", | |
549 | map { "\n$_" } compute_lib_depends(@{$args{deps}})); | |
550 | my $deps = join(" ", | |
551 | (map { $_.$objext } @{$args{objs}}), | |
552 | compute_lib_depends(@{$args{deps}})); | |
553 | return <<"EOF"; | |
554 | $bin$exeext: $deps | |
755542cb | 555 | IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest |
2fe73036 | 556 | \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<< |
7c0e1aa6 RL |
557 | $objs setargv.obj$linklibs \$(EX_LIBS) |
558 | << | |
755542cb | 559 | IF EXIST $bin$exeext.manifest \\ |
1fc431ba | 560 | \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext |
7c0e1aa6 RL |
561 | EOF |
562 | } | |
563 | sub in2script { | |
564 | my %args = @_; | |
565 | my $script = $args{script}; | |
cb663908 | 566 | my $sources = '"'.join('" "', @{$args{sources}}).'"'; |
7c0e1aa6 RL |
567 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, |
568 | "util", "dofile.pl")), | |
569 | rel2abs($config{builddir})); | |
570 | return <<"EOF"; | |
571 | $script: $sources | |
cb663908 | 572 | "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ |
7c0e1aa6 | 573 | "-o$target{build_file}" $sources > "$script" |
0ad1d94d RL |
574 | EOF |
575 | } | |
576 | sub generatedir { | |
577 | my %args = @_; | |
578 | my $dir = $args{dir}; | |
579 | my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}}; | |
580 | my @actions = (); | |
581 | my %extinfo = ( dso => $dsoext, | |
582 | lib => $libext, | |
583 | bin => $exeext ); | |
584 | ||
585 | foreach my $type (("dso", "lib", "bin", "script")) { | |
586 | next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); | |
850000aa RL |
587 | # For lib object files, we could update the library. However, |
588 | # LIB on Windows doesn't work that way, so we won't create any | |
589 | # actions for it, and the dependencies are already taken care of. | |
590 | if ($type ne "lib") { | |
0ad1d94d RL |
591 | foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { |
592 | if (dirname($prod) eq $dir) { | |
593 | push @deps, $prod.$extinfo{$type}; | |
594 | } else { | |
850000aa | 595 | push @actions, "\t@rem No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); |
0ad1d94d RL |
596 | } |
597 | } | |
598 | } | |
599 | } | |
600 | ||
601 | my $deps = join(" ", @deps); | |
602 | my $actions = join("\n", "", @actions); | |
603 | return <<"EOF"; | |
604 | $args{dir} $args{dir}\\ : $deps$actions | |
7c0e1aa6 RL |
605 | EOF |
606 | } | |
607 | "" # Important! This becomes part of the template result. | |
608 | -} |