2
0

test1022.pl 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2020, 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.haxx.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. ###########################################################################
  23. # Determine if curl-config --version matches the curl --version
  24. if ( $#ARGV != 2 )
  25. {
  26. print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n";
  27. exit 3;
  28. }
  29. my $what=$ARGV[2];
  30. # Read the output of curl --version
  31. open(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n";
  32. $_ = <CURL>;
  33. chomp;
  34. /libcurl\/([\.\d]+((-DEV)|(-\d+))?)/;
  35. my $version = $1;
  36. close CURL;
  37. my $curlconfigversion;
  38. # Read the output of curl-config --version/--vernum
  39. open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what list\n";
  40. $_ = <CURLCONFIG>;
  41. chomp;
  42. my $filever=$_;
  43. if ( $what eq "version" ) {
  44. if($filever =~ /^libcurl ([\.\d]+((-DEV)|(-\d+))?)$/) {
  45. $curlconfigversion = $1;
  46. }
  47. else {
  48. $curlconfigversion = "illegal value";
  49. }
  50. }
  51. else { # "vernum" case
  52. # Convert hex version to decimal for comparison's sake
  53. if($filever =~ /^(..)(..)(..)$/) {
  54. $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3);
  55. }
  56. else {
  57. $curlconfigversion = "illegal value";
  58. }
  59. # Strip off the -DEV from the curl version if it's there
  60. $version =~ s/-\w*$//;
  61. }
  62. close CURLCONFIG;
  63. my $different = $version ne $curlconfigversion;
  64. if ($different || !$version) {
  65. print "Mismatch in --version:\n";
  66. print "curl: $version\n";
  67. print "curl-config: $curlconfigversion\n";
  68. exit 1;
  69. }