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