Blame util/mkbuildinf.pl

Packit c4476c
#! /usr/bin/env perl
Packit c4476c
# Copyright 2014-2017 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
#
Packit c4476c
# Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
# this file except in compliance with the License.  You can obtain a copy
Packit c4476c
# in the file LICENSE in the source distribution or at
Packit c4476c
# https://www.openssl.org/source/license.html
Packit c4476c
Packit c4476c
use strict;
Packit c4476c
use warnings;
Packit c4476c
Packit c4476c
my ($cflags, $platform) = @ARGV;
Packit c4476c
$cflags = "compiler: $cflags";
Packit c4476c
Packit c4476c
my $date = gmtime($ENV{'SOURCE_DATE_EPOCH'} || time()) . " UTC";
Packit c4476c
Packit c4476c
print <<"END_OUTPUT";
Packit c4476c
/*
Packit c4476c
 * WARNING: do not edit!
Packit c4476c
 * Generated by util/mkbuildinf.pl
Packit c4476c
 *
Packit c4476c
 * Copyright 2014-2017 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
 *
Packit c4476c
 * Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
 * this file except in compliance with the License.  You can obtain a copy
Packit c4476c
 * in the file LICENSE in the source distribution or at
Packit c4476c
 * https://www.openssl.org/source/license.html
Packit c4476c
 */
Packit c4476c
Packit c4476c
#define PLATFORM "platform: $platform"
Packit c4476c
#define DATE "built on: $date"
Packit c4476c
Packit c4476c
/*
Packit c4476c
 * Generate compiler_flags as an array of individual characters. This is a
Packit c4476c
 * workaround for the situation where CFLAGS gets too long for a C90 string
Packit c4476c
 * literal
Packit c4476c
 */
Packit c4476c
static const char compiler_flags[] = {
Packit c4476c
END_OUTPUT
Packit c4476c
Packit c4476c
my $ctr = 0;
Packit c4476c
foreach my $c (split //, $cflags) {
Packit c4476c
    $c =~ s|([\\'])|\\$1|;
Packit c4476c
    # Max 16 characters per line
Packit c4476c
    if  (($ctr++ % 16) == 0) {
Packit c4476c
        if ($ctr != 1) {
Packit c4476c
            print "\n";
Packit c4476c
        }
Packit c4476c
        print "    ";
Packit c4476c
    }
Packit c4476c
    print "'$c',";
Packit c4476c
}
Packit c4476c
print <<"END_OUTPUT";
Packit c4476c
'\\0'
Packit c4476c
};
Packit c4476c
END_OUTPUT