1 |
#!/bin/sh |
2 |
|
3 |
## |
4 |
## Copyright 2003-2006 The Apache Software Foundation |
5 |
## |
6 |
## Licensed under the Apache License, Version 2.0 (the "License"); |
7 |
## you may not use this file except in compliance with the License. |
8 |
## You may obtain a copy of the License at |
9 |
## |
10 |
## http://www.apache.org/licenses/LICENSE-2.0 |
11 |
## |
12 |
## Unless required by applicable law or agreed to in writing, software |
13 |
## distributed under the License is distributed on an "AS IS" BASIS, |
14 |
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 |
## See the License for the specific language governing permissions and |
16 |
## limitations under the License. |
17 |
## |
18 |
|
19 |
# apreq2-config- based on apu-config: |
20 |
# APR-util script designed to allow easy command line access to APR-util |
21 |
# configuration parameters. |
22 |
|
23 |
PATH=/bin:/usr/bin:/usr/local/bin |
24 |
|
25 |
prefix="@prefix@" |
26 |
exec_prefix="@exec_prefix@" |
27 |
bindir="@bindir@" |
28 |
libdir="@libdir@" |
29 |
includedir="@includedir@/@APREQ_LIBNAME@" |
30 |
|
31 |
LIBS="@APR_LIBS@" |
32 |
LDFLAGS="@APR_LDFLAGS@" |
33 |
INCLUDES="@APR_INCLUDES@" |
34 |
SOLARIS=`echo @build_os@ | grep -i solaris` |
35 |
|
36 |
APREQ_LIBNAME="@APREQ_LIBNAME@" |
37 |
|
38 |
APREQ_SOURCE_DIR="@abs_srcdir@" |
39 |
APREQ_BUILD_DIR="@abs_builddir@" |
40 |
|
41 |
show_usage() |
42 |
{ |
43 |
cat << EOF |
44 |
Usage: apreq2-config [OPTION] |
45 |
|
46 |
Known values for OPTION are: |
47 |
--prefix[=DIR] change prefix to DIR |
48 |
--bindir print location where binaries are installed |
49 |
--includes print include information |
50 |
--includedir print location where headers are installed |
51 |
--ldflags print linker flags |
52 |
--libs print library information |
53 |
--srcdir print apreq2 source directory |
54 |
--link-ld print link switch(es) for linking to libapreq2 |
55 |
--link-libtool print the libtool inputs for linking to libapreq2 |
56 |
--la-file print the path to the library's .la file, if available |
57 |
--library-version print the API version as a dotted triple |
58 |
--libtool-version print the ABI version in a libtool-compatible format |
59 |
--package-version print the version number of the distribution |
60 |
--help print this help |
61 |
|
62 |
When linking with libtool, an application should do something like: |
63 |
APREQ_LIBS="\`apreq2-config --link-libtool --libs\`" |
64 |
or when linking directly: |
65 |
APREQ_LIBS="\`apreq2-config --link-ld --ldflags --libs\`" |
66 |
|
67 |
An application should use the results of --includes, and --ldflags in |
68 |
their build process. |
69 |
EOF |
70 |
} |
71 |
|
72 |
if test $# -eq 0; then |
73 |
show_usage |
74 |
exit 1 |
75 |
fi |
76 |
|
77 |
thisdir="`dirname $0`" |
78 |
thisdir="`cd $thisdir && pwd`" |
79 |
if test -d $bindir; then |
80 |
tmpbindir="`cd $bindir && pwd`" |
81 |
else |
82 |
tmpbindir="" |
83 |
fi |
84 |
# If we have the realpath program, use it to resolve symlinks. |
85 |
# Otherwise, being in a symlinked dir may result in incorrect output. |
86 |
if test -x "`which realpath 2>/dev/null`"; then |
87 |
thisdir="`realpath $thisdir`" |
88 |
if test -d "$APREQ_SOURCE_DIR"; then |
89 |
APREQ_SOURCE_DIR="`realpath $APREQ_SOURCE_DIR`" |
90 |
fi |
91 |
if test -n "$tmpbindir"; then |
92 |
tmpbindir="`realpath $tmpbindir`" |
93 |
fi |
94 |
fi |
95 |
if test "$tmpbindir" = "$thisdir"; then |
96 |
location=installed |
97 |
elif test "$APREQ_SOURCE_DIR" = "$thisdir"; then |
98 |
location=source |
99 |
else |
100 |
location=build |
101 |
fi |
102 |
|
103 |
|
104 |
if test "$location" = "installed"; then |
105 |
LA_FILE="$libdir/lib${APREQ_LIBNAME}.la" |
106 |
else |
107 |
LA_FILE="$thisdir/library/lib${APREQ_LIBNAME}.la" |
108 |
fi |
109 |
|
110 |
flags="" |
111 |
|
112 |
while test $# -gt 0; do |
113 |
# Normalize the prefix. |
114 |
case "$1" in |
115 |
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; |
116 |
*) optarg= ;; |
117 |
esac |
118 |
|
119 |
case "$1" in |
120 |
# It is possible for the user to override our prefix. |
121 |
--prefix=*) |
122 |
prefix=$optarg |
123 |
;; |
124 |
--prefix) |
125 |
echo $prefix |
126 |
exit 0 |
127 |
;; |
128 |
--bindir) |
129 |
echo $bindir |
130 |
exit 0 |
131 |
;; |
132 |
--libs) |
133 |
flags="$flags $LIBS" |
134 |
;; |
135 |
--includedir) |
136 |
if test "$location" = "installed"; then |
137 |
flags="$includedir" |
138 |
elif test "$location" = "source"; then |
139 |
flags="$APREQ_SOURCE_DIR/include" |
140 |
else |
141 |
# this is for VPATH builds |
142 |
flags="$thisdir/include $APREQ_SOURCE_DIR/include" |
143 |
fi |
144 |
echo $flags |
145 |
exit 0 |
146 |
;; |
147 |
--includes) |
148 |
if test "$location" = "installed"; then |
149 |
flags="$flags -I$includedir $INCLUDES" |
150 |
elif test "$location" = "source"; then |
151 |
flags="$flags -I$APREQ_SOURCE_DIR/include $INCLUDES" |
152 |
else |
153 |
# this is for VPATH builds |
154 |
flags="$flags -I$thisdir/include -I$APREQ_SOURCE_DIR/include $INCLUDES" |
155 |
fi |
156 |
;; |
157 |
--ldflags) |
158 |
flags="$flags $LDFLAGS" |
159 |
;; |
160 |
--srcdir) |
161 |
echo $APREQ_SOURCE_DIR |
162 |
exit 0 |
163 |
;; |
164 |
--library-version) |
165 |
echo @APREQ_DOTTED_VERSION@ |
166 |
exit 0 |
167 |
;; |
168 |
--libtool-version) |
169 |
echo @APREQ_LIBTOOL_VERSION@ |
170 |
exit 0 |
171 |
;; |
172 |
--package-version) |
173 |
echo "@VERSION@" |
174 |
exit 0 |
175 |
;; |
176 |
--link-ld) |
177 |
if test "$location" = "installed"; then |
178 |
### avoid using -L if libdir is a "standard" location like /usr/lib |
179 |
flags="$flags -L$libdir -l$APREQ_LIBNAME" |
180 |
else |
181 |
flags="$flags -L$thisdir/library/.libs -l$APREQ_LIBNAME" |
182 |
fi |
183 |
;; |
184 |
--link-libtool) |
185 |
# If the LA_FILE exists where we think it should be, use it. If we're |
186 |
# installed and the LA_FILE does not exist, assume to use -L/-l |
187 |
# (the LA_FILE may not have been installed). If we're building ourselves, |
188 |
# we'll assume that at some point the .la file be created. |
189 |
if test -f "$LA_FILE"; then |
190 |
flags="$flags $LA_FILE" |
191 |
elif test "$location" = "installed"; then |
192 |
### avoid using -L if libdir is a "standard" location like /usr/lib |
193 |
flags="$flags -L$libdir -l$APREQ_LIBNAME $apreq_libs" |
194 |
else |
195 |
flags="$flags $LA_FILE" |
196 |
fi |
197 |
;; |
198 |
--la-file) |
199 |
if test -f "$LA_FILE"; then |
200 |
flags="$flags $LA_FILE" |
201 |
fi |
202 |
;; |
203 |
--help) |
204 |
show_usage |
205 |
exit 0 |
206 |
;; |
207 |
*) |
208 |
show_usage |
209 |
exit 1 |
210 |
;; |
211 |
esac |
212 |
|
213 |
# Next please. |
214 |
shift |
215 |
done |
216 |
|
217 |
if test -n "$flags"; then |
218 |
if test -n "$SOLARIS"; then |
219 |
flags=`echo $flags | sed -e 's/-L\([^ ]*\)/-R\1 -L\1/g'` |
220 |
fi |
221 |
echo "$flags" |
222 |
fi |
223 |
|
224 |
exit 0 |