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