Based on one of those bug reports that are intercepted by a distro's bug
[platform/upstream/curl.git] / curl-config.in
1 #! /bin/sh
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) 2001 - 2007, 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 http://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 # $Id$
23 ###########################################################################
24 #
25 # The idea to this kind of setup info script was stolen from numerous
26 # other packages, such as neon, libxml and gnome.
27 #
28 prefix=@prefix@
29 exec_prefix=@exec_prefix@
30 includedir=@includedir@
31
32 usage()
33 {
34     cat <<EOF
35 Usage: curl-config [OPTION]
36
37 Available values for OPTION include:
38
39   --ca        ca bundle install path
40   --cc        compiler
41   --cflags    pre-processor and compiler flags
42   --checkfor [version] check for (lib)curl of the specified version
43   --features  newline separated list of enabled features
44   --help      display this help and exit
45   --libs      library linking information
46   --prefix    curl install prefix
47   --protocols newline separated list of enabled protocols
48   --static-libs static libcurl library linking information
49   --version   output version information
50   --vernum    output the version information as a number (hexadecimal)
51 EOF
52
53     exit $1
54 }
55
56 if test $# -eq 0; then
57     usage 1
58 fi
59
60 while test $# -gt 0; do
61     case "$1" in
62     # this deals with options in the style
63     # --option=value and extracts the value part
64     # [not currently used]
65     -*=*) value=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
66     *) value= ;;
67     esac
68
69     case "$1" in
70     --ca)
71         echo "@CURL_CA_BUNDLE@"
72         ;;
73
74     --cc)
75         echo "@CC@"
76         ;;
77
78     --prefix)
79         echo "$prefix"
80         ;;
81
82     --feature|--features)
83         if test "@USE_SSLEAY@" = "1"; then
84           echo "SSL"
85           NTLM=1 # OpenSSL implies NTLM
86         elif test -n "@SSL_ENABLED@"; then
87           echo "SSL"
88         fi
89         if test "@KRB4_ENABLED@" = "1"; then
90           echo "KRB4"
91         fi
92         if test "@IPV6_ENABLED@" = "1"; then
93           echo "IPv6"
94         fi
95         if test "@HAVE_LIBZ@" = "1"; then
96           echo "libz"
97         fi
98         if test "@HAVE_ARES@" = "1"; then
99           echo "AsynchDNS"
100         fi
101         if test "@IDN_ENABLED@" = "1"; then
102           echo "IDN"
103         fi
104         if test "@USE_WINDOWS_SSPI@" = "1"; then
105           echo "SSPI"
106           NTLM=1
107         fi
108         if test "$NTLM" = "1"; then
109           echo "NTLM"
110         fi
111         ;;
112
113     --protocols)
114         if test "@CURL_DISABLE_HTTP@" != "1"; then
115           echo "HTTP"
116           if test "@SSL_ENABLED@" = "1"; then
117             echo "HTTPS"
118           fi
119         fi
120         if test "@CURL_DISABLE_FTP@" != "1"; then
121           echo "FTP"
122           if test "@SSL_ENABLED@" = "1"; then
123             echo "FTPS"
124           fi
125         fi
126         if test "@CURL_DISABLE_FILE@" != "1"; then
127           echo "FILE"
128         fi
129         if test "@CURL_DISABLE_TELNET@" != "1"; then
130           echo "TELNET"
131         fi
132         if test "@CURL_DISABLE_LDAP@" != "1"; then
133           echo "LDAP"
134         fi
135         if test "@CURL_DISABLE_LDAPS@" != "1"; then
136           echo "LDAPS"
137         fi
138         if test "@CURL_DISABLE_DICT@" != "1"; then
139           echo "DICT"
140         fi
141         if test "@CURL_DISABLE_TFTP@" != "1"; then
142           echo "TFTP"
143         fi
144         if test "@USE_LIBSSH2@" = "1"; then
145           echo "SCP"
146           echo "SFTP"
147         fi
148         ;;
149     --version)
150         echo libcurl @VERSION@
151         exit 0
152         ;;
153
154     --checkfor)
155         checkfor=$2
156         cmajor=`echo $checkfor | cut -d. -f1`
157         cminor=`echo $checkfor | cut -d. -f2`
158         # when extracting the patch part we strip off everything after a
159         # dash as that's used for things like version 1.2.3-CVS
160         cpatch=`echo $checkfor | cut -d. -f3 | cut -d- -f1`
161         checknum=`echo "$cmajor*256*256 + $cminor*256 + ${cpatch:-0}" | bc`
162         numuppercase=`echo @VERSIONNUM@ | tr 'a-f' 'A-F'`
163         nownum=`echo "obase=10; ibase=16; $numuppercase" | bc`
164
165         if test "$nownum" -ge "$checknum"; then
166           # silent success
167           exit 0
168         else
169           echo "requested version $checkfor is newer than existing @VERSION@"
170           exit 1
171         fi
172         ;;
173
174     --vernum)
175         echo @VERSIONNUM@
176         exit 0
177         ;;
178
179     --help)
180         usage 0
181         ;;
182
183     --cflags)
184         if test "X@includedir@" = "X/usr/include"; then
185           echo ""
186         else
187           echo "-I@includedir@"
188         fi
189         ;;
190
191     --libs)
192         if test "X@libdir@" != "X/usr/lib"; then
193            CURLLIBDIR="-L@libdir@ "
194         else
195            CURLLIBDIR=""
196         fi
197         if test "X@REQUIRE_LIB_DEPS@" = "Xyes"; then
198           echo ${CURLLIBDIR}-lcurl @LDFLAGS@ @LIBCURL_LIBS@ @LIBS@
199         else
200           echo ${CURLLIBDIR}-lcurl @LDFLAGS@ @LIBS@
201         fi
202         ;;
203
204     --static-libs)
205         echo @libdir@/libcurl.@libext@ @LDFLAGS@ @LIBCURL_LIBS@ @LIBS@
206         ;;
207
208     *)
209         echo "unknown option: $1"
210         usage 1
211         ;;
212     esac
213     shift
214 done
215
216 exit 0