diff options
author | Richard Levitte <levitte@openssl.org> | 2016-03-08 19:19:53 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-03-09 00:15:56 +0100 |
commit | 8458f1bfab1b30ce96a39593331a94b44efbe2b2 (patch) | |
tree | 11993239ca94bcadde7367d0c00d43d277fe57f8 /Configurations/unix-Makefile.tmpl | |
parent | b2d6aed499e584e0da232fd109459cf7743f00fe (diff) | |
download | openssl-new-8458f1bfab1b30ce96a39593331a94b44efbe2b2.tar.gz |
Redo the Unix source code generator
For assembler, we want the final target to be foo.s (lowercase s).
However, the build.info may have lines like this (note upper case S):
GENERATE[foo.S]=foo.pl
This indicates that foo.s (lowercase s) is still to be produced, but
that producing it will take an extra step via $(CC) -E. Therefore,
the following variants (simplified for display) can be generated:
GENERATE[foo.S]=foo.pl => foo.s: foo.pl
$(PERL) $foo.pl $@.S; \
$(CC) $(CFLAGS) -E -P $@.S > $@ && \
rm -f $@.S
GENERATE[foo.s]=foo.pl => foo.s: foo.pl
$(PERL) $foo.pl $@
GENERATE[foo.S]=foo.m4 => foo.s: foo.m4
m4 -B 8192 $foo.m4 > $@.S; \
$(CC) $(CFLAGS) -E -P $@.S > $@ && \
rm -f $@.S
GENERATE[foo.s]=foo.m4 => foo.s: foo.m4
m4 -B 8192 $foo.m4 > $@
Reviewed-by: Andy Polyakov <appro@openssl.org>
Diffstat (limited to 'Configurations/unix-Makefile.tmpl')
-rw-r--r-- | Configurations/unix-Makefile.tmpl | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 9f4c1f228f..d5a64b5be3 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -828,38 +828,47 @@ $args{src}: $args{generator}->[0] \$(PERL) $generator > \$@ EOF } else { - if ($args{generator}->[0] =~ /\.[sS]$/) { - return <<"EOF"; -$args{src}: $args{generator}->[0] - \$(CC) \$(CFLAGS) -E \$< > \$@ -EOF - } elsif ($args{generator}->[0] =~ /\.pl$/) { - return <<"EOF"; -$args{src}: $args{generator}->[0] + if ($args{generator}->[0] =~ /\.pl$/) { + $generator = 'CC="$(CC)" $(PERL) '.$generator; + } elsif ($args{generator}->[0] =~ /\.m4$/) { + $generator = 'm4 -B 8192 '.$generator.' >' + } elsif ($args{generator}->[0] =~ /\.S$/) { + $generator = undef; + } else { + die "Generator type for $args{src} unknown: $generator\n"; + } + + if (defined($generator)) { + # If the target is named foo.S in build.info, we want to + # end up generating foo.s in two steps. + if ($args{src} =~ /\.S$/) { + (my $target = $args{src}) =~ s|\.S$|.s|; + return <<"EOF"; +$target: $args{generator}->[0] ( trap "rm -f \$@.S" INT; \\ - CC="\$(CC)" \$(PERL) $generator \$@.S; \\ - if grep '^#' \$@.S >/dev/null; then \\ - \$(CC) -E -P \$@.S > \$@ && rm -f \$@.S; \\ - else \\ - mv \$@.S \$@; \\ - fi ) + $generator \$@.S; \\ + \$(CC) \$(CFLAGS) -E -P \$@.S > \$@ && rm -f \$@.S ) EOF - } elsif ($args{generator}->[0] =~ /\.m4$/) { + } + # Otherwise.... return <<"EOF"; $args{src}: $args{generator}->[0] - m4 -B 8192 $generator > \$@ + $generator \$@ EOF - } else { - die "Generator type for $args{src} unknown: $args{generator}\n"; } + return <<"EOF"; +$args{src}: $args{generator}->[0] + \$(CC) \$(CFLAGS) -E -P \$< > \$@ +EOF } } sub src2obj { my %args = @_; my $obj = $args{obj}; - my $srcs = join(" ", @{$args{srcs}}); - my $deps = join(" ", @{$args{srcs}}, @{$args{deps}}); + my @srcs = map { (my $x = $_) =~ s/\.S$/.s/; $x } ( @{$args{srcs}} ); + my $srcs = join(" ", @srcs); + my $deps = join(" ", @srcs, @{$args{deps}}); my $incs = join("", map { " -I".$_ } @{$args{incs}}); my $ecflags = { lib => '$(SHARED_CFLAGS)', dso => '$(DSO_CFLAGS)', |