2
0

apu-config.in 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #!/bin/sh
  2. # Copyright 2001-2005 The Apache Software Foundation or its licensors, as
  3. # applicable.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # 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-util script designed to allow easy command line access to APR-util
  18. # configuration parameters.
  19. APRUTIL_MAJOR_VERSION="@APRUTIL_MAJOR_VERSION@"
  20. APRUTIL_DOTTED_VERSION="@APRUTIL_DOTTED_VERSION@"
  21. prefix="@prefix@"
  22. exec_prefix="@exec_prefix@"
  23. bindir="@bindir@"
  24. libdir="@libdir@"
  25. includedir="@includedir@"
  26. LIBS="@APRUTIL_EXPORT_LIBS@"
  27. INCLUDES="@APRUTIL_INCLUDES@"
  28. LDFLAGS="@APRUTIL_LDFLAGS@"
  29. APRUTIL_LIBNAME="@APRUTIL_LIBNAME@"
  30. APU_SOURCE_DIR="@abs_srcdir@"
  31. APU_BUILD_DIR="@abs_builddir@"
  32. APR_XML_EXPAT_OLD="@APR_XML_EXPAT_OLD@"
  33. APU_DB_VERSION="@apu_db_version@"
  34. # NOTE: the following line is modified during 'make install': alter with care!
  35. location=@APU_CONFIG_LOCATION@
  36. show_usage()
  37. {
  38. cat << EOF
  39. Usage: apu-$APRUTIL_MAJOR_VERSION-config [OPTION]
  40. Known values for OPTION are:
  41. --prefix[=DIR] change prefix to DIR
  42. --bindir print location where binaries are installed
  43. --includes print include information
  44. --includedir print location where headers are installed
  45. --ldflags print linker flags
  46. --libs print library information
  47. --srcdir print APR-util source directory
  48. --link-ld print link switch(es) for linking to APR-util
  49. --link-libtool print the libtool inputs for linking to APR-util
  50. --apu-la-file print the path to the .la file, if available
  51. --old-expat indicate if APR-util was built against an old expat
  52. --db-version print the DB version
  53. --version print APR-util's version as a dotted triple
  54. --help print this help
  55. When linking with libtool, an application should do something like:
  56. APU_LIBS="\`apu-$APRUTIL_MAJOR_VERSION-config --link-libtool --libs\`"
  57. or when linking directly:
  58. APU_LIBS="\`apu-$APRUTIL_MAJOR_VERSION-config --link-ld --libs\`"
  59. An application should use the results of --includes, and --ldflags in
  60. their build process.
  61. EOF
  62. }
  63. if test $# -eq 0; then
  64. show_usage
  65. exit 1
  66. fi
  67. if test "$location" = "installed"; then
  68. LA_FILE="$libdir/lib${APRUTIL_LIBNAME}.la"
  69. LIBS=`echo "$LIBS" | sed -e "s $APU_BUILD_DIR/xml/expat $prefix g" -e "s $prefix/lib/libexpat.la -lexpat g"`
  70. LDFLAGS=`echo "$LDFLAGS" | sed -e "s $APU_BUILD_DIR/xml/expat $prefix g"`
  71. INCLUDES=`echo "$INCLUDES" | sed -e "s $APU_BUILD_DIR/xml/expat $prefix g" -e "s -I$prefix/lib g"`
  72. else
  73. LA_FILE="$APU_BUILD_DIR/lib${APRUTIL_LIBNAME}.la"
  74. fi
  75. flags=""
  76. while test $# -gt 0; do
  77. # Normalize the prefix.
  78. case "$1" in
  79. -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  80. *) optarg= ;;
  81. esac
  82. case "$1" in
  83. # It is possible for the user to override our prefix.
  84. --prefix=*)
  85. prefix=$optarg
  86. ;;
  87. --prefix)
  88. echo $prefix
  89. exit 0
  90. ;;
  91. --bindir)
  92. echo $bindir
  93. exit 0
  94. ;;
  95. --libs)
  96. flags="$flags $LIBS"
  97. ;;
  98. --includedir)
  99. if test "$location" = "installed"; then
  100. flags="$includedir"
  101. elif test "$location" = "source"; then
  102. flags="$APU_SOURCE_DIR/include"
  103. else
  104. # this is for VPATH builds
  105. flags="$APU_BUILD_DIR/include $APU_SOURCE_DIR/include"
  106. fi
  107. echo $flags
  108. exit 0
  109. ;;
  110. --includes)
  111. if test "$location" = "installed"; then
  112. flags="$flags -I$includedir $INCLUDES"
  113. elif test "$location" = "source"; then
  114. flags="$flags -I$APU_SOURCE_DIR/include $INCLUDES"
  115. else
  116. # this is for VPATH builds
  117. flags="$flags -I$APU_BUILD_DIR/include -I$APU_SOURCE_DIR/include $INCLUDES"
  118. fi
  119. ;;
  120. --ldflags)
  121. flags="$flags $LDFLAGS"
  122. ;;
  123. --srcdir)
  124. echo $APU_SOURCE_DIR
  125. exit 0
  126. ;;
  127. --version)
  128. echo $APRUTIL_DOTTED_VERSION
  129. exit 0
  130. ;;
  131. --link-ld)
  132. if test "$location" = "installed"; then
  133. ### avoid using -L if libdir is a "standard" location like /usr/lib
  134. flags="$flags -L$libdir -l$APRUTIL_LIBNAME"
  135. else
  136. flags="$flags -L$APU_BUILD_DIR -l$APRUTIL_LIBNAME"
  137. fi
  138. ;;
  139. --link-libtool)
  140. # If the LA_FILE exists where we think it should be, use it. If we're
  141. # installed and the LA_FILE does not exist, assume to use -L/-l
  142. # (the LA_FILE may not have been installed). If we're building ourselves,
  143. # we'll assume that at some point the .la file be created.
  144. if test -f "$LA_FILE"; then
  145. flags="$flags $LA_FILE"
  146. elif test "$location" = "installed"; then
  147. ### avoid using -L if libdir is a "standard" location like /usr/lib
  148. # Since the user is specifying they are linking with libtool, we
  149. # *know* that -R will be recognized by libtool.
  150. flags="$flags -L$libdir -R$libdir -l$APRUTIL_LIBNAME"
  151. else
  152. flags="$flags $LA_FILE"
  153. fi
  154. ;;
  155. --apu-la-file)
  156. if test -f "$LA_FILE"; then
  157. flags="$flags $LA_FILE"
  158. fi
  159. ;;
  160. --old-expat)
  161. if test ! -n "$APR_XML_EXPAT_OLD"; then
  162. echo "no"
  163. else
  164. echo "$APR_XML_EXPAT_OLD"
  165. fi
  166. exit 0
  167. ;;
  168. --db-version)
  169. echo $APU_DB_VERSION
  170. exit 0
  171. ;;
  172. --help)
  173. show_usage
  174. exit 0
  175. ;;
  176. *)
  177. show_usage
  178. exit 1
  179. ;;
  180. esac
  181. # Next please.
  182. shift
  183. done
  184. if test -n "$flags"; then
  185. echo "$flags"
  186. fi
  187. exit 0