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