Work on yaz-config creation. Added yaz.m4.
[yaz-moved-to-github.git] / yaz-config.in
1 #!/bin/sh
2 # $Id: yaz-config.in,v 1.2 2000-10-11 10:40:56 adam Exp $
3 yazprefix=@prefix@
4 yaz_echo_cflags=no
5 yaz_echo_libs=no
6 yaz_echo_help=no
7 yaz_echo_tabs=no
8 yaz_echo_source=yes
9 yaz_echo_lalibs=no
10 yaz_src_root=@YAZ_SRC_ROOT@
11
12 yazlibs="@LIBS@"
13 YAZVERSION=@VERSION@
14
15 usage()
16 {
17         cat <<EOF
18 Usage: yaz-config [OPTIONS] [LIBRARIES]
19 Options:
20         [--prefix[=DIR]]
21         [--version]
22         [--libs]
23         [--lalibs]
24         [--cflags]
25         [--tabs]
26 EOF
27         exit $1
28 }
29
30 #if test $# -eq 0; then
31 #       yaz_echo_help=yes
32 #fi
33
34 while test $# -gt 0; do
35   case "$1" in
36   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
37   *) optarg= ;;
38   esac
39
40   case $1 in
41     --prefix=*)
42       yazprefix=$optarg
43       ;;
44     --prefix)
45       echo $yazprefix
46       exit 0
47       ;;
48     --version)
49       echo $YAZVERSION
50       exit 0
51       ;;
52     --cflags)
53       yaz_echo_cflags=yes
54       ;;
55     --libs)
56       yaz_echo_libs=yes
57       ;;
58     --tabs)
59       yaz_echo_tabs=yes
60       ;;
61     --source)
62       yaz_echo_source=yes
63       ;;
64     --lalibs)
65       yaz_echo_lalibs=yes
66       ;;
67     -*)
68       yaz_echo_help=yes
69       ;;
70   esac
71   shift
72 done
73
74 if test "$yaz_echo_source" = "yes"; then
75     YAZTAB=${yaz_src_root}/tab
76     YAZBIN=${yaz_src_root}/bin
77     YAZLIB="-L${yaz_src_root}/lib/.libs -lyaz $yazlibs"
78     YAZLALIB="${yaz_src_root}/lib/libyaz.la $yazlibs"
79     YAZINC="-I${yaz_src_root}/include"
80 else
81     YAZTAB=$yazprefix/share/yaz/tab
82     YAZBIN=$yazprefix/bin
83
84     if test "$yazprefix" = "/usr"; then
85         YAZLIB="-lyaz $yazlibs"
86     else
87         YAZLIB="-L$yazprefix/lib -lyaz $yazlibs"
88     fi
89     YAZLALIB=$YAZLIB
90     if test "$yazprefix" = "/usr"; then
91         YAZINC=
92     else
93         YAZINC=-I$yazprefix/include
94     fi
95 fi
96
97 if test "$yaz_echo_help" = "yes"; then
98         usage 1 1>&2
99 fi
100 if test "$yaz_echo_cflags" = "yes"; then
101         echo $YAZINC
102 fi
103 if test "$yaz_echo_libs" = "yes"; then
104         echo $YAZLIB
105 fi
106 if test "$yaz_echo_tabs" = "yes"; then
107         echo $YAZTAB
108 fi
109 if test "$yaz_echo_lalibs" = "yes"; then
110         echo $YAZLALIB
111 fi