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