diff options
author | Richard Levitte <levitte@openssl.org> | 2018-01-23 13:54:55 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2018-01-28 07:26:10 +0100 |
commit | 8c3bc594e0c74926bfefb84b8bae8a2fac82e465 (patch) | |
tree | 7875c47a8ecd68f42f701e6f3602a8cc0c4fe0dc /Configurations/unix-Makefile.tmpl | |
parent | df05f155a69b96b174e0e47bc689bf729de684b6 (diff) |
Processing GNU-style "make variables" - separate CPP flags from C flags
C preprocessor flags get separated from C flags, which has the
advantage that we don't get loads of macro definitions and inclusion
directory specs when linking shared libraries, DSOs and programs.
This is a step to add support for "make variables" when configuring.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5177)
Diffstat (limited to 'Configurations/unix-Makefile.tmpl')
-rw-r--r-- | Configurations/unix-Makefile.tmpl | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index f5c1014cc6..4c4506bfb4 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -184,20 +184,33 @@ HTMLSUFFIX=html ECHO = echo CROSS_COMPILE= {- $config{cross_compile_prefix} -} +CPPFLAGS={- our $cppflags = join(" ", + (map { "-D".$_} + @{$target{defines}}, @{$config{defines}}), + (map { "-I".$_} + @{$target{includes}}, @{$config{includes}}), + $target{cppflags}, $config{cppflags}) -} +CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -} CC= $(CROSS_COMPILE){- $target{cc} -} -CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -} -CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -} +CFLAGS={- $target{cflags} -} {- $config{cflags} -} CXX= $(CROSS_COMPILE){- $target{cxx} -} -CXXFLAGS={- our $cxxflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11 +CXXFLAGS={- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11 LDFLAGS= {- $config{lflags} -} {- $target{lflags} -} PLIB_LDFLAGS= {- $target{plib_lflags} -} EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -} +LIB_CPPFLAGS={- join(" ", + (map { "-D".$_} + 'OPENSSLDIR="\"$(OPENSSLDIR)\""', + 'ENGINESDIR="\"$(ENGINESDIR)\""'), + $target{shared_cppflag} || "") -} LIB_CFLAGS={- $target{shared_cflag} || "" -} LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -} LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -} +DSO_CPPFLAGS={- $target{dso_cppflags} || "" -} DSO_CFLAGS={- $target{dso_cflags} || "" -} DSO_CXXFLAGS={- $target{dso_cxxflags} || "" -} DSO_LDFLAGS={- $target{dso_lflags} || "" -} +BIN_CPPFLAGS={- $target{bin_cppflags} || "" -} BIN_CFLAGS={- $target{bin_cflags} || "" -} BIN_CXXFLAGS={- $target{bin_cxxflags} || "" -} BIN_LDFLAGS={- $target{bin_lflags} || "" -} @@ -844,7 +857,7 @@ EOF $target: $args{generator}->[0] $deps ( trap "rm -f \$@.*" INT 0; \\ $generator \$@.S; \\ - \$(CC) $incs \$(CFLAGS) -E \$@.S | \\ + \$(CC) $incs \$(CFLAGS) \$(CPPFLAGS) -E \$@.S | \\ \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\ mv -f \$@.i \$@ ) EOF @@ -857,7 +870,7 @@ EOF } return <<"EOF"; $args{src}: $args{generator}->[0] $deps - \$(CC) $incs \$(CFLAGS) -E $args{generator}->[0] | \\ + \$(CC) $incs \$(CFLAGS) \$(CPPFLAGS) -E $args{generator}->[0] | \\ \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@ EOF } @@ -884,23 +897,34 @@ EOF } } my $cmd = '$(CC)'; - my $cmdflags = '$(CFLAGS) -c'; + my $cmdflags = '$(CFLAGS)'; + my $cmdcompile = ' -c'; my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog}; if (grep /\.rc$/, @srcs) { $cmd = '$(RC)'; $cmdflags = '$(RCFLAGS)'; + $cmdcompile = ''; $makedepprog = undef; } elsif (grep /\.(cc|cpp)$/, @srcs) { $cmd = '$(CXX)'; - $cmdflags = '$(CXXFLAGS) -c'; + $cmdflags = '$(CXXFLAGS)'; $cmdflags .= ' ' . { lib => '$(LIB_CXXFLAGS)', dso => '$(DSO_CXXFLAGS)', bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}}; + $cmdflags .= ' $(CPPFLAGS)'; + $cmdflags .= ' ' . { lib => '$(LIB_CPPFLAGS)', + dso => '$(DSO_CPPFLAGS)', + bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}}; } else { $cmdflags .= ' ' . { lib => '$(LIB_CFLAGS)', dso => '$(DSO_CFLAGS)', bin => '$(BIN_CFLAGS)' } -> {$args{intent}}; + $cmdflags .= ' $(CPPFLAGS)'; + $cmdflags .= ' ' . { lib => '$(LIB_CPPFLAGS)', + dso => '$(DSO_CPPFLAGS)', + bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}}; } + $cmdflags .= $cmdcompile; my $recipe = <<"EOF"; $obj$objext: $deps EOF |