[ci] Fix netbsd job to upgrade existing packages
[xapian.git] / xapian-letor / xapianletor-config.in
blob031da10f0e7e5e12c6be7f456a4cd1f08eb2dc3a
1 #!/bin/sh
2 # @configure_input@
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
19 # USA
21 PROG_NAME=xapianletor-config
22 PROG_DESC="report information about the installed version of xapian-letor"
24 # ${prefix} and ${exec_prefix} are used in some @-substitutions, and
25 # ${prefix} is usually used in the exec_prefix @-substitution.
26 prefix="@prefix@"
27 exec_prefix="@exec_prefix@"
29 # Show usage information and exit with the specified exit status.
30 show_usage() {
31 cat <<EOF
32 Usage: $PROG_NAME OPTION...
34 Options:
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@>.
44 EOF
46 exit "$1"
49 # This script requires at least one argument.
50 [ 0 != "$#" ] || show_usage 1 1>&2
52 ##UNINSTONLYBEGIN
53 # Cached value. Note that this a return code, so 0 means uninstalled!
54 is_uninstalled_cache=
56 # Check if this is an uninstalled xapianletor-config.
57 is_uninstalled()
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-letor.
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"
74 ##UNINSTONLYEND
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 # xapianletor-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@/libxapianletor.la" ] ; then
86 # If "$dlname" is empty, we only have static libraries.
87 extract_dlname "@libdir@/libxapianletor.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"
96 return 0 # "true"
99 # -L option required (if any).
100 set_L_to_library_path() {
102 [ /usr/lib != "@libdir@" ] && L="-L@libdir@ "
105 set_I() {
106 ##UNINSTONLYBEGIN
107 if is_uninstalled ; then
108 set_I_for_uninstalled
109 else
110 ##UNINSTONLYEND
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.
118 case "@incdir@" in
119 /usr/include|/usr/include/c++) I= ;;
120 *) I="-I@incdir@" ;;
121 esac
122 ##UNINSTONLYBEGIN
124 ##UNINSTONLYEND
127 set_I_swig() {
128 ##UNINSTONLYBEGIN
129 if is_uninstalled ; then
130 set_I_for_uninstalled
131 else
132 ##UNINSTONLYEND
133 I="-I@incdir@"
134 ##UNINSTONLYBEGIN
136 ##UNINSTONLYEND
139 # Extract dlname from a libtool .la file.
140 extract_dlname() {
141 dlname=
142 # Need to quote ^ for Solaris /bin/sh.
143 assignment=`grep '^dlname=' "$1" 2>/dev/null`
144 eval "$assignment"
147 # Extract dependency_libs recursively from a libtool .la file, converting
148 # .la references into appropriate -L and -l options.
149 extract_dependency_libs() {
150 deps=
151 # Multiple whitespace (space or tab).
152 mws='[ ][ ]*'
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_() {
161 dependency_libs=
162 # Need to quote ^ for Solaris /bin/sh.
163 assignment=`grep '^dependency_libs=' "$1" 2>/dev/null`
164 eval "$assignment"
165 dependency_libs=`echo " $dependency_libs "|sed "s/$mws/ /g"`
166 while true ; do
167 file=`echo "$dependency_libs"|sed "s,$pat"',\2\3\4.la,'`
168 case $file in
169 *.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.
178 dependency_libs=$1
181 deps=$deps$dependency_libs
182 break
184 esac
185 done
188 builddir=`echo "$0"|sed 's![^/]*$!!'`
189 xo_lib_xapianletor=no
190 static=no
192 actions=
193 while [ 0 != "$#" ] ; do
194 arg=$1
195 shift
196 case $arg in
197 --help)
198 echo "$PROG_NAME - $PROG_DESC"
199 echo
200 show_usage 0
203 --version)
204 echo "$PROG_NAME - @PACKAGE_STRING@"
205 exit 0
208 --cxxflags|--swigflags|--libs|--ltlibs)
209 actions="$actions $arg"
212 --static)
213 static=yes
216 --from-xo-lib-xapianletor)
217 # Top Secret option which allows us to give a more helpful error
218 # message if we're asked to link with an uninstalled libxapianletor
219 # and libtool isn't in use.
220 xo_lib_xapianletor=yes
224 echo "$0: Unrecognized option: $arg" 1>&2
225 show_usage 1 1>&2
229 show_usage 1 1>&2
231 esac
232 done
234 for arg in $actions ; do
235 case $arg in
236 --cxxflags)
237 set_I
239 [ -n "@abi_affecting_cxxflags@" ] && F="@abi_affecting_cxxflags@ "
240 echo "$I$F"
243 --swigflags)
244 set_I_swig
245 echo "$I"
248 --libs)
249 ##UNINSTONLYBEGIN
250 if is_uninstalled ; then
251 if [ no = "$xo_lib_xapianletor" ]; then
252 echo "$0: Use libtool and '$PROG_NAME --ltlibs'" 1>&2
253 else
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 libxapianletor." 1>&2
265 exit 1
267 ##UNINSTONLYEND
268 set_L_to_library_path
270 if need_explicit_dependencies ; then
271 extract_dependency_libs "@libdir@/libxapianletor.la"
272 [ -n "$dependency_libs" ] && D=" $dependency_libs"
274 echo "$L -lxapianletor$D"
277 --ltlibs)
278 ##UNINSTONLYBEGIN
279 if is_uninstalled ; then
280 # Don't check if libxapianletor.la exists yet since we want to allow
281 # configuring against a xapian-letor 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}libxapianletor.la"
286 continue
288 ##UNINSTONLYEND
290 # If we need to pull in dependency_libs, we need libxapianletor.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
296 # behaviour.
297 if need_explicit_dependencies ; then
298 if [ -f "@libdir@/libxapianletor.la" ]; then
299 echo "@libdir@/libxapianletor.la"
300 continue
303 echo "$0: Can't find libxapianletor.la to link against." 1>&2
304 exit 1
307 set_L_to_library_path
308 echo "$L -lxapianletor"
310 esac
311 done
312 exit 0