• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env perl
2#***************************************************************************
3#                                  _   _ ____  _
4#  Project                     ___| | | |  _ \| |
5#                             / __| | | | |_) | |
6#                            | (__| |_| |  _ <| |___
7#                             \___|\___/|_| \_\_____|
8#
9# Copyright (C) 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.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# SPDX-License-Identifier: curl
23#
24###########################################################################
25
26my $autotools = $ARGV[0];
27my $cmake = $ARGV[1];
28
29if(!$cmake) {
30    print "Usage: cmp-config <config1> <config2.h>\n";
31    exit;
32}
33
34# this lists complete lines that will be removed from the output if
35# matching
36my %remove = (
37    '#define CURL_EXTERN_SYMBOL' => 1,
38    '#define CURL_OS "Linux"' => 1,
39    '#define CURL_OS "x86_64-pc-linux-gnu"' => 1,
40    '#define GETHOSTNAME_TYPE_ARG2 int' => 1,
41    '#define GETHOSTNAME_TYPE_ARG2 size_t' => 1,
42    '#define HAVE_BROTLI 1' => 1,
43    '#define HAVE_BROTLI_DECODE_H 1' => 1,
44    '#define HAVE_DLFCN_H 1' => 1,
45    '#define HAVE_GSSAPI_GSSAPI_KRB5_H 1' => 1,
46    '#define HAVE_INTTYPES_H 1' => 1,
47    '#define HAVE_LDAP_H 1' => 1,
48    '#define HAVE_LDAP_SSL 1' => 1,
49    '#define HAVE_LIBBROTLIDEC 1' => 1,
50    '#define HAVE_LIBPSL_H 1' => 1,
51    '#define HAVE_LIBRTMP_RTMP_H 1' => 1,
52    '#define HAVE_LIBSOCKET 1' => 1,
53    '#define HAVE_LIBSSH' => 1,
54    '#define HAVE_LIBSSH2 1' => 1,
55    '#define HAVE_LIBSSL 1' => 1,
56    '#define HAVE_LIBWOLFSSH' => 1,
57    '#define HAVE_LIBZSTD 1' => 1,
58    '#define HAVE_MSH3_H 1' => 1,
59    '#define HAVE_NGHTTP2_NGHTTP2_H 1' => 1,
60    '#define HAVE_NGHTTP3_NGHTTP3_H 1' => 1,
61    '#define HAVE_NGTCP2_NGTCP2_CRYPTO_H 1' => 1,
62    '#define HAVE_NGTCP2_NGTCP2_H 1' => 1,
63    '#define HAVE_OPENSSL_CRYPTO_H 1' => 1,
64    '#define HAVE_OPENSSL_ERR_H 1' => 1,
65    '#define HAVE_OPENSSL_PEM_H 1' => 1,
66    '#define HAVE_OPENSSL_RSA_H 1' => 1,
67    '#define HAVE_OPENSSL_SSL_H 1' => 1,
68    '#define HAVE_OPENSSL_X509_H 1' => 1,
69    '#define HAVE_QUICHE_H 1' => 1,
70    '#define HAVE_SSL_SET_QUIC_USE_LEGACY_CODEPOINT 1' => 1,
71    '#define HAVE_STDINT_H 1' => 1,
72    '#define HAVE_STDIO_H 1' => 1,
73    '#define HAVE_STDLIB_H 1' => 1,
74    '#define HAVE_STRING_H 1' => 1,
75    '#define HAVE_SYS_XATTR_H 1' => 1,
76    '#define HAVE_UNICODE_UIDNA_H 1' => 1,
77    '#define HAVE_WOLFSSH_SSH_H 1' => 1,
78    '#define HAVE_ZSTD 1' => 1,
79    '#define HAVE_ZSTD_H 1' => 1,
80    '#define LT_OBJDIR ".libs/"' => 1,
81    '#define NEED_LBER_H 1' => 1,
82    '#define PACKAGE "curl"' => 1,
83    '#define PACKAGE_BUGREPORT "a suitable curl mailing list: https://curl.se/mail/"' => 1,
84    '#define PACKAGE_NAME "curl"' => 1,
85    '#define PACKAGE_STRING "curl -"' => 1,
86    '#define PACKAGE_TARNAME "curl"' => 1,
87    '#define PACKAGE_URL ""' => 1,
88    '#define PACKAGE_VERSION "-"' => 1,
89    '#define SIZEOF_LONG_LONG 8' => 1,
90    '#define VERSION "-"' => 1,
91    '#define _FILE_OFFSET_BITS 64' => 1,
92    );
93
94sub filter {
95    my ($line) = @_;
96    if(!$remove{$line}) {
97        return "$line\n";
98    }
99    $remove{$line}++;
100    return "";
101}
102
103sub grepit {
104    my ($input, $output) = @_;
105    my @defines;
106    # first get all the #define lines
107    open(F, "<$input");
108    while(<F>) {
109        if($_ =~ /^#def/) {
110            chomp;
111            push @defines, $_;
112        }
113    }
114    close(F);
115
116    open(O, ">$output");
117
118    # output the sorted list through the filter
119    foreach my $d(sort @defines) {
120        print O filter($d);
121    }
122    close(O);
123}
124
125grepit($autotools, "/tmp/autotools");
126grepit($cmake, "/tmp/cmake");
127
128foreach my $v (keys %remove) {
129    if($remove{$v} == 1) {
130        print "Ignored, never matched line: $v\n";
131    }
132}
133
134
135# return the exit code from diff
136exit system("diff -u /tmp/autotools /tmp/cmake") >> 8;
137