xref: /freebsd-src/crypto/openssl/util/mkbuildinf.pl (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert#! /usr/bin/env perl
2*e0c4386eSCy Schubert# Copyright 2014-2017 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert#
4*e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubert
9*e0c4386eSCy Schubertuse strict;
10*e0c4386eSCy Schubertuse warnings;
11*e0c4386eSCy Schubert
12*e0c4386eSCy Schubertmy ($cflags, $platform) = @ARGV;
13*e0c4386eSCy Schubert$cflags = "compiler: $cflags";
14*e0c4386eSCy Schubert
15*e0c4386eSCy Schubertmy $date = gmtime($ENV{'SOURCE_DATE_EPOCH'} || time()) . " UTC";
16*e0c4386eSCy Schubert
17*e0c4386eSCy Schubertprint <<"END_OUTPUT";
18*e0c4386eSCy Schubert/*
19*e0c4386eSCy Schubert * WARNING: do not edit!
20*e0c4386eSCy Schubert * Generated by util/mkbuildinf.pl
21*e0c4386eSCy Schubert *
22*e0c4386eSCy Schubert * Copyright 2014-2017 The OpenSSL Project Authors. All Rights Reserved.
23*e0c4386eSCy Schubert *
24*e0c4386eSCy Schubert * Licensed under the Apache License 2.0 (the "License").  You may not use
25*e0c4386eSCy Schubert * this file except in compliance with the License.  You can obtain a copy
26*e0c4386eSCy Schubert * in the file LICENSE in the source distribution or at
27*e0c4386eSCy Schubert * https://www.openssl.org/source/license.html
28*e0c4386eSCy Schubert */
29*e0c4386eSCy Schubert
30*e0c4386eSCy Schubert#define PLATFORM "platform: $platform"
31*e0c4386eSCy Schubert#define DATE "built on: $date"
32*e0c4386eSCy Schubert
33*e0c4386eSCy Schubert/*
34*e0c4386eSCy Schubert * Generate compiler_flags as an array of individual characters. This is a
35*e0c4386eSCy Schubert * workaround for the situation where CFLAGS gets too long for a C90 string
36*e0c4386eSCy Schubert * literal
37*e0c4386eSCy Schubert */
38*e0c4386eSCy Schubertstatic const char compiler_flags[] = {
39*e0c4386eSCy SchubertEND_OUTPUT
40*e0c4386eSCy Schubert
41*e0c4386eSCy Schubertmy $ctr = 0;
42*e0c4386eSCy Schubertforeach my $c (split //, $cflags) {
43*e0c4386eSCy Schubert    $c =~ s|([\\'])|\\$1|;
44*e0c4386eSCy Schubert    # Max 16 characters per line
45*e0c4386eSCy Schubert    if  (($ctr++ % 16) == 0) {
46*e0c4386eSCy Schubert        if ($ctr != 1) {
47*e0c4386eSCy Schubert            print "\n";
48*e0c4386eSCy Schubert        }
49*e0c4386eSCy Schubert        print "    ";
50*e0c4386eSCy Schubert    }
51*e0c4386eSCy Schubert    print "'$c',";
52*e0c4386eSCy Schubert}
53*e0c4386eSCy Schubertprint <<"END_OUTPUT";
54*e0c4386eSCy Schubert'\\0'
55*e0c4386eSCy Schubert};
56*e0c4386eSCy SchubertEND_OUTPUT
57