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