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