4 # Copyright (C) 2002,2003,2004,2005,2006,2007,2009,2010,2012,2014,2015 Olly Betts
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21 PROG_NAME
=xapian-config
22 PROG_DESC
="report information about the installed version of xapian"
24 # ${prefix} and ${exec_prefix} are used in some @-substitutions, and
25 # ${prefix} is usually used in the exec_prefix @-substitution.
27 exec_prefix
="@exec_prefix@"
29 # Show usage information and exit with the specified exit status.
32 Usage: $PROG_NAME OPTION...
35 --cxxflags output all preprocessor and C++ compiler flags
36 --libs output all linker flags
37 --ltlibs output linker flags for linking using GNU libtool
38 --static make other options report values for static linking
39 --swigflags output preprocessor flags for use with SWIG
40 --help output this help and exit
41 --version output version information and exit
43 Report bugs to <@PACKAGE_BUGREPORT@>.
49 # This script requires at least one argument.
50 [ 0 != "$#" ] || show_usage
1 1>&2
53 # Cached value. Note that this a return code, so 0 means uninstalled!
56 # Check if this is an uninstalled xapian-config.
59 if [ -z "$is_uninstalled_cache" ]; then
60 [ -n "$builddir" -a -f "${builddir}Makefile" ]
61 is_uninstalled_cache
=$?
63 return $is_uninstalled_cache
66 # -I options for compiling against an uninstalled xapian.
67 set_I_for_uninstalled
() {
69 # version.h is generated by configure, so we also need builddir
70 # in the include path if it's different to srcdir.
71 [ "@abs_srcdir@" != "@abs_builddir@" ] && I
="-I@abs_builddir@/include "
72 I
="$I-I@abs_srcdir@/include"
76 need_explicit_dependencies
()
78 # For static libraries, we need to explicitly link with dependency_libs
79 # on all platforms. For shared libraries, it depends on the platform.
81 # xapian-config --static means static libraries.
82 [ no
= "$static" ] ||
return 0 # "true"
84 # If the .la file hasn't been installed, assume there are shared libraries.
85 if [ -f "@libdir@/libxapian@LIBRARY_VERSION_SUFFIX@.la" ] ; then
86 # If "$dlname" is empty, we only have static libraries.
87 extract_dlname
"@libdir@/libxapian@LIBRARY_VERSION_SUFFIX@.la"
88 [ -n "$dlname" ] ||
return 0 # "true"
91 # Vanilla libtool set this to either "yes" or "unknown" and then handles
92 # both of these the same way, but our configure forces this to "no" on
93 # platforms where we know that is appropriate.
94 [ no
!= "@link_all_deplibs_CXX@" ] ||
return 1 # "false"
99 # -L option required (if any).
100 set_L_to_library_path
() {
102 [ /usr
/lib
!= "@libdir@" ] && L
="-L@libdir@ "
107 if is_uninstalled
; then
108 set_I_for_uninstalled
111 # Adding -I/usr/include to CXXFLAGS causes problems with certain
112 # versions of GCC on some platforms where GCC generates "fixed"
113 # versions of vendor supplied include headers at install time.
114 # Normally these are used instead of those in /usr/include, but if
115 # you explicitly pass -I/usr/include you get the non-fixed
116 # versions. More recent GCC versions simply ignore -I/usr/include
117 # but we want to support older versions too.
119 /usr
/include|
/usr
/include
/c
++) I
= ;;
129 if is_uninstalled
; then
130 set_I_for_uninstalled
139 # Extract dlname from a libtool .la file.
142 # Need to quote ^ for Solaris /bin/sh.
143 assignment
=`grep '^dlname=' "$1" 2>/dev/null`
147 # Extract dependency_libs recursively from a libtool .la file, converting
148 # .la references into appropriate -L and -l options.
149 extract_dependency_libs
() {
151 # Multiple whitespace (space or tab).
153 la
='\(/[^ ]*\)\(/lib\)\([^ ]*\).la'
154 pat
='\(.* \)'"$la"'\( .*\)'
155 extract_dependency_libs_
"$1"
156 dependency_libs
=`echo "$deps"|sed 's/ */ /g;s/^ //;s/ $//'`
159 # Internal helper function for extract_dependency_libs.
160 extract_dependency_libs_
() {
162 # Need to quote ^ for Solaris /bin/sh.
163 assignment
=`grep '^dependency_libs=' "$1" 2>/dev/null`
165 dependency_libs
=`echo " $dependency_libs "|sed "s/$mws/ /g"`
167 file=`echo "$dependency_libs"|sed "s,$pat"',\2\3\4.la,'`
170 # Replace "/path/to/libfoo.la" with "-L/path/to -lfoo".
171 deps
="$deps "`echo "$dependency_libs"|sed "s,$pat"',\1-L\2 -l\4,'`
172 # Put the trailing part in $1 which is a local variable.
173 set "`echo "$dependency_libs"|sed "s
,$pat"',\5,'`"
174 # And expand any dependency libs from libfoo.la.
175 extract_dependency_libs_
"$file"
176 # Set dependency_libs to the trailing part, ready for the
177 # next pass of the loop which checks for more .la files.
181 deps
=$deps$dependency_libs
188 builddir
=`echo "$0"|sed 's![^/]*$!!'`
193 while [ 0 != "$#" ] ; do
198 echo "$PROG_NAME - $PROG_DESC"
204 echo "$PROG_NAME - @PACKAGE_STRING@"
208 --cxxflags|
--swigflags|
--libs|
--ltlibs)
209 actions
="$actions $arg"
216 --from-xo-lib-xapian)
217 # Top Secret option which allows us to give a more helpful error
218 # message if we're asked to link with an uninstalled libxapian@LIBRARY_VERSION_SUFFIX@
219 # and libtool isn't in use.
224 echo "$0: Unrecognized option: $arg" 1>&2
234 for arg
in $actions ; do
239 [ -n "@abi_affecting_cxxflags@" ] && F
="@abi_affecting_cxxflags@ "
250 if is_uninstalled
; then
251 if [ no
= "$xo_lib_xapian" ]; then
252 echo "$0: Use libtool and '$PROG_NAME --ltlibs'" 1>&2
254 configure_ac
='configure.in (or configure.ac)'
255 # If ac_top_srcdir isn't passed to us, we just end up looking
256 # in the current directory, which is a sensible fallback.
257 if [ -r "${ac_top_srcdir}configure.ac" ]; then
258 configure_ac
=configure.ac
259 elif [ -r "${ac_top_srcdir}configure.in" ]; then
260 configure_ac
=configure.
in
262 echo "$0: Add AC_PROG_LIBTOOL to your $configure_ac" 1>&2
264 echo "to link with an uninstalled libxapian@LIBRARY_VERSION_SUFFIX@." 1>&2
268 set_L_to_library_path
270 if need_explicit_dependencies
; then
271 extract_dependency_libs
"@libdir@/libxapian@LIBRARY_VERSION_SUFFIX@.la"
272 [ -n "$dependency_libs" ] && D
=" $dependency_libs"
274 echo "$L-lxapian@LIBRARY_VERSION_SUFFIX@$D"
279 if is_uninstalled
; then
280 # Don't check if libxapian@LIBRARY_VERSION_SUFFIX@.la exists yet since we want to allow
281 # configuring against a xapian-core tree which hasn't been built
282 # yet (the top level bootstrap script relies on this).
283 [ .
/ != "$builddir" ] && F
="$F$builddir"
284 [ no
= "$static" ] || F
="-static-libtool-libs $F"
285 echo "${F}libxapian@LIBRARY_VERSION_SUFFIX@.la"
290 # If we need to pull in dependency_libs, we need libxapian@LIBRARY_VERSION_SUFFIX@.la.
291 # Otherwise just use the appropriate -L and -l options.
292 # Upstream libtool currently never sets link_all_deplibs_CXX=no.
293 # Some Linux distros patch libtool to return no, and some have an
294 # unhelpful policy of not packaging .la files in an attempt to work
295 # around this. So avoiding using libtool here gives more consistent
297 if need_explicit_dependencies
; then
298 if [ -f "@libdir@/libxapian@LIBRARY_VERSION_SUFFIX@.la" ]; then
299 echo "@libdir@/libxapian@LIBRARY_VERSION_SUFFIX@.la"
303 echo "$0: Can't find libxapian@LIBRARY_VERSION_SUFFIX@.la to link against." 1>&2
307 set_L_to_library_path
308 echo "$L-lxapian@LIBRARY_VERSION_SUFFIX@"