📄 configure.pl
字号:
foreach (@using_mods) { die "ERROR: Module $_ isn't known (try --help)\n" unless(exists($MODULES{$_}));}if($#ARGV != 0) { help(); }my ($cc,$os,$submodel) = split(/-/,$ARGV[0],3);if(!defined($cc) or !defined($os) or !defined($submodel)) { help(); }################################################### Some special hacks ###################################################if(($special_flag & 1) and $cc ne 'gcc') { die "ERROR: Using --gcc295x without specifying GCC makes no sense\n"; }# There should be a mechanism to handle this in a general mannerif($os eq 'macosx') { $os = 'darwin'; }if($os eq 'linux' and $cc eq 'gcc' and 0){print <<END_OF_WARNING;WARNING: On GCC 2.96 systems, disable -fomit-frame-pointer in the Makefile Otherwise bad code, resulting in crashes, will be generatedEND_OF_WARNING}################################################### Check input ###################################################if(!defined($CC_BINARY_NAME{$cc})) { die "ERROR: Compiler $cc isn't known\n"; }if(!defined($OS_SUPPORTS_ARCH{$os}) and $os ne 'generic') { die "ERROR: OS $os isn't known\n"; }# Get the canonical submodel name (like r8k -> r8000)if(defined($SUBMODEL_ALIAS{$submodel})) { $submodel = $SUBMODEL_ALIAS{$submodel}; }my $arch = undef;# Convert an arch alias to it's real name (like axp -> alpha)if(defined($ARCH_ALIAS{$submodel})) { $arch = $ARCH_ALIAS{$submodel}; $submodel = $arch; }# If it's a regular submodel type, figure out what arch it iselsif(defined($ARCH{$submodel})) { $arch = $ARCH{$submodel}; }elsif($submodel eq 'generic') { $arch = 'generic'; }else { die "ERROR: Arch $submodel isn't known\n"; }# If we got a generic family name as the model typeif($submodel eq $arch and $submodel ne 'generic') { $submodel = $DEFAULT_SUBMODEL{$arch}; if($submodel ne $arch) { print STDERR "WARNING: Using $submodel as default type for family ", $REALNAME{$arch},"\n"; }}unless($make_style) { $make_style = $MAKEFILE_STYLE{$cc}; }################################################### Does the OS support the arch? ###################################################unless($arch eq 'generic' or $os eq 'generic' or in_array($OS_SUPPORTS_ARCH{$os}, $arch)) { die "ERROR: $REALNAME{$os} doesn't run on $REALNAME{$arch}\n"; }################################################### Does the compiler support the arch? ###################################################unless($arch eq 'generic' or (in_array($CC_SUPPORTS_ARCH{$cc}, $arch))) { die "ERROR: $REALNAME{$cc} doesn't run on $REALNAME{$arch}\n"; }################################################### Does the compiler support the OS? ###################################################unless($os eq 'generic' or (in_array($CC_SUPPORTS_OS{$cc}, $os))) { die "ERROR: $REALNAME{$cc} doesn't run on $REALNAME{$os}\n"; }################################################### Check for conflicts in the module selections ###################################################check_for_conflicts(@using_mods);my (%ignored_src, %ignored_include, %added_src, %added_include, %patched);foreach (@using_mods) { load_module($_, $cc, $os, $arch, $submodel, $no_asm, %{ $MODULES{$_} });}################################################### Print some source files ###################################################my $CONFIG_H_FILE = catfile($INCLUDE_DIR, $CONFIG_HEADER);print_config_h($MAJOR_VERSION, $MINOR_VERSION, $PATCH_VERSION, defines(@using_mods));################################################### Figure out the files involved #################################################### These go here because $make_style has to be defined (and correctly set)# before we call cat*my $CPP_INCLUDE_DIR = catdir($INCLUDE_DIR, $CPP_INCLUDE_DIR_DIRNAME);my $BUILD_LIB_DIR = catdir($BUILD_DIR, $BUILD_DIR_LIB);my $BUILD_CHECK_DIR = catdir($BUILD_DIR, $BUILD_DIR_CHECKS);my %lib_src = list_dir($SRC_DIR, \%ignored_src);my %check_src = list_dir($CHECK_DIR, undef);my %include = list_dir($INCLUDE_DIR, \%ignored_include);# Make sure to remove the directory that's in include/delete $include{$CPP_INCLUDE_DIR_DIRNAME};################################################### Print the makefile ###################################################generate_makefile($make_style, $cc, $os, $submodel, $arch, $debug, $no_asm, $no_shared, $special_flag, \%lib_src, \%check_src, \%include, \%added_src, \%added_include, \%patched, using_libs(@using_mods));################################################### Set up the build tree ###################################################if($NMAKE_ON_UNIX_HACK){ print "Not setting up build tree, just generating NMAKE makefile\n"; exit;}mkdirs(($CPP_INCLUDE_DIR, $BUILD_DIR, $BUILD_LIB_DIR, $BUILD_CHECK_DIR));clean_out_dirs(($CPP_INCLUDE_DIR));copy_files($CPP_INCLUDE_DIR, \%include, \%added_include);exit;use File::Spec::Win32;sub catfile { if($NMAKE_ON_UNIX_HACK && defined($make_style) && $make_style eq "nmake") { return File::Spec::Win32->catdir(@_); } else { return File::Spec->catfile(@_); }}sub catdir { if($NMAKE_ON_UNIX_HACK && defined($make_style) && $make_style eq "nmake") { return File::Spec::Win32->catdir(@_); } else { return File::Spec->catdir(@_); }}sub process { my $l = $_[0]; chomp($l); $l =~ s/#.*//; $l =~ s/^\s*//; $l =~ s/\s*$//; $l =~ s/\s\s*/ /; $l =~ s/\t/ /; $l;}sub check_for_file { my ($file,$mod) = @_; # Hacks upon hacks. Sigh. This thing is such a mess. return if($NMAKE_ON_UNIX_HACK && defined($make_style) && $make_style eq "nmake"); unless( -e $file ) { die "ERROR: Module $mod requires that file $file exist. This error\n", "should never occur; please contact the maintainers with details.\n"; }}sub using_libs { my @using = @_; my %libs; foreach my $mod (@using) { foreach my $lib (sort keys %{ $MODULES{$mod}{'libs'} }) { $libs{$lib} = 1; } } my @libarray; foreach (sort keys %libs) { push @libarray , $_; } return @libarray; }sub defines { my @using = @_; my @defarray; foreach (@using) { foreach my $define (sort keys %{ $MODULES{$_}{'define'} }) { push @defarray , $define; } } return @defarray; }# Any other alternatives here?sub portable_symlink { my ($from, $to) = @_; my $can_symlink = eval { symlink("",""); 1 }; my $can_link = eval { link("",""); 1 }; if($can_symlink) { symlink $from, $to or die "Can't symlink $from to $to ($!)"; } elsif($can_link) { link $from, $to or die "Can't link $from to $to ($!)"; } # Wow! We're running on a _really_ broken filesystem - hello Windows # ... OK, I guess perlport(3) says VMS and RISC OS are the same way. else { # Grrr... copy has different sematics than (sym)link # Does this work if the 'volume' thing is used? my(undef,$dirs,$file) = File::Spec->splitpath($from, 0); # Cut out empty entries and .. my $fixed_from = catfile((grep { /./ } grep { !/\.\./ } File::Spec->splitdir($dirs)), $file); copy ($fixed_from, $to) or die "Can't copy $fixed_from to $to ($!)"; }}sub copy_files { my ($include_dir, $mainline, $modules) = @_; my $updir = File::Spec->updir(); foreach (keys %{ $mainline }) { portable_symlink(catfile($updir, $_), catfile($include_dir, $_)); } foreach (keys %{ $modules }) { portable_symlink(catfile($updir, $updir, $$modules{$_}, $_), catfile($include_dir, $_)); }}sub list_dir { my ($dir, $ignore) = @_; opendir DIR, $dir or die "Couldn't open directory $dir ($!)\n"; my @list = grep { !/.dat$/ } grep { !/^keys$/ } grep { !/^\./ } readdir DIR; # If $ignore is set, pull everything in @list that's in $ignore out of it if(defined($ignore)) { @list = grep { !exists($$ignore{$_}) } @list; } close DIR; my %list = map { $_ => $dir } @list; return %list;}sub clean_out_dirs { my (@dirs) = @_; foreach my $dir (@dirs) { my %files = list_dir($dir); foreach my $file (keys %files) { my $path = catfile($dir, $file); unlink $path or die "Could not unlink $path ($!)\n"; } }}sub mkdirs { my (@dirs) = @_; foreach my $dir (@dirs) { next if( -e $dir and -d $dir ); # skip it if it's already there mkdir($dir, 0777) or die "ERROR: Could not create directory $dir ($!)\n"; }}sub in_array { my($array_ref, $target) = @_; if(!defined($array_ref)) { return 0; } my @array = @{ $array_ref }; foreach (@array) { if($_ eq $target) { return 1; } } return 0;}sub print_config_h { my ($major, $minor, $patch, @defines) = @_; chomp($patch); my $defines_old = ""; # The backwards compatible OPENCL_EXT_* macros my $defines = ""; foreach (sort @defines) { next if not defined $_ or not $_; $defines .= "#define BOTAN_EXT_$_\n"; $defines_old .= "#define OPENCL_EXT_$_\n"; } chomp($defines); chomp($defines_old); open CONFIG_H, ">$CONFIG_H_FILE" or die "Couldn't write $CONFIG_H_FILE ($!)\n"; print CONFIG_H <<END_OF_CONFIG_H;/************************************************** Configuration Header File ** (C) 1999-2002 The Botan Project **************************************************/#ifndef BOTAN_CONFIG_H__#define BOTAN_CONFIG_H__#include <botan/types.h>namespace Botan {const u32bit DEFAULT_BUFFERSIZE = 4*1024;const u32bit VECTOR_OVER_ALLOCATE = 4;#define MP_WORD_BITS 32#define BOTAN_VERSION_MAJOR $major#define BOTAN_VERSION_MINOR $minor#define BOTAN_VERSION_PATCH $patch$defines#define OPENCL_VERSION_MAJOR $major#define OPENCL_VERSION_MINOR $minor#define OPENCL_VERSION_PATCH $patch$defines_old}#endifEND_OF_CONFIG_H }sub check_for_conflicts { my @mods = @_; my (%ignored, %added, %patched, %replaced, %defines); foreach my $mod (@mods) { sub check_hash { my ($mod, $do_what, $hashref) = @_; foreach (keys %{ $MODULES{$mod}{$do_what} }) { ${$hashref}{conflicts($mod, $_, $do_what, $hashref)} = $mod; } } check_hash($mod, 'define', \%defines); check_hash($mod, 'replace', \%replaced); check_hash($mod, 'add', \%added); check_hash($mod, 'patch', \%patched); check_hash($mod, 'ignore', \%ignored); }}sub conflicts { my ($mod, $item, $do_what, $hashref) = @_; return if(!defined($item)); if(defined($$hashref{$item})) { my $other_mod = $$hashref{$item}; die "ERROR: Both $mod and $other_mod $do_what $item\n"; } return $item;}sub get_modules_list { my $MOD_DIR = $_[0]; my $dir = new DirHandle $MOD_DIR; if(!defined $dir) { return (); } my %MOD; while(defined($_ = $dir->read)) { next if($_ eq '.' or $_ eq '..'); my $MODULE = $_; my %modinfo = get_module_info($MODULE, $MOD_DIR); foreach (keys %modinfo) { $MOD{$MODULE}{$_} = $modinfo{$_}; } } return %MOD; }sub get_module_info { my ($MODULE, $MOD_DIR) = @_; my %HASH; my $mod_dirname = catfile($MOD_DIR,$MODULE); my $mod_dir = new DirHandle $mod_dirname; if(!defined $mod_dir) { die "ERROR: Couldn't open dir $mod_dirname ($!)\n"; } my %MODFILES; my $have_config_file = 0; while(defined($_ = $mod_dir->read)) { if($_ eq $MODULE) { $have_config_file = 1; } else { $MODFILES{$_} = undef; } } die "ERROR: Module $MODULE does not seem to have a description file\n" unless $have_config_file; my $desc_file = catfile($MOD_DIR,$MODULE,$MODULE); open MODFILE, "<$desc_file" or die "ERROR: Couldn't open file $desc_file, ($!)\n"; $HASH{'needs_std'} = {}; $HASH{'libs'} = {}; $HASH{'add'} = {}; $HASH{'replace'} = {}; $HASH{'ignore'} = {}; $HASH{'patch'} = {}; $HASH{'define'} = {};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -