xref: /curl/curl-config.in (revision e244d500)
1#!/bin/sh
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
26# shellcheck disable=SC2006
27
28prefix='@prefix@'
29# Used in 'libdir'
30# shellcheck disable=SC2034
31exec_prefix="@exec_prefix@"
32# shellcheck disable=SC2034
33includedir="@includedir@"
34cppflag_curl_staticlib='@LIBCURL_PC_CFLAGS@'
35
36usage()
37{
38  cat <<EOF
39Usage: curl-config [OPTION]
40
41Available values for OPTION include:
42
43  --built-shared says 'yes' if libcurl was built shared
44  --ca                  CA bundle install path
45  --cc                  compiler
46  --cflags              preprocessor and compiler flags
47  --checkfor [version]  check for (lib)curl of the specified version
48  --configure           the arguments given to configure when building curl
49  --features            newline separated list of enabled features
50  --help                display this help and exit
51  --libs                library linking information
52  --prefix              curl install prefix
53  --protocols           newline separated list of enabled protocols
54  --ssl-backends        output the SSL backends libcurl was built to support
55  --static-libs         static libcurl library linking information
56  --version             output version information
57  --vernum              output version as a hexadecimal number
58EOF
59
60  exit "$1"
61}
62
63if test "$#" -eq 0; then
64  usage 1
65fi
66
67while test "$#" -gt 0; do
68  case "$1" in
69  --built-shared)
70    echo '@ENABLE_SHARED@'
71    ;;
72
73  --ca)
74    echo '@CURL_CA_BUNDLE@'
75    ;;
76
77  --cc)
78    echo '@CC@'
79    ;;
80
81  --prefix)
82    echo "$prefix"
83    ;;
84
85  --feature|--features)
86    for feature in @SUPPORT_FEATURES@ ''; do
87      test -n "$feature" && echo "$feature"
88    done
89    ;;
90
91  --protocols)
92    # shellcheck disable=SC2043
93    for protocol in @SUPPORT_PROTOCOLS@; do
94      echo "$protocol"
95    done
96    ;;
97
98  --version)
99    echo 'libcurl @CURLVERSION@'
100    exit 0
101    ;;
102
103  --checkfor)
104    checkfor="$2"
105    cmajor=`echo "$checkfor" | cut -d. -f1`
106    cminor=`echo "$checkfor" | cut -d. -f2`
107    # when extracting the patch part we strip off everything after a
108    # dash as that's used for things like version 1.2.3-pre1
109    cpatch=`echo "$checkfor" | cut -d. -f3 | cut -d- -f1`
110
111    vmajor=`echo '@CURLVERSION@' | cut -d. -f1`
112    vminor=`echo '@CURLVERSION@' | cut -d. -f2`
113    # when extracting the patch part we strip off everything after a
114    # dash as that's used for things like version 1.2.3-pre1
115    vpatch=`echo '@CURLVERSION@' | cut -d. -f3 | cut -d- -f1`
116
117    if test "$vmajor" -gt "$cmajor"; then
118      exit 0
119    fi
120    if test "$vmajor" -eq "$cmajor"; then
121      if test "$vminor" -gt "$cminor"; then
122        exit 0
123      fi
124      if test "$vminor" -eq "$cminor"; then
125        if test "$cpatch" -le "$vpatch"; then
126          exit 0
127        fi
128      fi
129    fi
130
131    echo "requested version $checkfor is newer than existing @CURLVERSION@"
132    exit 1
133    ;;
134
135  --vernum)
136    echo '@VERSIONNUM@'
137    exit 0
138    ;;
139
140  --help)
141    usage 0
142    ;;
143
144  --cflags)
145    if test "X$cppflag_curl_staticlib" = 'X-DCURL_STATICLIB'; then
146      CPPFLAG_CURL_STATICLIB='-DCURL_STATICLIB '
147    else
148      CPPFLAG_CURL_STATICLIB=''
149    fi
150    if test "X@includedir@" = 'X/usr/include'; then
151      echo "${CPPFLAG_CURL_STATICLIB}"
152    else
153      echo "${CPPFLAG_CURL_STATICLIB}-I@includedir@"
154    fi
155    ;;
156
157  --libs)
158    if test "X@libdir@" != 'X/usr/lib' -a "X@libdir@" != 'X/usr/lib64'; then
159      CURLLIBDIR="-L@libdir@ "
160    else
161      CURLLIBDIR=''
162    fi
163    if test 'X@ENABLE_SHARED@' = 'Xno'; then
164      echo "${CURLLIBDIR}-lcurl @LIBCURL_PC_LIBS_PRIVATE@"
165    else
166      echo "${CURLLIBDIR}-lcurl"
167    fi
168    ;;
169
170  --ssl-backends)
171    echo '@SSL_BACKENDS@'
172    ;;
173
174  --static-libs)
175    if test 'X@ENABLE_STATIC@' != 'Xno'; then
176      echo "@libdir@/libcurl.@libext@ @LIBCURL_PC_LDFLAGS_PRIVATE@ @LIBCURL_PC_LIBS_PRIVATE@"
177    else
178      echo 'curl was built with static libraries disabled' >&2
179      exit 1
180    fi
181    ;;
182
183  --configure)
184    echo @CONFIGURE_OPTIONS@
185    ;;
186
187  *)
188    echo "unknown option: $1"
189    usage 1
190    ;;
191  esac
192  shift
193done
194
195exit 0
196