2
0

curl-config.in 4.9 KB

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