Commit 5b18235a authored by Richard Levitte's avatar Richard Levitte
Browse files

Processing GNU-style "make variables" - implementation



Support the following "make variables":

AR              (GNU compatible)
ARFLAGS         (GNU Compatible)
AS              (GNU Compatible)
ASFLAGS         (GNU Compatible)
CC              (GNU Compatible)
CFLAGS          (GNU Compatible)
CXX             (GNU Compatible)
CXXFLAGS        (GNU Compatible)
CPP             (GNU Compatible)
CPPFLAGS        (GNU Compatible)
CPPDEFINES      List of CPP macro definitions.  Alternative for -D
CPPINCLUDES     List of CPP inclusion directories.  Alternative for -I
HASHBANGPERL    Perl invocation to be inserted after '#!' in public
                perl scripts.
LDFLAGS         (GNU Compatible)
LDLIBS          (GNU Compatible)
RANLIB          Program to generate library archive index
RC              Program to manipulate Windows resources
RCFLAGS         Flags for $(RC)
RM              (GNU Compatible)

Setting one of these overrides the corresponding data from our config
targets.  However, flags given directly on the configuration command
line are additional, and are therefore added to the flags coming from
one of the variables above or the config target.

Fixes #2420

Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5177)
parent 8c3bc594
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1408,7 +1408,7 @@ my %targets = (
            # WIN32 UNICODE build gets linked with unicows.lib for
            # WIN32 UNICODE build gets linked with unicows.lib for
            # backward compatibility with Win9x.
            # backward compatibility with Win9x.
            push @ex_libs, 'unicows.lib'
            push @ex_libs, 'unicows.lib'
                if (grep { $_ eq "UNICODE" } @user_defines);
                if (grep { $_ eq "UNICODE" } @{$user{CPPDEFINES}});
            return join(" ", @ex_libs, @_);
            return join(" ", @ex_libs, @_);
        }),
        }),
        sys_id           => "WIN32",
        sys_id           => "WIN32",
+8 −8
Original line number Original line Diff line number Diff line
@@ -171,16 +171,16 @@ OPENSSLDIR_C={- $osslprefix -}DATAROOT:[000000]
# Where installed engines reside, for C
# Where installed engines reside, for C
ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover_dirname.$target{pointer_size} -}:


CC= {- $target{cc} -}
CC= {- $config{cc} -}
DEFINES={- our $defines = join(",",
DEFINES={- our $defines = join(",",
                               '__dummy', # To make comma processing easier
                               '__dummy', # To make comma processing easier
                               @{$target{defines}}, @{$config{defines}}) -}
                               @{$config{defines}}) -}
CPPFLAGS={- our $cppflags = join('', $target{cppflags}, $config{cppflags}) -}
CPPFLAGS={- our $cppflags = join('', @{$config{cppflags}}) -}
CPPFLAGS_Q={- $cppflags =~ s|"|""|g; $defines =~ s|"|""|g;
CPPFLAGS_Q={- $cppflags =~ s|"|""|g; $defines =~ s|"|""|g;
              $cppflags."/DEFINE($defines)" -}
              $cppflags."/DEFINE($defines)" -}
