113498266Sopenharmony_ci#!/usr/bin/env perl 213498266Sopenharmony_ci#*************************************************************************** 313498266Sopenharmony_ci# _ _ ____ _ 413498266Sopenharmony_ci# Project ___| | | | _ \| | 513498266Sopenharmony_ci# / __| | | | |_) | | 613498266Sopenharmony_ci# | (__| |_| | _ <| |___ 713498266Sopenharmony_ci# \___|\___/|_| \_\_____| 813498266Sopenharmony_ci# 913498266Sopenharmony_ci# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 1013498266Sopenharmony_ci# 1113498266Sopenharmony_ci# This software is licensed as described in the file COPYING, which 1213498266Sopenharmony_ci# you should have received as part of this distribution. The terms 1313498266Sopenharmony_ci# are also available at https://curl.se/docs/copyright.html. 1413498266Sopenharmony_ci# 1513498266Sopenharmony_ci# You may opt to use, copy, modify, merge, publish, distribute and/or sell 1613498266Sopenharmony_ci# copies of the Software, and permit persons to whom the Software is 1713498266Sopenharmony_ci# furnished to do so, under the terms of the COPYING file. 1813498266Sopenharmony_ci# 1913498266Sopenharmony_ci# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 2013498266Sopenharmony_ci# KIND, either express or implied. 2113498266Sopenharmony_ci# 2213498266Sopenharmony_ci# SPDX-License-Identifier: curl 2313498266Sopenharmony_ci# 2413498266Sopenharmony_ci########################################################################### 2513498266Sopenharmony_ci# Determine if curl-config --version matches the curl --version 2613498266Sopenharmony_ciif ( $#ARGV != 2 ) 2713498266Sopenharmony_ci{ 2813498266Sopenharmony_ci print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n"; 2913498266Sopenharmony_ci exit 3; 3013498266Sopenharmony_ci} 3113498266Sopenharmony_ci 3213498266Sopenharmony_cimy $what=$ARGV[2]; 3313498266Sopenharmony_ci 3413498266Sopenharmony_ci# Read the output of curl --version 3513498266Sopenharmony_ciopen(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n"; 3613498266Sopenharmony_ci$_ = <CURL>; 3713498266Sopenharmony_cichomp; 3813498266Sopenharmony_ci/libcurl\/([\.\d]+((-DEV)|(-\d+))?)/; 3913498266Sopenharmony_cimy $version = $1; 4013498266Sopenharmony_ciclose CURL; 4113498266Sopenharmony_ci 4213498266Sopenharmony_cimy $curlconfigversion; 4313498266Sopenharmony_ci 4413498266Sopenharmony_ci# Read the output of curl-config --version/--vernum 4513498266Sopenharmony_ciopen(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what list\n"; 4613498266Sopenharmony_ci$_ = <CURLCONFIG>; 4713498266Sopenharmony_cichomp; 4813498266Sopenharmony_cimy $filever=$_; 4913498266Sopenharmony_ciif ( $what eq "version" ) { 5013498266Sopenharmony_ci if($filever =~ /^libcurl ([\.\d]+((-DEV)|(-\d+))?)$/) { 5113498266Sopenharmony_ci $curlconfigversion = $1; 5213498266Sopenharmony_ci } 5313498266Sopenharmony_ci else { 5413498266Sopenharmony_ci $curlconfigversion = "illegal value"; 5513498266Sopenharmony_ci } 5613498266Sopenharmony_ci} 5713498266Sopenharmony_cielse { # "vernum" case 5813498266Sopenharmony_ci # Convert hex version to decimal for comparison's sake 5913498266Sopenharmony_ci if($filever =~ /^(..)(..)(..)$/) { 6013498266Sopenharmony_ci $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); 6113498266Sopenharmony_ci } 6213498266Sopenharmony_ci else { 6313498266Sopenharmony_ci $curlconfigversion = "illegal value"; 6413498266Sopenharmony_ci } 6513498266Sopenharmony_ci 6613498266Sopenharmony_ci # Strip off the -DEV from the curl version if it's there 6713498266Sopenharmony_ci $version =~ s/-\w*$//; 6813498266Sopenharmony_ci} 6913498266Sopenharmony_ciclose CURLCONFIG; 7013498266Sopenharmony_ci 7113498266Sopenharmony_cimy $different = $version ne $curlconfigversion; 7213498266Sopenharmony_ciif ($different || !$version) { 7313498266Sopenharmony_ci print "Mismatch in --version:\n"; 7413498266Sopenharmony_ci print "curl: $version\n"; 7513498266Sopenharmony_ci print "curl-config: $curlconfigversion\n"; 7613498266Sopenharmony_ci exit 1; 7713498266Sopenharmony_ci} 78