perl functions in a perl code fragment enclosed with "{-" and "-}".
They are all expected to return a string with the lines they produce.
- src2dep - function that produces build file lines to get the
- dependencies for an object file into a dependency
- file.
-
- It's called like this:
-
- src2dep(obj => "PATH/TO/objectfile",
- srcs => [ "PATH/TO/sourcefile", ... ],
- deps => [ "dep1", ... ],
- incs => [ "INCL/PATH", ... ]);
-
- 'obj' has the dependent object file as well as
- object file the dependencies are for; it's *without*
- extension, src2dep() is expected to add that.
- 'srcs' has the list of source files to build the
- object file, with the first item being the source
- file that directly corresponds to the object file.
- 'deps' is a list of explicit dependencies. 'incs'
- is a list of include file directories.
-
src2obj - function that produces build file lines to build an
object file from source files and associated data.
from static libraries, to programs from object files and libraries,
etc.
- src2dep - function that produces build file lines to get the
- dependencies for an object file into a dependency
- file.
-
- It's called like this:
-
- src2dep(obj => "PATH/TO/objectfile",
- srcs => [ "PATH/TO/sourcefile", ... ],
- incs => [ "INCL/PATH", ... ]);
-
- 'obj' has the dependent object file as well as
- object file the dependencies are for; it's *without*
- extension, src2dep() is expected to add that.
- 'srcs' has the list of source files to build the
- object file, with the first item being the source
- file that directly corresponds to the object file.
- 'incs' is a list of include file directories.
-
src2obj - function that produces build file lines to build an
object file from source files and associated data.
deps => [ reducedepends(resolvedepends($obj)) ],
incs => [ @{$unified_info{includes}->{$bin}},
@{$unified_info{includes}->{$obj}} ]);
- $OUT .= src2dep(obj => $obj_no_o,
- srcs => $unified_info{sources}->{$obj},
- deps => [ reducedepends(resolvedepends($obj)) ],
- incs => [ @{$unified_info{includes}->{$bin}},
- @{$unified_info{includes}->{$obj}} ]);
}
}
{-
use File::Basename;
use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
- sub src2dep {
- my %args = @_;
- my $dep = $args{obj};
- my $deps = join(", -\n\t\t", @{$args{srcs}}, @{$args{deps}});
-
- # Because VMS C isn't very good at combining a /INCLUDE path with
- # #includes having a relative directory (like '#include "../foo.h"),
- # the best choice is to move to the first source file's intended
- # directory before compiling, and make sure to write the object file
- # in the correct position (important when the object tree is other
- # than the source tree).
- my $forward = dirname($args{srcs}->[0]);
- my $backward = abs2rel(rel2abs("."), rel2abs($forward));
- my $depd = abs2rel(rel2abs(dirname($dep)), rel2abs($forward));
- my $depn = basename($dep);
- my $srcs =
- join(", ",
- map { abs2rel(rel2abs($_), rel2abs($forward)) } @{$args{srcs}});
- my $incs =
- "/INCLUDE=(".join(",",
- map {
- file_name_is_absolute($_)
- ? $_ : catdir($backward,$_)
- } @{$args{incs}}).")";
- my $before = $unified_info{before}->{$dep.".OBJ"} || "\@ !";
- my $after = $unified_info{after}->{$dep.".OBJ"} || "\@ !";
-
- return <<"EOF";
-$dep.MMS : $deps
- ${before}
- SET DEFAULT $forward
- \$(CC) \$(CFLAGS)${incs} /MMS=(TARGET=.OBJ)/OBJECT=${depd}${depn}.MMS $srcs
- SET DEFAULT $backward
- ${after}
- - PURGE $dep.MMS
-EOF
- }
sub src2obj {
my %args = @_;
my $obj = $args{obj};
my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
return <<"EOF";
-$obj.OBJ : $deps
+$obj.MMS : $deps
+ \$(CC) \$(CFLAGS)${incs} /MMS=(FILE=${objd}${objn}.MMS,TARGET=$obj.OBJ) /NOOBJECT $srcs
+$obj.OBJ : $obj.MMS
${before}
SET DEFAULT $forward
\$(CC) \$(CFLAGS)${incs} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
} } @_;
}
- sub src2dep {
+ sub src2obj {
my %args = @_;
- my $dep = $args{obj}.'$(DEP_EXT)';
- my $obj = $args{obj}.'$(OBJ_EXT)';
+ my $obj = $args{obj};
my $srcs = join(" ", @{$args{srcs}});
my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
my $makedepprog = $config{makedepprog};
if ($makedepprog eq "makedepend") {
return <<"EOF";
-$dep : $deps
+$obj\$(DEP_EXT): $deps
rm -f \$\@.tmp; touch \$\@.tmp
\$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" \\
-- -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs \\
2>/dev/null
sed -e 's/^.*|//' -e 's/ \\/\\(\\\\.\\|[^ ]\\)*//g' -e '/: *\$\$/d' -e '/^\\(#.*\\| *\\)\$\$/d' \$\@.tmp > \$\@
rm \$\@.tmp
+$obj\$(OBJ_EXT): $obj\$(DEP_EXT)
+ \$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
EOF
}
return <<"EOF";
-$dep : $deps Makefile
+$obj\$(DEP_EXT): $deps
\$(CC) -DOPENSSL_DOING_MAKEDEPEND \$(DEPFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
-EOF
- }
- sub src2obj {
- my %args = @_;
- my $obj = $args{obj}.'$(OBJ_EXT)';
- my $srcs = join(" ", @{$args{srcs}});
- my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
- my $incs = join(" ", map { " -I".$_ } @{$args{incs}});
- return <<"EOF";
-$obj : $deps
+$obj\$(OBJ_EXT): $obj\$(DEP_EXT)
\$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
EOF
}
# It's not necessary to have both as targets. The choice falls on the
# simplest, {libname}\$(SHLIB_EXT_SIMPLE).a for Windows POSIX layers and
# {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
-$shlibtarget : $lib\$(LIB_EXT) $deps $ordinalsfile
+$shlibtarget: $lib\$(LIB_EXT) $deps $ordinalsfile
\$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
PLATFORM=\$(PLATFORM) \\
PERL=\$(PERL) SRCDIR="\$(SRCDIR)" DSTDIR="$libd" \\
my $lib = $args{lib};
my $objs = join(" ", map { $_."\$(OBJ_EXT)" } @{$args{objs}});
return <<"EOF";
-$lib\$(LIB_EXT) : $objs
+$lib\$(LIB_EXT): $objs
\$(AR) \$\@ $objs
\$(RANLIB) \$\@ || echo Never mind.
EOF
" -L$d -l$l" } @{$args{deps}});
my $shlib_target = $config{no_shared} ? "" : $target{shared_target};
return <<"EOF";
-$bin\$(EXE_EXT) : $objs $deps
+$bin\$(EXE_EXT): $objs $deps
\$(RM) $bin\$(EXE_EXT)
\$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
PERL=\$(PERL) SRCDIR=\$(SRCDIR) \\
"util", "dofile.pl")),
rel2abs($config{builddir}));
return <<"EOF";
-$script : $sources
+$script: $sources
\$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
"-o$target{build_file}" $sources > "$script"
chmod a+x $script