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