Fix various order for various linking steps. Add Tcl libs.
[idzebra-moved-to-github.git] / idzebra-config.in
1 #!/bin/sh
2 # $Id: idzebra-config.in,v 1.2 2004-08-30 21:36:53 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 extralibs="@YAZLIB@ @TCL_LIB@ @LIBS@"
14 extralalibs="@YAZLALIB@ @TCL_LIB@ @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="api rset recctrl dict isams isamc isamb data1 bfile dfa util"
82 fi
83
84 for m in $modules; do
85     d=$m
86     if test "$m" = "api"; then
87         d="index"
88     fi
89     if test "$idzebra_echo_source" = "yes"; then
90         IDZEBRALIB="$IDZEBRALIB -L${idzebra_build_root}/$d/.libs -lidzebra-$m"
91         IDZEBRALALIB="$IDZEBRALALIB ${idzebra_build_root}/$d/libidzebra-$m.la"
92     else
93         IDZEBRALIB="$IDZEBRALIB -lidzebra-$m"
94     fi
95 done
96
97 if test "$idzebra_echo_source" = "yes"; then
98     IDZEBRALIB="$IDZEBRALIB $extralibs"
99     IDZEBRALALIB="$IDZEBRALALIB $extralalibs"
100     IDZEBRAINC="$IDZEBRAINC -I${idzebra_src_root}/include"
101 else
102     if test "$idzebraprefix" != "/usr"; then
103         IDZEBRALIB="-L${idzebraprefix}/lib $IDZEBRALIB"
104         IDZEBRAINC="$IDZEBRAINC -I${idzebraprefix}/include"
105     fi
106     IDZEBRALIB="$IDZEBRALIB $extralibs"
107     IDZEBRALALIB="$IDZEBRALIB"
108 fi
109
110 if test "$idzebra_echo_help" = "yes"; then
111     usage 1 1>&2
112 fi
113 if test "$idzebra_echo_cflags" = "yes"; then
114     echo $IDZEBRAINC
115 fi
116 if test "$idzebra_echo_libs" = "yes"; then
117     echo $IDZEBRALIB
118 fi
119 if test "$idzebra_echo_lalibs" = "yes"; then
120     echo $IDZEBRALALIB
121 fi