zoomsh: do not use readline for stdin (no tty) YAZ-724
[yaz-moved-to-github.git] / yaz-config.in
1 #!/bin/sh
2 # This file is part of the YAZ toolkit.
3 # Copyright (C) Index Data
4 # See the file LICENSE for details.
5
6 prefix=@prefix@
7 exec_prefix=@exec_prefix@
8 libdir=@libdir@
9 includedir=@includedir@
10 echo_cflags=no
11 echo_libs=no
12 echo_help=no
13 echo_include=no
14 echo_source=yes
15 echo_lalibs=no
16 echo_comp=no
17 src_root=@abs_top_srcdir@
18 build_root=@abs_top_builddir@
19 ICU_LIBS="@ICU_LIBS@"
20 ICU_CPPFLAGS="@ICU_CPPFLAGS@"
21 SSL_LIBS="@SSL_LIBS@"
22 LIBS="@LIBS@"
23 VERSION=@VERSION@
24 YAZVERSION=$VERSION
25 VERSION_SHA1=@VERSION_SHA1@
26
27 usage()
28 {
29     cat <<EOF
30 Usage: yaz-config [OPTIONS] [LIBRARIES]
31 Options:
32         [--prefix[=DIR]]
33         [--version]
34         [--libs]
35         [--lalibs]
36         [--cflags]
37         [--include]
38         [--comp]
39         [-V]
40 Libraries:
41         threads icu server static
42 EOF
43         exit $1
44 }
45
46 while test $# -gt 0; do
47     case "$1" in
48         -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
49         *) optarg= ;;
50     esac
51     
52     case $1 in
53         --prefix=*)
54             prefix=$optarg
55             ;;
56         --prefix)
57             echo $prefix
58             exit 0
59             ;;
60         -V)
61             echo "$VERSION $VERSION_SHA1"
62             exit 0
63             ;;
64         --version)
65             echo $VERSION
66             exit 0
67             ;;
68         --cflags)
69             echo_cflags=yes
70             ;;
71         --include)
72             echo_include=yes
73             ;;
74         --libs)
75             echo_libs=yes
76             ;;
77         --lalibs)
78             echo_lalibs=yes
79             ;;
80         --comp)
81             echo_comp=yes
82             ;;
83         threads)
84             lib_thread=yes
85             ;;
86         icu)
87             if test "$ICU_CPPFLAGS"; then
88                 lib_icu=yes
89             fi
90             ;;
91         ssl)
92             lib_ssl=yes
93             ;;
94         server)
95             lib_thread=yes
96             lib_server=yes
97             ;;
98         static)
99             lib_static=yes
100             ;;
101         -*)
102             echo_help=yes
103             ;;
104     esac
105     shift
106 done
107
108 YAZLIB="-lyaz"
109 if test "$lib_server" = "yes"; then
110     YAZLIB="-lyaz_server $YAZLIB"
111 fi
112
113 if test "$lib_icu" = "yes"; then
114     YAZLIB="-lyaz_icu $YAZLIB"
115 fi
116
117 YAZINC="@YAZ_CONFIG_CFLAGS@"
118
119 if test "$echo_source" = "yes"; then
120     YAZBIN=${build_root}/bin
121
122     if test "$lib_static" = "yes"; then
123         YAZLIB="${build_root}/src/.libs/libyaz.a"
124         if test "$lib_server" = "yes"; then
125             YAZLIB="${build_root}/src/.libs/libyaz_server.a $YAZLIB"
126         fi
127         if test "$lib_icu" = "yes"; then
128             YAZLIB="${build_root}/src/.libs/libyaz_icu.a $YAZLIB"
129         fi
130     else
131         YAZLIB="-L${build_root}/src/.libs $YAZLIB"
132     fi
133     LIBS="${SSL_LIBS} $LIBS"
134     YAZLIB="$YAZLIB $LIBS"
135
136     YAZLALIB="${build_root}/src/libyaz.la"
137     if test "$lib_server" = "yes"; then
138         YAZLALIB="${build_root}/src/libyaz_server.la $YAZLALIB"
139     fi
140     if test "$lib_icu" = "yes"; then
141         YAZLALIB="${build_root}/src/libyaz_icu.la $YAZLALIB"
142     fi
143     YAZLALIB="$YAZLALIB $LIBS"
144
145     YAZBINC="-I${src_root}/include"
146     YAZINC="$YAZBINC $YAZINC"
147     YAZCOMP=${src_root}/util/yaz-asncomp
148 else
149     YAZBIN=${prefix}/bin
150     YAZCOMP=${prefix}/bin/yaz-asncomp
151
152     if test "$prefix" != "/usr"; then
153         YAZLIB="-L$libdir $YAZLIB"
154     fi
155     if test "$lib_ssl" = "yes"; then
156         LIBS="${SSL_LIBS} $LIBS"
157     fi
158     YAZLIB="$YAZLIB $LIBS"
159     YAZLALIB=$YAZLIB
160     if test "$prefix" != "/usr"; then
161         YAZBINC="-I${includedir}"
162         YAZINC="$YAZBINC $YAZINC"
163     fi
164 fi
165
166 if test "$lib_thread" = "yes"; then
167     :
168 fi
169
170 if test "$lib_icu" = "yes"; then
171     YAZINC="$YAZINC $ICU_CPPFLAGS"
172     YAZLIB="$YAZLIB $ICU_LIBS"
173     YAZLALIB="$YAZLALIB $ICU_LIBS"
174 fi
175
176 if test "$echo_help" = "yes"; then
177     usage 1 1>&2
178 fi
179 if test "$echo_include" = "yes"; then
180     echo $YAZBINC
181 fi
182 if test "$echo_cflags" = "yes"; then
183     echo $YAZINC
184 fi
185 if test "$echo_libs" = "yes"; then
186     echo $YAZLIB
187 fi
188 if test "$echo_lalibs" = "yes"; then
189     echo $YAZLALIB
190 fi
191 if test "$echo_comp" = "yes"; then
192     echo $YAZCOMP
193 fi
194 # Local Variables:
195 # mode:shell-script
196 # sh-indentation: 2
197 # sh-basic-offset: 4
198 # End: