1#!/bin/sh
2##
3##  OSSP sa - Socket Abstraction
4##  Copyright (c) 2001-2005 Ralf S. Engelschall <rse@engelschall.com>
5##  Copyright (c) 2001-2005 The OSSP Project <http://www.ossp.org/>
6##  Copyright (c) 2001-2005 Cable & Wireless <http://www.cw.com/>
7##
8##  This file is part of OSSP sa, a socket abstraction library which
9##  can be found at http://www.ossp.org/pkg/lib/sa/.
10##
11##  Permission to use, copy, modify, and distribute this software for
12##  any purpose with or without fee is hereby granted, provided that
13##  the above copyright notice and this permission notice appear in all
14##  copies.
15##
16##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
17##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
20##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27##  SUCH DAMAGE.
28##
29##  sa-config.in: SA library build utility
30##
31
32DIFS='
33'
34
35prefix="@prefix@"
36exec_prefix="@exec_prefix@"
37
38sa_prefix="$prefix"
39sa_exec_prefix="$exec_prefix"
40sa_bindir="@bindir@"
41sa_libdir="@libdir@"
42sa_includedir="@includedir@"
43sa_mandir="@mandir@"
44sa_datadir="@datadir@"
45sa_acdir="@datadir@/aclocal"
46sa_cflags="@CFLAGS@"
47sa_ldflags="@LDFLAGS@"
48sa_libs="@LIBS@"
49sa_version="@SA_VERSION_STR@"
50
51help=no
52version=no
53
54usage="sa-config"
55usage="$usage [--help] [--version] [--all]"
56usage="$usage [--prefix] [--exec-prefix] [--bindir] [--libdir] [--includedir] [--mandir] [--datadir] [--acdir]"
57usage="$usage [--cflags] [--ldflags] [--libs]"
58if [ $# -eq 0 ]; then
59    echo "sa-config:Error: Invalid option" 1>&2
60    echo "sa-config:Usage: $usage" 1>&2
61    exit 1
62fi
63output=''
64output_extra=''
65all=no
66prev=''
67OIFS="$IFS" IFS="$DIFS"
68for option
69do
70    if [ ".$prev" != . ]; then
71        eval "$prev=\$option"
72        prev=''
73        continue
74    fi
75    case "$option" in
76        -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
77           *) optarg='' ;;
78    esac
79    case "$option" in
80        --help|-h)
81            echo "Usage: $usage"
82            exit 0
83            ;;
84        --version|-v)
85            echo "OSSP sa $sa_version"
86            exit 0
87            ;;
88        --all)
89            all=yes
90            ;;
91        --prefix)
92            output="$output $sa_prefix"
93            ;;
94        --exec-prefix)
95            output="$output $sa_exec_prefix"
96            ;;
97        --bindir)
98            output="$output $sa_bindir"
99            ;;
100        --libdir)
101            output="$output $sa_libdir"
102            ;;
103        --includedir)
104            output="$output $sa_includedir"
105            ;;
106        --mandir)
107            output="$output $sa_mandir"
108            ;;
109        --datadir)
110            output="$output $sa_datadir"
111            ;;
112        --acdir)
113            output="$output $sa_acdir"
114            ;;
115        --cflags)
116            output="$output -I$sa_includedir"
117            output_extra="$output_extra $sa_cflags"
118            ;;
119        --ldflags)
120            output="$output -L$sa_libdir"
121            output_extra="$output_extra $sa_ldflags"
122            ;;
123        --libs)
124            output="$output -lsa"
125            output_extra="$output_extra $sa_libs"
126            ;;
127        * )
128            echo "sa-config:Error: Invalid option" 1>&2
129            echo "sa-config:Usage: $usage" 1>&2
130            exit 1;
131            ;;
132    esac
133done
134IFS="$OIFS"
135if [ ".$prev" != . ]; then
136    echo "sa-config:Error: missing argument to --`echo $prev | sed 's/_/-/g'`" 1>&2
137    exit 1
138fi
139if [ ".$output" != . ]; then
140    if [ ".$all" = .yes ]; then
141        output="$output $output_extra"
142    fi
143    echo $output
144fi
145
146