cmp-config.pl 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at https://curl.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. # SPDX-License-Identifier: curl
  23. #
  24. ###########################################################################
  25. my $autotools = $ARGV[0];
  26. my $cmake = $ARGV[1];
  27. if(!$cmake) {
  28. print "Usage: cmp-config <config1> <config2.h>\n";
  29. exit;
  30. }
  31. # this lists complete lines that will be removed from the output if
  32. # matching
  33. my %remove = (
  34. '#define _FILE_OFFSET_BITS 64' => 1,
  35. '#define CURL_EXTERN_SYMBOL' => 1,
  36. '#define CURL_SA_FAMILY_T sa_family_t' => 1,
  37. '#define GETHOSTNAME_TYPE_ARG2 size_t' => 1,
  38. '#define HAVE_BROTLI 1' => 1,
  39. '#define HAVE_BROTLI_DECODE_H 1' => 1,
  40. '#define HAVE_DECL_GETPWUID_R 1' => 1,
  41. '#define HAVE_DLFCN_H 1' => 1,
  42. '#define HAVE_GETHOSTBYNAME 1' => 1,
  43. '#define HAVE_INTTYPES_H 1' => 1,
  44. '#define HAVE_IOCTL 1' => 1,
  45. '#define HAVE_LDAP_SSL 1' => 1,
  46. '#define HAVE_LIBBROTLIDEC 1' => 1,
  47. '#define HAVE_LIBSSL 1' => 1,
  48. '#define HAVE_LIBZSTD 1' => 1,
  49. '#define HAVE_OPENSSL3 1' => 1,
  50. '#define HAVE_OPENSSL_CRYPTO_H 1' => 1,
  51. '#define HAVE_OPENSSL_ERR_H 1' => 1,
  52. '#define HAVE_OPENSSL_PEM_H 1' => 1,
  53. '#define HAVE_OPENSSL_RSA_H 1' => 1,
  54. '#define HAVE_OPENSSL_SSL_H 1' => 1,
  55. '#define HAVE_OPENSSL_X509_H 1' => 1,
  56. '#define HAVE_SA_FAMILY_T 1' => 1,
  57. '#define HAVE_SETJMP_H 1' => 1,
  58. '#define HAVE_STDINT_H 1' => 1,
  59. '#define HAVE_STDIO_H 1' => 1,
  60. '#define HAVE_STDLIB_H 1' => 1,
  61. '#define HAVE_STRING_H 1' => 1,
  62. '#define HAVE_SYS_XATTR_H 1' => 1,
  63. '#define HAVE_ZSTD 1' => 1,
  64. '#define HAVE_ZSTD_H 1' => 1,
  65. '#define LT_OBJDIR ".libs/"' => 1,
  66. '#define OS "Linux"' => 1,
  67. '#define OS "x86_64-pc-linux-gnu"' => 1,
  68. '#define PACKAGE "curl"' => 1,
  69. '#define PACKAGE_BUGREPORT "a suitable curl mailing list: https://curl.se/mail/"' => 1,
  70. '#define PACKAGE_NAME "curl"' => 1,
  71. '#define PACKAGE_STRING "curl -"' => 1,
  72. '#define PACKAGE_TARNAME "curl"' => 1,
  73. '#define PACKAGE_URL ""' => 1,
  74. '#define PACKAGE_VERSION "-"' => 1,
  75. '#define SIZEOF_LONG_LONG 8' => 1,
  76. '#define USE_MANUAL 1' => 1,
  77. '#define VERSION "-"' => 1,
  78. );
  79. sub filter {
  80. my ($line) = @_;
  81. if(!$remove{$line}) {
  82. return "$line\n";
  83. }
  84. $remove{$line}++;
  85. return "";
  86. }
  87. sub grepit {
  88. my ($input, $output) = @_;
  89. my @defines;
  90. # first get all the #define lines
  91. open(F, "<$input");
  92. while(<F>) {
  93. if($_ =~ /^#def/) {
  94. chomp;
  95. push @defines, $_;
  96. }
  97. }
  98. close(F);
  99. open(O, ">$output");
  100. # output the sorted list through the filter
  101. foreach my $d(sort @defines) {
  102. print O filter($d);
  103. }
  104. close(O);
  105. }
  106. grepit($autotools, "/tmp/autotools");
  107. grepit($cmake, "/tmp/cmake");
  108. foreach my $v (keys %remove) {
  109. if($remove{$v} == 1) {
  110. print "Ignored, never matched line: $v\n";
  111. }
  112. }
  113. # return the exit code from diff
  114. exit system("diff -u /tmp/autotools /tmp/cmake") >> 8;