1#!/usr/bin/env perl
2# Determine if curl-config --protocols/--features matches the
3# curl --version protocols/features
4if ( $#ARGV != 2 )
5{
6    print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n";
7    exit 3;
8}
9
10my $what=$ARGV[2];
11
12# Read the output of curl --version
13my $curl_protocols="";
14open(CURL, "$ARGV[1]") || die "Can't get curl $what list\n";
15while( <CURL> )
16{
17    $curl_protocols = lc($_) if ( /$what:/i );
18}
19close CURL;
20
21$curl_protocols =~ /\w+: (.*)$/;
22@curl = split / /,$1;
23
24# These features are not supported by curl-config
25@curl = grep(!/^(Debug|TrackMemory|Largefile|CharConv|GSS-Negotiate|SPNEGO)$/i, @curl);
26@curl = sort @curl;
27
28# Read the output of curl-config
29my @curl_config;
30open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config $what list\n";
31while( <CURLCONFIG> )
32{
33    chomp;
34    push @curl_config, lc($_);
35}
36close CURLCONFIG;
37
38@curl_config = sort @curl_config;
39
40my $curlproto = join ' ', @curl;
41my $curlconfigproto = join ' ', @curl_config;
42
43my $different = $curlproto ne $curlconfigproto;
44if ($different) {
45    print "Mismatch in $what lists:\n";
46    print "curl:        $curlproto\n";
47    print "curl-config: $curlconfigproto\n";
48}
49exit $different;
50