windows-makefile.tmpl 29.6 KB
Newer Older
1 2 3 4 5 6
##
## Makefile for OpenSSL
##
## {- join("\n## ", @autowarntext) -}
{-
 our $objext = $target{obj_extension} || ".obj";
7
 our $resext = $target{res_extension} || ".res";
8 9 10 11 12 13 14
 our $depext = $target{dep_extension} || ".d";
 our $exeext = $target{exe_extension} || ".exe";
 our $libext = $target{lib_extension} || ".lib";
 our $shlibext = $target{shared_extension} || ".dll";
 our $shlibextimport = $target{shared_import_extension} || ".lib";
 our $dsoext = $target{dso_extension} || ".dll";

15
 (our $sover_dirname = $config{shlib_version_number}) =~ s|\.|_|g;
16

17 18
 my $build_scheme = $target{build_scheme};
 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
19
 my $win_installenv =
20 21
     $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
                                  : "ProgramW6432";
22
 my $win_commonenv =
23 24
     $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
                                  : "CommonProgramW6432";
25
 our $win_installroot =
26
     defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
27
 our $win_commonroot =
28
     defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
29 30 31 32

 # expand variables early
 $win_installroot = $ENV{$win_installroot};
 $win_commonroot = $ENV{$win_commonroot};
33

34 35
 sub shlib {
     my $lib = shift;
36 37
     return () if $disabled{shared} || $lib =~ /\.a$/;
     return () unless defined $unified_info{sharednames}->{$lib};
38 39 40
     return $unified_info{sharednames}->{$lib} . $shlibext;
 }

41 42 43 44 45
 sub lib {
     (my $lib = shift) =~ s/\.a$//;
     return $lib . $libext;
 }

46 47
 sub shlib_import {
     my $lib = shift;
48
     return () if $disabled{shared} || $lib =~ /\.a$/;
49 50 51 52 53 54 55 56
     return $lib . $shlibextimport;
 }

 sub dso {
     my $dso = shift;

     return $dso . $dsoext;
 }
57 58 59 60 61
 # This makes sure things get built in the order they need
 # to. You're welcome.
 sub dependmagic {
     my $target = shift;

62
     return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
63
 }
64 65 66 67 68 69 70 71 72 73 74 75 76
 '';
-}

PLATFORM={- $config{target} -}
SRCDIR={- $config{sourcedir} -}
BLDDIR={- $config{builddir} -}

VERSION={- $config{version} -}
MAJOR={- $config{major} -}
MINOR={- $config{minor} -}

SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}

77
LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
78
SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
79
SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -}
80
ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
81
ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -}
82
PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
83
PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
84
SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
85
{- output_off() if $disabled{makedepend}; "" -}
86 87 88
DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
                  grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
                  keys %{$unified_info{sources}}); -}
89
{- output_on() if $disabled{makedepend}; "" -}
90
GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
91 92 93
GENERATED={- # common0.tmpl provides @generated
             join(" ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; $x }
                       @generated) -}
94

