- Keith Mok added supported_protocols and supported_features to the pkg-config
[platform/upstream/curl.git] / curl-config.in
1 #! /bin/sh
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) 2001 - 2008, 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         for feature in @SUPPORT_FEATURES@; do
84             echo $feature;
85         done
86         ;;
87
88     --protocols)
89         for protocol in @SUPPORT_PROTOCOLS@; do
90             echo $protocol;
91         done
92         ;;
93     --version)
94         echo libcurl @VERSION@
95         exit 0
96         ;;
97
98     --checkfor)
99         checkfor=$2
100         cmajor=`echo $checkfor | cut -d. -f1`
101         cminor=`echo $checkfor | cut -d. -f2`
102         # when extracting the patch part we strip off everything after a
103         # dash as that's used for things like version 1.2.3-CVS
104         cpatch=`echo $checkfor | cut -d. -f3 | cut -d- -f1`
105         checknum=`echo "$cmajor*256*256 + $cminor*256 + ${cpatch:-0}" | bc`
106         numuppercase=`echo @VERSIONNUM@ | tr 'a-f' 'A-F'`
107         nownum=`echo "obase=10; ibase=16; $numuppercase" | bc`
108
109         if test "$nownum" -ge "$checknum"; then
110           # silent success
111           exit 0
112         else
113           echo "requested version $checkfor is newer than existing @VERSION@"
114           exit 1
115         fi
116         ;;
117
118     --vernum)
119         echo @VERSIONNUM@
120         exit 0
121         ;;
122
123     --help)
124         usage 0
125         ;;
126
127     --cflags)
128         if test "X@includedir@" = "X/usr/include"; then
129           echo ""
130         else
131           echo "-I@includedir@"
132         fi
133         ;;
134
135     --libs)
136         if test "X@libdir@" != "X/usr/lib" -a "X@libdir@" != "X/usr/lib64"; then
137            CURLLIBDIR="-L@libdir@ "
138         else
139            CURLLIBDIR=""
140         fi
141         if test "X@REQUIRE_LIB_DEPS@" = "Xyes"; then
142           echo ${CURLLIBDIR}-lcurl @LDFLAGS@ @LIBCURL_LIBS@ @LIBS@
143         else
144           echo ${CURLLIBDIR}-lcurl @LDFLAGS@ @LIBS@
145         fi
146         ;;
147
148     --static-libs)
149         echo @libdir@/libcurl.@libext@ @LDFLAGS@ @LIBCURL_LIBS@ @LIBS@
150         ;;
151
152     *)
153         echo "unknown option: $1"
154         usage 1
155         ;;
156     esac
157     shift
158 done
159
160 exit 0