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