Add our mirror of MSys as a submodule
[msysgit.git] / bin / apr-config
blob06acedaff988323415ef4fcc0a24f94b191b9633
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # APR script designed to allow easy command line access to APR configuration
19 # parameters.
21 APR_MAJOR_VERSION="0"
22 APR_DOTTED_VERSION="0.9.17"
24 prefix=""
25 exec_prefix="${prefix}"
26 bindir="${exec_prefix}/bin"
27 libdir="${exec_prefix}/lib"
28 datadir="${prefix}"
29 installbuilddir="${prefix}/build"
30 includedir="${prefix}/include/apr-${APR_MAJOR_VERSION}"
32 CC="gcc"
33 CPP="gcc -E"
34 SHELL="/bin/sh"
35 CPPFLAGS=""
36 CFLAGS="-g -O2"
37 LDFLAGS=""
38 LIBS=""
39 EXTRA_INCLUDES=""
40 SHLIBPATH_VAR="PATH"
41 APR_SOURCE_DIR="/src/subversion/subversion-1.4.6/apr"
42 APR_BUILD_DIR="/src/subversion/subversion-1.4.6/apr"
43 APR_SO_EXT="lo"
44 APR_LIB_TARGET="-rpath \$(libdir) \$\$objects"
45 APR_LIBNAME="apr-${APR_MAJOR_VERSION}"
47 # NOTE: the following line is modified during 'make install': alter with care!
48 location=installed
50 show_usage()
52 cat << EOF
53 Usage: apr-config [OPTION]
55 Known values for OPTION are:
56 --prefix[=DIR] change prefix to DIR
57 --bindir print location where binaries are installed
58 --includedir print location where headers are installed
59 --cc print C compiler name
60 --cpp print C preprocessor name and any required options
61 --cflags print C compiler flags
62 --cppflags print cpp flags
63 --includes print include information
64 --ldflags print linker flags
65 --libs print additional libraries to link against
66 --srcdir print APR source directory
67 --installbuilddir print APR build helper directory
68 --link-ld print link switch(es) for linking to APR
69 --link-libtool print the libtool inputs for linking to APR
70 --shlib-path-var print the name of the shared library path env var
71 --apr-la-file print the path to the .la file, if available
72 --apr-so-ext print the extensions of shared objects on this platform
73 --apr-lib-target print the libtool target information
74 --apr-libtool print the path to APR's libtool
75 --version print the APR's version as a dotted triple
76 --help print this help
78 When linking with libtool, an application should do something like:
79 APR_LIBS="\`apr-config --link-libtool --libs\`"
80 or when linking directly:
81 APR_LIBS="\`apr-config --link-ld --libs\`"
83 An application should use the results of --cflags, --cppflags, --includes,
84 and --ldflags in their build process.
85 EOF
88 if test $# -eq 0; then
89 show_usage
90 exit 1
93 if test "$location" = "installed"; then
94 LA_FILE="$libdir/lib${APR_LIBNAME}.la"
95 else
96 LA_FILE="$APR_BUILD_DIR/lib${APR_LIBNAME}.la"
99 flags=""
101 while test $# -gt 0; do
102 # Normalize the prefix.
103 case "$1" in
104 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
105 *) optarg= ;;
106 esac
108 case "$1" in
109 # It is possible for the user to override our prefix.
110 --prefix=*)
111 prefix=$optarg
113 --prefix)
114 echo $prefix
115 exit 0
117 --bindir)
118 echo $bindir
119 exit 0
121 --includedir)
122 if test "$location" = "installed"; then
123 flags="$includedir"
124 elif test "$location" = "source"; then
125 flags="$APR_SOURCE_DIR/include"
126 else
127 # this is for VPATH builds
128 flags="$APR_BUILD_DIR/include $APR_SOURCE_DIR/include"
130 echo $flags
131 exit 0
133 --cc)
134 echo $CC
135 exit 0
137 --cpp)
138 echo $CPP
139 exit 0
141 --cflags)
142 flags="$flags $CFLAGS"
144 --cppflags)
145 flags="$flags $CPPFLAGS"
147 --libs)
148 flags="$flags $LIBS"
150 --ldflags)
151 flags="$flags $LDFLAGS"
153 --includes)
154 if test "$location" = "installed"; then
155 flags="$flags -I$includedir $EXTRA_INCLUDES"
156 elif test "$location" = "source"; then
157 flags="$flags -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
158 else
159 # this is for VPATH builds
160 flags="$flags -I$APR_BUILD_DIR/include -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
163 --srcdir)
164 echo $APR_SOURCE_DIR
165 exit 0
167 --installbuilddir)
168 if test "$location" = "installed"; then
169 echo "${installbuilddir}"
170 elif test "$location" = "source"; then
171 echo "$APR_SOURCE_DIR/build"
172 else
173 # this is for VPATH builds
174 echo "$APR_BUILD_DIR/build"
176 exit 0
178 --version)
179 echo $APR_DOTTED_VERSION
180 exit 0
182 --link-ld)
183 if test "$location" = "installed"; then
184 ### avoid using -L if libdir is a "standard" location like /usr/lib
185 flags="$flags -L$libdir -l${APR_LIBNAME}"
186 else
187 ### this surely can't work since the library is in .libs?
188 flags="$flags -L$APR_BUILD_DIR -l${APR_LIBNAME}"
191 --link-libtool)
192 # If the LA_FILE exists where we think it should be, use it. If we're
193 # installed and the LA_FILE does not exist, assume to use -L/-l
194 # (the LA_FILE may not have been installed). If we're building ourselves,
195 # we'll assume that at some point the .la file be created.
196 if test -f "$LA_FILE"; then
197 flags="$flags $LA_FILE"
198 elif test "$location" = "installed"; then
199 ### avoid using -L if libdir is a "standard" location like /usr/lib
200 flags="$flags -L$libdir -l${APR_LIBNAME}"
201 else
202 flags="$flags $LA_FILE"
205 --shlib-path-var)
206 echo "$SHLIBPATH_VAR"
207 exit 0
209 --apr-la-file)
210 if test -f "$LA_FILE"; then
211 flags="$flags $LA_FILE"
214 --apr-so-ext)
215 echo "$APR_SO_EXT"
216 exit 0
218 --apr-lib-target)
219 echo "$APR_LIB_TARGET"
220 exit 0
222 --apr-libtool)
223 if test "$location" = "installed"; then
224 echo "${installbuilddir}/libtool"
225 else
226 echo "$APR_BUILD_DIR/libtool"
228 exit 0
230 --help)
231 show_usage
232 exit 0
235 show_usage
236 exit 1
238 esac
240 # Next please.
241 shift
242 done
244 if test -n "$flags"; then
245 echo "$flags"
248 exit 0