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