2
0

curl-config.in 4.8 KB

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