0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/deps/openssl/config/generate_gypi.pl

171 lines
5.4 KiB
Perl
Raw Normal View History

deps: add gyp, header and Makefile for openssl110 This commit has a new binding scheme in builing OpenSSL-1.1.0 library with Node. OpenSSL-1.1.0 uses a new build system with perl for various supported platforms. See `Configurations/README` and `Configurations/README.design` in the OpenSSL source for details. In order to build OpenSSL library without perl in the build of Node for various supported platforms, platform dependent files (e.g. asm and header files ) are pre-generated and stored into the `config/arch` directory. - Makefile and generate_gypi.pl Makefile has supported platform list and generates and copies platform dependent files (e.g. asm files) into arch directory with generate_gypi.pl. Platform dependent gypi files also created obtaining build information from `configdata.pm` that is generated with `Configure` in the OpenSSL build system. For Windows, `Configure` generates makefile that is only available to nmake command. Since nmake is not supported in Linux, `Makefile_VC-WIN32` and `Makefile_VC-WIN64A` are made created by hand for the use of GNU make. If make rules or targets are changed in the version up of OpenSSL, they should be also updated. The following files are used in upgrading openssl-1.1.0. - gyp and gypi files openssl.gyp has two targets of openssl and openssl-cli referred from node.gyp. They includes asm and no_asm gypi files with arch dependent gypi according to its build options and platforms . The gyp data which is common with asm and no_asm are stored in openssl_common.gypi. - header files bn_conf.h, dso_conf.h and opensslconf.h are platform dependent in the OpenSSL sources. They are replaced with *.h.tmpl files to include the file in the `../../../config/` and referred to each arch files that depends on asm and no-asm option. Fixes: https://github.com/nodejs/node/issues/4270 PR-URL: https://github.com/nodejs/node/pull/19794 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-03-07 13:38:23 +01:00
#! /usr/bin/env perl -w
use 5.10.0;
use strict;
use FindBin;
use lib "$FindBin::Bin/../openssl/";
use lib "$FindBin::Bin/../openssl/util/perl";
use File::Basename;
use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
use File::Copy;
use File::Path qw/make_path/;
use with_fallback qw(Text::Template);
# Read configdata from ../openssl/configdata.pm that is generated
# with ../openssl/Configure options arch
use configdata;
my $asm = $ARGV[0];
unless ($asm eq "asm" or $asm eq "no-asm") {
die "Error: $asm is invalid argument";
}
my $arch = $ARGV[1];
# nasm version check
my $nasm_banner = `nasm -v`;
die "Error: nasm is not installed." if (!$nasm_banner);
my $nasm_version_min = 2.11;
my ($nasm_version) = ($nasm_banner =~/^NASM version ([0-9]\.[0-9][0-9])+/);
if ($nasm_version < $nasm_version_min) {
die "Error: nasm version $nasm_version is too old." .
"$nasm_version_min or higher is required.";
}
# gas version check
my $gas_version_min = 2.26;
my $gas_banner = `gcc -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`;
my ($gas_version) = ($gas_banner =~/GNU assembler version ([2-9]\.[0-9]+)/);
if ($gas_version < $gas_version_min) {
die "Error: gas version $gas_version is too old." .
"$gas_version_min or higher is required.";
}
my $src_dir = "../openssl";
my $arch_dir = "../config/archs/$arch";
my $base_dir = "$arch_dir/$asm";
my $is_win = ($arch =~/^VC-WIN/);
# VC-WIN32 and VC-WIN64A generate makefile but it can be available
# with only nmake. Use pre-created Makefile_VC_WIN32
# Makefile_VC-WIN64A instead.
my $makefile = $is_win ? "../config/Makefile_$arch": "Makefile";
# Generate arch dependent header files with Makefile
my $buildinf = "crypto/buildinf.h";
my $progs = "apps/progs.h";
my $cmd1 = "cd ../openssl; make -f $makefile build_generated $buildinf $progs;";
system($cmd1) == 0 or die "Error in system($cmd1)";
# Copy and move all arch dependent header files into config/archs
make_path("$base_dir/crypto/include/internal", "$base_dir/include/openssl",
{
error => \my $make_path_err});
if (@$make_path_err) {
for my $diag (@$make_path_err) {
my ($file, $message) = %$diag;
die "make_path error: $file $message\n";
}
}
copy("$src_dir/configdata.pm", "$base_dir/") or die "Copy failed: $!";
copy("$src_dir/include/openssl/opensslconf.h",
"$base_dir/include/openssl/") or die "Copy failed: $!";
move("$src_dir/crypto/include/internal/bn_conf.h",
"$base_dir/crypto/include/internal/") or die "Move failed: $!";
move("$src_dir/crypto/include/internal/dso_conf.h",
"$base_dir/crypto/include/internal/") or die "Move failed: $!";
copy("$src_dir/$buildinf",
"$base_dir/crypto/") or die "Copy failed: $!";
move("$src_dir/$progs",
"$base_dir/include") or die "Copy failed: $!";
# read openssl source lists from configdata.pm
my @libapps_srcs = ();
foreach my $obj (@{$unified_info{sources}->{'apps/libapps.a'}}) {
push(@libapps_srcs, ${$unified_info{sources}->{$obj}}[0]);
}
my @libssl_srcs = ();
foreach my $obj (@{$unified_info{sources}->{libssl}}) {
push(@libssl_srcs, ${$unified_info{sources}->{$obj}}[0]);
}
my @libcrypto_srcs = ();
my @generated_srcs = ();
foreach my $obj (@{$unified_info{sources}->{libcrypto}}) {
my $src = ${$unified_info{sources}->{$obj}}[0];
# .S files should be preprocessed into .s
if ($unified_info{generate}->{$src}) {
# .S or .s files should be preprocessed into .asm for WIN
$src =~ s\.[sS]$\.asm\ if ($is_win);
push(@generated_srcs, $src);
} else {
push(@libcrypto_srcs, $src);
}
}
my @apps_openssl_srcs = ();
foreach my $obj (@{$unified_info{sources}->{'apps/openssl'}}) {
push(@apps_openssl_srcs, ${$unified_info{sources}->{$obj}}[0]);
}
# Generate all asm files and copy into config/archs
foreach my $src (@generated_srcs) {
my $cmd = "cd ../openssl; CC=gcc ASM=nasm make -f $makefile $src;" .
"cp --parents $src ../config/archs/$arch/$asm; cd ../config";
system("$cmd") == 0 or die "Error in system($cmd)";
}
$target{'lib_cppflags'} =~ s/-D//g;
my @lib_cppflags = split(/ /, $target{'lib_cppflags'});
deps: add gyp, header and Makefile for openssl110 This commit has a new binding scheme in builing OpenSSL-1.1.0 library with Node. OpenSSL-1.1.0 uses a new build system with perl for various supported platforms. See `Configurations/README` and `Configurations/README.design` in the OpenSSL source for details. In order to build OpenSSL library without perl in the build of Node for various supported platforms, platform dependent files (e.g. asm and header files ) are pre-generated and stored into the `config/arch` directory. - Makefile and generate_gypi.pl Makefile has supported platform list and generates and copies platform dependent files (e.g. asm files) into arch directory with generate_gypi.pl. Platform dependent gypi files also created obtaining build information from `configdata.pm` that is generated with `Configure` in the OpenSSL build system. For Windows, `Configure` generates makefile that is only available to nmake command. Since nmake is not supported in Linux, `Makefile_VC-WIN32` and `Makefile_VC-WIN64A` are made created by hand for the use of GNU make. If make rules or targets are changed in the version up of OpenSSL, they should be also updated. The following files are used in upgrading openssl-1.1.0. - gyp and gypi files openssl.gyp has two targets of openssl and openssl-cli referred from node.gyp. They includes asm and no_asm gypi files with arch dependent gypi according to its build options and platforms . The gyp data which is common with asm and no_asm are stored in openssl_common.gypi. - header files bn_conf.h, dso_conf.h and opensslconf.h are platform dependent in the OpenSSL sources. They are replaced with *.h.tmpl files to include the file in the `../../../config/` and referred to each arch files that depends on asm and no-asm option. Fixes: https://github.com/nodejs/node/issues/4270 PR-URL: https://github.com/nodejs/node/pull/19794 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-03-07 13:38:23 +01:00
# Create openssl.gypi
my $template =
Text::Template->new(TYPE => 'FILE',
SOURCE => 'openssl.gypi.tmpl',
DELIMITERS => [ "%%-", "-%%" ]
);
my $gypi = $template->fill_in(
HASH => {
libssl_srcs => \@libssl_srcs,
libcrypto_srcs => \@libcrypto_srcs,
generated_srcs => \@generated_srcs,
config => \%config,
target => \%target,
asm => \$asm,
arch => \$arch,
lib_cppflags => \@lib_cppflags,
deps: add gyp, header and Makefile for openssl110 This commit has a new binding scheme in builing OpenSSL-1.1.0 library with Node. OpenSSL-1.1.0 uses a new build system with perl for various supported platforms. See `Configurations/README` and `Configurations/README.design` in the OpenSSL source for details. In order to build OpenSSL library without perl in the build of Node for various supported platforms, platform dependent files (e.g. asm and header files ) are pre-generated and stored into the `config/arch` directory. - Makefile and generate_gypi.pl Makefile has supported platform list and generates and copies platform dependent files (e.g. asm files) into arch directory with generate_gypi.pl. Platform dependent gypi files also created obtaining build information from `configdata.pm` that is generated with `Configure` in the OpenSSL build system. For Windows, `Configure` generates makefile that is only available to nmake command. Since nmake is not supported in Linux, `Makefile_VC-WIN32` and `Makefile_VC-WIN64A` are made created by hand for the use of GNU make. If make rules or targets are changed in the version up of OpenSSL, they should be also updated. The following files are used in upgrading openssl-1.1.0. - gyp and gypi files openssl.gyp has two targets of openssl and openssl-cli referred from node.gyp. They includes asm and no_asm gypi files with arch dependent gypi according to its build options and platforms . The gyp data which is common with asm and no_asm are stored in openssl_common.gypi. - header files bn_conf.h, dso_conf.h and opensslconf.h are platform dependent in the OpenSSL sources. They are replaced with *.h.tmpl files to include the file in the `../../../config/` and referred to each arch files that depends on asm and no-asm option. Fixes: https://github.com/nodejs/node/issues/4270 PR-URL: https://github.com/nodejs/node/pull/19794 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-03-07 13:38:23 +01:00
is_win => \$is_win,
});
open(GYPI, "> ./archs/$arch/$asm/openssl.gypi");
print GYPI "$gypi";
close(GYPI);
# Create openssl-cl.gypi
my $cltemplate =
Text::Template->new(TYPE => 'FILE',
SOURCE => 'openssl-cl.gypi.tmpl',
DELIMITERS => [ "%%-", "-%%" ]
);
my $clgypi = $cltemplate->fill_in(
HASH => {
apps_openssl_srcs => \@apps_openssl_srcs,
libapps_srcs => \@libapps_srcs,
config => \%config,
target => \%target,
arch => \$arch,
lib_cppflags => \@lib_cppflags,
deps: add gyp, header and Makefile for openssl110 This commit has a new binding scheme in builing OpenSSL-1.1.0 library with Node. OpenSSL-1.1.0 uses a new build system with perl for various supported platforms. See `Configurations/README` and `Configurations/README.design` in the OpenSSL source for details. In order to build OpenSSL library without perl in the build of Node for various supported platforms, platform dependent files (e.g. asm and header files ) are pre-generated and stored into the `config/arch` directory. - Makefile and generate_gypi.pl Makefile has supported platform list and generates and copies platform dependent files (e.g. asm files) into arch directory with generate_gypi.pl. Platform dependent gypi files also created obtaining build information from `configdata.pm` that is generated with `Configure` in the OpenSSL build system. For Windows, `Configure` generates makefile that is only available to nmake command. Since nmake is not supported in Linux, `Makefile_VC-WIN32` and `Makefile_VC-WIN64A` are made created by hand for the use of GNU make. If make rules or targets are changed in the version up of OpenSSL, they should be also updated. The following files are used in upgrading openssl-1.1.0. - gyp and gypi files openssl.gyp has two targets of openssl and openssl-cli referred from node.gyp. They includes asm and no_asm gypi files with arch dependent gypi according to its build options and platforms . The gyp data which is common with asm and no_asm are stored in openssl_common.gypi. - header files bn_conf.h, dso_conf.h and opensslconf.h are platform dependent in the OpenSSL sources. They are replaced with *.h.tmpl files to include the file in the `../../../config/` and referred to each arch files that depends on asm and no-asm option. Fixes: https://github.com/nodejs/node/issues/4270 PR-URL: https://github.com/nodejs/node/pull/19794 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-03-07 13:38:23 +01:00
is_win => \$is_win,
});
open(CLGYPI, "> ./archs/$arch/$asm/openssl-cl.gypi");
print CLGYPI "$clgypi";
close(CLGYPI);
# Clean Up
my $cmd2 ="cd $src_dir; make -f $makefile clean; make -f $makefile distclean;" .
"git clean -f $src_dir/crypto";
system($cmd2) == 0 or die "Error in system($cmd2)";