blob: 377808c7347d54ef3f840da158e4a2239ea329fe [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#!/usr/bin/env perl
2# Determine if curl-config --version matches the curl --version
3if ( $#ARGV != 2 )
4{
5 print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n";
6 exit 3;
7}
8
9my $what=$ARGV[2];
10
11# Read the output of curl --version
12open(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n";
13$_ = <CURL>;
14chomp;
15/libcurl\/([\.\d]+((-DEV)|(-\d+))?)/;
16my $version = $1;
17close CURL;
18
19my $curlconfigversion;
20
21# Read the output of curl-config --version/--vernum
22open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what list\n";
23$_ = <CURLCONFIG>;
24chomp;
25my $filever=$_;
26if ( $what eq "version" ) {
27 if($filever =~ /^libcurl ([\.\d]+((-DEV)|(-\d+))?)$/) {
28 $curlconfigversion = $1;
29 }
30 else {
31 $curlconfigversion = "illegal value";
32 }
33}
34else { # "vernum" case
35 # Convert hex version to decimal for comparison's sake
36 if($filever =~ /^(..)(..)(..)$/) {
37 $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3);
38 }
39 else {
40 $curlconfigversion = "illegal value";
41 }
42
43 # Strip off the -DEV from the curl version if it's there
44 $version =~ s/-\w*$//;
45}
46close CURLCONFIG;
47
48my $different = $version ne $curlconfigversion;
49if ($different || !$version) {
50 print "Mismatch in --version:\n";
51 print "curl: $version\n";
52 print "curl-config: $curlconfigversion\n";
53 exit 1;
54}