Commit 45502bfe authored by Richard Levitte's avatar Richard Levitte
Browse files

Always build library object files with shared library cflags



This takes us away from the idea that we know exactly how our static
libraries are going to get used.  Instead, we make them available to
build shareable things with, be it other shared libraries or DSOs.

On the other hand, we also have greater control of when the shared
library cflags.  They will never be used with object files meant got
binaries, such as apps/openssl or test/test*.

With unified, we take this a bit further and prepare for having to
deal with extra cflags specifically to be used with DSOs (dynamic
engines), libraries and binaries (applications).

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
parent 011b9675
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -488,7 +488,8 @@ They are all expected to return a string with the lines they produce.
                        src2obj(obj => "PATH/TO/objectfile",
                                srcs => [ "PATH/TO/sourcefile", ... ],
                                deps => [ "dep1", ... ],
                                incs => [ "INCL/PATH", ... ]);
                                incs => [ "INCL/PATH", ... ]
                                intent => one of "lib", "dso", "bin" );

                  'obj' has the intended object file *without*
                  extension, src2obj() is expected to add that.
@@ -496,7 +497,9 @@ They are all expected to return a string with the lines they produce.
                  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.
                  is a list of include file directories.  Finally,
                  'intent' indicates what this object file is going
                  to be used for.

    obj2lib     - function that produces build file lines to build a
                  static library file ("libfoo.a" in Unix terms) from
+6 −3
Original line number Diff line number Diff line
@@ -392,15 +392,18 @@ etc.
                        src2obj(obj => "PATH/TO/objectfile",
                                srcs => [ "PATH/TO/sourcefile", ... ],
                                deps => [ "dep1", ... ],
                                incs => [ "INCL/PATH", ... ]);
                                incs => [ "INCL/PATH", ... ]
                                intent => one of "lib", "dso", "bin" );

                  'obj' has the intended object file *without*
                  extension, src2obj() 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 dependencies.  'incs' is a list
                  of include file directories.
                  'deps' is a list of explicit dependencies.  'incs'
                  is a list of include file directories.  Finally,
                  'intent' indicates what this object file is going
                  to be used for.

    obj2lib     - function that produces build file lines to build a
                  static library file ("libfoo.a" in Unix terms) from
+4 −2
Original line number Diff line number Diff line
@@ -37,12 +37,14 @@
     my $obj = shift;
     (my $obj_no_o = $obj) =~ s|\.o$||;
     my $bin = shift;
     my %opts = @_;
     if (@{$unified_info{sources}->{$obj}}) {
         $OUT .= src2obj(obj => $obj_no_o,
                         srcs => $unified_info{sources}->{$obj},
                         deps => [ reducedepends(resolvedepends($obj)) ],
                         incs => [ @{$unified_info{includes}->{$bin}},
                                   @{$unified_info{includes}->{$obj}} ]);
                                   @{$unified_info{includes}->{$obj}} ],
                         %opts);
     }
 }

@@ -78,7 +80,7 @@
                     objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
                               @{$unified_info{sources}->{$lib}} ],
                     deps => [ resolvedepends($lib) ]);
     map { doobj($_, $lib, intent => "lib") } @{$unified_info{sources}->{$lib}};
     map { doobj($_, $lib, intent => "dso") } @{$unified_info{sources}->{$lib}};
 }

 # dobin is responsible for building programs.  It will call obj2bin,
+11 −6
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@
     # given libname with the simple shared extension (possible SO version
     # removed).  This differs from shlib_simple() by being unconditional.
     sub dso {
         return () if $config{no_shared};
         my $engine = shift;

         return $engine . '$(DSO_EXT)';
@@ -149,6 +148,7 @@ CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
LDFLAGS= {- $config{lflags} -}
PLIB_LDFLAGS= {- $config{plib_lflags} -}
EX_LIBS= {- $config{ex_libs} -}
SHARED_CFLAGS={- $target{shared_cflag} || "" -}
SHARED_LDFLAGS={- $target{shared_ldflag}
                  # Unlike other OSes (like Solaris, Linux, Tru64,
                  # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
@@ -164,6 +164,8 @@ SHARED_LDFLAGS={- $target{shared_ldflag}
                  . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
                     ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
SHARED_RCFLAGS={- $target{shared_rcflag} -}
DSO_CFLAGS={- $target{shared_cflag} || "" -}
BIN_CFLAGS={- "" -}

PERL={- $config{perl} -}

@@ -824,24 +826,27 @@ configdata.pm: {- $config{build_file_template} -} $(SRCDIR)/Configure $(SRCDIR)/
      my $srcs = join(" ", @{$args{srcs}});
      my $deps = join(" ", @{$args{srcs}}, @{$args{deps}});
      my $incs = join("", map { " -I".$_ } @{$args{incs}});
      my $ecflags = { lib => '$(SHARED_CFLAGS)',
                      dso => '$(DSO_CFLAGS)',
                      bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
      my $makedepprog = $config{makedepprog};
      if ($makedepprog eq "makedepend") {
          return <<"EOF";
$obj\$(DEP_EXT): $deps
	rm -f \$\@.tmp; touch \$\@.tmp
	\$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" -- \$(CFLAGS)$incs -- $srcs \\
	\$(MAKEDEPEND) -f\$\@.tmp -o"|$obj" -- \$(CFLAGS) $ecflags$incs -- $srcs \\
	    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
	\$(CC) \$(CFLAGS) $ecflags$incs -c -o \$\@ $srcs
EOF
      }
      return <<"EOF";
$obj\$(DEP_EXT): $deps
	\$(CC) \$(CFLAGS)$incs -MM -MF \$\@ -MQ $obj $srcs
	\$(CC) \$(CFLAGS) $ecflags$incs -MM -MF \$\@ -MQ $obj $srcs
$obj\$(OBJ_EXT): $obj\$(DEP_EXT)
	\$(CC) \$(CFLAGS)$incs -c -o \$\@ $srcs
	\$(CC) \$(CFLAGS) $ecflags$incs -c -o \$\@ $srcs
EOF
  }
  # On Unix, we build shlibs from static libs, so we're ignoring the
+0 −8
Original line number Diff line number Diff line
@@ -983,14 +983,6 @@ if ($target{shared_target} eq "")
	$no_shared_warn = 1 if !$config{no_shared} && !$config{fips};
	$config{no_shared} = 1;
	}
if (!$config{no_shared})
	{
	if ($target{shared_cflag} ne "")
		{
		push @{$config{defines}}, "OPENSSL_PIC";
		$config{cflags} = "$target{shared_cflag} $config{cflags}";
		}
	}

if ($builder ne "mk1mf")
	{
Loading