mkbuildinf.pl 1.6 KB

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