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