Home | History | Annotate | Line # | Download | only in util
      1  1.1.1.2  christos #! /usr/bin/env perl
      2  1.1.1.2  christos # Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
      3      1.1  christos #
      4  1.1.1.2  christos # Licensed under the OpenSSL license (the "License").  You may not use
      5  1.1.1.2  christos # this file except in compliance with the License.  You can obtain a copy
      6  1.1.1.2  christos # in the file LICENSE in the source distribution or at
      7  1.1.1.2  christos # https://www.openssl.org/source/license.html
      8  1.1.1.2  christos 
      9  1.1.1.2  christos use strict;
     10  1.1.1.2  christos use warnings;
     11  1.1.1.2  christos use lib ".";
     12  1.1.1.2  christos use configdata;
     13  1.1.1.2  christos use File::Spec::Functions;
     14  1.1.1.2  christos 
     15  1.1.1.2  christos my $versionfile = catfile( $config{sourcedir}, "include/openssl/opensslv.h" );
     16  1.1.1.2  christos 
     17  1.1.1.2  christos my ( $ver, $v1, $v2, $v3, $v4, $beta, $version );
     18  1.1.1.2  christos 
     19  1.1.1.2  christos open FD, $versionfile or die "Couldn't open include/openssl/opensslv.h: $!\n";
     20  1.1.1.2  christos while (<FD>) {
     21      1.1  christos     if (/OPENSSL_VERSION_NUMBER\s+(0x[0-9a-f]+)/i) {
     22  1.1.1.2  christos         $ver     = hex($1);
     23  1.1.1.2  christos         $v1      = ( $ver >> 28 );
     24  1.1.1.2  christos         $v2      = ( $ver >> 20 ) & 0xff;
     25  1.1.1.2  christos         $v3      = ( $ver >> 12 ) & 0xff;
     26  1.1.1.2  christos         $v4      = ( $ver >>  4 ) & 0xff;
     27  1.1.1.2  christos         $beta    = $ver & 0xf;
     28  1.1.1.2  christos         $version = "$v1.$v2.$v3";
     29  1.1.1.2  christos         if ( $beta == 0xf ) {
     30  1.1.1.2  christos             $version .= chr( ord('a') + $v4 - 1 ) if ($v4);
     31  1.1.1.2  christos         } elsif ( $beta == 0 ) {
     32  1.1.1.2  christos             $version .= "-dev";
     33  1.1.1.2  christos         } else {
     34  1.1.1.2  christos             $version .= "-beta$beta";
     35  1.1.1.2  christos         }
     36  1.1.1.2  christos         last;
     37      1.1  christos     }
     38      1.1  christos }
     39      1.1  christos close(FD);
     40      1.1  christos 
     41  1.1.1.2  christos my $filename = $ARGV[0];
     42  1.1.1.2  christos my $description = "OpenSSL library";
     43  1.1.1.2  christos my $vft = "VFT_DLL";
     44  1.1.1.2  christos if ( $filename =~ /openssl/i ) {
     45  1.1.1.2  christos     $description = "OpenSSL application";
     46  1.1.1.2  christos     $vft = "VFT_APP";
     47  1.1.1.2  christos }
     48      1.1  christos 
     49  1.1.1.2  christos my $YEAR = [gmtime($ENV{SOURCE_DATE_EPOCH} || time())]->[5] + 1900;
     50      1.1  christos print <<___;
     51      1.1  christos #include <winver.h>
     52      1.1  christos 
     53      1.1  christos LANGUAGE 0x09,0x01
     54      1.1  christos 
     55      1.1  christos 1 VERSIONINFO
     56      1.1  christos   FILEVERSION $v1,$v2,$v3,$v4
     57      1.1  christos   PRODUCTVERSION $v1,$v2,$v3,$v4
     58      1.1  christos   FILEFLAGSMASK 0x3fL
     59      1.1  christos #ifdef _DEBUG
     60      1.1  christos   FILEFLAGS 0x01L
     61      1.1  christos #else
     62      1.1  christos   FILEFLAGS 0x00L
     63      1.1  christos #endif
     64      1.1  christos   FILEOS VOS__WINDOWS32
     65  1.1.1.2  christos   FILETYPE $vft
     66      1.1  christos   FILESUBTYPE 0x0L
     67      1.1  christos BEGIN
     68      1.1  christos     BLOCK "StringFileInfo"
     69      1.1  christos     BEGIN
     70      1.1  christos         BLOCK "040904b0"
     71      1.1  christos         BEGIN
     72      1.1  christos             // Required:
     73  1.1.1.2  christos             VALUE "CompanyName", "The OpenSSL Project, https://www.openssl.org/\\0"
     74      1.1  christos             VALUE "FileDescription", "$description\\0"
     75      1.1  christos             VALUE "FileVersion", "$version\\0"
     76  1.1.1.2  christos             VALUE "InternalName", "$filename\\0"
     77      1.1  christos             VALUE "OriginalFilename", "$filename\\0"
     78      1.1  christos             VALUE "ProductName", "The OpenSSL Toolkit\\0"
     79      1.1  christos             VALUE "ProductVersion", "$version\\0"
     80      1.1  christos             // Optional:
     81      1.1  christos             //VALUE "Comments", "\\0"
     82  1.1.1.2  christos             VALUE "LegalCopyright", "Copyright 1998-$YEAR The OpenSSL Authors. All rights reserved.\\0"
     83      1.1  christos             //VALUE "LegalTrademarks", "\\0"
     84      1.1  christos             //VALUE "PrivateBuild", "\\0"
     85      1.1  christos             //VALUE "SpecialBuild", "\\0"
     86      1.1  christos         END
     87      1.1  christos     END
     88      1.1  christos     BLOCK "VarFileInfo"
     89      1.1  christos     BEGIN
     90      1.1  christos         VALUE "Translation", 0x409, 0x4b0
     91      1.1  christos     END
     92      1.1  christos END
     93      1.1  christos ___
     94