Created idzebra-config that returns compiler flags and libs
[idzebra-moved-to-github.git] / idzebra-config.in
1 #!/bin/sh
2 # $Id: idzebra-config.in,v 1.1 2004-08-29 12:31:32 adam Exp $
3 idzebraprefix=@prefix@
4 idzebra_echo_cflags=no
5 idzebra_echo_libs=no
6 idzebra_echo_help=no
7 idzebra_echo_tabs=no
8 idzebra_echo_source=yes
9 idzebra_echo_lalibs=no
10 idzebra_src_root=@IDZEBRA_SRC_ROOT@
11 idzebra_build_root=@IDZEBRA_BUILD_ROOT@
12
13 yazlibs="@YAZLIB@ @LIBS@"
14 yazlalibs="@YAZLALIB@ @LIBS@"
15 IDZEBRAVERSION=@VERSION@
16
17 usage()
18 {
19         cat <<EOF
20 Usage: idzebra-config [OPTIONS] [LIBRARIES]
21 Options:
22         [--prefix[=DIR]]
23         [--version]
24         [--libs]
25         [--lalibs]
26         [--cflags]
27 EOF
28         exit $1
29 }
30
31 if test $# -eq 0; then
32         idzebra_echo_help=yes
33 fi
34
35 modules=""
36 while test $# -gt 0; do
37   case "$1" in
38   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
39   *) optarg= ;;
40   esac
41
42   case $1 in
43     --prefix=*)
44       idzebraprefix=$optarg
45       ;;
46     --prefix)
47       echo $idzebraprefix
48       exit 0
49       ;;
50     --version)
51       echo $IDZEBRAVERSION
52       exit 0
53       ;;
54     --cflags)
55       idzebra_echo_cflags=yes
56       ;;
57     --libs)
58       idzebra_echo_libs=yes
59       ;;
60     --tabs)
61       idzebra_echo_tabs=yes
62       ;;
63     --lalibs)
64       idzebra_echo_lalibs=yes
65       ;;
66     -*)
67       idzebra_echo_help=yes
68       ;;
69     *)
70       modules="$modules $1"
71       ;;
72   esac
73   shift
74 done
75
76 IDZEBRALIB=""
77 IDZEBRALALIB=""
78 IDZEBRAINC="@YAZINC@"
79
80 if test -z "$modules"; then
81     modules="util bfile dfa dict isamc isamb isams data1 recctrl rset api"
82 fi
83 for m in $modules; do
84     d=$m
85     if test "$m" = "api"; then
86         d="index"
87     fi
88     if test "$idzebra_echo_source" = "yes"; then
89         IDZEBRALIB="$IDZEBRALIB -L${idzebra_build_root}/$d/.libs -lidzebra-$m"
90         IDZEBRALALIB="$IDZEBRALALIB ${idzebra_build_root}/$d/libidzebra-$m.la"
91     else
92         IDZEBRALIB="$IDZEBRALIB -lidzebra-$m"
93     fi
94 done
95
96 if test "$idzebra_echo_source" = "yes"; then
97     IDZEBRALIB="$IDZEBRALIB $yazlibs"
98     IDZEBRALALIB="$IDZEBRALALIB $yazlalibs"
99     IDZEBRAINC="$IDZEBRAINC -I${idzebra_src_root}/include"
100 else
101     if test "$idzebraprefix" != "/usr"; then
102         IDZEBRALIB="-L${idzebraprefix}/lib $IDZEBRALIB"
103         IDZEBRAINC="$IDZEBRAINC -I${idzebraprefix}/include"
104     fi
105     IDZEBRALIB="$IDZEBRALIB $yazlibs"
106     IDZEBRALALIB="$IDZEBRALIB"
107 fi
108
109 if test "$idzebra_echo_help" = "yes"; then
110         usage 1 1>&2
111 fi
112 if test "$idzebra_echo_cflags" = "yes"; then
113         echo $IDZEBRAINC
114 fi
115 if test "$idzebra_echo_libs" = "yes"; then
116         echo $IDZEBRALIB
117 fi
118 if test "$idzebra_echo_lalibs" = "yes"; then
119         echo $IDZEBRALALIB
120 fi