1#!/bin/sh
2
3cat <<'EOM'
4#!/bin/sh
5#
6# Copyright (c) 2000 - 2008 Kungliga Tekniska H��gskolan
7# (Royal Institute of Technology, Stockholm, Sweden). 
8# All rights reserved. 
9#
10# Redistribution and use in source and binary forms, with or without 
11# modification, are permitted provided that the following conditions 
12# are met: 
13#
14# 1. Redistributions of source code must retain the above copyright 
15#    notice, this list of conditions and the following disclaimer. 
16#
17# 2. Redistributions in binary form must reproduce the above copyright 
18#    notice, this list of conditions and the following disclaimer in the 
19#    documentation and/or other materials provided with the distribution. 
20#
21# 3. Neither the name of the Institute nor the names of its contributors 
22#    may be used to endorse or promote products derived from this software 
23#    without specific prior written permission. 
24#
25# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
26# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
27# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
28# ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
29# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
30# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
31# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
32# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
33# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
34# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
35# SUCH DAMAGE. 
36#
37
38do_all=no
39do_libs=no
40do_lib_deps=no
41do_cflags=no
42do_usage=no
43print_prefix=no
44print_exec_prefix=no
45library=
46lib_krb5=no
47lib_gssapi=no
48lib_kadm_client=no
49lib_kadm_server=no
50lib_kafs=no
51
52if test $# -eq 0; then
53  do_usage=yes
54  usage_exit=1
55fi
56
57for i in $*; do
58  case $i in
59  --help)
60    do_usage=yes
61    usage_exit=0
62    ;;
63  --all)
64    do_all=yes
65    ;;
66  --vendor)
67    echo "Heimdal"
68    exit 0;
69    ;;
70  --version)
71    echo "@PACKAGE@ @VERSION@"
72    exit 0
73    ;;
74  --prefix=*)
75    prefix=`echo $i | sed 's/^--prefix=//'`
76    ;;
77  --prefix)
78    print_prefix=yes
79    ;;
80  --exec-prefix=*)
81    exec_prefix=`echo $i | sed 's/^--exec-prefix=//'`
82    ;;
83  --exec-prefix)
84    print_exec_prefix=yes
85    ;;
86  --libs)
87    do_libs=yes
88    ;;
89  --deps)
90    do_lib_deps=yes
91    ;;
92  --cflags)
93    do_cflags=yes
94    ;;
95  krb5)
96    library=krb5
97    lib_krb5=yes
98    ;;
99  gssapi)
100    library=gssapi
101    lib_gssapi=yes
102    ;;
103  kadm-client)
104    library=kadm-client
105    lib_kadm_client=yes
106    ;;
107  kadm-server)
108    library=kadm-server
109    lib_kadm_server=yes
110    ;;
111  kafs)
112    library=kafs
113    lib_kafs=yes
114    ;;
115  *)
116    echo "unknown option: $i"
117    exit 1
118    ;;
119  esac
120done
121
122if test "$do_usage" = "yes"; then
123    echo "usage: $0 [options] [libraries]"
124    echo "options:   [--help]         show this message"
125    echo "           [--all]          display version, vendor, etc."
126    echo "           [--version]      display version information"
127    echo "           [--prefix]       display the prefix of Kerberos"
128    echo "           [--exec-prefix]  display the exec_prefix of Kerberos"
129    echo "           [--cflags]       display the CFLAGS required"
130    echo "           [--libs]         display the libraries required to link"
131    echo "           [--deps]         display the dependent libs required"
132    echo "                            for static linking"
133    echo
134    echo "libraries: krb5             Kerberos 5 applications"
135    echo "           gssapi           GSSAPI applications"
136    echo "           kadm-client      libkadm5 client"
137    echo "           kadm-server      libkadm5 server"
138    echo "           kafs             kafs"
139    exit $usage_exit
140fi
141
142if test X"$library" = X; then
143    lib_krb5=yes
144fi
145
146if test "$prefix" = ""; then
147  prefix=@prefix@
148fi
149if test "$exec_prefix" = ""; then
150  exec_prefix=@exec_prefix@
151fi
152
153libdir=@libdir@
154includedir=@includedir@
155
156if test "$do_all" = "yes"; then
157    echo "Version:     @PACKAGE@ @VERSION@"
158    echo "Vendor:      Heimdal"
159    echo "Prefix:      $prefix"
160    echo "Exec_prefix: $exec_prefix"
161    exit 0
162fi
163
164if test "$print_prefix" = "yes"; then
165    echo $prefix
166    exit 0
167fi
168
169if test "$print_exec_prefix" = "yes"; then
170    echo $exec_prefix
171    exit 0
172fi
173
174# The following rpath_flag setting code is distilled from MIT Kerberos'
175# src/config/shlib.conf.  Some of this seems ancient and likely to be
176# wrong in some cases, but right for all the cases we probably care
177# about.  Also, this will very likely be wrong depending on how the
178# caller will be doing link-edits (with what compiler-driver or
179# link-editor)!  There's no fixing this.
180#
181# In principle this doesn't belong here: application should instead use
182# krb5-config --libdir to get the directory to use for the rpath, then
183# workout the rpath flags on their own.  Of course, there's no --libdir
184# option...  And MIT's krb5-config does include rpath flags.
185#
186# Compatibility with MIT is the winning consideration for now.
187EOM
188
189case "@CANONICAL_HOST@" in
190alpha*-dec-osf*)
191  rpath_flag='-Wl,-rpath -Wl,';;
192*-*-hpux*)
193  rpath_flag='-Wl,+b,';;
194*-*-irix* | mips-*-netbsd*)
195  rpath_flag='-Wl,-rpath -Wl,';;
196*-*-netbsd* | *-*-openbsd* | *-*-solaris*)
197  rpath_flag='-R';;
198*-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-freebsd*)
199  rpath_flag='-Wl,--enable-new-dtags -Wl,-rpath -Wl,';;
200*-*-aix*)
201  rpath_flag='-Wl,-blibpath:';;
202*)
203rpath_flag=;;
204esac
205
206echo "rpath_flag='$rpath_flag'"
207
208cat <<'EOM'
209
210if test "$do_libs" = "yes"; then
211    deplibs=""
212    if test "$lib_gssapi" = yes; then
213	lib_flags="$lib_flags -lgssapi"
214	deplibs="$deplibs -lheimntlm"
215	if test X"$do_lib_deps" = Xyes; then
216	    lib_krb5=yes
217	fi
218    fi
219    if test "$lib_kadm_client" = yes; then
220	lib_flags="$lib_flags -lkadm5clnt"
221	if test X"$do_lib_deps" = Xyes; then
222	    lib_krb5=yes
223	fi
224    fi
225    if test "$lib_kadm_server" = yes; then
226	lib_flags="$lib_flags -lkadm5srv"
227	deplibs="$deplibs @LIB_dbopen@"
228	if test X"$do_lib_deps" = Xyes; then
229	    lib_krb5=yes
230	fi
231    fi
232    if test "$lib_kafs" = yes; then
233	lib_flags="$lib_flags -lkafs"
234	if test X"$do_lib_deps" = Xyes; then
235	    lib_krb5=yes
236	fi
237    fi
238    if test "$lib_krb5" = yes; then
239	lib_flags="$lib_flags -lkrb5"
240    fi
241    deplibs="$deplibs @LIB_pkinit@ -lcom_err"
242    deplibs="$deplibs @LIB_hcrypto_appl@ -lasn1 -lwind -lheimbase -lroken"
243    deplibs="$deplibs @LIB_crypt@ @PTHREAD_LIBADD@ @LIB_dlopen@"
244    deplibs="$deplibs @LIB_door_create@ @LIBS@"
245    if test X"$do_lib_deps" = X"yes"; then
246	lib_flags="$lib_flags $deplibs"
247    fi
248    if test X"$libdir" != X/usr/lib; then
249	lib_flags="-L${libdir} $lib_flags"
250	if test X"$rpath_flag" != X; then
251	    lib_flags="${rpath_flag}${libdir} $lib_flags"
252	fi
253    fi
254
255    echo ${lib_flags}
256fi
257if test "$do_cflags" = "yes"; then
258    cflags=""
259    if test X"${includedir}" != X/usr/include; then
260	cflags="-I${includedir} $cflags"
261    fi
262    echo $cflags
263fi
264
265exit 0
266EOM
267