e57da01f2ca71fad8303d861e243b74103bdd958
[yaz-moved-to-github.git] / yaz-config.in
1 #!/bin/sh
2 # $Id: yaz-config.in,v 1.28 2007-04-17 20:26:18 adam Exp $
3 yazprefix=@prefix@
4 yaz_echo_cflags=no
5 yaz_echo_libs=no
6 yaz_echo_help=no
7 yaz_echo_source=yes
8 yaz_echo_lalibs=no
9 yaz_echo_comp=no
10 yaz_src_root=@YAZ_SRC_ROOT@
11 yaz_build_root=@YAZ_BUILD_ROOT@
12 PTHREAD_LIBS="@PTHREAD_LIBS@"
13 PTHREAD_CFLAGS="@PTHREAD_CFLAGS@"
14
15 yazextralibs="@LIBS@"
16 YAZVERSION=@VERSION@
17
18 usage()
19 {
20     cat <<EOF
21 Usage: yaz-config [OPTIONS] [LIBRARIES]
22 Options:
23         [--prefix[=DIR]]
24         [--version]
25         [--libs]
26         [--lalibs]
27         [--cflags]
28         [--comp]
29 Libraries:
30         threads
31 EOF
32         exit $1
33 }
34
35 while test $# -gt 0; do
36     case "$1" in
37         -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
38         *) optarg= ;;
39     esac
40     
41     case $1 in
42         --prefix=*)
43             yazprefix=$optarg
44             ;;
45         --prefix)
46             echo $yazprefix
47             exit 0
48             ;;
49         --version)
50             echo $YAZVERSION
51             exit 0
52             ;;
53         --cflags)
54             yaz_echo_cflags=yes
55             ;;
56         --libs)
57             yaz_echo_libs=yes
58             ;;
59         --lalibs)
60             yaz_echo_lalibs=yes
61             ;;
62         --comp)
63             yaz_echo_comp=yes
64             ;;
65         threads)
66             lib_thread=yes
67             ;;
68         server)
69             lib_thread=yes
70             lib_server=yes
71             ;;
72         -*)
73             yaz_echo_help=yes
74             ;;
75     esac
76     shift
77 done
78
79 lyaz="-lyaz"
80 if test "$lib_server" = "yes"; then
81     lyaz="-lyaz_server $lyaz"
82 fi
83
84 YAZINC="@YAZ_CONFIG_CFLAGS@"
85
86 if test "$yaz_echo_source" = "yes"; then
87     YAZBIN=${yaz_build_root}/bin
88
89     YAZLIB="-L${yaz_build_root}/src/.libs $lyaz"
90     YAZLIB="$YAZLIB $yazextralibs"
91
92     YAZLALIB="${yaz_build_root}/src/libyaz.la"
93     if test "$lib_server" = "yes"; then
94         YAZLALIB="${yaz_build_root}/src/libyaz_server.la $YAZLALIB"
95     fi
96     YAZLALIB="$YAZLALIB $yazextralibs"
97
98     YAZINC="-I${yaz_src_root}/include $YAZINC"
99     YAZCOMP=${yaz_src_root}/util/yaz-asncomp
100 else
101     YAZBIN=${yazprefix}/bin
102     YAZCOMP=${yazprefix}/bin/yaz-asncomp
103
104     if test "$yazprefix" != "/usr"; then
105         YAZLIB="-L$yazprefix/lib"
106     fi
107     YAZLIB="$YAZLIB $lyaz $yazextralibs"
108     YAZLALIB=$YAZLIB
109     if test "$yazprefix" != "/usr"; then
110         YAZINC="-I$yazprefix/include $YAZINC"
111     fi
112 fi
113
114 if test "$lib_thread" = "yes"; then
115     YAZINC="$PTHREAD_CFLAGS $YAZINC"
116 fi
117
118 if test "$lib_thread" = "yes"; then
119     YAZLIB="$YAZLIB $PTHREAD_LIBS"
120 fi
121
122 if test "$yaz_echo_help" = "yes"; then
123     usage 1 1>&2
124 fi
125 if test "$yaz_echo_cflags" = "yes"; then
126     echo $YAZINC
127 fi
128 if test "$yaz_echo_libs" = "yes"; then
129     echo $YAZLIB
130 fi
131 if test "$yaz_echo_lalibs" = "yes"; then
132     echo $YAZLALIB
133 fi
134 if test "$yaz_echo_comp" = "yes"; then
135     echo $YAZCOMP
136 fi
137 # Local Variables:
138 # mode:shell-script
139 # sh-indentation: 2
140 # sh-basic-offset: 4
141 # End: