Simplify yazpp-config a bit
[yazpp-moved-to-github.git] / yazpp-config.in
1 #!/bin/sh
2 prefix=@prefix@
3 echo_cflags=no
4 echo_libs=no
5 echo_help=no
6 echo_tabs=no
7 echo_source=yes
8 echo_lalibs=no
9 src_root=@abs_top_srcdir@
10 build_root=@abs_top_builddir@
11 yazlibs="@YAZLIB@ @LIBS@"
12 yazlalibs="@YAZLALIB@ @LIBS@"
13 VERSION=@VERSION@
14
15 usage()
16 {
17         cat <<EOF
18 Usage: yazpp-config [OPTIONS] [LIBRARIES]
19 Options:
20         [--prefix[=DIR]]
21         [--version]
22         [--libs]
23         [--lalibs]
24         [--cflags]
25 EOF
26         exit $1
27 }
28
29 if test $# -eq 0; then
30         echo_help=yes
31 fi
32
33 while test $# -gt 0; do
34   case "$1" in
35   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
36   *) optarg= ;;
37   esac
38
39   case $1 in
40     --prefix=*)
41       prefix=$optarg
42       ;;
43     --prefix)
44       echo $prefix
45       exit 0
46       ;;
47     --version)
48       echo $VERSION
49       exit 0
50       ;;
51     --cflags)
52       echo_cflags=yes
53       ;;
54     --libs)
55       echo_libs=yes
56       ;;
57     --tabs)
58       echo_tabs=yes
59       ;;
60     --lalibs)
61       echo_lalibs=yes
62       ;;
63     -*)
64       echo_help=yes
65       ;;
66   esac
67   shift
68 done
69
70 libs_short="-lyazpp -lzoompp"
71
72 YAZPPINC="@YAZINC@"
73
74 if test "$echo_source" = "yes"; then
75     YAZPPLIB="-L${build_root}/src/.libs -lyazpp"
76     YAZPPLIB="$YAZPPLIB -L${build_root}/zoom/.libs -lzoompp"
77     YAZPPLIB="$YAZPPLIB $yazlibs"
78     YAZPPLALIB="${build_root}/src/libyazpp.la $yazlalibs"
79     YAZPPINC="-I${src_root}/include $YAZPPINC"
80 else
81
82     if test "$prefix" = "/usr"; then
83         YAZPPLIB="${libs_short} $yazlibs"
84     else
85         YAZPPLIB="-L${prefix}/lib ${libs_short} $yazlibs"
86     fi
87     YAZPPLALIB=$YAZPPLIB
88     if test "$prefix" != "/usr"; then
89         YAZPPINC="-I${prefix}/include $YAZPPINC"
90     fi
91 fi
92
93 if test "$echo_help" = "yes"; then
94         usage 1 1>&2
95 fi
96 if test "$echo_cflags" = "yes"; then
97         echo $YAZPPINC
98 fi
99 if test "$echo_libs" = "yes"; then
100         echo $YAZPPLIB
101 fi
102 if test "$echo_lalibs" = "yes"; then
103         echo $YAZPPLALIB
104 fi