mkrc.pl 2.6 KB
Newer Older
R
Rich Salz 已提交
1
#! /usr/bin/env perl
H
HJ 已提交
2
# Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
3
#
R
Rich Salz 已提交
4 5 6 7
# Licensed under the OpenSSL license (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
8

9 10
use strict;
use warnings;
11 12 13 14
use lib ".";
use configdata;
use File::Spec::Functions;

15 16 17
my $versionfile = catfile( $config{sourcedir}, "include/openssl/opensslv.h" );

my ( $ver, $v1, $v2, $v3, $v4, $beta, $version );
18 19

open FD, $versionfile or die "Couldn't open include/openssl/opensslv.h: $!\n";
20
while (<FD>) {
21
    if (/OPENSSL_VERSION_NUMBER\s+(0x[0-9a-f]+)/i) {
22 23 24 25
        $ver     = hex($1);
        $v1      = ( $ver >> 28 );
        $v2      = ( $ver >> 20 ) & 0xff;
        $v3      = ( $ver >> 12 ) & 0xff;
R
Rich Salz 已提交
26
        $v4      = ( $ver >>  4 ) & 0xff;
27 28
        $beta    = $ver & 0xf;
        $version = "$v1.$v2.$v3";
R
Rich Salz 已提交
29 30 31 32 33 34 35
        if ( $beta == 0xf ) {
            $version .= chr( ord('a') + $v4 - 1 ) if ($v4);
        } elsif ( $beta == 0 ) {
            $version .= "-dev";
        } else {
            $version .= "-beta$beta";
        }
36
        last;
37 38 39 40
    }
}
close(FD);

41
my $filename = $ARGV[0];
R
Rich Salz 已提交
42 43 44 45 46 47
my $description = "OpenSSL library";
my $vft = "VFT_DLL";
if ( $filename =~ /openssl/i ) {
    $description = "OpenSSL application";
    $vft = "VFT_APP";
}
48

H
HJ 已提交
49
my $YEAR = [gmtime($ENV{SOURCE_DATE_EPOCH} || time())]->[5] + 1900;
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
print <<___;
#include <winver.h>

LANGUAGE 0x09,0x01

1 VERSIONINFO
  FILEVERSION $v1,$v2,$v3,$v4
  PRODUCTVERSION $v1,$v2,$v3,$v4
  FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
  FILEFLAGS 0x01L
#else
  FILEFLAGS 0x00L
#endif
  FILEOS VOS__WINDOWS32
R
Rich Salz 已提交
65
  FILETYPE $vft
66 67 68 69 70 71 72
  FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            // Required:
V
Viktor Szakats 已提交
73
            VALUE "CompanyName", "The OpenSSL Project, https://www.openssl.org/\\0"
74 75
            VALUE "FileDescription", "$description\\0"
            VALUE "FileVersion", "$version\\0"
R
Rich Salz 已提交
76
            VALUE "InternalName", "$filename\\0"
77 78 79 80 81
            VALUE "OriginalFilename", "$filename\\0"
            VALUE "ProductName", "The OpenSSL Toolkit\\0"
            VALUE "ProductVersion", "$version\\0"
            // Optional:
            //VALUE "Comments", "\\0"
R
Rich Salz 已提交
82
            VALUE "LegalCopyright", "Copyright 1998-$YEAR The OpenSSL Authors. All rights reserved.\\0"
83 84 85 86 87 88 89 90 91 92 93
            //VALUE "LegalTrademarks", "\\0"
            //VALUE "PrivateBuild", "\\0"
            //VALUE "SpecialBuild", "\\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 0x4b0
    END
END
___