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