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