curl-config.in 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. 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@includedir@" = 'X/usr/include'; then
  124. echo '@LIBCURL_PC_CFLAGS@'
  125. else
  126. echo "@LIBCURL_PC_CFLAGS@ -I@includedir@"
  127. fi
  128. ;;
  129. --libs)
  130. if test "X@libdir@" != 'X/usr/lib' -a "X@libdir@" != 'X/usr/lib64'; then
  131. curllibdir="-L@libdir@ "
  132. else
  133. curllibdir=''
  134. fi
  135. if test 'X@ENABLE_SHARED@' = 'Xno'; then
  136. echo "${curllibdir}-lcurl @LIBCURL_PC_LIBS_PRIVATE@"
  137. else
  138. echo "${curllibdir}-lcurl"
  139. fi
  140. ;;
  141. --ssl-backends)
  142. echo '@SSL_BACKENDS@'
  143. ;;
  144. --static-libs)
  145. if test 'X@ENABLE_STATIC@' != 'Xno'; then
  146. echo "@libdir@/libcurl.@libext@ @LIBCURL_PC_LDFLAGS_PRIVATE@ @LIBCURL_PC_LIBS_PRIVATE@"
  147. else
  148. echo 'curl was built with static libraries disabled' >&2
  149. exit 1
  150. fi
  151. ;;
  152. --configure)
  153. echo @CONFIGURE_OPTIONS@
  154. ;;
  155. *)
  156. echo "unknown option: $1"
  157. usage 1
  158. ;;
  159. esac
  160. shift
  161. done
  162. exit 0