mkbuildinf.pl 1.5 KB

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