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