apr-config.in 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #!/bin/sh
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # APR script designed to allow easy command line access to APR configuration
  18. # parameters.
  19. APR_MAJOR_VERSION="@APR_MAJOR_VERSION@"
  20. APR_DOTTED_VERSION="@APR_DOTTED_VERSION@"
  21. prefix="@prefix@"
  22. exec_prefix="@exec_prefix@"
  23. bindir="@bindir@"
  24. libdir="@libdir@"
  25. datarootdir="@datadir@"
  26. datadir="@datadir@"
  27. installbuilddir="@installbuilddir@"
  28. includedir="@includedir@"
  29. CC="@CC@"
  30. CPP="@CPP@"
  31. SHELL="@SHELL@"
  32. CPPFLAGS="@EXTRA_CPPFLAGS@"
  33. CFLAGS="@EXTRA_CFLAGS@"
  34. LDFLAGS="@EXTRA_LDFLAGS@"
  35. LIBS="@EXTRA_LIBS@"
  36. EXTRA_INCLUDES="@EXTRA_INCLUDES@"
  37. SHLIBPATH_VAR="@shlibpath_var@"
  38. APR_SOURCE_DIR="@apr_srcdir@"
  39. APR_BUILD_DIR="@apr_builddir@"
  40. APR_SO_EXT="@so_ext@"
  41. APR_LIB_TARGET="@export_lib_target@"
  42. APR_LIBNAME="@APR_LIBNAME@"
  43. # NOTE: the following line is modified during 'make install': alter with care!
  44. location=@APR_CONFIG_LOCATION@
  45. show_usage()
  46. {
  47. cat << EOF
  48. Usage: apr-$APR_MAJOR_VERSION-config [OPTION]
  49. Known values for OPTION are:
  50. --prefix[=DIR] change prefix to DIR
  51. --bindir print location where binaries are installed
  52. --includedir print location where headers are installed
  53. --cc print C compiler name
  54. --cpp print C preprocessor name and any required options
  55. --cflags print C compiler flags
  56. --cppflags print C preprocessor flags
  57. --includes print include information
  58. --ldflags print linker flags
  59. --libs print additional libraries to link against
  60. --srcdir print APR source directory
  61. --installbuilddir print APR build helper directory
  62. --link-ld print link switch(es) for linking to APR
  63. --link-libtool print the libtool inputs for linking to APR
  64. --shlib-path-var print the name of the shared library path env var
  65. --apr-la-file print the path to the .la file, if available
  66. --apr-so-ext print the extensions of shared objects on this platform
  67. --apr-lib-target print the libtool target information
  68. --apr-libtool print the path to APR's libtool
  69. --version print the APR's version as a dotted triple
  70. --help print this help
  71. When linking with libtool, an application should do something like:
  72. APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-libtool --libs\`"
  73. or when linking directly:
  74. APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-ld --libs\`"
  75. An application should use the results of --cflags, --cppflags, --includes,
  76. and --ldflags in their build process.
  77. EOF
  78. }
  79. if test $# -eq 0; then
  80. show_usage
  81. exit 1
  82. fi
  83. if test "$location" = "installed"; then
  84. LA_FILE="$libdir/lib${APR_LIBNAME}.la"
  85. else
  86. LA_FILE="$APR_BUILD_DIR/lib${APR_LIBNAME}.la"
  87. fi
  88. flags=""
  89. while test $# -gt 0; do
  90. # Normalize the prefix.
  91. case "$1" in
  92. -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  93. *) optarg= ;;
  94. esac
  95. case "$1" in
  96. # It is possible for the user to override our prefix.
  97. --prefix=*)
  98. prefix=$optarg
  99. ;;
  100. --prefix)
  101. echo $prefix
  102. exit 0
  103. ;;
  104. --bindir)
  105. echo $bindir
  106. exit 0
  107. ;;
  108. --includedir)
  109. if test "$location" = "installed"; then
  110. flags="$includedir"
  111. elif test "$location" = "source"; then
  112. flags="$APR_SOURCE_DIR/include"
  113. else
  114. # this is for VPATH builds
  115. flags="$APR_BUILD_DIR/include $APR_SOURCE_DIR/include"
  116. fi
  117. echo $flags
  118. exit 0
  119. ;;
  120. --cc)
  121. echo $CC
  122. exit 0
  123. ;;
  124. --cpp)
  125. echo $CPP
  126. exit 0
  127. ;;
  128. --cflags)
  129. flags="$flags $CFLAGS"
  130. ;;
  131. --cppflags)
  132. flags="$flags $CPPFLAGS"
  133. ;;
  134. --libs)
  135. flags="$flags $LIBS"
  136. ;;
  137. --ldflags)
  138. flags="$flags $LDFLAGS"
  139. ;;
  140. --includes)
  141. if test "$location" = "installed"; then
  142. flags="$flags -I$includedir $EXTRA_INCLUDES"
  143. elif test "$location" = "source"; then
  144. flags="$flags -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
  145. else
  146. # this is for VPATH builds
  147. flags="$flags -I$APR_BUILD_DIR/include -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
  148. fi
  149. ;;
  150. --srcdir)
  151. echo $APR_SOURCE_DIR
  152. exit 0
  153. ;;
  154. --installbuilddir)
  155. if test "$location" = "installed"; then
  156. echo "${installbuilddir}"
  157. elif test "$location" = "source"; then
  158. echo "$APR_SOURCE_DIR/build"
  159. else
  160. # this is for VPATH builds
  161. echo "$APR_BUILD_DIR/build"
  162. fi
  163. exit 0
  164. ;;
  165. --version)
  166. echo $APR_DOTTED_VERSION
  167. exit 0
  168. ;;
  169. --link-ld)
  170. if test "$location" = "installed"; then
  171. ### avoid using -L if libdir is a "standard" location like /usr/lib
  172. flags="$flags -L$libdir -l${APR_LIBNAME}"
  173. else
  174. ### this surely can't work since the library is in .libs?
  175. flags="$flags -L$APR_BUILD_DIR -l${APR_LIBNAME}"
  176. fi
  177. ;;
  178. --link-libtool)
  179. # If the LA_FILE exists where we think it should be, use it. If we're
  180. # installed and the LA_FILE does not exist, assume to use -L/-l
  181. # (the LA_FILE may not have been installed). If we're building ourselves,
  182. # we'll assume that at some point the .la file be created.
  183. if test -f "$LA_FILE"; then
  184. flags="$flags $LA_FILE"
  185. elif test "$location" = "installed"; then
  186. ### avoid using -L if libdir is a "standard" location like /usr/lib
  187. # Since the user is specifying they are linking with libtool, we
  188. # *know* that -R will be recognized by libtool.
  189. flags="$flags -L$libdir -R$libdir -l${APR_LIBNAME}"
  190. else
  191. flags="$flags $LA_FILE"
  192. fi
  193. ;;
  194. --shlib-path-var)
  195. echo "$SHLIBPATH_VAR"
  196. exit 0
  197. ;;
  198. --apr-la-file)
  199. if test -f "$LA_FILE"; then
  200. flags="$flags $LA_FILE"
  201. fi
  202. ;;
  203. --apr-so-ext)
  204. echo "$APR_SO_EXT"
  205. exit 0
  206. ;;
  207. --apr-lib-target)
  208. echo "$APR_LIB_TARGET"
  209. exit 0
  210. ;;
  211. --apr-libtool)
  212. if test "$location" = "installed"; then
  213. echo "${installbuilddir}/libtool"
  214. else
  215. echo "$APR_BUILD_DIR/libtool"
  216. fi
  217. exit 0
  218. ;;
  219. --help)
  220. show_usage
  221. exit 0
  222. ;;
  223. *)
  224. show_usage
  225. exit 1
  226. ;;
  227. esac
  228. # Next please.
  229. shift
  230. done
  231. if test -n "$flags"; then
  232. echo "$flags"
  233. fi
  234. exit 0