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