<commit_before>#!/usr/bin/perl -w

require 5.006;

use strict;

use Config;
use Getopt::Long;
use File::Spec;
use File::Copy;
use File::Find;
use Sys::Hostname;

my $MAJOR_VERSION = 1;
my $MINOR_VERSION = 7;
my $PATCH_VERSION = 20;

my $VERSION_STRING = "$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION";

##################################################
# Data                                           #
##################################################
my (%CPU, %OPERATING_SYSTEM, %COMPILER, %MODULES);

my @DOCS = (
   'api.pdf', 'tutorial.pdf', 'fips140.pdf',
   'api.tex', 'tutorial.tex', 'fips140.tex',
   'credits.txt', 'info.txt', 'license.txt', 'log.txt',
   'thanks.txt', 'todo.txt', 'pgpkeys.asc');

my $TRACING = 0;

##################################################
# Run main() and Quit                            #
##################################################
my $config = {};

main();
exit;

sub exec_uname {
    # Only exec it if we think it might actually work
    if(-f '/bin/uname' || -f '/usr/bin/uname' || -f '/bin/sh') {
        my $uname = `uname -a`;
        if($uname) {
            chomp $uname;
            return $uname;
        }
    }

    return '';
}

##################################################
# Main Driver                                    #
##################################################
sub main {
    my $base_dir = where_am_i();

    $$config{'uname'} = exec_uname();

    $$config{'base-dir'} = $base_dir;
    $$config{'src-dir'} = File::Spec->catdir($base_dir, 'src');
    $$config{'checks-dir'} = File::Spec->catdir($base_dir, 'checks');
    $$config{'doc-dir'} = File::Spec->catdir($base_dir, 'doc');

    $$config{'config-dir'} =
        File::Spec->catdir($$config{'src-dir'}, 'build-data');

    $$config{'command-line'} = $0 . ' ' . join(' ', @ARGV);
    $$config{'timestamp'} = gmtime;
    $$config{'user'} = getlogin || getpwuid($<) || '';
    $$config{'hostname'} = hostname;

    %CPU = read_info_files($config, 'arch', \&get_arch_info);
    %OPERATING_SYSTEM = read_info_files($config, 'os', \&get_os_info);
    %COMPILER = read_info_files($config, 'cc', \&get_cc_info);
    %MODULES = read_module_files($config);

    add_to($config, {
        'version_major' => $MAJOR_VERSION,
        'version_minor' => $MINOR_VERSION,
        'version_patch' => $PATCH_VERSION,
        'version'       => $VERSION_STRING,
        });

    get_options($config);

    my $default_value_is = sub {
        my ($var, $val) = @_;
        $$config{$var} = $val if not defined($$config{$var});
    };

    &$default_value_is('gcc_bug', 0);
    &$default_value_is('autoconfig', 1);
    &$default_value_is('debug', 0);
    &$default_value_is('shared', 'yes');
    &$default_value_is('local_config', '');

    my $major_minor = $MAJOR_VERSION . $MINOR_VERSION;

    # Goes into build-specific dirs (maybe)

    $$config{'build-dir'} = 'build';
    $$config{'botan-config'} = File::Spec->catfile(
        $$config{'build-dir'}, "botan-$major_minor-config");

    $$config{'botan-pkgconfig'} = File::Spec->catfile(
        $$config{'build-dir'}, "botan-$major_minor.pc");

    $$config{'makefile'} = 'Makefile';
    $$config{'check_prefix'} = '';
    $$config{'lib_prefix'} = '';

    if(defined($$config{'with_build_dir'})) {
        for my $var ('build-dir',
                     'botan-config',
                     'botan-pkgconfig',
                     'makefile',
                     'check_prefix',
                     'lib_prefix')
        {
            $$config{$var} = File::Spec->catfile($$config{'with_build_dir'},
                                                 $$config{$var});
        }
    }
    else {
    }

    choose_target($config);

    my $os = $$config{'os'};
    my $cc = $$config{'compiler'};

    &$default_value_is('prefix', os_info_for($os, 'install_root'));
    &$default_value_is('libdir', os_info_for($os, 'lib_dir'));
    &$default_value_is('docdir', os_info_for($os, 'doc_dir'));
    &$default_value_is('make_style', $COMPILER{$cc}{'makefile_style'});

    scan_modules($config);<commit_msg>For pkg-config, name as botan-$major.$minor.pc, eg botan-1.7, rather than botan-17, which was potentially confusing (and apparently contradictory to normal pkg-config naming conventions).<commit_after>#!/usr/bin/perl -w

require 5.006;

use strict;

use Config;
use Getopt::Long;
use File::Spec;
use File::Copy;
use File::Find;
use Sys::Hostname;

my $MAJOR_VERSION = 1;
my $MINOR_VERSION = 7;
my $PATCH_VERSION = 20;

my $VERSION_STRING = "$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION";

##################################################
# Data                                           #
##################################################
my (%CPU, %OPERATING_SYSTEM, %COMPILER, %MODULES);

my @DOCS = (
   'api.pdf', 'tutorial.pdf', 'fips140.pdf',
   'api.tex', 'tutorial.tex', 'fips140.tex',
   'credits.txt', 'info.txt', 'license.txt', 'log.txt',
   'thanks.txt', 'todo.txt', 'pgpkeys.asc');

my $TRACING = 0;

##################################################
# Run main() and Quit                            #
##################################################
my $config = {};

main();
exit;

sub exec_uname {
    # Only exec it if we think it might actually work
    if(-f '/bin/uname' || -f '/usr/bin/uname' || -f '/bin/sh') {
        my $uname = `uname -a`;
        if($uname) {
            chomp $uname;
            return $uname;
        }
    }

    return '';
}

##################################################
# Main Driver                                    #
##################################################
sub main {
    my $base_dir = where_am_i();

    $$config{'uname'} = exec_uname();

    $$config{'base-dir'} = $base_dir;
    $$config{'src-dir'} = File::Spec->catdir($base_dir, 'src');
    $$config{'checks-dir'} = File::Spec->catdir($base_dir, 'checks');
    $$config{'doc-dir'} = File::Spec->catdir($base_dir, 'doc');

    $$config{'config-dir'} =
        File::Spec->catdir($$config{'src-dir'}, 'build-data');

    $$config{'command-line'} = $0 . ' ' . join(' ', @ARGV);
    $$config{'timestamp'} = gmtime;
    $$config{'user'} = getlogin || getpwuid($<) || '';
    $$config{'hostname'} = hostname;

    %CPU = read_info_files($config, 'arch', \&get_arch_info);
    %OPERATING_SYSTEM = read_info_files($config, 'os', \&get_os_info);
    %COMPILER = read_info_files($config, 'cc', \&get_cc_info);
    %MODULES = read_module_files($config);

    add_to($config, {
        'version_major' => $MAJOR_VERSION,
        'version_minor' => $MINOR_VERSION,
        'version_patch' => $PATCH_VERSION,
        'version'       => $VERSION_STRING,
        });

    get_options($config);

    my $default_value_is = sub {
        my ($var, $val) = @_;
        $$config{$var} = $val if not defined($$config{$var});
    };

    &$default_value_is('gcc_bug', 0);
    &$default_value_is('autoconfig', 1);
    &$default_value_is('debug', 0);
    &$default_value_is('shared', 'yes');
    &$default_value_is('local_config', '');

    # Goes into build-specific dirs (maybe)

    $$config{'build-dir'} = 'build';
    $$config{'botan-config'} = File::Spec->catfile(
        $$config{'build-dir'},
        'botan-' . $MAJOR_VERSION . $MINOR_VERSION . '-config');

    $$config{'botan-pkgconfig'} = File::Spec->catfile(
        $$config{'build-dir'},
        'botan-' . $MAJOR_VERSION . '.' . $MINOR_VERSION . '.pc');

    $$config{'makefile'} = 'Makefile';
    $$config{'check_prefix'} = '';
    $$config{'lib_prefix'} = '';

    if(defined($$config{'with_build_dir'})) {
        for my $var ('build-dir',
                     'botan-config',
                     'botan-pkgconfig',
                     'makefile',
                     'check_prefix',
                     'lib_prefix')
        {
            $$config{$var} = File::Spec->catfile($$config{'with_build_dir'},
                                                 $$config{$var});
        }
    }
    else {
    }

    choose_target($config);

    my $os = $$config{'os'};
    my $cc = $$config{'compiler'};

    &$default_value_is('prefix', os_info_for($os, 'install_root'));
    &$default_value_is('libdir', os_info_for($os, 'lib_dir'));
    &$default_value_is('docdir', os_info_for($os, 'doc_dir'));
    &$default_value_is('make_style', $COMPILER{$cc}{'makefile_style'});

    scan_modules($config);
{'fraction_non_alphanumeric': 0.2534115393823318, 'fraction_numerical': 0.005027531721331099, 'mean_word_length': 2.906030855539972, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1815993', 'n_tokens_mistral': 2835, 'n_tokens_neox': 2711, 'n_words': 470}