1#!/usr/bin/env perl 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) 2010-2019, 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# 24 25use strict; 26use warnings; 27 28# the DISABLE options that can be set by configure 29my %disable; 30# the DISABLE options that are used in C files 31my %file; 32 33# we may get the dir root pointed out 34my $root=$ARGV[0] || "."; 35 36sub scan_configure { 37 open S, "<$root/configure.ac"; 38 while(<S>) { 39 if(/(CURL_DISABLE_[A-Z_]+)/g) { 40 my ($sym)=($1); 41 $disable{$sym} = 1; 42 } 43 } 44 close S; 45} 46 47sub scan_file { 48 my ($source)=@_; 49 open F, "<$source"; 50 while(<F>) { 51 if(/(CURL_DISABLE_[A-Z_]+)/g) { 52 my ($sym)=($1); 53 $file{$sym} = $source; 54 } 55 } 56 close F; 57} 58 59sub scan_dir { 60 my ($dir)=@_; 61 opendir(my $dh, $dir) || die "Can't opendir $dir: $!"; 62 my @cfiles = grep { /\.c\z/ && -f "$dir/$_" } readdir($dh); 63 closedir $dh; 64 for my $f (sort @cfiles) { 65 scan_file("$dir/$f"); 66 } 67} 68 69sub scan_sources { 70 scan_dir("$root/src"); 71 scan_dir("$root/lib"); 72 scan_dir("$root/lib/vtls"); 73 scan_dir("$root/lib/vauth"); 74} 75 76scan_configure(); 77scan_sources(); 78 79 80my $error = 0; 81# Check the configure symbols for use in code 82for my $s (sort keys %disable) { 83 if(!$file{$s}) { 84 printf "Present in configure.ac, not used by code: %s\n", $s; 85 $error++; 86 } 87} 88 89# Check the code symbols for use in configure 90for my $s (sort keys %file) { 91 if(!$disable{$s}) { 92 printf "Not set by configure: %s (%s)\n", $s, $file{$s}; 93 $error++; 94 } 95} 96 97exit $error; 98