2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
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 http://curl.haxx.se/docs/copyright.html.
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.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 ###########################################################################
24 # Experience has shown that the symbols-in-versions file is very useful to
25 # applications that want to build with a wide range of libcurl versions.
26 # It is however easy to get it wrong and the source gets a bit messy with all
27 # the fixed numerical comparisions.
29 # The point of this script is to provide an easy-to-use macro for libcurl-
30 # using applications to do preprocessor checks for specific libcurl defines,
31 # and yet make the code clearly show what the macro is used for.
33 # Run this script and generate libcurl-symbols.h and then use that header in
34 # a fashion similar to:
36 # #include "libcurl-symbols.h"
38 # #if LIBCURL_HAS(CURLOPT_MUTE)
45 open F, "<symbols-in-versions";
49 if($str =~ /([0-9]*)\.([0-9]*)\.*([0-9]*)/) {
50 return sprintf("0x%06x", $1<<16 | $2 << 8 | $3);
56 #include <curl/curl.h>
58 #define LIBCURL_HAS(x) \\
59 (defined(x ## _FIRST) && (x ## _FIRST <= LIBCURL_VERSION_NUM) && \\
60 (!defined(x ## _LAST) || ( x ## _LAST >= LIBCURL_VERSION_NUM)))
66 if(/^(CURL[^ ]*)[ \t]*(.*)/) {
67 my ($sym, $vers)=($1, $2);
73 # is there removed info?
74 if($vers =~ /([\d.]+)[ \t-]+([\d.]+)[ \t]+([\d.]+)/) {
75 ($intr, $dep, $rm)=($1, $2, $3);
77 # is it a dep-only line?
78 elsif($vers =~ /([\d.]+)[ \t-]+([\d.]+)/) {
79 ($intr, $dep)=($1, $2);
85 my $inum = str2num($intr);
88 #define ${sym}_FIRST $inum /* Added in $intr */
91 my $irm = str2num($rm);
94 #define ${sym}_LAST $irm /* Last featured in $rm */