Rename yazextralibs to just LIBS
[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     else
111         YAZLIB="-L${yaz_build_root}/src/.libs $lyaz"
112     fi
113     YAZLIB="$YAZLIB ${SSL_LIBS} $LIBS"
114
115     YAZLALIB="${yaz_build_root}/src/libyaz.la"
116     if test "$lib_server" = "yes"; then
117         YAZLALIB="${yaz_build_root}/src/libyaz_server.la $YAZLALIB"
118     fi
119     if test "$lib_icu" = "yes"; then
120         YAZLALIB="${yaz_build_root}/src/libyaz_icu.la $YAZLALIB"
121     fi
122     YAZLALIB="$YAZLALIB $LIBS"
123
124     YAZINC="-I${yaz_src_root}/include $YAZINC"
125     YAZCOMP=${yaz_src_root}/util/yaz-asncomp
126 else
127     YAZBIN=${yazprefix}/bin
128     YAZCOMP=${yazprefix}/bin/yaz-asncomp
129
130     if test "$yazprefix" != "/usr"; then
131         YAZLIB="-L$yazprefix/lib"
132     fi
133     YAZLIB="$YAZLIB $lyaz $LIBS"
134     YAZLALIB=$YAZLIB
135     if test "$yazprefix" != "/usr"; then
136         YAZINC="-I$yazprefix/include $YAZINC"
137     fi
138 fi
139
140 if test "$lib_thread" = "yes"; then
141     YAZINC="$PTHREAD_CFLAGS $YAZINC"
142     YAZLIB="$YAZLIB $PTHREAD_LIBS"
143     YAZLALIB="$YAZLALIB $PTHREAD_LIBS"
144 fi
145
146 if test "$lib_icu" = "yes"; then
147     YAZINC="$YAZINC $ICU_CPPFLAGS"
148     YAZLIB="$YAZLIB $ICU_LIBS"
149     YAZLALIB="$YAZLALIB $ICU_LIBS"
150 fi
151
152 if test "$yaz_echo_help" = "yes"; then
153     usage 1 1>&2
154 fi
155 if test "$yaz_echo_cflags" = "yes"; then
156     echo $YAZINC
157 fi
158 if test "$yaz_echo_libs" = "yes"; then
159     echo $YAZLIB
160 fi
161 if test "$yaz_echo_lalibs" = "yes"; then
162     echo $YAZLALIB
163 fi
164 if test "$yaz_echo_comp" = "yes"; then
165     echo $YAZCOMP
166 fi
167 # Local Variables:
168 # mode:shell-script
169 # sh-indentation: 2
170 # sh-basic-offset: 4
171 # End: