2
0

apr-config.in 6.7 KB

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