Home | History | Annotate | Line # | Download | only in Configurations
      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 $resext = $target{res_extension} || ".res";
      8  1.1  christos  our $depext = $target{dep_extension} || ".d";
      9  1.1  christos  our $exeext = $target{exe_extension} || ".exe";
     10  1.1  christos  our $libext = $target{lib_extension} || ".lib";
     11  1.1  christos  our $shlibext = $target{shared_extension} || ".dll";
     12  1.1  christos  our $shlibextimport = $target{shared_import_extension} || ".lib";
     13  1.1  christos  our $dsoext = $target{dso_extension} || ".dll";
     14  1.1  christos 
     15  1.1  christos  (our $sover_dirname = $config{shlib_version_number}) =~ s|\.|_|g;
     16  1.1  christos 
     17  1.1  christos  my $build_scheme = $target{build_scheme};
     18  1.1  christos  my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
     19  1.1  christos  my $win_installenv =
     20  1.1  christos      $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
     21  1.1  christos                                   : "ProgramW6432";
     22  1.1  christos  my $win_commonenv =
     23  1.1  christos      $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
     24  1.1  christos                                   : "CommonProgramW6432";
     25  1.1  christos  our $win_installroot =
     26  1.1  christos      defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
     27  1.1  christos  our $win_commonroot =
     28  1.1  christos      defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
     29  1.1  christos 
     30  1.1  christos  # expand variables early
     31  1.1  christos  $win_installroot = $ENV{$win_installroot};
     32  1.1  christos  $win_commonroot = $ENV{$win_commonroot};
     33  1.1  christos 
     34  1.1  christos  sub shlib {
     35  1.1  christos      my $lib = shift;
     36  1.1  christos      return () if $disabled{shared} || $lib =~ /\.a$/;
     37  1.1  christos      return () unless defined $unified_info{sharednames}->{$lib};
     38  1.1  christos      return $unified_info{sharednames}->{$lib} . $shlibext;
     39  1.1  christos  }
     40  1.1  christos 
     41  1.1  christos  sub lib {
     42  1.1  christos      (my $lib = shift) =~ s/\.a$//;
     43  1.1  christos      $lib .= '_static'
     44  1.1  christos          if (defined $unified_info{sharednames}->{$lib});
     45  1.1  christos      return $lib . $libext;
     46  1.1  christos  }
     47  1.1  christos 
     48  1.1  christos  sub shlib_import {
     49  1.1  christos      my $lib = shift;
     50  1.1  christos      return () if $disabled{shared} || $lib =~ /\.a$/;
     51  1.1  christos      return $lib . $shlibextimport;
     52  1.1  christos  }
     53  1.1  christos 
     54  1.1  christos  sub dso {
     55  1.1  christos      my $dso = shift;
     56  1.1  christos 
     57  1.1  christos      return $dso . $dsoext;
     58  1.1  christos  }
     59  1.1  christos  # This makes sure things get built in the order they need
     60  1.1  christos  # to. You're welcome.
     61  1.1  christos  sub dependmagic {
     62  1.1  christos      my $target = shift;
     63  1.1  christos 
     64  1.1  christos      return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
     65  1.1  christos  }
     66  1.1  christos  '';
     67  1.1  christos -}
     68  1.1  christos 
     69  1.1  christos PLATFORM={- $config{target} -}
     70  1.1  christos SRCDIR={- $config{sourcedir} -}
     71  1.1  christos BLDDIR={- $config{builddir} -}
     72  1.1  christos 
     73  1.1  christos VERSION={- $config{version} -}
     74  1.1  christos MAJOR={- $config{major} -}
     75  1.1  christos MINOR={- $config{minor} -}
     76  1.1  christos 
     77  1.1  christos SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
     78  1.1  christos 
     79  1.1  christos LIBS={- join(" ", map { ( shlib_import($_), lib($_) ) } @{$unified_info{libraries}}) -}
     80  1.1  christos SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
     81  1.1  christos SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -}
     82  1.1  christos ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
     83  1.1  christos ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -}
     84  1.1  christos PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
     85  1.1  christos PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
     86  1.1  christos SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
     87  1.1  christos {- output_off() if $disabled{makedepend}; "" -}
     88  1.1  christos DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
     89  1.1  christos                   grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
     90  1.1  christos                   keys %{$unified_info{sources}}); -}
     91  1.1  christos {- output_on() if $disabled{makedepend}; "" -}
     92  1.1  christos GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
     93  1.1  christos GENERATED={- # common0.tmpl provides @generated
     94  1.1  christos              join(" ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; $x }
     95  1.1  christos                        @generated) -}
     96  1.1  christos 
     97  1.1  christos INSTALL_LIBS={- join(" ", map { quotify1(shlib_import($_) or lib($_)) } @{$unified_info{install}->{libraries}}) -}
     98  1.1  christos INSTALL_SHLIBS={- join(" ", map { quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
     99  1.1  christos INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
    100  1.1  christos INSTALL_ENGINES={- join(" ", map { quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
    101  1.1  christos INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
    102  1.1  christos INSTALL_PROGRAMS={- join(" ", map { quotify1($_.$exeext) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
    103  1.1  christos INSTALL_PROGRAMPDBS={- join(" ", map { quotify1($_.".pdb") } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
    104  1.1  christos {- output_off() if $disabled{apps}; "" -}
    105  1.1  christos BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl"
    106  1.1  christos MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl"
    107  1.1  christos {- output_on() if $disabled{apps}; "" -}
    108  1.1  christos 
    109  1.1  christos APPS_OPENSSL={- use File::Spec::Functions;
    110  1.1  christos                 "\"".catfile("apps","openssl")."\"" -}
    111  1.1  christos 
    112  1.1  christos # Do not edit these manually. Use Configure with --prefix or --openssldir
    113  1.1  christos # to change this!  Short explanation in the top comment in Configure
    114  1.1  christos INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
    115  1.1  christos                   #
    116  1.1  christos                   use File::Spec::Functions qw(:DEFAULT splitpath);
    117  1.1  christos                   our $prefix = canonpath($config{prefix}
    118  1.1  christos                                           || "$win_installroot\\OpenSSL");
    119  1.1  christos                   our ($prefix_dev, $prefix_dir, $prefix_file) =
    120  1.1  christos                       splitpath($prefix, 1);
    121  1.1  christos                   $prefix_dev -}
    122  1.1  christos INSTALLTOP_dir={- canonpath($prefix_dir) -}
    123  1.1  christos OPENSSLDIR_dev={- #
    124  1.1  christos                   # The logic here is that if no --openssldir was given,
    125  1.1  christos                   # OPENSSLDIR will get the value "$win_commonroot\\SSL".
    126  1.1  christos                   # If --openssldir was given and the value is an absolute
    127  1.1  christos                   # path, OPENSSLDIR will get its value without change.
    128  1.1  christos                   # If the value from --openssldir is a relative path,
    129  1.1  christos                   # OPENSSLDIR will get $prefix with the --openssldir
    130  1.1  christos                   # value appended as a subdirectory.
    131  1.1  christos                   #
    132  1.1  christos                   use File::Spec::Functions qw(:DEFAULT splitpath);
    133  1.1  christos                   our $openssldir =
    134  1.1  christos                       $config{openssldir} ?
    135  1.1  christos                           (file_name_is_absolute($config{openssldir}) ?
    136  1.1  christos                                canonpath($config{openssldir})
    137  1.1  christos                                : catdir($prefix, $config{openssldir}))
    138  1.1  christos                           : canonpath("$win_commonroot\\SSL");
    139  1.1  christos                   our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
    140  1.1  christos                       splitpath($openssldir, 1);
    141  1.1  christos                   $openssldir_dev -}
    142  1.1  christos OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
    143  1.1  christos LIBDIR={- our $libdir = $config{libdir} || "lib";
    144  1.1  christos           file_name_is_absolute($libdir) ? "" : $libdir -}
    145  1.1  christos ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
    146  1.1  christos                   our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
    147  1.1  christos                   our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
    148  1.1  christos                       splitpath($enginesdir, 1);
    149  1.1  christos                   $enginesdir_dev -}
    150  1.1  christos ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
    151  1.1  christos !IF "$(DESTDIR)" != ""
    152  1.1  christos INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
    153  1.1  christos OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
    154  1.1  christos ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
    155  1.1  christos !ELSE
    156  1.1  christos INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
    157  1.1  christos OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
    158  1.1  christos ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
    159  1.1  christos !ENDIF
    160  1.1  christos 
    161  1.1  christos # $(libdir) is chosen to be compatible with the GNU coding standards
    162  1.1  christos libdir={- file_name_is_absolute($libdir)
    163  1.1  christos           ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
    164  1.1  christos 
    165  1.1  christos ##### User defined commands and flags ################################
    166  1.1  christos 
    167  1.1  christos CC={- $config{CC} -}
    168  1.1  christos CPP={- $config{CPP} -}
    169  1.1  christos CPPFLAGS={- our $cppflags1 = join(" ",
    170  1.1  christos                                   (map { "-D".$_} @{$config{CPPDEFINES}}),
    171  1.1  christos                                   (map { " /I ".$_} @{$config{CPPINCLUDES}}),
    172  1.1  christos                                   @{$config{CPPFLAGS}}) -}
    173  1.1  christos CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
    174  1.1  christos LD={- $config{LD} -}
    175  1.1  christos LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
    176  1.1  christos EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
    177  1.1  christos 
    178  1.1  christos PERL={- $config{PERL} -}
    179  1.1  christos 
    180  1.1  christos AR={- $config{AR} -}
    181  1.1  christos ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
    182  1.1  christos 
    183  1.1  christos MT={- $config{MT} -}
    184  1.1  christos MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
    185  1.1  christos 
    186  1.1  christos AS={- $config{AS} -}
    187  1.1  christos ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
    188  1.1  christos 
    189  1.1  christos RC={- $config{RC} -}
    190  1.1  christos RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -}
    191  1.1  christos 
    192  1.1  christos ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
    193  1.1  christos 
    194  1.1  christos ##### Special command flags ##########################################
    195  1.1  christos 
    196  1.1  christos COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
    197  1.1  christos LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
    198  1.1  christos AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
    199  1.1  christos MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
    200  1.1  christos MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
    201  1.1  christos ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
    202  1.1  christos RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
    203  1.1  christos 
    204  1.1  christos ##### Project flags ##################################################
    205  1.1  christos 
    206  1.1  christos # Variables starting with CNF_ are common variables for all product types
    207  1.1  christos 
    208  1.1  christos CNF_ASFLAGS={- join(' ', $target{asflags} || (),
    209  1.1  christos                          @{$config{asflags}}) -}
    210  1.1  christos CNF_CPPFLAGS={- our $cppfags2 =
    211  1.1  christos                     join(' ', $target{cppflags} || (),
    212  1.1  christos                               (map { '-D'.quotify1($_) } @{$target{defines}},
    213  1.1  christos                                                          @{$config{defines}}),
    214  1.1  christos                               (map { '-I'.'"'.$_.'"' } @{$target{includes}},
    215  1.1  christos                                                        @{$config{includes}}),
    216  1.1  christos                               @{$config{cppflags}}) -}
    217  1.1  christos CNF_CFLAGS={- join(' ', $target{cflags} || (),
    218  1.1  christos                         @{$config{cflags}}) -}
    219  1.1  christos CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
    220  1.1  christos                           @{$config{cxxflags}}) -}
    221  1.1  christos CNF_LDFLAGS={- join(' ', $target{lflags} || (),
    222  1.1  christos                          @{$config{lflags}}) -}
    223  1.1  christos CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
    224  1.1  christos                          @{$config{ex_libs}}) -}
    225  1.1  christos 
    226  1.1  christos # Variables starting with LIB_ are used to build library object files
    227  1.1  christos # and shared libraries.
    228  1.1  christos # Variables starting with DSO_ are used to build DSOs and their object files.
    229  1.1  christos # Variables starting with BIN_ are used to build programs and their object
    230  1.1  christos # files.
    231  1.1  christos 
    232  1.1  christos LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
    233  1.1  christos                          @{$config{lib_asflags}},
    234  1.1  christos                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
    235  1.1  christos LIB_CPPFLAGS={- our $lib_cppflags =
    236  1.1  christos                 join(' ', $target{lib_cppflags} || (),
    237  1.1  christos                           $target{shared_cppflag} || (),
    238  1.1  christos                           (map { '-D'.quotify1($_) }
    239  1.1  christos                                @{$target{lib_defines}},
    240  1.1  christos                                @{$target{shared_defines}},
    241  1.1  christos                                @{$config{lib_defines}},
    242  1.1  christos                                @{$config{shared_defines}}),
    243  1.1  christos                           (map { '-I'.quotify1($_) }
    244  1.1  christos                                @{$target{lib_includes}},
    245  1.1  christos                                @{$target{shared_includes}},
    246  1.1  christos                                @{$config{lib_includes}},
    247  1.1  christos                                @{$config{shared_includes}}),
    248  1.1  christos                           @{$config{lib_cppflags}},
    249  1.1  christos                           @{$config{shared_cppflag}});
    250  1.1  christos                 join(' ', $lib_cppflags,
    251  1.1  christos                           (map { '-D'.quotify1($_) }
    252  1.1  christos                                "OPENSSLDIR=\"$openssldir\"",
    253  1.1  christos                                "ENGINESDIR=\"$enginesdir\""),
    254  1.1  christos                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
    255  1.1  christos LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
    256  1.1  christos                         $target{shared_cflag} || (),
    257  1.1  christos                         @{$config{lib_cflags}},
    258  1.1  christos                         @{$config{shared_cflag}},
    259  1.1  christos                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
    260  1.1  christos LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
    261  1.1  christos                          $config{shared_ldflag} || (),
    262  1.1  christos                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
    263  1.1  christos LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
    264  1.1  christos DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
    265  1.1  christos                          $target{module_asflags} || (),
    266  1.1  christos                          @{$config{dso_asflags}},
    267  1.1  christos                          @{$config{module_asflags}},
    268  1.1  christos                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
    269  1.1  christos DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
    270  1.1  christos                           $target{module_cppflags} || (),
    271  1.1  christos                           @{$config{dso_cppflags}},
    272  1.1  christos                           @{$config{module_cppflags}},
    273  1.1  christos                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
    274  1.1  christos DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
    275  1.1  christos                         $target{module_cflags} || (),
    276  1.1  christos                         @{$config{dso_cflags}},
    277  1.1  christos                         @{$config{module_cflags}},
    278  1.1  christos                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
    279  1.1  christos DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
    280  1.1  christos                          $target{module_ldflags} || (),
    281  1.1  christos                          @{$config{dso_lflags}},
    282  1.1  christos                          @{$config{module_ldflags}},
    283  1.1  christos                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
    284  1.1  christos DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
    285  1.1  christos BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
    286  1.1  christos                          @{$config{bin_asflags}},
    287  1.1  christos                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
    288  1.1  christos BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
    289  1.1  christos                           @{$config{bin_cppflags}},
    290  1.1  christos                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
    291  1.1  christos BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
    292  1.1  christos                         @{$config{bin_cflags}},
    293  1.1  christos                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
    294  1.1  christos BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
    295  1.1  christos                          @{$config{bin_lflags}},
    296  1.1  christos                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
    297  1.1  christos BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
    298  1.1  christos 
    299  1.1  christos # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
    300  1.1  christos CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
    301  1.1  christos               $cppflags2 =~ s|([\\"])|\\$1|g;
    302  1.1  christos               join(' ', $lib_cppflags || (), $cppflags2 || (),
    303  1.1  christos                         $cppflags1 || ()) -}
    304  1.1  christos 
    305  1.1  christos PERLASM_SCHEME= {- $target{perlasm_scheme} -}
    306  1.1  christos 
    307  1.1  christos PROCESSOR= {- $config{processor} -}
    308  1.1  christos 
    309  1.1  christos # The main targets ###################################################
    310  1.1  christos 
    311  1.1  christos {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
    312  1.1  christos {- dependmagic('build_libs'); -}: build_libs_nodep
    313  1.1  christos {- dependmagic('build_engines'); -}: build_engines_nodep
    314  1.1  christos {- dependmagic('build_programs'); -}: build_programs_nodep
    315  1.1  christos 
    316  1.1  christos build_generated: $(GENERATED_MANDATORY)
    317  1.1  christos build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
    318  1.1  christos build_engines_nodep: $(ENGINES)
    319  1.1  christos build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
    320  1.1  christos 
    321  1.1  christos # Kept around for backward compatibility
    322  1.1  christos build_apps build_tests: build_programs
    323  1.1  christos 
    324  1.1  christos # Convenience target to prebuild all generated files, not just the mandatory
    325  1.1  christos # ones
    326  1.1  christos build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
    327  1.1  christos 	@{- output_off() if $disabled{makedepend}; "\@rem" -}
    328  1.1  christos 	@$(ECHO) "Warning: consider configuring with no-makedepend, because if"
    329  1.1  christos 	@$(ECHO) "         target system doesn't have $(PERL),"
    330  1.1  christos 	@$(ECHO) "         then make will fail..."
    331  1.1  christos 	@{- output_on() if $disabled{makedepend}; "\@rem" -}
    332  1.1  christos 
    333  1.1  christos test: tests
    334  1.1  christos {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
    335  1.1  christos 	@{- output_off() if $disabled{tests}; "\@rem" -}
    336  1.1  christos 	-mkdir $(BLDDIR)\test\test-runs
    337  1.1  christos 	set SRCTOP=$(SRCDIR)
    338  1.1  christos 	set BLDTOP=$(BLDDIR)
    339  1.1  christos 	set RESULT_D=$(BLDDIR)\test\test-runs
    340  1.1  christos 	set PERL=$(PERL)
    341  1.1  christos 	set OPENSSL_ENGINES=$(MAKEDIR)\engines
    342  1.1  christos 	set OPENSSL_DEBUG_MEMORY=on
    343  1.1  christos 	"$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
    344  1.1  christos 	@{- if ($disabled{tests}) { output_on(); } else { output_off(); } "\@rem" -}
    345  1.1  christos 	@$(ECHO) "Tests are not supported with your chosen Configure options"
    346  1.1  christos 	@{- output_on() if !$disabled{tests}; "\@rem" -}
    347  1.1  christos 
    348  1.1  christos list-tests:
    349  1.1  christos 	@{- output_off() if $disabled{tests}; "\@rem" -}
    350  1.1  christos 	@set SRCTOP=$(SRCDIR)
    351  1.1  christos 	@"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
    352  1.1  christos 	@{- if ($disabled{tests}) { output_on(); } else { output_off(); } "\@rem" -}
    353  1.1  christos 	@$(ECHO) "Tests are not supported with your chosen Configure options"
    354  1.1  christos 	@{- output_on() if !$disabled{tests}; "\@rem" -}
    355  1.1  christos 
    356  1.1  christos install: install_sw install_ssldirs install_docs
    357  1.1  christos 
    358  1.1  christos uninstall: uninstall_docs uninstall_sw
    359  1.1  christos 
    360  1.1  christos libclean:
    361  1.1  christos 	"$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
    362  1.1  christos 	-del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
    363  1.1  christos 
    364  1.1  christos clean: libclean
    365  1.1  christos 	{- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) || "\@rem" -}
    366  1.1  christos 	-del /Q /F $(ENGINES)
    367  1.1  christos 	-del /Q /F $(SCRIPTS)
    368  1.1  christos 	-del /Q /F $(GENERATED_MANDATORY)
    369  1.1  christos 	-del /Q /F $(GENERATED)
    370  1.1  christos 	-del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
    371  1.1  christos 	-del /Q /S /F engines\*.lib engines\*.exp
    372  1.1  christos 	-del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
    373  1.1  christos 	-del /Q /S /F test\*.exp
    374  1.1  christos 	-rmdir /Q /S test\test-runs
    375  1.1  christos 
    376  1.1  christos distclean: clean
    377  1.1  christos 	-del /Q /F configdata.pm
    378  1.1  christos 	-del /Q /F makefile
    379  1.1  christos 
    380  1.1  christos depend:
    381  1.1  christos 	@ {- output_off() if $disabled{makedepend}; "\@rem" -}
    382  1.1  christos 	@ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
    383  1.1  christos 	@ {- output_on() if $disabled{makedepend}; "\@rem" -}
    384  1.1  christos 
    385  1.1  christos # Install helper targets #############################################
    386  1.1  christos 
    387  1.1  christos install_sw: install_dev install_engines install_runtime
    388  1.1  christos 
    389  1.1  christos uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
    390  1.1  christos 
    391  1.1  christos install_docs: install_html_docs
    392  1.1  christos 
    393  1.1  christos uninstall_docs: uninstall_html_docs
    394  1.1  christos 
    395  1.1  christos install_ssldirs:
    396  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
    397  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
    398  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
    399  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
    400  1.1  christos                                         "$(OPENSSLDIR)\openssl.cnf.dist"
    401  1.1  christos 	@IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
    402  1.1  christos          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
    403  1.1  christos                                         "$(OPENSSLDIR)\openssl.cnf"
    404  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
    405  1.1  christos                                         "$(OPENSSLDIR)\misc"
    406  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
    407  1.1  christos                                         "$(OPENSSLDIR)\ct_log_list.cnf.dist"
    408  1.1  christos 	@IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
    409  1.1  christos          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
    410  1.1  christos                                         "$(OPENSSLDIR)\ct_log_list.cnf"
    411  1.1  christos 
    412  1.1  christos install_dev: install_runtime_libs
    413  1.1  christos 	@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
    414  1.1  christos 	@$(ECHO) "*** Installing development files"
    415  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
    416  1.1  christos 	@{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "\@rem" -}
    417  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
    418  1.1  christos 				       "$(INSTALLTOP)\include\openssl"
    419  1.1  christos 	@{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "\@rem" -}
    420  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
    421  1.1  christos 				       "$(SRCDIR)\include\openssl\*.h" \
    422  1.1  christos 				       "$(INSTALLTOP)\include\openssl"
    423  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
    424  1.1  christos 				       "$(INSTALLTOP)\include\openssl"
    425  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
    426  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
    427  1.1  christos 	@if "$(SHLIBS)"=="" \
    428  1.1  christos 	 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
    429  1.1  christos 
    430  1.1  christos uninstall_dev:
    431  1.1  christos 
    432  1.1  christos install_engines: install_runtime_libs build_engines
    433  1.1  christos 	@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
    434  1.1  christos 	@$(ECHO) "*** Installing engines"
    435  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
    436  1.1  christos 	@if not "$(ENGINES)"=="" \
    437  1.1  christos 	 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
    438  1.1  christos 	@if not "$(ENGINES)"=="" \
    439  1.1  christos 	 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
    440  1.1  christos 
    441  1.1  christos uninstall_engines:
    442  1.1  christos 
    443  1.1  christos install_runtime: install_programs
    444  1.1  christos 
    445  1.1  christos install_runtime_libs: build_libs
    446  1.1  christos 	@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
    447  1.1  christos 	@$(ECHO) "*** Installing runtime libraries"
    448  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
    449  1.1  christos 	@if not "$(SHLIBS)"=="" \
    450  1.1  christos 	 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
    451  1.1  christos 	@if not "$(SHLIBS)"=="" \
    452  1.1  christos 	 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
    453  1.1  christos                                         "$(INSTALLTOP)\bin"
    454  1.1  christos 
    455  1.1  christos install_programs: install_runtime_libs build_programs
    456  1.1  christos 	@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
    457  1.1  christos 	@$(ECHO) "*** Installing runtime programs"
    458  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
    459  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
    460  1.1  christos                                         "$(INSTALLTOP)\bin"
    461  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
    462  1.1  christos                                         "$(INSTALLTOP)\bin"
    463  1.1  christos 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
    464  1.1  christos                                         "$(INSTALLTOP)\bin"
    465  1.1  christos 
    466  1.1  christos uninstall_runtime:
    467  1.1  christos 
    468  1.1  christos install_html_docs:
    469  1.1  christos         "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
    470  1.1  christos                 "--destdir=$(INSTALLTOP)\html" --type=html
    471  1.1  christos 
    472  1.1  christos uninstall_html_docs:
    473  1.1  christos 
    474  1.1  christos # Building targets ###################################################
    475  1.1  christos 
    476  1.1  christos configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
    477  1.1  christos 	@$(ECHO) "Detected changed: $?"
    478  1.1  christos 	"$(PERL)" configdata.pm -r
    479  1.1  christos 	@$(ECHO) "**************************************************"
    480  1.1  christos 	@$(ECHO) "***                                            ***"
    481  1.1  christos 	@$(ECHO) "***   Please run the same make command again   ***"
    482  1.1  christos 	@$(ECHO) "***                                            ***"
    483  1.1  christos 	@$(ECHO) "**************************************************"
    484  1.1  christos 	@exit 1
    485  1.1  christos 
    486  1.1  christos reconfigure reconf:
    487  1.1  christos 	"$(PERL)" configdata.pm -r
    488  1.1  christos 
    489  1.1  christos {-
    490  1.1  christos  use File::Basename;
    491  1.1  christos  use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
    492  1.1  christos 
    493  1.1  christos  # Helper function to figure out dependencies on libraries
    494  1.1  christos  # It takes a list of library names and outputs a list of dependencies
    495  1.1  christos  sub compute_lib_depends {
    496  1.1  christos      if ($disabled{shared}) {
    497  1.1  christos 	 return map { lib($_) } @_;
    498  1.1  christos      }
    499  1.1  christos      return map { shlib_import($_) or lib($_) } @_;
    500  1.1  christos  }
    501  1.1  christos 
    502  1.1  christos   sub generatesrc {
    503  1.1  christos       my %args = @_;
    504  1.1  christos       (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
    505  1.1  christos       my ($gen0, @gens) = @{$args{generator}};
    506  1.1  christos       my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
    507  1.1  christos       my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
    508  1.1  christos       my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
    509  1.1  christos       my $deps = @{$args{deps}} ?
    510  1.1  christos           '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
    511  1.1  christos 
    512  1.1  christos       if ($target !~ /\.asm$/) {
    513  1.1  christos           if ($args{generator}->[0] =~ m|^.*\.in$|) {
    514  1.1  christos               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
    515  1.1  christos                                                    "util", "dofile.pl")),
    516  1.1  christos                                    rel2abs($config{builddir}));
    517  1.1  christos               return <<"EOF";
    518  1.1  christos $target: "$args{generator}->[0]" $deps
    519  1.1  christos 	"\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
    520  1.1  christos 	    "-o$target{build_file}" $generator > \$@
    521  1.1  christos EOF
    522  1.1  christos 	  } else {
    523  1.1  christos               return <<"EOF";
    524  1.1  christos $target: "$args{generator}->[0]" $deps
    525  1.1  christos 	"\$(PERL)"$generator_incs $generator > \$@
    526  1.1  christos EOF
    527  1.1  christos 	  }
    528  1.1  christos       } else {
    529  1.1  christos           if ($args{generator}->[0] =~ /\.pl$/) {
    530  1.1  christos               $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
    531  1.1  christos           } elsif ($args{generator}->[0] =~ /\.S$/) {
    532  1.1  christos               $generator = undef;
    533  1.1  christos           } else {
    534  1.1  christos               die "Generator type for $src unknown: $generator\n";
    535  1.1  christos           }
    536  1.1  christos 
    537  1.1  christos           my $cppflags = $incs;
    538  1.1  christos           $cppflags .= {
    539  1.1  christos               lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
    540  1.1  christos               dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
    541  1.1  christos               bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
    542  1.1  christos           } -> {$args{intent}};
    543  1.1  christos           if (defined($generator)) {
    544  1.1  christos               # If the target is named foo.S in build.info, we want to
    545  1.1  christos               # end up generating foo.s in two steps.
    546  1.1  christos               if ($args{src} =~ /\.S$/) {
    547  1.1  christos                    return <<"EOF";
    548  1.1  christos $target: "$args{generator}->[0]" $deps
    549  1.1  christos 	set ASM=\$(AS)
    550  1.1  christos 	$generator \$@.S
    551  1.1  christos 	\$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
    552  1.1  christos         del /Q \$@.S
    553  1.1  christos EOF
    554  1.1  christos               }
    555  1.1  christos               # Otherwise....
    556  1.1  christos               return <<"EOF";
    557  1.1  christos $target: "$args{generator}->[0]" $deps
    558  1.1  christos 	set ASM=\$(AS)
    559  1.1  christos 	$generator \$@
    560  1.1  christos EOF
    561  1.1  christos           }
    562  1.1  christos           return <<"EOF";
    563  1.1  christos $target: "$args{generator}->[0]" $deps
    564  1.1  christos 	\$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
    565  1.1  christos EOF
    566  1.1  christos       }
    567  1.1  christos   }
    568  1.1  christos 
    569  1.1  christos  sub src2obj {
    570  1.1  christos      my %args = @_;
    571  1.1  christos      my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
    572  1.1  christos                     } ( @{$args{srcs}} );
    573  1.1  christos      my $srcs = '"'.join('" "',  @srcs).'"';
    574  1.1  christos      my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
    575  1.1  christos      my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
    576  1.1  christos      my $cflags = { lib => ' $(LIB_CFLAGS)',
    577  1.1  christos 		    dso => ' $(DSO_CFLAGS)',
    578  1.1  christos 		    bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
    579  1.1  christos      $cflags .= $incs;
    580  1.1  christos      $cflags .= { lib => ' $(LIB_CPPFLAGS)',
    581  1.1  christos 		  dso => ' $(DSO_CPPFLAGS)',
    582  1.1  christos 		  bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
    583  1.1  christos      my $asflags = { lib => ' $(LIB_ASFLAGS)',
    584  1.1  christos 		     dso => ' $(DSO_ASFLAGS)',
    585  1.1  christos 		     bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
    586  1.1  christos      my $makedepprog = $config{makedepprog};
    587  1.1  christos      if ($srcs[0] =~ /\.rc$/) {
    588  1.1  christos          return <<"EOF";
    589  1.1  christos $args{obj}: $deps
    590  1.1  christos 	\$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
    591  1.1  christos EOF
    592  1.1  christos      }
    593  1.1  christos      (my $obj = $args{obj}) =~ s|\.o$||;
    594  1.1  christos      if ($srcs[0] =~ /\.asm$/) {
    595  1.1  christos          return <<"EOF";
    596  1.1  christos $obj$objext: $deps
    597  1.1  christos 	\$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
    598  1.1  christos EOF
    599  1.1  christos      } elsif ($srcs[0] =~ /.S$/) {
    600  1.1  christos          return <<"EOF";
    601  1.1  christos $obj$objext: $deps
    602  1.1  christos 	\$(CC) /EP /D__ASSEMBLER__ $cflags $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
    603  1.1  christos EOF
    604  1.1  christos      }
    605  1.1  christos      my $recipe = <<"EOF";
    606  1.1  christos $obj$objext: $deps
    607  1.1  christos 	\$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
    608  1.1  christos EOF
    609  1.1  christos      $recipe .= <<"EOF"	unless $disabled{makedepend};
    610  1.1  christos 	\$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
    611  1.1  christos EOF
    612  1.1  christos      return $recipe;
    613  1.1  christos  }
    614  1.1  christos 
    615  1.1  christos  # We *know* this routine is only called when we've configure 'shared'.
    616  1.1  christos  # Also, note that even though the import library built here looks like
    617  1.1  christos  # a static library, it really isn't.
    618  1.1  christos  sub libobj2shlib {
    619  1.1  christos      my %args = @_;
    620  1.1  christos      my $lib = $args{lib};
    621  1.1  christos      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
    622  1.1  christos                 grep { $_ =~ m/\.(?:o|res)$/ }
    623  1.1  christos                 @{$args{objs}};
    624  1.1  christos      my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
    625  1.1  christos      my @deps = compute_lib_depends(@{$args{deps}});
    626  1.1  christos      die "More than one exported symbols list" if scalar @defs > 1;
    627  1.1  christos      my $linklibs = join("", map { "$_\n" } @deps);
    628  1.1  christos      my $objs = join("\n", @objs);
    629  1.1  christos      my $deps = join(" ", @objs, @defs, @deps);
    630  1.1  christos      my $import = shlib_import($lib);
    631  1.1  christos      my $dll =  shlib($lib);
    632  1.1  christos      my $shared_def = join("", map { " /def:$_" } @defs);
    633  1.1  christos      return <<"EOF"
    634  1.1  christos # The import library may look like a static library, but it is not.
    635  1.1  christos # We MUST make the import library depend on the DLL, in case someone
    636  1.1  christos # mistakenly removes the latter.
    637  1.1  christos $import: $dll
    638  1.1  christos $dll: $deps
    639  1.1  christos 	IF EXIST $full.manifest DEL /F /Q $full.manifest
    640  1.1  christos 	IF EXIST \$@ DEL /F /Q \$@
    641  1.1  christos 	\$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
    642  1.1  christos 		/implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
    643  1.1  christos $objs
    644  1.1  christos $linklibs\$(LIB_EX_LIBS)
    645  1.1  christos <<
    646  1.1  christos 	IF EXIST $dll.manifest \\
    647  1.1  christos 	   \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
    648  1.1  christos 	IF EXIST apps\\$dll DEL /Q /F apps\\$dll
    649  1.1  christos 	IF EXIST test\\$dll DEL /Q /F test\\$dll
    650  1.1  christos 	IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
    651  1.1  christos 	COPY $dll apps
    652  1.1  christos 	COPY $dll test
    653  1.1  christos 	COPY $dll fuzz
    654  1.1  christos EOF
    655  1.1  christos  }
    656  1.1  christos  sub obj2dso {
    657  1.1  christos      my %args = @_;
    658  1.1  christos      my $dso = $args{lib};
    659  1.1  christos      my $dso_n = basename($dso);
    660  1.1  christos      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
    661  1.1  christos      my @deps = compute_lib_depends(@{$args{deps}});
    662  1.1  christos      my $objs = join("\n", @objs);
    663  1.1  christos      my $linklibs = join("", map { "$_\n" } @deps);
    664  1.1  christos      my $deps = join(" ", @objs, @deps);
    665  1.1  christos      return <<"EOF";
    666  1.1  christos $dso$dsoext: $deps
    667  1.1  christos 	IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
    668  1.1  christos 	\$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
    669  1.1  christos LIBRARY         $dso_n
    670  1.1  christos EXPORTS
    671  1.1  christos     bind_engine		@1
    672  1.1  christos     v_check		@2
    673  1.1  christos <<
    674  1.1  christos $objs
    675  1.1  christos $linklibs \$(DSO_EX_LIBS)
    676  1.1  christos <<
    677  1.1  christos 	IF EXIST $dso$dsoext.manifest \\
    678  1.1  christos 	   \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
    679  1.1  christos EOF
    680  1.1  christos  }
    681  1.1  christos  sub obj2lib {
    682  1.1  christos      my %args = @_;
    683  1.1  christos      my $lib = lib($args{lib});
    684  1.1  christos      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
    685  1.1  christos      my $objs = join("\n", @objs);
    686  1.1  christos      my $deps = join(" ", @objs);
    687  1.1  christos      return <<"EOF";
    688  1.1  christos $lib: $deps
    689  1.1  christos 	\$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
    690  1.1  christos $objs
    691  1.1  christos <<
    692  1.1  christos EOF
    693  1.1  christos  }
    694  1.1  christos  sub obj2bin {
    695  1.1  christos      my %args = @_;
    696  1.1  christos      my $bin = $args{bin};
    697  1.1  christos      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
    698  1.1  christos      my @deps = compute_lib_depends(@{$args{deps}});
    699  1.1  christos      my $objs = join("\n", @objs);
    700  1.1  christos      my $linklibs = join("", map { "$_\n" } @deps);
    701  1.1  christos      my $deps = join(" ", @objs, @deps);
    702  1.1  christos      return <<"EOF";
    703  1.1  christos $bin$exeext: $deps
    704  1.1  christos 	IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
    705  1.1  christos 	\$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
    706  1.1  christos $objs
    707  1.1  christos setargv.obj
    708  1.1  christos $linklibs\$(BIN_EX_LIBS)
    709  1.1  christos <<
    710  1.1  christos 	IF EXIST $bin$exeext.manifest \\
    711  1.1  christos 	   \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
    712  1.1  christos EOF
    713  1.1  christos   }
    714  1.1  christos   sub in2script {
    715  1.1  christos       my %args = @_;
    716  1.1  christos       my $script = $args{script};
    717  1.1  christos       my $sources = '"'.join('" "', @{$args{sources}}).'"';
    718  1.1  christos       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
    719  1.1  christos                                            "util", "dofile.pl")),
    720  1.1  christos                            rel2abs($config{builddir}));
    721  1.1  christos       return <<"EOF";
    722  1.1  christos $script: $sources
    723  1.1  christos 	"\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
    724  1.1  christos 	    "-o$target{build_file}" $sources > "$script"
    725  1.1  christos EOF
    726  1.1  christos   }
    727  1.1  christos   sub generatedir {
    728  1.1  christos       my %args = @_;
    729  1.1  christos       my $dir = $args{dir};
    730  1.1  christos       my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
    731  1.1  christos       my @actions = ();
    732  1.1  christos       my %extinfo = ( dso => $dsoext,
    733  1.1  christos                       lib => $libext,
    734  1.1  christos                       bin => $exeext );
    735  1.1  christos 
    736  1.1  christos       # We already have a 'test' target, and the top directory is just plain
    737  1.1  christos       # silly
    738  1.1  christos       return if $dir eq "test" || $dir eq ".";
    739  1.1  christos 
    740  1.1  christos       foreach my $type (("dso", "lib", "bin", "script")) {
    741  1.1  christos           next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
    742  1.1  christos           # For lib object files, we could update the library.  However,
    743  1.1  christos           # LIB on Windows doesn't work that way, so we won't create any
    744  1.1  christos           # actions for it, and the dependencies are already taken care of.
    745  1.1  christos           if ($type ne "lib") {
    746  1.1  christos               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
    747  1.1  christos                   if (dirname($prod) eq $dir) {
    748  1.1  christos                       push @deps, $prod.$extinfo{$type};
    749  1.1  christos                   }
    750  1.1  christos               }
    751  1.1  christos           }
    752  1.1  christos       }
    753  1.1  christos 
    754  1.1  christos       my $deps = join(" ", @deps);
    755  1.1  christos       my $actions = join("\n", "", @actions);
    756  1.1  christos       return <<"EOF";
    757  1.1  christos $dir $dir\\ : $deps$actions
    758  1.1  christos EOF
    759  1.1  christos   }
    760  1.1  christos   ""    # Important!  This becomes part of the template result.
    761  1.1  christos -}
    762