CFLAGS={- $target{cflags} -} {- $config{cflags} -}
CFLAGS={- join('', @{$config{cflags}}) -}
LDFLAGS= {- $target{lflags} -}
LDFLAGS= {- join('', @{$config{lflags}}) -}
EX_LIBS= {- $target{ex_libs} ? ",".$target{ex_libs} : "" -}{- $config{ex_libs} ? ",".$config{ex_libs} : "" -}
EX_LIBS= {- join('', map { ','.$_ } @{$config{ex_libs}}) -}
LIB_DEFINES={- join("",
LIB_DEFINES={- join("",
                    (map { ",$_" }
                    (map { ",$_" }
                     @{$target{shared_defines}},
                     @{$target{shared_defines}},
@@ -200,8 +200,8 @@ PERL={- $config{perl} -}
# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
# gcc, then the driver will automatically translate it to -xarch=v8plus
# gcc, then the driver will automatically translate it to -xarch=v8plus
# and pass it down to assembler.
# and pass it down to assembler.
AS={- $target{as} -}
AS={- $config{as} -}
ASFLAG={- $target{asflags} -}
ASFLAGS={- join('', @{$config{asflags}}) -}


# .FIRST and .LAST are special targets with MMS and MMK.
# .FIRST and .LAST are special targets with MMS and MMK.
# The defines in there are for C.  includes that look like
# The defines in there are for C.  includes that look like
+2 −2
Original line number Original line Diff line number Diff line
@@ -13,12 +13,12 @@


sub detect_gnu_ld {
sub detect_gnu_ld {
    my @lines =
    my @lines =
        `$config{cross_compile_prefix}$target{cc} -Wl,-V /dev/null 2>&1`;
        `$config{cross_compile_prefix}$config{cc} -Wl,-V /dev/null 2>&1`;
    return grep /^GNU ld/, @lines;
    return grep /^GNU ld/, @lines;
}
}
sub detect_gnu_cc {
sub detect_gnu_cc {
    my @lines =
    my @lines =
        `$config{cross_compile_prefix}$target{cc} -v 2>&1`;
        `$config{cross_compile_prefix}$config{cc} -v 2>&1`;
    return grep /gcc/, @lines;
    return grep /gcc/, @lines;
}
}


+22 −25
Original line number Original line Diff line number Diff line
@@ -185,24 +185,22 @@ ECHO = echo


CROSS_COMPILE= {- $config{cross_compile_prefix} -}
CROSS_COMPILE= {- $config{cross_compile_prefix} -}
CPPFLAGS={- our $cppflags = join(" ",
CPPFLAGS={- our $cppflags = join(" ",
                                 (map { "-D".$_}
                                 (map { "-D".$_} @{$config{defines}}),
                                  @{$target{defines}}, @{$config{defines}}),
                                 (map { "-I".$_} @{$config{includes}}),
                                 (map { "-I".$_}
                                 @{$config{cppflags}}) -}
                                  @{$target{includes}}, @{$config{includes}}),
                                 $target{cppflags}, $config{cppflags}) -}
CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
CC= $(CROSS_COMPILE){- $target{cc} -}
CC= $(CROSS_COMPILE){- $config{cc} -}
CFLAGS={- $target{cflags} -} {- $config{cflags} -}
CFLAGS={- join(' ', @{$config{cflags}}) -}
CXX= $(CROSS_COMPILE){- $target{cxx} -}
CXX= $(CROSS_COMPILE){- $config{cxx} -}
CXXFLAGS={- $target{cxxflags} -} {- $config{cxxflags} -} -std=c++11
CXXFLAGS={- join(' ', @{$config{cxxflags}}) -} -std=c++11
LDFLAGS= {- $config{lflags} -} {- $target{lflags} -}
LDFLAGS= {- join(' ', @{$config{lflags}}) -}
PLIB_LDFLAGS= {- $target{plib_lflags} -}
PLIB_LDFLAGS= {- join(' ', @{$config{plib_lflags}}) -}
EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
EX_LIBS= {- join(' ', @{$config{ex_libs}}) -}
LIB_CPPFLAGS={- join(" ",
LIB_CPPFLAGS={- join(' ',
                     (map { "-D".$_}
                     (map { '-D'.$_ }
                      'OPENSSLDIR="\"$(OPENSSLDIR)\""',
                          ('OPENSSLDIR="\"$(OPENSSLDIR)\""',
                      'ENGINESDIR="\"$(ENGINESDIR)\""'),
                           'ENGINESDIR="\"$(ENGINESDIR)\""')),
                     $target{shared_cppflag} || "") -}
                     $target{shared_cppflag}) || "" -}
LIB_CFLAGS={- $target{shared_cflag} || "" -}
LIB_CFLAGS={- $target{shared_cflag} || "" -}
LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
@@ -217,12 +215,11 @@ BIN_LDFLAGS={- $target{bin_lflags} || "" -}


PERL={- $config{perl} -}
PERL={- $config{perl} -}


ARFLAGS= {- $target{arflags} -}
AR=$(CROSS_COMPILE){- $config{ar} -}
AR=$(CROSS_COMPILE){- $target{ar} || "ar" -} $(ARFLAGS) r
ARFLAGS= {- join(' ', @{$config{arflags}}) -}
RANLIB= {- $target{ranlib} -}
RANLIB= {- $config{ranlib} -}
NM= $(CROSS_COMPILE){- $target{nm} || "nm" -}
RCFLAGS={- $target{shared_rcflag} -}
RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
RC= $(CROSS_COMPILE){- $target{rc} || "windres" -}
RCFLAGS={- join(' ', @{$config{rcflags}}) -} {- $target{shared_rcflag} -}
RM= rm -f
RM= rm -f
RMDIR= rmdir
RMDIR= rmdir
TAR= {- $target{tar} || "tar" -}
TAR= {- $target{tar} || "tar" -}
@@ -238,8 +235,8 @@ TARFILE= ../$(NAME).tar
# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
# gcc, then the driver will automatically translate it to -xarch=v8plus
# gcc, then the driver will automatically translate it to -xarch=v8plus
# and pass it down to assembler.
# and pass it down to assembler.
AS=$(CC) -c
AS={- $config{as} || '$(CC) -c' -}
ASFLAG=$(CFLAGS)
ASFLAGS={- join(' ', @{$config{asflags}}) || '$(CFLAGS)' -}
PERLASM_SCHEME= {- $target{perlasm_scheme} -}
PERLASM_SCHEME= {- $target{perlasm_scheme} -}


# For x86 assembler: Set PROCESSOR to 386 if you want to support
# For x86 assembler: Set PROCESSOR to 386 if you want to support
@@ -1057,7 +1054,7 @@ EOF
      my $objs = join(" ", @objs);
      my $objs = join(" ", @objs);
      return <<"EOF";
      return <<"EOF";
$lib$libext: $objs
$lib$libext: $objs
	\$(AR) \$\@ \$\?
	\$(AR) \$(ARFLAGS) \$\@ \$\?
	\$(RANLIB) \$\@ || echo Never mind.
	\$(RANLIB) \$\@ || echo Never mind.
EOF
EOF
  }
  }
+19 −21
Original line number Original line Diff line number Diff line
@@ -159,29 +159,27 @@ OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
!ENDIF
!ENDIF


CC={- $target{cc} -}
CC={- $config{cc} -}
CPPFLAGS={- our $cppflags = join(" ",
CPPFLAGS={- our $cppflags = join(" ",
                                 (map { "-D".$_}
                                 (map { "-D".$_} @{$config{defines}}),
                                  @{$target{defines}}, @{$config{defines}}),
                                 (map { " /I ".$_} @{$config{includes}}),
                                 (map { " /I ".$_}
                                 @{$config{cppflags}}) -}
                                  @{$target{includes}}, @{$config{includes}}),
                                 $target{cppflags}, $config{cppflags}) -}
CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
CFLAGS={- $target{cflags} -} {- $config{cflags} -}
CFLAGS={- join(' ', @{$config{cflags}}) -}
COUTFLAG={- $target{coutflag} || "/Fo" -}$(OSSL_EMPTY)
COUTFLAG={- $target{coutflag} || "/Fo" -}$(OSSL_EMPTY)
RC={- $target{rc} || "rc" -}
RC={- $config{rc} -}
RCOUTFLAG={- $target{rcoutflag} || "/fo" -}$(OSSL_EMPTY)
RCOUTFLAG={- $target{rcoutflag} || "/fo" -}$(OSSL_EMPTY)
LD={- $target{ld} || "link" -}
LD={- $config{ld} -}
LDFLAGS={- $target{lflags} -}
LDFLAGS={- join(' ', @{$config{lflags}}) -}
LDOUTFLAG={- $target{loutflag} || "/out:" -}$(OSSL_EMPTY)
LDOUTFLAG={- $target{loutflag} || "/out:" -}$(OSSL_EMPTY)
EX_LIBS={- $target{ex_libs} -}
EX_LIBS={- join(' ', @{$config{ex_libs}}) -}
LIB_CPPFLAGS={- join(" ",
LIB_CPPFLAGS={- join(" ",
                     $target{shared_cppflag} || "",
                     $target{shared_cppflag} || "",
                     (map { quotiry_l("-D".$_) }
                     (map { quotiry_l("-D".$_) }
                      'OPENSSLDIR="$(OPENSSLDIR)"',
                      'OPENSSLDIR="$(OPENSSLDIR)"',
                      'ENGINESDIR="$(ENGINESDIR)"')) -}
                      'ENGINESDIR="$(ENGINESDIR)"')) -}
LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -}
LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) -}
LIB_LDFLAGS={- $target{shared_ldflag} || "" -}
LIB_LDFLAGS={- join(' ', $target{shared_ldflag}, $config{shared_ldflag}) -}
DSO_CPPFLAGS={- $target{dso_cppflags} || "" -}
DSO_CPPFLAGS={- $target{dso_cppflags} || "" -}
DSO_CFLAGS={- $target{dso_cflags} || "" -}
DSO_CFLAGS={- $target{dso_cflags} || "" -}
DSO_LDFLAGS={- $target{dso_ldflag} || "" -}
DSO_LDFLAGS={- $target{dso_ldflag} || "" -}
@@ -191,17 +189,17 @@ BIN_LDFLAGS={- $target{bin_lflags} -}


PERL={- $config{perl} -}
PERL={- $config{perl} -}


AR={- $target{ar} -}
AR={- $config{ar} -}
ARFLAGS= {- $target{arflags} -}
ARFLAGS= {- join(' ', @{$config{arflags}}) -}
AROUTFLAG={- $target{aroutflag} || "/out:" -}$(OSSL_EMPTY)
AROUTFLAG={- $target{aroutflag} || "/out:" -}$(OSSL_EMPTY)


MT={- $target{mt} -}
MT={- $config{mt} -}
MTFLAGS= {- $target{mtflags} -}
MTFLAGS= {- join(' ', @{$config{mtflags}}) -}
MTINFLAG={- $target{mtinflag} || "-manifest " -}$(OSSL_EMPTY)
MTINFLAG={- $target{mtinflag} || "-manifest " -}$(OSSL_EMPTY)
MTOUTFLAG={- $target{mtoutflag} || "-outputresource:" -}$(OSSL_EMPTY)
MTOUTFLAG={- $target{mtoutflag} || "-outputresource:" -}$(OSSL_EMPTY)


AS={- $target{as} -}
AS={- $config{as} -}
ASFLAGS={- $target{asflags} -}
ASFLAGS={- join(' ', @{$config{asflags}}) -}
ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
PERLASM_SCHEME= {- $target{perlasm_scheme} -}
PERLASM_SCHEME= {- $target{perlasm_scheme} -}


@@ -316,10 +314,10 @@ install_dev:
	@if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
	@if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
	@echo *** Installing development files
	@echo *** Installing development files
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
	@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
	@rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
	@rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
				       "$(INSTALLTOP)\include\openssl"
				       "$(INSTALLTOP)\include\openssl"
	@rem {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
	@rem {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\include\openssl\*.h" \
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\include\openssl\*.h" \
				       "$(INSTALLTOP)\include\openssl"
				       "$(INSTALLTOP)\include\openssl"
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\include\openssl\*.h \
	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\include\openssl\*.h \
Loading