B
Bernd Edlinger 已提交
95
INSTALL_LIBS={- join(" ", map { quotify1(lib($_)) } @{$unified_info{install}->{libraries}}) -}
96 97
INSTALL_SHLIBS={- join(" ", map { quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
B
Bernd Edlinger 已提交
98 99 100 101
INSTALL_ENGINES={- join(" ", map { quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
INSTALL_PROGRAMS={- join(" ", map { quotify1($_.$exeext) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
INSTALL_PROGRAMPDBS={- join(" ", map { quotify1($_.".pdb") } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
102
{- output_off() if $disabled{apps}; "" -}
B
Bernd Edlinger 已提交
103 104
BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl"
MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl"
105 106
{- output_on() if $disabled{apps}; "" -}

R
Richard Levitte 已提交
107
APPS_OPENSSL={- use File::Spec::Functions;
B
Bernd Edlinger 已提交
108
                "\"".catfile("apps","openssl")."\"" -}
R
Richard Levitte 已提交
109

110 111
# Do not edit these manually. Use Configure with --prefix or --openssldir
# to change this!  Short explanation in the top comment in Configure
R
Richard Levitte 已提交
112 113 114
INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
                  #
                  use File::Spec::Functions qw(:DEFAULT splitpath);
115 116
                  our $prefix = canonpath($config{prefix}
                                          || "$win_installroot\\OpenSSL");
R
Richard Levitte 已提交
117
                  our ($prefix_dev, $prefix_dir, $prefix_file) =
118
                      splitpath($prefix, 1);
R
Richard Levitte 已提交
119
                  $prefix_dev -}
120
INSTALLTOP_dir={- canonpath($prefix_dir) -}
R
Richard Levitte 已提交
121 122
OPENSSLDIR_dev={- #
                  # The logic here is that if no --openssldir was given,
123
                  # OPENSSLDIR will get the value "$win_commonroot\\SSL".
R
Richard Levitte 已提交
124 125 126 127 128 129 130
                  # If --openssldir was given and the value is an absolute
                  # path, OPENSSLDIR will get its value without change.
                  # If the value from --openssldir is a relative path,
                  # OPENSSLDIR will get $prefix with the --openssldir
                  # value appended as a subdirectory.
                  #
                  use File::Spec::Functions qw(:DEFAULT splitpath);
131
                  our $openssldir =
R
Richard Levitte 已提交
132 133
                      $config{openssldir} ?
                          (file_name_is_absolute($config{openssldir}) ?
134
                               canonpath($config{openssldir})
R
Richard Levitte 已提交
135
                               : catdir($prefix, $config{openssldir}))
136
                          : canonpath("$win_commonroot\\SSL");
R
Richard Levitte 已提交
137 138 139
                  our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
                      splitpath($openssldir, 1);
                  $openssldir_dev -}
140
OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
141
LIBDIR={- our $libdir = $config{libdir} || "lib";
142
          file_name_is_absolute($libdir) ? "" : $libdir -}
R
Richard Levitte 已提交
143
ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
144
                  our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
R
Richard Levitte 已提交
145 146 147
                  our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
                      splitpath($enginesdir, 1);
                  $enginesdir_dev -}
148
ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
R
Richard Levitte 已提交
149 150 151 152 153 154 155 156 157
!IF "$(DESTDIR)" != ""
INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
!ELSE
INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
!ENDIF
158

159 160 161 162
# $(libdir) is chosen to be compatible with the GNU coding standards
libdir={- file_name_is_absolute($libdir)
          ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}

163 164 165 166 167 168 169 170 171 172 173 174
##### User defined commands and flags ################################

CC={- $config{CC} -}
CPP={- $config{CPP} -}
CPPFLAGS={- our $cppflags1 = join(" ",
                                  (map { "-D".$_} @{$config{CPPDEFINES}}),
                                  (map { " /I ".$_} @{$config{CPPINCLUDES}}),
                                  @{$config{CPPFLAGS}}) -}
CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
LD={- $config{LD} -}
LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
175

176
PERL={- $config{PERL} -}
177

178 179 180 181 182 183 184 185
AR={- $config{AR} -}
ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}

MT={- $config{MT} -}
MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}

AS={- $config{AS} -}
ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
186

187
RC={- $config{RC} -}
188

R
Richard Levitte 已提交
189 190
ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"

191 192 193 194 195 196 197
##### Special command flags ##########################################

COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
198
ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
199 200 201 202 203 204 205 206 207 208
RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)

##### Project flags ##################################################

# Variables starting with CNF_ are common variables for all product types

CNF_ASFLAGS={- join(' ', $target{asflags} || (),
                         @{$config{asflags}}) -}
CNF_CPPFLAGS={- our $cppfags2 =
                    join(' ', $target{cppflags} || (),
209 210 211 212
                              (map { '-D'.quotify1($_) } @{$target{defines}},
                                                         @{$config{defines}}),
                              (map { '-I'.quotify1($_) } @{$target{includes}},
                                                         @{$config{includes}}),
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
                              @{$config{cppflags}}) -}
CNF_CFLAGS={- join(' ', $target{cflags} || (),
                        @{$config{cflags}}) -}
CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
                          @{$config{cxxflags}}) -}
CNF_LDFLAGS={- join(' ', $target{lflags} || (),
                         @{$config{lflags}}) -}
CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
                         @{$config{ex_libs}}) -}

# Variables starting with LIB_ are used to build library object files
# and shared libraries.
# Variables starting with DSO_ are used to build DSOs and their object files.
# Variables starting with BIN_ are used to build programs and their object
# files.

LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
                         @{$config{lib_asflags}},
                         '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
232 233
LIB_CPPFLAGS={- our $lib_cppflags =
                join(' ', $target{lib_cppflags} || (),
234
                          $target{shared_cppflag} || (),
235
                          (map { '-D'.quotify1($_) }
236 237 238
                               @{$target{lib_defines}},
                               @{$target{shared_defines}},
                               @{$config{lib_defines}},
239
                               @{$config{shared_defines}}),
240
                          (map { '-I'.quotify1($_) }
241 242 243 244 245
                               @{$target{lib_includes}},
                               @{$target{shared_includes}},
                               @{$config{lib_includes}},
                               @{$config{shared_includes}}),
                          @{$config{lib_cppflags}},
246 247
                          @{$config{shared_cppflag}});
                join(' ', $lib_cppflags,
248
                          (map { '-D'.quotify1($_) }
249 250
                               "OPENSSLDIR=\"$openssldir\"",
                               "ENGINESDIR=\"$enginesdir\""),
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
                          '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
                        $target{shared_cflag} || (),
                        @{$config{lib_cflags}},
                        @{$config{shared_cflag}},
                        '$(CNF_CFLAGS)', '$(CFLAGS)') -}
LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
                         $config{shared_ldflag} || (),
                         '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
                         $target{module_asflags} || (),
                         @{$config{dso_asflags}},
                         @{$config{module_asflags}},
                         '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
                          $target{module_cppflags} || (),
                          @{$config{dso_cppflags}},
                          @{$config{module_cppflags}},
                          '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
                        $target{module_cflags} || (),
                        @{$config{dso_cflags}},
                        @{$config{module_cflags}},
                        '$(CNF_CFLAGS)', '$(CFLAGS)') -}
DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
                         $target{module_ldflags} || (),
                         @{$config{dso_lflags}},
                         @{$config{module_ldflags}},
                         '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
                         @{$config{bin_asflags}},
                         '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
                          @{$config{bin_cppflags}},
                          '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
                        @{$config{bin_cflags}},
                        '$(CNF_CFLAGS)', '$(CFLAGS)') -}
BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
                         @{$config{bin_lflags}},
                         '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)

# CPPFLAGS_Q is used for one thing only: to build up buildinf.h
CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
              $cppflags2 =~ s|([\\"])|\\$1|g;
299 300
              join(' ', $lib_cppflags || (), $cppflags2 || (),
                        $cppflags1 || ()) -}
301

302 303 304 305 306 307
PERLASM_SCHEME= {- $target{perlasm_scheme} -}

PROCESSOR= {- $config{processor} -}

# The main targets ###################################################

308 309 310 311
{- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
{- dependmagic('build_libs'); -}: build_libs_nodep
{- dependmagic('build_engines'); -}: build_engines_nodep
{- dependmagic('build_programs'); -}: build_programs_nodep
312

313
build_generated: $(GENERATED_MANDATORY)
314
build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
315
build_engines_nodep: $(ENGINES)
316
build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
317

318 319 320
# Kept around for backward compatibility
build_apps build_tests: build_programs

321 322 323
# Convenience target to prebuild all generated files, not just the mandatory
# ones
build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
324
	@{- output_off() if $disabled{makedepend}; "" -}
R
Richard Levitte 已提交
325 326 327
	@$(ECHO) "Warning: consider configuring with no-makedepend, because if"
	@$(ECHO) "         target system doesn't have $(PERL),"
	@$(ECHO) "         then make will fail..."
328
	@{- output_on() if $disabled{makedepend}; "" -}
329

330
test: tests
331
{- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
332
	@{- output_off() if $disabled{tests}; "" -}
333
	-mkdir $(BLDDIR)\test\test-runs
334 335
	set SRCTOP=$(SRCDIR)
	set BLDTOP=$(BLDDIR)
336
	set RESULT_D=$(BLDDIR)\test\test-runs
337
	set PERL=$(PERL)
B
Bernd Edlinger 已提交
338
	set OPENSSL_ENGINES=$(MAKEDIR)\engines
339
	set OPENSSL_DEBUG_MEMORY=on
340
	"$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
341
	@{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
R
Richard Levitte 已提交
342
	@$(ECHO) "Tests are not supported with your chosen Configure options"
343
	@{- output_on() if !$disabled{tests}; "" -}
344 345

list-tests:
346
	@{- output_off() if $disabled{tests}; "" -}
347
	@set SRCTOP=$(SRCDIR)
348
	@"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
349
	@{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
R
Richard Levitte 已提交
350
	@$(ECHO) "Tests are not supported with your chosen Configure options"
351
	@{- output_on() if !$disabled{tests}; "" -}
352

353 354 355 356
install: install_sw install_ssldirs install_docs

uninstall: uninstall_docs uninstall_sw

357
libclean:
358 359
	"$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
	-del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
360 361

clean: libclean
362 363 364
	{- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
	-del /Q /F $(ENGINES)
	-del /Q /F $(SCRIPTS)
365
	-del /Q /F $(GENERATED_MANDATORY)
366
	-del /Q /F $(GENERATED)
367 368 369 370
	-del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
	-del /Q /S /F engines\*.lib engines\*.exp
	-del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
	-del /Q /S /F test\*.exp
371
	-rmdir /Q /S test\test-runs
372

373 374 375 376
distclean: clean
	-del /Q /F configdata.pm
	-del /Q /F makefile

377
depend:
378
	@ {- output_off() if $disabled{makedepend}; "" -}
379
	@ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
380
	@ {- output_on() if $disabled{makedepend}; "" -}
381

382 383 384 385 386 387
# Install helper targets #############################################

install_sw: all install_dev install_engines install_runtime

uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev

388
install_docs: install_html_docs
389

390
uninstall_docs: uninstall_html_docs
391 392

install_ssldirs:
R
Richard Levitte 已提交
393 394 395
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
396
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
397 398 399 400
                                        "$(OPENSSLDIR)\openssl.cnf.dist"
	@IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
         "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
                                        "$(OPENSSLDIR)\openssl.cnf"
401
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
R
Richard Levitte 已提交
402
                                        "$(OPENSSLDIR)\misc"
R
Rich Salz 已提交
403 404 405 406 407
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
                                        "$(OPENSSLDIR)\ct_log_list.cnf.dist"
	@IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
         "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
                                        "$(OPENSSLDIR)\ct_log_list.cnf"
408 409

install_dev:
R
Richard Levitte 已提交
410 411
	@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
	@$(ECHO) "*** Installing development files"
R
Richard Levitte 已提交
412
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
413
	@{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
414 415
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
				       "$(INSTALLTOP)\include\openssl"
416
	@{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
417 418
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
				       "$(SRCDIR)\include\openssl\*.h" \
R
Richard Levitte 已提交
419
				       "$(INSTALLTOP)\include\openssl"
B
Bernd Edlinger 已提交
420
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
R
Richard Levitte 已提交
421
				       "$(INSTALLTOP)\include\openssl"
422 423
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
424
	@if "$(SHLIBS)"=="" \
425
	 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
426 427 428 429

uninstall_dev:

install_engines:
R
Richard Levitte 已提交
430 431
	@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
	@$(ECHO) "*** Installing engines"
R
Richard Levitte 已提交
432
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
433
	@if not "$(ENGINES)"=="" \
434
	 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
435
	@if not "$(ENGINES)"=="" \
436
	 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
437 438 439 440

uninstall_engines:

install_runtime:
R
Richard Levitte 已提交
441 442
	@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
	@$(ECHO) "*** Installing runtime files"
R
Richard Levitte 已提交
443
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
444
	@if not "$(SHLIBS)"=="" \
445
	 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
446
	@if not "$(SHLIBS)"=="" \
447
	 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
R
Richard Levitte 已提交
448
                                        "$(INSTALLTOP)\bin"
449
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
R
Richard Levitte 已提交
450
                                        "$(INSTALLTOP)\bin"
451
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
R
Richard Levitte 已提交
452
                                        "$(INSTALLTOP)\bin"
453
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
R
Richard Levitte 已提交
454
                                        "$(INSTALLTOP)\bin"
455 456 457

uninstall_runtime:

458 459
install_html_docs:
        "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
R
Richard Levitte 已提交
460
                "--destdir=$(INSTALLTOP)\html" --type=html
461 462 463

uninstall_html_docs:

464 465
# Building targets ###################################################

466
configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
R
Richard Levitte 已提交
467
	@$(ECHO) "Detected changed: $?"
468
	"$(PERL)" configdata.pm -r
R
Richard Levitte 已提交
469 470 471 472 473
	@$(ECHO) "**************************************************"
	@$(ECHO) "***                                            ***"
	@$(ECHO) "***   Please run the same make command again   ***"
	@$(ECHO) "***                                            ***"
	@$(ECHO) "**************************************************"
A
Andy Polyakov 已提交
474
	@exit 1
475

476
reconfigure reconf:
477
	"$(PERL)" configdata.pm -r
478

479 480 481 482 483 484 485 486
{-
 use File::Basename;
 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;

 # Helper function to figure out dependencies on libraries
 # It takes a list of library names and outputs a list of dependencies
 sub compute_lib_depends {
     if ($disabled{shared}) {
487
	 return map { lib($_) } @_;
488
     }
489 490 491 492 493 494
     foreach (@_) {
         (my $l = $_) =~ s/\.a$//;
         die "Linking with static variants of shared libraries is not supported in this configuration\n"
             if $l ne $_ && shlib($l);
     }
     return map { shlib_import($_) or lib($_) } @_;
495 496
 }

497 498 499
  sub generatesrc {
      my %args = @_;
      (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
500 501
      my ($gen0, @gens) = @{$args{generator}};
      my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
502 503 504 505
      my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
      my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
      my $deps = @{$args{deps}} ?
          '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
506 507

      if ($target !~ /\.asm$/) {
508 509 510 511 512 513 514 515 516 517 518
          if ($args{generator}->[0] =~ m|^.*\.in$|) {
              my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
                                                   "util", "dofile.pl")),
                                   rel2abs($config{builddir}));
              return <<"EOF";
$target: "$args{generator}->[0]" $deps
	"\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
	    "-o$target{build_file}" $generator > \$@
EOF
	  } else {
              return <<"EOF";
519 520
$target: "$args{generator}->[0]" $deps
	"\$(PERL)"$generator_incs $generator > \$@
521
EOF
522
	  }
523 524
      } else {
          if ($args{generator}->[0] =~ /\.pl$/) {
525
              $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
526 527 528 529 530 531
          } elsif ($args{generator}->[0] =~ /\.S$/) {
              $generator = undef;
          } else {
              die "Generator type for $src unknown: $generator\n";
          }

532
          my $cppflags = $incs;
533 534 535 536 537
          $cppflags .= {
              lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
              dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
              bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
          } -> {$args{intent}};
538 539 540 541 542
          if (defined($generator)) {
              # If the target is named foo.S in build.info, we want to
              # end up generating foo.s in two steps.
              if ($args{src} =~ /\.S$/) {
                   return <<"EOF";
543
$target: "$args{generator}->[0]" $deps
544 545
	set ASM=\$(AS)
	$generator \$@.S
R
Richard Levitte 已提交
546
	\$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
547 548 549 550 551
        del /Q \$@.S
EOF
              }
              # Otherwise....
              return <<"EOF";
552
$target: "$args{generator}->[0]" $deps
553 554 555 556 557
	set ASM=\$(AS)
	$generator \$@
EOF
          }
          return <<"EOF";
558
$target: "$args{generator}->[0]" $deps
R
Richard Levitte 已提交
559
	\$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
560 561 562 563
EOF
      }
  }

564 565
 sub src2obj {
     my %args = @_;
A
Andy Polyakov 已提交
566 567
     my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
                    } ( @{$args{srcs}} );
568 569 570
     my $srcs = '"'.join('" "',  @srcs).'"';
     my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
     my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
571 572 573
     my $cflags = { lib => ' $(LIB_CFLAGS)',
		    dso => ' $(DSO_CFLAGS)',
		    bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
574 575 576 577
     $cflags .= $incs;
     $cflags .= { lib => ' $(LIB_CPPFLAGS)',
		  dso => ' $(DSO_CPPFLAGS)',
		  bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
578 579 580
     my $asflags = { lib => ' $(LIB_ASFLAGS)',
		     dso => ' $(DSO_ASFLAGS)',
		     bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
581
     my $makedepprog = $config{makedepprog};
582 583 584 585 586 587 588
     if ($srcs[0] =~ /\.rc$/) {
         return <<"EOF";
$args{obj}: $deps
	\$(RC) \$(RCOUTFLAG)\$\@ $srcs
EOF
     }
     (my $obj = $args{obj}) =~ s|\.o$||;
589 590 591
     if ($srcs[0] =~ /\.asm$/) {
         return <<"EOF";
$obj$objext: $deps
592
	\$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
593 594 595 596 597
EOF
     } elsif ($srcs[0] =~ /.S$/) {
         return <<"EOF";
$obj$objext: $deps
	\$(CC) /EP /D__ASSEMBLER__ $cflags $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
598 599
EOF
     }
600
     return <<"EOF"	if (!$disabled{makedepend});
601
$obj$depext: $deps
602
	\$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
603
$obj$objext: $obj$depext
604
	\$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
605 606 607
EOF
    return <<"EOF"	if ($disabled{makedepend});
$obj$objext: $deps
608
	\$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
609 610 611 612 613 614 615 616 617 618
EOF
 }

 # On Unix, we build shlibs from static libs, so we're ignoring the
 # object file array.  We *know* this routine is only called when we've
 # configure 'shared'.
 sub libobj2shlib {
     my %args = @_;
     my $lib = $args{lib};
     my $shlib = $args{shlib};
619
     my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
620
                grep { $_ =~ m/\.(?:o|res)$/ }
621 622 623 624 625 626 627
                @{$args{objs}};
     my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
     my @deps = compute_lib_depends(@{$args{deps}});
     die "More than one exported symbols list" if scalar @defs > 1;
     my $linklibs = join("", map { "$_\n" } @deps);
     my $objs = join("\n", @objs);
     my $deps = join(" ", @objs, @defs, @deps);
628
     my $target = shlib_import($lib);
629
     my $shared_def = join("", map { " /def:$_" } @defs);
630
     return <<"EOF"
631
$target: $deps
632
	IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest
633
	IF EXIST \$@ DEL /F /Q \$@
634
	\$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
635 636
		/implib:\$@ \$(LDOUTFLAG)$shlib$shlibext$shared_def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1)
$objs
637
$linklibs\$(LIB_EX_LIBS)
638
<<
639
	IF EXIST $shlib$shlibext.manifest \\
640
	   \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext
R
Richard Levitte 已提交
641 642
	IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext
	IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext
M
Matt Caswell 已提交
643
	IF EXIST fuzz\\$shlib$shlibext DEL /Q /F fuzz\\$shlib$shlibext
644 645
	COPY $shlib$shlibext apps
	COPY $shlib$shlibext test
M
Matt Caswell 已提交
646
	COPY $shlib$shlibext fuzz
647 648 649 650 651
EOF
 }
 sub obj2dso {
     my %args = @_;
     my $dso = $args{lib};
652
     my $dso_n = basename($dso);
653 654 655 656 657
     my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
     my @deps = compute_lib_depends(@{$args{deps}});
     my $objs = join("\n", @objs);
     my $linklibs = join("", map { "$_\n" } @deps);
     my $deps = join(" ", @objs, @deps);
658 659
     return <<"EOF";
$dso$dsoext: $deps
660
	IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
661 662
	\$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
LIBRARY         $dso_n
663 664 665 666
EXPORTS
    bind_engine		@1
    v_check		@2
<<
667
$objs
668
$linklibs \$(DSO_EX_LIBS)
669
<<
670
	IF EXIST $dso$dsoext.manifest \\
671
	   \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
672 673 674
EOF
 }
 sub obj2lib {
675 676 677
     my %args = @_;
     my $lib = $args{lib};

678 679 680
     # Because static libs and import libs are both named the same in native
     # Windows, we can't have both.  We skip the static lib in that case,
     # as the shared libs are what we use anyway.
681
     return "" unless $disabled{"shared"} || $lib =~ /\.a$/;
682

683
     $lib =~ s/\.a$//;
684 685 686
     my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
     my $objs = join("\n", @objs);
     my $deps = join(" ", @objs);
687 688 689
     return <<"EOF";
$lib$libext: $deps
	\$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
690
$objs
691 692 693 694 695 696
<<
EOF
 }
 sub obj2bin {
     my %args = @_;
     my $bin = $args{bin};
697 698 699 700 701
     my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
     my @deps = compute_lib_depends(@{$args{deps}});
     my $objs = join("\n", @objs);
     my $linklibs = join("", map { "$_\n" } @deps);
     my $deps = join(" ", @objs, @deps);
702 703
     return <<"EOF";
$bin$exeext: $deps
704
	IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
705
	\$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
706 707
$objs
setargv.obj
708
$linklibs\$(BIN_EX_LIBS)
709
<<
710
	IF EXIST $bin$exeext.manifest \\
711
	   \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
712 713 714 715 716
EOF
  }
  sub in2script {
      my %args = @_;
      my $script = $args{script};
717
      my $sources = '"'.join('" "', @{$args{sources}}).'"';
718 719 720 721 722
      my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
                                           "util", "dofile.pl")),
                           rel2abs($config{builddir}));
      return <<"EOF";
$script: $sources
723
	"\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
724
	    "-o$target{build_file}" $sources > "$script"
725 726 727 728 729 730 731 732 733 734 735 736 737
EOF
  }
  sub generatedir {
      my %args = @_;
      my $dir = $args{dir};
      my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
      my @actions = ();
      my %extinfo = ( dso => $dsoext,
                      lib => $libext,
                      bin => $exeext );

      foreach my $type (("dso", "lib", "bin", "script")) {
          next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
738 739 740 741
          # For lib object files, we could update the library.  However,
          # LIB on Windows doesn't work that way, so we won't create any
          # actions for it, and the dependencies are already taken care of.
          if ($type ne "lib") {
742 743 744 745 746 747 748 749 750 751 752 753
              foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
                  if (dirname($prod) eq $dir) {
                      push @deps, $prod.$extinfo{$type};
                  }
              }
          }
      }

      my $deps = join(" ", @deps);
      my $actions = join("\n", "", @actions);
      return <<"EOF";
$args{dir} $args{dir}\\ : $deps$actions
754 755 756 757
EOF
  }
  ""    # Important!  This becomes part of the template result.
-}